PageRenderTime 55ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/drivers/net/wireless/bcmdhd/dhd_debug.h

https://gitlab.com/deadnem/Singularity
C Header | 312 lines | 186 code | 27 blank | 99 comment | 2 complexity | 676d06f3279995ae93c1830b87760c56 MD5 | raw file
  1. /*
  2. * Linux Debugability support code
  3. *
  4. * Copyright (C) 1999-2014, Broadcom Corporation
  5. *
  6. * Unless you and Broadcom execute a separate written software license
  7. * agreement governing use of this software, this software is licensed to you
  8. * under the terms of the GNU General Public License version 2 (the "GPL"),
  9. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  10. * following added to such license:
  11. *
  12. * As a special exception, the copyright holders of this software give you
  13. * permission to link this software with independent modules, and to copy and
  14. * distribute the resulting executable under terms of your choice, provided that
  15. * you also meet, for each linked independent module, the terms and conditions of
  16. * the license of that module. An independent module is a module which is not
  17. * derived from this software. The special exception does not apply to any
  18. * modifications of the software.
  19. *
  20. * Notwithstanding the above, under no circumstances may you combine this
  21. * software in any way with any other Broadcom software provided under a license
  22. * other than the GPL, without Broadcom's express prior written consent.
  23. *
  24. * $Id: dhd_debug.h 545157 2015-03-30 23:47:38Z $
  25. */
  26. #ifndef _dhd_debug_h_
  27. #define _dhd_debug_h_
  28. enum {
  29. DEBUG_RING_ID_INVALID = 0,
  30. FW_VERBOSE_RING_ID,
  31. FW_EVENT_RING_ID,
  32. DHD_EVENT_RING_ID,
  33. /* add new id here */
  34. DEBUG_RING_ID_MAX
  35. };
  36. enum {
  37. /* Feature set */
  38. DBG_MEMORY_DUMP_SUPPORTED = (1 << (0)), /* Memory dump of FW */
  39. DBG_PER_PACKET_TX_RX_STATUS_SUPPORTED = (1 << (1)), /* PKT Status */
  40. DBG_CONNECT_EVENT_SUPPORTED = (1 << (2)), /* Connectivity Event */
  41. DBG_POWER_EVENT_SUPOORTED = (1 << (3)), /* POWER of Driver */
  42. DBG_WAKE_LOCK_SUPPORTED = (1 << (4)), /* WAKE LOCK of Driver */
  43. DBG_VERBOSE_LOG_SUPPORTED = (1 << (5)), /* verbose log of FW */
  44. DBG_HEALTH_CHECK_SUPPORTED = (1 << (6)), /* monitor the health of FW */
  45. };
  46. enum {
  47. /* set for binary entries */
  48. DBG_RING_ENTRY_FLAGS_HAS_BINARY = (1 << (0)),
  49. /* set if 64 bits timestamp is present */
  50. DBG_RING_ENTRY_FLAGS_HAS_TIMESTAMP = (1 << (1))
  51. };
  52. #define DBGRING_NAME_MAX 32
  53. /* firmware verbose ring, ring id 1 */
  54. #define FW_VERBOSE_RING_NAME "fw_verbose"
  55. #define FW_VERBOSE_RING_SIZE (64 * 1024)
  56. /* firmware event ring, ring id 2 */
  57. #define FW_EVENT_RING_NAME "fw_event"
  58. #define FW_EVENT_RING_SIZE (64 * 1024)
  59. /* DHD connection event ring, ring id 3 */
  60. #define DHD_EVENT_RING_NAME "dhd_event"
  61. #define DHD_EVENT_RING_SIZE (64 * 1024)
  62. #define DBG_RING_STATUS_SIZE (sizeof(dhd_dbg_ring_status_t))
  63. #define VALID_RING(id) \
  64. (id > DEBUG_RING_ID_INVALID && id < DEBUG_RING_ID_MAX)
  65. /* driver receive association command from kernel */
  66. #define WIFI_EVENT_ASSOCIATION_REQUESTED 0
  67. #define WIFI_EVENT_AUTH_COMPLETE 1
  68. #define WIFI_EVENT_ASSOC_COMPLETE 2
  69. /* received firmware event indicating auth frames are sent */
  70. #define WIFI_EVENT_FW_AUTH_STARTED 3
  71. /* received firmware event indicating assoc frames are sent */
  72. #define WIFI_EVENT_FW_ASSOC_STARTED 4
  73. /* received firmware event indicating reassoc frames are sent */
  74. #define WIFI_EVENT_FW_RE_ASSOC_STARTED 5
  75. #define WIFI_EVENT_DRIVER_SCAN_REQUESTED 6
  76. #define WIFI_EVENT_DRIVER_SCAN_RESULT_FOUND 7
  77. #define WIFI_EVENT_DRIVER_SCAN_COMPLETE 8
  78. #define WIFI_EVENT_G_SCAN_STARTED 9
  79. #define WIFI_EVENT_G_SCAN_COMPLETE 10
  80. #define WIFI_EVENT_DISASSOCIATION_REQUESTED 11
  81. #define WIFI_EVENT_RE_ASSOCIATION_REQUESTED 12
  82. #define WIFI_EVENT_ROAM_REQUESTED 13
  83. /* received beacon from AP (event enabled only in verbose mode) */
  84. #define WIFI_EVENT_BEACON_RECEIVED 14
  85. /* firmware has triggered a roam scan (not g-scan) */
  86. #define WIFI_EVENT_ROAM_SCAN_STARTED 15
  87. /* firmware has completed a roam scan (not g-scan) */
  88. #define WIFI_EVENT_ROAM_SCAN_COMPLETE 16
  89. /* firmware has started searching for roam candidates (with reason =xx) */
  90. #define WIFI_EVENT_ROAM_SEARCH_STARTED 17
  91. /* firmware has stopped searching for roam candidates (with reason =xx) */
  92. #define WIFI_EVENT_ROAM_SEARCH_STOPPED 18
  93. /* received channel switch anouncement from AP */
  94. #define WIFI_EVENT_CHANNEL_SWITCH_ANOUNCEMENT 20
  95. /* fw start transmit eapol frame, with EAPOL index 1-4 */
  96. #define WIFI_EVENT_FW_EAPOL_FRAME_TRANSMIT_START 21
  97. /* fw gives up eapol frame, with rate, success/failure and number retries */
  98. #define WIFI_EVENT_FW_EAPOL_FRAME_TRANSMIT_STOP 22
  99. /* kernel queue EAPOL for transmission in driver with EAPOL index 1-4 */
  100. #define WIFI_EVENT_DRIVER_EAPOL_FRAME_TRANSMIT_REQUESTED 23
  101. /* with rate, regardless of the fact that EAPOL frame is accepted or rejected by firmware */
  102. #define WIFI_EVENT_FW_EAPOL_FRAME_RECEIVED 24
  103. /* with rate, and eapol index, driver has received */
  104. /* EAPOL frame and will queue it up to wpa_supplicant */
  105. #define WIFI_EVENT_DRIVER_EAPOL_FRAME_RECEIVED 26
  106. /* with success/failure, parameters */
  107. #define WIFI_EVENT_BLOCK_ACK_NEGOTIATION_COMPLETE 27
  108. #define WIFI_EVENT_BT_COEX_BT_SCO_START 28
  109. #define WIFI_EVENT_BT_COEX_BT_SCO_STOP 29
  110. /* for paging/scan etc..., when BT starts transmiting twice per BT slot */
  111. #define WIFI_EVENT_BT_COEX_BT_SCAN_START 30
  112. #define WIFI_EVENT_BT_COEX_BT_SCAN_STOP 31
  113. #define WIFI_EVENT_BT_COEX_BT_HID_START 32
  114. #define WIFI_EVENT_BT_COEX_BT_HID_STOP 33
  115. /* firmware sends auth frame in roaming to next candidate */
  116. #define WIFI_EVENT_ROAM_AUTH_STARTED 34
  117. /* firmware receive auth confirm from ap */
  118. #define WIFI_EVENT_ROAM_AUTH_COMPLETE 35
  119. /* firmware sends assoc/reassoc frame in */
  120. #define WIFI_EVENT_ROAM_ASSOC_STARTED 36
  121. /* firmware receive assoc/reassoc confirm from ap */
  122. #define WIFI_EVENT_ROAM_ASSOC_COMPLETE 37
  123. #define WIFI_TAG_VENDOR_SPECIFIC 0 /* take a byte stream as parameter */
  124. #define WIFI_TAG_BSSID 1 /* takes a 6 bytes MAC address as parameter */
  125. #define WIFI_TAG_ADDR 2 /* takes a 6 bytes MAC address as parameter */
  126. #define WIFI_TAG_SSID 3 /* takes a 32 bytes SSID address as parameter */
  127. #define WIFI_TAG_STATUS 4 /* takes an integer as parameter */
  128. #define WIFI_TAG_CHANNEL_SPEC 5 /* takes one or more wifi_channel_spec as parameter */
  129. #define WIFI_TAG_WAKE_LOCK_EVENT 6 /* takes a wake_lock_event struct as parameter */
  130. #define WIFI_TAG_ADDR1 7 /* takes a 6 bytes MAC address as parameter */
  131. #define WIFI_TAG_ADDR2 8 /* takes a 6 bytes MAC address as parameter */
  132. #define WIFI_TAG_ADDR3 9 /* takes a 6 bytes MAC address as parameter */
  133. #define WIFI_TAG_ADDR4 10 /* takes a 6 bytes MAC address as parameter */
  134. #define WIFI_TAG_TSF 11 /* take a 64 bits TSF value as parameter */
  135. #define WIFI_TAG_IE 12 /* take one or more specific 802.11 IEs parameter, */
  136. /* IEs are in turn indicated */
  137. /* in TLV format as per 802.11 spec */
  138. #define WIFI_TAG_INTERFACE 13 /* take interface name as parameter */
  139. #define WIFI_TAG_REASON_CODE 14 /* take a reason code as per 802.11 as parameter */
  140. #define WIFI_TAG_RATE_MBPS 15 /* take a wifi rate in 0.5 mbps */
  141. typedef struct {
  142. uint16 tag;
  143. uint16 len; /* length of value */
  144. uint8 value[0];
  145. } __attribute__ ((packed)) tlv_log;
  146. typedef struct per_packet_status_entry {
  147. uint8 flags;
  148. uint8 tid; /* transmit or received tid */
  149. uint16 MCS; /* modulation and bandwidth */
  150. /*
  151. * TX: RSSI of ACK for that packet
  152. * RX: RSSI of packet
  153. */
  154. uint8 rssi;
  155. uint8 num_retries; /* number of attempted retries */
  156. uint16 last_transmit_rate; /* last transmit rate in .5 mbps */
  157. /* transmit/reeive sequence for that MPDU packet */
  158. uint16 link_layer_transmit_sequence;
  159. /*
  160. * TX: firmware timestamp (us) when packet is queued within firmware buffer
  161. * for SDIO/HSIC or into PCIe buffer
  162. * RX : firmware receive timestamp
  163. */
  164. uint64 firmware_entry_timestamp;
  165. /*
  166. * firmware timestamp (us) when packet start contending for the
  167. * medium for the first time, at head of its AC queue,
  168. * or as part of an MPDU or A-MPDU. This timestamp is not updated
  169. * for each retry, only the first transmit attempt.
  170. */
  171. uint64 start_contention_timestamp;
  172. /*
  173. * fimrware timestamp (us) when packet is successfully transmitted
  174. * or aborted because it has exhausted its maximum number of retries
  175. */
  176. uint64 transmit_success_timestamp;
  177. /*
  178. * packet data. The length of packet data is determined by the entry_size field of
  179. * the wifi_ring_buffer_entry structure. It is expected that first bytes of the
  180. * packet, or packet headers only (up to TCP or RTP/UDP headers) will be copied into the ring
  181. */
  182. uint8 data[0];
  183. } __attribute__ ((packed)) per_packet_status_entry_t;
  184. typedef struct log_conn_event {
  185. uint16 event;
  186. tlv_log tlvs[0];
  187. /*
  188. * separate parameter structure per event to be provided and optional data
  189. * the event_data is expected to include an official android part, with some
  190. * parameter as transmit rate, num retries, num scan result found etc...
  191. * as well, event_data can include a vendor proprietary part which is
  192. * understood by the developer only.
  193. */
  194. } __attribute__ ((packed)) log_conn_event_t;
  195. /*
  196. * Ring buffer name for power events ring. note that power event are extremely frequents
  197. * and thus should be stored in their own ring/file so as not to clobber connectivity events
  198. */
  199. typedef struct wake_lock_event {
  200. uint32 status; /* 0 taken, 1 released */
  201. uint32 reason; /* reason why this wake lock is taken */
  202. char name[0]; /* null terminated */
  203. } __attribute__ ((packed)) wake_lock_event_t;
  204. typedef struct wifi_power_event {
  205. uint16 event;
  206. tlv_log tlvs[0];
  207. } __attribute__ ((packed)) wifi_power_event_t;
  208. /* entry type */
  209. enum {
  210. DBG_RING_ENTRY_EVENT_TYPE = 1,
  211. DBG_RING_ENTRY_PKT_TYPE,
  212. DBG_RING_ENTRY_WAKE_LOCK_EVENT_TYPE,
  213. DBG_RING_ENTRY_POWER_EVENT_TYPE,
  214. DBG_RING_ENTRY_DATA_TYPE
  215. };
  216. typedef struct dhd_dbg_ring_entry {
  217. uint16 len; /* payload length excluding the header */
  218. uint8 flags;
  219. uint8 type; /* Per ring specific */
  220. uint64 timestamp; /* present if has_timestamp bit is set. */
  221. } __attribute__ ((packed)) dhd_dbg_ring_entry_t;
  222. #define DBG_RING_ENTRY_SIZE (sizeof(dhd_dbg_ring_entry_t))
  223. #define ENTRY_LENGTH(hdr) (hdr->len + DBG_RING_ENTRY_SIZE)
  224. #define DBG_EVENT_LOG(dhd, connect_state) \
  225. { \
  226. do { \
  227. uint16 state = connect_state; \
  228. dhd_os_push_push_ring_data(dhd, DHD_EVENT_RING_ID, &state, sizeof(state)); \
  229. } while (0); \
  230. }
  231. typedef struct dhd_dbg_ring_status {
  232. uint8 name[DBGRING_NAME_MAX];
  233. uint32 flags;
  234. int ring_id; /* unique integer representing the ring */
  235. /* total memory size allocated for the buffer */
  236. uint32 ring_buffer_byte_size;
  237. uint32 verbose_level;
  238. /* number of bytes that was written to the buffer by driver */
  239. uint32 written_bytes;
  240. /* number of bytes that was read from the buffer by user land */
  241. uint32 read_bytes;
  242. /* number of records that was read from the buffer by user land */
  243. uint32 written_records;
  244. } dhd_dbg_ring_status_t;
  245. struct log_level_table {
  246. int log_level;
  247. uint16 tag;
  248. char *desc;
  249. };
  250. typedef void (*dbg_pullreq_t)(void *os_priv, const int ring_id);
  251. typedef void (*dbg_urgent_noti_t) (dhd_pub_t *dhdp, const void *data, const uint32 len);
  252. /* dhd_dbg functions */
  253. extern int dhd_dbg_attach(dhd_pub_t *dhdp, dbg_pullreq_t os_pullreq,
  254. dbg_urgent_noti_t os_urgent_notifier, void *os_priv);
  255. extern void dhd_dbg_detach(dhd_pub_t *dhdp);
  256. extern int dhd_dbg_start(dhd_pub_t *dhdp, bool start);
  257. extern void dhd_dbg_trace_evnt_handler(dhd_pub_t *dhdp, void *event_data,
  258. void *raw_event_ptr, uint datalen);
  259. extern int dhd_dbg_set_configuration(dhd_pub_t *dhdp, int ring_id,
  260. int log_level, int flags, int threshold);
  261. extern int dhd_dbg_get_ring_status(dhd_pub_t *dhdp, int ring_id,
  262. dhd_dbg_ring_status_t *dbg_ring_status);
  263. extern int dhd_dbg_ring_push(dhd_pub_t *dhdp, int ring_id, dhd_dbg_ring_entry_t *hdr, void *data);
  264. extern int dhd_dbg_ring_pull(dhd_pub_t *dhdp, int ring_id, void *data, uint32 buf_len);
  265. extern int dhd_dbg_find_ring_id(dhd_pub_t *dhdp, char *ring_name);
  266. extern void *dhd_dbg_get_priv(dhd_pub_t *dhdp);
  267. extern int dhd_dbg_send_urgent_evt(dhd_pub_t *dhdp, const void *data, const uint32 len);
  268. /* wrapper function */
  269. extern int dhd_os_dbg_attach(dhd_pub_t *dhdp);
  270. extern void dhd_os_dbg_detach(dhd_pub_t *dhdp);
  271. extern int dhd_os_dbg_register_callback(int ring_id,
  272. void (*dbg_ring_sub_cb)(void *ctx, const int ring_id, const void *data,
  273. const uint32 len, const dhd_dbg_ring_status_t dbg_ring_status));
  274. extern int dhd_os_dbg_register_urgent_notifier(dhd_pub_t *dhdp,
  275. void (*urgent_noti)(void *ctx, const void *data, const uint32 len, const uint32 fw_len));
  276. extern int dhd_os_start_logging(dhd_pub_t *dhdp, char *ring_name, int log_level,
  277. int flags, int time_intval, int threshold);
  278. extern int dhd_os_reset_logging(dhd_pub_t *dhdp);
  279. extern int dhd_os_suppress_logging(dhd_pub_t *dhdp, bool suppress);
  280. extern int dhd_os_get_ring_status(dhd_pub_t *dhdp, int ring_id,
  281. dhd_dbg_ring_status_t *dbg_ring_status);
  282. extern int dhd_os_trigger_get_ring_data(dhd_pub_t *dhdp, char *ring_name);
  283. extern int dhd_os_push_push_ring_data(dhd_pub_t *dhdp, int ring_id, void *data, int32 data_len);
  284. extern int dhd_os_dbg_get_feature(dhd_pub_t *dhdp, int32 *features);
  285. #endif /* _dhd_debug_h_ */