forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/bcmevent.c
....@@ -1,15 +1,16 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * bcmevent read-only data shared by kernel or app layers
43 *
5
- * Copyright (C) 1999-2019, Broadcom Corporation
6
- *
4
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
5
+ *
6
+ * Copyright (C) 1999-2017, Broadcom Corporation
7
+ *
78 * Unless you and Broadcom execute a separate written software license
89 * agreement governing use of this software, this software is licensed to you
910 * under the terms of the GNU General Public License version 2 (the "GPL"),
1011 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
1112 * following added to such license:
12
- *
13
+ *
1314 * As a special exception, the copyright holders of this software give you
1415 * permission to link this software with independent modules, and to copy and
1516 * distribute the resulting executable under terms of your choice, provided that
....@@ -17,7 +18,7 @@
1718 * the license of that module. An independent module is a module which is not
1819 * derived from this software. The special exception does not apply to any
1920 * modifications of the software.
20
- *
21
+ *
2122 * Notwithstanding the above, under no circumstances may you combine this
2223 * software in any way with any other Broadcom software provided under a license
2324 * other than the GPL, without Broadcom's express prior written consent.
....@@ -25,17 +26,16 @@
2526 *
2627 * <<Broadcom-WL-IPTag/Open:>>
2728 *
28
- * $Id: bcmevent.c 715966 2019-05-30 02:36:59Z $
29
+ * $Id: bcmevent.c 702756 2017-06-03 17:20:27Z $
2930 */
3031
3132 #include <typedefs.h>
3233 #include <bcmutils.h>
3334 #include <bcmendian.h>
34
-#include <proto/ethernet.h>
35
-#include <proto/bcmeth.h>
36
-#include <proto/bcmevent.h>
37
-#include <proto/802.11.h>
38
-
35
+#include <ethernet.h>
36
+#include <bcmeth.h>
37
+#include <bcmevent.h>
38
+#include <802.11.h>
3939
4040 /* Table of event name strings for UIs and debugging dumps */
4141 typedef struct {
....@@ -74,6 +74,7 @@
7474 BCMEVENT_NAME(WLC_E_AUTOAUTH),
7575 BCMEVENT_NAME(WLC_E_EAPOL_MSG),
7676 BCMEVENT_NAME(WLC_E_SCAN_COMPLETE),
77
+ BCMEVENT_NAME(WLC_E_IND_DOS_STATUS),
7778 BCMEVENT_NAME(WLC_E_ADDTS_IND),
7879 BCMEVENT_NAME(WLC_E_DELTS_IND),
7980 BCMEVENT_NAME(WLC_E_BCNSENT_IND),
....@@ -83,6 +84,9 @@
8384 BCMEVENT_NAME(WLC_E_PFN_NET_FOUND),
8485 BCMEVENT_NAME(WLC_E_PFN_SCAN_ALLGONE),
8586 BCMEVENT_NAME(WLC_E_PFN_NET_LOST),
87
+ BCMEVENT_NAME(WLC_E_JOIN_START),
88
+ BCMEVENT_NAME(WLC_E_ROAM_START),
89
+ BCMEVENT_NAME(WLC_E_ASSOC_START),
8690 #if defined(IBSS_PEER_DISCOVERY_EVENT)
8791 BCMEVENT_NAME(WLC_E_IBSS_ASSOC),
8892 #endif /* defined(IBSS_PEER_DISCOVERY_EVENT) */
....@@ -100,27 +104,28 @@
100104 BCMEVENT_NAME(WLC_E_IF),
101105 #ifdef WLP2P
102106 BCMEVENT_NAME(WLC_E_P2P_DISC_LISTEN_COMPLETE),
103
-#endif
107
+#endif // endif
104108 BCMEVENT_NAME(WLC_E_RSSI),
105
- BCMEVENT_NAME(WLC_E_EXTLOG_MSG),
109
+ BCMEVENT_NAME(WLC_E_PFN_SCAN_COMPLETE),
106110 BCMEVENT_NAME(WLC_E_ACTION_FRAME),
107111 BCMEVENT_NAME(WLC_E_ACTION_FRAME_RX),
108112 BCMEVENT_NAME(WLC_E_ACTION_FRAME_COMPLETE),
113
+#ifdef BCMWAPI_WAI
114
+ BCMEVENT_NAME(WLC_E_WAI_STA_EVENT),
115
+ BCMEVENT_NAME(WLC_E_WAI_MSG),
116
+#endif /* BCMWAPI_WAI */
109117 BCMEVENT_NAME(WLC_E_ESCAN_RESULT),
110118 BCMEVENT_NAME(WLC_E_ACTION_FRAME_OFF_CHAN_COMPLETE),
111119 #ifdef WLP2P
112120 BCMEVENT_NAME(WLC_E_PROBRESP_MSG),
113121 BCMEVENT_NAME(WLC_E_P2P_PROBREQ_MSG),
114
-#endif
122
+#endif // endif
115123 #ifdef PROP_TXSTATUS
116124 BCMEVENT_NAME(WLC_E_FIFO_CREDIT_MAP),
117
-#endif
125
+#endif // endif
118126 BCMEVENT_NAME(WLC_E_WAKE_EVENT),
119127 BCMEVENT_NAME(WLC_E_DCS_REQUEST),
120128 BCMEVENT_NAME(WLC_E_RM_COMPLETE),
121
-#ifdef WLMEDIA_HTSF
122
- BCMEVENT_NAME(WLC_E_HTSFSYNC),
123
-#endif
124129 BCMEVENT_NAME(WLC_E_OVERLAY_REQ),
125130 BCMEVENT_NAME(WLC_E_CSA_COMPLETE_IND),
126131 BCMEVENT_NAME(WLC_E_EXCESS_PM_WAKE_EVENT),
....@@ -128,7 +133,7 @@
128133 BCMEVENT_NAME(WLC_E_PFN_SCAN_ALLGONE),
129134 #ifdef SOFTAP
130135 BCMEVENT_NAME(WLC_E_GTK_PLUMBED),
131
-#endif
136
+#endif // endif
132137 BCMEVENT_NAME(WLC_E_ASSOC_REQ_IE),
133138 BCMEVENT_NAME(WLC_E_ASSOC_RESP_IE),
134139 BCMEVENT_NAME(WLC_E_BEACON_FRAME_RX),
....@@ -147,28 +152,31 @@
147152 #ifdef WLWNM
148153 BCMEVENT_NAME(WLC_E_WNM_STA_SLEEP),
149154 #endif /* WLWNM */
150
-#if defined(WL_PROXDETECT)
155
+#if defined(WL_PROXDETECT) || defined(RTT_SUPPORT)
151156 BCMEVENT_NAME(WLC_E_PROXD),
152
-#endif
157
+#endif // endif
153158 BCMEVENT_NAME(WLC_E_CCA_CHAN_QUAL),
154159 BCMEVENT_NAME(WLC_E_BSSID),
155160 #ifdef PROP_TXSTATUS
156161 BCMEVENT_NAME(WLC_E_BCMC_CREDIT_SUPPORT),
157
-#endif
162
+#endif // endif
158163 BCMEVENT_NAME(WLC_E_PSTA_PRIMARY_INTF_IND),
159164 BCMEVENT_NAME(WLC_E_TXFAIL_THRESH),
165
+#ifdef WLAIBSS
166
+ BCMEVENT_NAME(WLC_E_AIBSS_TXFAIL),
167
+#endif /* WLAIBSS */
160168 #ifdef GSCAN_SUPPORT
161169 BCMEVENT_NAME(WLC_E_PFN_GSCAN_FULL_RESULT),
162
- BCMEVENT_NAME(WLC_E_PFN_SWC),
170
+ BCMEVENT_NAME(WLC_E_PFN_SSID_EXT),
163171 #endif /* GSCAN_SUPPORT */
164172 #ifdef WLBSSLOAD_REPORT
165173 BCMEVENT_NAME(WLC_E_BSS_LOAD),
166
-#endif
174
+#endif // endif
167175 #if defined(BT_WIFI_HANDOVER) || defined(WL_TBOW)
168176 BCMEVENT_NAME(WLC_E_BT_WIFI_HANDOVER_REQ),
169
-#endif
177
+#endif // endif
170178 #ifdef WLFBT
171
- BCMEVENT_NAME(WLC_E_FBT_AUTH_REQ_IND),
179
+ BCMEVENT_NAME(WLC_E_FBT),
172180 #endif /* WLFBT */
173181 BCMEVENT_NAME(WLC_E_AUTHORIZED),
174182 BCMEVENT_NAME(WLC_E_PROBREQ_MSG_RX),
....@@ -178,7 +186,26 @@
178186 BCMEVENT_NAME(WLC_E_RMC_EVENT),
179187 BCMEVENT_NAME(WLC_E_DPSTA_INTF_IND),
180188 BCMEVENT_NAME(WLC_E_ALLOW_CREDIT_BORROW),
189
+ BCMEVENT_NAME(WLC_E_MSCH),
181190 BCMEVENT_NAME(WLC_E_ULP),
191
+ BCMEVENT_NAME(WLC_E_NAN),
192
+ BCMEVENT_NAME(WLC_E_PKT_FILTER),
193
+ BCMEVENT_NAME(WLC_E_DMA_TXFLUSH_COMPLETE),
194
+ BCMEVENT_NAME(WLC_E_PSK_AUTH),
195
+ BCMEVENT_NAME(WLC_E_SDB_TRANSITION),
196
+ BCMEVENT_NAME(WLC_E_PFN_SCAN_BACKOFF),
197
+ BCMEVENT_NAME(WLC_E_PFN_BSSID_SCAN_BACKOFF),
198
+ BCMEVENT_NAME(WLC_E_AGGR_EVENT),
199
+ BCMEVENT_NAME(WLC_E_TVPM_MITIGATION),
200
+#ifdef WL_NAN
201
+ BCMEVENT_NAME(WLC_E_NAN_CRITICAL),
202
+ BCMEVENT_NAME(WLC_E_NAN_NON_CRITICAL),
203
+ BCMEVENT_NAME(WLC_E_NAN),
204
+#endif /* WL_NAN */
205
+ BCMEVENT_NAME(WLC_E_RPSNOA),
206
+ BCMEVENT_NAME(WLC_E_PHY_CAL),
207
+ BCMEVENT_NAME(WLC_E_WA_LQM),
208
+ BCMEVENT_NAME(WLC_E_OVERTEMP),
182209 };
183210
184211 const char *bcmevent_get_name(uint event_type)
....@@ -203,6 +230,36 @@
203230 * otherwise return unknown string.
204231 */
205232 return ((event_name) ? event_name : "Unknown Event");
233
+}
234
+
235
+void
236
+wl_event_to_host_order(wl_event_msg_t * evt)
237
+{
238
+ /* Event struct members passed from dongle to host are stored in network
239
+ * byte order. Convert all members to host-order.
240
+ */
241
+ evt->event_type = ntoh32(evt->event_type);
242
+ evt->flags = ntoh16(evt->flags);
243
+ evt->status = ntoh32(evt->status);
244
+ evt->reason = ntoh32(evt->reason);
245
+ evt->auth_type = ntoh32(evt->auth_type);
246
+ evt->datalen = ntoh32(evt->datalen);
247
+ evt->version = ntoh16(evt->version);
248
+}
249
+
250
+void
251
+wl_event_to_network_order(wl_event_msg_t * evt)
252
+{
253
+ /* Event struct members passed from dongle to host are stored in network
254
+ * byte order. Convert all members to host-order.
255
+ */
256
+ evt->event_type = hton32(evt->event_type);
257
+ evt->flags = hton16(evt->flags);
258
+ evt->status = hton32(evt->status);
259
+ evt->reason = hton32(evt->reason);
260
+ evt->auth_type = hton32(evt->auth_type);
261
+ evt->datalen = hton32(evt->datalen);
262
+ evt->version = hton16(evt->version);
206263 }
207264
208265 /*
....@@ -246,13 +303,14 @@
246303 }
247304
248305 /* check length in bcmeth_hdr */
306
+
249307 /* temporary - header length not always set properly. When the below
250308 * !BCMDONGLEHOST is in all branches that use trunk DHD, the code
251309 * under BCMDONGLEHOST can be removed.
252310 */
253311 evlen = (uint16)(pktend - (uint8 *)&bcm_event->bcm_hdr.version);
254312 evend = (uint8 *)&bcm_event->bcm_hdr.version + evlen;
255
- if (evend > pktend) {
313
+ if (evend != pktend) {
256314 err = BCME_BADLEN;
257315 goto done;
258316 }
....@@ -282,7 +340,8 @@
282340
283341 /* ensure data length in event is not beyond the packet. */
284342 data_len = ntoh32_ua((void *)&bcm_event->event.datalen);
285
- if (data_len > (pktlen - sizeof(bcm_event_t))) {
343
+ if ((sizeof(bcm_event_t) + data_len +
344
+ BCMILCP_BCM_SUBTYPE_EVENT_DATA_PAD) != pktlen) {
286345 err = BCME_BADLEN;
287346 goto done;
288347 }
....@@ -298,8 +357,9 @@
298357 }
299358
300359 break;
360
+
301361 case BCMILCP_BCM_SUBTYPE_DNGLEVENT:
302
-#ifdef HEALTH_CHECK
362
+#if defined(DNGL_EVENT_SUPPORT)
303363 if ((pktlen < sizeof(bcm_dngl_event_t)) ||
304364 (evend < ((uint8 *)bcm_event + sizeof(bcm_dngl_event_t)))) {
305365 err = BCME_BADLEN;
....@@ -308,7 +368,8 @@
308368
309369 /* ensure data length in event is not beyond the packet. */
310370 data_len = ntoh16_ua((void *)&((bcm_dngl_event_t *)pktdata)->dngl_event.datalen);
311
- if (data_len > (pktlen - sizeof(bcm_dngl_event_t))) {
371
+ if ((sizeof(bcm_dngl_event_t) + data_len +
372
+ BCMILCP_BCM_SUBTYPE_EVENT_DATA_PAD) != pktlen) {
312373 err = BCME_BADLEN;
313374 goto done;
314375 }
....@@ -325,9 +386,11 @@
325386 }
326387
327388 break;
328
-#endif /* HEALTH_CHECK */
389
+#else
329390 err = BCME_UNSUPPORTED;
330391 break;
392
+#endif // endif
393
+
331394 default:
332395 err = BCME_NOTFOUND;
333396 goto done;
....@@ -336,34 +399,4 @@
336399 BCM_REFERENCE(data_len);
337400 done:
338401 return err;
339
-}
340
-
341
-void
342
-wl_event_to_host_order(wl_event_msg_t * evt)
343
-{
344
- /* Event struct members passed from dongle to host are stored in network
345
- * byte order. Convert all members to host-order.
346
- */
347
- evt->event_type = ntoh32(evt->event_type);
348
- evt->flags = ntoh16(evt->flags);
349
- evt->status = ntoh32(evt->status);
350
- evt->reason = ntoh32(evt->reason);
351
- evt->auth_type = ntoh32(evt->auth_type);
352
- evt->datalen = ntoh32(evt->datalen);
353
- evt->version = ntoh16(evt->version);
354
-}
355
-
356
-void
357
-wl_event_to_network_order(wl_event_msg_t * evt)
358
-{
359
- /* Event struct members passed from dongle to host are stored in network
360
- * byte order. Convert all members to host-order.
361
- */
362
- evt->event_type = hton32(evt->event_type);
363
- evt->flags = hton16(evt->flags);
364
- evt->status = hton32(evt->status);
365
- evt->reason = hton32(evt->reason);
366
- evt->auth_type = hton32(evt->auth_type);
367
- evt->datalen = hton32(evt->datalen);
368
- evt->version = hton16(evt->version);
369402 }