pktlog_ac_fmt.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /*
  2. * Copyright (c) 2012-2016 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. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. #ifndef REMOVE_PKT_LOG
  27. #ifndef _PKTLOG_FMT_H_
  28. #define _PKTLOG_FMT_H_
  29. #define CUR_PKTLOG_VER 10010 /* Packet log version */
  30. #define PKTLOG_MAGIC_NUM 7735225
  31. #ifdef __linux__
  32. #define PKTLOG_PROC_DIR "ath_pktlog"
  33. #define PKTLOG_PROC_SYSTEM "system"
  34. #define WLANDEV_BASENAME "cld"
  35. #endif
  36. #ifdef WIN32
  37. #pragma pack(push, pktlog_fmt, 1)
  38. #define __ATTRIB_PACK
  39. #elif defined(__EFI__)
  40. #define __ATTRIB_PACK
  41. #else
  42. #ifndef __ATTRIB_PACK
  43. #define __ATTRIB_PACK __attribute__ ((packed))
  44. #endif
  45. #endif
  46. #include <a_types.h>
  47. /*
  48. * Each packet log entry consists of the following fixed length header
  49. * followed by variable length log information determined by log_type
  50. */
  51. struct ath_pktlog_hdr {
  52. uint16_t flags;
  53. uint16_t missed_cnt;
  54. #ifdef HELIUMPLUS
  55. uint8_t log_type;
  56. uint8_t macId;
  57. #else
  58. uint16_t log_type;
  59. #endif
  60. uint16_t size;
  61. uint32_t timestamp;
  62. #ifdef HELIUMPLUS
  63. uint32_t type_specific_data;
  64. #endif
  65. } __ATTRIB_PACK;
  66. #define ATH_PKTLOG_HDR_FLAGS_MASK 0xffff
  67. #define ATH_PKTLOG_HDR_FLAGS_SHIFT 0
  68. #define ATH_PKTLOG_HDR_FLAGS_OFFSET 0
  69. #define ATH_PKTLOG_HDR_MISSED_CNT_MASK 0xffff0000
  70. #define ATH_PKTLOG_HDR_MISSED_CNT_SHIFT 16
  71. #define ATH_PKTLOG_HDR_MISSED_CNT_OFFSET 0
  72. #ifdef HELIUMPLUS
  73. #define ATH_PKTLOG_HDR_LOG_TYPE_MASK 0x00ff
  74. #define ATH_PKTLOG_HDR_LOG_TYPE_SHIFT 0
  75. #define ATH_PKTLOG_HDR_LOG_TYPE_OFFSET 1
  76. #define ATH_PKTLOG_HDR_MAC_ID_MASK 0xff00
  77. #define ATH_PKTLOG_HDR_MAC_ID_SHIFT 8
  78. #define ATH_PKTLOG_HDR_MAC_ID_OFFSET 1
  79. #else
  80. #define ATH_PKTLOG_HDR_LOG_TYPE_MASK 0xffff
  81. #define ATH_PKTLOG_HDR_LOG_TYPE_SHIFT 0
  82. #define ATH_PKTLOG_HDR_LOG_TYPE_OFFSET 1
  83. #endif
  84. #define ATH_PKTLOG_HDR_SIZE_MASK 0xffff0000
  85. #define ATH_PKTLOG_HDR_SIZE_SHIFT 16
  86. #define ATH_PKTLOG_HDR_SIZE_OFFSET 1
  87. #define ATH_PKTLOG_HDR_TIMESTAMP_OFFSET 2
  88. #define ATH_PKTLOG_HDR_TYPE_SPECIFIC_DATA_OFFSET 3
  89. /**
  90. * enum - Pktlog flag field details
  91. * packet origin [1:0]
  92. * 00 - Local
  93. * 01 - Remote
  94. * 10 - Unknown/Not applicable
  95. * 11 - Reserved
  96. * reserved [15:2]
  97. */
  98. enum {
  99. PKTLOG_FLG_FRM_TYPE_LOCAL_S = 0,
  100. PKTLOG_FLG_FRM_TYPE_REMOTE_S,
  101. PKTLOG_FLG_FRM_TYPE_CLONE_S,
  102. PKTLOG_FLG_FRM_TYPE_CBF_S,
  103. PKTLOG_FLG_FRM_TYPE_UNKNOWN_S
  104. };
  105. #define PHFLAGS_INTERRUPT_CONTEXT 0x80000000
  106. /* Masks for setting pktlog events filters */
  107. #define ATH_PKTLOG_TX 0x000000001
  108. #define ATH_PKTLOG_RX 0x000000002
  109. #define ATH_PKTLOG_RCFIND 0x000000004
  110. #define ATH_PKTLOG_RCUPDATE 0x000000008
  111. #define ATH_PKTLOG_ANI 0x000000010
  112. #define ATH_PKTLOG_TEXT 0x000000020
  113. #define ATH_PKTLOG_PHYERR 0x000000040
  114. #define ATH_PKTLOG_PROMISC 0x000000080
  115. #define ATH_PKTLOG_SW_EVENT 0x000000100
  116. /* Types of packet log events */
  117. #define PKTLOG_TYPE_TX_CTRL 1
  118. #define PKTLOG_TYPE_TX_STAT 2
  119. #define PKTLOG_TYPE_TX_MSDU_ID 3
  120. #define PKTLOG_TYPE_TX_FRM_HDR 4
  121. #define PKTLOG_TYPE_RX_STAT 5
  122. #define PKTLOG_TYPE_RC_FIND 6
  123. #define PKTLOG_TYPE_RC_UPDATE 7
  124. #define PKTLOG_TYPE_TX_VIRT_ADDR 8
  125. #define PKTLOG_TYPE_SMART_ANTENNA 9
  126. #define PKTLOG_TYPE_SW_EVENT 10
  127. #define PKTLOG_TYPE_MAX 11
  128. #define PKTLOG_MAX_TXCTL_WORDS 57 /* +2 words for bitmap */
  129. #define PKTLOG_MAX_TXSTATUS_WORDS 32
  130. #define PKTLOG_MAX_PROTO_WORDS 16
  131. #define PKTLOG_MAX_RXDESC_WORDS 62
  132. struct txctl_frm_hdr {
  133. uint16_t framectrl; /* frame control field from header */
  134. uint16_t seqctrl; /* frame control field from header */
  135. uint16_t bssid_tail; /* last two octets of bssid */
  136. uint16_t sa_tail; /* last two octets of SA */
  137. uint16_t da_tail; /* last two octets of DA */
  138. uint16_t resvd;
  139. };
  140. #if defined(HELIUMPLUS)
  141. /* Peregrine 11ac based */
  142. #define MAX_PKT_INFO_MSDU_ID 1
  143. #else
  144. /* Peregrine 11ac based */
  145. #define MAX_PKT_INFO_MSDU_ID 192
  146. #endif /* defined(HELIUMPLUS) */
  147. /*
  148. * msdu_id_info_t is defined for reference only
  149. */
  150. struct msdu_id_info {
  151. uint32_t num_msdu;
  152. uint8_t bound_bmap[(MAX_PKT_INFO_MSDU_ID + 7)>>3];
  153. /* TODO:
  154. * Convert the id's to uint32_t
  155. * Reduces computation in the driver code
  156. */
  157. uint16_t id[MAX_PKT_INFO_MSDU_ID];
  158. } __ATTRIB_PACK;
  159. #define MSDU_ID_INFO_NUM_MSDU_OFFSET 0 /* char offset */
  160. #define MSDU_ID_INFO_BOUND_BM_OFFSET offsetof(struct msdu_id_info, bound_bmap)
  161. #define MSDU_ID_INFO_ID_OFFSET offsetof(struct msdu_id_info, id)
  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. struct ath_pktlog_tx_status {
  174. struct ath_pktlog_hdr pl_hdr;
  175. void *ds_status;
  176. int32_t misc[0]; /* Can be used for HT specific or other misc info */
  177. } __ATTRIB_PACK;
  178. struct ath_pktlog_msdu_info {
  179. struct ath_pktlog_hdr pl_hdr;
  180. void *ath_msdu_info;
  181. A_UINT32 num_msdu;
  182. struct {
  183. /*
  184. * Provision to add more information fields
  185. */
  186. struct msdu_info_t {
  187. A_UINT32 num_msdu;
  188. A_UINT8 bound_bmap[MAX_PKT_INFO_MSDU_ID >> 3];
  189. } msdu_id_info;
  190. /*
  191. * array of num_msdu
  192. * Static implementation will consume unwanted memory
  193. * Need to split the pktlog_get_buf to get the buffer pointer only
  194. */
  195. uint16_t msdu_len[MAX_PKT_INFO_MSDU_ID];
  196. } priv;
  197. size_t priv_size;
  198. } __ATTRIB_PACK;
  199. struct ath_pktlog_rx_info {
  200. struct ath_pktlog_hdr pl_hdr;
  201. void *rx_desc;
  202. } __ATTRIB_PACK;
  203. struct ath_pktlog_rc_find {
  204. struct ath_pktlog_hdr pl_hdr;
  205. void *rcFind;
  206. } __ATTRIB_PACK;
  207. struct ath_pktlog_sw_event {
  208. struct ath_pktlog_hdr pl_hdr;
  209. void *sw_event;
  210. } __ATTRIB_PACK;
  211. struct ath_pktlog_rc_update {
  212. struct ath_pktlog_hdr pl_hdr;
  213. void *txRateCtrl; /* rate control state proper */
  214. } __ATTRIB_PACK;
  215. #ifdef WIN32
  216. #pragma pack(pop, pktlog_fmt)
  217. #endif
  218. #ifdef __ATTRIB_PACK
  219. #undef __ATTRIB_PACK
  220. #endif /* __ATTRIB_PACK */
  221. /*
  222. * The following header is included in the beginning of the file,
  223. * followed by log entries when the log buffer is read through procfs
  224. */
  225. struct ath_pktlog_bufhdr {
  226. uint32_t magic_num; /* Used by post processing scripts */
  227. uint32_t version; /* Set to CUR_PKTLOG_VER */
  228. };
  229. struct ath_pktlog_buf {
  230. struct ath_pktlog_bufhdr bufhdr;
  231. int32_t rd_offset;
  232. volatile int32_t wr_offset;
  233. /* Whenever this bytes written value croses 4K bytes,
  234. * logging will be triggered
  235. */
  236. int32_t bytes_written;
  237. /* Index of the messages sent to userspace */
  238. uint32_t msg_index;
  239. /* Offset for read */
  240. loff_t offset;
  241. char log_data[0];
  242. };
  243. #define PKTLOG_MOV_RD_IDX(_rd_offset, _log_buf, _log_size) \
  244. do { \
  245. if((_rd_offset + sizeof(struct ath_pktlog_hdr) + \
  246. ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
  247. (_rd_offset)))->size) <= _log_size) { \
  248. _rd_offset = ((_rd_offset) + sizeof(struct ath_pktlog_hdr) + \
  249. ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
  250. (_rd_offset)))->size); \
  251. } else { \
  252. _rd_offset = ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
  253. (_rd_offset)))->size; \
  254. } \
  255. (_rd_offset) = (((_log_size) - (_rd_offset)) >= \
  256. sizeof(struct ath_pktlog_hdr)) ? _rd_offset : 0; \
  257. } while(0)
  258. #endif /* _PKTLOG_FMT_H_ */
  259. #endif /* REMOVE_PKT_LOG */