提交 207d3bb2 编写于 作者: “wangyanzhen” 提交者: wangyanzhen

fix:optimize wlan docs

Signed-off-by: N“wangyanzhen” <wangyanzhen4@huawei.com>
上级 899ef1b5
...@@ -29,7 +29,7 @@ WLAN框架如图1所示,其中WLAN Driver模块主要提供启动加载、配 ...@@ -29,7 +29,7 @@ WLAN框架如图1所示,其中WLAN Driver模块主要提供启动加载、配
WLAN Driver框架主要由如下模块组成: WLAN Driver框架主要由如下模块组成:
1. WLAN Message:该部件为每个服务单独提供业务接口,每个服务也可依赖其他服务形成组合业务接口,此模块支持在用户态、内核态和MCU环境运行,实现件间的充分解耦。 1. WLAN Message:该部件为每个服务单独提供业务接口,每个服务也可依赖其他服务形成组合业务接口,此模块支持在用户态、内核态和MCU环境运行,实现件间的充分解耦。
2. WLAN Configuration Core:WLAN相关的配置文件进行解析。 2. WLAN Configuration Core:WLAN相关的配置文件进行解析。
...@@ -45,7 +45,7 @@ WLAN Driver框架主要由如下模块组成: ...@@ -45,7 +45,7 @@ WLAN Driver框架主要由如下模块组成:
8. NetBuf:该部件为WLAN驱动提供Linux或者LiteOS原生的网络数据缓冲的统一数据结构的封装以及对网络数据的操作接口的封装。 8. NetBuf:该部件为WLAN驱动提供Linux或者LiteOS原生的网络数据缓冲的统一数据结构的封装以及对网络数据的操作接口的封装。
9. FlowCtl:流控模块。 9. FlowCtl:流控模块,当数据量过大时按照优先级策略处理数据
10. HCC-CFG:WLAN相关参数配置其中包括板级配置、驱动配置、Module配置。 10. HCC-CFG:WLAN相关参数配置其中包括板级配置、驱动配置、Module配置。
...@@ -75,20 +75,10 @@ WLAN模块有三部分对外开放的API接口,如下图所示: ...@@ -75,20 +75,10 @@ WLAN模块有三部分对外开放的API接口,如下图所示:
![image](figures/WLAN驱动接口框架图.png "WLAN驱动接口框架图") ![image](figures/WLAN驱动接口框架图.png "WLAN驱动接口框架图")
- WLAN驱动模块对上层服务提供的HDI能力接口(适用于标准系统),主要功能有:创建/销毁ifeature对象、设置/获取功率模式等。提供的部分接口说明如表1所示:
**表1** IWlanInterface.idl
| 接口名称 | 功能描述 |
| -------- | -------- |
| CreateFeature([in]&nbsp;int&nbsp;type,&nbsp;[out]&nbsp;struct&nbsp;HdfFeatureInfo&nbsp;ifeature); | 创建ifeature对象。 |
| DestroyFeature([in]&nbsp;struct&nbsp;HdfFeatureInfo&nbsp;ifeature); | 销毁ifeature对象。 |
| GetPowerMode([in]&nbsp;struct&nbsp;HdfFeatureInfo&nbsp;ifeature,&nbsp;[out]&nbsp;unsigned&nbsp;char&nbsp;mode); | 获取功率模式。 |
| SetPowerMode([in]&nbsp;struct&nbsp;HdfFeatureInfo&nbsp;ifeature,&nbsp;[in]&nbsp;unsigned&nbsp;char&nbsp;mode); | 设置功率模式。 |
- WLAN驱动模块对上层服务提供的HAL能力接口(适用于小型系统及轻量系统),主要功能有:创建/销毁 IWiFi对象、设置MAC地址等。提供的部分接口说明如表2、表3所示: - WLAN驱动模块对上层服务提供的HAL能力接口(适用于小型系统及轻量系统),主要功能有:创建/销毁 IWiFi对象、设置MAC地址等。提供的部分接口说明如表2、表3所示:
**表2** wifi_hal.h **表1** wifi_hal.h
| 接口名称 | 功能描述 | | 接口名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
...@@ -97,7 +87,7 @@ WLAN模块有三部分对外开放的API接口,如下图所示: ...@@ -97,7 +87,7 @@ WLAN模块有三部分对外开放的API接口,如下图所示:
| int32_t&nbsp;(\*start)(struct&nbsp;IWiFi&nbsp;\*) | 创建HAL和驱动之间的通道及获取驱动支持的网卡信息。 | | int32_t&nbsp;(\*start)(struct&nbsp;IWiFi&nbsp;\*) | 创建HAL和驱动之间的通道及获取驱动支持的网卡信息。 |
| int32_t&nbsp;(\*stop)(struct&nbsp;IWiFi&nbsp;\*) | 销毁通道。 | | int32_t&nbsp;(\*stop)(struct&nbsp;IWiFi&nbsp;\*) | 销毁通道。 |
**表3** wifi_hal_base_feature.h **表2** wifi_hal_base_feature.h
| 接口名称 | 功能描述 | | 接口名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
...@@ -108,7 +98,7 @@ WLAN模块有三部分对外开放的API接口,如下图所示: ...@@ -108,7 +98,7 @@ WLAN模块有三部分对外开放的API接口,如下图所示:
- WLAN驱动模块也提供了需要驱动开发人员自行去填充具体实现内容的能力接口,主要功能有:初始化/注销NetDevice、打开/关闭NetDevice、获取NetDevice的状态等。提供的部分接口说明如表4所示: - WLAN驱动模块也提供了需要驱动开发人员自行去填充具体实现内容的能力接口,主要功能有:初始化/注销NetDevice、打开/关闭NetDevice、获取NetDevice的状态等。提供的部分接口说明如表4所示:
**表4** net_device.h **表3** net_device.h
| 接口名称 | 功能描述 | | 接口名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
...@@ -123,7 +113,7 @@ WLAN模块有三部分对外开放的API接口,如下图所示: ...@@ -123,7 +113,7 @@ WLAN模块有三部分对外开放的API接口,如下图所示:
可直接调用的接口如表5、表6和表7所示。 可直接调用的接口如表5、表6和表7所示。
**表5** wifi_module.h **表4** wifi_module.h
| 接口名称 | 功能描述 | | 接口名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
...@@ -132,7 +122,7 @@ WLAN模块有三部分对外开放的API接口,如下图所示: ...@@ -132,7 +122,7 @@ WLAN模块有三部分对外开放的API接口,如下图所示:
| int32_t&nbsp;DelFeature(struct&nbsp;WifiModule&nbsp;\*module,&nbsp;uint16_t&nbsp;featureType) | 基于HDF开发WLAN驱动时,从WifiModule删除一个功能组件。 | | int32_t&nbsp;DelFeature(struct&nbsp;WifiModule&nbsp;\*module,&nbsp;uint16_t&nbsp;featureType) | 基于HDF开发WLAN驱动时,从WifiModule删除一个功能组件。 |
| int32_t&nbsp;AddFeature(struct&nbsp;WifiModule&nbsp;\*module,&nbsp;uint16_t&nbsp;featureType,<br>&nbsp;struct&nbsp;WifiFeature&nbsp;\*featureData) | 基于HDF开发WLAN驱动时,注册一个功能组件到WifiModule。 | | int32_t&nbsp;AddFeature(struct&nbsp;WifiModule&nbsp;\*module,&nbsp;uint16_t&nbsp;featureType,<br>&nbsp;struct&nbsp;WifiFeature&nbsp;\*featureData) | 基于HDF开发WLAN驱动时,注册一个功能组件到WifiModule。 |
**表6** wifi_mac80211_ops.h **表5** wifi_mac80211_ops.h
| 接口名称 | 功能描述 | | 接口名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
...@@ -141,36 +131,47 @@ WLAN模块有三部分对外开放的API接口,如下图所示: ...@@ -141,36 +131,47 @@ WLAN模块有三部分对外开放的API接口,如下图所示:
| int32_t&nbsp;(\*connect)(NetDevice&nbsp;\*netDev,&nbsp;WifiConnectParams&nbsp;\*param) | 开始关联。 | | int32_t&nbsp;(\*connect)(NetDevice&nbsp;\*netDev,&nbsp;WifiConnectParams&nbsp;\*param) | 开始关联。 |
| int32_t&nbsp;(\*disconnect)(NetDevice&nbsp;\*netDev,&nbsp;uint16_t&nbsp;reasonCode) | 取消关联。 | | int32_t&nbsp;(\*disconnect)(NetDevice&nbsp;\*netDev,&nbsp;uint16_t&nbsp;reasonCode) | 取消关联。 |
**表7** hdf_netbuf.h **表6** hdf_netbuf.h
| 接口名称 | 功能描述 | | 接口名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
| static&nbsp;inline&nbsp;void&nbsp;NetBufQueueInit(struct&nbsp;NetBufQueue&nbsp;\*q) | 初始化NetBuf队列。 | | static&nbsp;inline&nbsp;void&nbsp;NetBufQueueInit(struct&nbsp;NetBufQueue&nbsp;\*q) | 初始化NetBuf队列。 |
| struct&nbsp;NetBuf&nbsp;\*NetBufAlloc(uint32_t&nbsp;size) | 申请NetBuf。 | | struct&nbsp;NetBuf&nbsp;\*NetBufAlloc(uint32_t&nbsp;size) | 申请NetBuf。 |
| void&nbsp;NetBufFree(struct&nbsp;NetBuf&nbsp;\*nb) | 释放NetBuf | | void&nbsp;NetBufFree(struct&nbsp;NetBuf&nbsp;\*nb) | 释放NetBuf |
| struct&nbsp;NetBuf&nbsp;\*Pbuf2NetBuf(const&nbsp;struct&nbsp;NetDevice&nbsp;\*netdev,&nbsp;struct&nbsp;pbuf&nbsp;\*lwipBuf) | lwip的pbuf转换为NetBuf。 | | struct&nbsp;NetBuf&nbsp;\*Pbuf2NetBuf(const&nbsp;struct&nbsp;NetDevice&nbsp;\*netdev,&nbsp;struct&nbsp;pbuf&nbsp;\*lwipBuf) | lwip的pbuf转换为NetBuf。 |
| struct&nbsp;pbuf&nbsp;\*NetBuf2Pbuf(const&nbsp;struct&nbsp;NetBuf&nbsp;\*nb) | NetBuf转换为lwip的pbuf。 | | struct&nbsp;pbuf&nbsp;\*NetBuf2Pbuf(const&nbsp;struct&nbsp;NetBuf&nbsp;\*nb) | NetBuf转换为lwip的pbuf。 |
### 开发步骤 ### 开发步骤
#### 厂商适配WLAN框架
WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,为不同厂商的WLAN模组提供统一的驱动模型,各WLAN模组厂商根据如下开发流程适配WLAN驱动框架。
WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,为不同厂商的WLAN模组提供统一的驱动模型,各WLAN模组厂商根据如下指导适配WLAN驱动框架。 **开发流程**
1. 配置硬件(例如module、芯片等)相关的参数。在wlan_platform.hcs文件中对参数进行配置,该文件会通过HDF框架中对应的接口解析后,生成全量配置的结构体对象。 1. 配置硬件(例如module、芯片等)相关的参数。wlan_platform.hcs文件中对参数进行配置后,HDF框架会对该文件进行解析,并生成全量配置的结构体对象。
2. 初始化和去初始化WLAN模块相关适配(如WLAN芯片初始化和去初始化、WLAN芯片驱动初始化和去初始化)。 2. 初始化和去初始化WLAN模块相关适配(如WLAN芯片初始化和去初始化、WLAN芯片驱动初始化和去初始化)。
3. 控制流命令下发的适配。 3. 控制流命令下发的适配。
4. 事件上报的调用。 4. 事件上报的调用。
### 开发实例 **开发实例**
本例程提供WLAN模块初始化过程的完整使用流程。示例如下(以Hi3881WLAN芯片为例): 本例程提供WLAN模块初始化过程的完整使用流程。示例如下(以Hi3881WLAN芯片为例):
1. 根据硬件具体情况修改配置参数 1. Driver的HCS配置
HCS文件配置包括:device相关配置和组件配置。
- device相关配置
配置文件内容包括:电源配置、复位配置和总线配置。
配置文件路径:vendor/<厂商名>/<设备名>/hdf_config/khdf/wifi。
根据硬件具体情况,在wlan_platform.hcs中配置相关参数,以下是WLAN平台配置的示例:
```text ```text
/* 根据硬件具体情况,在wlan_platform.hcs中配置相关参数,以下是WLAN平台配置的示例 */
hisi :& deviceList { hisi :& deviceList {
device0 :: deviceInst { device0 :: deviceInst {
deviceInstId = 0; deviceInstId = 0;
...@@ -203,7 +204,11 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -203,7 +204,11 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
} }
} }
} }
/* 每一块芯片添加配置文件wlan_chip_<芯片名>.hcs(如:wlan_chip_hi3881.hcs),配置相关参数。以下是hi3881的配置示例 */ ```
- 组件配置
每一块芯片添加配置文件wlan_chip_<芯片名>.hcs(如:wlan_chip_hi3881.hcs),配置相关参数。以下是hi3881的配置示例:
```text
root { root {
wlan_config { wlan_config {
hi3881 :& chipList { hi3881 :& chipList {
...@@ -220,85 +225,30 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -220,85 +225,30 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
} }
``` ```
2. 适配挂接WLAN芯片的初始化和去初始化、WLAN芯片驱动的初始化和去初始化。 2. 驱动适配挂接WLAN芯片的初始化和去初始化、WLAN芯片驱动的初始化和去初始化。
- 驱动适配入口函数实现
根据各自的芯片定义一个HdfDriverEntry类型的变量,主要实现Bind、Init、Release接口的函数挂接。调用HDF_INIT将驱动入口注册到HDF框架中,在加载驱动时HDF框架会先调用Bind函数,再调用Init函数加载该驱动。当Init调用异常时,HDF框架会调用Release释放驱动资源。
```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
/* WLAN芯片的初始化和去初始化函数。 */
int32_t InitHi3881Chip(struct HdfWlanDevice *device);
int32_t DeinitHi3881Chip(struct HdfWlanDevice *device);
/* WLAN芯片驱动的初始化和去初始化函数。 */
int32_t Hi3881Deinit(struct HdfChipDriver* chipDriver, struct NetDevice *netDevice);
int32_t Hi3881Init(struct HdfChipDriver* chipDriver, struct NetDevice *netDevice);
/* 初始化Mac80211与芯片侧的函数挂接。 */
hi_void HiMac80211Init(struct HdfChipDriver *chipDriver);
static const char* const HI3881_DRIVER_NAME = "hisi";
/* WLAN芯片驱动挂接以及Mac80211与芯片侧的函数挂接。 */
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; - 芯片初始化,芯片驱动初始化函数的注册
}
/* 释放WLAN芯片驱动。 */ InitChip/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) { Build/Release接口挂接芯片驱动的初始化、去初始化函数实现。
(void)factory;
return 1;
}
/* WLAN芯片相关函数的注册。 */ ```c
/* WLAN芯片相关函数的注册 */
static int32_t HDFWlanRegHisiDriverFactory(void) static int32_t HDFWlanRegHisiDriverFactory(void)
{ {
static struct HdfChipDriverFactory tmpFactory = { 0 }; static struct HdfChipDriverFactory tmpFactory = { 0 };
...@@ -328,35 +278,11 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -328,35 +278,11 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
(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);
``` ```
芯片初始化和芯片驱动初始化相关内容详见hdfinit_3881.c,具体函数分解如下: - 芯片的初始化和去初始化
```c ```c
#include "hdf_wifi_product.h" /* WLAN芯片的初始化函数 */
#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
/* WLAN芯片的初始化函数。 */
int32_t InitHi3881Chip(struct HdfWlanDevice *device) int32_t InitHi3881Chip(struct HdfWlanDevice *device)
{ {
uint8_t maxPortCount = 3; uint8_t maxPortCount = 3;
...@@ -384,7 +310,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -384,7 +310,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
return HI_SUCCESS; return HI_SUCCESS;
} }
/* WLAN芯片的去初始化函数。 */ /* WLAN芯片的去初始化函数 */
int32_t DeinitHi3881Chip(struct HdfWlanDevice *device) int32_t DeinitHi3881Chip(struct HdfWlanDevice *device)
{ {
(void)device; (void)device;
...@@ -394,8 +320,56 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -394,8 +320,56 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
} }
return ret; return ret;
} }
```
- 芯片驱动的初始化和去初始化
```c
/* WLAN芯片驱动挂接以及Mac80211与芯片侧的函数挂接 */
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;
}
/* WLAN芯片驱动的初始化函数。 */ /* 释放WLAN芯片驱动 */
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);
}
/* WLAN芯片驱动的初始化函数 */
int32_t Hi3881Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) int32_t Hi3881Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice)
{ {
hi_u16 mode; hi_u16 mode;
...@@ -428,7 +402,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -428,7 +402,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
return ret; return ret;
} }
/* WLAN芯片驱动的去初始化函数。 */ /* WLAN芯片驱动的去初始化函数 */
int32_t Hi3881Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) int32_t Hi3881Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice)
{ {
int32_t ret; int32_t ret;
...@@ -443,7 +417,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -443,7 +417,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
``` ```
在芯片侧初始化过程中调用netdev的init和add接口进行初始化netdev,并挂接netdev的一些函数指针。 在芯片驱动初始化过程中调用netdev的init和add接口进行初始化netdev,并挂接netdev的一些函数指针。
```c ```c
hi_s32 wal_init_drv_wlan_netdev(nl80211_iftype_uint8 type, wal_phy_mode mode, oal_net_device_stru *netdev) hi_s32 wal_init_drv_wlan_netdev(nl80211_iftype_uint8 type, wal_phy_mode mode, oal_net_device_stru *netdev)
...@@ -486,7 +460,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -486,7 +460,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
return HI_SUCCESS; return HI_SUCCESS;
} }
/* 挂接netdev的一些函数指针,详细挂接函数请参考NetDeviceInterFace。 */ /* 挂接netdev的一些函数指针,详细挂接函数请参考NetDeviceInterFace */
oal_net_device_ops_stru g_wal_net_dev_ops = oal_net_device_ops_stru g_wal_net_dev_ops =
{ {
.getStats = wal_netdev_get_stats, .getStats = wal_netdev_get_stats,
...@@ -497,19 +471,14 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -497,19 +471,14 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
.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)
{ {
/* 添加网络设备到协议栈。 */ /* 添加网络设备到协议栈 */
hi_u32 ret = NetDeviceAdd(netdev, (Protocol80211IfType)type); hi_u32 ret = NetDeviceAdd(netdev, (Protocol80211IfType)type);
...... ......
...@@ -521,7 +490,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -521,7 +490,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
3. 命令下发绑定,包括具有公共能力的设置MAC地址、设置发射功率等;STA相关的连接、扫描等;AP相关的启动AP、设置国家码等。 3. 命令下发绑定,包括具有公共能力的设置MAC地址、设置发射功率等;STA相关的连接、扫描等;AP相关的启动AP、设置国家码等。
```c ```c
/* 驱动需要实现的MAC层基本能力的控制接口 */ /* 驱动需要实现的MAC层基本能力的控制接口 */
static struct HdfMac80211BaseOps g_baseOps = { static struct HdfMac80211BaseOps g_baseOps = {
.SetMode = WalSetMode, .SetMode = WalSetMode,
.AddKey = WalAddKey, .AddKey = WalAddKey,
...@@ -534,7 +503,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -534,7 +503,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
.GetHwCapability = WalGetHwCapability .GetHwCapability = WalGetHwCapability
}; };
/* 驱动需要实现的MAC层STA能力的控制接口 */ /* 驱动需要实现的MAC层STA能力的控制接口 */
static struct HdfMac80211STAOps g_staOps = { static struct HdfMac80211STAOps g_staOps = {
.Connect = WalConnect, .Connect = WalConnect,
.Disconnect = WalDisconnect, .Disconnect = WalDisconnect,
...@@ -543,7 +512,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -543,7 +512,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
.SetScanningMacAddress = WalSetScanningMacAddress, .SetScanningMacAddress = WalSetScanningMacAddress,
}; };
/* 驱动需要实现的MAC层AP能力的控制接口 */ /* 驱动需要实现的MAC层AP能力的控制接口 */
static struct HdfMac80211APOps g_apOps = { static struct HdfMac80211APOps g_apOps = {
.ConfigAp = WalConfigAp, .ConfigAp = WalConfigAp,
.StartAp = WalStartAp, .StartAp = WalStartAp,
...@@ -565,7 +534,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -565,7 +534,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
.GetDriverFlag = WalGetDriverFlag .GetDriverFlag = WalGetDriverFlag
}; };
/* 初始化Mac80211与芯片侧的函数挂接 */ /* 初始化Mac80211与芯片侧的函数挂接 */
void HiMac80211Init(struct HdfChipDriver *chipDriver) void HiMac80211Init(struct HdfChipDriver *chipDriver)
{ {
if (chipDriver == NULL) { if (chipDriver == NULL) {
...@@ -600,7 +569,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -600,7 +569,7 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
return HI_SUCCESS; return HI_SUCCESS;
} }
``` ```
## 调测验证 **调测验证**
驱动开发完成后,在WLAN模块单元测试里面开发自测试用例以及验证WLAN模块基本功能。测试环境采用开发者自测试平台(这里以Hi3516DV300标准系统为例)。 驱动开发完成后,在WLAN模块单元测试里面开发自测试用例以及验证WLAN模块基本功能。测试环境采用开发者自测试平台(这里以Hi3516DV300标准系统为例)。
...@@ -770,28 +739,29 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -770,28 +739,29 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
上述xxx.xxx.xxx.xxx为当前测试终端的IP地址,若测试能够ping通测试终端则表示,WLAN驱动基本功能正常。 上述xxx.xxx.xxx.xxx为当前测试终端的IP地址,若测试能够ping通测试终端则表示,WLAN驱动基本功能正常。
3. 验证单元测试用例 #### 接口调用
WLAN驱动模块向上层提供两种能力接口:HDI接口和HAL接口。
HDI模块用例开发步骤(需要测试HDI模块指定接口时,可采用下列步骤): - HDI接口调用
- 使用WlanInterfaceGetInstance获取WLAN服务对象。 HDI接口调用开发步骤(以GetSupportFeature为例):
- 使用Start创建HAL和驱动之间的通道及获取驱动网卡信息 1. 使用WlanInterfaceGetInstance获取WLAN服务对象
- 通过GetSupportFeature获取该设备支持的WLAN特性 2. 使用Start创建HAL和驱动之间的通道及获取驱动网卡信息
- 调用Stop,销毁HAL和驱动之间的通道 3. 通过GetSupportFeature获取该设备支持的WLAN特性
- 执行WlanInterfaceRelease销毁WLAN服务对象 4. 调用Stop,销毁HAL和驱动之间的通道
HDI模块用例开发实例: 5. 执行WlanInterfaceRelease销毁WLAN服务对象。
HDI接口调用开发实例:
```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)
...@@ -839,42 +809,64 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -839,42 +809,64 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
} }
return rc; return rc;
} }
``` ```
HAL模块用例开发步骤(需要测试HAL模块指定接口时,可采用下列步骤): HDI接口调用编译:
1. 编译脚本中添加依赖的库文件:
```text
deps = [
"//drivers/peripheral/wlan/hdi_service:hdi_wlan_service",
]
```
2. 编译脚本中添加依赖的头文件:
```text
include_dirs = [
"//drivers/peripheral/wlan/interfaces/include",
"//drivers/peripheral/wlan/hdi_service",
"//drivers/peripheral/wlan/client/include",
"//drivers/peripheral/wlan/hal/include",
]
```
3. 执行编译脚本,确认是否编译OK。
- HAL接口调用
HAL接口调用开发步骤(需要测试HAL模块指定接口时,可采用下列步骤):
- 使用WifiConstruct创建一个WiFi实体。 1. 使用WifiConstruct创建一个WiFi实体。
- 用创建的WiFi实体调用start开启HAL和驱动之间的通道,获得驱动网卡的信息。 2. 用创建的WiFi实体调用start开启HAL和驱动之间的通道,获得驱动网卡的信息。
- 通过createFeature创建一个apFeature或者staFeature。后面可通过这些Feature去调用具体的实现接口,下面基于创建的apFeature为例进行介绍。 3. 通过createFeature创建一个apFeature或者staFeature。后面可通过这些Feature去调用具体的实现接口,下面基于创建的apFeature为例进行介绍。
- 调用和使用相关接口:如setMacAddress设置MAC地址、getDeviceMacAddress获取设备的MAC地址等。 4. 调用和使用相关接口:如setMacAddress设置MAC地址、getDeviceMacAddress获取设备的MAC地址等。
- 调用destroyFeature,销毁掉创建的apFeature。 5. 调用destroyFeature,销毁掉创建的apFeature。
- 调用stop销毁创建的通道。 6. 调用stop销毁创建的通道。
- 执行WifiDestruct销毁创建的WiFi实体。 7. 执行WifiDestruct销毁创建的WiFi实体。
HAL模块用例开发实例: HAL接口调用开发实例:
```c ```c
#include "wifi_hal.h" #include "wifi_hal.h"
#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;
/* 创建一个wifi实体。 */ /* 创建一个wifi实体。 */
ret = WifiConstruct(&wifi); ret = WifiConstruct(&wifi);
...@@ -921,26 +913,29 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -921,26 +913,29 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
return ret; return ret;
} }
``` ```
HAL接口调用编译:
1. 编译脚本中添加依赖的库文件:
4. 验证测试用例方法如下 ```text
1. 将测试用例推送到单板。 deps = [
"//drivers/peripheral/wlan/client:wifi_driver_client",
```shell "//drivers/peripheral/wlan/hal:wifi_hal",
hdc file send /xxx /data ]
``` ```
xxx表示需要推送到单板根目录的测试用例路径。 2. 编译脚本中添加依赖的头文件:
```text
include_dirs = [
"//drivers/peripheral/wlan/interfaces/include",
"//drivers/peripheral/wlan/hdi_service",
"//drivers/peripheral/wlan/client/include",
"//drivers/peripheral/wlan/hal/include",
]
```
3. 执行编译脚本,确认是否编译OK。
2. 修改测试用例权限并执行该用例。
```shell
hdc shell
cd data
chmod 777 测试用例名称
./测试用例名称
```
查看测试用例执行结果是否正确。
## 参考 ## 参考
...@@ -970,4 +965,3 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台, ...@@ -970,4 +965,3 @@ WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,
WLAN HDI服务端实现://drivers/peripheral/wlan WLAN HDI服务端实现://drivers/peripheral/wlan
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.
先完成此消息的编辑!
想要评论请 注册