1 /*
2 * Copyright (C) 2021–2022 Beijing OSWare Technology Co., Ltd
3 * This file contains confidential and proprietary information of
4 * OSWare Technology Co., Ltd
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 #include <net/cfg80211.h>
20 #include <net/regulatory.h>
21
22 #include "wifi_mac80211_ops.h"
23 #include "net_adpater.h"
24 #include "hdf_wlan_utils.h"
25 #include "wifi_module.h"
26 #include "osal_mem.h"
27 #include "hdf_wifi_event.h"
28
29 #define HDF_LOG_TAG Ap6212Driver
30 #ifndef errno_t
31 typedef int errno_t;
32 #endif
33
34 extern struct net_device_ops dhd_ops_pri;
35 extern struct cfg80211_ops wl_cfg80211_ops;
36
37 extern NetDevice *get_netDev(void);
38 extern struct wiphy* wrap_get_wiphy(void);
39 extern struct wireless_dev* wrap_get_widev(void);
40 extern const struct ieee80211_regdomain *wrp_get_regdomain(void);
41 extern int32_t wl_get_all_sta(struct net_device *ndev, uint32_t *num);
42 extern void dhd_get_mac_address(struct net_device *dev, void **addr);
43 extern s32 wl_get_all_sta_info(struct net_device *ndev, char* mac, uint32_t num);
44 extern int32_t wal_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy, struct net_device *netDev);
45 extern int32_t wl_cfg80211_set_wps_p2p_ie_wrp(struct net_device *ndev, char *buf, int len, int8_t type);
46 extern int32_t wal_cfg80211_remain_on_channel(struct wiphy *wiphy, struct net_device *netDev, int32_t freq,
47 unsigned int duration);
48 extern void wl_cfg80211_add_virtual_iface_wrap(struct wiphy *wiphy, char *name,
49 enum nl80211_iftype type, struct vif_params *params);
50 extern int32_t wl_cfg80211_set_country_code(struct net_device *net, char *country_code,
51 bool notify, bool user_enforced, int revinfo);
52 extern int32_t HdfWifiEventInformBssFrame(const struct NetDevice *netDev,
53 const struct WlanChannel *channel,
54 const struct ScannedBssInfo *bssInfo);
55 extern int32_t wl_cfg80211_change_beacon_wrap(struct wiphy *wiphy, struct net_device *dev,
56 struct cfg80211_beacon_data *info, int interval, int dtimPeriod, bool hidden_ssid);
57
58 extern errno_t memcpy_s(void *dest, size_t dest_max, const void *src, size_t count);
59 extern int snprintf_s(char *dest, size_t dest_max, size_t count, const char *format, ...);
60
61 typedef enum {
62 WLAN_BAND_2G,
63 WLAN_BAND_BUTT
64 } wlan_channel_band_enum;
65
66 #define WIFI_24G_CHANNEL_NUMS (14)
67 #define WAL_MIN_CHANNEL_2G (1)
68 #define WAL_MAX_CHANNEL_2G (14)
69 #define WAL_MIN_FREQ_2G (2412 + 5*(WAL_MIN_CHANNEL_2G - 1))
70 #define WAL_MAX_FREQ_2G (2484)
71 #define WAL_FREQ_2G_INTERVAL (5)
72 #define WLAN_WPS_IE_MAX_SIZE (352) // (WLAN_MEM_EVENT_SIZE2 - 32) /* 32表示事件自身占用的空间 */
73 /* Driver supports AP mode */
74 #define HISI_DRIVER_FLAGS_AP 0x00000040
75 /* Driver supports concurrent P2P operations */
76 #define HISI_DRIVER_FLAGS_P2P_CONCURRENT 0x00000200
77
78 #define HISI_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE 0x00000400
79 /* P2P capable (P2P GO or P2P Client) */
80 #define HISI_DRIVER_FLAGS_P2P_CAPABLE 0x00000800
81 /* Driver supports a dedicated interface for P2P Device */
82 #define HISI_DRIVER_FLAGS_DEDICATED_P2P_DEVICE 0x20000000
83 #define WAL_MAC_ADDR_LEN (6)
84 /*--------------------------------------------------------------------------------------------------*/
85 /* public */
86 /*--------------------------------------------------------------------------------------------------*/
GetIfName(enum nl80211_iftype type,char * ifName,uint32_t len)87 static int32_t GetIfName(enum nl80211_iftype type, char *ifName, uint32_t len)
88 {
89 if (ifName == NULL || len == 0) {
90 HDF_LOGE("%s:para is null!", __func__);
91 return HDF_FAILURE;
92 }
93 switch (type) {
94 case NL80211_IFTYPE_P2P_DEVICE:
95 if (snprintf_s(ifName, len, len -1, "p2p%d", 0) < 0) {
96 HDF_LOGE("%s:format ifName failed!", __func__);
97 return HDF_FAILURE;
98 }
99 break;
100 case NL80211_IFTYPE_P2P_CLIENT:
101 /* fall-through */
102 case NL80211_IFTYPE_P2P_GO:
103 if (snprintf_s(ifName, len, len -1, "p2p-p2p0-%d", 0) < 0) {
104 HDF_LOGE("%s:format ifName failed!", __func__);
105 return HDF_FAILURE;
106 }
107 break;
108 default:
109 HDF_LOGE("%s:GetIfName::not supported dev type!", __func__);
110 return HDF_FAILURE;
111 }
112 return HDF_SUCCESS;
113 }
114
WalReleaseHwCapability(struct WlanHwCapability * self)115 void WalReleaseHwCapability(struct WlanHwCapability *self)
116 {
117 uint8_t i;
118 if (self == NULL) {
119 return;
120 }
121 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
122 if (self->bands[i] != NULL) {
123 OsalMemFree(self->bands[i]);
124 self->bands[i] = NULL;
125 }
126 }
127 if (self->supportedRates != NULL) {
128 OsalMemFree(self->supportedRates);
129 self->supportedRates = NULL;
130 }
131 OsalMemFree(self);
132 }
133
GetChannelByFreq(struct wiphy * wiphy,uint16_t center_freq)134 static struct ieee80211_channel *GetChannelByFreq(struct wiphy* wiphy, uint16_t center_freq)
135 {
136 enum Ieee80211Band band;
137 struct ieee80211_supported_band *currentBand = NULL;
138 int32_t loop;
139 for (band = (enum Ieee80211Band)0; band < IEEE80211_NUM_BANDS; band++) {
140 currentBand = wiphy->bands[band];
141 if (currentBand == NULL) {
142 continue;
143 }
144 for (loop = 0; loop < currentBand->n_channels; loop++) {
145 if (currentBand->channels[loop].center_freq == center_freq) {
146 return ¤tBand->channels[loop];
147 }
148 }
149 }
150 return NULL;
151 }
152
WalGetChannel(struct wiphy * wiphy,int32_t freq)153 static struct ieee80211_channel *WalGetChannel(struct wiphy *wiphy, int32_t freq)
154 {
155 int32_t loop = 0;
156 enum Ieee80211Band band = IEEE80211_BAND_2GHZ;
157 struct ieee80211_supported_band *currentBand = NULL;
158
159 if (wiphy == NULL) {
160 HDF_LOGE("%s: capality is NULL!", __func__);
161 return NULL;
162 }
163
164 for (band = (enum Ieee80211Band)0; band < IEEE80211_NUM_BANDS; band++) {
165 currentBand = wiphy->bands[band];
166 if (currentBand == NULL) {
167 continue;
168 }
169
170 for (loop = 0; loop < currentBand->n_channels; loop++) {
171 if (currentBand->channels[loop].center_freq == freq) {
172 return ¤tBand->channels[loop];
173 }
174 }
175 }
176
177 return NULL;
178 }
179
inform_bss_frame(struct ieee80211_channel * channel,int32_t signal,int16_t freq,struct ieee80211_mgmt * mgmt,uint32_t mgmtLen)180 void inform_bss_frame(struct ieee80211_channel *channel, int32_t signal,
181 int16_t freq, struct ieee80211_mgmt *mgmt, uint32_t mgmtLen)
182 {
183 int32_t retVal = 0;
184 NetDevice *netDev = get_netDev();
185 struct ScannedBssInfo bssInfo;
186 struct WlanChannel hdfchannel;
187
188 if (channel == NULL || netDev == NULL || mgmt == NULL) {
189 HDF_LOGE("%s: inform_bss_frame channel = null or netDev = null!", __func__);
190 return;
191 }
192
193 bssInfo.signal = signal;
194 bssInfo.freq = freq;
195 bssInfo.mgmtLen = mgmtLen;
196 bssInfo.mgmt = (struct Ieee80211Mgmt *)mgmt;
197
198 hdfchannel.flags = channel->flags;
199 hdfchannel.channelId = channel->hw_value;
200 hdfchannel.centerFreq = channel->center_freq;
201
202 HDF_LOGE("%s: hdfchannel flags:%d--channelId:%d--centerFreq:%d--dstMac:%02x:%02x:%02x:%02x:%02x:%02x!",
203 __func__, hdfchannel.flags, hdfchannel.channelId, hdfchannel.centerFreq,
204 bssInfo.mgmt->bssid[0], bssInfo.mgmt->bssid[1], bssInfo.mgmt->bssid[2],
205 bssInfo.mgmt->bssid[3], bssInfo.mgmt->bssid[4], bssInfo.mgmt->bssid[5]);
206
207 retVal = HdfWifiEventInformBssFrame(netDev, &hdfchannel, &bssInfo);
208 if (retVal < 0) {
209 HDF_LOGE("%s: hdf wifi event inform bss frame failed!", __func__);
210 }
211 }
212
213 #define HDF_ETHER_ADDR_LEN (6)
inform_connect_result(uint8_t * bssid,uint8_t * rspIe,uint8_t * reqIe,uint32_t reqIeLen,uint32_t rspIeLen,uint16_t connectStatus)214 void inform_connect_result(uint8_t *bssid, uint8_t *rspIe,
215 uint8_t *reqIe, uint32_t reqIeLen,
216 uint32_t rspIeLen, uint16_t connectStatus)
217 {
218 int32_t retVal = 0;
219 NetDevice *netDev = get_netDev();
220 struct ConnetResult connResult;
221
222 if (netDev == NULL || bssid == NULL || rspIe == NULL || reqIe == NULL) {
223 HDF_LOGE("%s: netDev / bssid / rspIe / reqIe null!", __func__);
224 return;
225 }
226
227 memcpy_s(&connResult.bssid[0], HDF_ETHER_ADDR_LEN, bssid, HDF_ETHER_ADDR_LEN);
228 HDF_LOGE("%s: connResult:%02x:%02x:%02x:%02x:%02x:%02x\n", __func__,
229 connResult.bssid[0], connResult.bssid[1], connResult.bssid[2],
230 connResult.bssid[3], connResult.bssid[4], connResult.bssid[5]);
231
232 connResult.rspIe = rspIe;
233 connResult.rspIeLen = rspIeLen;
234
235 connResult.reqIe = reqIe;
236 connResult.reqIeLen = reqIeLen;
237
238 connResult.connectStatus = connectStatus;
239
240 connResult.freq = 0;
241 connResult.statusCode = connectStatus;
242
243 retVal = HdfWifiEventConnectResult(netDev, &connResult);
244 if (retVal < 0) {
245 HDF_LOGE("%s: hdf wifi event inform connect result failed!", __func__);
246 }
247 }
248
249 struct wireless_dev g_ap_wireless_dev;
250 struct ieee80211_channel g_ap_ieee80211_channel;
251 #define GET_DEV_CFG80211_WIRELESS(dev) ((struct wireless_dev*)((dev)->ieee80211Ptr))
SetupWireLessDev(struct NetDevice * netDev,struct WlanAPConf * apSettings)252 static int32_t SetupWireLessDev(struct NetDevice *netDev, struct WlanAPConf *apSettings)
253 {
254 if (netDev->ieee80211Ptr == NULL) {
255 netDev->ieee80211Ptr = &g_ap_wireless_dev;
256 }
257
258 if (GET_DEV_CFG80211_WIRELESS(netDev)->preset_chandef.chan == NULL) {
259 GET_DEV_CFG80211_WIRELESS(netDev)->preset_chandef.chan = &g_ap_ieee80211_channel;
260 }
261 GET_DEV_CFG80211_WIRELESS(netDev)->iftype = NL80211_IFTYPE_AP;
262 GET_DEV_CFG80211_WIRELESS(netDev)->preset_chandef.width = (enum nl80211_channel_type)apSettings->width;
263 GET_DEV_CFG80211_WIRELESS(netDev)->preset_chandef.center_freq1 = apSettings->centerFreq1;
264 GET_DEV_CFG80211_WIRELESS(netDev)->preset_chandef.center_freq2 = apSettings->centerFreq2;
265 GET_DEV_CFG80211_WIRELESS(netDev)->preset_chandef.chan->hw_value = apSettings->channel;
266 GET_DEV_CFG80211_WIRELESS(netDev)->preset_chandef.chan->band = IEEE80211_BAND_2GHZ;
267 GET_DEV_CFG80211_WIRELESS(netDev)->preset_chandef.chan->center_freq = apSettings->centerFreq1;
268
269 return HDF_SUCCESS;
270 }
271
272 /*--------------------------------------------------------------------------------------------------*/
273 /* HdfMac80211BaseOps */
274 /*--------------------------------------------------------------------------------------------------*/
WalSetMode(NetDevice * netDev,enum WlanWorkMode iftype)275 int32_t WalSetMode(NetDevice *netDev, enum WlanWorkMode iftype)
276 {
277 int32_t retVal = 0;
278 struct wiphy* wiphy = wrap_get_wiphy();
279
280 HDF_LOGE("%s: start... iftype=%d ", __func__, iftype);
281 retVal = (int32_t)wl_cfg80211_ops.change_virtual_intf(wiphy, netDev,
282 (enum nl80211_iftype)iftype, NULL);
283 if (retVal < 0) {
284 HDF_LOGE("%s: set mode failed!", __func__);
285 }
286
287 return retVal;
288 }
289
290 struct key_params gKeyParameter;
WalAddKey(struct NetDevice * netDev,uint8_t keyIndex,bool pairwise,const uint8_t * macAddr,struct KeyParams * params)291 int32_t WalAddKey(struct NetDevice *netDev, uint8_t keyIndex, bool pairwise, const uint8_t *macAddr,
292 struct KeyParams *params)
293 {
294 int32_t retVal = 0;
295 struct wiphy* wiphy = wrap_get_wiphy();
296
297 HDF_LOGE("%s: start...", __func__);
298
299 gKeyParameter.key = params->key;
300 gKeyParameter.seq = params->seq;
301
302 gKeyParameter.key_len = params->keyLen;
303 gKeyParameter.seq_len = params->seqLen;
304
305 gKeyParameter.cipher = params->cipher;
306 (void)netDev;
307 retVal = (int32_t)wl_cfg80211_ops.add_key(wiphy, netDev, keyIndex, pairwise, macAddr,
308 (struct key_params *)(&gKeyParameter));
309 if (retVal < 0) {
310 HDF_LOGE("%s: add key failed!", __func__);
311 }
312
313 return retVal;
314 }
315
WalDelKey(struct NetDevice * netDev,uint8_t keyIndex,bool pairwise,const uint8_t * macAddr)316 int32_t WalDelKey(struct NetDevice *netDev, uint8_t keyIndex, bool pairwise, const uint8_t *macAddr)
317 {
318 int32_t retVal = 0;
319 struct wiphy* wiphy = wrap_get_wiphy();
320
321 HDF_LOGE("%s: start...", __func__);
322
323 (void)netDev;
324 retVal = (int32_t)wl_cfg80211_ops.del_key(wiphy, netDev, keyIndex, pairwise, macAddr);
325 if (retVal < 0) {
326 HDF_LOGE("%s: delete key failed!", __func__);
327 }
328
329 return retVal;
330 }
331
WalSetDefaultKey(struct NetDevice * netDev,uint8_t keyIndex,bool unicast,bool multicas)332 int32_t WalSetDefaultKey(struct NetDevice *netDev, uint8_t keyIndex, bool unicast, bool multicas)
333 {
334 int32_t retVal = 0;
335 struct wiphy* wiphy = wrap_get_wiphy();
336
337 HDF_LOGE("%s: start...", __func__);
338
339 retVal = (int32_t)wl_cfg80211_ops.set_default_key(wiphy, netDev, keyIndex, unicast, multicas);
340 if (retVal < 0) {
341 HDF_LOGE("%s: set default key failed!", __func__);
342 }
343
344 return retVal;
345 }
346
WalGetDeviceMacAddr(NetDevice * netDev,int32_t type,uint8_t * mac,uint8_t len)347 int32_t WalGetDeviceMacAddr(NetDevice *netDev, int32_t type, uint8_t *mac, uint8_t len)
348 {
349 (void)len;
350 (void)type;
351 (void)netDev;
352 HDF_LOGE("%s: start...", __func__);
353
354 dhd_get_mac_address(netDev, (void**)&mac);
355
356 return HDF_SUCCESS;
357 }
358
WalSetMacAddr(NetDevice * netDev,uint8_t * mac,uint8_t len)359 int32_t WalSetMacAddr(NetDevice *netDev, uint8_t *mac, uint8_t len)
360 {
361 int32_t retVal = 0;
362 uint8_t zero_mac_addr[WAL_MAC_ADDR_LEN] = {0};
363
364 (void)len;
365 (void)netDev;
366 HDF_LOGE("%s: start...", __func__);
367
368 if ((memcmp(zero_mac_addr, mac, WAL_MAC_ADDR_LEN) == 0)
369 || ((mac[0] & 0x1) == 0x1)) {
370 HDF_LOGE("%s: mac address error !", __func__);
371 return HDF_FAILURE;
372 }
373
374 retVal = (int32_t)dhd_ops_pri.ndo_set_mac_address(netDev, mac);
375 if (retVal < 0) {
376 HDF_LOGE("%s: set mac address failed!", __func__);
377 }
378
379 return retVal;
380 }
381
WalSetTxPower(NetDevice * netDev,int32_t power)382 int32_t WalSetTxPower(NetDevice *netDev, int32_t power)
383 {
384 int retVal = 0;
385 struct wiphy* wiphy = wrap_get_wiphy();
386 struct wireless_dev *wdev = GET_NET_DEV_CFG80211_WIRELESS(netDev);
387
388 HDF_LOGE("%s: start...", __func__);
389
390 retVal = (int32_t)wl_cfg80211_ops.set_tx_power(wiphy, wdev, NL80211_TX_POWER_FIXED, power);
391 if (retVal < 0) {
392 HDF_LOGE("%s: set_tx_power failed!", __func__);
393 }
394
395 return HDF_SUCCESS;
396 }
397
WalGetValidFreqsWithBand(NetDevice * netDev,int32_t band,int32_t * freqs,uint32_t * num)398 int32_t WalGetValidFreqsWithBand(NetDevice *netDev, int32_t band, int32_t *freqs, uint32_t *num)
399 {
400 uint32_t freqIndex = 0;
401 uint32_t channelNumber;
402 uint32_t freqTmp;
403 uint32_t minFreq;
404 uint32_t maxFreq;
405 const struct ieee80211_regdomain *regdom = wrp_get_regdomain();
406 if (regdom == NULL) {
407 HDF_LOGE("%s: wal_get_cfg_regdb failed!", __func__);
408 return HDF_FAILURE;
409 }
410
411 (void)netDev;
412 HDF_LOGE("%s: start...", __func__);
413
414 minFreq = regdom->reg_rules[0].freq_range.start_freq_khz / MHZ_TO_KHZ(1);
415 maxFreq = regdom->reg_rules[0].freq_range.end_freq_khz / MHZ_TO_KHZ(1);
416 switch (band) {
417 case WLAN_BAND_2G:
418 for (channelNumber = 1; channelNumber <= WIFI_24G_CHANNEL_NUMS; channelNumber++) {
419 if (channelNumber < WAL_MAX_CHANNEL_2G) {
420 freqTmp = WAL_MIN_FREQ_2G + (channelNumber - 1) * WAL_FREQ_2G_INTERVAL;
421 } else if (channelNumber == WAL_MAX_CHANNEL_2G) {
422 freqTmp = WAL_MAX_FREQ_2G;
423 }
424 if (freqTmp < minFreq || freqTmp > maxFreq) {
425 continue;
426 }
427 freqs[freqIndex] = freqTmp;
428 freqIndex++;
429 }
430 *num = freqIndex;
431 break;
432 default:
433 HDF_LOGE("%s: no support band!", __func__);
434 return HDF_ERR_NOT_SUPPORT;
435 }
436 return HDF_SUCCESS;
437 }
438
WalGetHwCapability(struct NetDevice * netDev,struct WlanHwCapability ** capability)439 int32_t WalGetHwCapability(struct NetDevice *netDev, struct WlanHwCapability **capability)
440 {
441 uint8_t loop = 0;
442 struct wiphy* wiphy = wrap_get_wiphy();
443 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_2GHZ];
444 struct WlanHwCapability *hwCapability = (struct WlanHwCapability *)OsalMemCalloc(sizeof(struct WlanHwCapability));
445
446 (void)netDev;
447 if (hwCapability == NULL) {
448 HDF_LOGE("%s: oom!\n", __func__);
449 return HDF_FAILURE;
450 }
451 hwCapability->Release = WalReleaseHwCapability;
452 if (hwCapability->bands[IEEE80211_BAND_2GHZ] == NULL) {
453 hwCapability->bands[IEEE80211_BAND_2GHZ] =
454 OsalMemCalloc(sizeof(struct WlanBand) + (sizeof(struct WlanChannel) * band->n_channels));
455 if (hwCapability->bands[IEEE80211_BAND_2GHZ] == NULL) {
456 HDF_LOGE("%s: oom!\n", __func__);
457 WalReleaseHwCapability(hwCapability);
458 return HDF_FAILURE;
459 }
460 }
461 hwCapability->htCapability = band->ht_cap.cap;
462 hwCapability->bands[IEEE80211_BAND_2GHZ]->channelCount = band->n_channels;
463 for (loop = 0; loop < band->n_channels; loop++) {
464 hwCapability->bands[IEEE80211_BAND_2GHZ]->channels[loop].centerFreq = band->channels[loop].center_freq;
465 hwCapability->bands[IEEE80211_BAND_2GHZ]->channels[loop].flags = band->channels[loop].flags;
466 hwCapability->bands[IEEE80211_BAND_2GHZ]->channels[loop].channelId = band->channels[loop].hw_value;
467 }
468 hwCapability->supportedRateCount = band->n_bitrates;
469 hwCapability->supportedRates = OsalMemCalloc(sizeof(uint16_t) * band->n_bitrates);
470 if (hwCapability->supportedRates == NULL) {
471 HDF_LOGE("%s: oom!\n", __func__);
472 WalReleaseHwCapability(hwCapability);
473 return HDF_FAILURE;
474 }
475 for (loop = 0; loop < band->n_bitrates; loop++) {
476 hwCapability->supportedRates[loop] = band->bitrates[loop].bitrate;
477 }
478 *capability = hwCapability;
479 return HDF_SUCCESS;
480 }
481
WalRemainOnChannel(struct NetDevice * netDev,WifiOnChannel * onChannel)482 int32_t WalRemainOnChannel(struct NetDevice *netDev, WifiOnChannel *onChannel)
483 {
484 int32_t retVal = 0;
485 struct wiphy* wiphy = wrap_get_wiphy();
486
487 (void)netDev;
488 HDF_LOGE("%s: start...", __func__);
489 if (netDev == NULL || onChannel == NULL) {
490 HDF_LOGE("%s:NULL ptr!", __func__);
491 return HDF_FAILURE;
492 }
493
494 retVal = (int32_t)wal_cfg80211_remain_on_channel(wiphy, netDev, onChannel->freq, onChannel->duration);
495 if (retVal < 0) {
496 HDF_LOGE("%s: remain on channel failed!", __func__);
497 }
498
499 return retVal;
500 }
501
WalCancelRemainOnChannel(struct NetDevice * netDev)502 int32_t WalCancelRemainOnChannel(struct NetDevice *netDev)
503 {
504 int32_t retVal = 0;
505 struct wiphy* wiphy = wrap_get_wiphy();
506
507 (void)netDev;
508 HDF_LOGE("%s: start...", __func__);
509 if (netDev == NULL) {
510 HDF_LOGE("%s:NULL ptr!", __func__);
511 return HDF_FAILURE;
512 }
513
514 retVal = (int32_t)wal_cfg80211_cancel_remain_on_channel(wiphy, netDev);
515 if (retVal < 0) {
516 HDF_LOGE("%s: cancel remain on channel failed!", __func__);
517 }
518
519 return retVal;
520 }
521
WalProbeReqReport(struct NetDevice * netDev,int32_t report)522 int32_t WalProbeReqReport(struct NetDevice *netDev, int32_t report)
523 {
524 // NO SUPPORT
525 (void)report;
526 HDF_LOGE("%s: start...", __func__);
527 if (netDev == NULL) {
528 HDF_LOGE("%s:NULL ptr!", __func__);
529 return HDF_FAILURE;
530 }
531 return HDF_SUCCESS;
532 }
533
WalAddIf(struct NetDevice * netDev,WifiIfAdd * ifAdd)534 int32_t WalAddIf(struct NetDevice *netDev, WifiIfAdd *ifAdd)
535 {
536 char ifName[16] = {0};
537 struct wiphy* wiphy = wrap_get_wiphy();
538
539 HDF_LOGE("%s: start...", __func__);
540
541 GetIfName(ifAdd->type, ifName, 16);
542 wl_cfg80211_ops.add_virtual_intf(wiphy, ifName, 0, ifAdd->type, NULL);
543
544 return HDF_SUCCESS;
545 }
546
WalRemoveIf(struct NetDevice * netDev,WifiIfRemove * ifRemove)547 int32_t WalRemoveIf(struct NetDevice *netDev, WifiIfRemove *ifRemove)
548 {
549 struct NetDevice *removeNetdev = NULL;
550 struct wireless_dev *wdev = NULL;
551 struct wiphy* wiphy = wrap_get_wiphy();
552
553 (void)netDev;
554 HDF_LOGE("%s: start...", __func__);
555 if (ifRemove == NULL) {
556 HDF_LOGE("%s:NULL ptr!", __func__);
557 return HDF_FAILURE;
558 }
559
560 removeNetdev = NetDeviceGetInstByName((const char*)(ifRemove->ifName));
561 if (removeNetdev == NULL) {
562 return HDF_FAILURE;
563 }
564
565 wdev = GET_NET_DEV_CFG80211_WIRELESS(removeNetdev);
566 wl_cfg80211_ops.del_virtual_intf(wiphy, wdev);
567
568 return HDF_SUCCESS;
569 }
570
WalSetApWpsP2pIe(struct NetDevice * netDev,WifiAppIe * appIe)571 int32_t WalSetApWpsP2pIe(struct NetDevice *netDev, WifiAppIe *appIe)
572 {
573 int32_t retVal = 0;
574
575 (void)netDev;
576 HDF_LOGE("%s: start...", __func__);
577 if (netDev == NULL || appIe == NULL) {
578 HDF_LOGE("%s:NULL ptr!", __func__);
579 return HDF_FAILURE;
580 }
581
582 if (appIe->ieLen > WLAN_WPS_IE_MAX_SIZE) {
583 HDF_LOGE("%s:app ie length is too large!", __func__);
584 return HDF_FAILURE;
585 }
586
587 retVal = (int32_t)wl_cfg80211_set_wps_p2p_ie_wrp(netDev, appIe->ie, appIe->ieLen, (int8_t)appIe->appIeType);
588 if (retVal < 0) {
589 HDF_LOGE("%s: set_wps_p2p_ie failed!", __func__);
590 }
591
592 return retVal;
593 }
594
WalGetDriverFlag(struct NetDevice * netDev,WifiGetDrvFlags ** params)595 int32_t WalGetDriverFlag(struct NetDevice *netDev, WifiGetDrvFlags **params)
596 {
597 struct wireless_dev *wdev = GET_NET_DEV_CFG80211_WIRELESS(netDev);
598 WifiGetDrvFlags *getDrvFlag = (WifiGetDrvFlags *)OsalMemCalloc(sizeof(WifiGetDrvFlags));
599
600 if (netDev == NULL || params == NULL) {
601 HDF_LOGE("%s:NULL ptr!", __func__);
602 return HDF_FAILURE;
603 }
604
605 HDF_LOGE("%s: start...", __func__);
606
607 if (wdev == NULL) {
608 HDF_LOGE("%s: wdev NULL", __func__);
609 return HDF_FAILURE;
610 } else {
611 HDF_LOGE("%s: p_wdev:%p", __func__, wdev);
612 }
613
614 if (getDrvFlag == NULL) {
615 HDF_LOGE("%s: getDrvFlag NULL", __func__);
616 }
617 switch (wdev->iftype) {
618 case NL80211_IFTYPE_P2P_CLIENT:
619 /* fall-through */
620 case NL80211_IFTYPE_P2P_GO:
621 HDF_LOGE("%s: NL80211_IFTYPE_P2P_GO case!", __func__);
622 getDrvFlag->drvFlags = HISI_DRIVER_FLAGS_AP;
623 break;
624 case NL80211_IFTYPE_P2P_DEVICE:
625 HDF_LOGE("%s: NL80211_IFTYPE_P2P_DEVICE case!", __func__);
626 getDrvFlag->drvFlags = (HISI_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE |
627 HISI_DRIVER_FLAGS_P2P_CONCURRENT |
628 HISI_DRIVER_FLAGS_P2P_CAPABLE);
629 break;
630 default:
631 HDF_LOGE("%s: getDrvFlag->drvFlags default to 0 case!", __func__);
632 getDrvFlag->drvFlags = 0;
633 }
634 *params = getDrvFlag;
635 return HDF_SUCCESS;
636 }
637
WalSendAction(struct NetDevice * netDev,WifiActionData * actionData)638 int32_t WalSendAction(struct NetDevice *netDev, WifiActionData *actionData)
639 {
640 (void)netDev;
641 (void)actionData;
642 HDF_LOGE("%s: start...", __func__);
643 return HDF_ERR_NOT_SUPPORT;
644 }
645
WalGetIftype(struct NetDevice * netDev,uint8_t * iftype)646 int32_t WalGetIftype(struct NetDevice *netDev, uint8_t *iftype)
647 {
648 iftype = (uint8_t *)(&(GET_NET_DEV_CFG80211_WIRELESS(netDev)->iftype));
649 HDF_LOGE("%s: start...", __func__);
650 return HDF_SUCCESS;
651 }
652
653 /*--------------------------------------------------------------------------------------------------*/
654 /* HdfMac80211STAOps */
655 /*--------------------------------------------------------------------------------------------------*/
WalConnect(NetDevice * netDev,WlanConnectParams * param)656 static int32_t WalConnect(NetDevice *netDev, WlanConnectParams *param)
657 {
658 int ret = 0;
659 int32_t retVal = 0;
660 struct wiphy* wiphy = wrap_get_wiphy();
661 struct cfg80211_connect_params cfg80211_params = { 0 };
662
663 HDF_LOGE("%s: start ...!", __func__);
664
665 (void)netDev;
666
667 if (param->centerFreq != WLAN_FREQ_NOT_SPECFIED) {
668 cfg80211_params.channel = WalGetChannel(wiphy, param->centerFreq);
669 if ((cfg80211_params.channel == NULL) || (cfg80211_params.channel->flags & WIFI_CHAN_DISABLED)) {
670 HDF_LOGE("%s:illegal channel.flags=%u", __func__,
671 (cfg80211_params.channel == NULL) ? 0 : cfg80211_params.channel->flags);
672 return HDF_FAILURE;
673 }
674 }
675 cfg80211_params.bssid = param->bssid;
676 cfg80211_params.ssid = param->ssid;
677 cfg80211_params.ie = param->ie;
678 cfg80211_params.ssid_len = param->ssidLen;
679 cfg80211_params.ie_len = param->ieLen;
680 ret = memcpy_s(&cfg80211_params.crypto, sizeof(cfg80211_params.crypto), ¶m->crypto, sizeof(param->crypto));
681 if (ret != 0) {
682 HDF_LOGE("%s:Copy crypto info failed!ret=%d", __func__, ret);
683 return HDF_FAILURE;
684 }
685 cfg80211_params.key = param->key;
686 cfg80211_params.auth_type = (u_int8_t)param->authType;
687 cfg80211_params.privacy = param->privacy;
688 cfg80211_params.key_len = param->keyLen;
689 cfg80211_params.key_idx = param->keyIdx;
690 cfg80211_params.mfp = (u_int8_t)param->mfp;
691
692 retVal = wl_cfg80211_ops.connect(wiphy, netDev, &cfg80211_params);
693 if (retVal < 0) {
694 HDF_LOGE("%s: connect failed!\n", __func__);
695 }
696
697 return retVal;
698 }
699
WalDisconnect(NetDevice * netDev,uint16_t reasonCode)700 int32_t WalDisconnect(NetDevice *netDev, uint16_t reasonCode)
701 {
702 int32_t retVal = 0;
703 struct wiphy* wiphy = wrap_get_wiphy();
704
705 (void)netDev;
706 HDF_LOGE("%s: start...reasonCode:%d", __func__, reasonCode);
707
708 retVal = (int32_t)wl_cfg80211_ops.disconnect(wiphy, netDev, reasonCode);
709 if (retVal < 0) {
710 HDF_LOGE("%s: sta disconnect failed!", __func__);
711 }
712
713 return retVal;
714 }
715
WalBuildChannelInfo(struct wiphy * wiphy,struct WlanScanRequest * scanParam,struct cfg80211_scan_request ** request)716 int32_t WalBuildChannelInfo(struct wiphy* wiphy, struct WlanScanRequest *scanParam,
717 struct cfg80211_scan_request **request)
718 {
719 int32_t loop;
720 int32_t count = 0;
721 struct ieee80211_channel *chan = NULL;
722 enum Ieee80211Band band = IEEE80211_BAND_2GHZ;
723
724 // channel info
725 if ((scanParam->freqs == NULL) || (scanParam->freqsCount == 0)) {
726 if (wiphy->bands[band] == NULL) {
727 HDF_LOGE("%s: wiphy->bands[band] = NULL!\n", __func__);
728 return HDF_FAILURE;
729 }
730
731 for (loop = 0; loop < (int32_t)wiphy->bands[band]->n_channels; loop++) {
732 chan = &wiphy->bands[band]->channels[loop];
733 if ((chan->flags & WIFI_CHAN_DISABLED) != 0) {
734 continue;
735 }
736 (*request)->channels[count++] = chan;
737 }
738 } else {
739 for (loop = 0; loop < scanParam->freqsCount; loop++) {
740 chan = GetChannelByFreq(wiphy, (uint16_t)(scanParam->freqs[loop]));
741 if (chan == NULL) {
742 continue;
743 }
744
745 (*request)->channels[count++] = chan;
746 }
747 }
748
749 if (count == 0) {
750 HDF_LOGE("%s: invalid freq info!\n", __func__);
751 return HDF_FAILURE;
752 }
753 (*request)->n_channels = count;
754
755 return HDF_SUCCESS;
756 }
757
WalBuildSSidInfo(struct WlanScanRequest * scanParam,struct cfg80211_scan_request ** request)758 int32_t WalBuildSSidInfo(struct WlanScanRequest *scanParam, struct cfg80211_scan_request **request)
759 {
760 int32_t loop, count = 0, retVal = 0;
761 if (scanParam->ssidCount > WPAS_MAX_SCAN_SSIDS) {
762 HDF_LOGE("%s:unexpected numSsids!numSsids=%u", __func__, scanParam->ssidCount);
763 return HDF_FAILURE;
764 }
765
766 if (scanParam->ssidCount == 0) {
767 HDF_LOGE("%s:ssid number is 0!", __func__);
768 return HDF_SUCCESS;
769 }
770
771 (*request)->ssids = (struct cfg80211_ssid *)OsalMemCalloc(scanParam->ssidCount * sizeof(struct cfg80211_ssid));
772 if ((*request)->ssids == NULL) {
773 HDF_LOGE("%s: calloc request->ssids null", __func__);
774 return HDF_FAILURE;
775 }
776
777 for (loop = 0; loop < scanParam->ssidCount; loop++) {
778 if (count >= DRIVER_MAX_SCAN_SSIDS) {
779 break;
780 }
781
782 if (scanParam->ssids[loop].ssidLen > IEEE80211_MAX_SSID_LEN) {
783 continue;
784 }
785
786 (*request)->ssids[count].ssid_len = scanParam->ssids[loop].ssidLen;
787 if (memcpy_s((*request)->ssids[count].ssid, OAL_IEEE80211_MAX_SSID_LEN, scanParam->ssids[loop].ssid,
788 scanParam->ssids[loop].ssidLen) != 0) {
789 continue;
790 }
791 count++;
792 }
793 (*request)->n_ssids = count;
794
795 return HDF_SUCCESS;
796 }
797
798 struct cfg80211_scan_request g_request;
WalStartScan(NetDevice * netDev,struct WlanScanRequest * scanParam)799 int32_t WalStartScan(NetDevice *netDev, struct WlanScanRequest *scanParam)
800 {
801 int32_t loop, count = 0, retVal = 0;
802 enum Ieee80211Band band = IEEE80211_BAND_2GHZ;
803 struct ieee80211_channel *chan = NULL;
804 struct wiphy* wiphy = wrap_get_wiphy();
805 struct cfg80211_scan_request *request = &g_request;
806
807 if (request == NULL) {
808 return HDF_FAILURE;
809 }
810
811 // basic info
812 request->wiphy = wiphy;
813 request->wdev = GET_NET_DEV_CFG80211_WIRELESS(netDev);
814 request->n_ssids = scanParam->ssidCount;
815
816 if (WalBuildChannelInfo(wiphy, scanParam, &request) == HDF_FAILURE) {
817 return HDF_FAILURE;
818 }
819
820 // ssid info
821 if (WalBuildSSidInfo(scanParam, &request) == HDF_FAILURE) {
822 return HDF_FAILURE;
823 }
824
825 // User Ie Info
826 if (scanParam->extraIEsLen > 512) {
827 return HDF_FAILURE;
828 }
829
830 if ((scanParam->extraIEs != NULL) && (scanParam->extraIEsLen != 0)) {
831 request->ie = (uint8_t *)OsalMemCalloc(scanParam->extraIEsLen);
832 if (request->ie == NULL) {
833 if (request->ie != NULL) {
834 OsalMemFree((void*)request->ie);
835 request->ie = NULL;
836 }
837
838 return HDF_FAILURE;
839 }
840 (void)memcpy_s((void*)request->ie, scanParam->extraIEsLen, scanParam->extraIEs, scanParam->extraIEsLen);
841 request->ie_len = scanParam->extraIEsLen;
842 }
843
844 retVal = (int32_t)wl_cfg80211_ops.scan(wiphy, request);
845 if (retVal < 0) {
846 if (request != NULL) {
847 if ((request)->ie != NULL) {
848 OsalMemFree((void*)(request->ie));
849 request->ie = NULL;
850 }
851 if ((request)->ssids != NULL) {
852 OsalMemFree(request->ssids);
853 (request)->ssids = NULL;
854 }
855 OsalMemFree(request);
856 request = NULL;
857 }
858 }
859
860 return retVal;
861 }
862
WalAbortScan(NetDevice * netDev)863 int32_t WalAbortScan(NetDevice *netDev)
864 {
865 struct wiphy* wiphy = wrap_get_wiphy();
866 struct wireless_dev* wdev = wrap_get_widev();
867
868 (void)netDev;
869 HDF_LOGE("%s: start...", __func__);
870 wl_cfg80211_ops.abort_scan(wiphy, wdev);
871
872 return HDF_SUCCESS;
873 }
874
WalSetScanningMacAddress(NetDevice * netDev,unsigned char * mac,uint32_t len)875 int32_t WalSetScanningMacAddress(NetDevice *netDev, unsigned char *mac, uint32_t len)
876 {
877 (void)netDev;
878 (void)mac;
879 (void)len;
880 return HDF_ERR_NOT_SUPPORT;
881 }
882
883 /*--------------------------------------------------------------------------------------------------*/
884 /* HdfMac80211APOps */
885 /*--------------------------------------------------------------------------------------------------*/
886 struct cfg80211_ap_settings g_ap_setting_info;
887 u8 g_ap_ssid[IEEE80211_MAX_SSID_LEN];
888 struct ieee80211_channel g_ap_chan;
WalConfigAp(NetDevice * netDev,struct WlanAPConf * apConf)889 int32_t WalConfigAp(NetDevice *netDev, struct WlanAPConf *apConf)
890 {
891 int32_t ret = 0;
892 struct wiphy* wiphy = wrap_get_wiphy();
893
894 (void)netDev;
895 ret = SetupWireLessDev(netDev, apConf);
896 if (ret != 0) {
897 HDF_LOGE("%s: set up wireless device failed!", __func__);
898 return HDF_FAILURE;
899 }
900
901 HDF_LOGE("%s: before iftype = %d!", __func__, ((struct wireless_dev*)(netDev->ieee80211Ptr))->iftype);
902 ((struct wireless_dev*)(netDev->ieee80211Ptr))->iftype = NL80211_IFTYPE_AP;
903 HDF_LOGE("%s: after iftype = %d!", __func__, ((struct wireless_dev*)(netDev->ieee80211Ptr))->iftype);
904
905 g_ap_setting_info.ssid_len = apConf->ssidConf.ssidLen;
906 memcpy_s(&g_ap_ssid[0], apConf->ssidConf.ssidLen, &apConf->ssidConf.ssid[0], apConf->ssidConf.ssidLen);
907
908 g_ap_setting_info.ssid = &g_ap_ssid[0];
909 g_ap_setting_info.chandef.center_freq1 = apConf->centerFreq1;
910 g_ap_setting_info.chandef.center_freq2 = apConf->centerFreq2;
911 g_ap_setting_info.chandef.width = apConf->width;
912
913 g_ap_chan.center_freq = apConf->centerFreq1;
914 g_ap_chan.hw_value = apConf->channel;
915 g_ap_chan.band = apConf->band;
916 g_ap_chan.band = IEEE80211_BAND_2GHZ;
917 g_ap_setting_info.chandef.chan = &g_ap_chan;
918
919 ret = (int32_t)wl_cfg80211_ops.change_virtual_intf(wiphy, netDev,
920 (enum nl80211_iftype)(((struct wireless_dev*)(netDev->ieee80211Ptr))->iftype), NULL);
921 if (ret < 0) {
922 HDF_LOGE("%s: set mode failed!", __func__);
923 }
924
925 return HDF_SUCCESS;
926 }
927
WalStartAp(NetDevice * netDev)928 int32_t WalStartAp(NetDevice *netDev)
929 {
930 int32_t retVal = 0;
931 struct wiphy* wiphy = wrap_get_wiphy();
932
933 (void)netDev;
934 HDF_LOGE("%s: start...", __func__);
935 GET_DEV_CFG80211_WIRELESS(netDev)->preset_chandef.chan->center_freq = \
936 ((struct wireless_dev*)(netDev->ieee80211Ptr))->preset_chandef.center_freq1;
937 retVal = (int32_t)wl_cfg80211_ops.start_ap(wiphy, netDev, &g_ap_setting_info);
938 if (retVal < 0) {
939 HDF_LOGE("%s: start_ap failed!", __func__);
940 }
941
942 return retVal;
943 }
944
WalStopAp(NetDevice * netDev)945 int32_t WalStopAp(NetDevice *netDev)
946 {
947 int32_t retVal = 0;
948 struct wiphy* wiphy = wrap_get_wiphy();
949
950 (void)netDev;
951 HDF_LOGE("%s: start...", __func__);
952
953 retVal = (int32_t)wl_cfg80211_ops.stop_ap(wiphy, netDev);
954 if (retVal < 0) {
955 HDF_LOGE("%s: stop_ap failed!", __func__);
956 }
957
958 return retVal;
959 }
960
WalChangeBeacon(NetDevice * netDev,struct WlanBeaconConf * param)961 int32_t WalChangeBeacon(NetDevice *netDev, struct WlanBeaconConf *param)
962 {
963 int32_t retVal = 0;
964 struct cfg80211_beacon_data info;
965 struct wiphy* wiphy = wrap_get_wiphy();
966
967 (void)netDev;
968 HDF_LOGE("%s: start...", __func__);
969
970 memset_s(&info, sizeof(info), 0x00, sizeof(info));
971 info.head = param->headIEs;
972 info.head_len = (size_t)param->headIEsLength;
973 info.tail = param->tailIEs;
974 info.tail_len = (size_t)param->tailIEsLength;
975
976 info.beacon_ies = NULL;
977 info.proberesp_ies = NULL;
978 info.assocresp_ies = NULL;
979 info.probe_resp = NULL;
980 info.lci = NULL;
981 info.civicloc = NULL;
982 info.ftm_responder = 0X00;
983 info.beacon_ies_len = 0X00;
984 info.proberesp_ies_len = 0X00;
985 info.assocresp_ies_len = 0X00;
986 info.probe_resp_len = 0X00;
987 info.lci_len = 0X00;
988 info.civicloc_len = 0X00;
989
990 // add beacon data for start ap
991 g_ap_setting_info.dtim_period = param->DTIMPeriod;
992 g_ap_setting_info.hidden_ssid = param->hiddenSSID;
993 g_ap_setting_info.beacon_interval = param->interval;
994
995 g_ap_setting_info.beacon.head = param->headIEs;
996 g_ap_setting_info.beacon.head_len = param->headIEsLength;
997 g_ap_setting_info.beacon.tail = param->tailIEs;
998 g_ap_setting_info.beacon.tail_len = param->tailIEsLength;
999
1000 g_ap_setting_info.beacon.beacon_ies = NULL;
1001 g_ap_setting_info.beacon.proberesp_ies = NULL;
1002 g_ap_setting_info.beacon.assocresp_ies = NULL;
1003 g_ap_setting_info.beacon.probe_resp = NULL;
1004 g_ap_setting_info.beacon.lci = NULL;
1005 g_ap_setting_info.beacon.civicloc = NULL;
1006 g_ap_setting_info.beacon.ftm_responder = 0X00;
1007 g_ap_setting_info.beacon.beacon_ies_len = 0X00;
1008 g_ap_setting_info.beacon.proberesp_ies_len = 0X00;
1009 g_ap_setting_info.beacon.assocresp_ies_len = 0X00;
1010 g_ap_setting_info.beacon.probe_resp_len = 0X00;
1011 g_ap_setting_info.beacon.lci_len = 0X00;
1012 g_ap_setting_info.beacon.civicloc_len = 0X00;
1013
1014 HDF_LOGE("%s: headIEsLen:%d---tailIEsLen:%d!", __func__, param->headIEsLength, param->tailIEsLength);
1015
1016 retVal = (int32_t)wl_cfg80211_ops.change_beacon(wiphy, netDev, &info);
1017 if (retVal < 0) {
1018 HDF_LOGE("%s: change_beacon failed!", __func__);
1019 }
1020
1021 return HDF_SUCCESS;
1022 }
1023
WalDelStation(NetDevice * netDev,const uint8_t * macAddr)1024 int32_t WalDelStation(NetDevice *netDev, const uint8_t *macAddr)
1025 {
1026 int32_t retVal = 0;
1027 struct wiphy* wiphy = wrap_get_wiphy();
1028 struct station_del_parameters del_param = {macAddr, 10, 0};
1029
1030 (void)netDev;
1031 (void)macAddr;
1032 HDF_LOGE("%s: start...", __func__);
1033
1034 retVal = (int32_t)wl_cfg80211_ops.del_station(wiphy, netDev, &del_param);
1035 if (retVal < 0) {
1036 HDF_LOGE("%s: del_station failed!", __func__);
1037 }
1038
1039 return retVal;
1040 }
1041
WalSetCountryCode(NetDevice * netDev,const char * code,uint32_t len)1042 int32_t WalSetCountryCode(NetDevice *netDev, const char *code, uint32_t len)
1043 {
1044 int32_t retVal = 0;
1045
1046 (void)netDev;
1047 HDF_LOGE("%s: start...", __func__);
1048
1049 retVal = (int32_t)wl_cfg80211_set_country_code(netDev, (char*)code, false, true, len);
1050 if (retVal < 0) {
1051 HDF_LOGE("%s: set_country_code failed!", __func__);
1052 }
1053
1054 return retVal;
1055 }
1056
WalGetAssociatedStasCount(NetDevice * netDev,uint32_t * num)1057 int32_t WalGetAssociatedStasCount(NetDevice *netDev, uint32_t *num)
1058 {
1059 int32_t retVal = 0;
1060
1061 (void)netDev;
1062 HDF_LOGE("%s: start...", __func__);
1063
1064 retVal = (int32_t)wl_get_all_sta(netDev, num);
1065 if (retVal < 0) {
1066 HDF_LOGE("%s: wl_get_all_sta failed!", __func__);
1067 }
1068 return retVal;
1069 }
1070
WalGetAssociatedStasInfo(NetDevice * netDev,WifiStaInfo * staInfo,uint32_t num)1071 int32_t WalGetAssociatedStasInfo(NetDevice *netDev, WifiStaInfo *staInfo, uint32_t num)
1072 {
1073 int32_t retVal = 0;
1074
1075 (void)netDev;
1076 HDF_LOGE("%s: start...", __func__);
1077
1078 retVal = (int32_t)wl_get_all_sta_info(netDev, staInfo->mac, num);
1079 if (retVal < 0) {
1080 HDF_LOGE("%s: wl_get_all_sta_info failed!", __func__);
1081 }
1082
1083 return retVal;
1084 }
1085 /*--------------------------------------------------------------------------------------------------*/
1086 /*--------------------------------------------------------------------------------------------------*/
1087 /*--------------------------------------------------------------------------------------------------*/
1088 static struct HdfMac80211BaseOps g_baseOps = {
1089 .SetMode = WalSetMode,
1090 .AddKey = WalAddKey,
1091 .DelKey = WalDelKey,
1092 .SetDefaultKey = WalSetDefaultKey,
1093 .GetDeviceMacAddr = WalGetDeviceMacAddr,
1094 .SetMacAddr = WalSetMacAddr,
1095 .SetTxPower = WalSetTxPower,
1096 .GetValidFreqsWithBand = WalGetValidFreqsWithBand,
1097 .GetHwCapability = WalGetHwCapability,
1098 .SendAction = WalSendAction,
1099 .GetIftype = WalGetIftype,
1100 };
1101
1102 static struct HdfMac80211P2POps g_p2pOps = {
1103 .ProbeReqReport = WalProbeReqReport,
1104 .AddIf = WalAddIf,
1105 .RemoveIf = WalRemoveIf,
1106 .SetApWpsP2pIe = WalSetApWpsP2pIe,
1107 .GetDriverFlag = WalGetDriverFlag,
1108 .RemainOnChannel = WalRemainOnChannel,
1109 .CancelRemainOnChannel = WalCancelRemainOnChannel,
1110 };
1111
1112 static struct HdfMac80211STAOps g_staOps = {
1113 .Connect = WalConnect,
1114 .Disconnect = WalDisconnect,
1115 .StartScan = WalStartScan,
1116 .AbortScan = WalAbortScan,
1117 .SetScanningMacAddress = WalSetScanningMacAddress,
1118 };
1119
1120 static struct HdfMac80211APOps g_apOps = {
1121 .ConfigAp = WalConfigAp,
1122 .StartAp = WalStartAp,
1123 .StopAp = WalStopAp,
1124 .ConfigBeacon = WalChangeBeacon,
1125 .DelStation = WalDelStation,
1126 .SetCountryCode = WalSetCountryCode,
1127 .GetAssociatedStasCount = WalGetAssociatedStasCount,
1128 .GetAssociatedStasInfo = WalGetAssociatedStasInfo
1129 };
1130
ApMac80211Init(struct HdfChipDriver * chipDriver)1131 void ApMac80211Init(struct HdfChipDriver *chipDriver)
1132 {
1133 HDF_LOGE("%s: start...", __func__);
1134
1135 if (chipDriver == NULL) {
1136 HDF_LOGE("%s: input is NULL", __func__);
1137 return;
1138 }
1139 chipDriver->ops = &g_baseOps;
1140 chipDriver->staOps = &g_staOps;
1141 chipDriver->apOps = &g_apOps;
1142 chipDriver->p2pOps = &g_p2pOps;
1143 }
1144
1145 EXPORT_SYMBOL(inform_bss_frame);
1146 EXPORT_SYMBOL(inform_connect_result);