pktlog_ac_fmt.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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. /* Types of packet log events */
  116. #define PKTLOG_TYPE_TX_CTRL 1
  117. #define PKTLOG_TYPE_TX_STAT 2
  118. #define PKTLOG_TYPE_TX_MSDU_ID 3
  119. #define PKTLOG_TYPE_TX_FRM_HDR 4
  120. #define PKTLOG_TYPE_RX_STAT 5
  121. #define PKTLOG_TYPE_RC_FIND 6
  122. #define PKTLOG_TYPE_RC_UPDATE 7
  123. #define PKTLOG_TYPE_TX_VIRT_ADDR 8
  124. #define PKTLOG_TYPE_MAX 9
  125. #define PKTLOG_MAX_TXCTL_WORDS 57 /* +2 words for bitmap */
  126. #define PKTLOG_MAX_TXSTATUS_WORDS 32
  127. #define PKTLOG_MAX_PROTO_WORDS 16
  128. #define PKTLOG_MAX_RXDESC_WORDS 62
  129. struct txctl_frm_hdr {
  130. uint16_t framectrl; /* frame control field from header */
  131. uint16_t seqctrl; /* frame control field from header */
  132. uint16_t bssid_tail; /* last two octets of bssid */
  133. uint16_t sa_tail; /* last two octets of SA */
  134. uint16_t da_tail; /* last two octets of DA */
  135. uint16_t resvd;
  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. * msdu_id_info_t is defined for reference only
  146. */
  147. struct msdu_id_info {
  148. uint32_t num_msdu;
  149. uint8_t bound_bmap[(MAX_PKT_INFO_MSDU_ID + 7)>>3];
  150. /* TODO:
  151. * Convert the id's to uint32_t
  152. * Reduces computation in the driver code
  153. */
  154. uint16_t id[MAX_PKT_INFO_MSDU_ID];
  155. } __ATTRIB_PACK;
  156. #define MSDU_ID_INFO_NUM_MSDU_OFFSET 0 /* char offset */
  157. #define MSDU_ID_INFO_BOUND_BM_OFFSET offsetof(struct msdu_id_info, bound_bmap)
  158. #define MSDU_ID_INFO_ID_OFFSET offsetof(struct msdu_id_info, id)
  159. struct ath_pktlog_txctl {
  160. struct ath_pktlog_hdr pl_hdr;
  161. /* struct txctl_frm_hdr frm_hdr; */
  162. void *txdesc_hdr_ctl; /* frm_hdr + Tx descriptor words */
  163. struct {
  164. struct txctl_frm_hdr frm_hdr;
  165. uint32_t txdesc_ctl[PKTLOG_MAX_TXCTL_WORDS];
  166. /* uint32_t *proto_hdr; / * protocol header (variable length!) * / */
  167. /* uint32_t *misc; / * Can be used for HT specific or other misc info * / */
  168. } priv;
  169. } __ATTRIB_PACK;
  170. struct ath_pktlog_tx_status {
  171. struct ath_pktlog_hdr pl_hdr;
  172. void *ds_status;
  173. int32_t misc[0]; /* Can be used for HT specific or other misc info */
  174. } __ATTRIB_PACK;
  175. struct ath_pktlog_msdu_info {
  176. struct ath_pktlog_hdr pl_hdr;
  177. void *ath_msdu_info;
  178. A_UINT32 num_msdu;
  179. struct {
  180. /*
  181. * Provision to add more information fields
  182. */
  183. struct msdu_info_t {
  184. A_UINT32 num_msdu;
  185. A_UINT8 bound_bmap[MAX_PKT_INFO_MSDU_ID >> 3];
  186. } msdu_id_info;
  187. /*
  188. * array of num_msdu
  189. * Static implementation will consume unwanted memory
  190. * Need to split the pktlog_get_buf to get the buffer pointer only
  191. */
  192. uint16_t msdu_len[MAX_PKT_INFO_MSDU_ID];
  193. } priv;
  194. size_t priv_size;
  195. } __ATTRIB_PACK;
  196. struct ath_pktlog_rx_info {
  197. struct ath_pktlog_hdr pl_hdr;
  198. void *rx_desc;
  199. } __ATTRIB_PACK;
  200. struct ath_pktlog_rc_find {
  201. struct ath_pktlog_hdr pl_hdr;
  202. void *rcFind;
  203. } __ATTRIB_PACK;
  204. struct ath_pktlog_rc_update {
  205. struct ath_pktlog_hdr pl_hdr;
  206. void *txRateCtrl; /* rate control state proper */
  207. } __ATTRIB_PACK;
  208. #ifdef WIN32
  209. #pragma pack(pop, pktlog_fmt)
  210. #endif
  211. #ifdef __ATTRIB_PACK
  212. #undef __ATTRIB_PACK
  213. #endif /* __ATTRIB_PACK */
  214. /*
  215. * The following header is included in the beginning of the file,
  216. * followed by log entries when the log buffer is read through procfs
  217. */
  218. struct ath_pktlog_bufhdr {
  219. uint32_t magic_num; /* Used by post processing scripts */
  220. uint32_t version; /* Set to CUR_PKTLOG_VER */
  221. };
  222. struct ath_pktlog_buf {
  223. struct ath_pktlog_bufhdr bufhdr;
  224. int32_t rd_offset;
  225. volatile int32_t wr_offset;
  226. /* Whenever this bytes written value croses 4K bytes,
  227. * logging will be triggered
  228. */
  229. int32_t bytes_written;
  230. /* Index of the messages sent to userspace */
  231. uint32_t msg_index;
  232. /* Offset for read */
  233. loff_t offset;
  234. char log_data[0];
  235. };
  236. #define PKTLOG_MOV_RD_IDX(_rd_offset, _log_buf, _log_size) \
  237. do { \
  238. if((_rd_offset + sizeof(struct ath_pktlog_hdr) + \
  239. ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
  240. (_rd_offset)))->size) <= _log_size) { \
  241. _rd_offset = ((_rd_offset) + sizeof(struct ath_pktlog_hdr) + \
  242. ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
  243. (_rd_offset)))->size); \
  244. } else { \
  245. _rd_offset = ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
  246. (_rd_offset)))->size; \
  247. } \
  248. (_rd_offset) = (((_log_size) - (_rd_offset)) >= \
  249. sizeof(struct ath_pktlog_hdr)) ? _rd_offset : 0; \
  250. } while(0)
  251. #endif /* _PKTLOG_FMT_H_ */
  252. #endif /* REMOVE_PKT_LOG */