pktlog_ac_fmt.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. /*
  2. * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _PKTLOG_FMT_H_
  19. #define _PKTLOG_FMT_H_
  20. #ifndef REMOVE_PKT_LOG
  21. #define CUR_PKTLOG_VER 10010 /* Packet log version */
  22. #define PKTLOG_MAGIC_NUM 7735225
  23. #ifdef __linux__
  24. #ifdef MULTI_IF_NAME
  25. #define PKTLOG_PROC_DIR "ath_pktlog" MULTI_IF_NAME
  26. #define WLANDEV_BASENAME "cld" MULTI_IF_NAME
  27. #else
  28. #define PKTLOG_PROC_DIR "ath_pktlog"
  29. #define WLANDEV_BASENAME "cld"
  30. #endif
  31. #endif
  32. #define PKTLOG_PROC_SYSTEM "system"
  33. #ifdef WIN32
  34. #pragma pack(push, pktlog_fmt, 1)
  35. #define __ATTRIB_PACK
  36. #elif defined(__EFI__)
  37. #define __ATTRIB_PACK
  38. #else
  39. #ifndef __ATTRIB_PACK
  40. #define __ATTRIB_PACK __attribute__ ((packed))
  41. #endif
  42. #endif
  43. #include <a_types.h>
  44. /*
  45. * Each packet log entry consists of the following fixed length header
  46. * followed by variable length log information determined by log_type
  47. */
  48. struct ath_pktlog_hdr {
  49. uint16_t flags;
  50. uint16_t missed_cnt;
  51. #ifdef HELIUMPLUS
  52. uint8_t log_type;
  53. uint8_t macId;
  54. #else
  55. uint16_t log_type;
  56. #endif
  57. uint16_t size;
  58. uint32_t timestamp;
  59. #ifdef PKTLOG_HAS_SPECIFIC_DATA
  60. uint32_t type_specific_data;
  61. #endif
  62. } __ATTRIB_PACK;
  63. #define ATH_PKTLOG_HDR_FLAGS_MASK 0xffff
  64. #define ATH_PKTLOG_HDR_FLAGS_SHIFT 0
  65. #define ATH_PKTLOG_HDR_FLAGS_OFFSET 0
  66. #define ATH_PKTLOG_HDR_MISSED_CNT_MASK 0xffff0000
  67. #define ATH_PKTLOG_HDR_MISSED_CNT_SHIFT 16
  68. #define ATH_PKTLOG_HDR_MISSED_CNT_OFFSET 0
  69. #ifdef HELIUMPLUS
  70. #define ATH_PKTLOG_HDR_LOG_TYPE_MASK 0x00ff
  71. #define ATH_PKTLOG_HDR_LOG_TYPE_SHIFT 0
  72. #define ATH_PKTLOG_HDR_LOG_TYPE_OFFSET 1
  73. #define ATH_PKTLOG_HDR_MAC_ID_MASK 0xff00
  74. #define ATH_PKTLOG_HDR_MAC_ID_SHIFT 8
  75. #define ATH_PKTLOG_HDR_MAC_ID_OFFSET 1
  76. #else
  77. #define ATH_PKTLOG_HDR_LOG_TYPE_MASK 0xffff
  78. #define ATH_PKTLOG_HDR_LOG_TYPE_SHIFT 0
  79. #define ATH_PKTLOG_HDR_LOG_TYPE_OFFSET 1
  80. #endif
  81. #define ATH_PKTLOG_HDR_SIZE_MASK 0xffff0000
  82. #define ATH_PKTLOG_HDR_SIZE_SHIFT 16
  83. #define ATH_PKTLOG_HDR_SIZE_OFFSET 1
  84. #define ATH_PKTLOG_HDR_TIMESTAMP_OFFSET 2
  85. #define ATH_PKTLOG_HDR_TYPE_SPECIFIC_DATA_OFFSET 3
  86. /**
  87. * enum - Pktlog flag field details
  88. * packet origin [1:0]
  89. * 00 - Local
  90. * 01 - Remote
  91. * 10 - Unknown/Not applicable
  92. * 11 - Reserved
  93. * reserved [15:2]
  94. */
  95. enum {
  96. PKTLOG_FLG_FRM_TYPE_LOCAL_S = 0,
  97. PKTLOG_FLG_FRM_TYPE_REMOTE_S,
  98. PKTLOG_FLG_FRM_TYPE_CLONE_S,
  99. PKTLOG_FLG_FRM_TYPE_CBF_S,
  100. PKTLOG_FLG_FRM_TYPE_UNKNOWN_S
  101. };
  102. #define PHFLAGS_INTERRUPT_CONTEXT 0x80000000
  103. /* Masks for setting pktlog events filters */
  104. #define ATH_PKTLOG_TX 0x000000001
  105. #define ATH_PKTLOG_RX 0x000000002
  106. #define ATH_PKTLOG_RCFIND 0x000000004
  107. #define ATH_PKTLOG_RCUPDATE 0x000000008
  108. #define ATH_PKTLOG_ANI 0x000000010
  109. #define ATH_PKTLOG_TEXT 0x000000020
  110. #define ATH_PKTLOG_PHYERR 0x000000040
  111. #define ATH_PKTLOG_PROMISC 0x000000080
  112. #define ATH_PKTLOG_SW_EVENT 0x000000100
  113. /* WIN defns */
  114. #define ATH_PKTLOG_H_INFO 0x000000200
  115. #define ATH_PKTLOG_STEERING 0x000000400
  116. #define ATH_PKTLOG_REMOTE_LOGGING_ENABLE 0x000000800
  117. #define ATH_PKTLOG_TX_CAPTURE_ENABLE 0x000001000
  118. #define ATH_PKTLOG_LITE_T2H 0x000002000
  119. #define ATH_PKTLOG_LITE_RX 0x000004000
  120. /* Types of packet log events */
  121. #define PKTLOG_TYPE_TX_CTRL 1
  122. #define PKTLOG_TYPE_TX_STAT 2
  123. #define PKTLOG_TYPE_TX_MSDU_ID 3
  124. #define PKTLOG_TYPE_TX_FRM_HDR 4
  125. #define PKTLOG_TYPE_RX_STAT 5
  126. #define PKTLOG_TYPE_RC_FIND 6
  127. #define PKTLOG_TYPE_RC_UPDATE 7
  128. #define PKTLOG_TYPE_TX_VIRT_ADDR 8
  129. #define PKTLOG_TYPE_SMART_ANTENNA 9
  130. #define PKTLOG_TYPE_SW_EVENT 10
  131. #define PKTLOG_TYPE_PKT_DUMP 11
  132. /* From WIN definations */
  133. #define PKTLOG_TYPE_LITE_T2H 23
  134. #define PKTLOG_TYPE_LITE_RX 24
  135. #define PKTLOG_TYPE_MAX 25
  136. #define PKTLOG_MAX_TXCTL_WORDS 57 /* +2 words for bitmap */
  137. #define PKTLOG_MAX_TXSTATUS_WORDS 32
  138. #define PKTLOG_MAX_PROTO_WORDS 16
  139. #define PKTLOG_MAX_RXDESC_WORDS 62
  140. #define PKTLOG_HDR_SIZE_16 0x8000
  141. struct txctl_frm_hdr {
  142. uint16_t framectrl; /* frame control field from header */
  143. uint16_t seqctrl; /* frame control field from header */
  144. uint16_t bssid_tail; /* last two octets of bssid */
  145. uint16_t sa_tail; /* last two octets of SA */
  146. uint16_t da_tail; /* last two octets of DA */
  147. uint16_t resvd;
  148. };
  149. #if defined(HELIUMPLUS)
  150. /* Peregrine 11ac based */
  151. #define MAX_PKT_INFO_MSDU_ID 1
  152. #else
  153. /* Peregrine 11ac based */
  154. #define MAX_PKT_INFO_MSDU_ID 192
  155. #endif /* defined(HELIUMPLUS) */
  156. /*
  157. * msdu_id_info_t is defined for reference only
  158. */
  159. struct msdu_id_info {
  160. uint32_t num_msdu;
  161. uint8_t bound_bmap[(MAX_PKT_INFO_MSDU_ID + 7)>>3];
  162. /* TODO:
  163. * Convert the id's to uint32_t
  164. * Reduces computation in the driver code
  165. */
  166. uint16_t id[MAX_PKT_INFO_MSDU_ID];
  167. } __ATTRIB_PACK;
  168. #define MSDU_ID_INFO_NUM_MSDU_OFFSET 0 /* char offset */
  169. #define MSDU_ID_INFO_BOUND_BM_OFFSET offsetof(struct msdu_id_info, bound_bmap)
  170. #define MSDU_ID_INFO_ID_OFFSET offsetof(struct msdu_id_info, id)
  171. struct ath_pktlog_txctl {
  172. struct ath_pktlog_hdr pl_hdr;
  173. /* struct txctl_frm_hdr frm_hdr; */
  174. void *txdesc_hdr_ctl; /* frm_hdr + Tx descriptor words */
  175. struct {
  176. struct txctl_frm_hdr frm_hdr;
  177. uint32_t txdesc_ctl[PKTLOG_MAX_TXCTL_WORDS];
  178. /* uint32_t *proto_hdr; / * protocol header (variable length!) * / */
  179. /* uint32_t *misc; / * Can be used for HT specific or other misc info * / */
  180. } priv;
  181. } __ATTRIB_PACK;
  182. struct ath_pktlog_tx_status {
  183. struct ath_pktlog_hdr pl_hdr;
  184. void *ds_status;
  185. int32_t misc[0]; /* Can be used for HT specific or other misc info */
  186. } __ATTRIB_PACK;
  187. struct ath_pktlog_msdu_info {
  188. struct ath_pktlog_hdr pl_hdr;
  189. void *ath_msdu_info;
  190. A_UINT32 num_msdu;
  191. struct {
  192. /*
  193. * Provision to add more information fields
  194. */
  195. struct msdu_info_t {
  196. A_UINT32 num_msdu;
  197. A_UINT8 bound_bmap[MAX_PKT_INFO_MSDU_ID >> 3];
  198. } msdu_id_info;
  199. /*
  200. * array of num_msdu
  201. * Static implementation will consume unwanted memory
  202. * Need to split the pktlog_get_buf to get the buffer pointer only
  203. */
  204. uint16_t msdu_len[MAX_PKT_INFO_MSDU_ID];
  205. } priv;
  206. size_t priv_size;
  207. } __ATTRIB_PACK;
  208. struct ath_pktlog_rx_info {
  209. struct ath_pktlog_hdr pl_hdr;
  210. void *rx_desc;
  211. } __ATTRIB_PACK;
  212. struct ath_pktlog_rc_find {
  213. struct ath_pktlog_hdr pl_hdr;
  214. void *rcFind;
  215. } __ATTRIB_PACK;
  216. struct ath_pktlog_sw_event {
  217. struct ath_pktlog_hdr pl_hdr;
  218. void *sw_event;
  219. } __ATTRIB_PACK;
  220. struct ath_pktlog_rc_update {
  221. struct ath_pktlog_hdr pl_hdr;
  222. void *txRateCtrl; /* rate control state proper */
  223. } __ATTRIB_PACK;
  224. #ifdef WIN32
  225. #pragma pack(pop, pktlog_fmt)
  226. #endif
  227. #ifdef __ATTRIB_PACK
  228. #undef __ATTRIB_PACK
  229. #endif /* __ATTRIB_PACK */
  230. /*
  231. * The following header is included in the beginning of the file,
  232. * followed by log entries when the log buffer is read through procfs
  233. */
  234. struct ath_pktlog_bufhdr {
  235. uint32_t magic_num; /* Used by post processing scripts */
  236. uint32_t version; /* Set to CUR_PKTLOG_VER */
  237. };
  238. struct ath_pktlog_buf {
  239. struct ath_pktlog_bufhdr bufhdr;
  240. int32_t rd_offset;
  241. volatile int32_t wr_offset;
  242. /* Whenever this bytes written value croses 4K bytes,
  243. * logging will be triggered
  244. */
  245. int32_t bytes_written;
  246. /* Index of the messages sent to userspace */
  247. uint32_t msg_index;
  248. /* Offset for read */
  249. loff_t offset;
  250. char log_data[0];
  251. };
  252. #define PKTLOG_MOV_RD_IDX(_rd_offset, _log_buf, _log_size) \
  253. do { \
  254. if ((_rd_offset + sizeof(struct ath_pktlog_hdr) + \
  255. ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
  256. (_rd_offset)))->size) <= _log_size) { \
  257. _rd_offset = ((_rd_offset) + sizeof(struct ath_pktlog_hdr) + \
  258. ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
  259. (_rd_offset)))->size); \
  260. } else { \
  261. _rd_offset = ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
  262. (_rd_offset)))->size; \
  263. } \
  264. (_rd_offset) = (((_log_size) - (_rd_offset)) >= \
  265. sizeof(struct ath_pktlog_hdr)) ? _rd_offset : 0; \
  266. } while (0)
  267. #endif /* REMOVE_PKT_LOG */
  268. /**
  269. * enum pkt_type - packet type
  270. * @START_MONITOR: indicates parser to start packetdump parsing
  271. * @STOP_MONITOR: indicates parser to stop packetdump parsing
  272. * @TX_MGMT_PKT: TX management Packet
  273. * @TX_DATA_PKT: TX data Packet
  274. * @RX_MGMT_PKT: RX management Packet
  275. * @RX_DATA_PKT: RX data Packet
  276. *
  277. * This enum has packet types
  278. */
  279. enum pkt_type {
  280. START_MONITOR = 1,
  281. STOP_MONITOR,
  282. TX_MGMT_PKT,
  283. TX_DATA_PKT,
  284. RX_MGMT_PKT,
  285. RX_DATA_PKT,
  286. };
  287. /**
  288. * enum tx_pkt_fate - tx packet fate
  289. * @TX_PKT_FATE_ACKED: Sent over air and ACKed
  290. * @TX_PKT_FATE_SENT: Sent over air but not ACKed.
  291. * @TX_PKT_FATE_FW_QUEUED: Queued within firmware,
  292. * but not yet sent over air
  293. * @TX_PKT_FATE_FW_DROP_INVALID: Dropped by firmware as invalid.
  294. * E.g. bad source address, bad checksum, or invalid for current state.
  295. * @TX_PKT_FATE_FW_DROP_NOBUFS: Dropped by firmware due
  296. * to lack of buffer space
  297. * @TX_PKT_FATE_FW_DROP_OTHER: Dropped by firmware for any other
  298. * reason. Includes frames that were sent by driver to firmware, but
  299. * unaccounted for by firmware.
  300. * @TX_PKT_FATE_DRV_QUEUED: Queued within driver, not yet sent to firmware.
  301. * @TX_PKT_FATE_DRV_DROP_INVALID: Dropped by driver as invalid.
  302. * E.g. bad source address, or invalid for current state.
  303. * @TX_PKT_FATE_DRV_DROP_NOBUFS: Dropped by driver due to lack of buffer space
  304. * @TX_PKT_FATE_DRV_DROP_OTHER: Dropped by driver for any other reason.
  305. * E.g. out of buffers.
  306. *
  307. * This enum has packet fate types
  308. */
  309. enum tx_pkt_fate {
  310. TX_PKT_FATE_ACKED,
  311. TX_PKT_FATE_SENT,
  312. TX_PKT_FATE_FW_QUEUED,
  313. TX_PKT_FATE_FW_DROP_INVALID,
  314. TX_PKT_FATE_FW_DROP_NOBUFS,
  315. TX_PKT_FATE_FW_DROP_OTHER,
  316. TX_PKT_FATE_DRV_QUEUED,
  317. TX_PKT_FATE_DRV_DROP_INVALID,
  318. TX_PKT_FATE_DRV_DROP_NOBUFS,
  319. TX_PKT_FATE_DRV_DROP_OTHER,
  320. };
  321. /**
  322. * enum rx_pkt_fate - rx packet fate
  323. * @RX_PKT_FATE_SUCCESS: Valid and delivered to
  324. * network stack (e.g., netif_rx()).
  325. * @RX_PKT_FATE_FW_QUEUED: Queued within firmware,
  326. * but not yet sent to driver.
  327. * @RX_PKT_FATE_FW_DROP_FILTER: Dropped by firmware
  328. * due to host-programmable filters.
  329. * @RX_PKT_FATE_FW_DROP_INVALID: Dropped by firmware
  330. * as invalid. E.g. bad checksum, decrypt failed, or invalid for current state.
  331. * @RX_PKT_FATE_FW_DROP_NOBUFS: Dropped by firmware
  332. * due to lack of buffer space.
  333. * @RX_PKT_FATE_FW_DROP_OTHER: Dropped by firmware
  334. * for any other reason.
  335. * @RX_PKT_FATE_DRV_QUEUED: Queued within driver,
  336. * not yet delivered to network stack.
  337. * @RX_PKT_FATE_DRV_DROP_FILTER: Dropped by driver
  338. * due to filter rules.
  339. * @RX_PKT_FATE_DRV_DROP_INVALID: Dropped by driver as invalid.
  340. * E.g. not permitted in current state.
  341. * @RX_PKT_FATE_DRV_DROP_NOBUFS: Dropped by driver
  342. * due to lack of buffer space.
  343. * @RX_PKT_FATE_DRV_DROP_OTHER: Dropped by driver for any other reason.
  344. *
  345. * This enum has packet fate types
  346. */
  347. enum rx_pkt_fate {
  348. RX_PKT_FATE_SUCCESS,
  349. RX_PKT_FATE_FW_QUEUED,
  350. RX_PKT_FATE_FW_DROP_FILTER,
  351. RX_PKT_FATE_FW_DROP_INVALID,
  352. RX_PKT_FATE_FW_DROP_NOBUFS,
  353. RX_PKT_FATE_FW_DROP_OTHER,
  354. RX_PKT_FATE_DRV_QUEUED,
  355. RX_PKT_FATE_DRV_DROP_FILTER,
  356. RX_PKT_FATE_DRV_DROP_INVALID,
  357. RX_PKT_FATE_DRV_DROP_NOBUFS,
  358. RX_PKT_FATE_DRV_DROP_OTHER,
  359. };
  360. #endif /* _PKTLOG_FMT_H_ */