diff --git a/rk3568/wifi/bcmdhd_wifi6/Makefile b/rk3568/wifi/bcmdhd_wifi6/Makefile index 7244e2ac90f3c1e8d7d1bd3ec928e0c507db0879..959eb6c676b1efe67ae35feca9a9e5defb9db403 100755 --- a/rk3568/wifi/bcmdhd_wifi6/Makefile +++ b/rk3568/wifi/bcmdhd_wifi6/Makefile @@ -1,15 +1,23 @@ # SPDX-License-Identifier: GPL-2.0 # bcmdhd -#HDF_BDH6_VENDOR_PREFIX := ../../ +BDH6_ROOT_DIR := ../../../.. +KERNEL_SRC_DIR := $(BDH6_ROOT_DIR)/out/kernel/src_tmp/linux-5.10 +ORIG_PATH = $(KERNEL_SRC_DIR)/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd_wifi6 +CURR_PATH = $(BDH6_ROOT_DIR)/device/board/hihope/rk3568/wifi/bcmdhd_wifi6/ # Execute Makefile in the kernel root directory -#include drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd_wifi6/hdfwifi_bdh6.mk -include ../../../../device/board/hihope/drivers/rkwifi/bcmdhd_wifi6/hdfwifi_bdh6.mk +include $(BDH6_ROOT_DIR)/device/board/hihope/rk3568/wifi/bcmdhd_wifi6/hdfwifi_bdh6.mk + +#$(info HDF: $(HDF_FRAMEWORKS_INC)) +$(info ap6275s: srctree=$(srctree) src=$(src)) +#$(shell echo "hello world !" > /home/lijg/tools/abc.txt) +$(shell cp -f $(ORIG_PATH)/*.c $(CURR_PATH)) +$(shell cp -f $(ORIG_PATH)/*.h $(CURR_PATH)) +$(shell rm -fr $(CURR_PATH)/include) +$(shell cp -fr $(ORIG_PATH)/include $(CURR_PATH)/include) +$(shell rm -f $(CURR_PATH)/include/eapol.h) -#$(info lijg: $(HDF_FRAMEWORKS_INC)) -$(info lijg: srctree=$(srctree) src=$(src)) -$(info liuzb: ++++++++++++++++ this is 6275s makefile +++++++++++++++++++) #ccflags-$(CONFIG_DRIVERS_HDF_WIFI) += \ # $(HDF_FRAMEWORKS_INC) \ @@ -51,15 +59,19 @@ DHDCFLAGS = -Wall -Wstrict-prototypes -Dlinux -DBCMDRIVER \ -DWL_EXT_IAPSTA -DWL_ESCAN -DCCODE_LIST \ -DENABLE_INSMOD_NO_FW_LOAD \ $(HDF_BDH6_WIFI_CFLAGS) \ - -I../../../../device/board/hihope/drivers/rkwifi/bcmdhd_wifi6 \ - -I../../../../device/board/hihope/drivers/rkwifi/bcmdhd_wifi6/include \ - -I../../../../device/board/hihope/drivers/rkwifi/bcmdhd_wifi6/hdfadapt \ + -I../../../../device/board/hihope/rk3568/wifi/bcmdhd_wifi6 \ + -I../../../../device/board/hihope/rk3568/wifi/bcmdhd_wifi6/include \ + -I../../../../device/board/hihope/rk3568/wifi/bcmdhd_wifi6/hdf \ $(HDF_FRAMEWORKS_INC) \ $(HDF_WIFI_FRAMEWORKS_INC) \ $(HDF_WIFI_ADAPTER_INC) \ $(HDF_WIFI_VENDOR_INC) \ $(SECURE_LIB_INC) +#ORIGOFILES = aiutils.o siutils.o +#ORIGOFILES := $(addprefix $(ORIG_PATH),$(ORIGOFILES)) +#$(info ORIGOFILES = $(ORIGOFILES)) + DHDOFILES = aiutils.o siutils.o sbutils.o bcmutils.o bcmwifi_channels.o \ dhd_linux.o dhd_linux_platdev.o dhd_linux_sched.o dhd_pno.o \ dhd_common.o dhd_ip.o dhd_linux_wq.o dhd_custom_gpio.o \ @@ -70,7 +82,7 @@ DHDOFILES = aiutils.o siutils.o sbutils.o bcmutils.o bcmwifi_channels.o \ dhd_config.o dhd_ccode.o wl_event.o wl_android_ext.o wl_escan.o \ hdf/hdf_driver_bdh_register.o hdf/hdfinit_bdh.o \ hdf/net_bdh_adpater.o hdf/hdf_bdh_mac80211.o hdf/hdf_mac80211_sta.o \ - hdf/hdf_mac80211_sta_event.o hdf/hdf_mac80211_ap.o + hdf/hdf_mac80211_sta_event.o hdf/hdf_mac80211_ap.o hdf/hdf_mac80211_p2p.o ifeq ($(BCMDHD_STATIC_IF),y) DHDCFLAGS += -DWL_STATIC_IF @@ -257,6 +269,7 @@ ifeq ($(CONFIG_BCMDHD),m) endif obj-$(CONFIG_AP6XXX_WIFI6_HDF) += $(MODULE_NAME).o +#$(MODULE_NAME)-objs += $(DHDOFILES) $(ORIGOFILES) $(MODULE_NAME)-objs += $(DHDOFILES) ifeq ($(CONFIG_MACH_PLATFORM),y) diff --git a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_bdh_mac80211.c b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_bdh_mac80211.c index 382c6928fb14c871835eef6be41adfa96aa1ff5b..60fd2258bfb17576b663523f7ce2d95d16bae8b2 100644 --- a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_bdh_mac80211.c +++ b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_bdh_mac80211.c @@ -1,25 +1,22 @@ -/* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * - * HDF is dual licensed: you can use it either under the terms of - * the GPL, or the BSD license, at your option. - * See the LICENSE file in the root of this repository for complete details. - */ - -#include -#include - -#include +#include #include "wifi_module.h" #include "wifi_mac80211_ops.h" #include "hdf_wlan_utils.h" +#include +#include #include "net_bdh_adpater.h" -#include "hdf_public_ap6275s.h" +#include +#include "hdf_wl_interface.h" #define HDF_LOG_TAG BDH6Driver +extern struct cfg80211_ops wl_cfg80211_ops; +extern struct net_device_ops dhd_ops_pri; +extern struct hdf_inf_map g_hdf_infmap[HDF_INF_MAX]; +extern u64 p2p_cookie; +extern u32 p2p_remain_freq; typedef enum { WLAN_BAND_2G, @@ -34,30 +31,42 @@ typedef enum { #define WAL_MAX_FREQ_2G (2484) #define WAL_FREQ_2G_INTERVAL (5) -#define BDH6_GROUP_SIZE (1) -#define BDH6_ROW_SIZE (16) +//#define WAL_MIN_FREQ_5G (5180 + 20*(WAL_MIN_CHANNEL_2G - 1)) +//#define WAL_MAX_FREQ_5G (5850) +//#define WAL_FREQ_2G_INTERVAL (5) + +#define WLAN_WPS_IE_MAX_SIZE (352) // (WLAN_MEM_EVENT_SIZE2 - 32) /* 32表示事件自身占用的空间 */ +#define MAC_80211_FRAME_LEN 24 /* 非四地址情况下,MAC帧头的长度 */ -struct wiphy* get_linux_wiphy_ndev(struct net_device *ndev) + +struct net_device * GetLinuxInfByNetDevice(const struct NetDevice *netDevice); +struct NetDevice * get_real_netdev(NetDevice *netDev); + + +struct wiphy * get_linux_wiphy_ndev(struct net_device *ndev) { - if (ndev == NULL || ndev->ieee80211_ptr == NULL) { + if (NULL == ndev || NULL == ndev->ieee80211_ptr) { + //HDF_LOGE("%s: net_device is NULL", __func__); return NULL; } return ndev->ieee80211_ptr->wiphy; } -struct wiphy* get_linux_wiphy_hdfdev(NetDevice *netDev) +struct wiphy * get_linux_wiphy_hdfdev(NetDevice *netDev) { struct net_device *ndev = GetLinuxInfByNetDevice(netDev); return get_linux_wiphy_ndev(ndev); } + int32_t BDH6WalSetMode(NetDevice *netDev, enum WlanWorkMode iftype) { int32_t retVal = 0; struct net_device *netdev = NULL; struct wiphy *wiphy = NULL; + netDev = get_real_netdev(netDev); netdev = GetLinuxInfByNetDevice(netDev); if (!netdev) { @@ -72,8 +81,9 @@ int32_t BDH6WalSetMode(NetDevice *netDev, enum WlanWorkMode iftype) } HDF_LOGE("%s: start... iftype=%d ", __func__, iftype); - retVal = (int32_t) wl_cfg80211_ops.change_virtual_intf(wiphy, netdev, - (enum nl80211_iftype) iftype, NULL); + retVal = (int32_t)wl_cfg80211_ops.change_virtual_intf(wiphy, netdev, + (enum nl80211_iftype)iftype, + NULL); if (retVal < 0) { HDF_LOGE("%s: set mode failed!", __func__); } @@ -87,6 +97,11 @@ int32_t BDH6WalAddKey(struct NetDevice *netDev, uint8_t keyIndex, bool pairwise, int32_t retVal = 0; struct net_device *netdev = NULL; struct wiphy *wiphy = NULL; + netDev = get_real_netdev(netDev); + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 10, 0)) + struct key_params keypm; +#endif netdev = GetLinuxInfByNetDevice(netDev); if (!netdev) { @@ -99,14 +114,29 @@ int32_t BDH6WalAddKey(struct NetDevice *netDev, uint8_t keyIndex, bool pairwise, HDF_LOGE("%s: wiphy is NULL", __func__); return -1; } + + //HDF_LOGE("%s: start..., mac=%02x:%02x:%02x:%02x:%02x:%02x, keyIndex=%u,pairwise=%d, cipher=%u, seqlen=%d,keylen=%d", + // __func__, macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], macAddr[5], keyIndex, pairwise, params->cipher, + // params->seqLen, params->keyLen); - HDF_LOGE("%s: start..., mac=%p, keyIndex=%u, pairwise=%d, cipher=0x%x, seqlen=%d, keylen=%d", - __func__, macAddr, keyIndex, pairwise, params->cipher, params->seqLen, params->keyLen); - print_hex_dump(KERN_INFO, "key: ", DUMP_PREFIX_NONE, BDH6_ROW_SIZE, BDH6_GROUP_SIZE, params->key, - params->keyLen, true); + HDF_LOGE("%s: start..., mac=%p, keyIndex=%u,pairwise=%d, cipher=0x%x, seqlen=%d,keylen=%d", + __func__, macAddr, keyIndex, pairwise, params->cipher, + params->seqLen, params->keyLen); + print_hex_dump(KERN_INFO, "key: ", DUMP_PREFIX_NONE, 16, 1, params->key, params->keyLen, true); (void)netDev; +#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 10, 0)) + memset_s(&keypm, sizeof(struct key_params), 0, sizeof(struct key_params)); + keypm.key = params->key; + keypm.seq = params->seq; + keypm.key_len = params->keyLen; + keypm.seq_len = params->seqLen; + keypm.cipher = params->cipher; + keypm.vlan_id = 0; + retVal = (int32_t)wl_cfg80211_ops.add_key(wiphy, netdev, keyIndex, pairwise, macAddr, &keypm); +#else retVal = (int32_t)wl_cfg80211_ops.add_key(wiphy, netdev, keyIndex, pairwise, macAddr, (struct key_params *)params); +#endif if (retVal < 0) { HDF_LOGE("%s: add key failed!", __func__); } @@ -119,6 +149,7 @@ int32_t BDH6WalDelKey(struct NetDevice *netDev, uint8_t keyIndex, bool pairwise, int32_t retVal = 0; struct net_device *netdev = NULL; struct wiphy *wiphy = NULL; + netDev = get_real_netdev(netDev); netdev = GetLinuxInfByNetDevice(netDev); if (!netdev) { @@ -148,6 +179,7 @@ int32_t BDH6WalSetDefaultKey(struct NetDevice *netDev, uint8_t keyIndex, bool un int32_t retVal = 0; struct net_device *netdev = NULL; struct wiphy *wiphy = NULL; + netDev = get_real_netdev(netDev); netdev = GetLinuxInfByNetDevice(netDev); if (!netdev) { @@ -173,6 +205,7 @@ int32_t BDH6WalSetDefaultKey(struct NetDevice *netDev, uint8_t keyIndex, bool un int32_t BDH6WalGetDeviceMacAddr(NetDevice *netDev, int32_t type, uint8_t *mac, uint8_t len) { + netDev = get_real_netdev(netDev); struct net_device *netdev = GetLinuxInfByNetDevice(netDev); if (!netdev) { HDF_LOGE("%s: net_device is NULL", __func__); @@ -192,6 +225,7 @@ int32_t BDH6WalGetDeviceMacAddr(NetDevice *netDev, int32_t type, uint8_t *mac, u int32_t BDH6WalSetMacAddr(NetDevice *netDev, uint8_t *mac, uint8_t len) { int32_t retVal = 0; + netDev = get_real_netdev(netDev); struct net_device *netdev = GetLinuxInfByNetDevice(netDev); if (!netdev) { HDF_LOGE("%s: net_device is NULL", __func__); @@ -214,6 +248,7 @@ int32_t BDH6WalSetTxPower(NetDevice *netDev, int32_t power) { int retVal = 0; struct wiphy *wiphy = NULL; + netDev = get_real_netdev(netDev); // sync from net_device->ieee80211_ptr struct wireless_dev *wdev = GET_NET_DEV_CFG80211_WIRELESS(netDev); @@ -225,7 +260,9 @@ int32_t BDH6WalSetTxPower(NetDevice *netDev, int32_t power) } HDF_LOGE("%s: start...", __func__); - retVal = (int32_t)wl_cfg80211_ops.set_tx_power(wiphy, wdev, NL80211_TX_POWER_FIXED, power); + + retVal = (int32_t)wl_cfg80211_ops.set_tx_power(wiphy, wdev, NL80211_TX_POWER_FIXED ,power); + if (retVal < 0) { HDF_LOGE("%s: set_tx_power failed!", __func__); } @@ -233,7 +270,7 @@ int32_t BDH6WalSetTxPower(NetDevice *netDev, int32_t power) return HDF_SUCCESS; } -const struct ieee80211_regdomain* bdh6_get_regdomain(void); +const struct ieee80211_regdomain * bdh6_get_regdomain(void); int32_t BDH6WalGetValidFreqsWithBand(NetDevice *netDev, int32_t band, int32_t *freqs, uint32_t *num) @@ -249,15 +286,19 @@ int32_t BDH6WalGetValidFreqsWithBand(NetDevice *netDev, int32_t band, int32_t *f int32_t max5GChNum = 0; const struct ieee80211_regdomain *regdom = bdh6_get_regdomain(); if (regdom == NULL) { + HDF_LOGE("%s: wal_get_cfg_regdb failed!", __func__); return HDF_FAILURE; } + netDev = get_real_netdev(netDev); wiphy = get_linux_wiphy_hdfdev(netDev); if (!wiphy) { + HDF_LOGE("%s: wiphy is NULL", __func__); return -1; } (void)netDev; + HDF_LOGE("%s: start..., band=%d", __func__, band); minFreq = regdom->reg_rules[0].freq_range.start_freq_khz / MHZ_TO_KHZ(1); maxFreq = regdom->reg_rules[0].freq_range.end_freq_khz / MHZ_TO_KHZ(1); @@ -273,6 +314,7 @@ int32_t BDH6WalGetValidFreqsWithBand(NetDevice *netDev, int32_t band, int32_t *f continue; } + HDF_LOGE("bdh6 2G %u: freq=%u\n", freqIndex, freqTmp); freqs[freqIndex] = freqTmp; freqIndex++; } @@ -281,18 +323,41 @@ int32_t BDH6WalGetValidFreqsWithBand(NetDevice *netDev, int32_t band, int32_t *f case WLAN_BAND_5G: band5g = wiphy->bands[IEEE80211_BAND_5GHZ]; - if (band5g == NULL) { + if (NULL == band5g) { + HDF_LOGE("%s: bamd5g is null!", __func__); return HDF_ERR_NOT_SUPPORT; } + //band5g->n_channels; max5GChNum = min(band5g->n_channels, WIFI_24G_CHANNEL_NUMS); for (freqIndex = 0; freqIndex < max5GChNum; freqIndex++) { freqs[freqIndex] = band5g->channels[freqIndex].center_freq; + HDF_LOGE("bdh6 5G %u: freq=%u\n", freqIndex, freqs[freqIndex]); } *num = freqIndex; break; + /** + case WLAN_BAND_5G: + for (channelNumber = 1; channelNumber <= WIFI_24G_CHANNEL_NUMS; channelNumber++) { + if (channelNumber < WAL_MAX_CHANNEL_2G) { + freqTmp = WAL_MIN_FREQ_2G + (channelNumber - 1) * WAL_FREQ_2G_INTERVAL; + } else if (channelNumber == WAL_MAX_CHANNEL_2G) { + freqTmp = WAL_MAX_FREQ_2G; + } + if (freqTmp < minFreq || freqTmp > maxFreq) { + continue; + } + + HDF_LOGE("bdh6 2G %u: freq=%u\n", freqIndex, freqTmp); + freqs[freqIndex] = freqTmp; + freqIndex++; + } + *num = freqIndex; + break; + */ default: + HDF_LOGE("%s: no support band!", __func__); return HDF_ERR_NOT_SUPPORT; } return HDF_SUCCESS; @@ -317,58 +382,6 @@ void BDH6WalReleaseHwCapability(struct WlanHwCapability *self) OsalMemFree(self); } -static int32_t BDH6GetHw5GCapability(struct wiphy* wiphy, struct ieee80211_supported_band *band5g, - struct WlanHwCapability *hwCapability) -{ - uint8_t loop = 0; - hwCapability->bands[IEEE80211_BAND_5GHZ] = OsalMemCalloc(sizeof(struct WlanBand) + \ - (sizeof(struct WlanChannel) * band5g->n_channels)); - if (hwCapability->bands[IEEE80211_BAND_5GHZ] == NULL) { - HDF_LOGE("%s: oom!\n", __func__); - BDH6WalReleaseHwCapability(hwCapability); - return HDF_FAILURE; - } - - hwCapability->bands[IEEE80211_BAND_5GHZ]->channelCount = band5g->n_channels; - for (loop = 0; loop < band5g->n_channels; loop++) { - hwCapability->bands[IEEE80211_BAND_5GHZ]->channels[loop].centerFreq = band5g->channels[loop].center_freq; - hwCapability->bands[IEEE80211_BAND_5GHZ]->channels[loop].flags = band5g->channels[loop].flags; - hwCapability->bands[IEEE80211_BAND_5GHZ]->channels[loop].channelId = band5g->channels[loop].hw_value; - } - - return HDF_SUCCESS; -} - -static int32_t BDH6WalGetSupportRate(struct WlanHwCapability *hwCapability, struct ieee80211_supported_band *band, - struct ieee80211_supported_band *band5g, uint16_t supportedRateCount) -{ - uint8_t loop = 0; - hwCapability->supportedRateCount = supportedRateCount; - hwCapability->supportedRates = OsalMemCalloc(sizeof(uint16_t) * supportedRateCount); - if (hwCapability->supportedRates == NULL) { - HDF_LOGE("%s: oom!\n", __func__); - BDH6WalReleaseHwCapability(hwCapability); - return HDF_FAILURE; - } - - for (loop = 0; loop < band->n_bitrates; loop++) { - hwCapability->supportedRates[loop] = band->bitrates[loop].bitrate; - HDF_LOGE("bdh6 2G supportedRates %u: %u\n", loop, hwCapability->supportedRates[loop]); - } - - if (band5g) { - for (loop = band->n_bitrates; loop < supportedRateCount; loop++) { - hwCapability->supportedRates[loop] = band5g->bitrates[loop].bitrate; - HDF_LOGE("bdh6 5G supportedRates %u: %u\n", loop, hwCapability->supportedRates[loop]); - } - } - - if (hwCapability->supportedRateCount > MAX_SUPPORTED_RATE) - hwCapability->supportedRateCount = MAX_SUPPORTED_RATE; - - return HDF_SUCCESS; -} - int32_t BDH6WalGetHwCapability(struct NetDevice *netDev, struct WlanHwCapability **capability) { uint8_t loop = 0; @@ -377,14 +390,22 @@ int32_t BDH6WalGetHwCapability(struct NetDevice *netDev, struct WlanHwCapability struct ieee80211_supported_band *band5g = NULL; struct WlanHwCapability *hwCapability = NULL; uint16_t supportedRateCount = 0; + netDev = get_real_netdev(netDev); wiphy = get_linux_wiphy_hdfdev(netDev); if (!wiphy) { + HDF_LOGE("%s: wiphy is NULL", __func__); return -1; } + + HDF_LOGE("%s: start...", __func__); + band = wiphy->bands[IEEE80211_BAND_2GHZ]; hwCapability = (struct WlanHwCapability *)OsalMemCalloc(sizeof(struct WlanHwCapability)); + + //(void)netDev; if (hwCapability == NULL) { + HDF_LOGE("%s: oom!\n", __func__); return HDF_FAILURE; } hwCapability->Release = BDH6WalReleaseHwCapability; @@ -393,6 +414,7 @@ int32_t BDH6WalGetHwCapability(struct NetDevice *netDev, struct WlanHwCapability hwCapability->bands[IEEE80211_BAND_2GHZ] = OsalMemCalloc(sizeof(struct WlanBand) + (sizeof(struct WlanChannel) * band->n_channels)); if (hwCapability->bands[IEEE80211_BAND_2GHZ] == NULL) { + HDF_LOGE("%s: oom!\n", __func__); BDH6WalReleaseHwCapability(hwCapability); return HDF_FAILURE; } @@ -406,40 +428,160 @@ int32_t BDH6WalGetHwCapability(struct NetDevice *netDev, struct WlanHwCapability hwCapability->bands[IEEE80211_BAND_2GHZ]->channels[loop].centerFreq = band->channels[loop].center_freq; hwCapability->bands[IEEE80211_BAND_2GHZ]->channels[loop].flags = band->channels[loop].flags; hwCapability->bands[IEEE80211_BAND_2GHZ]->channels[loop].channelId = band->channels[loop].hw_value; + HDF_LOGE("bdh6 2G band %u: centerFreq=%u, channelId=%u, flags=0x%08x\n", loop, + hwCapability->bands[IEEE80211_BAND_2GHZ]->channels[loop].centerFreq, + hwCapability->bands[IEEE80211_BAND_2GHZ]->channels[loop].channelId, + hwCapability->bands[IEEE80211_BAND_2GHZ]->channels[loop].flags); } - + if (wiphy->bands[IEEE80211_BAND_5GHZ]) { // Fill 5Ghz band band5g = wiphy->bands[IEEE80211_BAND_5GHZ]; - if (BDH6GetHw5GCapability(wiphy, band5g, hwCapability) != HDF_SUCCESS) { + hwCapability->bands[IEEE80211_BAND_5GHZ] = OsalMemCalloc(sizeof(struct WlanBand) + (sizeof(struct WlanChannel) * band5g->n_channels)); + if (hwCapability->bands[IEEE80211_BAND_5GHZ] == NULL) { + HDF_LOGE("%s: oom!\n", __func__); + BDH6WalReleaseHwCapability(hwCapability); return HDF_FAILURE; } + hwCapability->bands[IEEE80211_BAND_5GHZ]->channelCount = band5g->n_channels; + for (loop = 0; loop < band5g->n_channels; loop++) { + hwCapability->bands[IEEE80211_BAND_5GHZ]->channels[loop].centerFreq = band5g->channels[loop].center_freq; + hwCapability->bands[IEEE80211_BAND_5GHZ]->channels[loop].flags = band5g->channels[loop].flags; + hwCapability->bands[IEEE80211_BAND_5GHZ]->channels[loop].channelId = band5g->channels[loop].hw_value; + HDF_LOGE("bdh6 5G band %u: centerFreq=%u, channelId=%u, flags=0x%08x\n", loop, + hwCapability->bands[IEEE80211_BAND_5GHZ]->channels[loop].centerFreq, + hwCapability->bands[IEEE80211_BAND_5GHZ]->channels[loop].channelId, + hwCapability->bands[IEEE80211_BAND_5GHZ]->channels[loop].flags); + } + + //hwCapability->htCapability = band5g->ht_cap.cap; supportedRateCount += band5g->n_bitrates; } - if (BDH6WalGetSupportRate(hwCapability, band, band5g, supportedRateCount) != HDF_FAILURE) { + HDF_LOGE("bdh6 htCapability= %u,%u; supportedRateCount= %u,%u,%u\n", hwCapability->htCapability, + band5g->ht_cap.cap, supportedRateCount, band->n_bitrates, band5g->n_bitrates); + + hwCapability->supportedRateCount = supportedRateCount; + hwCapability->supportedRates = OsalMemCalloc(sizeof(uint16_t) * supportedRateCount); + if (hwCapability->supportedRates == NULL) { + HDF_LOGE("%s: oom!\n", __func__); + BDH6WalReleaseHwCapability(hwCapability); return HDF_FAILURE; } + + for (loop = 0; loop < band->n_bitrates; loop++) { + hwCapability->supportedRates[loop] = band->bitrates[loop].bitrate; + HDF_LOGE("bdh6 2G supportedRates %u: %u\n", loop, hwCapability->supportedRates[loop]); + } + + if (band5g) { + for (loop = band->n_bitrates; loop < supportedRateCount; loop++) { + hwCapability->supportedRates[loop] = band5g->bitrates[loop].bitrate; + HDF_LOGE("bdh6 5G supportedRates %u: %u\n", loop, hwCapability->supportedRates[loop]); + } + } + + if (hwCapability->supportedRateCount > MAX_SUPPORTED_RATE) + hwCapability->supportedRateCount = MAX_SUPPORTED_RATE; + *capability = hwCapability; return HDF_SUCCESS; } int32_t BDH6WalSendAction(struct NetDevice *netDev, WifiActionData *actionData) { - (void)netDev; - (void)actionData; - HDF_LOGE("%s: start...", __func__); - return HDF_ERR_NOT_SUPPORT; + int retVal = 0; + struct NetDevice *hnetdev = NULL; + struct net_device *netdev = NULL; + struct wiphy *wiphy = NULL; + struct wireless_dev *wdev = NULL; + static u64 action_cookie = 0; + struct cfg80211_mgmt_tx_params params; + u32 center_freq = 0; + u8 *action_buf = NULL; + struct ieee80211_mgmt *mgmt = NULL; + u8 *srcMac = NULL; + hnetdev = netDev; // backup it + + HDF_LOGE("%s: start %s...", __func__, hnetdev->name); + + netDev = get_real_netdev(netDev); + netdev = GetLinuxInfByNetDevice(netDev); + if (!netdev) { + HDF_LOGE("%s: net_device is NULL", __func__); + return -1; + } + + wiphy = get_linux_wiphy_ndev(netdev); + if (!wiphy) { + HDF_LOGE("%s: wiphy is NULL", __func__); + return -1; + } + + if (0 == strcmp(hnetdev->name, "p2p0")) { + wdev = g_hdf_infmap[HDF_INF_P2P0].wdev; + if (g_hdf_infmap[HDF_INF_P2P1].netdev) + //srcMac = g_hdf_infmap[HDF_INF_P2P1].netdev->dev_addr; + //srcMac = g_hdf_infmap[HDF_INF_P2P0].macaddr; + srcMac = wdev->address; + //srcMac = actionData->src; + else + srcMac = actionData->src; + } else { + wdev = netdev->ieee80211_ptr; + srcMac = actionData->src; + } + + //action_cookie ++; + memset_s(¶ms, sizeof(params), 0, sizeof(params)); + params.wait = 0; + //center_freq = ieee80211_channel_to_freq_khz(11, NL80211_BAND_2GHZ); // = 2462*1000 vs channel id 11 + center_freq = p2p_remain_freq; + params.chan = ieee80211_get_channel_khz(wiphy, MHZ_TO_KHZ(center_freq)); + if (params.chan == NULL) { + HDF_LOGE("%s: get center_freq %u faild", __func__, center_freq); + return -1; + } + HDF_LOGE("%s: get channel center_freq=%u, channel_id=%d", __func__, params.chan->center_freq, params.chan->hw_value); + + // build 802.11 action header + action_buf = (u8 *)OsalMemCalloc(MAC_80211_FRAME_LEN+actionData->dataLen); + mgmt = (struct ieee80211_mgmt *)action_buf; + mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION); + memcpy(mgmt->da, actionData->dst, ETH_ALEN); + memcpy(mgmt->sa, srcMac, ETH_ALEN); + memcpy(mgmt->bssid, actionData->bssid, ETH_ALEN); + + /* 填充payload信息 */ + if (actionData->dataLen > 0) { + memcpy(action_buf+MAC_80211_FRAME_LEN, actionData->data, actionData->dataLen); + } + params.buf = action_buf; + params.len = (MAC_80211_FRAME_LEN + actionData->dataLen); + + print_hex_dump(KERN_INFO, "Action pkt: ", DUMP_PREFIX_NONE, 16, 1, params.buf, params.len, true); + HDF_LOGE("%s: %s len=%u, dst: %02x:%02x:%02x:%02x:%02x:%02x, src:%02x:%02x:%02x:%02x:%02x:%02x, bssid:%02x:%02x:%02x:%02x:%02x:%02x", + __func__, netDev->name, params.len, + actionData->dst[0], actionData->dst[1], actionData->dst[2], actionData->dst[3], actionData->dst[4], actionData->dst[5], + actionData->src[0], actionData->src[1], actionData->src[2], actionData->src[3], actionData->src[4], actionData->src[5], + actionData->bssid[0], actionData->bssid[1], actionData->bssid[2], actionData->bssid[3], actionData->bssid[4], actionData->bssid[5] + ); + retVal = (int32_t)wl_cfg80211_ops.mgmt_tx(wiphy, wdev, ¶ms , &action_cookie); + + OsalMemFree(action_buf); + return retVal; } int32_t BDH6WalGetIftype(struct NetDevice *netDev, uint8_t *iftype) { + netDev = get_real_netdev(netDev); iftype = (uint8_t *)(&(GET_NET_DEV_CFG80211_WIRELESS(netDev)->iftype)); HDF_LOGE("%s: start...", __func__); return HDF_SUCCESS; } -static struct HdfMac80211BaseOps g_bdh6_baseOps = { +static struct HdfMac80211BaseOps g_bdh6_baseOps = +{ .SetMode = BDH6WalSetMode, .AddKey = BDH6WalAddKey, .DelKey = BDH6WalDelKey, @@ -466,6 +608,9 @@ static struct HdfMac80211BaseOps g_bdh6_baseOps = { }; +extern struct HdfMac80211STAOps g_bdh6_staOps; +extern struct HdfMac80211APOps g_bdh6_apOps; +extern struct HdfMac80211P2POps g_bdh6_p2pOps; void BDH6Mac80211Init(struct HdfChipDriver *chipDriver) { @@ -479,6 +624,6 @@ void BDH6Mac80211Init(struct HdfChipDriver *chipDriver) chipDriver->ops = &g_bdh6_baseOps; chipDriver->staOps = &g_bdh6_staOps; chipDriver->apOps = &g_bdh6_apOps; - chipDriver->p2pOps = NULL; + chipDriver->p2pOps = &g_bdh6_p2pOps; } diff --git a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_driver_bdh_register.c b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_driver_bdh_register.c index a5856abcefc69dad2b0959e7f378000392aaf87f..56e865d9be46993d024c576610520637648d4ba8 100644 --- a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_driver_bdh_register.c +++ b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_driver_bdh_register.c @@ -1,11 +1,20 @@ /* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. * - * HDF is dual licensed: you can use it either under the terms of - * the GPL, or the BSD license, at your option. - * See the LICENSE file in the root of this repository for complete details. - */ - + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ #include "hdf_device_desc.h" #include "hdf_wifi_product.h" #include "hdf_log.h" @@ -13,10 +22,13 @@ #include "hdf_wlan_chipdriver_manager.h" #include "securec.h" #include "wifi_module.h" - +//#include "hi_wifi_api.h" +//#include "hi_types_base.h" #define HDF_LOG_TAG BDH6Driver +//#if 0 + int32_t InitBDH6Chip(struct HdfWlanDevice *device); int32_t DeinitBDH6Chip(struct HdfWlanDevice *device); int32_t BDH6Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice); @@ -57,7 +69,7 @@ static struct HdfChipDriver *BuildBDH6Driver(struct HdfWlanDevice *device, uint8 specificDriver->init = BDH6Init; specificDriver->deinit = BDH6Deinit; - HDF_LOGW("bdh6: call BuildBDH6Driver"); + HDF_LOGW("bdh6: call BuildBDH6Driver %p", specificDriver); BDH6Mac80211Init(specificDriver); @@ -106,12 +118,14 @@ static int32_t HDFWlanRegBDH6DriverFactory(void) return HDF_SUCCESS; } +//#endif static int32_t HdfWlanBDH6ChipDriverInit(struct HdfDeviceObject *device) { (void)device; HDF_LOGW("bdh6: call HdfWlanBDH6ChipDriverInit"); return HDFWlanRegBDH6DriverFactory(); + //return 0; } static int HdfWlanBDH6DriverBind(struct HdfDeviceObject *dev) diff --git a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_ap.c b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_ap.c index 27ba87bb12e6f404cf73a4ad81ab7bcba0eadb9b..db2a412e52b4a174421d1c0d79e6a1afa79bb380 100644 --- a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_ap.c +++ b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_ap.c @@ -1,177 +1,252 @@ -/* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * - * HDF is dual licensed: you can use it either under the terms of - * the GPL, or the BSD license, at your option. - * See the LICENSE file in the root of this repository for complete details. - */ +/* + * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include "wifi_mac80211_ops.h" +//#include "net_adpater.h" +#include "hdf_wlan_utils.h" +#include "wifi_module.h" #include #include - +#include "osal_mem.h" +#include "hdf_wifi_event.h" +#include "hdf_log.h" #include #include #include +#include "net_device_adapter.h" -#include - -#include "wifi_mac80211_ops.h" -#include "hdf_wlan_utils.h" -#include "wifi_module.h" -#include "osal_mem.h" -#include "hdf_wifi_event.h" -#include "hdf_log.h" -#include "net_device_adapter.h" -#include "hdf_public_ap6275s.h" #define HDF_LOG_TAG bcmdhd - +//#define retVal 0 +//#define HDF_SUCCESS 1 +#ifndef errno_t +typedef int errno_t; +#endif struct net_device *g_save_kernel_net = NULL; +extern struct net_device_ops dhd_ops_pri; +extern struct cfg80211_ops wl_cfg80211_ops; +extern struct net_device * GetLinuxInfByNetDevice(const struct NetDevice *netDevice); +extern struct wiphy * get_linux_wiphy_ndev(struct net_device *ndev); + + +extern struct wireless_dev* wrap_get_widev(void); +extern const struct ieee80211_regdomain * wrp_get_regdomain(void); +extern int32_t wl_get_all_sta(struct net_device *ndev, uint32_t *num); +extern void dhd_get_mac_address(struct net_device *dev, void **addr); +extern s32 wl_get_all_sta_info(struct net_device *ndev, char* mac, uint32_t num); +extern int32_t wal_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy, struct net_device *netDev); +extern int32_t wl_cfg80211_set_wps_p2p_ie_wrp(struct net_device *ndev, char *buf, int len, int8_t type); +extern int32_t wal_cfg80211_remain_on_channel(struct wiphy *wiphy, struct net_device *netDev, int32_t freq, + unsigned int duration); +extern void wl_cfg80211_add_virtual_iface_wrap(struct wiphy *wiphy, char *name, enum nl80211_iftype type, + struct vif_params *params); +extern int32_t wl_cfg80211_set_country_code(struct net_device *net, char *country_code, + bool notify, bool user_enforced, int revinfo); + +extern int32_t wl_cfg80211_change_beacon_wrap(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_beacon_data *info, int interval, + int dtimPeriod, bool hidden_ssid); + +extern errno_t memcpy_s(void *dest, size_t dest_max, const void *src, size_t count); +extern int snprintf_s(char *dest, size_t dest_max, size_t count, const char *format, ...); +extern s32 wldev_ioctl_get(struct net_device *dev, u32 cmd, void *arg, u32 len); +extern int32_t wl_get_all_sta(struct net_device *ndev, uint32_t *num); + +extern int32_t HdfWifiEventDelSta(struct NetDevice *netDev, const uint8_t *macAddr, uint8_t addrLen); +extern NetDevice * GetHdfNetDeviceByLinuxInf(struct net_device *dev); + +struct NetDevice * get_real_netdev(NetDevice *netDev); /*--------------------------------------------------------------------------------------------------*/ /* public */ /*--------------------------------------------------------------------------------------------------*/ +#define oal_net_dev_priv(_pst_dev) GET_NET_DEV_PRIV(_pst_dev) #define MAX_NUM_OF_ASSOCIATED_DEV 64 #define WLC_GET_ASSOCLIST 159 +#define dtoh32(i) i + -#define ETH_MAC_LEN 6 typedef struct maclist { - uint32 count; /**< number of MAC addresses */ - struct ether_addr ea[1]; /**< variable length array of MAC addresses */ + uint32 count; /**< number of MAC addresses */ + struct ether_addr ea[1]; /**< variable length array of MAC addresses */ } maclist_t; -int ChangDelSta(struct net_device *dev, const uint8_t *macAddr, uint8_t addrLen) +/* +void ChangeStationInfo (struct station_info *info, struct StationInfo *Info) { - int ret; - struct NetDevice *netDev = GetHdfNetDeviceByLinuxInf(dev); - ret = HdfWifiEventDelSta(netDev, macAddr, ETH_MAC_LEN); - return ret; + Info->assocReqIes = info->assocReqIes; + Info->assocReqIesLen = info->assocReqIesLen; + + return Info; +}*/ + + +int ChangDelSta(struct net_device *dev,const uint8_t *macAddr, uint8_t addrLen){ + int ret; + struct NetDevice *netDev = GetHdfNetDeviceByLinuxInf(dev); + ret = HdfWifiEventDelSta(netDev, macAddr, 6); + return ret; } int ChangNewSta(struct net_device *dev, const uint8_t *macAddr, uint8_t addrLen, const struct station_info *info) { - int ret; - struct NetDevice *netDev = NULL; - struct StationInfo Info = {0}; + int ret; + struct NetDevice *netDev = NULL; + struct StationInfo Info = {0}; - Info.assocReqIes = info->assoc_req_ies; - Info.assocReqIesLen = info->assoc_req_ies_len; +// ChangeStationInfo (info, &Info); + Info.assocReqIes = info->assoc_req_ies; + Info.assocReqIesLen = info->assoc_req_ies_len; + + netDev = GetHdfNetDeviceByLinuxInf(dev); - netDev = GetHdfNetDeviceByLinuxInf(dev); + ret = HdfWifiEventNewSta(netDev,macAddr,addrLen,&Info); + return ret; - ret = HdfWifiEventNewSta(netDev, macAddr, addrLen, &Info); - return ret; } -int32_t wl_get_all_sta(struct net_device *ndev, uint32_t *num) -{ - int ret = 0; - char mac_buf[MAX_NUM_OF_ASSOCIATED_DEV * sizeof(struct ether_addr) + sizeof(uint)] = {0}; - struct maclist *assoc_maclist = (struct maclist *)mac_buf; - assoc_maclist->count = MAX_NUM_OF_ASSOCIATED_DEV; - ret = wldev_ioctl_get(ndev, WLC_GET_ASSOCLIST, assoc_maclist, sizeof(mac_buf)); - *num = assoc_maclist->count; - return 0; -} +int32_t wl_get_all_sta(struct net_device *ndev, uint32_t *num){ + int ret=0; + char mac_buf[MAX_NUM_OF_ASSOCIATED_DEV * + sizeof(struct ether_addr) + sizeof(uint)] = {0}; + struct maclist *assoc_maclist = (struct maclist *)mac_buf; + assoc_maclist->count = MAX_NUM_OF_ASSOCIATED_DEV; + ret = wldev_ioctl_get(ndev, WLC_GET_ASSOCLIST, + assoc_maclist, sizeof(mac_buf)); + *num = assoc_maclist->count; + return 0; +} #define MAX_NUM_OF_ASSOCLIST 64 #define CMD_ASSOC_CLIENTS "ASSOCLIST" +#define htod32(i) i + + + + +int wl_get_all_sta_info(struct net_device *ndev, char* mac, uint32_t num){ + + int bytes_written = 0; + int error = 0; + int len = 0; + int i; + char mac_buf[MAX_NUM_OF_ASSOCLIST *sizeof(struct ether_addr) + sizeof(uint)] = {0}; + struct maclist *assoc_maclist = (struct maclist *)mac_buf; + assoc_maclist->count = htod32(MAX_NUM_OF_ASSOCLIST); + error = wldev_ioctl_get(ndev, WLC_GET_ASSOCLIST, assoc_maclist, sizeof(mac_buf)); + if (error) return -1; + assoc_maclist->count = dtoh32(assoc_maclist->count); + bytes_written = snprintf(mac, num, "%s listcount: %d Stations:", + CMD_ASSOC_CLIENTS, assoc_maclist->count); + for (i = 0; i < assoc_maclist->count; i++) { + len = snprintf(mac + bytes_written, num - bytes_written, " " MACDBG, + MAC2STRDBG(assoc_maclist->ea[i].octet)); + /* A return value of '(total_len - bytes_written)' or more means that the + * output was truncated + */ + if ((len > 0) && (len < (num - bytes_written))) { + bytes_written += len; + } else { + bytes_written = -1; + break; + } + } + + return bytes_written; -int wl_get_all_sta_info(struct net_device *ndev, char* mac, uint32_t num) -{ - int bytes_written = 0; - int error = 0; - int len = 0; - int i; - char mac_buf[MAX_NUM_OF_ASSOCLIST *sizeof(struct ether_addr) + sizeof(uint)] = {0}; - struct maclist *assoc_maclist = (struct maclist *)mac_buf; - assoc_maclist->count = (MAX_NUM_OF_ASSOCLIST); - error = wldev_ioctl_get(ndev, WLC_GET_ASSOCLIST, assoc_maclist, sizeof(mac_buf)); - if (error) { - return -1; - } - assoc_maclist->count = assoc_maclist->count; - bytes_written = snprintf_s(mac, num, num, "%s listcount: %d Stations:", - CMD_ASSOC_CLIENTS, assoc_maclist->count); - for (i = 0; i < assoc_maclist->count; i++) { - len = snprintf_s(mac + bytes_written, num - bytes_written, num - bytes_written, " " MACDBG, - MAC2STRDBG(assoc_maclist->ea[i].octet)); - /* A return value of '(total_len - bytes_written)' or more means that the - * output was truncated - */ - if ((len > 0) && (len < (num - bytes_written))) { - bytes_written += len; - } else { - bytes_written = -1; - break; - } - } - - return bytes_written; } #if 1 -#define RATE_OFFSET 2 -#define CAP_OFFSET 2 -// Copy from nl80211_check_ap_rate_selectors() in nl80211.c -static void bdh6_nl80211_check_ap_rate_selectors(struct cfg80211_ap_settings *params, const u8 *rates) +static void bdh6_nl80211_check_ap_rate_selectors(struct cfg80211_ap_settings *params, + const u8 *rates) { - int i; + int i; - if (!rates) - return; + if (!rates) + return; - for (i = 0; i < rates[1]; i++) { - if (rates[RATE_OFFSET + i] == BSS_MEMBERSHIP_SELECTOR_HT_PHY) - params->ht_required = true; - if (rates[RATE_OFFSET + i] == BSS_MEMBERSHIP_SELECTOR_VHT_PHY) - params->vht_required = true; - } + for (i = 0; i < rates[1]; i++) { + if (rates[2 + i] == BSS_MEMBERSHIP_SELECTOR_HT_PHY) + params->ht_required = true; + if (rates[2 + i] == BSS_MEMBERSHIP_SELECTOR_VHT_PHY) + params->vht_required = true; +#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 10, 0)) + if (rates[2 + i] == BSS_MEMBERSHIP_SELECTOR_HE_PHY) + params->he_required = true; +#endif + } } -// Copy from nl80211_calculate_ap_params() in nl80211.c static void bdh6_nl80211_calculate_ap_params(struct cfg80211_ap_settings *params) { - const struct cfg80211_beacon_data *bcn = ¶ms->beacon; - size_t ies_len = bcn->tail_len; - const u8 *ies = bcn->tail; - const u8 *rates; - const u8 *cap; + const struct cfg80211_beacon_data *bcn = ¶ms->beacon; + size_t ies_len = bcn->tail_len; + const u8 *ies = bcn->tail; + const u8 *rates; + const u8 *cap; - rates = cfg80211_find_ie(WLAN_EID_SUPP_RATES, ies, ies_len); + rates = cfg80211_find_ie(WLAN_EID_SUPP_RATES, ies, ies_len); HDF_LOGE("lijg: find beacon tail WLAN_EID_SUPP_RATES=%p", rates); - bdh6_nl80211_check_ap_rate_selectors(params, rates); + bdh6_nl80211_check_ap_rate_selectors(params, rates); - rates = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, ies, ies_len); + rates = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, ies, ies_len); HDF_LOGE("lijg: find beacon tail WLAN_EID_EXT_SUPP_RATES=%p", rates); - bdh6_nl80211_check_ap_rate_selectors(params, rates); + bdh6_nl80211_check_ap_rate_selectors(params, rates); - cap = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, ies, ies_len); + cap = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, ies, ies_len); HDF_LOGE("lijg: find beacon tail WLAN_EID_HT_CAPABILITY=%p", cap); - if (cap && cap[1] >= sizeof(*params->ht_cap)) - params->ht_cap = (void *)(cap + CAP_OFFSET); - cap = cfg80211_find_ie(WLAN_EID_VHT_CAPABILITY, ies, ies_len); + if (cap && cap[1] >= sizeof(*params->ht_cap)) + params->ht_cap = (void *)(cap + 2); + cap = cfg80211_find_ie(WLAN_EID_VHT_CAPABILITY, ies, ies_len); HDF_LOGE("lijg: find beacon tail WLAN_EID_VHT_CAPABILITY=%p", cap); - if (cap && cap[1] >= sizeof(*params->vht_cap)) - params->vht_cap = (void *)(cap + CAP_OFFSET); + if (cap && cap[1] >= sizeof(*params->vht_cap)) + params->vht_cap = (void *)(cap + 2); +#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 10, 0)) + cap = cfg80211_find_ext_ie(WLAN_EID_EXT_HE_CAPABILITY, ies, ies_len); + HDF_LOGE("lijg: find beacon tail WLAN_EID_EXT_HE_CAPABILITY=%p", cap); + if (cap && cap[1] >= sizeof(*params->he_cap) + 1) + params->he_cap = (void *)(cap + 3); + cap = cfg80211_find_ext_ie(WLAN_EID_EXT_HE_OPERATION, ies, ies_len); + HDF_LOGE("lijg: find beacon tail WLAN_EID_EXT_HE_OPERATION=%p", cap); + if (cap && cap[1] >= sizeof(*params->he_oper) + 1) + params->he_oper = (void *)(cap + 3); +#endif } #endif +//static struct wireless_dev g_ap_wireless_dev; static struct ieee80211_channel g_ap_ieee80211_channel; +#define GET_DEV_CFG80211_WIRELESS(dev) ((struct wireless_dev*)((dev)->ieee80211_ptr)) static struct cfg80211_ap_settings g_ap_setting_info; static u8 g_ap_ssid[IEEE80211_MAX_SSID_LEN]; +//static struct ieee80211_channel g_ap_chan; static int start_ap_flag = 0; static int32_t SetupWireLessDev(struct net_device *netDev, struct WlanAPConf *apSettings) @@ -179,11 +254,23 @@ static int32_t SetupWireLessDev(struct net_device *netDev, struct WlanAPConf *ap struct wireless_dev *wdev = NULL; struct ieee80211_channel *chan = NULL; +#if 0 + if (netDev->ieee80211_ptr == NULL) { + netDev->ieee80211_ptr = &g_ap_wireless_dev; + } + + if (GET_DEV_CFG80211_WIRELESS(netDev)->preset_chandef.chan == NULL) { + GET_DEV_CFG80211_WIRELESS(netDev)->preset_chandef.chan = &g_ap_ieee80211_channel; + } +#endif wdev = netDev->ieee80211_ptr; - if (wdev == NULL) { + if (NULL == wdev) { HDF_LOGE("%s: wdev is null", __func__); return -1; } + HDF_LOGE("%s:%p, chan=%p, channel=%u,centfreq1=%u,centfreq2=%u,band=%u,width=%u", __func__, + wdev, wdev->preset_chandef.chan, + apSettings->channel, apSettings->centerFreq1, apSettings->centerFreq2, apSettings->band, apSettings->width); wdev->iftype = NL80211_IFTYPE_AP; wdev->preset_chandef.width = (enum nl80211_channel_type)apSettings->width; @@ -194,7 +281,7 @@ static int32_t SetupWireLessDev(struct net_device *netDev, struct WlanAPConf *ap if (chan) { wdev->preset_chandef.chan = chan; HDF_LOGE("%s: use valid channel %u", __func__, chan->center_freq); - } else if (wdev->preset_chandef.chan == NULL) { + } else if (NULL == wdev->preset_chandef.chan) { wdev->preset_chandef.chan = &g_ap_ieee80211_channel; wdev->preset_chandef.chan->hw_value = apSettings->channel; wdev->preset_chandef.chan->band = apSettings->band; // IEEE80211_BAND_2GHZ; @@ -213,10 +300,10 @@ static int32_t SetupWireLessDev(struct net_device *netDev, struct WlanAPConf *ap int32_t WalConfigAp(NetDevice *netDev, struct WlanAPConf *apConf) { int32_t ret = 0; - struct net_device *netdev = NULL; struct wiphy *wiphy = NULL; - netdev = GetLinuxInfByNetDevice(netDev); + netDev = get_real_netdev(netDev); + netdev = GetLinuxInfByNetDevice(netDev); if (!netdev) { HDF_LOGE("%s: net_device is NULL", __func__); return -1; @@ -228,9 +315,9 @@ int32_t WalConfigAp(NetDevice *netDev, struct WlanAPConf *apConf) return -1; } - memset_s(&g_ap_setting_info, sizeof(g_ap_setting_info), 0x00, sizeof(g_ap_setting_info)); + memset(&g_ap_setting_info, 0x00, sizeof(g_ap_setting_info)); ret = SetupWireLessDev(netdev, apConf); - if (ret != 0) { + if (0 != ret) { HDF_LOGE("%s: set up wireless device failed!", __func__); return HDF_FAILURE; } @@ -240,11 +327,23 @@ int32_t WalConfigAp(NetDevice *netDev, struct WlanAPConf *apConf) HDF_LOGE("%s: after iftype = %d!", __func__, netdev->ieee80211_ptr->iftype); g_ap_setting_info.ssid_len = apConf->ssidConf.ssidLen; - memcpy_s(&g_ap_ssid[0], IEEE80211_MAX_SSID_LEN, &apConf->ssidConf.ssid[0], apConf->ssidConf.ssidLen); + memcpy(&g_ap_ssid[0], &apConf->ssidConf.ssid[0], apConf->ssidConf.ssidLen); g_ap_setting_info.ssid = &g_ap_ssid[0]; +#if 0 + g_ap_setting_info.chandef.center_freq1 = apConf->centerFreq1; + g_ap_setting_info.chandef.center_freq2 = apConf->centerFreq2; + g_ap_setting_info.chandef.width = apConf->width; + + g_ap_chan.center_freq = apConf->centerFreq1; + g_ap_chan.hw_value = apConf->channel; + g_ap_chan.band = apConf->band; + g_ap_chan.band = IEEE80211_BAND_2GHZ; + g_ap_setting_info.chandef.chan = &g_ap_chan; +#endif + ret = (int32_t)wl_cfg80211_ops.change_virtual_intf(wiphy, netdev, - (enum nl80211_iftype)netdev->ieee80211_ptr->iftype, NULL); + (enum nl80211_iftype)netdev->ieee80211_ptr->iftype, NULL); if (ret < 0) { HDF_LOGE("%s: set mode failed!", __func__); } @@ -256,14 +355,17 @@ int32_t WalSetCountryCode(NetDevice *netDev, const char *code, uint32_t len) { int32_t ret = 0; struct net_device *netdev = NULL; + netDev = get_real_netdev(netDev); netdev = GetLinuxInfByNetDevice(netDev); if (!netdev) { HDF_LOGE("%s: net_device is NULL", __func__); return -1; - } + } HDF_LOGE("%s: start...", __func__); + ret = (int32_t)wl_cfg80211_set_country_code(netdev, (char*)code, false, true, len); + if (ret < 0) { HDF_LOGE("%s: set_country_code failed!", __func__); } @@ -273,9 +375,11 @@ int32_t WalSetCountryCode(NetDevice *netDev, const char *code, uint32_t len) int32_t WalStopAp(NetDevice *netDev) { + int32_t ret = 0; struct net_device *netdev = NULL; struct wiphy *wiphy = NULL; + netDev = get_real_netdev(netDev); netdev = GetLinuxInfByNetDevice(netDev); if (!netdev) { HDF_LOGE("%s: net_device is NULL", __func__); @@ -289,21 +393,29 @@ int32_t WalStopAp(NetDevice *netDev) } HDF_LOGE("%s: start...", __func__); + ret = (int32_t)wl_cfg80211_ops.stop_ap(wiphy, netdev); + + + return ret; } int32_t WalStartAp(NetDevice *netDev) -{ +{ + int32_t ret = 0; +#if 1 struct net_device *netdev = NULL; struct wiphy *wiphy = NULL; struct wireless_dev *wdev = NULL; + netDev = get_real_netdev(netDev); if (start_ap_flag) { WalStopAp(netDev); HDF_LOGE("do not start up, because start_ap_flag=%d", start_ap_flag); + //return ret; } netdev = GetLinuxInfByNetDevice(netDev); @@ -318,23 +430,52 @@ int32_t WalStartAp(NetDevice *netDev) return -1; } wdev = netdev->ieee80211_ptr; + + HDF_LOGE("%s: start...", __func__); + //GET_DEV_CFG80211_WIRELESS(netdev)->preset_chandef.chan->center_freq = + // netdev->ieee80211_ptr->preset_chandef.center_freq1; ret = (int32_t)wl_cfg80211_ops.start_ap(wiphy, netdev, &g_ap_setting_info); + if (ret < 0) { HDF_LOGE("%s: start_ap failed!", __func__); } else { wdev->preset_chandef = g_ap_setting_info.chandef; - wdev->beacon_interval = g_ap_setting_info.beacon_interval; - wdev->chandef = g_ap_setting_info.chandef; - wdev->ssid_len = g_ap_setting_info.ssid_len; - memcpy_s(wdev->ssid, IEEE80211_MAX_SSID_LEN, g_ap_setting_info.ssid, wdev->ssid_len); + wdev->beacon_interval = g_ap_setting_info.beacon_interval; + wdev->chandef = g_ap_setting_info.chandef; + wdev->ssid_len = g_ap_setting_info.ssid_len; + memcpy(wdev->ssid, g_ap_setting_info.ssid, wdev->ssid_len); start_ap_flag = 1; } +#endif return ret; } -static void WalInitBeacon(struct WlanBeaconConf *param) +int32_t WalChangeBeacon(NetDevice *netDev, struct WlanBeaconConf *param) { + + int32_t ret = 0; + struct cfg80211_beacon_data info; + struct net_device *netdev = NULL; + struct wiphy *wiphy = NULL; + netDev = get_real_netdev(netDev); + netdev = GetLinuxInfByNetDevice(netDev); + if (!netdev) { + HDF_LOGE("%s: net_device is NULL", __func__); + return -1; + } + + wiphy = get_linux_wiphy_ndev(netdev); + if (!wiphy) { + HDF_LOGE("%s: wiphy is NULL", __func__); + return -1; + } + + HDF_LOGE("%s: start...", __func__); + + memset(&info, 0x00, sizeof(info)); + +#if 1 if (g_ap_setting_info.beacon.head != NULL) { OsalMemFree((uint8_t *)g_ap_setting_info.beacon.head); g_ap_setting_info.beacon.head = NULL; @@ -346,50 +487,23 @@ static void WalInitBeacon(struct WlanBeaconConf *param) if (param->headIEs && param->headIEsLength > 0) { g_ap_setting_info.beacon.head = OsalMemCalloc(param->headIEsLength); - memcpy_s((uint8_t *)g_ap_setting_info.beacon.head, param->headIEsLength, param->headIEs, param->headIEsLength); + memcpy((uint8_t *)g_ap_setting_info.beacon.head, param->headIEs, param->headIEsLength); g_ap_setting_info.beacon.head_len = param->headIEsLength; + + //info.head = g_ap_setting_info.beacon.head; + //info.head_len = g_ap_setting_info.beacon.head_len; } if (param->tailIEs && param->tailIEsLength > 0) { g_ap_setting_info.beacon.tail = OsalMemCalloc(param->tailIEsLength); - memcpy_s((uint8_t *)g_ap_setting_info.beacon.tail, param->tailIEsLength, param->tailIEs, param->tailIEsLength); + memcpy((uint8_t *)g_ap_setting_info.beacon.tail, param->tailIEs, param->tailIEsLength); g_ap_setting_info.beacon.tail_len = param->tailIEsLength; - } - - g_ap_setting_info.dtim_period = param->DTIMPeriod; - g_ap_setting_info.hidden_ssid = param->hiddenSSID; - g_ap_setting_info.beacon_interval = param->interval; - g_ap_setting_info.beacon.beacon_ies = NULL; - g_ap_setting_info.beacon.proberesp_ies = NULL; - g_ap_setting_info.beacon.assocresp_ies = NULL; - g_ap_setting_info.beacon.probe_resp = NULL; - - g_ap_setting_info.beacon.beacon_ies_len = 0X00; - g_ap_setting_info.beacon.proberesp_ies_len = 0X00; - g_ap_setting_info.beacon.assocresp_ies_len = 0X00; - g_ap_setting_info.beacon.probe_resp_len = 0X00; -} -int32_t WalChangeBeacon(NetDevice *netDev, struct WlanBeaconConf *param) -{ - int32_t ret = 0; - struct cfg80211_beacon_data info; - struct net_device *netdev = NULL; - struct wiphy *wiphy = NULL; - netdev = GetLinuxInfByNetDevice(netDev); - if (!netdev) { - HDF_LOGE("%s: net_device is NULL", __func__); - return -1; + //info.tail = g_ap_setting_info.beacon.tail; + //info.tail_len = g_ap_setting_info.beacon.tail_len; } +#endif - wiphy = get_linux_wiphy_ndev(netdev); - if (!wiphy) { - HDF_LOGE("%s: wiphy is NULL", __func__); - return -1; - } - memset_s(&info, sizeof(info), 0x00, sizeof(info)); - - WalInitBeacon(param); info.head = param->headIEs; info.head_len = (size_t)param->headIEsLength; info.tail = param->tailIEs; @@ -399,17 +513,51 @@ int32_t WalChangeBeacon(NetDevice *netDev, struct WlanBeaconConf *param) info.proberesp_ies = NULL; info.assocresp_ies = NULL; info.probe_resp = NULL; - + //info.lci = NULL; + //info.civicloc = NULL; + //info.ftm_responder = 0X00; info.beacon_ies_len = 0X00; info.proberesp_ies_len = 0X00; info.assocresp_ies_len = 0X00; info.probe_resp_len = 0X00; + //info.lci_len = 0X00; + //info.civicloc_len = 0X00; + + /* add beacon data for start ap*/ + g_ap_setting_info.dtim_period = param->DTIMPeriod; + g_ap_setting_info.hidden_ssid = param->hiddenSSID; + g_ap_setting_info.beacon_interval = param->interval; + HDF_LOGE("%s: dtim_period:%d---hidden_ssid:%d---beacon_interval:%d!", + __func__, g_ap_setting_info.dtim_period, g_ap_setting_info.hidden_ssid, g_ap_setting_info.beacon_interval); + + //g_ap_setting_info.beacon.head = param->headIEs; + //g_ap_setting_info.beacon.head_len = param->headIEsLength; + //g_ap_setting_info.beacon.tail = param->tailIEs; + //g_ap_setting_info.beacon.tail_len = param->tailIEsLength; + g_ap_setting_info.beacon.beacon_ies = NULL; + g_ap_setting_info.beacon.proberesp_ies = NULL; + g_ap_setting_info.beacon.assocresp_ies = NULL; + g_ap_setting_info.beacon.probe_resp = NULL; + //g_ap_setting_info.beacon.lci = NULL; + // g_ap_setting_info.beacon.civicloc = NULL; + // g_ap_setting_info.beacon.ftm_responder = 0X00; + g_ap_setting_info.beacon.beacon_ies_len = 0X00; + g_ap_setting_info.beacon.proberesp_ies_len = 0X00; + g_ap_setting_info.beacon.assocresp_ies_len = 0X00; + g_ap_setting_info.beacon.probe_resp_len = 0X00; + // g_ap_setting_info.beacon.lci_len = 0X00; + // g_ap_setting_info.beacon.civicloc_len = 0X00; + + // call nl80211_calculate_ap_params(¶ms); bdh6_nl80211_calculate_ap_params(&g_ap_setting_info); + + HDF_LOGE("%s: headIEsLen:%d---tailIEsLen:%d!", __func__, param->headIEsLength, param->tailIEsLength); ret = WalStartAp(netDev); HDF_LOGE("call start_ap ret=%d", ret); - + ret = (int32_t)wl_cfg80211_ops.change_beacon(wiphy, netdev, &info); + if (ret < 0) { HDF_LOGE("%s: change_beacon failed!", __func__); } @@ -419,10 +567,11 @@ int32_t WalChangeBeacon(NetDevice *netDev, struct WlanBeaconConf *param) int32_t WalDelStation(NetDevice *netDev, const uint8_t *macAddr) { - int32_t ret = 0; + int32_t ret = 0; struct net_device *netdev = NULL; struct wiphy *wiphy = NULL; - struct station_del_parameters del_param = {macAddr, 10, 0}; + struct station_del_parameters del_param = {macAddr, 10, 0}; + netDev = get_real_netdev(netDev); netdev = GetLinuxInfByNetDevice(netDev); if (!netdev) { HDF_LOGE("%s: net_device is NULL", __func__); @@ -435,10 +584,14 @@ int32_t WalDelStation(NetDevice *netDev, const uint8_t *macAddr) return -1; } + + + //(void)netDev; (void)macAddr; HDF_LOGE("%s: start...", __func__); - + ret = (int32_t)wl_cfg80211_ops.del_station(wiphy, netdev, &del_param); + if (ret < 0) { HDF_LOGE("%s: del_station failed!", __func__); } @@ -448,47 +601,59 @@ int32_t WalDelStation(NetDevice *netDev, const uint8_t *macAddr) int32_t WalGetAssociatedStasCount(NetDevice *netDev, uint32_t *num) { - int32_t ret = 0; + + + int32_t ret = 0; +#if 1 struct net_device *netdev = NULL; + netDev = get_real_netdev(netDev); netdev = GetLinuxInfByNetDevice(netDev); if (!netdev) { HDF_LOGE("%s: net_device is NULL", __func__); return -1; } - + HDF_LOGE("%s: start...", __func__); - + ret = (int32_t)wl_get_all_sta(netdev, num); + if (ret < 0) { HDF_LOGE("%s: wl_get_all_sta failed!", __func__); - } + } - return ret; +#endif + return ret; } -int32_t WalGetAssociatedStasInfo(NetDevice *netDev, WifiStaInfo *staInfo, uint32_t num) +int32_t WalGetAssociatedStasInfo(NetDevice *netDev, WifiStaInfo *staInfo, uint32_t num) { - int32_t ret = 0; + int32_t ret = 0; struct net_device *netdev = NULL; + netDev = get_real_netdev(netDev); netdev = GetLinuxInfByNetDevice(netDev); if (!netdev) { HDF_LOGE("%s: net_device is NULL", __func__); return -1; } + HDF_LOGE("%s: start...", __func__); + ret = (int32_t)wl_get_all_sta_info(netdev, staInfo->mac, num); + if (ret < 0) { HDF_LOGE("%s: wl_get_all_sta_info failed!", __func__); } - - return ret; + + return ret; } /*--------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------*/ -struct HdfMac80211APOps g_bdh6_apOps = { + +struct HdfMac80211APOps g_bdh6_apOps = +{ .ConfigAp = WalConfigAp, .StartAp = WalStartAp, .StopAp = WalStopAp, @@ -498,3 +663,5 @@ struct HdfMac80211APOps g_bdh6_apOps = { .GetAssociatedStasCount = WalGetAssociatedStasCount, .GetAssociatedStasInfo = WalGetAssociatedStasInfo }; + + diff --git a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_p2p.c b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_p2p.c new file mode 100755 index 0000000000000000000000000000000000000000..16bd588a669325cf8d1048696e977be14779ae99 --- /dev/null +++ b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_p2p.c @@ -0,0 +1,358 @@ +/* + * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "wifi_mac80211_ops.h" +#include "hdf_wlan_utils.h" +#include "wifi_module.h" +#include +#include +#include "osal_mem.h" +#include "hdf_wifi_event.h" +#include "hdf_log.h" +#include "osl.h" + + + +#include +#include +#include +#include +#include "net_device_adapter.h" +#include "hdf_wl_interface.h" +#include + +//#include "hdf_wifi_cmd.h" +//#include "wl_cfg80211.h" + + + +enum wl_management_type { + WL_BEACON = 0x1, + WL_PROBE_RESP = 0x2, + WL_ASSOC_RESP = 0x4 +}; + +#define HDF_LOG_TAG BDH6Driver +#define HISI_DRIVER_FLAGS_AP 0x00000040 +#define HISI_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE 0x00000400 +#define HISI_DRIVER_FLAGS_P2P_CONCURRENT 0x00000200 +#define HISI_DRIVER_FLAGS_P2P_CAPABLE 0x00000800 +#define WLAN_WPS_IE_MAX_SIZE 352 + +#if defined(WL_CFG80211_P2P_DEV_IF) +#define ndev_to_cfg(ndev) ((ndev)->ieee80211_ptr) +#else +#define ndev_to_cfg(ndev) (ndev) +#endif +#ifndef errno_t +typedef int errno_t; +#endif +extern struct net_device_ops dhd_ops_pri; +extern struct cfg80211_ops wl_cfg80211_ops; +extern struct hdf_inf_map g_hdf_infmap[HDF_INF_MAX]; +extern int g_hdf_ifidx; + +extern struct net_device * GetLinuxInfByNetDevice(const struct NetDevice *netDevice); +extern struct wiphy * get_linux_wiphy_ndev(struct net_device *ndev); +extern struct wiphy * get_linux_wiphy_hdfdev(NetDevice *netDev); +int BDH6InitNetdev(struct NetDevice *netDevice, int private_data_size, int type, int ifidx); +int get_dhd_priv_data_size(void); +struct NetDevice * get_hdf_netdev(int ifidx); + + +extern s32 wl_cfg80211_set_wps_p2p_ie(struct net_device *net, char *buf, int len, + enum wl_management_type type); + + +struct net_device * get_krn_netdev(int ifidx); +struct NetDevice * get_real_netdev(NetDevice *netDev); + +static u64 p2p_cookie = 0; +u32 p2p_remain_freq = 0; + +int32_t WalRemainOnChannel(struct NetDevice *netDev, WifiOnChannel *onChannel) +{ + struct net_device *netdev = NULL; + struct wiphy *wiphy = NULL; + bcm_struct_cfgdev *cfgdev = NULL; + struct ieee80211_channel *channel = NULL; + unsigned int duration; + + netDev = get_real_netdev(netDev); + netdev = GetLinuxInfByNetDevice(netDev); + if (!netdev) { + HDF_LOGE("%s: net_device is NULL", __func__); + return -1; + } + + wiphy = get_linux_wiphy_ndev(netdev); + if (!wiphy) { + HDF_LOGE("%s: wiphy is NULL", __func__); + return -1; + } + HDF_LOGE("%s: freq=%u, duration=%u", __func__, onChannel->freq, onChannel->duration); + + channel = OsalMemCalloc(sizeof(channel)); + cfgdev = ndev_to_cfg(netdev); + channel->center_freq = onChannel->freq; //remain_on_channel函数需要的参数 + duration = (unsigned int)onChannel->duration; + p2p_remain_freq = channel->center_freq; + + return wl_cfg80211_ops.remain_on_channel(wiphy, cfgdev, channel, duration, &p2p_cookie); + OsalMemFree(channel); +} + + + +int32_t WalCancelRemainOnChannel(struct NetDevice *netDev) + +{ + struct net_device *netdev = NULL; + bcm_struct_cfgdev *cfgdev = NULL; + struct wiphy *wiphy = NULL; + + netDev = get_real_netdev(netDev); + netdev = GetLinuxInfByNetDevice(netDev); + wiphy = get_linux_wiphy_ndev(netdev); + if (!wiphy) { + HDF_LOGE("%s: wiphy is NULL", __func__); + return -1; + } + + HDF_LOGE("%s: primary netdev %s", __func__, netDev->name); + if (!netdev) { + HDF_LOGE("%s: net_device is NULL", __func__); + return -1; + } + + cfgdev = ndev_to_cfg(netdev); + + return wl_cfg80211_ops.cancel_remain_on_channel(wiphy, cfgdev, p2p_cookie); +} + +int32_t WalProbeReqReport(struct NetDevice *netDev, int32_t report) + +{ + (void)report; + + HDF_LOGE("%s: primary netdev %s, report=%d", __func__, netDev->name, report); + + return HDF_SUCCESS; + +} +//extern int wl_cfgp2p_start_p2p_device(struct wiphy *wiphy, struct wireless_dev *wdev); +int32_t WalAddIf(struct NetDevice *netDev, WifiIfAdd *ifAdd) +{ + struct wiphy *wiphy = NULL; + struct wireless_dev *wdev = NULL; + int ret = 0; + struct net_device *p2p_netdev = NULL; + struct NetDevice *p2p_hnetdev = NULL; + + if (netDev == NULL || ifAdd == NULL) { + HDF_LOGE("%s:NULL ptr!", __func__); + return -1; + } + + HDF_LOGE("%s: primary netdev %s, type=%u", __func__, netDev->name, ifAdd->type); + netDev = get_real_netdev(netDev); + + ret = BDH6InitNetdev(netDev, get_dhd_priv_data_size(), ifAdd->type, HDF_INF_P2P1); + if (ret != 0) { + HDF_LOGE("%s:BDH6InitNetdev p2p-p2p0-0 failed", __func__); + return HDF_FAILURE; + } + + wiphy = get_linux_wiphy_hdfdev(netDev); + if (wiphy == NULL) { + HDF_LOGE("%s:get wlan0 wiphy failed", __func__); + return HDF_FAILURE; + } + + p2p_hnetdev = get_hdf_netdev(g_hdf_ifidx); + p2p_netdev = get_krn_netdev(g_hdf_ifidx); + + wdev = wl_cfg80211_ops.add_virtual_intf(wiphy, p2p_hnetdev->name, NET_NAME_USER, ifAdd->type, NULL); + if (wdev == NULL || wdev == ERR_PTR(-ENODEV)) { + HDF_LOGE("%s:create wdev for %s %d failed", __func__, p2p_hnetdev->name, ifAdd->type); + return HDF_FAILURE; + } + HDF_LOGE("%s:%s wdev->netdev=%p, %p", __func__, p2p_hnetdev->name, wdev->netdev, p2p_netdev); + p2p_hnetdev->ieee80211Ptr = p2p_netdev->ieee80211_ptr; + + // update mac addr to NetDevice object + memcpy_s(p2p_hnetdev->macAddr, MAC_ADDR_SIZE, p2p_netdev->dev_addr, p2p_netdev->addr_len); + HDF_LOGE("%s: %s mac: %02x:%02x:%02x:%02x:%02x:%02x", __func__, p2p_hnetdev->name, + p2p_hnetdev->macAddr[0], + p2p_hnetdev->macAddr[1], + p2p_hnetdev->macAddr[2], + p2p_hnetdev->macAddr[3], + p2p_hnetdev->macAddr[4], + p2p_hnetdev->macAddr[5] + ); + + //g_event_ifidx = HDF_INF_P2P1; + //hdf_bdh6_netdev_open(p2p_hnetdev); + + return HDF_SUCCESS; +} + +int32_t WalRemoveIf(struct NetDevice *netDev, WifiIfRemove *ifRemove) +{ + int i = HDF_INF_WLAN0; + struct wiphy *wiphy = NULL; + struct wireless_dev *wdev = NULL; + //struct net_device *p2p_netdev = NULL; + struct NetDevice *p2p_hnetdev = NULL; + int ret = 0; + netDev = get_real_netdev(netDev); + + wiphy = get_linux_wiphy_hdfdev(netDev); + if (wiphy == NULL) { + HDF_LOGE("%s:get wlan0 wiphy failed", __func__); + return HDF_FAILURE; + } + + HDF_LOGE("%s: primary netdev %s, ifname=%s", __func__, netDev->name, ifRemove->ifname); + for (; i < HDF_INF_MAX; i ++) { + p2p_hnetdev = g_hdf_infmap[i].hnetdev; + if (strcmp(p2p_hnetdev->name, ifRemove->ifname) == 0) { + wdev = (struct wireless_dev *)p2p_hnetdev->ieee80211Ptr; + //ret = wl_cfg80211_ops.del_virtual_intf(wiphy, wdev); + break; + } + } + + return ret; +} + +int32_t WalSetApWpsP2pIe(struct NetDevice *netDev, WifiAppIe *appIe) +{ + struct net_device *netdev = NULL; + enum wl_management_type type; + + netDev = get_real_netdev(netDev); + netdev = GetLinuxInfByNetDevice(netDev); + type = appIe->appIeType; + + HDF_LOGE("%s: primary netdev %s, type=%d", __func__, netDev->name, type); + if (!netdev) { + HDF_LOGE("%s: net_device is NULL", __func__); + return -1; + } + + if (appIe->ieLen > WLAN_WPS_IE_MAX_SIZE) { + //oam_error_log0(0, 0, "app ie length is too large!"); + return -1; + } + + return wl_cfg80211_set_wps_p2p_ie(netdev, appIe->ie, appIe->ieLen, type); +} + +void cfg80211_init_wdev(struct wireless_dev *wdev); + +int hdf_start_p2p_device(void) +{ + static int start_p2p_completed = 0; + int ret = HDF_SUCCESS; + struct wiphy *wiphy = NULL; + struct wireless_dev *wdev = NULL; + struct net_device *netdev = get_krn_netdev(HDF_INF_WLAN0); + + if (start_p2p_completed == 1) { + HDF_LOGE("%s:start p2p completed already", __func__); + return 0; + } + + // create wdev object for p2p-dev-wlan0 device, refer nl80211_new_interface() + wiphy = get_linux_wiphy_ndev(netdev); + if (wiphy == NULL) { + HDF_LOGE("%s:get wlan0 wiphy failed", __func__); + return HDF_FAILURE; + } + + wdev = wl_cfg80211_ops.add_virtual_intf(wiphy, "p2p-dev-wlan0", NET_NAME_USER, NL80211_IFTYPE_P2P_DEVICE, NULL); + if (wdev == NULL) { + HDF_LOGE("%s:create wdev for p2p-dev-wlan0 %d failed", __func__, NL80211_IFTYPE_P2P_DEVICE); + return HDF_FAILURE; + } + cfg80211_init_wdev(wdev); + HDF_LOGE("%s:p2p-dev-wlan0 wdev->netdev=%p", __func__, wdev->netdev); + + g_hdf_infmap[HDF_INF_P2P0].wdev = wdev; // free it for module released !! + + ret = wl_cfg80211_ops.start_p2p_device(wiphy, NULL); + HDF_LOGE("call start_p2p_device ret = %d", ret); + g_event_ifidx = HDF_INF_P2P0; + start_p2p_completed = 1; + + return ret; +} + +int32_t WalGetDriverFlag(struct NetDevice *netDev, WifiGetDrvFlags **params) +{ + struct wireless_dev *wdev = NULL; + WifiGetDrvFlags *getDrvFlag = NULL; + int iftype = 0; + + HDF_LOGE("%s: primary netdev %s", __func__, netDev->name); + if (netDev == NULL || params == NULL) { + HDF_LOGE("%s:NULL ptr!", __func__); + return -1; + } + wdev = (struct wireless_dev*)((netDev)->ieee80211Ptr); + getDrvFlag = (WifiGetDrvFlags *)OsalMemCalloc(sizeof(WifiGetDrvFlags)); + iftype = wdev->iftype; + + //iftype = NL80211_IFTYPE_P2P_DEVICE; + + switch (iftype) { + case NL80211_IFTYPE_P2P_CLIENT: + /* fall-through */ + case NL80211_IFTYPE_P2P_GO: + getDrvFlag->drvFlags = (unsigned int)(HISI_DRIVER_FLAGS_AP); + g_event_ifidx = HDF_INF_P2P1; + break; + case NL80211_IFTYPE_P2P_DEVICE: + getDrvFlag->drvFlags = (unsigned int)(HISI_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE | + HISI_DRIVER_FLAGS_P2P_CONCURRENT | + HISI_DRIVER_FLAGS_P2P_CAPABLE); + //getDrvFlag->drvFlags = (unsigned int)0xBA0CFEC0; + hdf_start_p2p_device(); + break; + default: + getDrvFlag->drvFlags = 0; + } + + *params = getDrvFlag; + + HDF_LOGE("%s: %s iftype=%d, drvflag=%lu", __func__, netDev->name, iftype, getDrvFlag->drvFlags); + return HDF_SUCCESS; +} + +struct HdfMac80211P2POps g_bdh6_p2pOps = { + .RemainOnChannel = WalRemainOnChannel, + .CancelRemainOnChannel = WalCancelRemainOnChannel, + .ProbeReqReport = WalProbeReqReport, + .AddIf = WalAddIf, + .RemoveIf = WalRemoveIf, + .SetApWpsP2pIe = WalSetApWpsP2pIe, + .GetDriverFlag = WalGetDriverFlag, +}; + + diff --git a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta.c b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta.c index ed703b471bfa0688ec5fd1cd608f1ccdb3f6ea84..cabb0193ab74f06fe531973efeda37d5cdcd8b22 100644 --- a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta.c +++ b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta.c @@ -1,42 +1,45 @@ -/* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * - * HDF is dual licensed: you can use it either under the terms of - * the GPL, or the BSD license, at your option. - * See the LICENSE file in the root of this repository for complete details. - */ - -#include -#include #include #include #include #include #include +#include #include - - -#include +#include #include "osal_mem.h" +#include "hdf_mac80211_sta.h" #include "net_device.h" #include "net_device_impl.h" #include "net_device_adapter.h" #include "wifi_mac80211_ops.h" #include "hdf_wifi_cmd.h" #include "hdf_wifi_event.h" - -#include "hdf_public_ap6275s.h" -#include "hdf_mac80211_sta.h" +#include #define HDF_LOG_TAG BDH6Driver +//extern int32_t wl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, +// struct cfg80211_scan_request *request); +extern int32_t wl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_connect_params *sme); +extern int32_t wl_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, + u16 reason_code); +extern int32_t wl_cfg80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev); + +extern struct cfg80211_ops wl_cfg80211_ops; + +typedef unsigned char hi_u8; #define WIFI_SCAN_EXTRA_IE_LEN_MAX (512) -#define BDH6_POINT_CHANNEL_SIZE (8) +extern struct net_device * GetLinuxInfByNetDevice(const struct NetDevice *netDevice); +struct wiphy * get_linux_wiphy_ndev(struct net_device *ndev); +struct NetDevice * get_real_netdev(NetDevice *netDev); +int hdf_start_p2p_device(void); + static struct ieee80211_channel *GetChannelByFreq(const struct wiphy *wiphy, uint16_t center_freq) { @@ -57,30 +60,6 @@ static struct ieee80211_channel *GetChannelByFreq(const struct wiphy *wiphy, uin return NULL; } -static int32_t FillScanChannel(const struct wiphy *wiphy, int32_t channelTotal, - enum Ieee80211Band band, struct cfg80211_scan_request *request) -{ - int32_t loop; - int32_t count = 0; - struct ieee80211_channel *chan = NULL; - - for (loop = 0; loop < (int32_t)wiphy->bands[band]->n_channels; loop++) { - if (count >= channelTotal) { - break; - } - - chan = &wiphy->bands[band]->channels[loop]; - if ((chan->flags & WIFI_CHAN_DISABLED) != 0) { - continue; - } - - request->channels[count++] = chan; - } - - return count; -} - - static int32_t WifiScanSetChannel(const struct wiphy *wiphy, const struct WlanScanRequest *params, struct cfg80211_scan_request *request) { @@ -92,13 +71,24 @@ static int32_t WifiScanSetChannel(const struct wiphy *wiphy, const struct WlanSc int32_t channelTotal = ieee80211_get_num_supported_channels((struct wiphy *)wiphy); if ((params->freqs == NULL) || (params->freqsCount == 0)) { - for (band = IEEE80211_BAND_2GHZ; band <= IEEE80211_BAND_5GHZ; band++) { + for(band = IEEE80211_BAND_2GHZ; band <= IEEE80211_BAND_5GHZ; band++) { if (wiphy->bands[band] == NULL) { HDF_LOGE("%s: wiphy->bands[band] = NULL!\n", __func__); continue; } - count = FillScanChannel(wiphy, channelTotal, band, request); + for (loop = 0; loop < (int32_t)wiphy->bands[band]->n_channels; loop++) { + if(count >= channelTotal) { + break; + } + + chan = &wiphy->bands[band]->channels[loop]; + if ((chan->flags & WIFI_CHAN_DISABLED) != 0) { + continue; + } + + request->channels[count++] = chan; + } } } else { for (loop = 0; loop < params->freqsCount; loop++) { @@ -108,10 +98,9 @@ static int32_t WifiScanSetChannel(const struct wiphy *wiphy, const struct WlanSc continue; } - if (count >= channelTotal) { + if(count >= channelTotal) { break; } - request->channels[count++] = chan; } } @@ -177,13 +166,21 @@ static int32_t WifiScanSetUserIe(const struct WlanScanRequest *params, struct cf request->ie = (uint8_t *)OsalMemCalloc(params->extraIEsLen); if (request->ie == NULL) { HDF_LOGE("%s: calloc request->ie null", __func__); - return HDF_FAILURE; + goto fail; } (void)memcpy_s((void *)request->ie, params->extraIEsLen, params->extraIEs, params->extraIEsLen); request->ie_len = params->extraIEsLen; } return HDF_SUCCESS; + +fail: + if (request->ie != NULL) { + OsalMemFree((void *)request->ie); //add void * + request->ie = NULL; + } + + return HDF_FAILURE; } static int32_t WifiScanSetRequest(struct NetDevice *netdev, const struct WlanScanRequest *params, @@ -193,8 +190,10 @@ static int32_t WifiScanSetRequest(struct NetDevice *netdev, const struct WlanSca return HDF_FAILURE; } request->wiphy = GET_NET_DEV_CFG80211_WIRELESS(netdev)->wiphy; + // request->dev = netdev; // for sched scan request->wdev = GET_NET_DEV_CFG80211_WIRELESS(netdev); request->n_ssids = params->ssidCount; + // request->prefix_ssid_scan_flag = 0; // for sched scan if (WifiScanSetChannel(GET_NET_DEV_CFG80211_WIRELESS(netdev)->wiphy, params, request)) { HDF_LOGE("%s: set channel failed!", __func__); return HDF_FAILURE; @@ -231,20 +230,24 @@ static void WifiScanFree(struct cfg80211_scan_request **request) int32_t HdfStartScan(NetDevice *netDev, struct WlanScanRequest *scanParam) { int32_t ret = 0; + struct net_device *ndev = NULL; + struct wiphy *wiphy = NULL; + static int32_t is_p2p_complete = 0; + NetDevice * hnetdev = netDev; + int32_t channelTotal; - struct net_device *ndev = GetLinuxInfByNetDevice(netDev); - struct wiphy *wiphy = get_linux_wiphy_ndev(ndev); - - int32_t channelTotal = ieee80211_get_num_supported_channels(wiphy); + netDev = get_real_netdev(netDev); + ndev = GetLinuxInfByNetDevice(netDev); + wiphy = get_linux_wiphy_ndev(ndev); + channelTotal = ieee80211_get_num_supported_channels(wiphy); struct cfg80211_scan_request *request = - (struct cfg80211_scan_request *)OsalMemCalloc(sizeof(struct cfg80211_scan_request) + - BDH6_POINT_CHANNEL_SIZE * channelTotal); + (struct cfg80211_scan_request *)OsalMemCalloc(sizeof(struct cfg80211_scan_request) + sizeof(struct ieeee80211_channel *)*channelTotal); - HDF_LOGE("%s: enter hdfStartScan, channelTotal: %d", __func__, channelTotal); + HDF_LOGE("%s: enter hdfStartScan %s, channelTotal: %d", __func__, ndev->name, channelTotal); if (request == NULL) { - HDF_LOGE("%s: calloc request null!\n", __func__); + HDF_LOGE("%s: calloc request null!\n", __func__); return HDF_FAILURE; } if (WifiScanSetRequest(netDev, scanParam, request) != HDF_SUCCESS) { @@ -252,15 +255,27 @@ int32_t HdfStartScan(NetDevice *netDev, struct WlanScanRequest *scanParam) return HDF_FAILURE; } - HDF_LOGE("%s: enter cfg80211_scan !", __func__); + if (is_p2p_complete == 0 && 0 == strcmp(hnetdev->name, "p2p0")) { + //request->n_ssids = 0; // begin scan for station mode + //hdf_start_p2p_device(); + //msleep(500); + } + + HDF_LOGE("%s: enter cfg80211_scan, n_ssids=%d !", __func__, request->n_ssids); ret = wl_cfg80211_ops.scan(wiphy, request); - - HDF_LOGE("%s: left cfg80211_scan !", __func__); + HDF_LOGE("%s: left cfg80211_scan %d!", __func__, ret); if (ret != HDF_SUCCESS) { WifiScanFree(&request); } + if (is_p2p_complete == 0 && 0 == strcmp(hnetdev->name, "p2p0")) { + //hdf_start_p2p_device(); + //is_p2p_complete = 1; + //ret = -19; + //msleep(5000); + } + return ret; } @@ -269,6 +284,7 @@ int32_t HdfAbortScan(NetDevice *netDev) struct net_device *ndev = NULL; struct wireless_dev *wdev = NULL; struct wiphy *wiphy = NULL; + netDev = get_real_netdev(netDev); if (netDev == NULL) { HDF_LOGE("%s:NULL ptr!", __func__); @@ -281,14 +297,14 @@ int32_t HdfAbortScan(NetDevice *netDev) wiphy = get_linux_wiphy_ndev(ndev); - if (ndev == NULL) { + if(ndev == NULL) { HDF_LOGE("%s:NULL ptr!", __func__); return HDF_FAILURE; } - wdev = ndev->ieee80211_ptr; + wdev = ndev->ieee80211_ptr; - if (!wdev || !wdev->wiphy) { + if (!wdev || !wdev->wiphy) { return HDF_FAILURE; } @@ -325,59 +341,22 @@ static struct ieee80211_channel *WalGetChannel(struct wiphy *wiphy, int32_t freq return NULL; } -static void HdfFillConnParam(struct cfg80211_connect_params *cfg_param, WlanConnectParams *param) -{ - cfg_param->bssid = param->bssid; - cfg_param->ssid = param->ssid; - cfg_param->ie = param->ie; - cfg_param->ssid_len = param->ssidLen; - cfg_param->ie_len = param->ieLen; - - cfg_param->crypto.wpa_versions = param->crypto.wpaVersions; - cfg_param->crypto.cipher_group = param->crypto.cipherGroup; - cfg_param->crypto.n_ciphers_pairwise = param->crypto.n_ciphersPairwise; - - memcpy_s(cfg_param->crypto.ciphers_pairwise, - NL80211_MAX_NR_CIPHER_SUITES*sizeof(cfg80211_params.crypto.ciphers_pairwise[0]), - param->crypto.ciphersPairwise, NL80211_MAX_NR_CIPHER_SUITES*sizeof(param->crypto.ciphersPairwise[0])); - - memcpy_s(cfg_param->crypto.akm_suites, - NL80211_MAX_NR_AKM_SUITES*sizeof(cfg80211_params.crypto.akm_suites[0]), - param->crypto.akmSuites, NL80211_MAX_NR_AKM_SUITES*sizeof(param->crypto.akmSuites[0])); - - cfg_param->crypto.n_akm_suites = param->crypto.n_akmSuites; - - if (param->crypto.controlPort) { - cfg_param->crypto.control_port = true; - } else { - cfg_param->crypto.control_port = false; - } - - cfg_param->crypto.control_port_ethertype = param->crypto.controlPortEthertype; - cfg_param->crypto.control_port_no_encrypt = param->crypto.controlPortNoEncrypt; - - cfg_param->key = param->key; - cfg_param->auth_type = (unsigned char)param->authType; - cfg_param->privacy = param->privacy; - cfg_param->key_len = param->keyLen; - cfg_param->key_idx = param->keyIdx; - cfg_param->mfp = (unsigned char)param->mfp; -} - int32_t HdfConnect(NetDevice *netDev, WlanConnectParams *param) { int32_t ret = 0; struct net_device *ndev = NULL; struct wiphy *wiphy = NULL; struct cfg80211_connect_params cfg80211_params = { 0 }; + netDev = get_real_netdev(netDev); if (netDev == NULL || param == NULL) { HDF_LOGE("%s:NULL ptr!", __func__); return HDF_FAILURE; } - + ndev = GetLinuxInfByNetDevice(netDev); - if (ndev == NULL) { + + if(ndev == NULL) { HDF_LOGE("%s:NULL ptr!", __func__); return HDF_FAILURE; } @@ -397,7 +376,46 @@ int32_t HdfConnect(NetDevice *netDev, WlanConnectParams *param) } } - HdfFillConnParam(&cfg80211_params, param); + cfg80211_params.bssid = param->bssid; + cfg80211_params.ssid = param->ssid; + cfg80211_params.ie = param->ie; + cfg80211_params.ssid_len = param->ssidLen; + cfg80211_params.ie_len = param->ieLen; + + cfg80211_params.crypto.wpa_versions = param->crypto.wpaVersions; + cfg80211_params.crypto.cipher_group = param->crypto.cipherGroup; + cfg80211_params.crypto.n_ciphers_pairwise = param->crypto.n_ciphersPairwise; + + memcpy_s(cfg80211_params.crypto.ciphers_pairwise, NL80211_MAX_NR_CIPHER_SUITES*sizeof(cfg80211_params.crypto.ciphers_pairwise[0]), \ + param->crypto.ciphersPairwise, NL80211_MAX_NR_CIPHER_SUITES*sizeof(param->crypto.ciphersPairwise[0])); + + memcpy_s(cfg80211_params.crypto.akm_suites, NL80211_MAX_NR_AKM_SUITES*sizeof(cfg80211_params.crypto.akm_suites[0]), \ + param->crypto.akmSuites, NL80211_MAX_NR_AKM_SUITES*sizeof(param->crypto.akmSuites[0])); + + cfg80211_params.crypto.n_akm_suites = param->crypto.n_akmSuites; + + if(param->crypto.controlPort) { + cfg80211_params.crypto.control_port = true; + } else { + cfg80211_params.crypto.control_port = false; + } + + cfg80211_params.crypto.control_port_ethertype = param->crypto.controlPortEthertype; + cfg80211_params.crypto.control_port_no_encrypt = param->crypto.controlPortNoEncrypt; + + cfg80211_params.key = param->key; + cfg80211_params.auth_type = (hi_u8)param->authType; + cfg80211_params.privacy = param->privacy; + cfg80211_params.key_len = param->keyLen; + cfg80211_params.key_idx = param->keyIdx; + cfg80211_params.mfp = (hi_u8)param->mfp; + + HDF_LOGE("%s: %s connect ssid: %s", __func__, netDev->name, cfg80211_params.ssid); + HDF_LOGE("%s: cfg80211_params auth_type:%d--channelId:%d--centerFreq:%d--Mac:%02x:%02x:%02x:%02x:%02x:%02x", + __func__, cfg80211_params.auth_type, cfg80211_params.channel->band, param->centerFreq, + cfg80211_params.bssid[0], cfg80211_params.bssid[1], cfg80211_params.bssid[2], + cfg80211_params.bssid[3], cfg80211_params.bssid[4], cfg80211_params.bssid[5]); + ret = wl_cfg80211_ops.connect(wiphy, ndev, &cfg80211_params); if (ret < 0) { HDF_LOGE("%s: connect failed!\n", __func__); @@ -411,36 +429,44 @@ int32_t HdfDisconnect(NetDevice *netDev, uint16_t reasonCode) int32_t ret = 0; struct net_device *ndev = NULL; struct wiphy *wiphy = NULL; - + netDev = get_real_netdev(netDev); + HDF_LOGE("%s: start...", __func__); - + if (netDev == NULL) { HDF_LOGE("%s:NULL ptr!", __func__); return HDF_FAILURE; } + ndev = GetLinuxInfByNetDevice(netDev); - if (ndev == NULL) { + + if(ndev == NULL) { HDF_LOGE("%s:NULL ptr!", __func__); return HDF_FAILURE; } + wiphy = get_linux_wiphy_ndev(ndev); if (!wiphy) { HDF_LOGE("%s: wiphy is NULL", __func__); return -1; } + +// return wl_cfg80211_disconnect(wiphy, ndev, reasonCode); ret = wl_cfg80211_ops.disconnect(wiphy, ndev, reasonCode); + return ret; } int32_t HdfSetScanningMacAddress(NetDevice *netDev, unsigned char *mac, uint32_t len) { - (void)netDev; + netDev = get_real_netdev(netDev); (void)mac; (void)len; return HDF_ERR_NOT_SUPPORT; } -struct HdfMac80211STAOps g_bdh6_staOps = { +struct HdfMac80211STAOps g_bdh6_staOps = +{ .Connect = HdfConnect, .Disconnect = HdfDisconnect, .StartScan = HdfStartScan, diff --git a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta.h b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta.h index 8660f748468bacc0f1636dbcb3e6a9690ae4ec72..86dfcc19a187837b5e807d710e5a732ae2d3b939 100644 --- a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta.h +++ b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta.h @@ -1,11 +1,3 @@ -/* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * - * HDF is dual licensed: you can use it either under the terms of - * the GPL, or the BSD license, at your option. - * See the LICENSE file in the root of this repository for complete details. - */ - #ifndef WAL_MAC80211_STA_H_ #define WAL_MAC80211_STA_H_ @@ -16,4 +8,7 @@ int32_t HdfAbortScan(NetDevice *netDev); int32_t HdfConnect(NetDevice *netDev, WlanConnectParams *param); int32_t HdfDisconnect(NetDevice *netDev, uint16_t reasonCode); int32_t HdfSetScanningMacAddress(NetDevice *netDev, unsigned char *mac, uint32_t len); + #endif + + diff --git a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta_event.c b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta_event.c index b01e2cfdeb039ba32eb10718bd3d23c3eff843ee..9ab005909ca6a3945a41e30e9db9f3ece6ca7a5f 100644 --- a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta_event.c +++ b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta_event.c @@ -1,46 +1,34 @@ -/* - * hdf_mac80211_sta_event.c - * - * sta event driver - * - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -#include -#include - -#include #include #include #include #include #include +#include #include +#include #include "osal_mem.h" + +#include "hdf_mac80211_sta_event.h" #include "net_device.h" #include "net_device_impl.h" #include "net_device_adapter.h" #include "wifi_mac80211_ops.h" #include "hdf_wifi_cmd.h" #include "hdf_wifi_event.h" -#include "hdf_public_ap6275s.h" -#include "hdf_mac80211_sta_event.h" +#include "hdf_wl_interface.h" +#include #define HDF_LOG_TAG BDH6Driver +typedef unsigned char hi_u8; + #define WIFI_SCAN_EXTRA_IE_LEN_MAX (512) +extern struct NetDevice * GetHdfNetDeviceByLinuxInf(struct net_device *dev); +struct NetDevice * get_hdf_netdev(int ifidx); + int32_t HdfScanEventCallback(struct net_device *ndev, HdfWifiScanStatus _status) { int32_t ret = 0; @@ -48,20 +36,32 @@ int32_t HdfScanEventCallback(struct net_device *ndev, HdfWifiScanStatus _status) NetDevice *netDev = GetHdfNetDeviceByLinuxInf(ndev); WifiScanStatus status = _status; - HDF_LOGE("%s: %d, scandone!", __func__, _status); +#if 1 + // for check p2p0 report + netDev = get_hdf_netdev(g_event_ifidx); +#endif + HDF_LOGE("%s: %d, scandone!", __func__, _status); + ret = HdfWifiEventScanDone(netDev, status); return ret; } #define HDF_ETHER_ADDR_LEN (6) -int32_t HdfConnectResultEventCallback(struct net_device *ndev, struct ConnetResult *conn) +int32_t HdfConnectResultEventCallback(struct net_device *ndev, uint8_t *bssid, uint8_t *reqIe, + uint8_t *rspIe, uint32_t reqIeLen, + uint32_t rspIeLen, uint16_t connectStatus, uint16_t freq) { int32_t retVal = 0; NetDevice *netDev = GetHdfNetDeviceByLinuxInf(ndev); struct ConnetResult connResult; +#if 1 + // for check p2p0 report + netDev = get_hdf_netdev(g_event_ifidx); +#endif + HDF_LOGE("%s: enter", __func__); if (netDev == NULL || bssid == NULL || rspIe == NULL || reqIe == NULL) { @@ -69,18 +69,21 @@ int32_t HdfConnectResultEventCallback(struct net_device *ndev, struct ConnetResu return -1; } - memcpy_s(&connResult.bssid[0], HDF_ETHER_ADDR_LEN, conn->bssid, HDF_ETHER_ADDR_LEN); + memcpy(&connResult.bssid[0], bssid, HDF_ETHER_ADDR_LEN); + HDF_LOGE("%s: connResult:%02x:%02x:%02x:%02x:%02x:%02x, freq:%d\n", __func__, + connResult.bssid[0], connResult.bssid[1], connResult.bssid[2], + connResult.bssid[3], connResult.bssid[4], connResult.bssid[5], freq); - connResult.rspIe = conn->rspIe; - connResult.rspIeLen = conn->rspIeLen; + connResult.rspIe = rspIe; + connResult.rspIeLen = rspIeLen; - connResult.reqIe = conn->reqIe; - connResult.reqIeLen = conn->reqIeLen; + connResult.reqIe = reqIe; + connResult.reqIeLen = reqIeLen; - connResult.connectStatus = conn->connectStatus; + connResult.connectStatus = connectStatus; - connResult.freq = conn->freq; - connResult.statusCode = conn->connectStatus; + connResult.freq = freq; + connResult.statusCode = connectStatus; retVal = HdfWifiEventConnectResult(netDev, &connResult); if (retVal < 0) { @@ -95,6 +98,10 @@ int32_t HdfDisconnectedEventCallback(struct net_device *ndev, uint16_t reason, u int32_t ret = 0; NetDevice *netDev = GetHdfNetDeviceByLinuxInf(ndev); +#if 1 + // for check p2p0 report + netDev = get_hdf_netdev(g_event_ifidx); +#endif HDF_LOGE("%s: leave", __func__); @@ -103,29 +110,50 @@ int32_t HdfDisconnectedEventCallback(struct net_device *ndev, uint16_t reason, u return ret; } -void HdfInformBssFrameEventCallback(struct net_device *ndev, struct ieee80211_channel *channel, - struct ScannedBssInfo *bss) + +void HdfInformBssFrameEventCallback(struct net_device *ndev, struct ieee80211_channel *channel, int32_t signal, + int16_t freq, struct ieee80211_mgmt *mgmt, uint32_t mgmtLen) { int32_t retVal = 0; NetDevice *netDev = GetHdfNetDeviceByLinuxInf(ndev); struct ScannedBssInfo bssInfo; struct WlanChannel hdfchannel; - if (channel == NULL || netDev == NULL || bss->mgmt == NULL) { + if (channel == NULL || netDev == NULL || mgmt == NULL) { HDF_LOGE("%s: inform_bss_frame channel = null or netDev = null!", __func__); return; } - bssInfo.signal = bss->signal; - bssInfo.freq = bss->freq; - bssInfo.mgmtLen = bss->mgmtLen; - bssInfo.mgmt = (struct Ieee80211Mgmt *)bss->mgmt; +#if 1 + // for test p2p0 report + netDev = get_hdf_netdev(g_event_ifidx); +#endif + + bssInfo.signal = signal; + bssInfo.freq = freq; + bssInfo.mgmtLen = mgmtLen; + bssInfo.mgmt = (struct Ieee80211Mgmt *)mgmt; hdfchannel.flags = channel->flags; hdfchannel.channelId = channel->hw_value; hdfchannel.centerFreq = channel->center_freq; + + /* + HDF_LOGE("%s: hdfchannel flags:%d--channelId:%d--centerFreq:%d--dstMac:%02x:%02x:%02x:%02x:%02x:%02x,!", + __func__, hdfchannel.flags, hdfchannel.channelId, hdfchannel.centerFreq, + bssInfo.mgmt->bssid[0], bssInfo.mgmt->bssid[1], bssInfo.mgmt->bssid[2], + bssInfo.mgmt->bssid[3], bssInfo.mgmt->bssid[4], bssInfo.mgmt->bssid[5]); + */ + retVal = HdfWifiEventInformBssFrame(netDev, &hdfchannel, &bssInfo); + if (retVal < 0) { HDF_LOGE("%s: hdf wifi event inform bss frame failed!", __func__); + } else { + HDF_LOGE("%s: hdf wifi event inform bss frame ret = %d", __func__, retVal); } -} \ No newline at end of file +} + + + + diff --git a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta_event.h b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta_event.h index ab9badf4d905065e1fe7ee7d4db1b62961654521..f87ac6894835b172bacc4ba982cba6b38b57835c 100644 --- a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta_event.h +++ b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_mac80211_sta_event.h @@ -1,24 +1,13 @@ -/* - * hdf_mac80211_sta_event.h - * - * sta event driver - * - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - #ifndef WAL_MAC80211_STA_EVENT_H_ #define WAL_MAC80211_STA_EVENT_H_ +//#include "wifi_mac80211_ops.h" +//#include "hdf_wifi_cmd.h" +//#include "hdf_wifi_event.h" + +//typedef WifiScanStatus HdfWifiScanStatus + +//#define ETH_ADDR_LEN (6) #define HDF_ETHER_ADDR_LEN (6) #include @@ -41,10 +30,17 @@ typedef enum { HDF_WIFI_SCAN_TIMEOUT } HdfWifiScanStatus; -int32_t HdfScanEventCallback(struct net_device *ndev, HdfWifiScanStatus _status); -int32_t HdfConnectResultEventCallback(struct net_device *ndev, struct ConnetResult *conn); -void HdfInformBssFrameEventCallback(struct net_device *ndev, struct ieee80211_channel *channel, - struct ScannedBssInfo *bss); -int32_t HdfDisconnectedEventCallback(struct net_device *ndev, uint16_t reason, uint8_t *ie, uint32_t len); +extern int32_t HdfScanEventCallback(struct net_device *ndev, HdfWifiScanStatus status); + +extern int32_t HdfConnectResultEventCallback(struct net_device *ndev, uint8_t *bssid, uint8_t *reqIe, + uint8_t *rspIe, uint32_t reqIeLen, + uint32_t rspIeLen, uint16_t connectStatus, uint16_t freq); + +extern void HdfInformBssFrameEventCallback(struct net_device *ndev, struct ieee80211_channel *channel, int32_t signal, + int16_t freq, struct ieee80211_mgmt *mgmt, uint32_t mgmtLen); + +extern int32_t HdfDisconnectedEventCallback(struct net_device *ndev, uint16_t reason, uint8_t *ie, uint32_t len); #endif + + diff --git a/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_wl_interface.h b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_wl_interface.h new file mode 100755 index 0000000000000000000000000000000000000000..484d817c1afb2c71d7f12126922a7a85dee65ae1 --- /dev/null +++ b/rk3568/wifi/bcmdhd_wifi6/hdf/hdf_wl_interface.h @@ -0,0 +1,23 @@ +#ifndef HDF_WL_INTERFACE_H +#define HDF_WL_INTERFACE_H +#include "net_device.h" +#include +#include + +enum hdf_inf_type { + HDF_INF_WLAN0 =0, // master interface + HDF_INF_P2P0, + HDF_INF_P2P1, + HDF_INF_AP0, + HDF_INF_MAX +}; + +struct hdf_inf_map { + struct NetDevice *hnetdev; + struct net_device *netdev; + struct wireless_dev *wdev; + u8 macaddr[ETH_ALEN]; +}; + +extern int g_event_ifidx; +#endif diff --git a/rk3568/wifi/bcmdhd_wifi6/hdf/hdfinit_bdh.c b/rk3568/wifi/bcmdhd_wifi6/hdf/hdfinit_bdh.c index 59513ac2a96cbb5ee4fdc614db562e67c9fc74b2..0a70e9c623e9f737041a10235e25c1b74fe82935 100644 --- a/rk3568/wifi/bcmdhd_wifi6/hdf/hdfinit_bdh.c +++ b/rk3568/wifi/bcmdhd_wifi6/hdf/hdfinit_bdh.c @@ -1,28 +1,54 @@ /* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. * - * HDF is dual licensed: you can use it either under the terms of - * the GPL, or the BSD license, at your option. - * See the LICENSE file in the root of this repository for complete details. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - +#include #include "hdf_wifi_product.h" #include "wifi_mac80211_ops.h" #include "hdf_wlan_utils.h" +#include "hdf_wl_interface.h" #include "net_bdh_adpater.h" +#include +#include +#include #define HDF_LOG_TAG BDH6Driver int dhd_module_init(void); +void * GetLinuxInfByNetDevice(const struct NetDevice *netDevice); int get_dhd_priv_data_size(void); +int BDH6InitNetdev(struct NetDevice *netDevice, int private_data_size, int type, int ifidx); +struct wiphy * get_linux_wiphy_ndev(struct net_device *ndev); +struct NetDevice * get_hdf_netdev(int ifidx); +struct net_device * get_krn_netdev(int ifidx); +extern void rtnl_lock(void); +extern void rtnl_unlock(void); +int hdf_cfgp2p_register_ndev(struct net_device *p2p_netdev, struct net_device *primary_netdev, struct wiphy *wiphy); +struct NetDeviceInterFace *wal_get_net_p2p_ops(void); -struct NetDevice *g_hdf_netdev = NULL; +s32 wl_get_vif_macaddr(struct bcm_cfg80211 *cfg, u16 wl_iftype, u8 *mac_addr); + +extern struct cfg80211_ops wl_cfg80211_ops; + + +struct hdf_inf_map g_hdf_infmap[HDF_INF_MAX]; +int g_hdf_ifidx = HDF_INF_WLAN0; +int g_event_ifidx = HDF_INF_WLAN0; -void* get_dhd_priv_data(void) -{ - return g_hdf_netdev->mlPriv; -} // BDH Wifi6 chip driver init int32_t InitBDH6Chip(struct HdfWlanDevice *device) @@ -36,6 +62,7 @@ int32_t DeinitBDH6Chip(struct HdfWlanDevice *device) { int32_t ret = HDF_SUCCESS; (void)device; + //ret = bdh6_wifi_deinit(); if (ret != 0) { HDF_LOGE("%s:Deinit failed!ret=%d", __func__, ret); } @@ -44,27 +71,45 @@ int32_t DeinitBDH6Chip(struct HdfWlanDevice *device) int32_t BDH6Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) { + //uint16_t mode; int32_t ret = 0; struct HdfWifiNetDeviceData *data = NULL; - void *netdev = NULL; + struct net_device *netdev = NULL; int private_data_size = 0; + struct wiphy *wiphy = NULL; + struct wireless_dev *wdev = NULL; + struct net_device *p2p_netdev = NULL; + struct NetDevice *p2p_hnetdev = NULL; + struct bcm_cfg80211 *cfg = NULL; + + // check byte order + //if (htons(0x2345) == 0x2345) + if (cpu_to_le16(0x2345) == 0x2345) + HDF_LOGW("little endian"); + else + HDF_LOGW("big endian"); + + //nl80211_iftype_uint8 type; (void)chipDriver; + //HDF_LOGW("%s: start...", __func__); HDF_LOGW("bdh6: call BDH6Init"); + memset_s(g_hdf_infmap, sizeof(g_hdf_infmap), 0, sizeof(g_hdf_infmap)); + g_hdf_ifidx = HDF_INF_WLAN0; // master interface + if (netDevice == NULL) { HDF_LOGE("%s netdevice is null!", __func__); return HDF_FAILURE; } + // netdev = GetLinuxInfByNetDevice(netDevice); - if (netdev == NULL) { + if (NULL == netdev) { HDF_LOGE("%s net_device is null!", __func__); return HDF_FAILURE; } - set_krn_netdev(netdev); - data = GetPlatformData(netDevice); if (data == NULL) { HDF_LOGE("%s:netdevice data null!", __func__); @@ -78,15 +123,128 @@ int32_t BDH6Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) // create bdh6 private object private_data_size = get_dhd_priv_data_size(); netDevice->mlPriv = kzalloc(private_data_size, GFP_KERNEL); - if (netDevice->mlPriv == NULL) { + if (NULL == netDevice->mlPriv) { HDF_LOGE("%s:kzalloc mlPriv failed", __func__); return HDF_FAILURE; } - g_hdf_netdev = netDevice; + + set_krn_netdev(netDevice, netdev, g_hdf_ifidx); dhd_module_init(); + // Call linux register_netdev() + //ret = NetDeviceAdd(netDevice); + //HDF_LOGE("%s:NetDeviceAdd ret=%d", __func__, ret); + ret = hdf_bdh6_netdev_open(netDevice); + if (ret != 0) { + HDF_LOGE("%s:open netdev %s failed", __func__, netDevice->name); + return HDF_FAILURE; + } + + // create p2p0 static interface + ret = BDH6InitNetdev(netDevice, sizeof(void *), NL80211_IFTYPE_P2P_DEVICE, HDF_INF_P2P0); + if (ret != 0) { + HDF_LOGE("%s:BDH6InitNetdev p2p0 failed", __func__); + return HDF_FAILURE; + } + + wdev = kzalloc(sizeof(*wdev), GFP_KERNEL); + if (wdev == NULL) { + HDF_LOGE("%s:get wlan0 wdev failed", __func__); + return HDF_FAILURE; + } + wiphy = get_linux_wiphy_ndev(netdev); + if (wiphy == NULL) { + HDF_LOGE("%s:get wlan0 wiphy failed", __func__); + return HDF_FAILURE; + } + + p2p_hnetdev = get_hdf_netdev(g_hdf_ifidx); + p2p_netdev = get_krn_netdev(g_hdf_ifidx); + wdev->wiphy = wiphy; + wdev->iftype = NL80211_IFTYPE_P2P_DEVICE; + p2p_netdev->ieee80211_ptr = wdev; + wdev->netdev = p2p_netdev; + p2p_hnetdev->ieee80211Ptr = p2p_netdev->ieee80211_ptr; + + // update mac from wdev address + cfg = wiphy_priv(wiphy); + // WL_IF_TYPE_P2P_DISC = 7 + wl_get_vif_macaddr(cfg, 7, p2p_hnetdev->macAddr); + memcpy_s(p2p_netdev->dev_addr, p2p_netdev->addr_len, p2p_hnetdev->macAddr, MAC_ADDR_SIZE); + + // reset netdev_ops + p2p_hnetdev->netDeviceIf = wal_get_net_p2p_ops(); + hdf_cfgp2p_register_ndev(p2p_netdev, netdev, wiphy); + + // Call linux register_netdev() + ret = NetDeviceAdd(p2p_hnetdev); + HDF_LOGE("NetDeviceAdd %s ret = %d", p2p_hnetdev->name, ret); + ////////////////////////////////////////////////////////////// + +#if 0 + // can't call rtnl_lock(); because NetDeviceAdd() -->register_netdev() -->rtnl_lock() + // create p2p0 interface + ret = BDH6InitNetdev(netDevice, get_dhd_priv_data_size(), NL80211_IFTYPE_P2P_DEVICE, HDF_INF_P2P0); + if (ret != 0) { + HDF_LOGE("%s:BDH6InitNetdev p2p0 failed", __func__); + return HDF_FAILURE; + } + + // create wdev object for p2p0 interface, refer nl80211_new_interface() + wiphy = get_linux_wiphy_ndev(netdev); + if (wiphy == NULL) { + HDF_LOGE("%s:get wlan0 wiphy failed", __func__); + return HDF_FAILURE; + } + + wdev = wl_cfg80211_ops.add_virtual_intf(wiphy, "p2p-dev-wlan0", NET_NAME_USER, NL80211_IFTYPE_P2P_DEVICE, NULL); + if (wdev == NULL) { + HDF_LOGE("%s:create wdev for p2p-dev-wlan0 %d failed", __func__, NL80211_IFTYPE_P2P_DEVICE); + return HDF_FAILURE; + } + HDF_LOGE("%s:p2p-dev-wlan0 wdev->netdev=%p", __func__, wdev->netdev); + + p2p_hnetdev = get_hdf_netdev(g_hdf_ifidx); + p2p_netdev = get_krn_netdev(g_hdf_ifidx); + //p2p_netdev->ieee80211_ptr = wdev; + //wdev->netdev = p2p_netdev; + //p2p_hnetdev->ieee80211Ptr = p2p_netdev->ieee80211_ptr; + //SET_NETDEV_DEV(p2p_netdev, wiphy_dev(wdev->wiphy)); + g_hdf_infmap[g_hdf_ifidx].wdev = wdev; // free it for module released !! + + ret = wl_cfg80211_ops.start_p2p_device(wiphy, NULL); + HDF_LOGE("call start_p2p_device ret = %d", ret); + + wdev = wl_cfg80211_ops.add_virtual_intf(wiphy, p2p_hnetdev->name, NET_NAME_USER, NL80211_IFTYPE_P2P_CLIENT, NULL); + if (wdev == NULL) { + HDF_LOGE("%s:create wdev for p2p0 %d failed", __func__, NL80211_IFTYPE_P2P_CLIENT); + return HDF_FAILURE; + } + HDF_LOGE("%s:%s wdev->netdev=%p, %p", __func__, p2p_hnetdev->name, wdev->netdev, p2p_netdev); + + p2p_hnetdev->ieee80211Ptr = p2p_netdev->ieee80211_ptr; + // update mac addr to NetDevice object + memcpy_s(p2p_hnetdev->macAddr, MAC_ADDR_SIZE, p2p_netdev->dev_addr, p2p_netdev->addr_len); + HDF_LOGE("%s: p2p0 mac: %02x:%02x:%02x:%02x:%02x:%02x", __func__, + p2p_hnetdev->macAddr[0], + p2p_hnetdev->macAddr[1], + p2p_hnetdev->macAddr[2], + p2p_hnetdev->macAddr[3], + p2p_hnetdev->macAddr[4], + p2p_hnetdev->macAddr[5] + ); + + //cfg80211_init_wdev(wdev); + // you can use rdev = wiphy_to_rdev(wdev->wiphy); + //struct cfg80211_registered_device *rdev = container_of(wdev->wiphy, struct cfg80211_registered_device, wiphy); + //cfg80211_register_wdev(rdev, wdev); + + //rtnl_unlock(); + + hdf_bdh6_netdev_open(p2p_hnetdev); +#endif return HDF_SUCCESS; } @@ -97,3 +255,12 @@ int32_t BDH6Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice hdf_bdh6_netdev_stop(netDevice); return HDF_SUCCESS; } + +struct NetDevice * get_real_netdev(NetDevice *netDev) +{ + if (0 == strcmp(netDev->name, "p2p0")) { + return get_hdf_netdev(HDF_INF_WLAN0); + } else { + return netDev; + } +} diff --git a/rk3568/wifi/bcmdhd_wifi6/hdf/net_bdh_adpater.c b/rk3568/wifi/bcmdhd_wifi6/hdf/net_bdh_adpater.c index 4fe1f10b9107b8b4fd86e7178839ec3783571601..1532b4db6cd91879e18a78f9027d56940bf492d6 100644 --- a/rk3568/wifi/bcmdhd_wifi6/hdf/net_bdh_adpater.c +++ b/rk3568/wifi/bcmdhd_wifi6/hdf/net_bdh_adpater.c @@ -1,48 +1,237 @@ -/* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * - * HDF is dual licensed: you can use it either under the terms of - * the GPL, or the BSD license, at your option. - * See the LICENSE file in the root of this repository for complete details. - */ #include "net_bdh_adpater.h" #include - #include - #include "eapol.h" +#include "hdf_wlan_utils.h" +#include "hdf_wl_interface.h" #define HDF_LOG_TAG BDH6Driver -struct net_device *g_linux_netdev = NULL; +typedef enum { + WAL_ADDR_IDX_STA0 = 0, + WAL_ADDR_IDX_AP0 = 1, + WAL_ADDR_IDX_STA1 = 2, + WAL_ADDR_IDX_STA2 = 3, + WAL_ADDR_IDX_BUTT +} wal_addr_idx; + + +extern struct hdf_inf_map g_hdf_infmap[HDF_INF_MAX]; +extern int g_hdf_ifidx; struct wiphy *g_linux_wiphy = NULL; -void set_krn_netdev(struct net_device *netdev) +int get_dhd_priv_data_size(void); +extern void rtnl_lock(void); +extern void rtnl_unlock(void); + + +void set_krn_netdev(struct NetDevice *hnetdev, struct net_device *netdev, int ifidx) +{ + g_hdf_infmap[ifidx].hnetdev = hnetdev; + g_hdf_infmap[ifidx].netdev = netdev; +} + +struct NetDevice * get_hdf_netdev(int ifidx) { - g_linux_netdev = (struct net_device *)netdev; + return g_hdf_infmap[ifidx].hnetdev; } -struct net_device* get_krn_netdev(void) +struct net_device * get_krn_netdev(int ifidx) { - return g_linux_netdev; + return g_hdf_infmap[ifidx].netdev; } -struct wiphy* get_krn_wiphy(void) +struct wiphy * get_krn_wiphy(void) { return g_linux_wiphy; } -void set_krn_wiphy(struct wiphy *pwiphy) +void set_krn_wiphy(void *pwiphy) { g_linux_wiphy = (struct wiphy *)pwiphy; } +extern struct net_device_ops dhd_ops_pri; + +extern struct NetDeviceInterFace *wal_get_net_dev_ops(void); +extern int dhd_netdev_changemtu_wrapper(struct net_device *netdev, int mtu); +struct net_device * GetLinuxInfByNetDevice(const struct NetDevice *netDevice); +struct NetDeviceInterFace *wal_get_net_p2p_ops(void); + + +#define WIFI_IFNAME_MAX_SIZE 16 + +static wal_addr_idx wal_get_dev_addr_idx(int type) +{ + wal_addr_idx addr_idx = WAL_ADDR_IDX_BUTT; + + switch (type) { + case NL80211_IFTYPE_STATION: + addr_idx = WAL_ADDR_IDX_STA0; + break; + case NL80211_IFTYPE_AP: + case NL80211_IFTYPE_P2P_CLIENT: + case NL80211_IFTYPE_P2P_GO: + case NL80211_IFTYPE_MESH_POINT: + addr_idx = WAL_ADDR_IDX_AP0; + break; + case NL80211_IFTYPE_P2P_DEVICE: + addr_idx = WAL_ADDR_IDX_STA2; + break; + default: + HDF_LOGE("wal_get_dev_addr_idx:: dev type [%d] is not supported !", type); + break; + } + + return addr_idx; +} + +int wal_get_dev_addr(unsigned char *pc_addr, unsigned char addr_len, int type) +{ + unsigned char us_addr[MAC_ADDR_SIZE]; + unsigned int tmp; + wal_addr_idx addr_idx; + struct net_device *netdev = get_krn_netdev(0); + + if (pc_addr == NULL) { + HDF_LOGE("wal_get_dev_addr:: pc_addr is NULL!"); + return -1; + } + + addr_idx = wal_get_dev_addr_idx(type); + if (addr_idx >= WAL_ADDR_IDX_BUTT) { + return -1; + } + + for (tmp = 0; tmp < MAC_ADDR_SIZE; tmp++) { + us_addr[tmp] = netdev->dev_addr[tmp]; + } + + /* 1.低位自增 2.高位取其进位 3.低位将进位位置0 */ + us_addr[5] += addr_idx; /* 5 地址第6位 */ + us_addr[4] += ((us_addr[5] & (0x100)) >> 8); /* 4 地址第5位 5 地址第6位 8 右移8位 */ + us_addr[5] = us_addr[5] & (0xff); /* 5 地址第6位 */ + /* 最低位运算完成,下面类似 */ + us_addr[3] += ((us_addr[4] & (0x100)) >> 8); /* 3 地址第4位 4 地址第5位 8 右移8位 */ + us_addr[4] = us_addr[4] & (0xff); /* 4 地址第5位 */ + us_addr[2] += ((us_addr[3] & (0x100)) >> 8); /* 2 地址第3位 3 地址第4位 8 右移8位 */ + us_addr[3] = us_addr[3] & (0xff); /* 3 地址第4位 */ + us_addr[1] += ((us_addr[2] & (0x100)) >> 8); /* 1 地址第2位 2 地址第3位 8 右移8位 */ + us_addr[2] = us_addr[2] & (0xff); /* 2 地址第3位 */ + us_addr[0] += ((us_addr[1] & (0x100)) >> 8); /* 8 右移8位 */ + us_addr[1] = us_addr[1] & (0xff); + if (us_addr[0] > 0xff) { + us_addr[0] = 0; + } + us_addr[0] &= 0xFE; + + for (tmp = 0; tmp < addr_len; tmp++) { + pc_addr[tmp] = us_addr[tmp]; + } + + return 0; +} + + +int32_t GetIfName(int type, char *ifName, uint32_t len) +{ + if (ifName == NULL || len == 0) { + HDF_LOGE("%s:para is null!", __func__); + return -1; + } + switch (type) { + case NL80211_IFTYPE_P2P_DEVICE: + if (snprintf_s(ifName, len, len - 1, "p2p%d", 0) < 0) { + HDF_LOGE("%s:format ifName failed!", __func__); + return -1; + } + break; + case NL80211_IFTYPE_P2P_CLIENT: + /* fall-through */ + case NL80211_IFTYPE_P2P_GO: + if (snprintf_s(ifName, len, len - 1, "p2p-p2p0-%d", 0) < 0) { + //if (snprintf_s(ifName, len, len - 1, "p2p-wlan0-%d", 0) < 0) { + HDF_LOGE("%s:format ifName failed!", __func__); + return -1; + } + break; + default: + HDF_LOGE("%s:GetIfName::not supported dev type!", __func__); + return -1; + } + return 0; +} + +int BDH6InitNetdev(struct NetDevice *netDevice, int private_data_size, int type, int ifidx) +{ + struct NetDevice *hnetdev = NULL; + char ifName[WIFI_IFNAME_MAX_SIZE] = {0}; + struct HdfWifiNetDeviceData *data = NULL; + struct net_device *netdev = NULL; + int ret = 0; + unsigned char ac_addr[MAC_ADDR_SIZE] = {0}; + + if (netDevice == NULL) { + HDF_LOGE("%s:para is null!", __func__); + return -1; + } + if (GetIfName(type, ifName, WIFI_IFNAME_MAX_SIZE) != 0) { + HDF_LOGE("%s:get ifName failed!", __func__); + return -1; + } + + hnetdev = NetDeviceInit(ifName, strlen(ifName), WIFI_LINK, FULL_OS); + if (hnetdev == NULL) { + HDF_LOGE("%s:netdev is null!", __func__); + return -1; + } + data = GetPlatformData(netDevice); + if (data == NULL) { + HDF_LOGE("%s:netdevice data null!", __func__); + return -1; + } + hnetdev->classDriverName = netDevice->classDriverName; + hnetdev->classDriverPriv = data; + + netdev = GetLinuxInfByNetDevice(hnetdev); + if (NULL == netdev) { + HDF_LOGE("%s net_device is null!", __func__); + return HDF_FAILURE; + } + + hdf_bdh6_netdev_init(hnetdev); // set net_dev_ops + + // create bdh6 private object + //private_data_size = get_dhd_priv_data_size(); + hnetdev->mlPriv = kzalloc(private_data_size, GFP_KERNEL); + if (NULL == hnetdev->mlPriv) { + HDF_LOGE("%s:kzalloc mlPriv failed", __func__); + return -1; + } + + // set mac address + ret = wal_get_dev_addr(ac_addr, MAC_ADDR_SIZE, type); + if (ret != 0) { + HDF_LOGE("generate macaddr for %s failed", hnetdev->name); + } + memcpy_s(hnetdev->macAddr, MAC_ADDR_SIZE, ac_addr, MAC_ADDR_SIZE); + + // Call linux register_netdev() + //ret = NetDeviceAdd(hnetdev); + //HDF_LOGE("NetDeviceAdd %s ret = %d", hnetdev->name, ret); + + g_hdf_ifidx = ifidx; + set_krn_netdev(hnetdev, netdev, ifidx); + + return ret; +} + int32_t hdf_bdh6_netdev_init(struct NetDevice *netDev) { - HDF_LOGE("%s: start...", __func__); - if (netDev == NULL) { + HDF_LOGE("%s: start %s...", __func__, netDev->name); + if (NULL == netDev) { HDF_LOGE("%s: netDev null!", __func__); return HDF_FAILURE; } @@ -54,23 +243,44 @@ int32_t hdf_bdh6_netdev_init(struct NetDevice *netDev) return HDF_SUCCESS; } +int32_t hdf_p2p_netdev_init(struct NetDevice *netDev) +{ + HDF_LOGE("%s: start %s...", __func__, netDev->name); + if (NULL == netDev) { + HDF_LOGE("%s: netDev null!", __func__); + return HDF_FAILURE; + } + + HDF_LOGE("%s: netDev->name:%s\n", __func__, netDev->name); + netDev->netDeviceIf = wal_get_net_p2p_ops(); + CreateEapolData(netDev); + + return HDF_SUCCESS; +} + + void hdf_bdh6_netdev_deinit(struct NetDevice *netDev) { - HDF_LOGE("%s: start...", __func__); + HDF_LOGE("%s: start %s...", __func__, netDev->name); (void)netDev; } int32_t hdf_bdh6_netdev_open(struct NetDevice *netDev) { int32_t retVal = 0; - const int idx0 = 0, idx1 = 1, idx2 = 2, idx3 = 3, idx4 = 4, idx5 = 5; struct net_device *netdev = GetLinuxInfByNetDevice(netDev); + HDF_LOGE("%s: start %s ...", __func__, netDev->name); + if (netdev != get_krn_netdev(0)) { + // for virtual don't call open + return 0; + } - if (netdev == NULL) { + if (NULL == netdev) { HDF_LOGE("%s: netDev null!", __func__); return HDF_FAILURE; } + rtnl_lock(); HDF_LOGE("%s: ndo_stop...", __func__); retVal = (int32_t)dhd_ops_pri.ndo_stop(netdev); if (retVal < 0) { @@ -79,34 +289,62 @@ int32_t hdf_bdh6_netdev_open(struct NetDevice *netDev) retVal = (int32_t)dhd_ops_pri.ndo_open(netdev); if (retVal < 0) { + HDF_LOGE("%s: hdf net device open failed! ret = %d", __func__, retVal); } netDev->ieee80211Ptr = netdev->ieee80211_ptr; - if (netDev->ieee80211Ptr == NULL) { + if (NULL == netDev->ieee80211Ptr) { + HDF_LOGE("%s: NULL == netDev->ieee80211Ptr", __func__); } // update mac addr to NetDevice object memcpy_s(netDev->macAddr, MAC_ADDR_SIZE, netdev->dev_addr, netdev->addr_len); - HDF_LOGE("%s: %02x:%02x:%02x:%02x:%02x:%02x", __func__, - netDev->macAddr[idx0], netDev->macAddr[idx1], netDev->macAddr[idx2], - netDev->macAddr[idx3], netDev->macAddr[idx4], netDev->macAddr[idx5]); - + HDF_LOGE("%s: %02x:%02x:%02x:%02x:%02x:%02x", __func__, + netDev->macAddr[0], + netDev->macAddr[1], + netDev->macAddr[2], + netDev->macAddr[3], + netDev->macAddr[4], + netDev->macAddr[5] + ); + + rtnl_unlock(); + + //struct wireless_dev *wdev = GET_NET_DEV_CFG80211_WIRELESS(netDev); + //g_gphdfnetdev = netDev; + return retVal; } +int32_t hdf_p2p_netdev_open(struct NetDevice *netDev) +{ + HDF_LOGE("%s: start %s...", __func__, netDev->name); + //hdf_bdh6_netdev_open(get_hdf_netdev(HDF_INF_WLAN0)); + return 0; +} + + int32_t hdf_bdh6_netdev_stop(struct NetDevice *netDev) { int32_t retVal = 0; struct net_device *netdev = GetLinuxInfByNetDevice(netDev); + HDF_LOGE("%s: start %s...", __func__, netDev->name); + if (netdev != get_krn_netdev(0)) { + // for virtual don't call stop + return 0; + } - HDF_LOGE("%s: start...", __func__); + //(void)netDev; - if (netdev == NULL) { + if (NULL == netdev) { HDF_LOGE("%s: netDev null!", __func__); return HDF_FAILURE; } + rtnl_lock(); retVal = (int32_t)dhd_ops_pri.ndo_stop(netdev); + rtnl_unlock(); + if (retVal < 0) { HDF_LOGE("%s: hdf net device stop failed! ret = %d", __func__, retVal); } @@ -114,12 +352,22 @@ int32_t hdf_bdh6_netdev_stop(struct NetDevice *netDev) return retVal; } +int32_t hdf_p2p_netdev_stop(struct NetDevice *netDev) +{ + HDF_LOGE("%s: start %s...", __func__, netDev->name); + return 0; +} + + int32_t hdf_bdh6_netdev_xmit(struct NetDevice *netDev, NetBuf *netBuff) { int32_t retVal = 0; struct net_device *netdev = GetLinuxInfByNetDevice(netDev); - if (netdev == NULL || netBuff == NULL) { + //(void)netDev; + //HDF_LOGI("%s: start...", __func__); + + if (NULL == netdev || NULL == netBuff) { HDF_LOGE("%s: netdev or netBuff null!", __func__); return HDF_FAILURE; } @@ -132,15 +380,29 @@ int32_t hdf_bdh6_netdev_xmit(struct NetDevice *netDev, NetBuf *netBuff) return retVal; } +int32_t hdf_p2p_netdev_xmit(struct NetDevice *netDev, NetBuf *netBuff) +{ + HDF_LOGI("%s: start %s...", __func__, netDev->name); + if (netBuff) { + dev_kfree_skb_any(netBuff); + } + + return 0; +} + + int32_t hdf_bdh6_netdev_ioctl(struct NetDevice *netDev, IfReq *req, int32_t cmd) { int32_t retVal = 0; struct ifreq dhd_req = {0}; + //struct net_device * netdev = get_krn_netdev(); struct net_device *netdev = GetLinuxInfByNetDevice(netDev); - HDF_LOGE("%s: start...", __func__); + //(void)netDev; + HDF_LOGE("%s: start %s...", __func__, netDev->name); + //return HDF_FAILURE; - if (netdev == NULL || req == NULL) { + if (NULL == netdev || NULL == req) { HDF_LOGE("%s: netdev or req null!", __func__); return HDF_FAILURE; } @@ -155,14 +417,23 @@ int32_t hdf_bdh6_netdev_ioctl(struct NetDevice *netDev, IfReq *req, int32_t cmd) return retVal; } -int32_t hdf_bdh6_netdev_setmacaddr(struct NetDevice *netDev, unsigned char *addr) +int32_t hdf_p2p_netdev_ioctl(struct NetDevice *netDev, IfReq *req, int32_t cmd) +{ + HDF_LOGE("%s: start %s...", __func__, netDev->name); + return 0; +} + + +int32_t hdf_bdh6_netdev_setmacaddr(struct NetDevice *netDev, void *addr) { int32_t retVal = 0; + //struct net_device * netdev = get_krn_netdev(); struct net_device *netdev = GetLinuxInfByNetDevice(netDev); - HDF_LOGE("%s: start...", __func__); + //(void)netDev; + HDF_LOGE("%s: start %s...", __func__, netDev->name); - if (netdev == NULL || addr == NULL) { + if (NULL == netdev || NULL == addr) { HDF_LOGE("%s: netDev or addr null!", __func__); return HDF_FAILURE; } @@ -175,21 +446,42 @@ int32_t hdf_bdh6_netdev_setmacaddr(struct NetDevice *netDev, unsigned char *addr return retVal; } +int32_t hdf_p2p_netdev_setmacaddr(struct NetDevice *netDev, void *addr) +{ + int32_t retVal = 0; + struct net_device *netdev = GetLinuxInfByNetDevice(netDev); + + //(void)netDev; + HDF_LOGE("%s: start %s...", __func__, netDev->name); + + if (NULL == netdev || NULL == addr) { + HDF_LOGE("%s: netDev or addr null!", __func__); + return HDF_FAILURE; + } + + memcpy_s(netdev->dev_addr, netdev->addr_len, addr, netdev->addr_len); + memcpy_s(netDev->macAddr, MAC_ADDR_SIZE, netdev->dev_addr, netdev->addr_len); + return retVal; +} + + struct NetDevStats *hdf_bdh6_netdev_getstats(struct NetDevice *netDev) { static struct NetDevStats devStat = {0}; - struct net_device_stats *kdevStat = NULL; + struct net_device_stats * kdevStat = NULL; + //struct net_device * netdev = get_krn_netdev(); struct net_device *netdev = GetLinuxInfByNetDevice(netDev); - HDF_LOGE("%s: start...", __func__); + //(void)netDev; + HDF_LOGE("%s: start %s...", __func__, netDev->name); - if (netdev == NULL) { + if (NULL == netdev) { HDF_LOGE("%s: netDev null!", __func__); return NULL; } kdevStat = dhd_ops_pri.ndo_get_stats(netdev); - if (kdevStat == NULL) { + if (NULL == kdevStat) { HDF_LOGE("%s: ndo_get_stats return null!", __func__); return NULL; } @@ -206,6 +498,24 @@ struct NetDevStats *hdf_bdh6_netdev_getstats(struct NetDevice *netDev) return &devStat; } +struct NetDevStats *hdf_p2p_netdev_getstats(struct NetDevice *netDev) +{ + static struct NetDevStats devStat = {0}; + //struct net_device_stats * kdevStat = NULL; + struct net_device *netdev = GetLinuxInfByNetDevice(netDev); + + //(void)netDev; + HDF_LOGE("%s: start %s...", __func__, netDev->name); + + if (NULL == netdev) { + HDF_LOGE("%s: netDev null!", __func__); + return NULL; + } + + return &devStat; +} + + void hdf_bdh6_netdev_setnetifstats(struct NetDevice *netDev, NetIfStatus status) { HDF_LOGE("%s: start...", __func__); @@ -230,17 +540,19 @@ uint32_t hdf_bdh6_netdev_netifnotify(struct NetDevice *netDev, NetDevNotify *not } int32_t hdf_bdh6_netdev_changemtu(struct NetDevice *netDev, int32_t mtu) -{ +{ int32_t retVal = 0; + //struct net_device * netdev = get_krn_netdev(); struct net_device *netdev = GetLinuxInfByNetDevice(netDev); - HDF_LOGE("%s: start...", __func__); + HDF_LOGE("%s: start %s...", __func__, netDev->name); - if (netdev == NULL) { + //(void)netDev; + if (NULL == netdev) { HDF_LOGE("%s: netdev null!", __func__); return HDF_FAILURE; } HDF_LOGE("%s: change mtu to %d\n", __FUNCTION__, mtu); - // dengb fixed +//dengb fixed retVal = (int32_t)dhd_netdev_changemtu_wrapper(netdev, mtu); if (retVal < 0) { HDF_LOGE("%s: hdf net device chg mtu failed! ret = %d", __func__, retVal); @@ -249,23 +561,30 @@ int32_t hdf_bdh6_netdev_changemtu(struct NetDevice *netDev, int32_t mtu) return retVal; } +int32_t hdf_p2p_netdev_changemtu(struct NetDevice *netDev, int32_t mtu) +{ + struct net_device *netdev = GetLinuxInfByNetDevice(netDev); + HDF_LOGE("%s: start %s...", __func__, netDev->name); + netdev->mtu = mtu; + return 0; +} + + void hdf_bdh6_netdev_linkstatuschanged(struct NetDevice *netDev) { HDF_LOGE("%s: start...", __func__); (void)netDev; } -#define BDH6_SHIFT_BIT 8 - ProcessingResult hdf_bdh6_netdev_specialethertypeprocess(const struct NetDevice *netDev, NetBuf *buff) { struct EtherHeader *header = NULL; + // uint16_t etherType; const struct Eapol *eapolInstance = NULL; int ret = HDF_SUCCESS; uint16_t protocol; - const int pidx0 = 12, pidx1 = 13; - HDF_LOGE("%s: start...", __func__); + HDF_LOGE("%s: start %s...", __func__, netDev->name); if (netDev == NULL || buff == NULL) { return PROCESSING_ERROR; @@ -273,15 +592,15 @@ ProcessingResult hdf_bdh6_netdev_specialethertypeprocess(const struct NetDevice header = (struct EtherHeader *)NetBufGetAddress(buff, E_DATA_BUF); - protocol = (buff->data[pidx0] << BDH6_SHIFT_BIT) | buff->data[pidx1]; + protocol = (buff->data[12] << 8) | buff->data[13]; if (protocol != ETHER_TYPE_PAE) { HDF_LOGE("%s: return PROCESSING_CONTINUE", __func__); - NetBufFree(buff); + NetBufFree(buff); return PROCESSING_CONTINUE; } if (netDev->specialProcPriv == NULL) { HDF_LOGE("%s: return PROCESSING_ERROR", __func__); - NetBufFree(buff); + NetBufFree(buff); return PROCESSING_ERROR; } @@ -295,7 +614,8 @@ ProcessingResult hdf_bdh6_netdev_specialethertypeprocess(const struct NetDevice } -struct NetDeviceInterFace g_wal_bdh6_net_dev_ops = { +struct NetDeviceInterFace g_wal_bdh6_net_dev_ops = +{ .init = hdf_bdh6_netdev_init, .deInit = hdf_bdh6_netdev_deinit, .open = hdf_bdh6_netdev_open, @@ -317,18 +637,27 @@ struct NetDeviceInterFace *wal_get_net_dev_ops(void) return &g_wal_bdh6_net_dev_ops; } -void wal_netif_rx_ni(struct sk_buff *skb) -{ - NetIfRxNi(g_hdf_netdev, skb); -} -void wal_netif_rx(struct sk_buff *skb) +struct NetDeviceInterFace g_bdh6_p2p_net_dev_ops = { - NetIfRx(g_hdf_netdev, skb); -} + .init = hdf_p2p_netdev_init, + .deInit = hdf_bdh6_netdev_deinit, + .open = hdf_p2p_netdev_open, + .stop = hdf_p2p_netdev_stop, + .xmit = hdf_p2p_netdev_xmit, + .ioctl = hdf_p2p_netdev_ioctl, + .setMacAddr = hdf_p2p_netdev_setmacaddr, + .getStats = hdf_p2p_netdev_getstats, + .setNetIfStatus = hdf_bdh6_netdev_setnetifstats, + .selectQueue = hdf_bdh6_netdev_selectqueue, + .netifNotify = hdf_bdh6_netdev_netifnotify, + .changeMtu = hdf_p2p_netdev_changemtu, + .linkStatusChanged = hdf_bdh6_netdev_linkstatuschanged, + .specialEtherTypeProcess = hdf_bdh6_netdev_specialethertypeprocess, +}; -NetDevice* get_bdh6_netDev(void) +struct NetDeviceInterFace *wal_get_net_p2p_ops(void) { - return g_hdf_netdev; + return &g_bdh6_p2p_net_dev_ops; } diff --git a/rk3568/wifi/bcmdhd_wifi6/hdf/net_bdh_adpater.h b/rk3568/wifi/bcmdhd_wifi6/hdf/net_bdh_adpater.h index cc1be4fca710e291bb1c380a62bc1b6efe1bb11e..de951af7c64cda3699d516851f2ced10ca3eec48 100644 --- a/rk3568/wifi/bcmdhd_wifi6/hdf/net_bdh_adpater.h +++ b/rk3568/wifi/bcmdhd_wifi6/hdf/net_bdh_adpater.h @@ -1,16 +1,30 @@ /* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. * - * HDF is dual licensed: you can use it either under the terms of - * the GPL, or the BSD license, at your option. - * See the LICENSE file in the root of this repository for complete details. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef NET_BDH_ADAPTER_H #define NET_BDH_ADAPTER_H -#include + +//#include "hmac_ext_if.h" +//#include "oam_ext_if.h" +//#include "wal_main.h" #include "net_device.h" +#include #ifdef __cplusplus @@ -19,20 +33,13 @@ extern "C" { #endif #endif - -void set_krn_netdev(struct net_device *netdev); -struct net_device* get_krn_netdev(void); -struct wiphy* get_krn_wiphy(void); +void set_krn_netdev(struct NetDevice *hnetdev, struct net_device *netdev, int ifidx); +struct wiphy * get_krn_wiphy(void); int32_t hdf_bdh6_netdev_init(struct NetDevice *netDev); int32_t hdf_bdh6_netdev_open(struct NetDevice *netDev); int32_t hdf_bdh6_netdev_stop(struct NetDevice *netDev); - -struct NetDeviceInterFace* wal_get_net_dev_ops(void); -int dhd_netdev_changemtu_wrapper(struct net_device *netdev, int mtu); -struct net_device* GetLinuxInfByNetDevice(const struct NetDevice *netDevice); - #ifdef __cplusplus #if __cplusplus }