From d40f04504eee5a21925b428b589f9feffcc02b6d Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Tue, 10 Aug 2021 13:29:16 +0000 Subject: [PATCH] Description:add wlan hal interface Feature or Bugfix:Feature Binary Source: No Signed-off-by: YOUR_NAME --- include/wifi/wifi_mac80211_ops.h | 1 + model/network/wifi/core/module/wifi_base.c | 46 ++++++++++++++++++- .../wifi/platform/include/hdf_wlan_services.h | 31 +++++++------ 3 files changed, 62 insertions(+), 16 deletions(-) diff --git a/include/wifi/wifi_mac80211_ops.h b/include/wifi/wifi_mac80211_ops.h index 7869d6c48..aa26a666d 100644 --- a/include/wifi/wifi_mac80211_ops.h +++ b/include/wifi/wifi_mac80211_ops.h @@ -605,6 +605,7 @@ struct HdfMac80211BaseOps { int32_t (*SendAction)(struct NetDevice *netDev, WifiActionData *actionData); + int32_t (*GetIftype)(struct NetDevice *netDev, uint8_t *iftype); }; /** diff --git a/model/network/wifi/core/module/wifi_base.c b/model/network/wifi/core/module/wifi_base.c index 73f03fa44..1d19774a2 100644 --- a/model/network/wifi/core/module/wifi_base.c +++ b/model/network/wifi/core/module/wifi_base.c @@ -1272,6 +1272,49 @@ static int32_t WifiCmdResetDriver(const RequestContext *context, struct HdfSBuf return ret; } +static uint32_t GetIftype(struct NetDevice *netdev, uint8_t *iftype) +{ + struct HdfChipDriver *chipDriver = GetChipDriver(netdev); + if (chipDriver == NULL) { + HDF_LOGE("%s:bad net device found!", __func__); + return HDF_FAILURE; + } + RETURN_IF_CHIPOPS_NOT_IMPLEMENT(chipDriver->ops, GetIftype); + return chipDriver->ops->GetIftype(netdev, iftype); +} + +#define MAX_NETDEVICE_COUNT 20 +static int32_t WifiCmdGetNetDevInfo(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData) +{ + (void)context; + (void)reqData; + uint32_t i; + uint32_t netdevNum; + uint8_t iftype; + struct NetDevice *netDev = NULL; + + netdevNum = NetDevGetRegisterCount(); + if (!HdfSbufWriteUint32(rspData, netdevNum)) { + HDF_LOGE("%s: %s!", __func__, ERROR_DESC_WRITE_RSP_FAILED); + return HDF_FAILURE; + } + for (i = 0; i < MAX_NETDEVICE_COUNT; i++) { + netDev = NetDeviceGetInstByIndex(i); + if (netDev != NULL) { + if (GetIftype(netDev, &iftype) != HDF_SUCCESS) { + iftype = 0; + } + if (!HdfSbufWriteUint32(rspData, i) || !HdfSbufWriteBuffer(rspData, netDev->name, strlen(netDev->name) + 1) || + !HdfSbufWriteUint8(rspData, iftype) || + !HdfSbufWriteBuffer(rspData, GET_NET_DEV_MAC_ADDR(netDev), ETH_ADDR_LEN)) { + HDF_LOGE("%s: %s!", __func__, ERROR_DESC_WRITE_RSP_FAILED); + return HDF_FAILURE; + } + } + } + return HDF_SUCCESS; +} + static int32_t RemainOnChannel(struct NetDevice *netdev, WifiOnChannel *onChannel) { struct HdfChipDriver *chipDriver = GetChipDriver(netdev); @@ -1624,7 +1667,7 @@ static struct MessageDef g_wifiBaseFeatureCmds[] = { DUEMessage(CMD_BASE_GET_CHIPID, WifiCmdGetChipId, 0), DUEMessage(CMD_BASE_GET_IFNAMES, WifiCmdGetIfNamesByChipId, 0), DUEMessage(CMD_BASE_RESET_DRIVER, WifiCmdResetDriver, 0), - DUEMessage(CMD_BASE_DO_RESET_PRIVATE, WifiCmdDoResetChip, 0), + DUEMessage(CMD_BASE_GET_NETDEV_INFO, WifiCmdGetNetDevInfo, 0), DUEMessage(CMD_P2P_PROBE_REQ_REPORT, WifiCmdProbeReqReport, 0), DUEMessage(CMD_P2P_REMAIN_ON_CHANNEL, WifiCmdRemainOnChannel, 0), DUEMessage(CMD_P2P_CANCEL_REMAIN_ON_CHANNEL, WifiCmdCancelRemainOnChannel, 0), @@ -1632,6 +1675,7 @@ static struct MessageDef g_wifiBaseFeatureCmds[] = { DUEMessage(CMD_P2P_REMOVE_IF, WifiCmdRemoveIf, 0), DUEMessage(CMD_P2P_SET_AP_WPS_P2P_IE, WifiCmdSetApWpsP2pIe, 0), DUEMessage(CMD_P2P_GET_DRIVER_FLAGS, WifiCmdGetDriverFlag, 0), + DUEMessage(CMD_BASE_DO_RESET_PRIVATE, WifiCmdDoResetChip, 0), }; ServiceDefine(BaseService, BASE_SERVICE_ID, g_wifiBaseFeatureCmds); diff --git a/model/network/wifi/platform/include/hdf_wlan_services.h b/model/network/wifi/platform/include/hdf_wlan_services.h index ad4e1148d..47fb1b8b5 100644 --- a/model/network/wifi/platform/include/hdf_wlan_services.h +++ b/model/network/wifi/platform/include/hdf_wlan_services.h @@ -1,10 +1,10 @@ -/* - * 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) 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 HDF_WLAN_SERVICES_H #define HDF_WLAN_SERVICES_H @@ -42,14 +42,15 @@ enum BaseCommands { CMD_BASE_GET_CHIPID, CMD_BASE_GET_IFNAMES, CMD_BASE_RESET_DRIVER, - CMD_BASE_DO_RESET_PRIVATE = 25, - CMD_P2P_PROBE_REQ_REPORT = 26, - CMD_P2P_REMAIN_ON_CHANNEL, - CMD_P2P_CANCEL_REMAIN_ON_CHANNEL, - CMD_P2P_ADD_IF, - CMD_P2P_REMOVE_IF, - CMD_P2P_SET_AP_WPS_P2P_IE, - CMD_P2P_GET_DRIVER_FLAGS, + CMD_BASE_GET_NETDEV_INFO = 25, + CMD_P2P_PROBE_REQ_REPORT = 26, + CMD_P2P_REMAIN_ON_CHANNEL, + CMD_P2P_CANCEL_REMAIN_ON_CHANNEL, + CMD_P2P_ADD_IF, + CMD_P2P_REMOVE_IF, + CMD_P2P_SET_AP_WPS_P2P_IE, + CMD_P2P_GET_DRIVER_FLAGS, + CMD_BASE_DO_RESET_PRIVATE, }; enum APCommands { -- Gitee