hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_escan.c
old mode 100644new mode 100755
....@@ -1,5 +1,4 @@
11 /* SPDX-License-Identifier: GPL-2.0 */
2
-
32 #if defined(WL_ESCAN)
43 #include <bcmendian.h>
54 #include <linux/if_arp.h>
....@@ -42,11 +41,11 @@
4241 #define dtohchanspec(i) (i)
4342 #define WL_EXTRA_BUF_MAX 2048
4443
45
-#define wl_escan_get_buf(a) ((wl_scan_results_v109_t *) (a)->escan_buf)
44
+#define wl_escan_get_buf(a) ((wl_scan_results_t *) (a)->escan_buf)
4645
4746 #if defined(WL_WIRELESS_EXT)
4847 extern int wl_iw_handle_scanresults_ies(char **event_p, char *end,
49
- struct iw_request_info *info, wl_bss_info_v109_t *bi);
48
+ struct iw_request_info *info, wl_bss_info_t *bi);
5049 #define for_each_bss_wext(list, bss, __i) \
5150 for (__i = 0; __i < list->count && __i < IW_MAX_AP; __i++, bss = next_bss(list, bss))
5251 #endif
....@@ -206,7 +205,7 @@
206205 return wl_chspec_host_to_driver(ioctl_ver, chanspec);
207206 }
208207
209
-static inline struct wl_bss_info *next_bss(wl_scan_results_v109_t *list,
208
+static inline struct wl_bss_info *next_bss(wl_scan_results_t *list,
210209 struct wl_bss_info *bss)
211210 {
212211 return bss = bss ?
....@@ -217,7 +216,7 @@
217216 #ifndef BSSCACHE
218217 static void
219218 wl_escan_dump_bss(struct net_device *dev, struct wl_escan_info *escan,
220
- wl_bss_info_v109_t *bi)
219
+ wl_bss_info_t *bi)
221220 {
222221 int16 rssi;
223222 int channel;
....@@ -245,9 +244,9 @@
245244 static s32
246245 wl_escan_inform_bss(struct net_device *dev, struct wl_escan_info *escan)
247246 {
248
- wl_scan_results_v109_t *bss_list;
247
+ wl_scan_results_t *bss_list;
249248 #ifndef BSSCACHE
250
- wl_bss_info_v109_t *bi = NULL; /* must be initialized */
249
+ wl_bss_info_t *bi = NULL; /* must be initialized */
251250 s32 i;
252251 #endif
253252 s32 err = 0;
....@@ -284,14 +283,14 @@
284283 wl_reset_bss_cache(&escan->g_bss_cache_ctrl);
285284 if (escan->autochannel)
286285 wl_ext_get_best_channel(dev, &escan->g_bss_cache_ctrl,
287
- &escan->best_2g_ch, &escan->best_5g_ch, &escan->best_6g_ch);
286
+ escan->ioctl_ver, &escan->best_2g_ch, &escan->best_5g_ch, &escan->best_6g_ch);
288287 #else
289288 bi = next_bss(bss_list, bi);
290289 for_each_bss(bss_list, bi, i) {
291290 wl_escan_dump_bss(dev, escan, bi);
292291 }
293292 if (escan->autochannel)
294
- wl_ext_get_best_channel(dev, bss_list,
293
+ wl_ext_get_best_channel(dev, bss_list, escan->ioctl_ver,
295294 &escan->best_2g_ch, &escan->best_5g_ch, &escan->best_6g_ch);
296295 #endif
297296
....@@ -299,19 +298,19 @@
299298 }
300299 #endif /* ESCAN_RESULT_PATCH */
301300
302
-static wl_scan_params_v1_t *
301
+static wl_scan_params_t *
303302 wl_escan_alloc_params(struct net_device *dev, struct wl_escan_info *escan,
304303 int channel, int nprobes, int *out_params_size)
305304 {
306
- wl_scan_params_v1_t *params;
305
+ wl_scan_params_t *params;
307306 int params_size;
308307 int num_chans;
309308
310309 *out_params_size = 0;
311310
312311 /* Our scan params only need space for 1 channel and 0 ssids */
313
- params_size = WL_SCAN_PARAMS_V1_FIXED_SIZE + 1 * sizeof(uint16);
314
- params = (wl_scan_params_v1_t*) kzalloc(params_size, GFP_KERNEL);
312
+ params_size = WL_SCAN_PARAMS_FIXED_SIZE + 1 * sizeof(uint16);
313
+ params = (wl_scan_params_t*) kzalloc(params_size, GFP_KERNEL);
315314 if (params == NULL) {
316315 ESCAN_ERROR(dev->name, "mem alloc failed (%d bytes)\n", params_size);
317316 return params;
....@@ -344,7 +343,7 @@
344343 static void
345344 wl_escan_abort(struct net_device *dev, struct wl_escan_info *escan)
346345 {
347
- wl_scan_params_v1_t *params = NULL;
346
+ wl_scan_params_t *params = NULL;
348347 s32 params_size = 0;
349348 s32 err = BCME_OK;
350349 if (!in_atomic()) {
....@@ -417,7 +416,7 @@
417416 #ifdef ESCAN_BUF_OVERFLOW_MGMT
418417 static void
419418 wl_escan_find_removal_candidate(struct wl_escan_info *escan,
420
- wl_bss_info_v109_t *bss, removal_element_t *candidate)
419
+ wl_bss_info_t *bss, removal_element_t *candidate)
421420 {
422421 int idx;
423422 for (idx = 0; idx < BUF_OVERFLOW_MGMT_COUNT; idx++) {
....@@ -436,17 +435,17 @@
436435
437436 static void
438437 wl_escan_remove_lowRSSI_info(struct net_device *dev, struct wl_escan_info *escan,
439
- wl_scan_results_v109_t *list, removal_element_t *candidate, wl_bss_info_v109_t *bi)
438
+ wl_scan_results_t *list, removal_element_t *candidate, wl_bss_info_t *bi)
440439 {
441440 int idx1, idx2;
442441 int total_delete_len = 0;
443442 for (idx1 = 0; idx1 < BUF_OVERFLOW_MGMT_COUNT; idx1++) {
444
- int cur_len = WL_SCAN_RESULTS_V109_FIXED_SIZE;
445
- wl_bss_info_v109_t *bss = NULL;
443
+ int cur_len = WL_SCAN_RESULTS_FIXED_SIZE;
444
+ wl_bss_info_t *bss = NULL;
446445 if (candidate[idx1].RSSI >= bi->RSSI)
447446 continue;
448447 for (idx2 = 0; idx2 < list->count; idx2++) {
449
- bss = bss ? (wl_bss_info_v109_t *)((uintptr)bss + dtoh32(bss->length)) :
448
+ bss = bss ? (wl_bss_info_t *)((uintptr)bss + dtoh32(bss->length)) :
450449 list->bss_info;
451450 if (!bcmp(&candidate[idx1].BSSID, &bss->BSSID, ETHER_ADDR_LEN) &&
452451 candidate[idx1].RSSI == bss->RSSI &&
....@@ -479,16 +478,16 @@
479478 {
480479 struct wl_escan_info *escan = (struct wl_escan_info *)argu;
481480 s32 status = ntoh32(e->status);
482
- wl_bss_info_v109_t *bi;
483
- wl_escan_result_v109_t *escan_result;
484
- wl_bss_info_v109_t *bss = NULL;
485
- wl_scan_results_v109_t *list;
481
+ wl_bss_info_t *bi;
482
+ wl_escan_result_t *escan_result;
483
+ wl_bss_info_t *bss = NULL;
484
+ wl_scan_results_t *list;
486485 u32 bi_length;
487486 u32 i;
488487 u16 channel;
489488
490489 mutex_lock(&escan->usr_sync);
491
- escan_result = (wl_escan_result_v109_t *)data;
490
+ escan_result = (wl_escan_result_t *)data;
492491
493492 if (escan->escan_state != ESCAN_STATE_SCANING) {
494493 ESCAN_DBG(dev->name, "Not my scan\n");
....@@ -515,7 +514,7 @@
515514 goto exit;
516515 }
517516 bi_length = dtoh32(bi->length);
518
- if (bi_length != (dtoh32(escan_result->buflen) - WL_ESCAN_RESULTS_V109_FIXED_SIZE)) {
517
+ if (bi_length != (dtoh32(escan_result->buflen) - WL_ESCAN_RESULTS_FIXED_SIZE)) {
519518 ESCAN_ERROR(dev->name, "Invalid bss_info length %d: ignoring\n",
520519 bi_length);
521520 goto exit;
....@@ -530,7 +529,7 @@
530529 /* ----- terence 20130524: skip invalid bss */
531530
532531 {
533
- int cur_len = WL_SCAN_RESULTS_V109_FIXED_SIZE;
532
+ int cur_len = WL_SCAN_RESULTS_FIXED_SIZE;
534533 #ifdef ESCAN_BUF_OVERFLOW_MGMT
535534 removal_element_t candidate[BUF_OVERFLOW_MGMT_COUNT];
536535 int remove_lower_rssi = FALSE;
....@@ -547,7 +546,7 @@
547546 ESCAN_DBG(dev->name, "%s(%pM) RSSI %d flags 0x%x length %d\n",
548547 bi->SSID, &bi->BSSID, bi->RSSI, bi->flags, bi->length);
549548 for (i = 0; i < list->count; i++) {
550
- bss = bss ? (wl_bss_info_v109_t *)((uintptr)bss + dtoh32(bss->length))
549
+ bss = bss ? (wl_bss_info_t *)((uintptr)bss + dtoh32(bss->length))
551550 : list->bss_info;
552551 #ifdef ESCAN_BUF_OVERFLOW_MGMT
553552 ESCAN_DBG(dev->name,
....@@ -691,15 +690,16 @@
691690 wl_uint32_list_t *list, void *scan_params, wl_scan_info_t *scan_info)
692691 {
693692 int err = 0;
694
- wl_scan_results_v109_t *results;
693
+ wl_scan_results_t *results;
695694 char *ptr;
696695 int i = 0, j = 0;
697696 wlc_ssid_t ssid_tmp;
698697 u32 n_channels = 0;
699698 chanspec_t chanspec;
700699 u32 n_ssids = 0;
701
- wl_scan_params_v1_t *params = NULL;
700
+ wl_scan_params_t *params = NULL;
702701 wl_scan_params_v2_t *params_v2 = NULL;
702
+ u32 scan_param_size = 0;
703703 u32 channel_offset = 0;
704704 u32 cur_offset;
705705 uint16 *chan_list = NULL;
....@@ -707,7 +707,7 @@
707707 results = wl_escan_get_buf(escan);
708708 results->version = 0;
709709 results->count = 0;
710
- results->buflen = WL_SCAN_RESULTS_V109_FIXED_SIZE;
710
+ results->buflen = WL_SCAN_RESULTS_FIXED_SIZE;
711711 escan->escan_state = ESCAN_STATE_SCANING;
712712
713713 /* Arm scan timeout timer */
....@@ -715,10 +715,12 @@
715715
716716 if (escan->scan_params_v2) {
717717 params_v2 = (wl_scan_params_v2_t *)scan_params;
718
+ scan_param_size = sizeof(wl_scan_params_v2_t);
718719 channel_offset = offsetof(wl_scan_params_v2_t, channel_list);
719720 } else {
720
- params = (wl_scan_params_v1_t *)scan_params;
721
- channel_offset = offsetof(wl_scan_params_v1_t, channel_list);
721
+ params = (wl_scan_params_t *)scan_params;
722
+ scan_param_size = sizeof(wl_scan_params_t);
723
+ channel_offset = offsetof(wl_scan_params_t, channel_list);
722724 }
723725
724726 if (params_v2) {
....@@ -841,7 +843,7 @@
841843 {
842844 wl_event_msg_t msg;
843845 struct wl_escan_info *escan = (struct wl_escan_info *)data;
844
- wl_scan_results_v109_t *bss_list;
846
+ wl_scan_results_t *bss_list;
845847 struct wl_bss_info *bi = NULL;
846848 s32 i;
847849 u32 channel;
....@@ -881,10 +883,11 @@
881883 struct dhd_pub *dhdp = dhd_get_pub(dev);
882884 struct wl_escan_info *escan = dhdp->escan;
883885 s32 err = BCME_OK;
884
- wl_escan_params_v1_t *eparams = NULL;
886
+ wl_escan_params_t *eparams = NULL;
885887 wl_escan_params_v2_t *eparams_v2 = NULL;
886
- u8 *scan_params = NULL, *params = NULL;
888
+ u8 *scan_params = NULL;
887889 s32 params_size;
890
+ wl_escan_params_t *params = NULL;
888891 u32 n_channels = 0;
889892 wl_uint32_list_t *list;
890893 u8 valid_chan_list[sizeof(u32)*(MAX_CTRL_CHANSPECS + 1)];
....@@ -915,8 +918,8 @@
915918 params_size = (WL_SCAN_PARAMS_V2_FIXED_SIZE +
916919 OFFSETOF(wl_escan_params_v2_t, params));
917920 } else {
918
- params_size = (WL_SCAN_PARAMS_V1_FIXED_SIZE +
919
- OFFSETOF(wl_escan_params_v1_t, params));
921
+ params_size = (WL_SCAN_PARAMS_FIXED_SIZE +
922
+ OFFSETOF(wl_escan_params_t, params));
920923 }
921924
922925 /* if scan request is not empty parse scan request paramters */
....@@ -934,7 +937,7 @@
934937 }
935938
936939 n_channels = list->count;
937
- /* Allocate space for populating ssids in wl_escan_params_v1_t struct */
940
+ /* Allocate space for populating ssids in wl_escan_params_t struct */
938941 if (list->count % 2)
939942 /* If n_channels is odd, add a padd of u16 */
940943 params_size += sizeof(u16) * (n_channels + 1);
....@@ -944,7 +947,7 @@
944947 params_size += sizeof(struct wlc_ssid) * 2;
945948 }
946949
947
- params = kzalloc(params_size, GFP_KERNEL);
950
+ params = (wl_escan_params_t *) kzalloc(params_size, GFP_KERNEL);
948951 if (params == NULL) {
949952 ESCAN_ERROR(dev->name, "kzalloc failed\n");
950953 err = -ENOMEM;
....@@ -956,14 +959,13 @@
956959 scan_params = (u8 *)&eparams_v2->params;
957960 eparams_v2->version = htod32(ESCAN_REQ_VERSION_V2);
958961 eparams_v2->action = htod16(WL_SCAN_ACTION_START);
959
- wl_escan_set_sync_id(eparams_v2->sync_id);
960962 } else {
961
- eparams = (wl_escan_params_v1_t *)params;
963
+ eparams = (wl_escan_params_t *)params;
962964 scan_params = (u8 *)&eparams->params;
963
- eparams->version = htod32(ESCAN_REQ_VERSION_V1);
965
+ eparams->version = htod32(ESCAN_REQ_VERSION);
964966 eparams->action = htod16(WL_SCAN_ACTION_START);
965
- wl_escan_set_sync_id(eparams->sync_id);
966967 }
968
+ wl_escan_set_sync_id(params->sync_id);
967969
968970 wl_escan_prep(dev, escan, list, scan_params, scan_info);
969971
....@@ -1012,7 +1014,7 @@
10121014
10131015 static int
10141016 wl_escan_merge_scan_results(struct net_device *dev, struct wl_escan_info *escan,
1015
- struct iw_request_info *info, char *extra, wl_bss_info_v109_t *bi, int *len, int max_size)
1017
+ struct iw_request_info *info, char *extra, wl_bss_info_t *bi, int *len, int max_size)
10161018 {
10171019 s32 err = BCME_OK;
10181020 struct iw_event iwe;
....@@ -1135,8 +1137,8 @@
11351137 s32 err = BCME_OK;
11361138 int i = 0, cnt = 0;
11371139 int len_prep = 0;
1138
- wl_bss_info_v109_t *bi = NULL;
1139
- wl_scan_results_v109_t *bss_list;
1140
+ wl_bss_info_t *bi = NULL;
1141
+ wl_scan_results_t *bss_list;
11401142 __u16 buflen_from_user = dwrq->length;
11411143
11421144 bss_list = escan->bss_list;
....@@ -1172,8 +1174,8 @@
11721174 s32 err = BCME_OK;
11731175 int i = 0, cnt = 0;
11741176 int len_prep = 0;
1175
- wl_bss_info_v109_t *bi = NULL;
1176
- wl_scan_results_v109_t *bss_list;
1177
+ wl_bss_info_t *bi = NULL;
1178
+ wl_scan_results_t *bss_list;
11771179 __u16 buflen_from_user = dwrq->length;
11781180 wl_bss_cache_t *node;
11791181
....@@ -1217,7 +1219,7 @@
12171219 int cache_cnt = 0;
12181220 #endif
12191221 int len_prep = 0, len_ret = 0;
1220
- wl_bss_info_v109_t *bi = NULL;
1222
+ wl_bss_info_t *bi = NULL;
12211223 __u16 buflen_from_user = dwrq->length;
12221224 char *buf = NULL;
12231225 struct ether_addr cur_bssid;
....@@ -1374,8 +1376,8 @@
13741376 struct ether_addr *peer_bssid, struct wl_mesh_params *mesh_info)
13751377 {
13761378 int i = 0;
1377
- wl_bss_info_v109_t *bi = NULL;
1378
- wl_scan_results_v109_t *bss_list;
1379
+ wl_bss_info_t *bi = NULL;
1380
+ wl_scan_results_t *bss_list;
13791381 int16 bi_rssi, bi_chan;
13801382 wlc_ssid_t bi_meshid;
13811383 bool is_mesh_peer = FALSE, found = FALSE;
....@@ -1446,8 +1448,8 @@
14461448 struct wl_mesh_params *mesh_info)
14471449 {
14481450 int i = 0;
1449
- wl_bss_info_v109_t *bi = NULL;
1450
- wl_scan_results_v109_t *bss_list;
1451
+ wl_bss_info_t *bi = NULL;
1452
+ wl_scan_results_t *bss_list;
14511453 int16 bi_rssi, bi_chan, max_rssi = -100;
14521454 uint min_hop_cnt = 255;
14531455 wlc_ssid_t bi_meshid;