pktlog_ac_fmt.h 12 KB

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