forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_android_ext.c
old mode 100644new mode 100755
....@@ -1,5 +1,4 @@
11 /* SPDX-License-Identifier: GPL-2.0 */
2
-
32 #include <linux/module.h>
43 #include <linux/netdevice.h>
54 #include <net/netlink.h>
....@@ -32,8 +31,6 @@
3231 #ifdef WL_ESCAN
3332 #include <wl_escan.h>
3433 #endif /* WL_ESCAN */
35
-
36
-uint android_msg_level = ANDROID_ERROR_LEVEL | ANDROID_MSG_LEVEL;
3734
3835 #define AEXT_ERROR(name, arg1, args...) \
3936 do { \
....@@ -83,9 +80,6 @@
8380 #define CMD_ROAM_TRIGGER "ROAM_TRIGGER"
8481 #define CMD_PM "PM"
8582 #define CMD_MONITOR "MONITOR"
86
-#ifdef BTC_WAR
87
-#define CMD_BTC_WAR "BTC_WAR"
88
-#endif /* BTC_WAR */
8983 #define CMD_SET_SUSPEND_BCN_LI_DTIM "SET_SUSPEND_BCN_LI_DTIM"
9084 #define CMD_WLMSGLEVEL "WLMSGLEVEL"
9185 #ifdef WL_EXT_IAPSTA
....@@ -323,9 +317,9 @@
323317 }
324318
325319 chanspec_t
326
-wl_ext_chspec_host_to_driver(struct dhd_pub *dhd, chanspec_t chanspec)
320
+wl_ext_chspec_host_to_driver(int ioctl_ver, chanspec_t chanspec)
327321 {
328
- if (dhd->conf->ioctl_ver == 1) {
322
+ if (ioctl_ver == 1) {
329323 chanspec = wl_ext_chspec_to_legacy(chanspec);
330324 if (chanspec == INVCHANSPEC) {
331325 return chanspec;
....@@ -337,7 +331,7 @@
337331 }
338332
339333 static void
340
-wl_ext_ch_to_chanspec(struct dhd_pub *dhd, int ch,
334
+wl_ext_ch_to_chanspec(int ioctl_ver, int ch,
341335 struct wl_join_params *join_params, size_t *join_params_size)
342336 {
343337 chanspec_t chanspec = 0;
....@@ -360,7 +354,7 @@
360354 join_params->params.chanspec_list[0] &= WL_CHANSPEC_CHAN_MASK;
361355 join_params->params.chanspec_list[0] |= chanspec;
362356 join_params->params.chanspec_list[0] =
363
- wl_ext_chspec_host_to_driver(dhd,
357
+ wl_ext_chspec_host_to_driver(ioctl_ver,
364358 join_params->params.chanspec_list[0]);
365359
366360 join_params->params.chanspec_num =
....@@ -405,10 +399,10 @@
405399 }
406400
407401 chanspec_t
408
-wl_ext_chspec_driver_to_host(struct dhd_pub *dhd, chanspec_t chanspec)
402
+wl_ext_chspec_driver_to_host(int ioctl_ver, chanspec_t chanspec)
409403 {
410404 chanspec = dtohchanspec(chanspec);
411
- if (dhd->conf->ioctl_ver == 1) {
405
+ if (ioctl_ver == 1) {
412406 chanspec = wl_ext_chspec_from_legacy(chanspec);
413407 }
414408
....@@ -419,7 +413,7 @@
419413 chanspec_band_t
420414 wl_ext_wlcband_to_chanspec_band(int band)
421415 {
422
- chanspec_band_t chanspec_band = INVCHANSPEC;
416
+ chanspec_band_t chanspec_band = WLC_BAND_INVALID;
423417
424418 switch (band) {
425419 #ifdef WL_6G_BAND
....@@ -434,7 +428,6 @@
434428 chanspec_band = WL_CHANSPEC_BAND_2G;
435429 break;
436430 default:
437
- AEXT_ERROR("wlan", "Invalid Frequency Band\n");
438431 break;
439432 }
440433 return chanspec_band;
....@@ -556,6 +549,28 @@
556549 }
557550 }
558551
552
+int
553
+wl_ext_get_ioctl_ver(struct net_device *dev, int *ioctl_ver)
554
+{
555
+ int ret = 0;
556
+ s32 val = 0;
557
+
558
+ val = 1;
559
+ ret = wl_ext_ioctl(dev, WLC_GET_VERSION, &val, sizeof(val), 0);
560
+ if (ret) {
561
+ return ret;
562
+ }
563
+ val = dtoh32(val);
564
+ if (val != WLC_IOCTL_VERSION && val != 1) {
565
+ AEXT_ERROR(dev->name, "Version mismatch, please upgrade. Got %d, expected %d or 1\n",
566
+ val, WLC_IOCTL_VERSION);
567
+ return BCME_VERSION;
568
+ }
569
+ *ioctl_ver = val;
570
+
571
+ return ret;
572
+}
573
+
559574 void
560575 wl_ext_bss_iovar_war(struct net_device *ndev, s32 *val)
561576 {
....@@ -596,7 +611,6 @@
596611 wl_ext_set_chanspec(struct net_device *dev, struct wl_chan_info *chan_info,
597612 chanspec_t *ret_chspec)
598613 {
599
- struct dhd_pub *dhd = dhd_get_pub(dev);
600614 s32 _chan = chan_info->chan;
601615 chanspec_t chspec = 0;
602616 chanspec_t fw_chspec = 0;
....@@ -609,6 +623,7 @@
609623 u32 bw_cap;
610624 } param = {0, 0};
611625 chanspec_band_t chanspec_band = 0;
626
+ int ioctl_ver;
612627
613628 if ((chan_info->band != WLC_BAND_2G) && (chan_info->band != WLC_BAND_5G) &&
614629 (chan_info->band != WLC_BAND_6G)) {
....@@ -617,11 +632,11 @@
617632 }
618633
619634 param.band = chan_info->band;
620
- err = wldev_iovar_getbuf(dev, "bw_cap", &param, sizeof(param),
635
+ err = wl_ext_iovar_getbuf(dev, "bw_cap", &param, sizeof(param),
621636 iovar_buf, WLC_IOCTL_SMLEN, NULL);
622637 if (err) {
623638 if (err != BCME_UNSUPPORTED) {
624
- AEXT_TRACE(dev->name, "bw_cap failed, %d\n", err);
639
+ AEXT_ERROR(dev->name, "bw_cap failed, %d\n", err);
625640 return err;
626641 } else {
627642 err = wl_ext_iovar_getint(dev, "mimo_bw_cap", &bw_cap);
....@@ -641,7 +656,8 @@
641656 chanspec_band = wl_ext_wlcband_to_chanspec_band(chan_info->band);
642657 chspec = wf_create_chspec_from_primary(chan_info->chan, bw, chanspec_band);
643658 if (wf_chspec_valid(chspec)) {
644
- fw_chspec = wl_ext_chspec_host_to_driver(dhd, chspec);
659
+ wl_ext_get_ioctl_ver(dev, &ioctl_ver);
660
+ fw_chspec = wl_ext_chspec_host_to_driver(ioctl_ver, chspec);
645661 if (fw_chspec != INVCHANSPEC) {
646662 if ((err = wl_ext_iovar_setint(dev, "chanspec", fw_chspec)) == BCME_BADCHAN) {
647663 if (bw == WL_CHANSPEC_BW_80)
....@@ -651,11 +667,8 @@
651667 } else if (err) {
652668 AEXT_ERROR(dev->name, "failed to set chanspec error %d\n", err);
653669 } else
654
- WL_MSG(dev->name, "channel %s-%d(0x%x %sMHz)\n",
655
- CHSPEC2BANDSTR(chspec), chan_info->chan, chspec,
656
- CHSPEC_IS20(chspec)?"20":
657
- CHSPEC_IS40(chspec)?"40":
658
- CHSPEC_IS80(chspec)?"80":"160");
670
+ WL_MSG(dev->name, "channel %s-%d(0x%x)\n",
671
+ CHSPEC2BANDSTR(chspec), chan_info->chan, chspec);
659672 } else {
660673 AEXT_ERROR(dev->name, "failed to convert host chanspec to fw chanspec\n");
661674 err = BCME_ERROR;
....@@ -681,59 +694,44 @@
681694 static int
682695 wl_ext_channel(struct net_device *dev, char* command, int total_len)
683696 {
684
- struct dhd_pub *dhd = dhd_get_pub(dev);
685697 struct wl_chan_info chan_info;
686
- char chan[16]="";
687
- int ret, bytes_written = 0;
688
- chanspec_t chanspec;
689
- u32 fw_chanspec = 0;
690
-
691
- /* get: dhd_priv channel
692
- * set: dhd_priv channel [6|36|2g6|5g36|6g5]
693
- */
698
+ int ret;
699
+ char band[16]="";
700
+ int channel = 0;
701
+ channel_info_t ci;
702
+ int bytes_written = 0;
703
+ chanspec_t fw_chspec;
694704
695705 AEXT_TRACE(dev->name, "cmd %s", command);
696706
697
- sscanf(command, "%*s %s", chan);
698
- memset(&chan_info, 0, sizeof(struct wl_chan_info));
699
- if (strnicmp(chan, "2g", strlen("2g")) == 0) {
700
- chan_info.band = WLC_BAND_2G;
701
- chan_info.chan = (int)simple_strtol(chan+2, NULL, 10);
702
- }
703
- else if (strnicmp(chan, "5g", strlen("5g")) == 0) {
704
- chan_info.band = WLC_BAND_5G;
705
- chan_info.chan = (int)simple_strtol(chan+2, NULL, 10);
707
+ sscanf(command, "%*s %d %s", &channel, band);
708
+ if (strnicmp(band, "band=auto", strlen("band=auto")) == 0) {
709
+ chan_info.band = WLC_BAND_AUTO;
706710 }
707711 #ifdef WL_6G_BAND
708
- else if (strnicmp(chan, "6g", strlen("6g")) == 0) {
712
+ else if (strnicmp(band, "band=6g", strlen("band=6g")) == 0) {
709713 chan_info.band = WLC_BAND_6G;
710
- chan_info.chan = (int)simple_strtol(chan+2, NULL, 10);
711714 }
712715 #endif /* WL_6G_BAND */
713
- else if (strlen(chan)) {
714
- chan_info.chan = (int)simple_strtol(chan, NULL, 10);
715
- if (chan_info.chan <= CH_MAX_2G_CHANNEL)
716
- chan_info.band = WLC_BAND_2G;
717
- else
718
- chan_info.band = WLC_BAND_5G;
716
+ else if (strnicmp(band, "band=5g", strlen("band=5g")) == 0) {
717
+ chan_info.band = WLC_BAND_5G;
718
+ }
719
+ else if (strnicmp(band, "band=2g", strlen("band=2g")) == 0) {
720
+ chan_info.band = WLC_BAND_2G;
719721 }
720722
721
- if (chan_info.chan > 0) {
722
- ret = wl_ext_set_chanspec(dev, &chan_info, &chanspec);
723
+ if (channel > 0) {
724
+ chan_info.chan = channel;
725
+ ret = wl_ext_set_chanspec(dev, &chan_info, &fw_chspec);
723726 } else {
724
- ret = wl_ext_iovar_getint(dev, "chanspec", (s32 *)&fw_chanspec);
725
- if (ret == BCME_OK) {
726
- chanspec = fw_chanspec;
727
- chanspec = wl_ext_chspec_driver_to_host(dhd, chanspec);
728
- chan_info.band = CHSPEC2WLC_BAND(chanspec);
729
- chan_info.chan = wf_chspec_ctlchan(chanspec);
730
- if (chan_info.band == WLC_BAND_6G) {
731
- bytes_written = snprintf(command, total_len,
732
- "channel 6g%d", chan_info.chan);
733
- } else {
734
- bytes_written = snprintf(command, total_len,
735
- "channel %d", chan_info.chan);
736
- }
727
+ if (!(ret = wl_ext_ioctl(dev, WLC_GET_CHANNEL, &ci,
728
+ sizeof(channel_info_t), FALSE))) {
729
+ AEXT_TRACE(dev->name, "hw_channel %d\n", ci.hw_channel);
730
+ AEXT_TRACE(dev->name, "target_channel %d\n", ci.target_channel);
731
+ AEXT_TRACE(dev->name, "scan_channel %d\n", ci.scan_channel);
732
+ bytes_written = snprintf(command, sizeof(channel_info_t)+2,
733
+ "channel %d", ci.hw_channel);
734
+ AEXT_TRACE(dev->name, "command result is %s\n", command);
737735 ret = bytes_written;
738736 }
739737 }
....@@ -746,47 +744,28 @@
746744 {
747745 int ret, i;
748746 int bytes_written = -1;
749
- wl_uint32_list_t *list = NULL;
750
- chanspec_t chspec;
751
- u32 channel;
747
+ u8 valid_chan_list[sizeof(u32)*(WL_NUMCHANNELS + 1)];
748
+ wl_uint32_list_t *list;
752749
753750 AEXT_TRACE(dev->name, "cmd %s", command);
754751
755
- list = kzalloc(sizeof(u32)*(MAX_CTRL_CHANSPECS + 1), GFP_KERNEL);
756
- if (list == NULL) {
757
- AEXT_ERROR(dev->name, "kzalloc failed\n");
758
- ret = -ENOMEM;
759
- goto exit;
760
- }
761
-
762
- ret = wl_construct_ctl_chanspec_list(dev, list);
763
- if (ret < 0) {
752
+ memset(valid_chan_list, 0, sizeof(valid_chan_list));
753
+ list = (wl_uint32_list_t *)(void *) valid_chan_list;
754
+ list->count = htod32(WL_NUMCHANNELS);
755
+ ret = wl_ext_ioctl(dev, WLC_GET_VALID_CHANNELS, valid_chan_list,
756
+ sizeof(valid_chan_list), 0);
757
+ if (ret<0) {
764758 AEXT_ERROR(dev->name, "get channels failed with %d\n", ret);
765
- goto exit;
766759 } else {
767
- bytes_written = 0;
768
- for (i = 0; i < list->count; i++) {
769
- chspec = list->element[i];
770
- channel = wf_chspec_ctlchan(chspec);
771
-#ifdef WL_6G_BAND
772
- if (CHSPEC_IS6G(chspec) && (channel >= CH_MIN_6G_CHANNEL) &&
773
- (channel <= CH_MAX_6G_CHANNEL)) {
774
- bytes_written += snprintf(command+bytes_written, total_len, "6g%d ",
775
- channel);
776
- } else
777
-#endif
778
- {
779
- bytes_written += snprintf(command+bytes_written, total_len, "%d ",
780
- channel);
781
- }
760
+ bytes_written = snprintf(command, total_len, "channels");
761
+ for (i = 0; i < dtoh32(list->count); i++) {
762
+ bytes_written += snprintf(command+bytes_written, total_len, " %d",
763
+ dtoh32(list->element[i]));
782764 }
783765 AEXT_TRACE(dev->name, "command result is %s\n", command);
784766 ret = bytes_written;
785767 }
786768
787
-exit:
788
- if (list)
789
- kfree(list);
790769 return ret;
791770 }
792771
....@@ -884,30 +863,6 @@
884863 return ret;
885864 }
886865
887
-#ifdef BTC_WAR
888
-extern int btc_war;
889
-static int
890
-wl_ext_btc_war(struct net_device *dev, char *command, int total_len)
891
-{
892
- int user_btc_war = 0;
893
- bool enable = FALSE;
894
-
895
- sscanf(command, "%*s %d", &user_btc_war);
896
-
897
- AEXT_TRACE(dev->name, "btc_war=%d, user_btc_war=%d\n",
898
- btc_war, user_btc_war);
899
-
900
- if (btc_war >= 0) {
901
- btc_war = user_btc_war;
902
- if (btc_war > 0)
903
- enable = TRUE;
904
- wl_ext_btc_config(dev, enable);
905
- }
906
-
907
- return 0;
908
-}
909
-#endif /* BTC_WAR */
910
-
911866 s32
912867 wl_ext_connect(struct net_device *dev, struct wl_conn_info *conn_info)
913868 {
....@@ -918,7 +873,10 @@
918873 s32 err = 0;
919874 u32 chan_cnt = 0;
920875 s8 *iovar_buf = NULL;
876
+ int ioctl_ver = 0;
921877 char sec[64];
878
+
879
+ wl_ext_get_ioctl_ver(dev, &ioctl_ver);
922880
923881 if (dhd->conf->chip == BCM43362_CHIP_ID)
924882 goto set_ssid;
....@@ -975,7 +933,7 @@
975933 ext_join_params->assoc.chanspec_list[0] &= WL_CHANSPEC_CHAN_MASK;
976934 ext_join_params->assoc.chanspec_list[0] |= chspec;
977935 ext_join_params->assoc.chanspec_list[0] =
978
- wl_ext_chspec_host_to_driver(dhd,
936
+ wl_ext_chspec_host_to_driver(ioctl_ver,
979937 ext_join_params->assoc.chanspec_list[0]);
980938 }
981939 ext_join_params->assoc.chanspec_num = htod32(ext_join_params->assoc.chanspec_num);
....@@ -1012,7 +970,7 @@
1012970 else
1013971 memcpy(&join_params.params.bssid, &ether_bcast, ETH_ALEN);
1014972
1015
- wl_ext_ch_to_chanspec(dhd, conn_info->channel, &join_params, &join_params_size);
973
+ wl_ext_ch_to_chanspec(ioctl_ver, conn_info->channel, &join_params, &join_params_size);
1016974 AEXT_TRACE(dev->name, "join_param_size %zu\n", join_params_size);
1017975
1018976 if (join_params.ssid.SSID_len < IEEE80211_MAX_SSID_LEN) {
....@@ -1129,30 +1087,6 @@
11291087 return FALSE;
11301088 }
11311089
1132
-bool
1133
-wl_ext_passive_chan(struct net_device *dev, struct wl_chan_info *chan_info)
1134
-{
1135
- struct dhd_pub *dhd = dhd_get_pub(dev);
1136
- u32 chanspec;
1137
- s32 ret = BCME_OK;
1138
-
1139
- chanspec = wf_create_chspec_from_primary(chan_info->chan,
1140
- WL_CHANSPEC_BW_20, wl_ext_wlcband_to_chanspec_band(chan_info->band));
1141
-
1142
- chanspec = wl_ext_chspec_host_to_driver(dhd, chanspec);
1143
-
1144
- ret = wldev_iovar_getint(dev, "per_chan_info", &chanspec);
1145
- if (!ret) {
1146
- if (chanspec & WL_CHAN_PASSIVE)
1147
- return TRUE;
1148
- } else {
1149
- if (chan_info->band == WLC_BAND_5G && chan_info->chan >= 52 && chan_info->chan <= 144)
1150
- return TRUE;
1151
- }
1152
-
1153
- return FALSE;
1154
-}
1155
-
11561090 uint16
11571091 wl_ext_get_default_chan(struct net_device *dev,
11581092 uint16 *chan_2g, uint16 *chan_5g, bool nodfs)
....@@ -1183,8 +1117,6 @@
11831117 chan_info.band = WLC_BAND_5G;
11841118 chan_info.chan = chan_tmp;
11851119 if (wl_ext_dfs_chan(&chan_info) && nodfs)
1186
- continue;
1187
- else if (wl_ext_passive_chan(dev, &chan_info))
11881120 continue;
11891121 else
11901122 *chan_5g = chan_tmp;
....@@ -1265,6 +1197,69 @@
12651197
12661198 return ret;
12671199 }
1200
+
1201
+#ifdef WL_CFG80211
1202
+bool
1203
+wl_legacy_chip_check(struct net_device *net)
1204
+{
1205
+ struct dhd_pub *dhd = dhd_get_pub(net);
1206
+ uint chip;
1207
+
1208
+ chip = dhd_conf_get_chip(dhd);
1209
+
1210
+ if (chip == BCM43362_CHIP_ID || chip == BCM4330_CHIP_ID ||
1211
+ chip == BCM4334_CHIP_ID || chip == BCM43340_CHIP_ID ||
1212
+ chip == BCM43341_CHIP_ID || chip == BCM4324_CHIP_ID ||
1213
+ chip == BCM4335_CHIP_ID || chip == BCM4339_CHIP_ID ||
1214
+ chip == BCM4354_CHIP_ID || chip == BCM4356_CHIP_ID ||
1215
+ chip == BCM4371_CHIP_ID ||
1216
+ chip == BCM43430_CHIP_ID ||
1217
+ chip == BCM4345_CHIP_ID || chip == BCM43454_CHIP_ID ||
1218
+ chip == BCM4359_CHIP_ID ||
1219
+ chip == BCM43143_CHIP_ID || chip == BCM43242_CHIP_ID ||
1220
+ chip == BCM43569_CHIP_ID) {
1221
+ return true;
1222
+ }
1223
+
1224
+ return false;
1225
+}
1226
+
1227
+bool
1228
+wl_new_chip_check(struct net_device *net)
1229
+{
1230
+ struct dhd_pub *dhd = dhd_get_pub(net);
1231
+ uint chip;
1232
+
1233
+ chip = dhd_conf_get_chip(dhd);
1234
+
1235
+ if (chip == BCM4359_CHIP_ID || chip == BCM43012_CHIP_ID ||
1236
+ chip == BCM43751_CHIP_ID || chip == BCM43752_CHIP_ID) {
1237
+ return true;
1238
+ }
1239
+
1240
+ return false;
1241
+}
1242
+
1243
+bool
1244
+wl_extsae_chip(struct dhd_pub *dhd)
1245
+{
1246
+ uint chip;
1247
+
1248
+ chip = dhd_conf_get_chip(dhd);
1249
+
1250
+ if (chip == BCM43362_CHIP_ID || chip == BCM4330_CHIP_ID ||
1251
+ chip == BCM4334_CHIP_ID || chip == BCM43340_CHIP_ID ||
1252
+ chip == BCM43341_CHIP_ID || chip == BCM4324_CHIP_ID ||
1253
+ chip == BCM4335_CHIP_ID || chip == BCM4339_CHIP_ID ||
1254
+ chip == BCM4354_CHIP_ID || chip == BCM4356_CHIP_ID ||
1255
+ chip == BCM43143_CHIP_ID || chip == BCM43242_CHIP_ID ||
1256
+ chip == BCM43569_CHIP_ID) {
1257
+ return false;
1258
+ }
1259
+
1260
+ return true;
1261
+}
1262
+#endif
12681263
12691264 #ifdef WLEASYMESH
12701265 #define CMD_EASYMESH "EASYMESH"
....@@ -1480,7 +1475,7 @@
14801475 int total_len)
14811476 {
14821477 struct dhd_pub *dhd = dhd_get_pub(dev);
1483
- wl_mkeep_alive_pkt_v1_t *mkeep_alive_pktp;
1478
+ wl_mkeep_alive_pkt_t *mkeep_alive_pktp;
14841479 int ret = -1, i, ifidx, id, period=-1;
14851480 char *packet = NULL, *buf = NULL;
14861481 int bytes_written = 0;
....@@ -1508,7 +1503,7 @@
15081503 ret = wl_ext_iovar_getbuf(dev, "mkeep_alive", &id, sizeof(id), buf,
15091504 total_len, NULL);
15101505 if (!ret) {
1511
- mkeep_alive_pktp = (wl_mkeep_alive_pkt_v1_t *) buf;
1506
+ mkeep_alive_pktp = (wl_mkeep_alive_pkt_t *) buf;
15121507 bytes_written += snprintf(command+bytes_written, total_len,
15131508 "Id :%d\n"
15141509 "Period (msec) :%d\n"
....@@ -1716,22 +1711,24 @@
17161711 wl_ext_recal(struct net_device *dev, char *data, char *command,
17171712 int total_len)
17181713 {
1719
- struct dhd_pub *dhd = dhd_get_pub(dev);
17201714 int ret = 0, i, nchan, nssid = 0;
1721
- int params_size = WL_SCAN_PARAMS_V1_FIXED_SIZE + WL_NUMCHANNELS * sizeof(uint16);
1722
- wl_scan_params_v1_t *params = NULL;
1715
+ int params_size = WL_SCAN_PARAMS_FIXED_SIZE + WL_NUMCHANNELS * sizeof(uint16);
1716
+ wl_scan_params_t *params = NULL;
1717
+ int ioctl_ver;
17231718 char *p;
17241719
17251720 AEXT_TRACE(dev->name, "Enter\n");
17261721
17271722 if (data) {
17281723 params_size += WL_SCAN_PARAMS_SSID_MAX * sizeof(wlc_ssid_t);
1729
- params = (wl_scan_params_v1_t *) kzalloc(params_size, GFP_KERNEL);
1724
+ params = (wl_scan_params_t *) kzalloc(params_size, GFP_KERNEL);
17301725 if (params == NULL) {
17311726 ret = -ENOMEM;
17321727 goto exit;
17331728 }
17341729 memset(params, 0, params_size);
1730
+
1731
+ wl_ext_get_ioctl_ver(dev, &ioctl_ver);
17351732
17361733 memcpy(&params->bssid, &ether_bcast, ETHER_ADDR_LEN);
17371734 params->bss_type = DOT11_BSSTYPE_ANY;
....@@ -1753,7 +1750,7 @@
17531750 params->home_time = htod32(params->home_time);
17541751
17551752 for (i = 0; i < nchan; i++) {
1756
- wl_ext_chspec_host_to_driver(dhd, params->channel_list[i]);
1753
+ wl_ext_chspec_host_to_driver(ioctl_ver, params->channel_list[i]);
17571754 }
17581755
17591756 p = (char*)params->channel_list + nchan * sizeof(uint16);
....@@ -2530,6 +2527,22 @@
25302527 } csi_list_t;
25312528
25322529 static int
2530
+wl_ether_atoe(const char *a, struct ether_addr *n)
2531
+{
2532
+ char *c = NULL;
2533
+ int i = 0;
2534
+
2535
+ memset(n, 0, ETHER_ADDR_LEN);
2536
+ for (;;) {
2537
+ n->octet[i++] = (uint8)strtoul(a, &c, 16);
2538
+ if (!*c++ || i == ETHER_ADDR_LEN)
2539
+ break;
2540
+ a = c;
2541
+ }
2542
+ return (i == ETHER_ADDR_LEN);
2543
+}
2544
+
2545
+static int
25332546 wl_ext_csi(struct net_device *dev, char *data, char *command, int total_len)
25342547 {
25352548 csi_config_t csi, *csip;
....@@ -2548,7 +2561,7 @@
25482561
25492562 if (data) {
25502563 sscanf(data, "%s %d", mac, &period);
2551
- ret = bcm_ether_atoe(mac, &ea);
2564
+ ret = wl_ether_atoe(mac, &ea);
25522565 if (!ret) {
25532566 AEXT_ERROR(dev->name, "rejecting mac=%s, ret=%d\n", mac, ret);
25542567 goto exit;
....@@ -2646,34 +2659,6 @@
26462659 return bytes_written;
26472660 }
26482661
2649
-static int
2650
-wl_ext_disable_5g_band(struct net_device *dev, char *data, char *command,
2651
- int total_len)
2652
-{
2653
-#ifdef WL_CFG80211
2654
- struct bcm_cfg80211 *cfg = wl_get_cfg(dev);
2655
-#endif
2656
- int ret = -1;
2657
- int val;
2658
-
2659
- if (data) {
2660
- val = (int)simple_strtol(data, NULL, 0);
2661
- ret = wl_ext_iovar_setint(dev, "disable_5g_band", val);
2662
-#ifdef WL_CFG80211
2663
- if (!ret)
2664
- wl_update_wiphybands(cfg, true);
2665
-#endif
2666
- } else {
2667
- ret = wl_ext_iovar_getint(dev, "disable_5g_band", &val);
2668
- if (!ret) {
2669
- ret = snprintf(command, total_len, "%d", val);
2670
- AEXT_TRACE(dev->name, "command result is %s\n", command);
2671
- }
2672
- }
2673
-
2674
- return ret;
2675
-}
2676
-
26772662 typedef int (wl_ext_tpl_parse_t)(struct net_device *dev, char *data, char *command,
26782663 int total_len);
26792664
....@@ -2726,7 +2711,6 @@
27262711 {WLC_GET_VAR, WLC_SET_VAR, "csi", wl_ext_csi},
27272712 #endif /* CSI_SUPPORT */
27282713 {WLC_GET_VAR, WLC_SET_VAR, "country", wl_ext_get_country},
2729
- {WLC_GET_VAR, WLC_SET_VAR, "disable_5g_band", wl_ext_disable_5g_band},
27302714 };
27312715
27322716 /*
....@@ -2868,11 +2852,6 @@
28682852 else if (strnicmp(command, CMD_MONITOR, strlen(CMD_MONITOR)) == 0) {
28692853 *bytes_written = wl_ext_monitor(net, command, total_len);
28702854 }
2871
-#ifdef BTC_WAR
2872
- else if (strnicmp(command, CMD_BTC_WAR, strlen(CMD_BTC_WAR)) == 0) {
2873
- *bytes_written = wl_ext_btc_war(net, command, total_len);
2874
- }
2875
-#endif /* BTC_WAR */
28762855 else if (strnicmp(command, CMD_SET_SUSPEND_BCN_LI_DTIM, strlen(CMD_SET_SUSPEND_BCN_LI_DTIM)) == 0) {
28772856 int bcn_li_dtim;
28782857 bcn_li_dtim = (int)simple_strtol((command + strlen(CMD_SET_SUSPEND_BCN_LI_DTIM) + 1), NULL, 10);
....@@ -2966,7 +2945,7 @@
29662945 return -ENOMEM;
29672946 }
29682947
2969
- err = wldev_iovar_getbuf(dev, "chan_info_list", NULL,
2948
+ err = wl_ext_iovar_getbuf(dev, "chan_info_list", NULL,
29702949 0, list, LOCAL_BUF_LEN, NULL);
29712950 if (err == BCME_UNSUPPORTED) {
29722951 err = wl_ext_iovar_getbuf(dev, "chanspecs", NULL,
....@@ -3041,11 +3020,11 @@
30413020 s32 err = BCME_OK;
30423021
30433022 param.band = band;
3044
- err = wldev_iovar_getbuf(net, "bw_cap", &param, sizeof(param), buf,
3023
+ err = wl_ext_iovar_getbuf(net, "bw_cap", &param, sizeof(param), buf,
30453024 sizeof(buf), NULL);
30463025 if (err) {
30473026 if (err != BCME_UNSUPPORTED) {
3048
- AEXT_TRACE(net->name, "bw_cap failed, %d\n", err);
3027
+ AEXT_ERROR(net->name, "bw_cap failed, %d\n", err);
30493028 return err;
30503029 } else {
30513030 err = wl_ext_iovar_getint(net, "mimo_bw_cap", &bw_cap);
....@@ -3079,13 +3058,11 @@
30793058 #if defined(BSSCACHE)
30803059 wl_bss_cache_ctrl_t *bss_cache_ctrl,
30813060 #else
3082
- wl_scan_results_v109_t *bss_list,
3061
+ wl_scan_results_t *bss_list,
30833062 #endif /* BSSCACHE */
3084
- int *best_2g_ch, int *best_5g_ch, int *best_6g_ch)
3063
+ int ioctl_ver, int *best_2g_ch, int *best_5g_ch, int *best_6g_ch)
30853064 {
3086
- struct dhd_pub *dhd = dhd_get_pub(net);
30873065 struct wl_bss_info *bi = NULL; /* must be initialized */
3088
- struct wl_chan_info chan_info;
30893066 s32 i, j;
30903067 #if defined(BSSCACHE)
30913068 wl_bss_cache_t *node;
....@@ -3096,7 +3073,8 @@
30963073 s32 distance_6g;
30973074 #endif /* WL_6G_BAND */
30983075 s32 cen_ch, distance, distance_2g, distance_5g, chanspec, min_ap=999;
3099
- wl_uint32_list_t *list = NULL;
3076
+ u8 valid_chan_list[sizeof(u32)*(MAX_CTRL_CHANSPECS + 1)];
3077
+ wl_uint32_list_t *list;
31003078 int ret;
31013079 chanspec_t chspec;
31023080 u32 channel;
....@@ -3111,33 +3089,24 @@
31113089 memset(six_g_band8, -1, sizeof(six_g_band8));
31123090 #endif /* WL_6G_BAND */
31133091
3114
- list = kzalloc(sizeof(u32)*(MAX_CTRL_CHANSPECS + 1), GFP_KERNEL);
3115
- if (list == NULL) {
3116
- AEXT_ERROR(net->name, "kzalloc failed\n");
3117
- ret = -ENOMEM;
3118
- goto exit;
3119
- }
3092
+ memset(valid_chan_list, 0, sizeof(valid_chan_list));
3093
+ list = (wl_uint32_list_t *)(void *) valid_chan_list;
31203094
31213095 ret = wl_construct_ctl_chanspec_list(net, list);
31223096 if (ret < 0) {
31233097 AEXT_ERROR(net->name, "get channels failed with %d\n", ret);
3124
- goto exit;
3098
+ return 0;
31253099 } else {
31263100 for (i = 0; i < list->count; i++) {
31273101 chspec = list->element[i];
31283102 channel = wf_chspec_ctlchan(chspec);
3129
- chan_info.band = CHSPEC2WLC_BAND(chspec);
3130
- chan_info.chan = channel;
3131
- if (wl_ext_passive_chan(net, &chan_info)) {
3132
- continue;
3133
- }
31343103 if (CHSPEC_IS2G(chspec) && (channel >= CH_MIN_2G_CHANNEL) &&
3135
- (channel <= CH_MAX_2G_CHANNEL)) {
3104
+ (channel <= CH_MAX_2G_CHANNEL)) {
31363105 b_band[channel-1] = 0;
31373106 }
31383107 #ifdef WL_6G_BAND
31393108 else if (CHSPEC_IS6G(chspec) && (channel >= CH_MIN_6G_CHANNEL) &&
3140
- (channel <= CH_MAX_6G_CHANNEL)) {
3109
+ (channel <= CH_MAX_6G_CHANNEL)) {
31413110 if (channel <= 93)
31423111 six_g_band5[(channel-1)/4] = 0;
31433112 else if (channel >= 97 && channel <= 109)
....@@ -3173,9 +3142,9 @@
31733142 #if defined(BSSCACHE)
31743143 bi = node->results.bss_info;
31753144 #else
3176
- bi = bi ? (wl_bss_info_v109_t *)((uintptr)bi + dtoh32(bi->length)) : bss_list->bss_info;
3145
+ bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : bss_list->bss_info;
31773146 #endif /* BSSCACHE */
3178
- chanspec = wl_ext_chspec_driver_to_host(dhd, bi->chanspec);
3147
+ chanspec = wl_ext_chspec_driver_to_host(ioctl_ver, bi->chanspec);
31793148 cen_ch = CHSPEC_CHANNEL(bi->chanspec);
31803149 distance = 0;
31813150 if (CHSPEC_IS20(chanspec))
....@@ -3198,25 +3167,25 @@
31983167 else if (CHSPEC_IS6G(chanspec)) {
31993168 distance += distance_6g;
32003169 if (cen_ch <= 93) {
3201
- for (j=0; j<ARRAYSIZE(six_g_band5); j++) {
3170
+ for (j=0; j<ARRAYSIZE(a_band1); j++) {
32023171 if (six_g_band5[j] >= 0 && abs(cen_ch-(93+j*4)) <= distance)
32033172 six_g_band5[j] += 1;
32043173 }
32053174 }
32063175 else if (channel >= 97 && channel <= 109) {
3207
- for (j=0; j<ARRAYSIZE(six_g_band6); j++) {
3176
+ for (j=0; j<ARRAYSIZE(a_band4); j++) {
32083177 if (six_g_band6[j] >= 0 && abs(cen_ch-(97+j*4)) <= distance)
32093178 six_g_band6[j] += 1;
32103179 }
32113180 }
32123181 else if (channel >= 117 && channel <= 181) {
3213
- for (j=0; j<ARRAYSIZE(six_g_band7); j++) {
3182
+ for (j=0; j<ARRAYSIZE(a_band4); j++) {
32143183 if (six_g_band7[j] >= 0 && abs(cen_ch-(117+j*4)) <= distance)
32153184 six_g_band7[j] += 1;
32163185 }
32173186 }
32183187 else if (channel >= 189 && channel <= 221) {
3219
- for (j=0; j<ARRAYSIZE(six_g_band8); j++) {
3188
+ for (j=0; j<ARRAYSIZE(a_band4); j++) {
32203189 if (six_g_band8[j] >= 0 && abs(cen_ch-(189+j*4)) <= distance)
32213190 six_g_band8[j] += 1;
32223191 }
....@@ -3346,9 +3315,7 @@
33463315 }
33473316
33483317 exit:
3349
- if (list)
3350
- kfree(list);
3351
- return ret;
3318
+ return 0;
33523319 }
33533320 #endif /* WL_CFG80211 || WL_ESCAN */
33543321
....@@ -3384,7 +3351,7 @@
33843351 memset(reqbuf, 0, CHANSPEC_BUF_SIZE);
33853352
33863353 acs_band = wl_ext_wlcband_to_chanspec_band(band);
3387
- if (acs_band == INVCHANSPEC) {
3354
+ if ((uint32)acs_band == WLC_BAND_INVALID) {
33883355 acs_band = WL_CHANSPEC_BAND_2G;
33893356 }
33903357
....@@ -3449,7 +3416,7 @@
34493416 kfree(reqbuf);
34503417 }
34513418
3452
- return chosen;
3419
+ return channel;
34533420 }
34543421 #endif /* WL_CFG80211 */
34553422
....@@ -3459,36 +3426,29 @@
34593426 {
34603427 int ret = -1, i, cnt = 0;
34613428 int retry = 0, retry_max, retry_interval = 250, up = 1;
3462
- wl_scan_info_t *scan_info = NULL;
3463
-
3464
- scan_info = kmalloc(sizeof(wl_scan_info_t), GFP_KERNEL);
3465
- if (scan_info == NULL) {
3466
- AEXT_ERROR(dev->name, "kzalloc failed\n");
3467
- ret = -ENOMEM;
3468
- goto exit;
3469
- }
3429
+ wl_scan_info_t scan_info;
34703430
34713431 retry_max = WL_ESCAN_TIMER_INTERVAL_MS/retry_interval;
34723432 ret = wldev_ioctl_get(dev, WLC_GET_UP, &up, sizeof(s32));
34733433 if (ret < 0 || up == 0) {
34743434 ret = wldev_ioctl_set(dev, WLC_UP, &up, sizeof(s32));
34753435 }
3476
- memset(scan_info, 0, sizeof(wl_scan_info_t));
3436
+ memset(&scan_info, 0, sizeof(wl_scan_info_t));
34773437 if (band == WLC_BAND_2G || band == WLC_BAND_AUTO) {
34783438 for (i=0; i<13; i++) {
3479
- scan_info->channels.channel[i+cnt] = wf_create_chspec_from_primary(i+1,
3439
+ scan_info.channels.channel[i+cnt] = wf_create_chspec_from_primary(i+1,
34803440 WL_CHANSPEC_BW_20, WL_CHANSPEC_BAND_2G);
34813441 }
34823442 cnt += 13;
34833443 }
34843444 if (band == WLC_BAND_5G || band == WLC_BAND_AUTO) {
34853445 for (i=0; i<4; i++) {
3486
- scan_info->channels.channel[i+cnt] = wf_create_chspec_from_primary(36+i*4,
3446
+ scan_info.channels.channel[i+cnt] = wf_create_chspec_from_primary(36+i*4,
34873447 WL_CHANSPEC_BW_20, WL_CHANSPEC_BAND_5G);
34883448 }
34893449 cnt += 4;
34903450 for (i=0; i<4; i++) {
3491
- scan_info->channels.channel[i+cnt] = wf_create_chspec_from_primary(149+i*4,
3451
+ scan_info.channels.channel[i+cnt] = wf_create_chspec_from_primary(149+i*4,
34923452 WL_CHANSPEC_BW_20, WL_CHANSPEC_BAND_5G);
34933453 }
34943454 cnt += 4;
....@@ -3496,7 +3456,7 @@
34963456 #ifdef WL_6G_BAND
34973457 if (band == WLC_BAND_6G || band == WLC_BAND_AUTO) {
34983458 for (i=0; i<59; i++) {
3499
- scan_info->channels.channel[i+cnt] = wf_create_chspec_from_primary(1+i*4,
3459
+ scan_info.channels.channel[i+cnt] = wf_create_chspec_from_primary(1+i*4,
35003460 WL_CHANSPEC_BW_20, WL_CHANSPEC_BAND_6G);
35013461 }
35023462 cnt += 59;
....@@ -3504,13 +3464,13 @@
35043464 #endif /* WL_6G_BAND */
35053465 if (band == WLC_BAND_2G)
35063466 fast_scan = FALSE;
3507
- scan_info->channels.count = cnt;
3467
+ scan_info.channels.count = cnt;
35083468 if (fast_scan)
3509
- scan_info->scan_time = 40;
3510
- scan_info->bcast_ssid = TRUE;
3469
+ scan_info.scan_time = 40;
3470
+ scan_info.bcast_ssid = TRUE;
35113471 retry = retry_max;
35123472 while (retry--) {
3513
- ret = wl_escan_set_scan(dev, scan_info);
3473
+ ret = wl_escan_set_scan(dev, &scan_info);
35143474 if (!ret)
35153475 break;
35163476 OSL_SLEEP(retry_interval);
....@@ -3520,16 +3480,13 @@
35203480 ret = -1;
35213481 }
35223482
3523
-exit:
3524
- if (scan_info)
3525
- kfree(scan_info);
35263483 return ret;
35273484 }
35283485
3529
-static int
3486
+int
35303487 wl_ext_drv_apcs(struct net_device *dev, uint32 band)
35313488 {
3532
- int ret = 0, chanspec = 0;
3489
+ int ret = 0, channel = 0;
35333490 struct dhd_pub *dhd = dhd_get_pub(dev);
35343491 struct wl_escan_info *escan = NULL;
35353492 int retry = 0, retry_max, retry_interval = 250;
....@@ -3544,22 +3501,15 @@
35443501 retry = retry_max;
35453502 while (retry--) {
35463503 if (escan->escan_state == ESCAN_STATE_IDLE) {
3547
- if (band == WLC_BAND_5G) {
3548
- chanspec = wf_create_chspec_from_primary(wf_chspec_primary20_chan(escan->best_5g_ch),
3549
- WL_CHANSPEC_BW_20, WL_CHANSPEC_BAND_5G);
3550
- }
3504
+ if (band == WLC_BAND_5G)
3505
+ channel = escan->best_5g_ch;
35513506 #ifdef WL_6G_BAND
3552
- else if (band == WLC_BAND_6G) {
3553
- chanspec = wf_create_chspec_from_primary(wf_chspec_primary20_chan(escan->best_6g_ch),
3554
- WL_CHANSPEC_BW_20, WL_CHANSPEC_BAND_6G);
3555
- }
3507
+ else if (band == WLC_BAND_6G)
3508
+ channel = escan->best_6g_ch;
35563509 #endif /* WL_6G_BAND */
3557
- else {
3558
- chanspec = wf_create_chspec_from_primary(wf_chspec_primary20_chan(escan->best_2g_ch),
3559
- WL_CHANSPEC_BW_20, WL_CHANSPEC_BAND_2G);
3560
- }
3561
- WL_MSG(dev->name, "selected channel = %d(0x%x)\n",
3562
- wf_chspec_ctlchan(chanspec), chanspec);
3510
+ else
3511
+ channel = escan->best_2g_ch;
3512
+ WL_MSG(dev->name, "selected channel = %d\n", channel);
35633513 goto done;
35643514 }
35653515 AEXT_INFO(dev->name, "escan_state=%d, %d tried, ret = %d\n",
....@@ -3570,51 +3520,46 @@
35703520 done:
35713521 escan->autochannel = 0;
35723522
3573
- return chanspec;
3523
+ return channel;
35743524 }
35753525 #endif /* WL_ESCAN */
35763526
35773527 int
35783528 wl_ext_autochannel(struct net_device *dev, uint acs, uint32 band)
35793529 {
3580
- int chosen = 0;
3581
- uint16 chan_2g, chan_5g, channel;
3530
+ int channel = 0;
3531
+ uint16 chan_2g, chan_5g;
35823532
3583
- AEXT_INFO(dev->name, "acs=0x%x, band=%s\n", acs, WLCBAND2STR(band));
3533
+ AEXT_INFO(dev->name, "acs=0x%x, band=%d \n", acs, band);
35843534
35853535 #ifdef WL_CFG80211
35863536 if (acs & ACS_FW_BIT) {
35873537 int ret = 0;
35883538 ret = wldev_ioctl_get(dev, WLC_GET_CHANNEL_SEL, &channel, sizeof(channel));
3589
- chosen = 0;
3539
+ channel = 0;
35903540 if (ret != BCME_UNSUPPORTED)
3591
- chosen = wl_ext_fw_apcs(dev, band);
3592
- if (chosen)
3593
- return chosen;
3541
+ channel = wl_ext_fw_apcs(dev, band);
3542
+ if (channel)
3543
+ return channel;
35943544 }
35953545 #endif
35963546
35973547 #ifdef WL_ESCAN
35983548 if (acs & ACS_DRV_BIT)
3599
- chosen = wl_ext_drv_apcs(dev, band);
3549
+ channel = wl_ext_drv_apcs(dev, band);
36003550 #endif /* WL_ESCAN */
36013551
3602
- if (chosen == 0) {
3552
+ if (channel == 0) {
36033553 wl_ext_get_default_chan(dev, &chan_2g, &chan_5g, TRUE);
36043554 if (band == WLC_BAND_5G) {
3605
- chosen = wf_create_chspec_from_primary(wf_chspec_primary20_chan(chan_5g),
3606
- WL_CHANSPEC_BW_20, WL_CHANSPEC_BAND_5G);
36073555 channel = chan_5g;
36083556 } else {
3609
- chosen = wf_create_chspec_from_primary(wf_chspec_primary20_chan(chan_2g),
3610
- WL_CHANSPEC_BW_20, WL_CHANSPEC_BAND_2G);
36113557 channel = chan_2g;
36123558 }
3613
- AEXT_ERROR(dev->name, "ACS failed. Fall back to default channel (%s-%d) \n",
3614
- CHSPEC2BANDSTR(chosen), channel);
3559
+ AEXT_ERROR(dev->name, "ACS failed. Fall back to default channel (%d) \n", channel);
36153560 }
36163561
3617
- return chosen;
3562
+ return channel;
36183563 }
36193564
36203565 #if defined(RSSIAVG)
....@@ -3812,10 +3757,10 @@
38123757
38133758 void
38143759 wl_update_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl,
3815
- wl_scan_results_v109_t *ss_list)
3760
+ wl_scan_results_t *ss_list)
38163761 {
38173762 wl_rssi_cache_t *node, *prev, *leaf, **rssi_head;
3818
- wl_bss_info_v109_t *bi = NULL;
3763
+ wl_bss_info_t *bi = NULL;
38193764 int i, j, k;
38203765 struct osl_timespec now, timeout;
38213766
....@@ -3841,7 +3786,7 @@
38413786 node = *rssi_head;
38423787 prev = NULL;
38433788 k = 0;
3844
- bi = bi ? (wl_bss_info_v109_t *)((uintptr)bi + dtoh32(bi->length)) : ss_list->bss_info;
3789
+ bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : ss_list->bss_info;
38453790 for (;node;) {
38463791 if (!memcmp(&node->BSSID, &bi->BSSID, ETHER_ADDR_LEN)) {
38473792 AEXT_INFO("wlan", "Update %d with BSSID %pM, RSSI=%3d, SSID \"%s\"\n",
....@@ -4167,11 +4112,11 @@
41674112 #if defined(RSSIAVG)
41684113 wl_rssi_cache_ctrl_t *rssi_cache_ctrl,
41694114 #endif /* RSSIAVG */
4170
- wl_scan_results_v109_t *ss_list)
4115
+ wl_scan_results_t *ss_list)
41714116 {
41724117 wl_bss_cache_t *node, *node_target = NULL, *prev, *leaf, **bss_head;
41734118 wl_bss_cache_t *node_rssi_prev = NULL, *node_rssi = NULL;
4174
- wl_bss_info_v109_t *bi = NULL;
4119
+ wl_bss_info_t *bi = NULL;
41754120 int i, k=0, bss_num = 0;
41764121 struct osl_timespec now, timeout;
41774122 int16 rssi_min;
....@@ -4206,7 +4151,7 @@
42064151 prev = NULL;
42074152 node_target = NULL;
42084153 node_rssi_prev = NULL;
4209
- bi = bi ? (wl_bss_info_v109_t *)((uintptr)bi + dtoh32(bi->length)) : ss_list->bss_info;
4154
+ bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : ss_list->bss_info;
42104155
42114156 // find the bss with same BSSID
42124157 for (;node;) {