pktlog_ac_fmt.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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. /* Command to process Monitor status ring (Rx) buffers */
  133. #define PKTLOG_TYPE_RX_STATBUF 22
  134. /* Command to process PPDU Tx buffers from CE */
  135. #define PKTLOG_TYPE_LITE_T2H 23
  136. /* Command to process PPDU Rx buffers from Monitor status ring */
  137. #define PKTLOG_TYPE_LITE_RX 24
  138. #define PKTLOG_TYPE_MAX 25
  139. #define PKTLOG_MAX_TXCTL_WORDS 57 /* +2 words for bitmap */
  140. #define PKTLOG_MAX_TXSTATUS_WORDS 32
  141. #define PKTLOG_MAX_PROTO_WORDS 16
  142. #define PKTLOG_MAX_RXDESC_WORDS 62
  143. #define PKTLOG_HDR_SIZE_16 0x8000
  144. struct txctl_frm_hdr {
  145. uint16_t framectrl; /* frame control field from header */
  146. uint16_t seqctrl; /* frame control field from header */
  147. uint16_t bssid_tail; /* last two octets of bssid */
  148. uint16_t sa_tail; /* last two octets of SA */
  149. uint16_t da_tail; /* last two octets of DA */
  150. uint16_t resvd;
  151. };
  152. #if defined(HELIUMPLUS)
  153. /* Peregrine 11ac based */
  154. #define MAX_PKT_INFO_MSDU_ID 1
  155. #else
  156. /* Peregrine 11ac based */
  157. #define MAX_PKT_INFO_MSDU_ID 192
  158. #endif /* defined(HELIUMPLUS) */
  159. /*
  160. * msdu_id_info_t is defined for reference only
  161. */
  162. struct msdu_id_info {
  163. uint32_t num_msdu;
  164. uint8_t bound_bmap[(MAX_PKT_INFO_MSDU_ID + 7)>>3];
  165. /* TODO:
  166. * Convert the id's to uint32_t
  167. * Reduces computation in the driver code
  168. */
  169. uint16_t id[MAX_PKT_INFO_MSDU_ID];
  170. } __ATTRIB_PACK;
  171. #define MSDU_ID_INFO_NUM_MSDU_OFFSET 0 /* char offset */
  172. #define MSDU_ID_INFO_BOUND_BM_OFFSET offsetof(struct msdu_id_info, bound_bmap)
  173. #define MSDU_ID_INFO_ID_OFFSET offsetof(struct msdu_id_info, id)
  174. struct ath_pktlog_txctl {
  175. struct ath_pktlog_hdr pl_hdr;
  176. /* struct txctl_frm_hdr frm_hdr; */
  177. void *txdesc_hdr_ctl; /* frm_hdr + Tx descriptor words */
  178. struct {
  179. struct txctl_frm_hdr frm_hdr;
  180. uint32_t txdesc_ctl[PKTLOG_MAX_TXCTL_WORDS];
  181. /* uint32_t *proto_hdr; / * protocol header (variable length!) * / */
  182. /* uint32_t *misc; / * Can be used for HT specific or other misc info * / */
  183. } priv;
  184. } __ATTRIB_PACK;
  185. struct ath_pktlog_tx_status {
  186. struct ath_pktlog_hdr pl_hdr;
  187. void *ds_status;
  188. int32_t misc[0]; /* Can be used for HT specific or other misc info */
  189. } __ATTRIB_PACK;
  190. struct ath_pktlog_msdu_info {
  191. struct ath_pktlog_hdr pl_hdr;
  192. void *ath_msdu_info;
  193. A_UINT32 num_msdu;
  194. struct {
  195. /*
  196. * Provision to add more information fields
  197. */
  198. struct msdu_info_t {
  199. A_UINT32 num_msdu;
  200. A_UINT8 bound_bmap[MAX_PKT_INFO_MSDU_ID >> 3];
  201. } msdu_id_info;
  202. /*
  203. * array of num_msdu
  204. * Static implementation will consume unwanted memory
  205. * Need to split the pktlog_get_buf to get the buffer pointer only
  206. */
  207. uint16_t msdu_len[MAX_PKT_INFO_MSDU_ID];
  208. } priv;
  209. size_t priv_size;
  210. } __ATTRIB_PACK;
  211. struct ath_pktlog_rx_info {
  212. struct ath_pktlog_hdr pl_hdr;
  213. void *rx_desc;
  214. } __ATTRIB_PACK;
  215. struct ath_pktlog_rc_find {
  216. struct ath_pktlog_hdr pl_hdr;
  217. void *rcFind;
  218. } __ATTRIB_PACK;
  219. struct ath_pktlog_sw_event {
  220. struct ath_pktlog_hdr pl_hdr;
  221. void *sw_event;
  222. } __ATTRIB_PACK;
  223. struct ath_pktlog_rc_update {
  224. struct ath_pktlog_hdr pl_hdr;
  225. void *txRateCtrl; /* rate control state proper */
  226. } __ATTRIB_PACK;
  227. #ifdef WIN32
  228. #pragma pack(pop, pktlog_fmt)
  229. #endif
  230. #ifdef __ATTRIB_PACK
  231. #undef __ATTRIB_PACK
  232. #endif /* __ATTRIB_PACK */
  233. /*
  234. * The following header is included in the beginning of the file,
  235. * followed by log entries when the log buffer is read through procfs
  236. */
  237. struct ath_pktlog_bufhdr {
  238. uint32_t magic_num; /* Used by post processing scripts */
  239. uint32_t version; /* Set to CUR_PKTLOG_VER */
  240. };
  241. struct ath_pktlog_buf {
  242. struct ath_pktlog_bufhdr bufhdr;
  243. int32_t rd_offset;
  244. volatile int32_t wr_offset;
  245. /* Whenever this bytes written value croses 4K bytes,
  246. * logging will be triggered
  247. */
  248. int32_t bytes_written;
  249. /* Index of the messages sent to userspace */
  250. uint32_t msg_index;
  251. /* Offset for read */
  252. loff_t offset;
  253. char log_data[0];
  254. };
  255. #define PKTLOG_MOV_RD_IDX(_rd_offset, _log_buf, _log_size) \
  256. do { \
  257. if ((_rd_offset + sizeof(struct ath_pktlog_hdr) + \
  258. ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
  259. (_rd_offset)))->size) <= _log_size) { \
  260. _rd_offset = ((_rd_offset) + sizeof(struct ath_pktlog_hdr) + \
  261. ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
  262. (_rd_offset)))->size); \
  263. } else { \
  264. _rd_offset = ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
  265. (_rd_offset)))->size; \
  266. } \
  267. (_rd_offset) = (((_log_size) - (_rd_offset)) >= \
  268. sizeof(struct ath_pktlog_hdr)) ? _rd_offset : 0; \
  269. } while (0)
  270. #endif /* REMOVE_PKT_LOG */
  271. /**
  272. * enum pkt_type - packet type
  273. * @START_MONITOR: indicates parser to start packetdump parsing
  274. * @STOP_MONITOR: indicates parser to stop packetdump parsing
  275. * @TX_MGMT_PKT: TX management Packet
  276. * @TX_DATA_PKT: TX data Packet
  277. * @RX_MGMT_PKT: RX management Packet
  278. * @RX_DATA_PKT: RX data Packet
  279. *
  280. * This enum has packet types
  281. */
  282. enum pkt_type {
  283. START_MONITOR = 1,
  284. STOP_MONITOR,
  285. TX_MGMT_PKT,
  286. TX_DATA_PKT,
  287. RX_MGMT_PKT,
  288. RX_DATA_PKT,
  289. };
  290. /**
  291. * enum tx_pkt_fate - tx packet fate
  292. * @TX_PKT_FATE_ACKED: Sent over air and ACKed
  293. * @TX_PKT_FATE_SENT: Sent over air but not ACKed.
  294. * @TX_PKT_FATE_FW_QUEUED: Queued within firmware,
  295. * but not yet sent over air
  296. * @TX_PKT_FATE_FW_DROP_INVALID: Dropped by firmware as invalid.
  297. * E.g. bad source address, bad checksum, or invalid for current state.
  298. * @TX_PKT_FATE_FW_DROP_NOBUFS: Dropped by firmware due
  299. * to lack of buffer space
  300. * @TX_PKT_FATE_FW_DROP_OTHER: Dropped by firmware for any other
  301. * reason. Includes frames that were sent by driver to firmware, but
  302. * unaccounted for by firmware.
  303. * @TX_PKT_FATE_DRV_QUEUED: Queued within driver, not yet sent to firmware.
  304. * @TX_PKT_FATE_DRV_DROP_INVALID: Dropped by driver as invalid.
  305. * E.g. bad source address, or invalid for current state.
  306. * @TX_PKT_FATE_DRV_DROP_NOBUFS: Dropped by driver due to lack of buffer space
  307. * @TX_PKT_FATE_DRV_DROP_OTHER: Dropped by driver for any other reason.
  308. * E.g. out of buffers.
  309. *
  310. * This enum has packet fate types
  311. */
  312. enum tx_pkt_fate {
  313. TX_PKT_FATE_ACKED,
  314. TX_PKT_FATE_SENT,
  315. TX_PKT_FATE_FW_QUEUED,
  316. TX_PKT_FATE_FW_DROP_INVALID,
  317. TX_PKT_FATE_FW_DROP_NOBUFS,
  318. TX_PKT_FATE_FW_DROP_OTHER,
  319. TX_PKT_FATE_DRV_QUEUED,
  320. TX_PKT_FATE_DRV_DROP_INVALID,
  321. TX_PKT_FATE_DRV_DROP_NOBUFS,
  322. TX_PKT_FATE_DRV_DROP_OTHER,
  323. };
  324. /**
  325. * enum rx_pkt_fate - rx packet fate
  326. * @RX_PKT_FATE_SUCCESS: Valid and delivered to
  327. * network stack (e.g., netif_rx()).
  328. * @RX_PKT_FATE_FW_QUEUED: Queued within firmware,
  329. * but not yet sent to driver.
  330. * @RX_PKT_FATE_FW_DROP_FILTER: Dropped by firmware
  331. * due to host-programmable filters.
  332. * @RX_PKT_FATE_FW_DROP_INVALID: Dropped by firmware
  333. * as invalid. E.g. bad checksum, decrypt failed, or invalid for current state.
  334. * @RX_PKT_FATE_FW_DROP_NOBUFS: Dropped by firmware
  335. * due to lack of buffer space.
  336. * @RX_PKT_FATE_FW_DROP_OTHER: Dropped by firmware
  337. * for any other reason.
  338. * @RX_PKT_FATE_DRV_QUEUED: Queued within driver,
  339. * not yet delivered to network stack.
  340. * @RX_PKT_FATE_DRV_DROP_FILTER: Dropped by driver
  341. * due to filter rules.
  342. * @RX_PKT_FATE_DRV_DROP_INVALID: Dropped by driver as invalid.
  343. * E.g. not permitted in current state.
  344. * @RX_PKT_FATE_DRV_DROP_NOBUFS: Dropped by driver
  345. * due to lack of buffer space.
  346. * @RX_PKT_FATE_DRV_DROP_OTHER: Dropped by driver for any other reason.
  347. *
  348. * This enum has packet fate types
  349. */
  350. enum rx_pkt_fate {
  351. RX_PKT_FATE_SUCCESS,
  352. RX_PKT_FATE_FW_QUEUED,
  353. RX_PKT_FATE_FW_DROP_FILTER,
  354. RX_PKT_FATE_FW_DROP_INVALID,
  355. RX_PKT_FATE_FW_DROP_NOBUFS,
  356. RX_PKT_FATE_FW_DROP_OTHER,
  357. RX_PKT_FATE_DRV_QUEUED,
  358. RX_PKT_FATE_DRV_DROP_FILTER,
  359. RX_PKT_FATE_DRV_DROP_INVALID,
  360. RX_PKT_FATE_DRV_DROP_NOBUFS,
  361. RX_PKT_FATE_DRV_DROP_OTHER,
  362. };
  363. #endif /* _PKTLOG_FMT_H_ */