From cde9070d9970eef1f7ec2360586c802a16230ad8 Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Fri, 10 May 2024 07:43:50 +0000 Subject: [PATCH] rtl88x2CE_WiFi_linux driver --- kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/bcmevent.c | 155 +++++++++++++++++++++++++++++++-------------------- 1 files changed, 94 insertions(+), 61 deletions(-) diff --git a/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/bcmevent.c b/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/bcmevent.c index 23a5560..1e5a250 100644 --- a/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/bcmevent.c +++ b/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/bcmevent.c @@ -1,15 +1,16 @@ -/* SPDX-License-Identifier: GPL-2.0 */ /* * bcmevent read-only data shared by kernel or app layers * - * Copyright (C) 1999-2019, Broadcom Corporation - * + * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation + * + * Copyright (C) 1999-2017, Broadcom Corporation + * * Unless you and Broadcom execute a separate written software license * agreement governing use of this software, this software is licensed to you * under the terms of the GNU General Public License version 2 (the "GPL"), * available at http://www.broadcom.com/licenses/GPLv2.php, with the * following added to such license: - * + * * As a special exception, the copyright holders of this software give you * permission to link this software with independent modules, and to copy and * distribute the resulting executable under terms of your choice, provided that @@ -17,7 +18,7 @@ * the license of that module. An independent module is a module which is not * derived from this software. The special exception does not apply to any * modifications of the software. - * + * * Notwithstanding the above, under no circumstances may you combine this * software in any way with any other Broadcom software provided under a license * other than the GPL, without Broadcom's express prior written consent. @@ -25,17 +26,16 @@ * * <<Broadcom-WL-IPTag/Open:>> * - * $Id: bcmevent.c 715966 2019-05-30 02:36:59Z $ + * $Id: bcmevent.c 702756 2017-06-03 17:20:27Z $ */ #include <typedefs.h> #include <bcmutils.h> #include <bcmendian.h> -#include <proto/ethernet.h> -#include <proto/bcmeth.h> -#include <proto/bcmevent.h> -#include <proto/802.11.h> - +#include <ethernet.h> +#include <bcmeth.h> +#include <bcmevent.h> +#include <802.11.h> /* Table of event name strings for UIs and debugging dumps */ typedef struct { @@ -74,6 +74,7 @@ BCMEVENT_NAME(WLC_E_AUTOAUTH), BCMEVENT_NAME(WLC_E_EAPOL_MSG), BCMEVENT_NAME(WLC_E_SCAN_COMPLETE), + BCMEVENT_NAME(WLC_E_IND_DOS_STATUS), BCMEVENT_NAME(WLC_E_ADDTS_IND), BCMEVENT_NAME(WLC_E_DELTS_IND), BCMEVENT_NAME(WLC_E_BCNSENT_IND), @@ -83,6 +84,9 @@ BCMEVENT_NAME(WLC_E_PFN_NET_FOUND), BCMEVENT_NAME(WLC_E_PFN_SCAN_ALLGONE), BCMEVENT_NAME(WLC_E_PFN_NET_LOST), + BCMEVENT_NAME(WLC_E_JOIN_START), + BCMEVENT_NAME(WLC_E_ROAM_START), + BCMEVENT_NAME(WLC_E_ASSOC_START), #if defined(IBSS_PEER_DISCOVERY_EVENT) BCMEVENT_NAME(WLC_E_IBSS_ASSOC), #endif /* defined(IBSS_PEER_DISCOVERY_EVENT) */ @@ -100,27 +104,28 @@ BCMEVENT_NAME(WLC_E_IF), #ifdef WLP2P BCMEVENT_NAME(WLC_E_P2P_DISC_LISTEN_COMPLETE), -#endif +#endif // endif BCMEVENT_NAME(WLC_E_RSSI), - BCMEVENT_NAME(WLC_E_EXTLOG_MSG), + BCMEVENT_NAME(WLC_E_PFN_SCAN_COMPLETE), BCMEVENT_NAME(WLC_E_ACTION_FRAME), BCMEVENT_NAME(WLC_E_ACTION_FRAME_RX), BCMEVENT_NAME(WLC_E_ACTION_FRAME_COMPLETE), +#ifdef BCMWAPI_WAI + BCMEVENT_NAME(WLC_E_WAI_STA_EVENT), + BCMEVENT_NAME(WLC_E_WAI_MSG), +#endif /* BCMWAPI_WAI */ BCMEVENT_NAME(WLC_E_ESCAN_RESULT), BCMEVENT_NAME(WLC_E_ACTION_FRAME_OFF_CHAN_COMPLETE), #ifdef WLP2P BCMEVENT_NAME(WLC_E_PROBRESP_MSG), BCMEVENT_NAME(WLC_E_P2P_PROBREQ_MSG), -#endif +#endif // endif #ifdef PROP_TXSTATUS BCMEVENT_NAME(WLC_E_FIFO_CREDIT_MAP), -#endif +#endif // endif BCMEVENT_NAME(WLC_E_WAKE_EVENT), BCMEVENT_NAME(WLC_E_DCS_REQUEST), BCMEVENT_NAME(WLC_E_RM_COMPLETE), -#ifdef WLMEDIA_HTSF - BCMEVENT_NAME(WLC_E_HTSFSYNC), -#endif BCMEVENT_NAME(WLC_E_OVERLAY_REQ), BCMEVENT_NAME(WLC_E_CSA_COMPLETE_IND), BCMEVENT_NAME(WLC_E_EXCESS_PM_WAKE_EVENT), @@ -128,7 +133,7 @@ BCMEVENT_NAME(WLC_E_PFN_SCAN_ALLGONE), #ifdef SOFTAP BCMEVENT_NAME(WLC_E_GTK_PLUMBED), -#endif +#endif // endif BCMEVENT_NAME(WLC_E_ASSOC_REQ_IE), BCMEVENT_NAME(WLC_E_ASSOC_RESP_IE), BCMEVENT_NAME(WLC_E_BEACON_FRAME_RX), @@ -147,28 +152,31 @@ #ifdef WLWNM BCMEVENT_NAME(WLC_E_WNM_STA_SLEEP), #endif /* WLWNM */ -#if defined(WL_PROXDETECT) +#if defined(WL_PROXDETECT) || defined(RTT_SUPPORT) BCMEVENT_NAME(WLC_E_PROXD), -#endif +#endif // endif BCMEVENT_NAME(WLC_E_CCA_CHAN_QUAL), BCMEVENT_NAME(WLC_E_BSSID), #ifdef PROP_TXSTATUS BCMEVENT_NAME(WLC_E_BCMC_CREDIT_SUPPORT), -#endif +#endif // endif BCMEVENT_NAME(WLC_E_PSTA_PRIMARY_INTF_IND), BCMEVENT_NAME(WLC_E_TXFAIL_THRESH), +#ifdef WLAIBSS + BCMEVENT_NAME(WLC_E_AIBSS_TXFAIL), +#endif /* WLAIBSS */ #ifdef GSCAN_SUPPORT BCMEVENT_NAME(WLC_E_PFN_GSCAN_FULL_RESULT), - BCMEVENT_NAME(WLC_E_PFN_SWC), + BCMEVENT_NAME(WLC_E_PFN_SSID_EXT), #endif /* GSCAN_SUPPORT */ #ifdef WLBSSLOAD_REPORT BCMEVENT_NAME(WLC_E_BSS_LOAD), -#endif +#endif // endif #if defined(BT_WIFI_HANDOVER) || defined(WL_TBOW) BCMEVENT_NAME(WLC_E_BT_WIFI_HANDOVER_REQ), -#endif +#endif // endif #ifdef WLFBT - BCMEVENT_NAME(WLC_E_FBT_AUTH_REQ_IND), + BCMEVENT_NAME(WLC_E_FBT), #endif /* WLFBT */ BCMEVENT_NAME(WLC_E_AUTHORIZED), BCMEVENT_NAME(WLC_E_PROBREQ_MSG_RX), @@ -178,7 +186,26 @@ BCMEVENT_NAME(WLC_E_RMC_EVENT), BCMEVENT_NAME(WLC_E_DPSTA_INTF_IND), BCMEVENT_NAME(WLC_E_ALLOW_CREDIT_BORROW), + BCMEVENT_NAME(WLC_E_MSCH), BCMEVENT_NAME(WLC_E_ULP), + BCMEVENT_NAME(WLC_E_NAN), + BCMEVENT_NAME(WLC_E_PKT_FILTER), + BCMEVENT_NAME(WLC_E_DMA_TXFLUSH_COMPLETE), + BCMEVENT_NAME(WLC_E_PSK_AUTH), + BCMEVENT_NAME(WLC_E_SDB_TRANSITION), + BCMEVENT_NAME(WLC_E_PFN_SCAN_BACKOFF), + BCMEVENT_NAME(WLC_E_PFN_BSSID_SCAN_BACKOFF), + BCMEVENT_NAME(WLC_E_AGGR_EVENT), + BCMEVENT_NAME(WLC_E_TVPM_MITIGATION), +#ifdef WL_NAN + BCMEVENT_NAME(WLC_E_NAN_CRITICAL), + BCMEVENT_NAME(WLC_E_NAN_NON_CRITICAL), + BCMEVENT_NAME(WLC_E_NAN), +#endif /* WL_NAN */ + BCMEVENT_NAME(WLC_E_RPSNOA), + BCMEVENT_NAME(WLC_E_PHY_CAL), + BCMEVENT_NAME(WLC_E_WA_LQM), + BCMEVENT_NAME(WLC_E_OVERTEMP), }; const char *bcmevent_get_name(uint event_type) @@ -203,6 +230,36 @@ * otherwise return unknown string. */ return ((event_name) ? event_name : "Unknown Event"); +} + +void +wl_event_to_host_order(wl_event_msg_t * evt) +{ + /* Event struct members passed from dongle to host are stored in network + * byte order. Convert all members to host-order. + */ + evt->event_type = ntoh32(evt->event_type); + evt->flags = ntoh16(evt->flags); + evt->status = ntoh32(evt->status); + evt->reason = ntoh32(evt->reason); + evt->auth_type = ntoh32(evt->auth_type); + evt->datalen = ntoh32(evt->datalen); + evt->version = ntoh16(evt->version); +} + +void +wl_event_to_network_order(wl_event_msg_t * evt) +{ + /* Event struct members passed from dongle to host are stored in network + * byte order. Convert all members to host-order. + */ + evt->event_type = hton32(evt->event_type); + evt->flags = hton16(evt->flags); + evt->status = hton32(evt->status); + evt->reason = hton32(evt->reason); + evt->auth_type = hton32(evt->auth_type); + evt->datalen = hton32(evt->datalen); + evt->version = hton16(evt->version); } /* @@ -246,13 +303,14 @@ } /* check length in bcmeth_hdr */ + /* temporary - header length not always set properly. When the below * !BCMDONGLEHOST is in all branches that use trunk DHD, the code * under BCMDONGLEHOST can be removed. */ evlen = (uint16)(pktend - (uint8 *)&bcm_event->bcm_hdr.version); evend = (uint8 *)&bcm_event->bcm_hdr.version + evlen; - if (evend > pktend) { + if (evend != pktend) { err = BCME_BADLEN; goto done; } @@ -282,7 +340,8 @@ /* ensure data length in event is not beyond the packet. */ data_len = ntoh32_ua((void *)&bcm_event->event.datalen); - if (data_len > (pktlen - sizeof(bcm_event_t))) { + if ((sizeof(bcm_event_t) + data_len + + BCMILCP_BCM_SUBTYPE_EVENT_DATA_PAD) != pktlen) { err = BCME_BADLEN; goto done; } @@ -298,8 +357,9 @@ } break; + case BCMILCP_BCM_SUBTYPE_DNGLEVENT: -#ifdef HEALTH_CHECK +#if defined(DNGL_EVENT_SUPPORT) if ((pktlen < sizeof(bcm_dngl_event_t)) || (evend < ((uint8 *)bcm_event + sizeof(bcm_dngl_event_t)))) { err = BCME_BADLEN; @@ -308,7 +368,8 @@ /* ensure data length in event is not beyond the packet. */ data_len = ntoh16_ua((void *)&((bcm_dngl_event_t *)pktdata)->dngl_event.datalen); - if (data_len > (pktlen - sizeof(bcm_dngl_event_t))) { + if ((sizeof(bcm_dngl_event_t) + data_len + + BCMILCP_BCM_SUBTYPE_EVENT_DATA_PAD) != pktlen) { err = BCME_BADLEN; goto done; } @@ -325,9 +386,11 @@ } break; -#endif /* HEALTH_CHECK */ +#else err = BCME_UNSUPPORTED; break; +#endif // endif + default: err = BCME_NOTFOUND; goto done; @@ -336,34 +399,4 @@ BCM_REFERENCE(data_len); done: return err; -} - -void -wl_event_to_host_order(wl_event_msg_t * evt) -{ - /* Event struct members passed from dongle to host are stored in network - * byte order. Convert all members to host-order. - */ - evt->event_type = ntoh32(evt->event_type); - evt->flags = ntoh16(evt->flags); - evt->status = ntoh32(evt->status); - evt->reason = ntoh32(evt->reason); - evt->auth_type = ntoh32(evt->auth_type); - evt->datalen = ntoh32(evt->datalen); - evt->version = ntoh16(evt->version); -} - -void -wl_event_to_network_order(wl_event_msg_t * evt) -{ - /* Event struct members passed from dongle to host are stored in network - * byte order. Convert all members to host-order. - */ - evt->event_type = hton32(evt->event_type); - evt->flags = hton16(evt->flags); - evt->status = hton32(evt->status); - evt->reason = hton32(evt->reason); - evt->auth_type = hton32(evt->auth_type); - evt->datalen = hton32(evt->datalen); - evt->version = hton16(evt->version); } -- Gitblit v1.6.2