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_wifi_product.h
25  *
26  * @brief Declares the data structure of the WLAN module.
27  *
28  * @since 1.0
29  * @version 1.0
30  */
31 
32 #ifndef HDFLITE_HDF_WIFI_PRODUCT_H
33 #define HDFLITE_HDF_WIFI_PRODUCT_H
34 
35 #include "hdf_device_desc.h"
36 #include "hdf_wlan_config.h"
37 #include "hdf_wlan_power_manager.h"
38 #include "hdf_wlan_reset_manager.h"
39 #include "hdf_ibus_intf.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /**
46  * @brief Defines the WLAN chip manufacturer.
47  *
48  * @since 1.0
49  * @version 1.0
50  */
51 struct HdfWlanManufacturer {
52     int32_t vendorId;           /**< Vendor ID of the chip */
53     int32_t deviceId;           /**< Device ID of the chip */
54 };
55 
56 /**
57  * @brief Indicates the maximum number of interfaces.
58  *
59  * The value is <b>32</b>.
60  * @since 1.0
61  * @version 1.0
62  */
63 #define MAX_IF_COUNT 32
64 
65 /**
66  * @brief Defines the WLAN device.
67  *
68  * @since 1.0
69  */
70 struct HdfWlanDevice {
71     uint8_t id;
72     const char *driverName;                     /**< Driver name */
73     const char *chipName;                       /**< Chip name */
74     uint32_t netIfMap;                          /**< WLAN device bitmap */
75     struct HdfWlanManufacturer manufacturer;    /**< WLAN device manufacturer */
76     struct ResetManager *reset;                 /**< Chip reset management API */
77     struct PowerManager *powers;                /**< Chip power management APIs */
78     struct BusDev *bus;
79 };
80 
81 /**
82  * @brief Initializes the WLAN module.
83  *
84  * @param device Indicates the pointer to the Hardware Driver Foundation (HDF) device.
85  * @param config Indicates the pointer to the WLAN module configuration generated by
86  * the HDF Configuration Source (HCS).
87  *
88  * @return Returns <b>0</b> if the WLAN module is initialized; returns a negative value otherwise.
89  *
90  * @since 1.0
91  * @version 1.0
92  */
93 int HdfWlanInitProduct(struct HdfDeviceObject *device, const struct HdfConfigWlanModuleConfig *config);
94 
95 /**
96  * @brief Obtains the data structure of the WLAN module.
97  *
98  * @return Returns the data structure if obtained; returns <b>NULL</b> otherwise.
99  *
100  * @since 1.0
101  * @version 1.0
102  */
103 struct WifiModule* HdfWlanGetModule(void);
104 
105 /**
106  * @brief Obtains the <b>HdfWlanDevice</b> structure.
107  *
108  * @param chipId Indicates the chip ID.
109  *
110  * @return Returns the pointer to the <b>HdfWlanDevice</b> structure if obtained; returns <b>NULL</b> otherwise.
111  *
112  * @since 1.1
113  * @version 1.0
114  */
115 struct HdfWlanDevice *HdfWlanGetWlanDevice(uint8_t chipId);
116 
117 /**
118  * @brief Sends a broadcast event.
119  *
120  * @param id Indicates the ID of the event to send.
121  * @param data Indicates the pointer to the event information.
122  *
123  * @return Returns <b>0</b> if the broadcast event is sent; returns a negative value otherwise.
124  *
125  * @since 1.0
126  * @version 1.0
127  */
128 int HdfWlanSendBroadcastEvent(uint32_t id, const struct HdfSBuf *data);
129 
130 /**
131  * @brief Adds a WLAN device.
132  *
133  * @param device Indicates the pointer to the device to add.
134  *
135  * @return Returns <b>0</b> if the WLAN device is added; returns a negative value otherwise.
136  *
137  * @since 1.0
138  * @version 1.0
139  */
140 int HdfWlanAddDevice(struct HdfWlanDevice *device);
141 
142 /**
143  * @brief Deinitializes the WLAN module.
144  *
145  * @since 1.0
146  * @version 1.0
147  */
148 void HdfWlanDeinitProduct(void);
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 #endif // HDFLITE_HDF_WIFI_PRODUCT_H
154 /** @} */
155