mirror of
https://gitee.com/openharmony/drivers_framework
synced 2024-11-23 21:10:02 +00:00
feat: Add new hdf wlan hal interfaces about power model.
Signed-off-by: RichardHuang9527 <huangyiping8@huawei.com>
This commit is contained in:
parent
86c1c372af
commit
7cb9d3a197
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2020-2022 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.
|
||||
@ -35,8 +35,8 @@
|
||||
#ifndef WIFI_MAC80211_OPS_H
|
||||
#define WIFI_MAC80211_OPS_H
|
||||
|
||||
#include "net_device.h"
|
||||
#include "hdf_wifi_cmd.h"
|
||||
#include "net_device.h"
|
||||
|
||||
/**
|
||||
* @brief Indicates the length of the MAC address of the device.
|
||||
@ -148,16 +148,16 @@ enum Ieee80211Band {
|
||||
* @version 1.0
|
||||
*/
|
||||
enum Ieee80211ChannelWidth {
|
||||
WLAN_CHANNEL_WIDTH_10 = BIT(0), /**< 10 MHz */
|
||||
WLAN_CHANNEL_WIDTH_20 = BIT(1), /**< 20 MHz */
|
||||
WLAN_CHANNEL_WIDTH_40P = BIT(2), /**< 40 MHz (two 20 MHz channels, with the primary channel
|
||||
* having a higher frequency
|
||||
*/
|
||||
WLAN_CHANNEL_WIDTH_40M = BIT(3), /**< 40 MHz (two 20 MHz channels, with the primary channel
|
||||
* having a lower frequency
|
||||
*/
|
||||
WLAN_CHANNEL_WIDTH_80 = BIT(4), /**< 80 MHz */
|
||||
WLAN_CHANNEL_WIDTH_160 = BIT(5), /**< 160 MHz */
|
||||
WLAN_CHANNEL_WIDTH_10 = BIT(0), /**< 10 MHz */
|
||||
WLAN_CHANNEL_WIDTH_20 = BIT(1), /**< 20 MHz */
|
||||
WLAN_CHANNEL_WIDTH_40P = BIT(2), /**< 40 MHz (two 20 MHz channels, with the primary channel
|
||||
* having a higher frequency
|
||||
*/
|
||||
WLAN_CHANNEL_WIDTH_40M = BIT(3), /**< 40 MHz (two 20 MHz channels, with the primary channel
|
||||
* having a lower frequency
|
||||
*/
|
||||
WLAN_CHANNEL_WIDTH_80 = BIT(4), /**< 80 MHz */
|
||||
WLAN_CHANNEL_WIDTH_160 = BIT(5), /**< 160 MHz */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -167,8 +167,8 @@ enum Ieee80211ChannelWidth {
|
||||
* @version 1.0
|
||||
*/
|
||||
enum WlanWorkMode {
|
||||
WLAN_WORKMODE_STA = 2, /**< STA mode */
|
||||
WLAN_WORKMODE_AP = 3, /**< AP mode */
|
||||
WLAN_WORKMODE_STA = 2, /**< STA mode */
|
||||
WLAN_WORKMODE_AP = 3, /**< AP mode */
|
||||
WLAN_WORKMODE_AP_VLAN,
|
||||
WLAN_WORKMODE_WDS,
|
||||
WLAN_WORKMODE_MONITOR,
|
||||
@ -197,7 +197,7 @@ struct KeyParams {
|
||||
#define UINT32_BIT(BIT) (((uint32_t)1) << (BIT))
|
||||
|
||||
#define WLAN_CHANNEL_FLAG_DFS_UNKNOWN 0x00000000
|
||||
#define WLAN_CHANNEL_FLAG_DFS_MASK 0x00000300
|
||||
#define WLAN_CHANNEL_FLAG_DFS_MASK 0x00000300
|
||||
|
||||
/**
|
||||
* @brief Enumerates WLAN channel capability flags.
|
||||
@ -206,19 +206,19 @@ struct KeyParams {
|
||||
* @version 1.0
|
||||
*/
|
||||
enum WlanChannelCapabilityFlags {
|
||||
WLAN_CHANNEL_FLAG_DISABLED = UINT32_BIT(0), /**< Channel disabled */
|
||||
WLAN_CHANNEL_FLAG_NO_IR = UINT32_BIT(1), /**< Infrared light (IR) not supported */
|
||||
WLAN_CHANNEL_FLAG_RADAR = UINT32_BIT(3), /**< Radar supported */
|
||||
WLAN_CHANNEL_FLAG_HT40PLUS = UINT32_BIT(4), /**< A 40 MHz channel that consists of two 20 MHz channels,
|
||||
* with the primary channel having a higher frequency
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_DISABLED = UINT32_BIT(0), /**< Channel disabled */
|
||||
WLAN_CHANNEL_FLAG_NO_IR = UINT32_BIT(1), /**< Infrared light (IR) not supported */
|
||||
WLAN_CHANNEL_FLAG_RADAR = UINT32_BIT(3), /**< Radar supported */
|
||||
WLAN_CHANNEL_FLAG_HT40PLUS = UINT32_BIT(4), /**< A 40 MHz channel that consists of two 20 MHz channels,
|
||||
* with the primary channel having a higher frequency
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_HT40MINUS = UINT32_BIT(5), /**< A 40 MHz channel that consists of two 20 MHz channels,
|
||||
* with the primary channel having a lower frequency
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_HT40 = UINT32_BIT(6), /**< 40 MHz channel */
|
||||
WLAN_CHANNEL_FLAG_SURVEY_LIST_INITIALIZED = UINT32_BIT(7), /**< Survey list initialized */
|
||||
WLAN_CHANNEL_FLAG_DFS_USABLE = UINT32_BIT(8), /**< Dynamic frequency selection (DFS) supported */
|
||||
WLAN_CHANNEL_FLAG_DFS_UNAVAILABLE = UINT32_BIT(9), /**< DFS disabled */
|
||||
WLAN_CHANNEL_FLAG_DFS_USABLE = UINT32_BIT(8), /**< Dynamic frequency selection (DFS) supported */
|
||||
WLAN_CHANNEL_FLAG_DFS_UNAVAILABLE = UINT32_BIT(9), /**< DFS disabled */
|
||||
WLAN_CHANNEL_FLAG_DFS_AVAILABLE = WLAN_CHANNEL_FLAG_DFS_USABLE | WLAN_CHANNEL_FLAG_DFS_UNAVAILABLE,
|
||||
WLAN_CHANNEL_FLAG_VHT_10_70 =
|
||||
UINT32_BIT(11), /**< A 80 MHz channel: Frequency
|
||||
@ -238,32 +238,43 @@ enum WlanChannelCapabilityFlags {
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_INDOOR_ONLY = UINT32_BIT(16), /**< Used only indoors */
|
||||
WLAN_CHANNEL_FLAG_GO_CONCURRENT = UINT32_BIT(17), /**< Go Concurrent supported */
|
||||
WLAN_CHANNEL_FLAG_VHT_10_150 = UINT32_BIT(20), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 10 MHz to the channel's center frequency + 150 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_30_130 = UINT32_BIT(21), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 30 MHz to the channel's center frequency + 130 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_50_110 = UINT32_BIT(22), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 50 MHz to the channel's center frequency + 110 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_70_90 = UINT32_BIT(23), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
frequency - 70 MHz to the channel's center frequency + 90 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_90_70 = UINT32_BIT(24), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 90 MHz to the channel's center frequency + 70 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_110_50 = UINT32_BIT(25), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 110 MHz to the channel's center frequency + 50 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_130_30 = UINT32_BIT(26), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 130 MHz to the channel's center frequency + 30 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_150_10 = UINT32_BIT(27), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 150 MHz to the channel's center frequency + 10 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_10_150 = UINT32_BIT(20), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 10 MHz to the channel's center frequency + 150 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_30_130 = UINT32_BIT(21), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 30 MHz to the channel's center frequency + 130 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_50_110 = UINT32_BIT(22), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 50 MHz to the channel's center frequency + 110 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_70_90 = UINT32_BIT(23), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
frequency - 70 MHz to the channel's center frequency + 90 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_90_70 = UINT32_BIT(24), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 90 MHz to the channel's center frequency + 70 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_110_50 = UINT32_BIT(25), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 110 MHz to the channel's center frequency + 50 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_130_30 = UINT32_BIT(26), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 130 MHz to the channel's center frequency + 30 MHz
|
||||
*/
|
||||
WLAN_CHANNEL_FLAG_VHT_150_10 = UINT32_BIT(27), /**< A 160 MHz channel: Frequency band = Channel's center
|
||||
* frequency - 150 MHz to the channel's center frequency + 10 MHz
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Define wifi power mode.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#define WIFI_POWER_MODE_SLEEPING 0
|
||||
#define WIFI_POWER_MODE_GENERAL 1
|
||||
#define WIFI_POWER_MODE_THROUGH_WALL 2
|
||||
#define WIFI_POWER_MODE_NUM 3
|
||||
|
||||
/**
|
||||
* @brief Describes a communication channel.
|
||||
*
|
||||
@ -294,8 +305,8 @@ struct WlanBand {
|
||||
* @version 1.0
|
||||
*/
|
||||
struct WlanSSID {
|
||||
uint8_t ssid[IEEE80211_MAX_SSID_LEN]; /**< SSID array */
|
||||
uint8_t ssidLen; /**< SSID length */
|
||||
uint8_t ssid[IEEE80211_MAX_SSID_LEN]; /**< SSID array */
|
||||
uint8_t ssidLen; /**< SSID length */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -321,24 +332,24 @@ struct WlanScanRequest {
|
||||
* @version 1.0
|
||||
*/
|
||||
struct CryptoSettings {
|
||||
uint32_t wpaVersions; /**< WPA version */
|
||||
uint32_t cipherGroup; /**< Cipher group */
|
||||
int32_t n_ciphersPairwise; /**< Number of unicast ciphers supported by the AP */
|
||||
uint32_t wpaVersions; /**< WPA version */
|
||||
uint32_t cipherGroup; /**< Cipher group */
|
||||
int32_t n_ciphersPairwise; /**< Number of unicast ciphers supported by the AP */
|
||||
uint32_t ciphersPairwise[NL80211_MAX_NR_CIPHER_SUITES]; /**< Unicast cipher suites. The maximum number of
|
||||
* unicast cipher suites is specified by
|
||||
* {@link NL80211_MAX_NR_CIPHER_SUITES}.
|
||||
*/
|
||||
int32_t n_akmSuites; /**< Number of authentication and key management (AKM) suites */
|
||||
uint32_t akmSuites[NL80211_MAX_NR_AKM_SUITES]; /**< AKM suites. The maximum number of AKM suites is specified
|
||||
* by {@link NL80211_MAX_NR_AKM_SUITES}.
|
||||
*/
|
||||
uint16_t controlPortEthertype; /**< Data can be transmitted over an unauthenticated port. */
|
||||
int8_t controlPort; /**< Whether the user space control port is authorized. The value <b>true</b>
|
||||
* indicates that the user space control port is unauthorized.
|
||||
*/
|
||||
int8_t controlPortNoEncrypt; /**< Whether to encrypt frames transmitted over the control port.
|
||||
* The value <b>1</b> indicates that the frames are not encrypted.
|
||||
*/
|
||||
int32_t n_akmSuites; /**< Number of authentication and key management (AKM) suites */
|
||||
uint32_t akmSuites[NL80211_MAX_NR_AKM_SUITES]; /**< AKM suites. The maximum number of AKM suites is specified
|
||||
* by {@link NL80211_MAX_NR_AKM_SUITES}.
|
||||
*/
|
||||
uint16_t controlPortEthertype; /**< Data can be transmitted over an unauthenticated port. */
|
||||
int8_t controlPort; /**< Whether the user space control port is authorized. The value <b>true</b>
|
||||
* indicates that the user space control port is unauthorized.
|
||||
*/
|
||||
int8_t controlPortNoEncrypt; /**< Whether to encrypt frames transmitted over the control port.
|
||||
* The value <b>1</b> indicates that the frames are not encrypted.
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
@ -348,16 +359,16 @@ struct CryptoSettings {
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct WlanConnectParams {
|
||||
uint32_t centerFreq; /**< Connection channel. If this parameter is not specified, the connection channel
|
||||
* is automatically obtained from the scan result.
|
||||
*/
|
||||
uint8_t *bssid; /**< AP BSSID. If this parameter is not specified, the AP BSSID is automatically
|
||||
* obtained from the scan result.
|
||||
*/
|
||||
uint8_t *ssid; /**< SSID */
|
||||
uint8_t *ie; /**< IE information required for the connection */
|
||||
uint32_t ssidLen; /**< SSID length */
|
||||
uint32_t ieLen; /**< IE length */
|
||||
uint32_t centerFreq; /**< Connection channel. If this parameter is not specified, the connection channel
|
||||
* is automatically obtained from the scan result.
|
||||
*/
|
||||
uint8_t *bssid; /**< AP BSSID. If this parameter is not specified, the AP BSSID is automatically
|
||||
* obtained from the scan result.
|
||||
*/
|
||||
uint8_t *ssid; /**< SSID */
|
||||
uint8_t *ie; /**< IE information required for the connection */
|
||||
uint32_t ssidLen; /**< SSID length */
|
||||
uint32_t ieLen; /**< IE length */
|
||||
struct CryptoSettings crypto; /**< Cryptography information */
|
||||
const uint8_t *key; /**< Wired Equivalent Privacy (WEP) key used for Shared Key
|
||||
* Authentication (SKA)
|
||||
@ -367,7 +378,7 @@ typedef struct WlanConnectParams {
|
||||
uint8_t keyLen; /**< Key length */
|
||||
uint8_t keyIdx; /**< Index of the WEP key used for SKA */
|
||||
uint8_t mfp; /**< Whether to enable Management Frame Protection (MFP) */
|
||||
uint8_t aucResv[WIFI_CONNECT_PARM_RESV_SIZE]; /**< Reserved field */
|
||||
uint8_t aucResv[WIFI_CONNECT_PARM_RESV_SIZE]; /**< Reserved field */
|
||||
} WlanConnectParams;
|
||||
|
||||
/**
|
||||
@ -414,13 +425,13 @@ typedef struct {
|
||||
* @version 1.0
|
||||
*/
|
||||
struct WlanBeaconConf {
|
||||
uint32_t interval; /**< Beacon interval */
|
||||
uint32_t DTIMPeriod; /**< Delivery Traffic Indication Message (DTIM) interval for sending beacons */
|
||||
uint8_t *headIEs; /**< One or more IEs before the TIM IE */
|
||||
size_t headIEsLength; /**< Length of the IEs before the TIM IE */
|
||||
uint8_t *tailIEs; /**< One or more IEs after the TIM IE */
|
||||
size_t tailIEsLength; /**< Length of the IEs after the TIM IE */
|
||||
bool hiddenSSID; /**< Whether to hide the SSID */
|
||||
uint32_t interval; /**< Beacon interval */
|
||||
uint32_t DTIMPeriod; /**< Delivery Traffic Indication Message (DTIM) interval for sending beacons */
|
||||
uint8_t *headIEs; /**< One or more IEs before the TIM IE */
|
||||
size_t headIEsLength; /**< Length of the IEs before the TIM IE */
|
||||
uint8_t *tailIEs; /**< One or more IEs after the TIM IE */
|
||||
size_t tailIEsLength; /**< Length of the IEs after the TIM IE */
|
||||
bool hiddenSSID; /**< Whether to hide the SSID */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -430,12 +441,12 @@ struct WlanBeaconConf {
|
||||
* @version 1.0
|
||||
*/
|
||||
struct WlanAPConf {
|
||||
struct WlanSSID ssidConf; /**< SSID configuration */
|
||||
uint16_t channel; /**< Channel */
|
||||
uint16_t centerFreq1; /**< Center frequency 1 */
|
||||
uint16_t centerFreq2; /**< Center frequency 2 */
|
||||
uint8_t band; /**< Band, as enumerated in <b>Ieee80211Band</b> */
|
||||
uint8_t width; /**< Channel width, as enumerated in <b>Ieee80211ChannelWidth</b> */
|
||||
struct WlanSSID ssidConf; /**< SSID configuration */
|
||||
uint16_t channel; /**< Channel */
|
||||
uint16_t centerFreq1; /**< Center frequency 1 */
|
||||
uint16_t centerFreq2; /**< Center frequency 2 */
|
||||
uint8_t band; /**< Band, as enumerated in <b>Ieee80211Band</b> */
|
||||
uint8_t width; /**< Channel width, as enumerated in <b>Ieee80211ChannelWidth</b> */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -447,9 +458,9 @@ struct WlanAPConf {
|
||||
struct WlanHwCapability {
|
||||
void (*Release)(struct WlanHwCapability *self); /**< Function for releasing the hardware capability */
|
||||
struct WlanBand *bands[IEEE80211_NUM_BANDS]; /**< Frequency bands */
|
||||
uint16_t htCapability; /**< High-throughput (HT) capability */
|
||||
uint16_t supportedRateCount; /**< Number of supported rates */
|
||||
uint16_t *supportedRates; /**< An array of supported rates in 100 kbit/s */
|
||||
uint16_t htCapability; /**< High-throughput (HT) capability */
|
||||
uint16_t supportedRateCount; /**< Number of supported rates */
|
||||
uint16_t *supportedRates; /**< An array of supported rates in 100 kbit/s */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -486,8 +497,8 @@ struct HdfMac80211BaseOps {
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t (*AddKey)(struct NetDevice *netDev, uint8_t keyIndex, bool pairwise, const uint8_t *macAddr,
|
||||
struct KeyParams *params);
|
||||
int32_t (*AddKey)(
|
||||
struct NetDevice *netDev, uint8_t keyIndex, bool pairwise, const uint8_t *macAddr, struct KeyParams *params);
|
||||
|
||||
/**
|
||||
* @brief Deletes a key with a specified MAC address.
|
||||
@ -592,6 +603,32 @@ struct HdfMac80211BaseOps {
|
||||
int32_t (*SendAction)(struct NetDevice *netDev, WifiActionData *actionData);
|
||||
|
||||
int32_t (*GetIftype)(struct NetDevice *netDev, uint8_t *iftype);
|
||||
|
||||
/**
|
||||
* @brief Obtains the power mode which is being used.
|
||||
*
|
||||
* @param ifName Indicates the pointer to the network interface name.
|
||||
* @param mode Indicates the pointer to the power mode.
|
||||
*
|
||||
* @return Returns <b>0</b> if get infos successful; returns a negative value otherwise.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t (*GetPowerMode)(const char *ifName, uint8_t *mode);
|
||||
|
||||
/**
|
||||
* @brief Set the power mode.
|
||||
*
|
||||
* @param ifName Indicates the pointer to the network interface name.
|
||||
* @param mode The value set to power mode.
|
||||
*
|
||||
* @return Returns <b>0</b> if get infos successful; returns a negative value otherwise.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t (*SetPowerMode)(const char *ifName, uint8_t mode);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1,23 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2020-2022 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 "wifi_base.h"
|
||||
#include "../hdf_wifi_core.h"
|
||||
#include "eapol.h"
|
||||
#include "hdf_wlan_services.h"
|
||||
#include "hdf_wlan_utils.h"
|
||||
#include "hdf_wifi_event.h"
|
||||
#include "hdf_wlan_chipdriver_manager.h"
|
||||
#include "hdf_wlan_config.h"
|
||||
#include "hdf_wlan_services.h"
|
||||
#include "hdf_wlan_utils.h"
|
||||
#include "message/message_router.h"
|
||||
#include "message/sidecar.h"
|
||||
#include "securec.h"
|
||||
#include "wifi_mac80211_ops.h"
|
||||
#include "wifi_module.h"
|
||||
#include "../hdf_wifi_core.h"
|
||||
|
||||
#define HDF_LOG_TAG HDF_WIFI_CORE
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#define WIFI_24G_CHANNEL_NUM 14
|
||||
#define WIFI_MAX_CHANNEL_NUM 24
|
||||
#define WIFI_24G_CHANNEL_NUM 14
|
||||
#define WIFI_MAX_CHANNEL_NUM 24
|
||||
#define DEFAULT_EAPOL_PACKAGE_SIZE 800
|
||||
|
||||
Service *g_baseService = NULL;
|
||||
@ -72,8 +72,8 @@ static uint32_t SetMode(struct NetDevice *netDev, uint8_t iftype)
|
||||
return chipDriver->ops->SetMode(netDev, iftype);
|
||||
}
|
||||
|
||||
static uint32_t AddKey(struct NetDevice *netDev, uint8_t keyIndex, bool pairwise, const uint8_t *macAddr,
|
||||
struct KeyParams *params)
|
||||
static uint32_t AddKey(
|
||||
struct NetDevice *netDev, uint8_t keyIndex, bool pairwise, const uint8_t *macAddr, struct KeyParams *params)
|
||||
{
|
||||
struct HdfChipDriver *chipDriver = GetChipDriver(netDev);
|
||||
if (chipDriver == NULL) {
|
||||
@ -193,7 +193,7 @@ static int32_t WifiCmdNewKey(const RequestContext *context, struct HdfSBuf *reqD
|
||||
OsalMemFree(keyExt);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
netDev = NetDeviceGetInstByName(ifName);
|
||||
if (netDev == NULL) {
|
||||
HDF_LOGE("%s:netDev not found!ifName=%s", __func__, ifName);
|
||||
@ -316,7 +316,7 @@ static int32_t WifiCmdSetKey(const RequestContext *context, struct HdfSBuf *reqD
|
||||
|
||||
static int32_t WifiCmdSendEapol(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData)
|
||||
{
|
||||
WifiTxEapol eapol = { 0 };
|
||||
WifiTxEapol eapol = {0};
|
||||
struct NetDevice *netdev = NULL;
|
||||
const char *ifName = NULL;
|
||||
|
||||
@ -349,7 +349,7 @@ static int32_t WifiCmdSendEapol(const RequestContext *context, struct HdfSBuf *r
|
||||
static int32_t WifiCmdReceiveEapol(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData)
|
||||
{
|
||||
struct NetDevice *netdev = NULL;
|
||||
WifiRxEapol eapol = { 0 };
|
||||
WifiRxEapol eapol = {0};
|
||||
const char *ifName = NULL;
|
||||
int32_t ret;
|
||||
|
||||
@ -505,8 +505,8 @@ static int32_t WifiCmdSetMode(const RequestContext *context, struct HdfSBuf *req
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void WifiGetChannelData(struct WlanBand *band, WifiHwFeatureData **featureData,
|
||||
struct WlanHwCapability *capability, uint32_t iee80211band)
|
||||
static void WifiGetChannelData(
|
||||
struct WlanBand *band, WifiHwFeatureData **featureData, struct WlanHwCapability *capability, uint32_t iee80211band)
|
||||
{
|
||||
uint32_t loop;
|
||||
if (band == NULL || featureData == NULL || *featureData == NULL) {
|
||||
@ -621,7 +621,7 @@ static uint32_t GetValidFreqsWithBand(struct NetDevice *netdev, int32_t band, in
|
||||
static int32_t WifiCmdGetHwFeature(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData)
|
||||
{
|
||||
struct NetDevice *netdev = NULL;
|
||||
WifiHwFeatureData featureData = { 0 };
|
||||
WifiHwFeatureData featureData = {0};
|
||||
const char *ifName = NULL;
|
||||
int32_t ret;
|
||||
|
||||
@ -697,9 +697,9 @@ static void SetNetworkAddr(struct NetDevice *netdev, uint32_t type)
|
||||
|
||||
static void UnsetNetworkAddr(struct NetDevice *netdev)
|
||||
{
|
||||
IpV4Addr ip = { 0x00000000UL };
|
||||
IpV4Addr netmask = { 0x00000000UL };
|
||||
IpV4Addr gw = { 0x00000000UL };
|
||||
IpV4Addr ip = {0x00000000UL};
|
||||
IpV4Addr netmask = {0x00000000UL};
|
||||
IpV4Addr gw = {0x00000000UL};
|
||||
if (netdev != NULL) {
|
||||
NetIfSetAddr(netdev, &ip, &netmask, &gw);
|
||||
}
|
||||
@ -786,20 +786,17 @@ static int32_t WifiCmdSendAction(const RequestContext *context, struct HdfSBuf *
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
if (!HdfSbufReadBuffer(reqData, (const void **)&(actionData.bssid), &dataSize) ||
|
||||
dataSize != ETH_ADDR_LEN) {
|
||||
if (!HdfSbufReadBuffer(reqData, (const void **)&(actionData.bssid), &dataSize) || dataSize != ETH_ADDR_LEN) {
|
||||
HDF_LOGE("%s: %s!ParamName=%s,readSize=%u", __func__, ERROR_DESC_READ_REQ_FAILED, "bssid", dataSize);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
if (!HdfSbufReadBuffer(reqData, (const void **)&(actionData.dst), &dataSize) ||
|
||||
dataSize != ETH_ADDR_LEN) {
|
||||
if (!HdfSbufReadBuffer(reqData, (const void **)&(actionData.dst), &dataSize) || dataSize != ETH_ADDR_LEN) {
|
||||
HDF_LOGE("%s: %s!ParamName=%s,readSize=%u", __func__, ERROR_DESC_READ_REQ_FAILED, "dst", dataSize);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
if (!HdfSbufReadBuffer(reqData, (const void **)&(actionData.src), &dataSize) ||
|
||||
dataSize != ETH_ADDR_LEN) {
|
||||
if (!HdfSbufReadBuffer(reqData, (const void **)&(actionData.src), &dataSize) || dataSize != ETH_ADDR_LEN) {
|
||||
HDF_LOGE("%s: %s!ParamName=%s,readSize=%u", __func__, ERROR_DESC_READ_REQ_FAILED, "src", dataSize);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
@ -955,8 +952,8 @@ static int32_t WifiCmdSetMacAddr(const RequestContext *context, struct HdfSBuf *
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t WifiCmdGetValidFreqsWithBand(const RequestContext *context, struct HdfSBuf *reqData,
|
||||
struct HdfSBuf *rspData)
|
||||
static int32_t WifiCmdGetValidFreqsWithBand(
|
||||
const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData)
|
||||
{
|
||||
int32_t ret;
|
||||
struct NetDevice *netdev = NULL;
|
||||
@ -1112,8 +1109,8 @@ static int32_t WifiCmdGetChipId(const RequestContext *context, struct HdfSBuf *r
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t WifiCmdGetIfNamesByChipId(const RequestContext *context, struct HdfSBuf *reqData,
|
||||
struct HdfSBuf *rspData)
|
||||
static int32_t WifiCmdGetIfNamesByChipId(
|
||||
const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData)
|
||||
{
|
||||
uint8_t chipId;
|
||||
uint8_t ifNameCount = 0;
|
||||
@ -1253,8 +1250,8 @@ static int32_t WifiCmdDoResetChip(const RequestContext *context, struct HdfSBuf
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SendMessageResetDriverCallBack(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData,
|
||||
ErrorCode rspCode)
|
||||
void SendMessageResetDriverCallBack(
|
||||
const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData, ErrorCode rspCode)
|
||||
{
|
||||
uint8_t chipId;
|
||||
int32_t ret;
|
||||
@ -1298,8 +1295,8 @@ static int32_t WifiCmdResetDriver(const RequestContext *context, struct HdfSBuf
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
ret = g_baseService->SendAsyncMessage(g_baseService, BASE_SERVICE_ID, CMD_BASE_DO_RESET_PRIVATE, data,
|
||||
SendMessageResetDriverCallBack);
|
||||
ret = g_baseService->SendAsyncMessage(
|
||||
g_baseService, BASE_SERVICE_ID, CMD_BASE_DO_RESET_PRIVATE, data, SendMessageResetDriverCallBack);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HdfSbufRecycle(data);
|
||||
HDF_LOGE("%s: fail to reset the driver,%d", __func__, ret);
|
||||
@ -1327,7 +1324,7 @@ static int32_t WifiCmdGetNetDevInfo(const RequestContext *context, struct HdfSBu
|
||||
struct NetDevice *netDev = NULL;
|
||||
(void)context;
|
||||
(void)reqData;
|
||||
|
||||
|
||||
netdevNum = NetDevGetRegisterCount();
|
||||
if (!HdfSbufWriteUint32(rspData, netdevNum)) {
|
||||
HDF_LOGE("%s: %s!", __func__, ERROR_DESC_WRITE_RSP_FAILED);
|
||||
@ -1351,6 +1348,120 @@ static int32_t WifiCmdGetNetDevInfo(const RequestContext *context, struct HdfSBu
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static uint32_t HdfdWlanGetPowerMode(const char *ifName, uint8_t *mode)
|
||||
{
|
||||
struct NetDevice *netdev = NULL;
|
||||
|
||||
if (ifName == NULL || mode == NULL) {
|
||||
HDF_LOGE("%s: Invalid parameter", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
netdev = NetDeviceGetInstByName(ifName);
|
||||
if (netdev == NULL) {
|
||||
HDF_LOGE("%s:netdev not found!ifName=%s.", __func__, ifName);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
struct HdfChipDriver *chipDriver = GetChipDriver(netdev);
|
||||
if (chipDriver == NULL) {
|
||||
HDF_LOGE("%s:bad net device found!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (chipDriver->ops == NULL) {
|
||||
return HDF_ERR_INVALID_OBJECT;
|
||||
}
|
||||
if (chipDriver->ops->GetPowerMode == NULL) {
|
||||
*mode = WIFI_POWER_MODE_GENERAL;
|
||||
HDF_LOGE("%s: chipDriver->ops->GetPowerMode is null\r\n", __func__);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
return chipDriver->ops->GetPowerMode(ifName, mode);
|
||||
}
|
||||
|
||||
static int32_t WifiCmdGetPowerMode(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData)
|
||||
{
|
||||
int32_t ret;
|
||||
const char *ifName = NULL;
|
||||
uint8_t mode;
|
||||
(void)context;
|
||||
|
||||
if (reqData == NULL || rspData == NULL) {
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
ifName = HdfSbufReadString(reqData);
|
||||
if (ifName == NULL) {
|
||||
HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "ifName");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
ret = HdfdWlanGetPowerMode(ifName, &mode);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: fail to get power mode, %d", __func__, ret);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfSbufWriteUint8(rspData, mode)) {
|
||||
HDF_LOGE("%s: %s!", __func__, ERROR_DESC_WRITE_RSP_FAILED);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static uint32_t HdfdWlanSetPowerMode(const char *ifName, uint8_t mode)
|
||||
{
|
||||
struct NetDevice *netdev = NULL;
|
||||
|
||||
if (ifName == NULL || mode >= WIFI_POWER_MODE_NUM) {
|
||||
HDF_LOGE("%s: Invalid parameter", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
netdev = NetDeviceGetInstByName(ifName);
|
||||
if (netdev == NULL) {
|
||||
HDF_LOGE("%s:netdev not found!ifName=%s.", __func__, ifName);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
struct HdfChipDriver *chipDriver = GetChipDriver(netdev);
|
||||
if (chipDriver == NULL) {
|
||||
HDF_LOGE("%s:bad net device found!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (chipDriver->ops == NULL) {
|
||||
return HDF_ERR_INVALID_OBJECT;
|
||||
}
|
||||
|
||||
if (chipDriver->ops->SetPowerMode == NULL) {
|
||||
HDF_LOGE("%s: chipDriver->ops->SetPowerMode is null\r\n", __func__);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
return chipDriver->ops->SetPowerMode(ifName, mode);
|
||||
}
|
||||
|
||||
static int32_t WifiCmdSetPowerMode(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData)
|
||||
{
|
||||
int32_t ret;
|
||||
const char *ifName = NULL;
|
||||
uint8_t mode;
|
||||
(void)context;
|
||||
|
||||
if (reqData == NULL || rspData == NULL) {
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
ifName = HdfSbufReadString(reqData);
|
||||
if (ifName == NULL) {
|
||||
HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "ifName");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfSbufReadUint8(reqData, &mode)) {
|
||||
HDF_LOGE("%s: read data failed! ParamName=%s", __func__, "power mode");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
ret = HdfdWlanSetPowerMode(ifName, mode);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: fail to set power mode, %d", __func__, ret);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct MessageDef g_wifiBaseFeatureCmds[] = {
|
||||
DUEMessage(CMD_BASE_NEW_KEY, WifiCmdNewKey, 0),
|
||||
DUEMessage(CMD_BASE_DEL_KEY, WifiCmdDelKey, 0),
|
||||
@ -1378,15 +1489,15 @@ static struct MessageDef g_wifiBaseFeatureCmds[] = {
|
||||
DUEMessage(CMD_BASE_RESET_DRIVER, WifiCmdResetDriver, 0),
|
||||
DUEMessage(CMD_BASE_GET_NETDEV_INFO, WifiCmdGetNetDevInfo, 0),
|
||||
DUEMessage(CMD_BASE_DO_RESET_PRIVATE, WifiCmdDoResetChip, 0),
|
||||
DUEMessage(CMD_BASE_GET_POWER_MODE, WifiCmdGetPowerMode, 0),
|
||||
DUEMessage(CMD_BASE_SET_POWER_MODE, WifiCmdSetPowerMode, 0),
|
||||
};
|
||||
ServiceDefine(BaseService, BASE_SERVICE_ID, g_wifiBaseFeatureCmds);
|
||||
|
||||
int32_t BaseInit()
|
||||
{
|
||||
if (g_baseService == NULL) {
|
||||
ServiceCfg cfg = {
|
||||
.dispatcherId = DEFAULT_DISPATCHER_ID
|
||||
};
|
||||
ServiceCfg cfg = {.dispatcherId = DEFAULT_DISPATCHER_ID};
|
||||
g_baseService = CreateService(BaseService, &cfg);
|
||||
if (g_baseService == NULL) {
|
||||
return HDF_FAILURE;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2020-2022 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.
|
||||
@ -45,6 +45,8 @@ enum BaseCommands {
|
||||
CMD_BASE_RESET_DRIVER,
|
||||
CMD_BASE_GET_NETDEV_INFO = 25,
|
||||
CMD_BASE_DO_RESET_PRIVATE,
|
||||
CMD_BASE_GET_POWER_MODE,
|
||||
CMD_BASE_SET_POWER_MODE
|
||||
};
|
||||
|
||||
enum APCommands {
|
||||
@ -74,4 +76,4 @@ enum P2PCommands {
|
||||
CMD_P2P_GET_DRIVER_FLAGS
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user