| .. | .. |
|---|
| 1 | | -/* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 2 | 1 | /* |
|---|
| 3 | 2 | * bcmevent read-only data shared by kernel or app layers |
|---|
| 4 | 3 | * |
|---|
| 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 | + * |
|---|
| 7 | 8 | * Unless you and Broadcom execute a separate written software license |
|---|
| 8 | 9 | * agreement governing use of this software, this software is licensed to you |
|---|
| 9 | 10 | * under the terms of the GNU General Public License version 2 (the "GPL"), |
|---|
| 10 | 11 | * available at http://www.broadcom.com/licenses/GPLv2.php, with the |
|---|
| 11 | 12 | * following added to such license: |
|---|
| 12 | | - * |
|---|
| 13 | + * |
|---|
| 13 | 14 | * As a special exception, the copyright holders of this software give you |
|---|
| 14 | 15 | * permission to link this software with independent modules, and to copy and |
|---|
| 15 | 16 | * distribute the resulting executable under terms of your choice, provided that |
|---|
| .. | .. |
|---|
| 17 | 18 | * the license of that module. An independent module is a module which is not |
|---|
| 18 | 19 | * derived from this software. The special exception does not apply to any |
|---|
| 19 | 20 | * modifications of the software. |
|---|
| 20 | | - * |
|---|
| 21 | + * |
|---|
| 21 | 22 | * Notwithstanding the above, under no circumstances may you combine this |
|---|
| 22 | 23 | * software in any way with any other Broadcom software provided under a license |
|---|
| 23 | 24 | * other than the GPL, without Broadcom's express prior written consent. |
|---|
| .. | .. |
|---|
| 25 | 26 | * |
|---|
| 26 | 27 | * <<Broadcom-WL-IPTag/Open:>> |
|---|
| 27 | 28 | * |
|---|
| 28 | | - * $Id: bcmevent.c 715966 2019-05-30 02:36:59Z $ |
|---|
| 29 | + * $Id: bcmevent.c 702756 2017-06-03 17:20:27Z $ |
|---|
| 29 | 30 | */ |
|---|
| 30 | 31 | |
|---|
| 31 | 32 | #include <typedefs.h> |
|---|
| 32 | 33 | #include <bcmutils.h> |
|---|
| 33 | 34 | #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> |
|---|
| 39 | 39 | |
|---|
| 40 | 40 | /* Table of event name strings for UIs and debugging dumps */ |
|---|
| 41 | 41 | typedef struct { |
|---|
| .. | .. |
|---|
| 74 | 74 | BCMEVENT_NAME(WLC_E_AUTOAUTH), |
|---|
| 75 | 75 | BCMEVENT_NAME(WLC_E_EAPOL_MSG), |
|---|
| 76 | 76 | BCMEVENT_NAME(WLC_E_SCAN_COMPLETE), |
|---|
| 77 | + BCMEVENT_NAME(WLC_E_IND_DOS_STATUS), |
|---|
| 77 | 78 | BCMEVENT_NAME(WLC_E_ADDTS_IND), |
|---|
| 78 | 79 | BCMEVENT_NAME(WLC_E_DELTS_IND), |
|---|
| 79 | 80 | BCMEVENT_NAME(WLC_E_BCNSENT_IND), |
|---|
| .. | .. |
|---|
| 83 | 84 | BCMEVENT_NAME(WLC_E_PFN_NET_FOUND), |
|---|
| 84 | 85 | BCMEVENT_NAME(WLC_E_PFN_SCAN_ALLGONE), |
|---|
| 85 | 86 | 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), |
|---|
| 86 | 90 | #if defined(IBSS_PEER_DISCOVERY_EVENT) |
|---|
| 87 | 91 | BCMEVENT_NAME(WLC_E_IBSS_ASSOC), |
|---|
| 88 | 92 | #endif /* defined(IBSS_PEER_DISCOVERY_EVENT) */ |
|---|
| .. | .. |
|---|
| 100 | 104 | BCMEVENT_NAME(WLC_E_IF), |
|---|
| 101 | 105 | #ifdef WLP2P |
|---|
| 102 | 106 | BCMEVENT_NAME(WLC_E_P2P_DISC_LISTEN_COMPLETE), |
|---|
| 103 | | -#endif |
|---|
| 107 | +#endif // endif |
|---|
| 104 | 108 | BCMEVENT_NAME(WLC_E_RSSI), |
|---|
| 105 | | - BCMEVENT_NAME(WLC_E_EXTLOG_MSG), |
|---|
| 109 | + BCMEVENT_NAME(WLC_E_PFN_SCAN_COMPLETE), |
|---|
| 106 | 110 | BCMEVENT_NAME(WLC_E_ACTION_FRAME), |
|---|
| 107 | 111 | BCMEVENT_NAME(WLC_E_ACTION_FRAME_RX), |
|---|
| 108 | 112 | 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 */ |
|---|
| 109 | 117 | BCMEVENT_NAME(WLC_E_ESCAN_RESULT), |
|---|
| 110 | 118 | BCMEVENT_NAME(WLC_E_ACTION_FRAME_OFF_CHAN_COMPLETE), |
|---|
| 111 | 119 | #ifdef WLP2P |
|---|
| 112 | 120 | BCMEVENT_NAME(WLC_E_PROBRESP_MSG), |
|---|
| 113 | 121 | BCMEVENT_NAME(WLC_E_P2P_PROBREQ_MSG), |
|---|
| 114 | | -#endif |
|---|
| 122 | +#endif // endif |
|---|
| 115 | 123 | #ifdef PROP_TXSTATUS |
|---|
| 116 | 124 | BCMEVENT_NAME(WLC_E_FIFO_CREDIT_MAP), |
|---|
| 117 | | -#endif |
|---|
| 125 | +#endif // endif |
|---|
| 118 | 126 | BCMEVENT_NAME(WLC_E_WAKE_EVENT), |
|---|
| 119 | 127 | BCMEVENT_NAME(WLC_E_DCS_REQUEST), |
|---|
| 120 | 128 | BCMEVENT_NAME(WLC_E_RM_COMPLETE), |
|---|
| 121 | | -#ifdef WLMEDIA_HTSF |
|---|
| 122 | | - BCMEVENT_NAME(WLC_E_HTSFSYNC), |
|---|
| 123 | | -#endif |
|---|
| 124 | 129 | BCMEVENT_NAME(WLC_E_OVERLAY_REQ), |
|---|
| 125 | 130 | BCMEVENT_NAME(WLC_E_CSA_COMPLETE_IND), |
|---|
| 126 | 131 | BCMEVENT_NAME(WLC_E_EXCESS_PM_WAKE_EVENT), |
|---|
| .. | .. |
|---|
| 128 | 133 | BCMEVENT_NAME(WLC_E_PFN_SCAN_ALLGONE), |
|---|
| 129 | 134 | #ifdef SOFTAP |
|---|
| 130 | 135 | BCMEVENT_NAME(WLC_E_GTK_PLUMBED), |
|---|
| 131 | | -#endif |
|---|
| 136 | +#endif // endif |
|---|
| 132 | 137 | BCMEVENT_NAME(WLC_E_ASSOC_REQ_IE), |
|---|
| 133 | 138 | BCMEVENT_NAME(WLC_E_ASSOC_RESP_IE), |
|---|
| 134 | 139 | BCMEVENT_NAME(WLC_E_BEACON_FRAME_RX), |
|---|
| .. | .. |
|---|
| 147 | 152 | #ifdef WLWNM |
|---|
| 148 | 153 | BCMEVENT_NAME(WLC_E_WNM_STA_SLEEP), |
|---|
| 149 | 154 | #endif /* WLWNM */ |
|---|
| 150 | | -#if defined(WL_PROXDETECT) |
|---|
| 155 | +#if defined(WL_PROXDETECT) || defined(RTT_SUPPORT) |
|---|
| 151 | 156 | BCMEVENT_NAME(WLC_E_PROXD), |
|---|
| 152 | | -#endif |
|---|
| 157 | +#endif // endif |
|---|
| 153 | 158 | BCMEVENT_NAME(WLC_E_CCA_CHAN_QUAL), |
|---|
| 154 | 159 | BCMEVENT_NAME(WLC_E_BSSID), |
|---|
| 155 | 160 | #ifdef PROP_TXSTATUS |
|---|
| 156 | 161 | BCMEVENT_NAME(WLC_E_BCMC_CREDIT_SUPPORT), |
|---|
| 157 | | -#endif |
|---|
| 162 | +#endif // endif |
|---|
| 158 | 163 | BCMEVENT_NAME(WLC_E_PSTA_PRIMARY_INTF_IND), |
|---|
| 159 | 164 | BCMEVENT_NAME(WLC_E_TXFAIL_THRESH), |
|---|
| 165 | +#ifdef WLAIBSS |
|---|
| 166 | + BCMEVENT_NAME(WLC_E_AIBSS_TXFAIL), |
|---|
| 167 | +#endif /* WLAIBSS */ |
|---|
| 160 | 168 | #ifdef GSCAN_SUPPORT |
|---|
| 161 | 169 | BCMEVENT_NAME(WLC_E_PFN_GSCAN_FULL_RESULT), |
|---|
| 162 | | - BCMEVENT_NAME(WLC_E_PFN_SWC), |
|---|
| 170 | + BCMEVENT_NAME(WLC_E_PFN_SSID_EXT), |
|---|
| 163 | 171 | #endif /* GSCAN_SUPPORT */ |
|---|
| 164 | 172 | #ifdef WLBSSLOAD_REPORT |
|---|
| 165 | 173 | BCMEVENT_NAME(WLC_E_BSS_LOAD), |
|---|
| 166 | | -#endif |
|---|
| 174 | +#endif // endif |
|---|
| 167 | 175 | #if defined(BT_WIFI_HANDOVER) || defined(WL_TBOW) |
|---|
| 168 | 176 | BCMEVENT_NAME(WLC_E_BT_WIFI_HANDOVER_REQ), |
|---|
| 169 | | -#endif |
|---|
| 177 | +#endif // endif |
|---|
| 170 | 178 | #ifdef WLFBT |
|---|
| 171 | | - BCMEVENT_NAME(WLC_E_FBT_AUTH_REQ_IND), |
|---|
| 179 | + BCMEVENT_NAME(WLC_E_FBT), |
|---|
| 172 | 180 | #endif /* WLFBT */ |
|---|
| 173 | 181 | BCMEVENT_NAME(WLC_E_AUTHORIZED), |
|---|
| 174 | 182 | BCMEVENT_NAME(WLC_E_PROBREQ_MSG_RX), |
|---|
| .. | .. |
|---|
| 178 | 186 | BCMEVENT_NAME(WLC_E_RMC_EVENT), |
|---|
| 179 | 187 | BCMEVENT_NAME(WLC_E_DPSTA_INTF_IND), |
|---|
| 180 | 188 | BCMEVENT_NAME(WLC_E_ALLOW_CREDIT_BORROW), |
|---|
| 189 | + BCMEVENT_NAME(WLC_E_MSCH), |
|---|
| 181 | 190 | 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), |
|---|
| 182 | 209 | }; |
|---|
| 183 | 210 | |
|---|
| 184 | 211 | const char *bcmevent_get_name(uint event_type) |
|---|
| .. | .. |
|---|
| 203 | 230 | * otherwise return unknown string. |
|---|
| 204 | 231 | */ |
|---|
| 205 | 232 | 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); |
|---|
| 206 | 263 | } |
|---|
| 207 | 264 | |
|---|
| 208 | 265 | /* |
|---|
| .. | .. |
|---|
| 246 | 303 | } |
|---|
| 247 | 304 | |
|---|
| 248 | 305 | /* check length in bcmeth_hdr */ |
|---|
| 306 | + |
|---|
| 249 | 307 | /* temporary - header length not always set properly. When the below |
|---|
| 250 | 308 | * !BCMDONGLEHOST is in all branches that use trunk DHD, the code |
|---|
| 251 | 309 | * under BCMDONGLEHOST can be removed. |
|---|
| 252 | 310 | */ |
|---|
| 253 | 311 | evlen = (uint16)(pktend - (uint8 *)&bcm_event->bcm_hdr.version); |
|---|
| 254 | 312 | evend = (uint8 *)&bcm_event->bcm_hdr.version + evlen; |
|---|
| 255 | | - if (evend > pktend) { |
|---|
| 313 | + if (evend != pktend) { |
|---|
| 256 | 314 | err = BCME_BADLEN; |
|---|
| 257 | 315 | goto done; |
|---|
| 258 | 316 | } |
|---|
| .. | .. |
|---|
| 282 | 340 | |
|---|
| 283 | 341 | /* ensure data length in event is not beyond the packet. */ |
|---|
| 284 | 342 | 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) { |
|---|
| 286 | 345 | err = BCME_BADLEN; |
|---|
| 287 | 346 | goto done; |
|---|
| 288 | 347 | } |
|---|
| .. | .. |
|---|
| 298 | 357 | } |
|---|
| 299 | 358 | |
|---|
| 300 | 359 | break; |
|---|
| 360 | + |
|---|
| 301 | 361 | case BCMILCP_BCM_SUBTYPE_DNGLEVENT: |
|---|
| 302 | | -#ifdef HEALTH_CHECK |
|---|
| 362 | +#if defined(DNGL_EVENT_SUPPORT) |
|---|
| 303 | 363 | if ((pktlen < sizeof(bcm_dngl_event_t)) || |
|---|
| 304 | 364 | (evend < ((uint8 *)bcm_event + sizeof(bcm_dngl_event_t)))) { |
|---|
| 305 | 365 | err = BCME_BADLEN; |
|---|
| .. | .. |
|---|
| 308 | 368 | |
|---|
| 309 | 369 | /* ensure data length in event is not beyond the packet. */ |
|---|
| 310 | 370 | 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) { |
|---|
| 312 | 373 | err = BCME_BADLEN; |
|---|
| 313 | 374 | goto done; |
|---|
| 314 | 375 | } |
|---|
| .. | .. |
|---|
| 325 | 386 | } |
|---|
| 326 | 387 | |
|---|
| 327 | 388 | break; |
|---|
| 328 | | -#endif /* HEALTH_CHECK */ |
|---|
| 389 | +#else |
|---|
| 329 | 390 | err = BCME_UNSUPPORTED; |
|---|
| 330 | 391 | break; |
|---|
| 392 | +#endif // endif |
|---|
| 393 | + |
|---|
| 331 | 394 | default: |
|---|
| 332 | 395 | err = BCME_NOTFOUND; |
|---|
| 333 | 396 | goto done; |
|---|
| .. | .. |
|---|
| 336 | 399 | BCM_REFERENCE(data_len); |
|---|
| 337 | 400 | done: |
|---|
| 338 | 401 | 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); |
|---|
| 369 | 402 | } |
|---|