1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 /** 10 * @addtogroup WLAN 11 * @{ 12 * 13 * @brief Provides cross-OS migration, component adaptation, and modular assembly and compilation. 14 * 15 * Based on the unified APIs provided by the WLAN module, developers of the Hardware Driver Interface 16 * (HDI) are capable of creating, disabling, scanning for, and connecting to WLAN hotspots, managing WLAN chips, 17 * network devices, and power, and applying for, releasing, and moving network data buffers. 18 * 19 * @since 1.0 20 * @version 1.0 21 */ 22 23 /** 24 * @file hdf_wlan_chipdriver_manager.h 25 * 26 * @brief Declares data structures and functions of the WLAN chip driver manager. 27 * 28 * @since 1.0 29 * @version 1.0 30 */ 31 32 #ifndef HDF_WLAN_CHIPDRIVER_MANGER_H 33 #define HDF_WLAN_CHIPDRIVER_MANGER_H 34 #include "hdf_wifi_product.h" 35 #include "hdf_wlan_power_manager.h" 36 #include "hdf_wlan_reset_manager.h" 37 #include "wifi_module.h" 38 39 /** 40 * @brief Indicates the maximum number of chip drivers. 41 * 42 * @since 1.0 43 * @version 1.0 44 */ 45 #define MAX_CHIPDRIVER_COUNT 16 46 47 /** 48 * @brief Indicates the maximum number of WLAN chip driver managers. 49 * 50 * @since 1.0 51 * @version 1.0 52 */ 53 #define HDF_WLAN_MAX_MANAGER_COUNT 8 54 55 /** 56 * @brief Describes WLAN device data. 57 * 58 * @since 1.0 59 * @version 1.0 60 */ 61 struct HdfWifiNetDeviceData { 62 uint8_t netInterfaceId; /**< Network interface ID */ 63 struct HdfChipDriver *chipDriver; /**< Chip driver */ 64 struct HdfWlanDevice *device; /**< WLAN device */ 65 }; 66 67 /** 68 * @brief Describes the <b>HdfChipDriverFactory</b> instance and provides functions such as initializing and 69 * deinitializing a chip, and obtaining the maximum number of interfaces. 70 * 71 * @since 1.0 72 * @version 1.0 73 */ 74 struct HdfChipDriverFactory { 75 const char *driverName; /**< Driver name */ 76 77 /** 78 * @brief Initializes a specified chip. 79 * 80 * @param device Indicates the pointer to the WLAN device where the chip resides. 81 * @return Returns <b>0</b> if the chip is initialized; returns a negative value otherwise. 82 * 83 * @since 1.0 84 * @version 1.0 85 */ 86 int32_t (*InitChip)(struct HdfWlanDevice *device); 87 88 /** 89 * @brief Deinitializes a specified chip. 90 * 91 * @param device Indicates the pointer to the WLAN device where the chip resides. 92 * @return Returns <b>0</b> if the chip is deinitialized; returns a negative value otherwise. 93 * 94 * @since 1.0 95 * @version 1.0 96 */ 97 int32_t (*DeinitChip)(struct HdfWlanDevice *device); 98 99 /** 100 * @brief Releases a specified <b>HdfChipDriverFactory</b> instance. 101 * 102 * @param factory Indicates the pointer to the <b>HdfChipDriverFactory</b> instance. 103 * 104 * @since 1.0 105 * @version 1.0 106 */ 107 void (*ReleaseFactory)(struct HdfChipDriverFactory *factory); 108 109 /** 110 * @brief Creates a <b>HdfChipDriver</b> instance with the initialization and deinitialization functions. 111 * 112 * @param device Indicates the pointer to the WLAN device. 113 * @param ifIndex Indicates the interface index. 114 * @return Returns the pointer to the <b>HdfChipDriver</b> instance. 115 * 116 * @since 1.0 117 * @version 1.0 118 */ 119 struct HdfChipDriver *(*Build)(struct HdfWlanDevice *device, uint8_t ifIndex); 120 121 /** 122 * @brief Releases a specified <b>HdfChipDriver</b> instance. 123 * 124 * @param chipDriver Indicates the pointer to the <b>HdfChipDriver</b> instance. 125 * 126 * @since 1.0 127 * @version 1.0 128 */ 129 void (*Release)(struct HdfChipDriver *chipDriver); 130 131 /** 132 * @brief Obtains the maximum number of interfaces of a specified <b>HdfChipDriverFactory</b> instance. 133 * 134 * @param factory Indicates the pointer to the <b>HdfChipDriverFactory</b> instance. 135 * @return Returns the maximum number of interfaces. 136 * 137 * @since 1.0 138 * @version 1.0 139 */ 140 uint8_t (*GetMaxIFCount)(struct HdfChipDriverFactory *factory); 141 }; 142 143 /** 144 * @brief Manages chip drivers. 145 * 146 * @since 1.0 147 * @version 1.0 148 */ 149 struct HdfChipDriverManager { 150 struct HdfChipDriverFactory **chipFactoryInsts; /**< <b>HdfChipDriverFactory</b> instances */ 151 152 /** 153 * @brief Registers a chip driver. 154 * 155 * @param factoryInst Indicates the pointer to the <b>HdfChipDriverFactory</b> instance. 156 * @return Returns <b>0</b> if the chip driver is registered; returns a negative value otherwise. 157 * 158 * @since 1.0 159 * @version 1.0 160 */ 161 int32_t (*RegChipDriver)(struct HdfChipDriverFactory *factoryInst); 162 163 /** 164 * @brief Obtains the chip driver based on the network device name. 165 * 166 * @param name Indicates the pointer to the network device name. 167 * @return Returns the pointer to the <b>HdfChipDriverFactory</b> instance. 168 * 169 * @since 1.0 170 * @version 1.0 171 */ 172 struct HdfChipDriverFactory *(*GetChipDriverByName)(const char *name); 173 }; 174 175 /** 176 * @brief Obtains an <b>HdfChipDriverManager</b> instance. 177 * 178 * @return Returns the pointer to the <b>HdfChipDriverManager</b> instance. 179 * 180 * @since 1.0 181 * @version 1.0 182 */ 183 struct HdfChipDriverManager *HdfWlanGetChipDriverMgr(void); 184 185 /** 186 * @brief Deinitializes an <b>HdfChipDriverManager</b> instance. 187 * 188 * @return Returns <b>0</b> if the <b>HdfChipDriverManager</b> instance is deinitialized; returns a 189 * negative value otherwise. 190 * 191 * @since 1.0 192 * @version 1.0 193 */ 194 int32_t ChipDriverMgrDeInit(void); 195 196 #endif 197 /** @} */ 198