Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | #ifndef REMOVE_PKT_LOG |
| 29 | #ifndef _PKTLOG_FMT_H_ |
| 30 | #define _PKTLOG_FMT_H_ |
| 31 | |
| 32 | #define CUR_PKTLOG_VER 10010 /* Packet log version */ |
| 33 | #define PKTLOG_MAGIC_NUM 7735225 |
| 34 | |
| 35 | #ifdef __linux__ |
| 36 | #define PKTLOG_PROC_DIR "ath_pktlog" |
| 37 | #define PKTLOG_PROC_SYSTEM "system" |
| 38 | #define WLANDEV_BASENAME "cld" |
| 39 | #endif |
| 40 | |
| 41 | #ifdef WIN32 |
| 42 | #pragma pack(push, pktlog_fmt, 1) |
| 43 | #define __ATTRIB_PACK |
| 44 | #elif defined(__EFI__) |
| 45 | #define __ATTRIB_PACK |
| 46 | #else |
| 47 | #ifndef __ATTRIB_PACK |
| 48 | #define __ATTRIB_PACK __attribute__ ((packed)) |
| 49 | #endif |
| 50 | #endif |
| 51 | #include <a_types.h> |
| 52 | /* |
| 53 | * Each packet log entry consists of the following fixed length header |
| 54 | * followed by variable length log information determined by log_type |
| 55 | */ |
| 56 | |
| 57 | struct ath_pktlog_hdr { |
| 58 | uint16_t flags; |
| 59 | uint16_t missed_cnt; |
| 60 | uint16_t log_type; |
| 61 | uint16_t size; |
| 62 | uint32_t timestamp; |
| 63 | #ifdef HELIUMPLUS |
| 64 | uint32_t type_specific_data; |
| 65 | #endif |
| 66 | } __ATTRIB_PACK; |
| 67 | |
| 68 | #define ATH_PKTLOG_HDR_FLAGS_MASK 0xffff |
| 69 | #define ATH_PKTLOG_HDR_FLAGS_SHIFT 0 |
| 70 | #define ATH_PKTLOG_HDR_FLAGS_OFFSET 0 |
| 71 | #define ATH_PKTLOG_HDR_MISSED_CNT_MASK 0xffff0000 |
| 72 | #define ATH_PKTLOG_HDR_MISSED_CNT_SHIFT 16 |
| 73 | #define ATH_PKTLOG_HDR_MISSED_CNT_OFFSET 0 |
| 74 | #define ATH_PKTLOG_HDR_LOG_TYPE_MASK 0xffff |
| 75 | #define ATH_PKTLOG_HDR_LOG_TYPE_SHIFT 0 |
| 76 | #define ATH_PKTLOG_HDR_LOG_TYPE_OFFSET 1 |
| 77 | #define ATH_PKTLOG_HDR_SIZE_MASK 0xffff0000 |
| 78 | #define ATH_PKTLOG_HDR_SIZE_SHIFT 16 |
| 79 | #define ATH_PKTLOG_HDR_SIZE_OFFSET 1 |
| 80 | #define ATH_PKTLOG_HDR_TIMESTAMP_OFFSET 2 |
| 81 | #define ATH_PKTLOG_HDR_TYPE_SPECIFIC_DATA_OFFSET 3 |
| 82 | |
| 83 | /** |
| 84 | * enum - Pktlog flag field details |
| 85 | * packet origin [1:0] |
| 86 | * 00 - Local |
| 87 | * 01 - Remote |
| 88 | * 10 - Unknown/Not applicable |
| 89 | * 11 - Reserved |
| 90 | * reserved [15:2] |
| 91 | */ |
| 92 | enum { |
| 93 | PKTLOG_FLG_FRM_TYPE_LOCAL_S = 0, |
| 94 | PKTLOG_FLG_FRM_TYPE_REMOTE_S, |
| 95 | PKTLOG_FLG_FRM_TYPE_CLONE_S, |
| 96 | PKTLOG_FLG_FRM_TYPE_CBF_S, |
| 97 | PKTLOG_FLG_FRM_TYPE_UNKNOWN_S |
| 98 | }; |
| 99 | |
| 100 | #define PHFLAGS_INTERRUPT_CONTEXT 0x80000000 |
| 101 | |
| 102 | /* Masks for setting pktlog events filters */ |
| 103 | #define ATH_PKTLOG_TX 0x000000001 |
| 104 | #define ATH_PKTLOG_RX 0x000000002 |
| 105 | #define ATH_PKTLOG_RCFIND 0x000000004 |
| 106 | #define ATH_PKTLOG_RCUPDATE 0x000000008 |
| 107 | #define ATH_PKTLOG_ANI 0x000000010 |
| 108 | #define ATH_PKTLOG_TEXT 0x000000020 |
| 109 | #define ATH_PKTLOG_PHYERR 0x000000040 |
| 110 | #define ATH_PKTLOG_PROMISC 0x000000080 |
| 111 | |
| 112 | /* Types of packet log events */ |
| 113 | #define PKTLOG_TYPE_TX_CTRL 1 |
| 114 | #define PKTLOG_TYPE_TX_STAT 2 |
| 115 | #define PKTLOG_TYPE_TX_MSDU_ID 3 |
| 116 | #define PKTLOG_TYPE_TX_FRM_HDR 4 |
| 117 | #define PKTLOG_TYPE_RX_STAT 5 |
| 118 | #define PKTLOG_TYPE_RC_FIND 6 |
| 119 | #define PKTLOG_TYPE_RC_UPDATE 7 |
| 120 | #define PKTLOG_TYPE_TX_VIRT_ADDR 8 |
| 121 | #define PKTLOG_TYPE_MAX 9 |
| 122 | |
| 123 | #define PKTLOG_MAX_TXCTL_WORDS 57 /* +2 words for bitmap */ |
| 124 | #define PKTLOG_MAX_TXSTATUS_WORDS 32 |
| 125 | #define PKTLOG_MAX_PROTO_WORDS 16 |
| 126 | #define PKTLOG_MAX_RXDESC_WORDS 62 |
| 127 | |
| 128 | struct txctl_frm_hdr { |
| 129 | uint16_t framectrl; /* frame control field from header */ |
| 130 | uint16_t seqctrl; /* frame control field from header */ |
| 131 | uint16_t bssid_tail; /* last two octets of bssid */ |
| 132 | uint16_t sa_tail; /* last two octets of SA */ |
| 133 | uint16_t da_tail; /* last two octets of DA */ |
| 134 | uint16_t resvd; |
| 135 | }; |
| 136 | |
| 137 | #if defined(HELIUMPLUS) |
| 138 | /* Peregrine 11ac based */ |
| 139 | #define MAX_PKT_INFO_MSDU_ID 1 |
| 140 | #else |
| 141 | /* Peregrine 11ac based */ |
| 142 | #define MAX_PKT_INFO_MSDU_ID 192 |
| 143 | #endif /* defined(HELIUMPLUS) */ |
| 144 | |
| 145 | /* |
| 146 | * msdu_id_info_t is defined for reference only |
| 147 | */ |
| 148 | struct msdu_id_info { |
| 149 | uint32_t num_msdu; |
| 150 | uint8_t bound_bmap[(MAX_PKT_INFO_MSDU_ID + 7)>>3]; |
| 151 | /* TODO: |
| 152 | * Convert the id's to uint32_t |
| 153 | * Reduces computation in the driver code |
| 154 | */ |
| 155 | uint16_t id[MAX_PKT_INFO_MSDU_ID]; |
| 156 | } __ATTRIB_PACK; |
| 157 | #define MSDU_ID_INFO_NUM_MSDU_OFFSET 0 /* char offset */ |
| 158 | #define MSDU_ID_INFO_BOUND_BM_OFFSET offsetof(struct msdu_id_info, bound_bmap) |
| 159 | #define MSDU_ID_INFO_ID_OFFSET offsetof(struct msdu_id_info, id) |
| 160 | |
| 161 | |
| 162 | struct ath_pktlog_txctl { |
| 163 | struct ath_pktlog_hdr pl_hdr; |
| 164 | /* struct txctl_frm_hdr frm_hdr; */ |
| 165 | void *txdesc_hdr_ctl; /* frm_hdr + Tx descriptor words */ |
| 166 | struct { |
| 167 | struct txctl_frm_hdr frm_hdr; |
| 168 | uint32_t txdesc_ctl[PKTLOG_MAX_TXCTL_WORDS]; |
| 169 | /* uint32_t *proto_hdr; / * protocol header (variable length!) * / */ |
| 170 | /* uint32_t *misc; / * Can be used for HT specific or other misc info * / */ |
| 171 | } priv; |
| 172 | } __ATTRIB_PACK; |
| 173 | |
| 174 | struct ath_pktlog_tx_status { |
| 175 | struct ath_pktlog_hdr pl_hdr; |
| 176 | void *ds_status; |
| 177 | int32_t misc[0]; /* Can be used for HT specific or other misc info */ |
| 178 | } __ATTRIB_PACK; |
| 179 | |
| 180 | struct ath_pktlog_msdu_info { |
| 181 | struct ath_pktlog_hdr pl_hdr; |
| 182 | void *ath_msdu_info; |
| 183 | A_UINT32 num_msdu; |
| 184 | struct { |
| 185 | /* |
| 186 | * Provision to add more information fields |
| 187 | */ |
| 188 | struct msdu_info_t { |
| 189 | A_UINT32 num_msdu; |
| 190 | A_UINT8 bound_bmap[MAX_PKT_INFO_MSDU_ID >> 3]; |
| 191 | } msdu_id_info; |
| 192 | /* |
| 193 | * array of num_msdu |
| 194 | * Static implementation will consume unwanted memory |
| 195 | * Need to split the pktlog_get_buf to get the buffer pointer only |
| 196 | */ |
| 197 | uint16_t msdu_len[MAX_PKT_INFO_MSDU_ID]; |
| 198 | } priv; |
| 199 | size_t priv_size; |
| 200 | |
| 201 | } __ATTRIB_PACK; |
| 202 | |
| 203 | struct ath_pktlog_rx_info { |
| 204 | struct ath_pktlog_hdr pl_hdr; |
| 205 | void *rx_desc; |
| 206 | } __ATTRIB_PACK; |
| 207 | |
| 208 | struct ath_pktlog_rc_find { |
| 209 | struct ath_pktlog_hdr pl_hdr; |
| 210 | void *rcFind; |
| 211 | } __ATTRIB_PACK; |
| 212 | |
| 213 | struct ath_pktlog_rc_update { |
| 214 | struct ath_pktlog_hdr pl_hdr; |
| 215 | void *txRateCtrl; /* rate control state proper */ |
| 216 | } __ATTRIB_PACK; |
| 217 | |
| 218 | #ifdef WIN32 |
| 219 | #pragma pack(pop, pktlog_fmt) |
| 220 | #endif |
| 221 | #ifdef __ATTRIB_PACK |
| 222 | #undef __ATTRIB_PACK |
| 223 | #endif /* __ATTRIB_PACK */ |
| 224 | |
| 225 | /* |
| 226 | * The following header is included in the beginning of the file, |
| 227 | * followed by log entries when the log buffer is read through procfs |
| 228 | */ |
| 229 | |
| 230 | struct ath_pktlog_bufhdr { |
| 231 | uint32_t magic_num; /* Used by post processing scripts */ |
| 232 | uint32_t version; /* Set to CUR_PKTLOG_VER */ |
| 233 | }; |
| 234 | |
| 235 | struct ath_pktlog_buf { |
| 236 | struct ath_pktlog_bufhdr bufhdr; |
| 237 | int32_t rd_offset; |
| 238 | volatile int32_t wr_offset; |
| 239 | /* Whenever this bytes written value croses 4K bytes, |
| 240 | * logging will be triggered |
| 241 | */ |
| 242 | int32_t bytes_written; |
| 243 | /* Index of the messages sent to userspace */ |
| 244 | uint32_t msg_index; |
| 245 | /* Offset for read */ |
| 246 | loff_t offset; |
| 247 | char log_data[0]; |
| 248 | }; |
| 249 | |
| 250 | #define PKTLOG_MOV_RD_IDX(_rd_offset, _log_buf, _log_size) \ |
| 251 | do { \ |
| 252 | if((_rd_offset + sizeof(struct ath_pktlog_hdr) + \ |
| 253 | ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \ |
| 254 | (_rd_offset)))->size) <= _log_size) { \ |
| 255 | _rd_offset = ((_rd_offset) + sizeof(struct ath_pktlog_hdr) + \ |
| 256 | ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \ |
| 257 | (_rd_offset)))->size); \ |
| 258 | } else { \ |
| 259 | _rd_offset = ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \ |
| 260 | (_rd_offset)))->size; \ |
| 261 | } \ |
| 262 | (_rd_offset) = (((_log_size) - (_rd_offset)) >= \ |
| 263 | sizeof(struct ath_pktlog_hdr)) ? _rd_offset : 0; \ |
| 264 | } while(0) |
| 265 | |
| 266 | #endif /* _PKTLOG_FMT_H_ */ |
| 267 | #endif /* REMOVE_PKT_LOG */ |