xref: /wlan-driver/qcacld-3.0/core/hdd/src/wlan_hdd_connectivity_logging.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /*
19  * DOC: wlan_hdd_connectivity_logging.c
20  *
21  * Implementation for the Common connectivity and roam logging api.
22  */
23 
24 #include "wlan_hdd_connectivity_logging.h"
25 
26 #define GET_ATTR_OFFSET(member) \
27 	qdf_offsetof(struct wlan_log_record, member)
28 
29 #define ATTR_GET_VALUE(type, record, field_offset) \
30 	(*(type *)((uint8_t *)record + field_offset))
31 
32 /**
33  * struct connectivity_log_attr  - Connectivity logging attribute info
34  * @attribute_id: Vendor attribute ID. Defined by enum qca_wlan_vendor_attr_diag
35  * @attribute_type: NL type of the attribute
36  * @attribute_length: Length of the attribute
37  * @field_offset: Field offset
38  */
39 struct connectivity_log_attr {
40 	enum qca_wlan_vendor_attr_diag attribute_id;
41 	uint8_t attribute_type;
42 	uint16_t attribute_length;
43 	uint16_t field_offset;
44 };
45 
46 static const enum qca_vendor_attr_diag_event_type
47 hdd_connectivity_log_attr_table[WLAN_TAG_MAX] = {
48 	[WLAN_CONNECTING] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_CONNECTING,
49 	[WLAN_CONNECTING_FAIL] =
50 		QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_CONNECTING_FAIL,
51 	[WLAN_AUTH_REQ] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_AUTH_REQ,
52 	[WLAN_AUTH_RESP] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_AUTH_RESP,
53 	[WLAN_ASSOC_REQ] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ASSOC_REQ,
54 	[WLAN_ASSOC_RSP] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ASSOC_RESP,
55 	[WLAN_REASSOC_REQ] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_REASSOC_REQ,
56 	[WLAN_REASSOC_RSP] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_REASSOC_RES,
57 	[WLAN_DEAUTH_RX] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DEAUTH_RX,
58 	[WLAN_DEAUTH_TX] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DEAUTH_TX,
59 	[WLAN_DISASSOC_RX] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DISASSOC_RX,
60 	[WLAN_DISASSOC_TX] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DISASSOC_TX,
61 	[WLAN_DISCONN_BMISS] =
62 			QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_BEACON_LOSS_DISCONN,
63 	[WLAN_ROAM_SCAN_START] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_SCAN_START,
64 	[WLAN_ROAM_SCAN_DONE] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_SCAN_DONE,
65 	[WLAN_ROAM_SCORE_CURR_AP] =
66 		QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_SCORE_CURR_AP,
67 	[WLAN_ROAM_SCORE_CAND_AP] =
68 		QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_SCORE_CAND_AP,
69 	[WLAN_ROAM_RESULT] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_RESULT,
70 	[WLAN_ROAM_CANCEL] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_CANCEL,
71 	[WLAN_BTM_REQ] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_BTM_REQ,
72 	[WLAN_BTM_QUERY] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_BTM_QUERY,
73 	[WLAN_BTM_RESP] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_BTM_RESP,
74 	[WLAN_BTM_REQ_CANDI] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_BTM_REQ_CANDI,
75 	[WLAN_ROAM_WTC] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_BTM_WTC,
76 	[WLAN_DHCP_DISCOVER] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DHCP_DISCOVER,
77 	[WLAN_DHCP_OFFER] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DHCP_OFFER,
78 	[WLAN_DHCP_REQUEST] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DHCP_REQUEST,
79 	[WLAN_DHCP_ACK] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DHCP_ACK,
80 	[WLAN_DHCP_NACK] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DHCP_NACK,
81 	[WLAN_EAPOL_M1] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAPOL_M1,
82 	[WLAN_EAPOL_M2] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAPOL_M2,
83 	[WLAN_EAPOL_M3] =  QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAPOL_M3,
84 	[WLAN_EAPOL_M4] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAPOL_M4,
85 	[WLAN_GTK_M1] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_GTK_M1,
86 	[WLAN_GTK_M2] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_GTK_M2,
87 	[WLAN_EAP_REQUEST] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAP_REQUEST,
88 	[WLAN_EAP_RESPONSE] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAP_RESPONSE,
89 	[WLAN_EAP_SUCCESS] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAP_SUCCESS,
90 	[WLAN_EAP_FAILURE] = QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAP_FAILURE,
91 };
92 
93 #define WLAN_CONNECTIVITY_ATTR_END (QCA_WLAN_VENDOR_ATTR_DIAG_MAX + 1)
94 
95 static const struct connectivity_log_attr
96 connectivity_attr_table[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_MAX + 1]
97 			[WLAN_CONNECTIVITY_ATTR_END] = {
98 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_CONNECTING] = {
99 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,    sizeof(uint32_t),
100 	 GET_ATTR_OFFSET(log_subtype)},
101 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP, NLA_U64, sizeof(uint64_t),
102 	 GET_ATTR_OFFSET(timestamp_us)},
103 	 {QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
104 	 GET_ATTR_OFFSET(ktime_us)},
105 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX, NLA_U8, sizeof(uint8_t),
106 	 GET_ATTR_OFFSET(vdev_id)},
107 	{QCA_WLAN_VENDOR_ATTR_DIAG_SSID, NLA_BINARY,
108 	 GET_ATTR_OFFSET(conn_info.ssid_len), GET_ATTR_OFFSET(conn_info.ssid)},
109 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,  NLA_BINARY, QDF_MAC_ADDR_SIZE,
110 	 GET_ATTR_OFFSET(bssid)},
111 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID_HINT, NLA_BINARY, QDF_MAC_ADDR_SIZE,
112 	 GET_ATTR_OFFSET(conn_info.bssid_hint)},
113 	{QCA_WLAN_VENDOR_ATTR_DIAG_FREQ,       NLA_U16,    sizeof(uint16_t),
114 	 GET_ATTR_OFFSET(conn_info.freq)},
115 	{QCA_WLAN_VENDOR_ATTR_DIAG_FREQ_HINT,  NLA_U16,    sizeof(uint16_t),
116 	 GET_ATTR_OFFSET(conn_info.freq_hint)},
117 	{QCA_WLAN_VENDOR_ATTR_DIAG_PAIRWISE_SUITE,   NLA_U32, sizeof(uint32_t),
118 	 GET_ATTR_OFFSET(conn_info.pairwise)},
119 	{QCA_WLAN_VENDOR_ATTR_DIAG_AKM,              NLA_U32, sizeof(uint32_t),
120 	 GET_ATTR_OFFSET(conn_info.akm)},
121 	{QCA_WLAN_VENDOR_ATTR_DIAG_GROUP_SUITE,      NLA_U32, sizeof(uint32_t),
122 	 GET_ATTR_OFFSET(conn_info.group)},
123 	{QCA_WLAN_VENDOR_ATTR_DIAG_GROUP_MGMT_SUITE, NLA_U32, sizeof(uint32_t),
124 	 GET_ATTR_OFFSET(conn_info.group_mgmt)},
125 	{QCA_WLAN_VENDOR_ATTR_DIAG_AUTH_ALGO,        NLA_U8,  sizeof(uint8_t),
126 	 GET_ATTR_OFFSET(conn_info.auth_type)},
127 	{QCA_WLAN_VENDOR_ATTR_DIAG_BT_COEX_ACTIVE,   NLA_FLAG, sizeof(uint8_t),
128 	 GET_ATTR_OFFSET(conn_info.is_bt_coex_active)},
129 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
130 	},
131 
132 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_CONNECTING_FAIL] = {
133 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32, sizeof(uint32_t),
134 	 GET_ATTR_OFFSET(log_subtype)},
135 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64, sizeof(uint64_t),
136 	 GET_ATTR_OFFSET(timestamp_us)},
137 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
138 	 GET_ATTR_OFFSET(ktime_us)},
139 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8, sizeof(uint8_t),
140 	 GET_ATTR_OFFSET(vdev_id)},
141 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,      NLA_BINARY, QDF_MAC_ADDR_SIZE,
142 	 GET_ATTR_OFFSET(bssid)},
143 	{QCA_WLAN_VENDOR_ATTR_DIAG_FREQ,       NLA_U16, sizeof(uint16_t),
144 	 GET_ATTR_OFFSET(conn_info.freq)},
145 	{QCA_WLAN_VENDOR_ATTR_DIAG_REASON_CODE, NLA_U16, sizeof(uint16_t),
146 	 GET_ATTR_OFFSET(conn_info.conn_status)},
147 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
148 	},
149 
150 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_AUTH_REQ] = {
151 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
152 	 GET_ATTR_OFFSET(log_subtype)},
153 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,   NLA_U64,  sizeof(uint64_t),
154 	 GET_ATTR_OFFSET(timestamp_us)},
155 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
156 	 GET_ATTR_OFFSET(ktime_us)},
157 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,     NLA_U8,   sizeof(uint8_t),
158 	 GET_ATTR_OFFSET(vdev_id)},
159 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,       NLA_BINARY, QDF_MAC_ADDR_SIZE,
160 	 GET_ATTR_OFFSET(bssid)},
161 	{QCA_WLAN_VENDOR_ATTR_DIAG_RSSI,        NLA_S32,  sizeof(int32_t),
162 	 GET_ATTR_OFFSET(pkt_info.rssi)},
163 	{QCA_WLAN_VENDOR_ATTR_DIAG_AUTH_ALGO,   NLA_U8,   sizeof(uint8_t),
164 	 GET_ATTR_OFFSET(pkt_info.auth_algo)},
165 	{QCA_WLAN_VENDOR_ATTR_DIAG_SAE_AUTH_FRAME_TYPE, NLA_U8, sizeof(uint8_t),
166 	 GET_ATTR_OFFSET(pkt_info.auth_type)},
167 	{QCA_WLAN_VENDOR_ATTR_DIAG_SEQUENCE_NUMBER, NLA_U16,  sizeof(uint16_t),
168 	 GET_ATTR_OFFSET(pkt_info.seq_num)},
169 	{QCA_WLAN_VENDOR_ATTR_DIAG_STATUS_CODE, NLA_U8, sizeof(uint8_t),
170 	 GET_ATTR_OFFSET(pkt_info.frame_status_code)},
171 	{QCA_WLAN_VENDOR_ATTR_DIAG_FRAME_TX_STATUS,   NLA_U8, sizeof(uint8_t),
172 	 GET_ATTR_OFFSET(pkt_info.tx_status)},
173 	{QCA_WLAN_VENDOR_ATTR_DIAG_IS_RETRY_FRAME, NLA_FLAG, sizeof(uint8_t),
174 	 GET_ATTR_OFFSET(pkt_info.is_retry_frame)},
175 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
176 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
177 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
178 	},
179 
180 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_AUTH_RESP] = {
181 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32, sizeof(uint32_t),
182 	 GET_ATTR_OFFSET(log_subtype)},
183 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64, sizeof(uint64_t),
184 	 GET_ATTR_OFFSET(timestamp_us)},
185 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
186 	 GET_ATTR_OFFSET(ktime_us)},
187 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8, sizeof(uint8_t),
188 	 GET_ATTR_OFFSET(vdev_id)},
189 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,      NLA_BINARY, QDF_MAC_ADDR_SIZE,
190 	 GET_ATTR_OFFSET(bssid)},
191 	{QCA_WLAN_VENDOR_ATTR_DIAG_AUTH_ALGO,  NLA_U8, sizeof(uint8_t),
192 	 GET_ATTR_OFFSET(pkt_info.auth_algo)},
193 	{QCA_WLAN_VENDOR_ATTR_DIAG_SAE_AUTH_FRAME_TYPE, NLA_U8, sizeof(uint8_t),
194 	 GET_ATTR_OFFSET(pkt_info.auth_type)},
195 	{QCA_WLAN_VENDOR_ATTR_DIAG_SEQUENCE_NUMBER,   NLA_U16, sizeof(uint16_t),
196 	 GET_ATTR_OFFSET(pkt_info.seq_num)},
197 	{QCA_WLAN_VENDOR_ATTR_DIAG_STATUS_CODE, NLA_U8,  sizeof(uint8_t),
198 	 GET_ATTR_OFFSET(pkt_info.frame_status_code)},
199 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
200 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
201 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
202 	},
203 
204 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ASSOC_REQ] = {
205 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
206 	 GET_ATTR_OFFSET(log_subtype)},
207 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,   NLA_U64,  sizeof(uint64_t),
208 	 GET_ATTR_OFFSET(timestamp_us)},
209 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
210 	 GET_ATTR_OFFSET(ktime_us)},
211 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,     NLA_U8,   sizeof(uint8_t),
212 	 GET_ATTR_OFFSET(vdev_id)},
213 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,       NLA_BINARY, QDF_MAC_ADDR_SIZE,
214 	 GET_ATTR_OFFSET(bssid)},
215 	{QCA_WLAN_VENDOR_ATTR_DIAG_RSSI,        NLA_S32,  sizeof(int32_t),
216 	 GET_ATTR_OFFSET(pkt_info.rssi)},
217 	{QCA_WLAN_VENDOR_ATTR_DIAG_SEQUENCE_NUMBER,   NLA_U16, sizeof(uint16_t),
218 	 GET_ATTR_OFFSET(pkt_info.seq_num)},
219 	{QCA_WLAN_VENDOR_ATTR_DIAG_FRAME_TX_STATUS,   NLA_U8, sizeof(uint8_t),
220 	 GET_ATTR_OFFSET(pkt_info.tx_status)},
221 	{QCA_WLAN_VENDOR_ATTR_DIAG_IS_RETRY_FRAME,    NLA_FLAG, sizeof(uint8_t),
222 	 GET_ATTR_OFFSET(pkt_info.is_retry_frame)},
223 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
224 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
225 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
226 	},
227 
228 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ASSOC_RESP] = {
229 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
230 	 GET_ATTR_OFFSET(log_subtype)},
231 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,   NLA_U64,  sizeof(uint64_t),
232 	 GET_ATTR_OFFSET(timestamp_us)},
233 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
234 	 GET_ATTR_OFFSET(ktime_us)},
235 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,     NLA_U8,   sizeof(uint8_t),
236 	 GET_ATTR_OFFSET(vdev_id)},
237 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,       NLA_BINARY, QDF_MAC_ADDR_SIZE,
238 	 GET_ATTR_OFFSET(bssid)},
239 	{QCA_WLAN_VENDOR_ATTR_DIAG_SEQUENCE_NUMBER,   NLA_U16, sizeof(uint16_t),
240 	 GET_ATTR_OFFSET(pkt_info.seq_num)},
241 	{QCA_WLAN_VENDOR_ATTR_DIAG_STATUS_CODE, NLA_U8,  sizeof(uint8_t),
242 	 GET_ATTR_OFFSET(pkt_info.frame_status_code)},
243 	{QCA_WLAN_VENDOR_ATTR_DIAG_ASSOC_ID,   NLA_U16, sizeof(uint16_t),
244 	 GET_ATTR_OFFSET(pkt_info.assoc_id)},
245 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
246 	},
247 
248 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_REASSOC_REQ] = {
249 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
250 	 GET_ATTR_OFFSET(log_subtype)},
251 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,   NLA_U64,  sizeof(uint64_t),
252 	 GET_ATTR_OFFSET(timestamp_us)},
253 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
254 	 GET_ATTR_OFFSET(ktime_us)},
255 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,     NLA_U8,   sizeof(uint8_t),
256 	 GET_ATTR_OFFSET(vdev_id)},
257 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,       NLA_BINARY, QDF_MAC_ADDR_SIZE,
258 	 GET_ATTR_OFFSET(bssid)},
259 	{QCA_WLAN_VENDOR_ATTR_DIAG_RSSI,        NLA_S32,  sizeof(int32_t),
260 	 GET_ATTR_OFFSET(pkt_info.rssi)},
261 	{QCA_WLAN_VENDOR_ATTR_DIAG_SEQUENCE_NUMBER,   NLA_U16, sizeof(uint16_t),
262 	 GET_ATTR_OFFSET(pkt_info.seq_num)},
263 	{QCA_WLAN_VENDOR_ATTR_DIAG_FRAME_TX_STATUS,   NLA_U8, sizeof(uint8_t),
264 	 GET_ATTR_OFFSET(pkt_info.tx_status)},
265 	{QCA_WLAN_VENDOR_ATTR_DIAG_IS_RETRY_FRAME,    NLA_FLAG, sizeof(uint8_t),
266 	 GET_ATTR_OFFSET(pkt_info.is_retry_frame)},
267 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
268 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
269 	{WLAN_CONNECTIVITY_ATTR_END, 0, 0, 0},
270 	},
271 
272 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_REASSOC_RES] = {
273 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
274 	 GET_ATTR_OFFSET(log_subtype)},
275 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,   NLA_U64,  sizeof(uint64_t),
276 	 GET_ATTR_OFFSET(timestamp_us)},
277 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
278 	 GET_ATTR_OFFSET(ktime_us)},
279 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,     NLA_U8,   sizeof(uint8_t),
280 	 GET_ATTR_OFFSET(vdev_id)},
281 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,       NLA_BINARY, QDF_MAC_ADDR_SIZE,
282 	 GET_ATTR_OFFSET(bssid)},
283 	{QCA_WLAN_VENDOR_ATTR_DIAG_SEQUENCE_NUMBER,   NLA_U16, sizeof(uint16_t),
284 	 GET_ATTR_OFFSET(pkt_info.seq_num)},
285 	{QCA_WLAN_VENDOR_ATTR_DIAG_STATUS_CODE, NLA_U8,  sizeof(uint8_t),
286 	 GET_ATTR_OFFSET(pkt_info.frame_status_code)},
287 	{QCA_WLAN_VENDOR_ATTR_DIAG_ASSOC_ID,   NLA_U16, sizeof(uint16_t),
288 	 GET_ATTR_OFFSET(pkt_info.assoc_id)},
289 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
290 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
291 	{WLAN_CONNECTIVITY_ATTR_END, 0, 0, 0},
292 	},
293 
294 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DEAUTH_RX] = {
295 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
296 	 GET_ATTR_OFFSET(log_subtype)},
297 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64,  sizeof(uint64_t),
298 	 GET_ATTR_OFFSET(timestamp_us)},
299 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
300 	 GET_ATTR_OFFSET(ktime_us)},
301 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,     NLA_U8,   sizeof(uint8_t),
302 	 GET_ATTR_OFFSET(vdev_id)},
303 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,       NLA_BINARY, QDF_MAC_ADDR_SIZE,
304 	 GET_ATTR_OFFSET(bssid)},
305 	{QCA_WLAN_VENDOR_ATTR_DIAG_RSSI,            NLA_S32,  sizeof(int32_t),
306 	 GET_ATTR_OFFSET(pkt_info.rssi)},
307 	{QCA_WLAN_VENDOR_ATTR_DIAG_SEQUENCE_NUMBER,  NLA_U16, sizeof(uint16_t),
308 	 GET_ATTR_OFFSET(pkt_info.seq_num)},
309 	{QCA_WLAN_VENDOR_ATTR_DIAG_REASON_CODE, NLA_U16, sizeof(uint16_t),
310 	 GET_ATTR_OFFSET(pkt_info.frame_status_code)},
311 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
312 	},
313 
314 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DEAUTH_TX] = {
315 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
316 	 GET_ATTR_OFFSET(log_subtype)},
317 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP, NLA_U64,  sizeof(uint64_t),
318 	 GET_ATTR_OFFSET(timestamp_us)},
319 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
320 	 GET_ATTR_OFFSET(ktime_us)},
321 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,     NLA_U8,   sizeof(uint8_t),
322 	 GET_ATTR_OFFSET(vdev_id)},
323 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,       NLA_BINARY, QDF_MAC_ADDR_SIZE,
324 	 GET_ATTR_OFFSET(bssid)},
325 	{QCA_WLAN_VENDOR_ATTR_DIAG_RSSI,        NLA_S32, sizeof(int32_t),
326 	 GET_ATTR_OFFSET(pkt_info.rssi)},
327 	{QCA_WLAN_VENDOR_ATTR_DIAG_SEQUENCE_NUMBER, NLA_U16, sizeof(uint16_t),
328 	 GET_ATTR_OFFSET(pkt_info.seq_num)},
329 	{QCA_WLAN_VENDOR_ATTR_DIAG_REASON_CODE, NLA_U16, sizeof(uint16_t),
330 	 GET_ATTR_OFFSET(pkt_info.frame_status_code)},
331 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
332 	},
333 
334 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DISASSOC_RX] = {
335 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
336 	 GET_ATTR_OFFSET(log_subtype)},
337 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,   NLA_U64,  sizeof(uint64_t),
338 	 GET_ATTR_OFFSET(timestamp_us)},
339 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
340 	 GET_ATTR_OFFSET(ktime_us)},
341 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX, NLA_U8, sizeof(uint8_t),
342 	 GET_ATTR_OFFSET(vdev_id)},
343 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID, NLA_BINARY, QDF_MAC_ADDR_SIZE,
344 	 GET_ATTR_OFFSET(bssid)},
345 	{QCA_WLAN_VENDOR_ATTR_DIAG_RSSI, NLA_S32, sizeof(int32_t),
346 	 GET_ATTR_OFFSET(pkt_info.rssi)},
347 	{QCA_WLAN_VENDOR_ATTR_DIAG_SEQUENCE_NUMBER, NLA_U16, sizeof(uint16_t),
348 	 GET_ATTR_OFFSET(pkt_info.seq_num)},
349 	{QCA_WLAN_VENDOR_ATTR_DIAG_REASON_CODE, NLA_U16, sizeof(uint16_t),
350 	 GET_ATTR_OFFSET(pkt_info.frame_status_code)},
351 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
352 	},
353 
354 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DISASSOC_TX] = {
355 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
356 	 GET_ATTR_OFFSET(log_subtype)},
357 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP, NLA_U64,  sizeof(uint64_t),
358 	 GET_ATTR_OFFSET(timestamp_us)},
359 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
360 	 GET_ATTR_OFFSET(ktime_us)},
361 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX, NLA_U8, sizeof(uint8_t),
362 	 GET_ATTR_OFFSET(vdev_id)},
363 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID, NLA_BINARY, QDF_MAC_ADDR_SIZE,
364 	 GET_ATTR_OFFSET(bssid)},
365 	{QCA_WLAN_VENDOR_ATTR_DIAG_RSSI, NLA_S32, sizeof(int32_t),
366 	 GET_ATTR_OFFSET(pkt_info.rssi)},
367 	{QCA_WLAN_VENDOR_ATTR_DIAG_SEQUENCE_NUMBER, NLA_U16, sizeof(uint16_t),
368 	 GET_ATTR_OFFSET(pkt_info.seq_num)},
369 	{QCA_WLAN_VENDOR_ATTR_DIAG_REASON_CODE, NLA_U16, sizeof(uint16_t),
370 	 GET_ATTR_OFFSET(pkt_info.frame_status_code)},
371 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
372 	},
373 
374 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_BEACON_LOSS_DISCONN] = {
375 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
376 	 GET_ATTR_OFFSET(log_subtype)},
377 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP, NLA_U64,  sizeof(uint64_t),
378 	 GET_ATTR_OFFSET(timestamp_us)},
379 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
380 	 GET_ATTR_OFFSET(ktime_us)},
381 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX, NLA_U8, sizeof(uint8_t),
382 	 GET_ATTR_OFFSET(vdev_id)},
383 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID, NLA_BINARY, QDF_MAC_ADDR_SIZE,
384 	 GET_ATTR_OFFSET(bssid)},
385 	{QCA_WLAN_VENDOR_ATTR_DIAG_RSSI,  NLA_S32, sizeof(int32_t),
386 	 GET_ATTR_OFFSET(pkt_info.rssi)},
387 	{QCA_WLAN_VENDOR_ATTR_DIAG_REASON_CODE, NLA_U16, sizeof(uint16_t),
388 	 GET_ATTR_OFFSET(pkt_info.frame_status_code)},
389 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
390 	},
391 
392 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_SCAN_START] = {
393 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
394 	 GET_ATTR_OFFSET(log_subtype)},
395 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,   NLA_U64,  sizeof(uint64_t),
396 	 GET_ATTR_OFFSET(timestamp_us)},
397 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
398 	 GET_ATTR_OFFSET(ktime_us)},
399 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,     NLA_U8,   sizeof(uint8_t),
400 	 GET_ATTR_OFFSET(vdev_id)},
401 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_TRIGGER_REASON,  NLA_U8,
402 	 sizeof(uint8_t), GET_ATTR_OFFSET(roam_trig.trigger_reason)},
403 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_TRIGGER_SUB_REASON,  NLA_U8,
404 	 sizeof(uint8_t), GET_ATTR_OFFSET(roam_trig.trigger_sub_reason)},
405 	{QCA_WLAN_VENDOR_ATTR_DIAG_RSSI, NLA_S32, sizeof(int32_t),
406 	 GET_ATTR_OFFSET(roam_trig.current_rssi)},
407 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_CU,  NLA_U8, sizeof(uint8_t),
408 	 GET_ATTR_OFFSET(roam_trig.cu_load)},
409 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_SCAN_TYPE, NLA_U8, sizeof(uint8_t),
410 	 GET_ATTR_OFFSET(roam_trig.is_full_scan)},
411 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_RSSI_THRESHOLD, NLA_S32,
412 	 sizeof(int32_t), GET_ATTR_OFFSET(roam_trig.rssi_threshold)},
413 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
414 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
415 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
416 	},
417 
418 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_SCAN_DONE] = {
419 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
420 	 GET_ATTR_OFFSET(log_subtype)},
421 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,   NLA_U64,  sizeof(uint64_t),
422 	 GET_ATTR_OFFSET(timestamp_us)},
423 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
424 	 GET_ATTR_OFFSET(ktime_us)},
425 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,     NLA_U8,   sizeof(uint8_t),
426 	 GET_ATTR_OFFSET(vdev_id)},
427 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_AP_COUNT,  NLA_U8, sizeof(uint8_t),
428 	 GET_ATTR_OFFSET(roam_scan.cand_ap_count)},
429 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
430 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
431 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_FREQ_LIST, NLA_NESTED, sizeof(uint16_t),
432 	 GET_ATTR_OFFSET(roam_scan.scan_freq)},
433 	{QCA_WLAN_VENDOR_ATTR_DIAG_BT_COEX_ACTIVE,   NLA_FLAG, sizeof(uint8_t),
434 	 GET_ATTR_OFFSET(roam_scan.is_btcoex_active)},
435 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
436 	},
437 
438 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_SCORE_CURR_AP] = {
439 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
440 	 GET_ATTR_OFFSET(log_subtype)},
441 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64,
442 	 sizeof(uint64_t), GET_ATTR_OFFSET(timestamp_us)},
443 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
444 	 GET_ATTR_OFFSET(ktime_us)},
445 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8, sizeof(uint8_t),
446 	 GET_ATTR_OFFSET(vdev_id)},
447 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,  NLA_BINARY, QDF_MAC_ADDR_SIZE,
448 	 GET_ATTR_OFFSET(ap.cand_bssid)},
449 	{QCA_WLAN_VENDOR_ATTR_DIAG_FREQ,   NLA_U16, sizeof(uint16_t),
450 	 GET_ATTR_OFFSET(ap.freq)},
451 	{QCA_WLAN_VENDOR_ATTR_DIAG_RSSI,   NLA_S32, sizeof(int32_t),
452 	 GET_ATTR_OFFSET(ap.rssi)},
453 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_CU, NLA_U8, sizeof(uint8_t),
454 	 GET_ATTR_OFFSET(ap.cu_load)},
455 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_SCORE,  NLA_U16, sizeof(uint16_t),
456 	 GET_ATTR_OFFSET(ap.total_score)},
457 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
458 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
459 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
460 	},
461 
462 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_SCORE_CAND_AP] = {
463 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
464 	 GET_ATTR_OFFSET(log_subtype)},
465 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,   NLA_U64,  sizeof(uint64_t),
466 	 GET_ATTR_OFFSET(timestamp_us)},
467 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
468 	 GET_ATTR_OFFSET(ktime_us)},
469 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,     NLA_U8,   sizeof(uint8_t),
470 	 GET_ATTR_OFFSET(vdev_id)},
471 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_AP_RANK, NLA_U8, sizeof(uint8_t),
472 	 GET_ATTR_OFFSET(ap.idx)},
473 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_CU, NLA_U8, sizeof(uint8_t),
474 	 GET_ATTR_OFFSET(ap.cu_load)},
475 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,  NLA_BINARY, QDF_MAC_ADDR_SIZE,
476 	 GET_ATTR_OFFSET(ap.cand_bssid)},
477 	{QCA_WLAN_VENDOR_ATTR_DIAG_FREQ,   NLA_U16, sizeof(uint16_t),
478 	 GET_ATTR_OFFSET(ap.freq)},
479 	{QCA_WLAN_VENDOR_ATTR_DIAG_RSSI,   NLA_S32, sizeof(int32_t),
480 	 GET_ATTR_OFFSET(ap.rssi)},
481 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_SCORE,  NLA_U16, sizeof(uint16_t),
482 	 GET_ATTR_OFFSET(ap.total_score)},
483 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_AP_ETP, NLA_U32, sizeof(uint32_t),
484 	 GET_ATTR_OFFSET(ap.etp)},
485 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
486 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
487 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
488 	},
489 
490 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_RESULT] = {
491 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
492 	 GET_ATTR_OFFSET(log_subtype)},
493 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,   NLA_U64,  sizeof(uint64_t),
494 	 GET_ATTR_OFFSET(timestamp_us)},
495 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
496 	 GET_ATTR_OFFSET(ktime_us)},
497 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,     NLA_U8,   sizeof(uint8_t),
498 	 GET_ATTR_OFFSET(vdev_id)},
499 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,  NLA_BINARY, QDF_MAC_ADDR_SIZE,
500 	 GET_ATTR_OFFSET(bssid)},
501 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
502 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
503 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_SUCCESSFUL, NLA_FLAG,
504 	 sizeof(uint8_t), GET_ATTR_OFFSET(roam_result.is_roam_successful)},
505 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
506 	},
507 
508 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_CANCEL] = {
509 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32, sizeof(uint32_t),
510 	 GET_ATTR_OFFSET(log_subtype)},
511 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP, NLA_U64, sizeof(uint64_t),
512 	 GET_ATTR_OFFSET(timestamp_us)},
513 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
514 	 GET_ATTR_OFFSET(ktime_us)},
515 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX, NLA_U8, sizeof(uint8_t),
516 	 GET_ATTR_OFFSET(vdev_id)},
517 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
518 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
519 	{QCA_WLAN_VENDOR_ATTR_DIAG_REASON_CODE, NLA_U16, sizeof(uint16_t),
520 	 GET_ATTR_OFFSET(roam_result.roam_fail_reason)},
521 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
522 	},
523 
524 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_BTM_QUERY] = {
525 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
526 	 GET_ATTR_OFFSET(log_subtype)},
527 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64,  sizeof(uint64_t),
528 	 GET_ATTR_OFFSET(timestamp_us)},
529 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
530 	 GET_ATTR_OFFSET(ktime_us)},
531 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8,   sizeof(uint8_t),
532 	 GET_ATTR_OFFSET(vdev_id)},
533 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_TOKEN,  NLA_U8, sizeof(uint8_t),
534 	 GET_ATTR_OFFSET(btm_info.token)},
535 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_QUERY_REASON, NLA_U8, sizeof(uint8_t),
536 	 GET_ATTR_OFFSET(btm_info.reason)},
537 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
538 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
539 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
540 	},
541 
542 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_BTM_REQ] = {
543 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32, sizeof(uint32_t),
544 	 GET_ATTR_OFFSET(log_subtype)},
545 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64, sizeof(uint64_t),
546 	 GET_ATTR_OFFSET(timestamp_us)},
547 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
548 	 GET_ATTR_OFFSET(ktime_us)},
549 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8,  sizeof(uint8_t),
550 	 GET_ATTR_OFFSET(vdev_id)},
551 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_TOKEN,  NLA_U8, sizeof(uint8_t),
552 	 GET_ATTR_OFFSET(btm_info.token)},
553 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_MODE,   NLA_U8,  sizeof(uint8_t),
554 	 GET_ATTR_OFFSET(btm_info.mode)},
555 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_DISASSOC_TIMER, NLA_U16,
556 	 sizeof(uint16_t), GET_ATTR_OFFSET(btm_info.disassoc_timer)},
557 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_VALIDITY_INTERVAL, NLA_U8,
558 	 sizeof(uint8_t), GET_ATTR_OFFSET(btm_info.validity_timer)},
559 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_CANDIDATE_LIST_COUNT, NLA_U8,
560 	 sizeof(uint8_t), GET_ATTR_OFFSET(btm_info.candidate_list_count)},
561 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
562 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
563 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
564 	},
565 
566 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_BTM_WTC] = {
567 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
568 	 GET_ATTR_OFFSET(log_subtype)},
569 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,   NLA_U64,  sizeof(uint64_t),
570 	 GET_ATTR_OFFSET(timestamp_us)},
571 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
572 	 GET_ATTR_OFFSET(ktime_us)},
573 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,     NLA_U8,   sizeof(uint8_t),
574 	 GET_ATTR_OFFSET(vdev_id)},
575 	{QCA_WLAN_VENDOR_ATTR_DIAG_REASON_CODE, NLA_U16, sizeof(uint16_t),
576 	 GET_ATTR_OFFSET(btm_info.reason)},
577 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_WTC_SUB_REASON_CODE, NLA_U8,
578 	 sizeof(uint8_t), GET_ATTR_OFFSET(btm_info.sub_reason)},
579 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_WTC_DURATION, NLA_U32, sizeof(uint32_t),
580 	 GET_ATTR_OFFSET(btm_info.wtc_duration)},
581 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
582 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
583 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
584 	},
585 
586 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_BTM_REQ_CANDI] = {
587 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,  NLA_U32,  sizeof(uint32_t),
588 	 GET_ATTR_OFFSET(log_subtype)},
589 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP, NLA_U64, sizeof(uint64_t),
590 	 GET_ATTR_OFFSET(timestamp_us)},
591 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
592 	 GET_ATTR_OFFSET(ktime_us)},
593 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX, NLA_U8, sizeof(uint8_t),
594 	 GET_ATTR_OFFSET(vdev_id)},
595 	{QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_AP_RANK, NLA_U8, sizeof(uint8_t),
596 	 GET_ATTR_OFFSET(btm_cand.idx)},
597 	{QCA_WLAN_VENDOR_ATTR_DIAG_BSSID,  NLA_BINARY, QDF_MAC_ADDR_SIZE,
598 	 GET_ATTR_OFFSET(btm_cand.bssid)},
599 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_PREFERENCE, NLA_U8, sizeof(uint8_t),
600 	 GET_ATTR_OFFSET(btm_cand.preference)},
601 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
602 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
603 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
604 	},
605 
606 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_BTM_RESP] = {
607 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32, sizeof(uint32_t),
608 	 GET_ATTR_OFFSET(log_subtype)},
609 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64, sizeof(uint64_t),
610 	 GET_ATTR_OFFSET(timestamp_us)},
611 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
612 	 GET_ATTR_OFFSET(ktime_us)},
613 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8,  sizeof(uint8_t),
614 	 GET_ATTR_OFFSET(vdev_id)},
615 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_TOKEN,  NLA_U8, sizeof(uint8_t),
616 	 GET_ATTR_OFFSET(btm_info.token)},
617 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_STATUS_CODE, NLA_U8, sizeof(uint8_t),
618 	 GET_ATTR_OFFSET(btm_info.btm_status_code)},
619 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_DELAY, NLA_U8, sizeof(uint8_t),
620 	 GET_ATTR_OFFSET(btm_info.btm_delay)},
621 	{QCA_WLAN_VENDOR_ATTR_DIAG_BTM_TARGET_BSSID, NLA_BINARY,
622 	 QDF_MAC_ADDR_SIZE, GET_ATTR_OFFSET(btm_info.target_bssid)},
623 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
624 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
625 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
626 	},
627 
628 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DHCP_DISCOVER] = {
629 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32, sizeof(uint32_t),
630 	 GET_ATTR_OFFSET(log_subtype)},
631 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP, NLA_U64, sizeof(uint64_t),
632 	 GET_ATTR_OFFSET(timestamp_us)},
633 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
634 	 GET_ATTR_OFFSET(ktime_us)},
635 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX, NLA_U8, sizeof(uint8_t),
636 	 GET_ATTR_OFFSET(vdev_id)},
637 	{QCA_WLAN_VENDOR_ATTR_DIAG_FRAME_TX_STATUS, NLA_U8, sizeof(uint8_t),
638 	 GET_ATTR_OFFSET(pkt_info.tx_status)},
639 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
640 	},
641 
642 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DHCP_OFFER] = {
643 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32, sizeof(uint32_t),
644 	 GET_ATTR_OFFSET(log_subtype)},
645 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64, sizeof(uint64_t),
646 	 GET_ATTR_OFFSET(timestamp_us)},
647 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
648 	 GET_ATTR_OFFSET(ktime_us)},
649 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX, NLA_U8, sizeof(uint8_t),
650 	 GET_ATTR_OFFSET(vdev_id)},
651 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
652 	},
653 
654 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DHCP_REQUEST] = {
655 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
656 	 GET_ATTR_OFFSET(log_subtype)},
657 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP, NLA_U64, sizeof(uint64_t),
658 	 GET_ATTR_OFFSET(timestamp_us)},
659 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
660 	 GET_ATTR_OFFSET(ktime_us)},
661 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8,   sizeof(uint8_t),
662 	 GET_ATTR_OFFSET(vdev_id)},
663 	{QCA_WLAN_VENDOR_ATTR_DIAG_FRAME_TX_STATUS, NLA_U8, sizeof(uint8_t),
664 	 GET_ATTR_OFFSET(pkt_info.tx_status)},
665 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
666 	},
667 
668 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DHCP_ACK] = {
669 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
670 	 GET_ATTR_OFFSET(log_subtype)},
671 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64,  sizeof(uint64_t),
672 	 GET_ATTR_OFFSET(timestamp_us)},
673 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
674 	 GET_ATTR_OFFSET(ktime_us)},
675 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8,   sizeof(uint8_t),
676 	 GET_ATTR_OFFSET(vdev_id)},
677 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
678 	},
679 
680 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_DHCP_NACK] = {
681 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
682 	 GET_ATTR_OFFSET(log_subtype)},
683 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64,  sizeof(uint64_t),
684 	 GET_ATTR_OFFSET(timestamp_us)},
685 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
686 	 GET_ATTR_OFFSET(ktime_us)},
687 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8,   sizeof(uint8_t),
688 	 GET_ATTR_OFFSET(vdev_id)},
689 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
690 	},
691 
692 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAPOL_M1] = {
693 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
694 	 GET_ATTR_OFFSET(log_subtype)},
695 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64,  sizeof(uint64_t),
696 	 GET_ATTR_OFFSET(timestamp_us)},
697 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
698 	 GET_ATTR_OFFSET(ktime_us)},
699 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8,   sizeof(uint8_t),
700 	 GET_ATTR_OFFSET(vdev_id)},
701 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
702 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
703 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
704 	},
705 
706 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAPOL_M2] = {
707 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
708 	 GET_ATTR_OFFSET(log_subtype)},
709 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64,  sizeof(uint64_t),
710 	 GET_ATTR_OFFSET(timestamp_us)},
711 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
712 	 GET_ATTR_OFFSET(ktime_us)},
713 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,  NLA_U8, sizeof(uint8_t),
714 	 GET_ATTR_OFFSET(vdev_id)},
715 	{QCA_WLAN_VENDOR_ATTR_DIAG_FRAME_TX_STATUS,  NLA_U8, sizeof(uint8_t),
716 	 GET_ATTR_OFFSET(pkt_info.tx_status)},
717 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
718 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
719 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
720 	},
721 
722 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAPOL_M3] = {
723 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
724 	 GET_ATTR_OFFSET(log_subtype)},
725 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64,  sizeof(uint64_t),
726 	 GET_ATTR_OFFSET(timestamp_us)},
727 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
728 	 GET_ATTR_OFFSET(ktime_us)},
729 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX, NLA_U8,   sizeof(uint8_t),
730 	 GET_ATTR_OFFSET(vdev_id)},
731 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
732 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
733 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
734 	},
735 
736 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAPOL_M4] = {
737 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
738 	 GET_ATTR_OFFSET(log_subtype)},
739 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64,  sizeof(uint64_t),
740 	 GET_ATTR_OFFSET(timestamp_us)},
741 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
742 	 GET_ATTR_OFFSET(ktime_us)},
743 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8,   sizeof(uint8_t),
744 	 GET_ATTR_OFFSET(vdev_id)},
745 	{QCA_WLAN_VENDOR_ATTR_DIAG_FRAME_TX_STATUS, NLA_U8, sizeof(uint8_t),
746 	 GET_ATTR_OFFSET(pkt_info.tx_status)},
747 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
748 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
749 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
750 	},
751 
752 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_GTK_M1] = {
753 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
754 	 GET_ATTR_OFFSET(log_subtype)},
755 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64,  sizeof(uint64_t),
756 	 GET_ATTR_OFFSET(timestamp_us)},
757 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
758 	 GET_ATTR_OFFSET(ktime_us)},
759 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8,   sizeof(uint8_t),
760 	 GET_ATTR_OFFSET(vdev_id)},
761 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
762 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
763 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
764 	},
765 
766 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_GTK_M2] = {
767 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
768 	 GET_ATTR_OFFSET(log_subtype)},
769 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP, NLA_U64, sizeof(uint64_t),
770 	 GET_ATTR_OFFSET(timestamp_us)},
771 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
772 	 GET_ATTR_OFFSET(ktime_us)},
773 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8,   sizeof(uint8_t),
774 	 GET_ATTR_OFFSET(vdev_id)},
775 	{QCA_WLAN_VENDOR_ATTR_DIAG_FRAME_TX_STATUS, NLA_U8, sizeof(uint8_t),
776 	 GET_ATTR_OFFSET(pkt_info.tx_status)},
777 	{QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP, NLA_U64,
778 	 sizeof(uint64_t), GET_ATTR_OFFSET(fw_timestamp_us)},
779 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
780 	},
781 
782 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAP_REQUEST] = {
783 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32, sizeof(uint32_t),
784 	 GET_ATTR_OFFSET(log_subtype)},
785 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP, NLA_U64, sizeof(uint64_t),
786 	 GET_ATTR_OFFSET(timestamp_us)},
787 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
788 	 GET_ATTR_OFFSET(ktime_us)},
789 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX, NLA_U8,  sizeof(uint8_t),
790 	 GET_ATTR_OFFSET(vdev_id)},
791 	{QCA_WLAN_VENDOR_ATTR_DIAG_EAP_TYPE, NLA_U8, sizeof(uint8_t),
792 	 GET_ATTR_OFFSET(pkt_info.eap_type)},
793 	{QCA_WLAN_VENDOR_ATTR_DIAG_EAP_LEN,  NLA_U16, sizeof(uint16_t),
794 	 GET_ATTR_OFFSET(pkt_info.eap_len)},
795 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
796 	},
797 
798 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAP_RESPONSE] = {
799 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
800 	 GET_ATTR_OFFSET(log_subtype)},
801 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP, NLA_U64, sizeof(uint64_t),
802 	 GET_ATTR_OFFSET(timestamp_us)},
803 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
804 	 GET_ATTR_OFFSET(ktime_us)},
805 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX, NLA_U8, sizeof(uint8_t),
806 	 GET_ATTR_OFFSET(vdev_id)},
807 	{QCA_WLAN_VENDOR_ATTR_DIAG_EAP_TYPE, NLA_U8, sizeof(uint8_t),
808 	 GET_ATTR_OFFSET(pkt_info.eap_type)},
809 	{QCA_WLAN_VENDOR_ATTR_DIAG_EAP_LEN,  NLA_U16, sizeof(uint16_t),
810 	 GET_ATTR_OFFSET(pkt_info.eap_len)},
811 	{QCA_WLAN_VENDOR_ATTR_DIAG_FRAME_TX_STATUS, NLA_U8, sizeof(uint8_t),
812 	 GET_ATTR_OFFSET(pkt_info.tx_status)},
813 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
814 	},
815 
816 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAP_SUCCESS] = {
817 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
818 	 GET_ATTR_OFFSET(log_subtype)},
819 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64,  sizeof(uint64_t),
820 	 GET_ATTR_OFFSET(timestamp_us)},
821 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
822 	 GET_ATTR_OFFSET(ktime_us)},
823 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8,   sizeof(uint8_t),
824 	 GET_ATTR_OFFSET(vdev_id)},
825 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
826 	},
827 
828 	[QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_EAP_FAILURE] = {
829 	{QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE, NLA_U32,  sizeof(uint32_t),
830 	 GET_ATTR_OFFSET(log_subtype)},
831 	{QCA_WLAN_VENDOR_ATTR_DIAG_HOST_TIMESTAMP,  NLA_U64,  sizeof(uint64_t),
832 	 GET_ATTR_OFFSET(timestamp_us)},
833 	{QCA_WLAN_VENDOR_ATTR_DIAG_KERNEL_TIMESTAMP, NLA_U64, sizeof(uint64_t),
834 	 GET_ATTR_OFFSET(ktime_us)},
835 	{QCA_WLAN_VENDOR_ATTR_DIAG_IFINDEX,    NLA_U8,   sizeof(uint8_t),
836 	 GET_ATTR_OFFSET(vdev_id)},
837 	{WLAN_CONNECTIVITY_ATTR_END,   0, 0, 0},
838 	},
839 };
840 
841 #ifdef WLAN_FEATURE_CONNECTIVITY_LOGGING
842 static enum qca_roam_reason
wlan_hdd_convert_roam_reason(enum roam_trigger_reason roam_reason)843 wlan_hdd_convert_roam_reason(enum roam_trigger_reason roam_reason)
844 {
845 	switch (roam_reason) {
846 	case ROAM_TRIGGER_REASON_PER:
847 		return QCA_ROAM_REASON_PER;
848 	case ROAM_TRIGGER_REASON_BMISS:
849 		return QCA_ROAM_REASON_BEACON_MISS;
850 	case ROAM_TRIGGER_REASON_LOW_RSSI:
851 		return QCA_ROAM_REASON_POOR_RSSI;
852 	case ROAM_TRIGGER_REASON_HIGH_RSSI:
853 		return QCA_ROAM_REASON_BETTER_RSSI;
854 	case ROAM_TRIGGER_REASON_PERIODIC:
855 		return QCA_ROAM_REASON_PERIODIC_TIMER;
856 	case ROAM_TRIGGER_REASON_DENSE:
857 		return QCA_ROAM_REASON_CONGESTION;
858 	case ROAM_TRIGGER_REASON_BACKGROUND:
859 		return QCA_ROAM_REASON_BACKGROUND_SCAN;
860 	case ROAM_TRIGGER_REASON_FORCED:
861 		return QCA_ROAM_REASON_USER_TRIGGER;
862 	case ROAM_TRIGGER_REASON_BTM:
863 		return QCA_ROAM_REASON_BTM;
864 	case ROAM_TRIGGER_REASON_BSS_LOAD:
865 		return QCA_ROAM_REASON_BSS_LOAD;
866 	case ROAM_TRIGGER_REASON_DEAUTH:
867 		return QCA_ROAM_REASON_DISCONNECTION;
868 	case ROAM_TRIGGER_REASON_IDLE:
869 		return QCA_ROAM_REASON_IDLE;
870 	case ROAM_TRIGGER_REASON_WTC_BTM:
871 		return QCA_ROAM_REASON_WTC;
872 	case ROAM_TRIGGER_REASON_BTC:
873 		return QCA_ROAM_REASON_BT_ACTIVITY;
874 	default:
875 		break;
876 	}
877 
878 	return QCA_ROAM_REASON_UNKNOWN;
879 }
880 
881 static enum qca_roam_scan_scheme
wlan_hdd_convert_roam_scan_type(uint8_t roam_scan_type)882 wlan_hdd_convert_roam_scan_type(uint8_t roam_scan_type)
883 {
884 	if (roam_scan_type)
885 		return QCA_ROAM_SCAN_SCHEME_FULL_SCAN;
886 
887 	return QCA_ROAM_SCAN_SCHEME_PARTIAL_SCAN;
888 }
889 
890 static enum qca_roam_sub_reason
wlan_hdd_get_converted_roam_sub_reason(enum roam_trigger_sub_reason sub_reason)891 wlan_hdd_get_converted_roam_sub_reason(enum roam_trigger_sub_reason sub_reason)
892 {
893 	switch (sub_reason) {
894 	case ROAM_TRIGGER_SUB_REASON_PERIODIC_TIMER:
895 		return QCA_ROAM_SUB_REASON_PERIODIC_TIMER;
896 
897 	case ROAM_TRIGGER_SUB_REASON_INACTIVITY_TIMER_LOW_RSSI:
898 		return QCA_ROAM_SUB_REASON_INACTIVITY_TIMER_LOW_RSSI;
899 
900 	case ROAM_TRIGGER_SUB_REASON_BTM_DI_TIMER:
901 		return QCA_ROAM_SUB_REASON_BTM_DI_TIMER;
902 
903 	case ROAM_TRIGGER_SUB_REASON_FULL_SCAN:
904 		return QCA_ROAM_SUB_REASON_FULL_SCAN;
905 
906 	case ROAM_TRIGGER_SUB_REASON_LOW_RSSI_PERIODIC:
907 		return QCA_ROAM_SUB_REASON_LOW_RSSI_PERIODIC;
908 
909 	case ROAM_TRIGGER_SUB_REASON_CU_PERIODIC:
910 		return QCA_ROAM_SUB_REASON_CU_PERIODIC;
911 
912 	case ROAM_TRIGGER_SUB_REASON_PERIODIC_TIMER_AFTER_INACTIVITY:
913 		return QCA_ROAM_SUB_REASON_PERIODIC_TIMER_AFTER_INACTIVITY_LOW_RSSI;
914 
915 	case ROAM_TRIGGER_SUB_REASON_PERIODIC_TIMER_AFTER_INACTIVITY_CU:
916 		return QCA_ROAM_SUB_REASON_PERIODIC_TIMER_AFTER_INACTIVITY_CU;
917 
918 	case ROAM_TRIGGER_SUB_REASON_INACTIVITY_TIMER_CU:
919 		return QCA_ROAM_SUB_REASON_INACTIVITY_TIMER_CU;
920 
921 	default:
922 		break;
923 	}
924 
925 	return 0;
926 }
927 
928 static enum qca_wlan_vendor_tx_status
wlan_hdd_get_converted_tx_status(uint8_t tx_status)929 wlan_hdd_get_converted_tx_status(uint8_t tx_status)
930 {
931 	switch (tx_status) {
932 	case QDF_TX_RX_STATUS_FW_DISCARD:
933 	case QDF_TX_RX_STATUS_INVALID:
934 	case QDF_TX_RX_STATUS_DROP:
935 	case QDF_TX_RX_STATUS_DOWNLOAD_SUCC:
936 	case QDF_TX_RX_STATUS_DEFAULT:
937 	default:
938 		return QCA_WLAN_VENDOR_TX_STATUS_FAIL;
939 	case QDF_TX_RX_STATUS_NO_ACK:
940 		return QCA_WLAN_VENDOR_TX_STATUS_NO_ACK;
941 	case QDF_TX_RX_STATUS_OK:
942 		return QCA_WLAN_VENDOR_TX_STATUS_ACK;
943 	}
944 
945 	return QCA_WLAN_VENDOR_TX_STATUS_FAIL;
946 }
947 
948 static uint16_t
wlan_hdd_get_connectivity_log_tlv_len(struct wlan_log_record * rec)949 wlan_hdd_get_connectivity_log_tlv_len(struct wlan_log_record *rec)
950 {
951 	uint16_t j, log_evt_type, len = 0;
952 	enum qca_wlan_vendor_attr_diag attr_id;
953 
954 	log_evt_type = hdd_connectivity_log_attr_table[rec->log_subtype];
955 	if (log_evt_type >= (QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_MAX + 1))
956 			return 0;
957 
958 	for (j = 0; j < WLAN_CONNECTIVITY_ATTR_END; j++) {
959 		attr_id =
960 			connectivity_attr_table[log_evt_type][j].attribute_id;
961 		if (attr_id == WLAN_CONNECTIVITY_ATTR_END)
962 			break;
963 
964 		if (log_evt_type ==
965 		    QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_CONNECTING &&
966 		    attr_id == QCA_WLAN_VENDOR_ATTR_DIAG_FREQ &&
967 		    !rec->conn_info.freq)
968 			continue;
969 
970 		if (log_evt_type ==
971 		    QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_CONNECTING &&
972 		    attr_id == QCA_WLAN_VENDOR_ATTR_DIAG_FREQ_HINT &&
973 		    !rec->conn_info.freq_hint)
974 			continue;
975 
976 		if (attr_id == QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP &&
977 		    !rec->fw_timestamp_us)
978 			continue;
979 
980 		if (log_evt_type ==
981 		    QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_SCAN_DONE &&
982 		    attr_id == QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_FREQ_LIST) {
983 			len += nla_total_size(
984 					NLMSG_HDRLEN +
985 					(rec->roam_scan.num_scanned_freq *
986 					 sizeof(rec->roam_scan.scan_freq[0])));
987 		} else {
988 			len += nla_total_size(connectivity_attr_table[
989 				      log_evt_type][j].attribute_length);
990 		}
991 	}
992 
993 	return len;
994 }
995 
996 static uint16_t
wlan_hdd_get_connectivity_log_event_len(struct wlan_log_record * rec,uint8_t num_records)997 wlan_hdd_get_connectivity_log_event_len(struct wlan_log_record *rec,
998 					uint8_t num_records)
999 {
1000 	uint16_t len = 0;
1001 	uint8_t i;
1002 
1003 	for (i = 0; i < num_records; i++)
1004 		len += wlan_hdd_get_connectivity_log_tlv_len(&rec[i]);
1005 
1006 	return len;
1007 }
1008 
1009 static QDF_STATUS
wlan_hdd_put_connectivity_logging_data(struct sk_buff * skb,struct wlan_log_record * rec,struct connectivity_log_attr * attribute)1010 wlan_hdd_put_connectivity_logging_data(struct sk_buff *skb,
1011 				       struct wlan_log_record *rec,
1012 				       struct connectivity_log_attr *attribute)
1013 {
1014 	int errno = 0;
1015 	struct qdf_mac_addr bssid = {0};
1016 	enum  qca_wlan_vendor_attr_diag attribute_id =
1017 						attribute->attribute_id;
1018 	uint16_t field_offset = attribute->field_offset;
1019 
1020 	switch (attribute_id) {
1021 	case QCA_WLAN_VENDOR_ATTR_DIAG_SSID:
1022 		errno = nla_put(skb, attribute_id, rec->conn_info.ssid_len,
1023 				rec->conn_info.ssid);
1024 
1025 		break;
1026 	case QCA_WLAN_VENDOR_ATTR_DIAG_BSSID:
1027 		bssid = ATTR_GET_VALUE(struct qdf_mac_addr, rec, field_offset);
1028 		if (qdf_is_macaddr_zero(&bssid) ||
1029 		    qdf_is_macaddr_broadcast(&bssid))
1030 			break;
1031 
1032 		errno = nla_put(skb, attribute_id, QDF_MAC_ADDR_SIZE,
1033 				bssid.bytes);
1034 		break;
1035 	case QCA_WLAN_VENDOR_ATTR_DIAG_BSSID_HINT:
1036 		if (qdf_is_macaddr_zero(&rec->conn_info.bssid_hint) ||
1037 		    qdf_is_macaddr_broadcast(&rec->conn_info.bssid_hint))
1038 			break;
1039 
1040 		errno = nla_put(skb, attribute_id, QDF_MAC_ADDR_SIZE,
1041 				rec->conn_info.bssid_hint.bytes);
1042 		break;
1043 	case QCA_WLAN_VENDOR_ATTR_DIAG_BTM_TARGET_BSSID:
1044 		bssid = ATTR_GET_VALUE(struct qdf_mac_addr, rec, field_offset);
1045 		if (qdf_is_macaddr_zero(&bssid) ||
1046 		    qdf_is_macaddr_broadcast(&bssid))
1047 			break;
1048 
1049 		errno = nla_put(skb, attribute_id, QDF_MAC_ADDR_SIZE,
1050 				bssid.bytes);
1051 		break;
1052 	default:
1053 		break;
1054 	}
1055 
1056 	if (errno) {
1057 		hdd_err_rl("Failed to put attribute_id:%d",
1058 			   attribute->attribute_id);
1059 		return QDF_STATUS_E_FAILURE;
1060 	}
1061 
1062 	return QDF_STATUS_SUCCESS;
1063 }
1064 
1065 static QDF_STATUS
wlan_hdd_fill_roam_scan_frequencies(struct sk_buff * skb,struct wlan_log_record * rec)1066 wlan_hdd_fill_roam_scan_frequencies(struct sk_buff *skb,
1067 				    struct wlan_log_record *rec)
1068 {
1069 	int errno;
1070 	struct nlattr *attr, *attr1;
1071 	uint8_t i;
1072 	QDF_STATUS status = QDF_STATUS_SUCCESS;
1073 
1074 	attr = nla_nest_start(
1075 			skb, QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_FREQ_LIST);
1076 	if (!attr)
1077 		return QDF_STATUS_E_FAILURE;
1078 
1079 	for (i = 0; i < rec->roam_scan.num_scanned_freq; i++) {
1080 		attr1 = nla_nest_start(skb, i);
1081 		if (!attr1) {
1082 			status = QDF_STATUS_E_FAILURE;
1083 			break;
1084 		}
1085 
1086 		errno = nla_put_u16(skb, QCA_WLAN_VENDOR_ATTR_DIAG_FREQ,
1087 				    rec->roam_scan.scan_freq[i]);
1088 		if (errno) {
1089 			status = qdf_status_from_os_return(errno);
1090 			break;
1091 		}
1092 
1093 		nla_nest_end(skb, attr1);
1094 	}
1095 
1096 	nla_nest_end(skb, attr);
1097 
1098 	return status;
1099 }
1100 
1101 static QDF_STATUS
wlan_hdd_fill_connectivity_logging_data(struct sk_buff * skb,struct wlan_log_record * rec)1102 wlan_hdd_fill_connectivity_logging_data(struct sk_buff *skb,
1103 					struct wlan_log_record *rec)
1104 {
1105 	uint8_t i, val8, attr_val8;
1106 	enum qca_wlan_vendor_attr_diag attr_id;
1107 	enum qca_vendor_attr_diag_event_type evt_type;
1108 	struct connectivity_log_attr attr;
1109 	QDF_STATUS status;
1110 	int errno;
1111 
1112 	/*
1113 	 * Continue to the next event if the Event type is invalid
1114 	 */
1115 	evt_type = hdd_connectivity_log_attr_table[rec->log_subtype];
1116 	if (evt_type >= (QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_MAX + 1))
1117 		return QDF_STATUS_SUCCESS;
1118 
1119 	errno = nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE,
1120 			    evt_type);
1121 	if (errno)
1122 		return QDF_STATUS_E_FAILURE;
1123 
1124 	/*
1125 	 * zeroth index in the attribute table is always
1126 	 * QCA_WLAN_VENDOR_ATTR_DIAG_EVENT_TYPE. So
1127 	 * start the loop from first index.
1128 	 */
1129 	for (i = 1; i < WLAN_CONNECTIVITY_ATTR_END; i++) {
1130 		attr = connectivity_attr_table[evt_type][i];
1131 		attr_id = attr.attribute_id;
1132 		if (attr_id == WLAN_CONNECTIVITY_ATTR_END)
1133 			break;
1134 
1135 		if (evt_type == QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_CONNECTING &&
1136 		    attr_id == QCA_WLAN_VENDOR_ATTR_DIAG_FREQ &&
1137 		    !rec->conn_info.freq)
1138 			continue;
1139 
1140 		if (evt_type == QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_CONNECTING &&
1141 		    attr_id == QCA_WLAN_VENDOR_ATTR_DIAG_FREQ_HINT &&
1142 		    !rec->conn_info.freq_hint)
1143 			continue;
1144 
1145 		if (attr_id == QCA_WLAN_VENDOR_ATTR_DIAG_FIRMWARE_TIMESTAMP &&
1146 		    !rec->fw_timestamp_us)
1147 			continue;
1148 
1149 		if (evt_type ==
1150 		    QCA_WLAN_VENDOR_DIAG_EVENT_TYPE_ROAM_SCAN_DONE &&
1151 		    attr_id == QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_FREQ_LIST) {
1152 			status = wlan_hdd_fill_roam_scan_frequencies(skb, rec);
1153 			if (QDF_IS_STATUS_ERROR(status))
1154 				continue;
1155 		}
1156 
1157 		switch (attr.attribute_type) {
1158 		case NLA_U8:
1159 			val8 = ATTR_GET_VALUE(uint8_t, rec, attr.field_offset);
1160 			attr_val8 = val8;
1161 			if (attr.attribute_id ==
1162 			    QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_TRIGGER_SUB_REASON)
1163 				attr_val8 = wlan_hdd_get_converted_roam_sub_reason(val8);
1164 			else if (attr.attribute_id ==
1165 				 QCA_WLAN_VENDOR_ATTR_DIAG_FRAME_TX_STATUS)
1166 				attr_val8 = wlan_hdd_get_converted_tx_status(val8);
1167 			else if (attr.attribute_id ==
1168 				 QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_TRIGGER_REASON)
1169 				attr_val8 = wlan_hdd_convert_roam_reason(val8);
1170 			else if (attr.attribute_id ==
1171 				 QCA_WLAN_VENDOR_ATTR_DIAG_ROAM_SCAN_TYPE)
1172 				attr_val8 = wlan_hdd_convert_roam_scan_type(val8);
1173 
1174 			errno = nla_put_u8(skb, attr.attribute_id, attr_val8);
1175 			break;
1176 		case NLA_U16:
1177 			errno = nla_put_u16(skb, attr.attribute_id,
1178 					    ATTR_GET_VALUE(uint16_t, rec,
1179 							   attr.field_offset));
1180 			break;
1181 		case NLA_U32:
1182 			errno = nla_put_u32(skb, attr.attribute_id,
1183 					    ATTR_GET_VALUE(uint32_t, rec,
1184 							   attr.field_offset));
1185 			break;
1186 		case NLA_S32:
1187 			errno = nla_put_s32(skb, attr.attribute_id,
1188 					    ATTR_GET_VALUE(int32_t, rec,
1189 							   attr.field_offset));
1190 			break;
1191 		case NLA_U64:
1192 			errno = wlan_cfg80211_nla_put_u64(
1193 			    skb, attr.attribute_id,
1194 			    ATTR_GET_VALUE(uint64_t, rec, attr.field_offset));
1195 			break;
1196 		case NLA_FLAG:
1197 			if (ATTR_GET_VALUE(bool, rec, attr.field_offset))
1198 				errno = nla_put_flag(skb, attr.attribute_id);
1199 			break;
1200 		case NLA_BINARY:
1201 			status = wlan_hdd_put_connectivity_logging_data(
1202 						skb, rec, &attr);
1203 			if (QDF_IS_STATUS_ERROR(status))
1204 				return status;
1205 			break;
1206 		default:
1207 			break;
1208 		}
1209 	}
1210 
1211 	if (errno) {
1212 		hdd_err_rl("NLA put failed for attr:%d",
1213 			   attr.attribute_id);
1214 		return QDF_STATUS_E_FAILURE;
1215 	}
1216 
1217 	return QDF_STATUS_SUCCESS;
1218 }
1219 
1220 /**
1221  * wlan_hdd_send_connectivity_log_to_user  - Send the connectivity log buffer
1222  * to userspace
1223  * @rec: Pointer to the log record
1224  * @hdd_context: HDD global context
1225  * @num_records: Number of records
1226  *
1227  * Return: QDF_STATUS
1228  */
1229 static QDF_STATUS
wlan_hdd_send_connectivity_log_to_user(struct wlan_log_record * rec,void * hdd_context,uint8_t num_records)1230 wlan_hdd_send_connectivity_log_to_user(struct wlan_log_record *rec,
1231 				       void *hdd_context,
1232 				       uint8_t num_records)
1233 {
1234 	struct hdd_context *hdd_ctx;
1235 	struct nlattr *attr, *attr1;
1236 	struct sk_buff *vendor_event;
1237 	uint16_t len, i = 0;
1238 	QDF_STATUS status;
1239 
1240 	hdd_enter();
1241 
1242 	hdd_ctx = hdd_context;
1243 	if (wlan_hdd_validate_context(hdd_ctx))
1244 		return QDF_STATUS_E_FAILURE;
1245 
1246 	len = wlan_hdd_get_connectivity_log_event_len(rec, num_records);
1247 
1248 	vendor_event = wlan_cfg80211_vendor_event_alloc(
1249 			hdd_ctx->wiphy, NULL, len + NLMSG_HDRLEN,
1250 			QCA_NL80211_VENDOR_SUBCMD_DIAG_EVENT_INDEX,
1251 			GFP_ATOMIC);
1252 	if (!vendor_event) {
1253 		hdd_err("wlan_cfg80211_vendor_event_alloc failed");
1254 		return QDF_STATUS_E_NOMEM;
1255 	}
1256 
1257 	attr = nla_nest_start(vendor_event,
1258 			      QCA_WLAN_VENDOR_ATTR_DIAG_EVENT);
1259 	if (!attr)
1260 		goto failure;
1261 
1262 	for (i = 0; i < num_records; i++) {
1263 		attr1 = nla_nest_start(vendor_event, i);
1264 		if (!attr1)
1265 			goto failure;
1266 
1267 		status = wlan_hdd_fill_connectivity_logging_data(vendor_event,
1268 								 &rec[i]);
1269 		if (QDF_IS_STATUS_ERROR(status)) {
1270 			hdd_err_rl("Failed to fill fat idx:%d subtype:%d",
1271 				   i, rec[i].log_subtype);
1272 			goto failure;
1273 		}
1274 
1275 		nla_nest_end(vendor_event, attr1);
1276 	}
1277 
1278 	nla_nest_end(vendor_event, attr);
1279 	wlan_cfg80211_vendor_event(vendor_event, GFP_ATOMIC);
1280 
1281 	hdd_exit();
1282 
1283 	return QDF_STATUS_SUCCESS;
1284 failure:
1285 	hdd_err("NLA fill failed num_records:%d", num_records);
1286 	wlan_cfg80211_vendor_free_skb(vendor_event);
1287 
1288 	return QDF_STATUS_E_FAILURE;
1289 }
1290 
wlan_hdd_start_connectivity_logging(struct hdd_context * hdd_ctx)1291 void wlan_hdd_start_connectivity_logging(struct hdd_context *hdd_ctx)
1292 {
1293 	struct wlan_cl_osif_cbks hdd_cb;
1294 
1295 	hdd_cb.wlan_connectivity_log_send_to_usr =
1296 			wlan_hdd_send_connectivity_log_to_user;
1297 	wlan_connectivity_logging_start(hdd_ctx->psoc, &hdd_cb, hdd_ctx);
1298 }
1299 #endif
1300 
1301 #ifdef CONNECTIVITY_DIAG_EVENT
1302 static enum wlan_diag_connect_fail_reason
wlan_hdd_convert_con_fail_reason_to_diag_reason(enum wlan_cm_connect_fail_reason reason)1303 wlan_hdd_convert_con_fail_reason_to_diag_reason(
1304 				enum wlan_cm_connect_fail_reason reason)
1305 {
1306 	switch (reason) {
1307 	case CM_NO_CANDIDATE_FOUND:
1308 		return WLAN_DIAG_NO_CANDIDATE_FOUND;
1309 	case CM_ABORT_DUE_TO_NEW_REQ_RECVD:
1310 		return WLAN_DIAG_ABORT_DUE_TO_NEW_REQ_RECVD;
1311 	case CM_BSS_SELECT_IND_FAILED:
1312 		return WLAN_DIAG_BSS_SELECT_IND_FAILED;
1313 	case CM_PEER_CREATE_FAILED:
1314 		return WLAN_DIAG_PEER_CREATE_FAILED;
1315 	case CM_JOIN_FAILED:
1316 		return WLAN_DIAG_JOIN_FAILED;
1317 	case CM_JOIN_TIMEOUT:
1318 		return WLAN_DIAG_JOIN_TIMEOUT;
1319 	case CM_AUTH_FAILED:
1320 		return WLAN_DIAG_AUTH_FAILED;
1321 	case CM_AUTH_TIMEOUT:
1322 		return WLAN_DIAG_AUTH_TIMEOUT;
1323 	case CM_ASSOC_FAILED:
1324 		return WLAN_DIAG_ASSOC_FAILED;
1325 	case CM_ASSOC_TIMEOUT:
1326 		return WLAN_DIAG_ASSOC_TIMEOUT;
1327 	case CM_HW_MODE_FAILURE:
1328 		return WLAN_DIAG_HW_MODE_FAILURE;
1329 	case CM_SER_FAILURE:
1330 		return WLAN_DIAG_SER_FAILURE;
1331 	case CM_SER_TIMEOUT:
1332 		return WLAN_DIAG_SER_TIMEOUT;
1333 	case CM_GENERIC_FAILURE:
1334 		return WLAN_DIAG_GENERIC_FAILURE;
1335 	case CM_VALID_CANDIDATE_CHECK_FAIL:
1336 		return WLAN_DIAG_VALID_CANDIDATE_CHECK_FAIL;
1337 	default:
1338 		hdd_err("Invalid connect fail reason code");
1339 	}
1340 
1341 	return WLAN_DIAG_UNSPECIFIC_REASON;
1342 }
1343 
1344 void
wlan_hdd_connectivity_fail_event(struct wlan_objmgr_vdev * vdev,struct wlan_cm_connect_resp * rsp)1345 wlan_hdd_connectivity_fail_event(struct wlan_objmgr_vdev *vdev,
1346 				 struct wlan_cm_connect_resp *rsp)
1347 {
1348 	WLAN_HOST_DIAG_EVENT_DEF(wlan_diag_event, struct wlan_diag_connect);
1349 
1350 	qdf_mem_zero(&wlan_diag_event, sizeof(struct wlan_diag_connect));
1351 
1352 	if (wlan_vdev_mlme_get_opmode(vdev) != QDF_STA_MODE)
1353 		return;
1354 
1355 	if (wlan_vdev_mlme_is_mlo_vdev(vdev) &&
1356 	    (wlan_vdev_mlme_is_mlo_link_switch_in_progress(vdev) ||
1357 	     wlan_vdev_mlme_is_mlo_link_vdev(vdev)))
1358 		return;
1359 
1360 	wlan_diag_event.diag_cmn.vdev_id = wlan_vdev_get_id(vdev);
1361 
1362 	wlan_diag_event.diag_cmn.timestamp_us = qdf_get_time_of_the_day_us();
1363 	wlan_diag_event.diag_cmn.ktime_us = qdf_ktime_to_us(qdf_ktime_get());
1364 	wlan_diag_event.subtype = WLAN_CONN_DIAG_CONNECT_FAIL_EVENT;
1365 	qdf_mem_copy(wlan_diag_event.diag_cmn.bssid, rsp->bssid.bytes,
1366 		     QDF_MAC_ADDR_SIZE);
1367 
1368 	wlan_diag_event.version = DIAG_CONN_VERSION;
1369 	wlan_diag_event.freq = rsp->freq;
1370 	wlan_diag_event.reason =
1371 	wlan_hdd_convert_con_fail_reason_to_diag_reason(rsp->reason);
1372 
1373 	WLAN_HOST_DIAG_EVENT_REPORT(&wlan_diag_event, EVENT_WLAN_CONN);
1374 }
1375 #endif
1376