OSDN Git Service

am "update rtt.h for 11mc double side RTT"
[android-x86/hardware-libhardware_legacy.git] / include / hardware_legacy / wifi_logger.h
1 #include "wifi_hal.h"\r
2 \r
3 #ifndef __WIFI_HAL_LOGGER_H\r
4 #define __WIFI_HAL_LOGGER_H\r
5 \r
6 #ifdef __cplusplus\r
7 extern "C"\r
8 {\r
9 #endif /* __cplusplus */\r
10 \r
11 #define LOGGER_MAJOR_VERSION      1\r
12 #define LOGGER_MINOR_VERSION      0\r
13 #define LOGGER_MICRO_VERSION      0\r
14 \r
15 typedef int wifi_radio;\r
16 typedef int wifi_ring_buffer_id;\r
17 \r
18 typedef struct {\r
19     u8 direction:1; //  0: TX, 1: RX\r
20     u8 success:1; // whether packet was transmitted or received/decrypted successfully\r
21     u8 has_80211_header:1; // has full 802.11 header, else has 802.3 header\r
22     u8 protected_packet:1; // whether packet was encrypted\r
23     u8 tid:4; // transmit  or received tid\r
24     u8 MCS; // modulation and bandwidth\r
25     u8 rssi; // TX: RSSI of ACK for that packet\r
26              // RX: RSSI of packet\r
27     u8 num_retries; // number of attempted retries\r
28     u16 last_transmit_rate; // last transmit rate in .5 mbps\r
29     u16 link_layer_transmit_sequence; // transmit/reeive sequence for that MPDU packet\r
30     u64 firmware_entry_timestamp;  // TX: firmware timestamp (us) when packet is queued within firmware buffer\r
31                                    // for SDIO/HSIC or into PCIe buffer\r
32                                    // RX : firmware receive timestamp\r
33     u64 start_contention_timestamp; // firmware timestamp (us) when packet start contending for the\r
34                                     // medium for the first time, at head of its AC queue,\r
35                                     // or as part of an MPDU or A-MPDU. This timestamp is not updated\r
36                                     // for each retry, only the first transmit attempt.\r
37     u64 transmit_success_timestamp; // fimrware timestamp (us) when packet is successfully transmitted\r
38                                     // or aborted because it has exhausted its maximum number of retries\r
39     u8 data[0]; // packet data. The length of packet data is determined by the entry_size field of\r
40                 // the wifi_ring_buffer_entry structure. It is expected that first bytes of the\r
41                 // packet, or packet headers only (up to TCP or RTP/UDP headers) will be copied into the ring\r
42 } wifi_ring_per_packet_status_entry;\r
43 \r
44 \r
45 // Below events refer to the wifi_connectivity_event ring and shall be supported\r
46 \r
47 #define WIFI_EVENT_ASSOCIATION_REQUESTED 0 // driver receive association command from kernel\r
48 #define WIFI_EVENT_AUTH_COMPLETE 1\r
49 #define WIFI_EVENT_ASSOC_COMPLETE 2\r
50 #define WIFI_EVENT_FW_AUTH_STARTED 3 // received firmware event indicating auth frames are sent\r
51 #define WIFI_EVENT_FW_ASSOC_STARTED 4 // received firmware event indicating assoc frames are sent\r
52 #define WIFI_EVENT_FW_RE_ASSOC_STARTED 5 // received firmware event indicating reassoc frames are sent\r
53 #define WIFI_EVENT_DRIVER_SCAN_REQUESTED 6\r
54 #define WIFI_EVENT_DRIVER_SCAN_RESULT_FOUND 7\r
55 #define WIFI_EVENT_DRIVER_SCAN_COMPLETE 8\r
56 #define WIFI_EVENT_G_SCAN_STARTED 9\r
57 #define WIFI_EVENT_G_SCAN_COMPLETE 10\r
58 #define WIFI_EVENT_DISASSOCIATION_REQUESTED 11\r
59 #define WIFI_EVENT_RE_ASSOCIATION_REQUESTED 12\r
60 #define WIFI_EVENT_ROAM_REQUESTED 13\r
61 #define WIFI_EVENT_BEACON_RECEIVED 14 // received beacon from AP (event enabled only in verbose mode)\r
62 #define WIFI_EVENT_ROAM_SCAN_STARTED 15 // firmware has triggered a roam scan (not g-scan)\r
63 #define WIFI_EVENT_ROAM_SCAN_COMPLETE 16 // firmware has completed a roam scan (not g-scan)\r
64 #define WIFI_EVENT_ROAM_SEARCH_STARTED 17 // firmware has started searching for roam candidates (with reason =xx)\r
65 #define WIFI_EVENT_ROAM_SEARCH_STOPPED 18 // firmware has stopped searching for roam candidates (with reason =xx)\r
66 #define WIFI_EVENT_CHANNEL_SWITCH_ANOUNCEMENT 20 // received channel switch anouncement from AP\r
67 #define WIFI_EVENT_FW_EAPOL_FRAME_TRANSMIT_START 21 // fw start transmit eapol frame, with EAPOL index 1-4\r
68 #define WIFI_EVENT_FW_EAPOL_FRAME_TRANSMIT_STOP 22 // fw gives up eapol frame, with rate, success/failure and number retries\r
69 #define WIFI_EVENT_DRIVER_EAPOL_FRAME_TRANSMIT_REQUESTED 23 // kernel queue EAPOL for transmission in tdriver\r
70                                                             // with EAPOL index 1-4\r
71 #define WIFI_EVENT_FW_EAPOL_FRAME_RECEIVED 24 // with rate, regardless of the fact that EAPOL frame\r
72                                            // is accepted or rejected by firmware\r
73 #define WIFI_EVENT_DRIVER_EAPOL_FRAME_RECEIVED 26 // with rate, and eapol index, driver has received EAPOL\r
74                                                     //frame and will queue it up to wpa_supplicant\r
75 #define WIFI_EVENT_BLOCK_ACK_NEGOTIATION_COMPLETE 27 // with success/failure, parameters\r
76 #define WIFI_EVENT_BT_COEX_BT_SCO_START 28\r
77 #define WIFI_EVENT_BT_COEX_BT_SCO_STOP 29\r
78 #define WIFI_EVENT_BT_COEX_BT_SCAN_START 30 // for paging/scan etc..., when BT starts transmiting twice per BT slot\r
79 #define WIFI_EVENT_BT_COEX_BT_SCAN_STOP 31\r
80 #define WIFI_EVENT_BT_COEX_BT_HID_START 32\r
81 #define WIFI_EVENT_BT_COEX_BT_HID_STOP 33\r
82 #define WIFI_EVENT_ROAM_AUTH_STARTED 34 // firmware sends auth frame in roaming to next candidate\r
83 #define WIFI_EVENT_ROAM_AUTH_COMPLETE 35 // firmware receive auth confirm from ap\r
84 #define WIFI_EVENT_ROAM_ASSOC_STARTED 36 // firmware sends assoc/reassoc frame in roaming to next candidate\r
85 #define WIFI_EVENT_ROAM_ASSOC_COMPLETE 37 // firmware receive assoc/reassoc confirm from ap\r
86 \r
87 \r
88 typedef struct {\r
89     u16 event;\r
90     u8 event_data[0]; // separate parameter structure per event to be provided and optional data\r
91                         // the event_data is expected to include an official android part, with some parameter\r
92                         // as transmit rate, num retries, num scan result found etc...\r
93                         // as well, event_data can include a vendor proprietary part which is understood\r
94                         // by the developer only.\r
95 } wifi_ring_buffer_driver_connectivity_event;\r
96 \r
97 static char connectivity_event_ring_name[] = "wifi_connectivity_events"; //ring buffer name for connectivity events ring\r
98 \r
99 /**\r
100  * This structure represent a logger entry within a ring buffer.\r
101  * Wifi driver are responsible to manage the ring buffer and write the debug\r
102  * information into those rings.\r
103  *\r
104  * In general, the debug entries can be used to store meaningful 802.11 information (SME, MLME,\r
105  * connection and packet statistics) as well as vendor proprietary data that is specific to a\r
106  * specific driver or chipset.\r
107  * Binary entries can be used so as to store packet data or vendor specific information and\r
108  * will be treated as blobs of data by android.\r
109  *\r
110  * A user land process will be started by framework so as to periodically retrieve the\r
111  * data logged by drivers into their ring buffer, store the data into log files and include\r
112  * the logs into android bugreports.\r
113  */\r
114 typedef struct {\r
115     u16 entry_size:13;\r
116     u16 binary:1; //set for binary entries\r
117     u16 has_timestamp:1; //set if 64 bits timestamp is present\r
118     u16 reserved:1;\r
119     u8 type; // Per ring specific\r
120     u8 resvd;\r
121     u64 timestamp; //present if has_timestamp bit is set.\r
122     union {\r
123         u8 data[0];\r
124         wifi_ring_buffer_driver_connectivity_event connectivity_event;\r
125         };\r
126 } wifi_ring_buffer_entry;\r
127 \r
128 #define WIFI_RING_BUFFER_FLAG_HAS_BINARY_ENTRIES         0x00000001     // set if binary entries are present\r
129 #define WIFI_RING_BUFFER_FLAG_HAS_ASCII_ENTRIES          0x00000002     // set if ascii entries are present\r
130 \r
131 /* ring buffer params */\r
132 /**\r
133  * written_bytes and read_bytes implement a producer consumer API\r
134  *     hence written_bytes >= read_bytes\r
135  * a modulo arithmetic of the buffer size has to be applied to those counters:\r
136  * actual offset into ring buffer = written_bytes % ring_buffer_byte_size\r
137  *\r
138  */\r
139 typedef struct {\r
140    u8 name[32];\r
141    u32 flags;\r
142    u64 fd; // linux file descriptor for that buffer\r
143    u32 ring_buffer_byte_size;   // total memory size allocated for the buffer\r
144    u32 verbose_level; //\r
145    u32 written_bytes; // number of bytes that was written to the buffer by driver, monotonously increasing integer\r
146    u32 read_bytes;  // number of bytes that was read from the buffer by user land, monotonously increasing integer\r
147 } wifi_ring_buffer_status;\r
148 \r
149 /**\r
150  * API to trigger the debug collection.\r
151  *  Unless his API is invoked - logging is not triggered.\r
152  *  - verbose_level 0 corresponds to no collection\r
153  *  - verbose_level 1+ are TBD, with increasing level of logging\r
154  *\r
155  * buffer_name represent the name of the ring for which data collection shall start.\r
156  */\r
157 wifi_error wifi_set_logging_level(wifi_interface_handle iface, u32 verbose_level, u8 * buffer_name);\r
158 \r
159 /* callback for reporting ring buffer status */\r
160 typedef struct {\r
161   void (*on_ring_buffer_status_results) (wifi_request_id id, u32 num_buffers, wifi_ring_buffer_status *status);\r
162 } wifi_ring_buffer_status_result_handler;\r
163 \r
164 /* api to get the status of a ring buffer */\r
165 wifi_error wifi_get_ring_buffer_status(wifi_request_id id,\r
166         wifi_interface_handle iface, wifi_ring_buffer_id ring_id, wifi_ring_buffer_status_result_handler handler);\r
167 \r
168 /* api to collect a firmware memory dump for a given iface */\r
169 wifi_error wifi_get_firmware_memory_dump(wifi_request_id id,\r
170         wifi_interface_handle iface, char * buffer, int buffer_size);\r
171 \r
172 /* api to collect a firmware version string */\r
173 wifi_error wifi_get_firmware_version(wifi_request_id id,\r
174         wifi_interface_handle iface, char * buffer, int buffer_size);\r
175 \r
176 /* api to collect a driver version string */\r
177 wifi_error wifi_get_driver_version(wifi_request_id id,\r
178         wifi_interface_handle iface, char * buffer, int buffer_size);\r
179 \r
180 \r
181 /* Feature set */\r
182 #define WIFI_LOGGER_MEMORY_DUMP_SUPPORTED 1\r
183 #define WIFI_LOGGER_PER_PACKET_TX_RX_STATUS_SUPPORTED 2\r
184 \r
185 wifi_error wifi_get_logger_supported_feature_set(wifi_interface_handle handle, unsigned int *support);\r
186 \r
187 \r
188 #ifdef __cplusplus\r
189 }\r
190 #endif /* __cplusplus */\r
191 \r
192 #endif /*__WIFI_HAL_STATS_ */\r
193 \r