提交 b7777257 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 4e6fbd03
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
### WLAN ### WLAN
The Wireless Local Area Network (WLAN) Driver module in OpenHarmony is developed based on the Hardware Driver Foundation (HDF). It features cross-OS porting, self-adaptation to component differences, and modular assembly and build. The Wireless Local Area Network (WLAN) Driver module in OpenHarmony is developed based on the Hardware Driver Foundation (HDF). It provides cross-OS porting, self-adaptation to component differences, and module assembly and building.
### Working Principles ### Working Principles
...@@ -44,7 +44,7 @@ The WLAN driver consists of the following modules: ...@@ -44,7 +44,7 @@ The WLAN driver consists of the following modules:
8. NetBuf: encapsulates the unified data structure of the Linux or LiteOS native network data buffer and the operation interfaces for network data. 8. NetBuf: encapsulates the unified data structure of the Linux or LiteOS native network data buffer and the operation interfaces for network data.
9. FlowCtl: performs flow control. 9. FlowCtl: processes data based on the priority when the data volume is too large.
10. HCC-CFG: configures WLAN parameters, including the board configuration, driver configuration, and module configuration. 10. HCC-CFG: configures WLAN parameters, including the board configuration, driver configuration, and module configuration.
...@@ -74,20 +74,10 @@ The WLAN module provides the following types of APIs: ...@@ -74,20 +74,10 @@ The WLAN module provides the following types of APIs:
![image](figures/WLAN_driver_APIs.png "WLAN Driver APIs") ![image](figures/WLAN_driver_APIs.png "WLAN Driver APIs")
- The WLAN module provides HDI APIs for upper-layer services (applicable to the standard system). **Table 1** describes the major APIs.
**Table 1** IWlanInterface.idl
| API| Description|
| -------- | -------- |
| CreateFeature([in] int type, [out] struct HdfFeatureInfo ifeature);| Creates an **ifeature** instance.|
| DestroyFeature([in] struct HdfFeatureInfo ifeature);| Destroys an **ifeature** instance.|
| GetPowerMode([in] struct HdfFeatureInfo ifeature, [out] unsigned char mode);| Obtains the power mode.|
| SetPowerMode([in] struct HdfFeatureInfo ifeature, [in] unsigned char mode);| Sets the power mode.|
- The WLAN module provides HAL APIs for upper-layer services (applicable to small and mini systems). **Table 2** and **Table 3** describe some APIs. - The WLAN module provides HAL APIs for upper-layer services (applicable to small and mini systems). **Table 2** and **Table 3** describe some APIs.
**Table 2** wifi_hal.h **Table 1** wifi_hal.h
| API| Description| | API| Description|
| -------- | -------- | | -------- | -------- |
...@@ -96,7 +86,7 @@ The WLAN module provides the following types of APIs: ...@@ -96,7 +86,7 @@ The WLAN module provides the following types of APIs:
| int32_t (\*start)(struct IWiFi \*)| Creates a channel between the HAL and the driver and obtains the NICs supported by the driver.| | int32_t (\*start)(struct IWiFi \*)| Creates a channel between the HAL and the driver and obtains the NICs supported by the driver.|
| int32_t (\*stop)(struct IWiFi \*)| Stops the channel between the HAL and the driver.| | int32_t (\*stop)(struct IWiFi \*)| Stops the channel between the HAL and the driver.|
**Table 3** wifi_hal_base_feature.h **Table 2** wifi_hal_base_feature.h
| API| Description| | API| Description|
| -------- | -------- | | -------- | -------- |
...@@ -107,69 +97,79 @@ The WLAN module provides the following types of APIs: ...@@ -107,69 +97,79 @@ The WLAN module provides the following types of APIs:
- The WLAN Driver module also provides APIs that you need to fill in the implementation. **Table 4** describes some APIs. - The WLAN Driver module also provides APIs that you need to fill in the implementation. **Table 4** describes some APIs.
**Table 4** net_device.h **Table 3** net_device.h
| API| Description| | API| Description|
| -------- | -------- | | -------- | -------- |
| int32_t (\*init)(struct NetDevice \*netDev) | Initializes a network device.| | int32_t (\*init)(struct NetDevice \*netDev)| Initializes a network device.|
| struct NetDevStats \*(\*getStats)(struct NetDevice \*netDev) | Obtains the state of a network device.| | struct NetDevStats \*(\*getStats)(struct NetDevice \*netDev)| Obtains the state of a network device.|
| int32_t (\*setMacAddr)(struct NetDevice \*netDev, void \*addr) | Sets the MAC address.| | int32_t (\*setMacAddr)(struct NetDevice \*netDev, void \*addr)| Sets the MAC address.|
| void (\*deInit)(struct NetDevice \*netDev) | Deinitializes a network device.| | void (\*deInit)(struct NetDevice \*netDev)| Deinitializes a network device.|
| int32_t (\*open)(struct NetDevice \*netDev) | Opens a network device.| | int32_t (\*open)(struct NetDevice \*netDev)| Opens a network device.|
| int32_t (\*stop)(struct NetDevice \*netDev) | Stops a network device.| | int32_t (\*stop)(struct NetDevice \*netDev)| Stops a network device.|
- The WLAN Driver module provides APIs that you can directly use to create or release a **WifiModule**, connect to or disconnect from a WLAN hotspot, request or release a **NetBuf**, and convert between the **pbuf** structure of Lightweight IP (lwIP) and a **NetBuf**. - The WLAN Driver module provides APIs that you can directly use to create or release a **WifiModule**, connect to or disconnect from a WLAN hotspot, request or release a **NetBuf**, and convert between the **pbuf** structure of Lightweight IP (lwIP) and a **NetBuf**.
Tables 5 to 7 describe the APIs. Tables 5 to 7 describe the APIs.
**Table 5** wifi_module.h **Table 4** wifi_module.h
| API| Description| | API| Description|
| -------- | -------- | | -------- | -------- |
| struct WifiModule \*WifiModuleCreate(const struct HdfConfigWifiModuleConfig \*config) | Creates a **WifiModule**.| | struct WifiModule \*WifiModuleCreate(const struct HdfConfigWifiModuleConfig \*config)| Creates a **WifiModule**.|
| void WifiModuleDelete(struct WifiModule \*module) | Deletes a **WifiModule** and releases its data.| | void WifiModuleDelete(struct WifiModule \*module)| Deletes a **WifiModule** and releases its data.|
| int32_t DelFeature(struct WifiModule \*module, uint16_t featureType) | Deletes a feature from a **WifiModule**.| | int32_t DelFeature(struct WifiModule \*module, uint16_t featureType)| Deletes a feature from a **WifiModule**.|
| int32_t AddFeature(struct WifiModule \*module, uint16_t featureType, struct WifiFeature \*featureData) | Adds a feature to a **WifiModule**.| | int32_t AddFeature(struct WifiModule \*module, uint16_t featureType, struct WifiFeature \*featureData)| Adds a feature to a **WifiModule**.|
**Table 6** wifi_mac80211_ops.h **Table 5** wifi_mac80211_ops.h
| API| Description| | API| Description|
| -------- | -------- | | -------- | -------- |
| int32_t (\*startAp)(NetDevice \*netDev) | Starts an AP.| | int32_t (\*startAp)(NetDevice \*netDev)| Starts an AP.|
| int32_t (\*stopAp)(NetDevice \*netDev) | Stops an AP.| | int32_t (\*stopAp)(NetDevice \*netDev)| Stops an AP.|
| int32_t (\*connect)(NetDevice \*netDev, WifiConnectParams \*param) | Connects to a hotspot.| | int32_t (\*connect)(NetDevice \*netDev, WifiConnectParams \*param)| Connects to a hotspot.|
| int32_t (\*disconnect)(NetDevice \*netDev, uint16_t reasonCode) | Disconnects from a hotspot.| | int32_t (\*disconnect)(NetDevice \*netDev, uint16_t reasonCode)| Disconnects from a hotspot.|
**Table 7** hdf_netbuf.h **Table 6** hdf_netbuf.h
| API| Description| | API| Description|
| -------- | -------- | | -------- | -------- |
| static inline void NetBufQueueInit(struct NetBufQueue \*q) | Initializes a **NetBuf** queue.| | static inline void NetBufQueueInit(struct NetBufQueue \*q)| Initializes a **NetBuf** queue.|
| struct NetBuf \*NetBufAlloc(uint32_t size) | Allocates a **NetBuf**.| | struct NetBuf \*NetBufAlloc(uint32_t size)| Allocates a **NetBuf**.|
| void NetBufFree(struct NetBuf \*nb) | Releases a **NetBuf**.| | void NetBufFree(struct NetBuf \*nb) | Releases a **NetBuf**.|
| struct NetBuf \*Pbuf2NetBuf(const struct NetDevice \*netdev, struct pbuf \*lwipBuf) | Converts the **pbuf** structure of lwIP to a **NetBuf**.| | struct NetBuf \*Pbuf2NetBuf(const struct NetDevice \*netdev, struct pbuf \*lwipBuf)| Converts the **pbuf** structure of lwIP to a **NetBuf**.|
| struct pbuf \*NetBuf2Pbuf(const struct NetBuf \*nb) | Converts a **NetBuf** to the **pbuf** structure of lwIP.| | struct pbuf \*NetBuf2Pbuf(const struct NetBuf \*nb)| Converts a **NetBuf** to the **pbuf** structure of lwIP.|
### How to Develop ### How to Develop
#### WLAN Framework Adaptation
The WLAN driver module developed based on the HDF and Platform frameworks provides a unified driver model for WLAN modules of different vendors regardless of the OS and system on a chip (SoC). The WLAN driver framework developed based on the HDF and Platform framework provides a unified driver model regardless of the OS and system on a chip (SoC). When developing your WLAN driver, you need to configure data based on the WLAN driver framework.
**Development Procedure**
1. Configure hardware (such as modules and chips) parameters in the **wlan_platform.hcs** file. This file can be parsed by the APIs in the HDF to generate structure objects with full configuration. 1. Configure hardware (such as modules and chips) parameters in the **wlan_platform.hcs** file. The HDF parses the file to generate structure objects with full configuration.
2. Implement initialization and deinitialization of the WLAN module (such as initialize and deinitialize the WLAN chip and WLAN chip driver). 2. Implement initialization and deinitialization of the WLAN module (such as initialize and deinitialize the WLAN chip and WLAN chip driver).
3. Implement the delivery of control flow commands. 3. Implement the delivery of control flow commands.
4. Implement event reporting. 4. Implement event reporting.
### Development Example **Development Example**
The following uses the Hi3881 WLAN chip as an example to describe how to initialize a WLAN module. The following uses the Hi3881 WLAN chip as an example to describe how to initialize a WLAN module.
1. Configure hardware parameters. 1. Configure the HDF configuration source (HCS) for the driver.
The HCS includes device configuration and component configuration.
- Device configuration
The configuration file contains the power supply, reset, and bus configuration.
Configuration file path: **vendor/<vendor name>/<device name >/hdf_config/khdf/wifi**
Configure device parameters in **wlan_platform.hcs** based on the device you use. The following is an example of WLAN platform configuration.
```text ```text
/* Configure parameters in wlan_platform.hcs based on the hardware you use. The following is an example of WLAN platform configuration. */
hisi :& deviceList { hisi :& deviceList {
device0 :: deviceInst { device0 :: deviceInst {
deviceInstId = 0; deviceInstId = 0;
...@@ -202,7 +202,11 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial ...@@ -202,7 +202,11 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial
} }
} }
} }
/* Add the configuration file wlan_chip_<Chip name>.hcs (for example, wlan_chip_hi3881.hcs) for each chip and set parameters. The following uses the Hi3881 chip as an example. */ ```
- Component configuration
Add a configuration file **wlan_chip_.hcs** for each chip, for example, **wlan_chip_hi3881.hcs**, and configure related parameters. The following is a configuration example of hi3881.
```text
root { root {
wlan_config { wlan_config {
hi3881 :& chipList { hi3881 :& chipList {
...@@ -220,83 +224,28 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial ...@@ -220,83 +224,28 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial
``` ```
2. Hook the **init** and **deinit** functions of the WLAN chip and WLAN chip driver. 2. Hook the **init** and **deinit** functions of the WLAN chip and WLAN chip driver.
- Implementing the driver adaptation entry function
Define a variable of the HdfDriverEntry type based on the chip to hook functions of **Bind()**, **Init()**, and **Release()**. Call **HDF_INIT** to register the driver entry with the HDF. During driver loading, the HDF calls the **Bind** function and then the **Init** function to load the driver. If **Init()** fails to be called, the HDF calls **Release()** to release driver resources.
```c ```c
#include "hdf_device_desc.h" struct HdfDriverEntry g_hdfHisiChipEntry = {
#include "hdf_wifi_product.h" .moduleVersion = 1,
#include "hdf_log.h" .Bind = HdfWlanHisiDriverBind,
#include "osal_mem.h" .Init = HdfWlanHisiChipDriverInit,
#include "hdf_wlan_chipdriver_manager.h" .Release = HdfWlanHisiChipRelease,
#include "securec.h" .moduleName = "HDF_WLAN_CHIPS"
#include "wifi_module.h" };
#include "hi_wifi_api.h"
#include "hi_types_base.h"
#define HDF_LOG_TAG Hi3881Driver
/* Functions for initializing and deinitializing a WLAN chip. */
int32_t InitHi3881Chip(struct HdfWlanDevice *device);
int32_t DeinitHi3881Chip(struct HdfWlanDevice *device);
/* Functions for initializing and deinitializing a WLAN chip driver. */
int32_t Hi3881Deinit(struct HdfChipDriver* chipDriver, struct NetDevice *netDevice);
int32_t Hi3881Init(struct HdfChipDriver* chipDriver, struct NetDevice *netDevice);
/* Initialize mac80211 by hooking the functions of the chip. */
hi_void HiMac80211Init(struct HdfChipDriver *chipDriver);
static const char* const HI3881_DRIVER_NAME = "hisi";
/* Hook the functions of the WLAN chip driver, mac80211, and chip. */
static struct HdfChipDriver *BuildHi3881Driver(struct HdfWlanDevice *device, uint8_t ifIndex)
{
struct HdfChipDriver *specificDriver = NULL;
if (device == NULL) {
HDF_LOGE("%s fail: channel is NULL!", __func__);
return NULL;
}
(void)ifIndex;
specificDriver = (struct HdfChipDriver *)OsalMemCalloc(sizeof(struct HdfChipDriver));
if (specificDriver == NULL) {
HDF_LOGE("%s fail: OsalMemCalloc fail!", __func__);
return NULL;
}
if (memset_s(specificDriver, sizeof(struct HdfChipDriver), 0, sizeof(struct HdfChipDriver)) != EOK) {
HDF_LOGE("%s fail: memset_s fail!", __func__);
OsalMemFree(specificDriver);
return NULL;
}
if (strcpy_s(specificDriver->name, MAX_WIFI_COMPONENT_NAME_LEN, HI3881_DRIVER_NAME) != EOK) {
HDF_LOGE("%s fail: strcpy_s fail!", __func__);
OsalMemFree(specificDriver);
return NULL;
}
specificDriver->init = Hi3881Init;
specificDriver->deinit = Hi3881Deinit;
HiMac80211Init(specificDriver); HDF_INIT(g_hdfHisiChipEntry);
```
return specificDriver; - Registering the functions for initializing the chip and chip driver
}
/* Release the WLAN chip driver. */ Hook the chip initialization function to **InitChip()** and the chip deinitialization function to **DeinitChip()**.
static void ReleaseHi3881Driver(struct HdfChipDriver *chipDriver)
{
if (chipDriver == NULL) {
return;
}
if (strcmp(chipDriver->name, HI3881_DRIVER_NAME) != 0) {
HDF_LOGE("%s:Not my driver!", __func__);
return;
}
OsalMemFree(chipDriver);
}
static uint8_t GetHi3881GetMaxIFCount(struct HdfChipDriverFactory *factory) { Hook the chip driver initialization function to **Build()** and the chip driver deinitialization function to **Release()**.
(void)factory;
return 1;
}
```c
/* Register WLAN chip functions. */ /* Register WLAN chip functions. */
static int32_t HDFWlanRegHisiDriverFactory(void) static int32_t HDFWlanRegHisiDriverFactory(void)
{ {
...@@ -327,35 +276,11 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial ...@@ -327,35 +276,11 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial
(void)device; (void)device;
return HDFWlanRegHisiDriverFactory(); return HDFWlanRegHisiDriverFactory();
} }
struct HdfDriverEntry g_hdfHisiChipEntry = {
.moduleVersion = 1,
.Bind = HdfWlanHisiDriverBind,
.Init = HdfWlanHisiChipDriverInit,
.Release = HdfWlanHisiChipRelease,
.moduleName = "HDF_WLAN_CHIPS"
};
HDF_INIT(g_hdfHisiChipEntry);
``` ```
For details about initialization of the chip and chip driver, see hdfinit_3881.c. The functions are as follows: - Initializing and deinitializing the chip
```c ```c
#include "hdf_wifi_product.h" /* Function for initializing the WLAN chip. */
#include "hi_wifi_api.h"
#if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
#include "oal_thread.h"
#include "osal_time.h"
#endif
#include "wifi_mac80211_ops.h"
#include "wal_cfg80211.h"
#include "net_adapter.h"
#include "hdf_wlan_utils.h"
#define HDF_LOG_TAG Hi3881Driver
/* Initialize the WLAN chip. */
int32_t InitHi3881Chip(struct HdfWlanDevice *device) int32_t InitHi3881Chip(struct HdfWlanDevice *device)
{ {
uint8_t maxPortCount = 3; uint8_t maxPortCount = 3;
...@@ -383,7 +308,7 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial ...@@ -383,7 +308,7 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial
return HI_SUCCESS; return HI_SUCCESS;
} }
/* Deinitializing the WLAN chip. */ /* Function for deinitializing the WLAN chip. */
int32_t DeinitHi3881Chip(struct HdfWlanDevice *device) int32_t DeinitHi3881Chip(struct HdfWlanDevice *device)
{ {
(void)device; (void)device;
...@@ -393,8 +318,56 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial ...@@ -393,8 +318,56 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial
} }
return ret; return ret;
} }
```
- Initializing and deinitializing the chip driver
```c
/* Hook the functions of the WLAN chip driver, mac80211, and chip. */
static struct HdfChipDriver *BuildHi3881Driver(struct HdfWlanDevice *device, uint8_t ifIndex)
{
struct HdfChipDriver *specificDriver = NULL;
if (device == NULL) {
HDF_LOGE("%s fail: channel is NULL!", __func__);
return NULL;
}
(void)ifIndex;
specificDriver = (struct HdfChipDriver *)OsalMemCalloc(sizeof(struct HdfChipDriver));
if (specificDriver == NULL) {
HDF_LOGE("%s fail: OsalMemCalloc fail!", __func__);
return NULL;
}
if (memset_s(specificDriver, sizeof(struct HdfChipDriver), 0, sizeof(struct HdfChipDriver)) != EOK) {
HDF_LOGE("%s fail: memset_s fail!", __func__);
OsalMemFree(specificDriver);
return NULL;
}
if (strcpy_s(specificDriver->name, MAX_WIFI_COMPONENT_NAME_LEN, HI3881_DRIVER_NAME) != EOK) {
HDF_LOGE("%s fail: strcpy_s fail!", __func__);
OsalMemFree(specificDriver);
return NULL;
}
specificDriver->init = Hi3881Init;
specificDriver->deinit = Hi3881Deinit;
HiMac80211Init(specificDriver);
return specificDriver;
}
/* Release the WLAN chip driver. */
static void ReleaseHi3881Driver(struct HdfChipDriver *chipDriver)
{
if (chipDriver == NULL) {
return;
}
if (strcmp(chipDriver->name, HI3881_DRIVER_NAME) != 0) {
HDF_LOGE("%s:Not my driver!", __func__);
return;
}
OsalMemFree(chipDriver);
}
/* Initializing the WLAN chip driver. */ /* Function for initializing the WLAN chip driver. */
int32_t Hi3881Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) int32_t Hi3881Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice)
{ {
hi_u16 mode; hi_u16 mode;
...@@ -427,7 +400,7 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial ...@@ -427,7 +400,7 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial
return ret; return ret;
} }
/* Deinitializing the WLAN chip driver. */ /* Function for deinitializing the WLAN chip driver. */
int32_t Hi3881Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) int32_t Hi3881Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice)
{ {
int32_t ret; int32_t ret;
...@@ -496,14 +469,9 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial ...@@ -496,14 +469,9 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial
.changeMtu = oal_net_device_change_mtu, .changeMtu = oal_net_device_change_mtu,
.init = oal_net_device_init, .init = oal_net_device_init,
.deInit = oal_net_free_netdev, .deInit = oal_net_free_netdev,
#if (defined(_PRE_WLAN_FEATURE_FLOWCTL) || defined(_PRE_WLAN_FEATURE_OFFLOAD_FLOWCTL))
.selectQueue = wal_netdev_select_queue, ...
#endif
.setMacAddr = wal_netdev_set_mac_addr,
#if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
.netifNotify = HI_NULL,
#endif
.specialEtherTypeProcess = SpecialEtherTypeProcess,
}; };
hi_s32 wal_init_netif(nl80211_iftype_uint8 type, oal_net_device_stru *netdev, const oal_wireless_dev *wdev) hi_s32 wal_init_netif(nl80211_iftype_uint8 type, oal_net_device_stru *netdev, const oal_wireless_dev *wdev)
...@@ -512,6 +480,7 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial ...@@ -512,6 +480,7 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial
hi_u32 ret = NetDeviceAdd(netdev, (Protocol80211IfType)type); hi_u32 ret = NetDeviceAdd(netdev, (Protocol80211IfType)type);
... ...
return HI_SUCCESS; return HI_SUCCESS;
} }
``` ```
...@@ -602,7 +571,9 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial ...@@ -602,7 +571,9 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial
return HI_SUCCESS; return HI_SUCCESS;
} }
``` ```
## Verification
**Verification**
Develop test cases in the WLAN module unit test to verify the basic features of the WLAN module. The following uses Hi3516D V300 standard system as an example. Develop test cases in the WLAN module unit test to verify the basic features of the WLAN module. The following uses Hi3516D V300 standard system as an example.
...@@ -735,7 +706,7 @@ Develop test cases in the WLAN module unit test to verify the basic features of ...@@ -735,7 +706,7 @@ Develop test cases in the WLAN module unit test to verify the basic features of
4. On the mobile phone, select the network named **test** in the available Wi-Fi list and enter the password. 4. On the mobile phone, select the network named **test** in the available Wi-Fi list and enter the password.
The network name and password are configured in the **hostapd.conf** file. You can see the network name in the connected Wi-Fi list if the connection is successful. The network name and password are configured in the **hostapd.conf** file. You can see that network name in the connected Wi-Fi list if the connection is successful.
5. Ping the test terminal from the development board. 5. Ping the test terminal from the development board.
...@@ -745,9 +716,13 @@ Develop test cases in the WLAN module unit test to verify the basic features of ...@@ -745,9 +716,13 @@ Develop test cases in the WLAN module unit test to verify the basic features of
In the command, xxx.xxx.xxx.xxx indicates the IP address of the test terminal. If the test terminal can be pinged, the WLAN driver provides basic features normally. In the command, xxx.xxx.xxx.xxx indicates the IP address of the test terminal. If the test terminal can be pinged, the WLAN driver provides basic features normally.
- Verify basic STA features. - Verify basic STA features.
1. Start the STA on the development board, and enable the hotspot on the test terminal. (The hotspot name and password are configured in the **hostapd.conf** file. The hotspot name is **test**, and the password is **12345678**.) 1. Start the STA on the development board, and enable the hotspot on the test terminal.
The hotspot name and password are configured in the **hostapd.conf** file. The hotspot name is **test**, and the password is **12345678**.
2. Run the following command in the **cmd** window: 2. Run the following command in the **cmd** window:
...@@ -756,6 +731,8 @@ Develop test cases in the WLAN module unit test to verify the basic features of ...@@ -756,6 +731,8 @@ Develop test cases in the WLAN module unit test to verify the basic features of
wpa_supplicant -i wlan0 -d -c wpa_supplicant.conf wpa_supplicant -i wlan0 -d -c wpa_supplicant.conf
``` ```
3. Run the following commands in another **cmd** window: 3. Run the following commands in another **cmd** window:
```shell ```shell
...@@ -764,6 +741,7 @@ Develop test cases in the WLAN module unit test to verify the basic features of ...@@ -764,6 +741,7 @@ Develop test cases in the WLAN module unit test to verify the basic features of
mount -o rw,remount /vendor mount -o rw,remount /vendor
busybox udhcpc -i wlan0 -s system/lib/dhcpc.sh busybox udhcpc -i wlan0 -s system/lib/dhcpc.sh
``` ```
The IP addresses of the board and test terminal are displayed if the command is successful. The IP addresses of the board and test terminal are displayed if the command is successful.
4. Ping the test terminal from the development board. 4. Ping the test terminal from the development board.
...@@ -772,11 +750,14 @@ Develop test cases in the WLAN module unit test to verify the basic features of ...@@ -772,11 +750,14 @@ Develop test cases in the WLAN module unit test to verify the basic features of
busybox ping xxx.xxx.xxx.xxx busybox ping xxx.xxx.xxx.xxx
``` ```
In the command, xxx.xxx.xxx.xxx indicates the IP address of the test terminal. If the test terminal can be pinged, the WLAN driver provides basic features normally. In the command, *xxx.xxx.xxx.xxx* indicates the IP address of the test terminal. If the test terminal can be pinged, the WLAN driver provides basic features normally.
3. Verify the unit test cases. #### **API Invocation**
The WLAN driver module provides two types of capability interfaces for the upper layer: HDI interface and HAL interface.
- HDI API invocation
To test a specified interface of the HDI module, perform the following steps: The following uses **GetSupportFeature** as an example to describe the development procedure:
1. Call **WlanInterfaceGetInstance()** to obtain a WLAN service instance. 1. Call **WlanInterfaceGetInstance()** to obtain a WLAN service instance.
...@@ -789,13 +770,12 @@ Develop test cases in the WLAN module unit test to verify the basic features of ...@@ -789,13 +770,12 @@ Develop test cases in the WLAN module unit test to verify the basic features of
5. Call **WlanInterfaceRelease()** to destroy the WLAN service instance. 5. Call **WlanInterfaceRelease()** to destroy the WLAN service instance.
The sample code is as follows: The sample code is as follows:
```c ```c
#include "v1_0/iwlan_interface.h" #include "v1_0/iwlan_interface.h"
#include "wlan_callback_impl.h" #include "wlan_callback_impl.h"
#include "wlan_impl.h" #include "wlan_impl.h"
#define PROTOCOL_80211_IFTYPE_NUM 11; #define PROTOCOL_80211_IFTYPE_NUM 11
#define HDF_SUCCESS 0 #define HDF_SUCCESS 0
#define HDF_FAILURE (-1) #define HDF_FAILURE (-1)
...@@ -843,7 +823,30 @@ Develop test cases in the WLAN module unit test to verify the basic features of ...@@ -843,7 +823,30 @@ Develop test cases in the WLAN module unit test to verify the basic features of
} }
return rc; return rc;
} }
```
Building:
1. Add the dependent library file to the build script.
```text
deps = [
"//drivers/peripheral/wlan/hdi_service:hdi_wlan_service",
]
```
2. Add the dependent header files to the build script.
```text
include_dirs = [
"//drivers/peripheral/wlan/interfaces/include",
"//drivers/peripheral/wlan/hdi_service",
"//drivers/peripheral/wlan/client/include",
"//drivers/peripheral/wlan/hal/include",
]
``` ```
3. Run the build script and check whether the build is successful.
- HAL API invocation
To test a specified interface of the HAL module, perform the following steps: To test a specified interface of the HAL module, perform the following steps:
...@@ -857,7 +860,7 @@ Develop test cases in the WLAN module unit test to verify the basic features of ...@@ -857,7 +860,7 @@ Develop test cases in the WLAN module unit test to verify the basic features of
5. Call **destroyFeature()** to destroy the **apFeature** instance. 5. Call **destroyFeature()** to destroy the **apFeature** instance.
6. Call **stop()** to destroy the channel between the HAL and the driver. 6. Call **Stop()** to destroy the channel between the HAL and the driver.
7. Call **WifiDestruct()** to destroy the **IWiFi** instance. 7. Call **WifiDestruct()** to destroy the **IWiFi** instance.
...@@ -868,18 +871,16 @@ Develop test cases in the WLAN module unit test to verify the basic features of ...@@ -868,18 +871,16 @@ Develop test cases in the WLAN module unit test to verify the basic features of
#include "wifi_hal_sta_feature.h" #include "wifi_hal_sta_feature.h"
#include "wifi_hal_ap_feature.h" #include "wifi_hal_ap_feature.h"
#include "wifi_hal_cmd.h" #include "wifi_hal_cmd.h"
#include "wifi_hal_event.h"
#define MAC_LEN 6 #define MAC_LEN 6
#define HDF_SUCCESS 0 #define HDF_SUCCESS 0
#define HDF_FAILURE (-1) #define HDF_FAILURE (-1)
```
static int32_t hal_main() static int32_t hal_main()
{ {
int32_t ret; int32_t ret;
struct IWiFi *wifi; struct IWiFi *wifi;
struct IWiFiAp *apFeature;
/* Create an IWiFi instance. */ /* Create an IWiFi instance. */
ret = WifiConstruct(&wifi); ret = WifiConstruct(&wifi);
...@@ -926,26 +927,29 @@ Develop test cases in the WLAN module unit test to verify the basic features of ...@@ -926,26 +927,29 @@ Develop test cases in the WLAN module unit test to verify the basic features of
return ret; return ret;
} }
``` ```
Building:
1. Add the dependent library file to the build script.
4. Verify the test cases. ```text
1. Push the test cases to the development board. deps = [
"//drivers/peripheral/wlan/client:wifi_driver_client",
```shell "//drivers/peripheral/wlan/hal:wifi_hal",
hdc file send /xxx /data ]
``` ```
In the command, xxx indicates the path of the test cases of the development board. 2. Add the dependent header files to the build script.
```text
include_dirs = [
"//drivers/peripheral/wlan/interfaces/include",
"//drivers/peripheral/wlan/hdi_service",
"//drivers/peripheral/wlan/client/include",
"//drivers/peripheral/wlan/hal/include",
]
```
3. Run the build script and check whether the build is successful.
2. Modify the permissions on the test cases and execute the test cases.
```shell
hdc shell
cd data
chmod 777 Test_case_name
./ Test case name.
```
3. Check the test case execution result.
## Reference ## Reference
...@@ -959,34 +963,19 @@ Develop test cases in the WLAN module unit test to verify the basic features of ...@@ -959,34 +963,19 @@ Develop test cases in the WLAN module unit test to verify the basic features of
- Code paths: - Code paths:
- Adaptation of WLAN FlowCtl component on LiteOS: - Adaptation of WLAN FlowCtl component on LiteOS: **//drivers/hdf_core/adapter/khdf/liteos/model/network/wifi**
- Adaptation of HDF network model on LiteOS: **//drivers/hdf_core/adapter/khdf/liteos/model/network**
**//drivers/hdf_core/adapter/khdf/liteos/model/network/wifi**
- Adaptation of HDF network model on LiteOS:
**//drivers/hdf_core/adapter/khdf/liteos/model/network**
- Adaptation of WLAN FlowCtl component on Linux, build of the HDF WLAN model, and build of the vendor's WLAN driver:
**//drivers/hdf_core/adapter/khdf/linux/model/network/wifi**
- Core code for implementing the WLAN module:
**//drivers/hdf_core/framework/model/network/wifi** - Adaptation of WLAN FlowCtl component on Linux, build of the HDF WLAN model, and build of the vendor's WLAN driver: **//drivers/hdf_core/adapter/khdf/linux/model/network/wifi**
- Core code for implementing the WLAN module: **//drivers/hdf_core/framework/model/network/wifi**
- External APIs of the WLAN module: **//drivers/hdf_core/framework/include/wifi**
- HDF network model APIs: **//drivers/hdf_core/framework/include/net**
- WLAN HDI server implementation: **//drivers/peripheral/wlan**
- External APIs of the WLAN module:
**//drivers/hdf_core/framework/include/wifi**
- HDF network model APIs:
**//drivers/hdf_core/framework/include/net**
- WLAN HDI server implementation:
**//drivers/peripheral/wlan**
- External APIs of the WLAN HDI:
**//out/{product_name}/gen/drivers/interface/wlan/v1_0**
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册