forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_cfgvif.c
old mode 100644new mode 100755
....@@ -519,7 +519,7 @@
519519 * role to station type while bringing down the interface
520520 */
521521 if (p2p_ndev->ieee80211_ptr->iftype == NL80211_IFTYPE_STATION) {
522
- WL_DBG_MEM(("%s, Change to GC base role\n", p2p_ndev->name));
522
+ WL_DBG_MEM(("%s, Change to GC base role\n", __FUNCTION__));
523523 return WL_IF_TYPE_P2P_GC;
524524 }
525525
....@@ -888,7 +888,6 @@
888888 WL_DBG(("%s:Mac addr" MACDBG "\n",
889889 __FUNCTION__, MAC2STRDBG(mac_addr)));
890890
891
-#if defined(SPECIFIC_MAC_GEN_SCHEME)
892891 if ((wl_iftype == WL_IF_TYPE_P2P_DISC) || (wl_iftype == WL_IF_TYPE_AP) ||
893892 (wl_iftype == WL_IF_TYPE_P2P_GO) || (wl_iftype == WL_IF_TYPE_P2P_GC)) {
894893 /* Avoid invoking release mac addr code for interfaces using
....@@ -896,11 +895,6 @@
896895 */
897896 return BCME_OK;
898897 }
899
-#else
900
- if (wl_iftype == WL_IF_TYPE_P2P_DISC) {
901
- return BCME_OK;
902
- }
903
-#endif /* SPECIFIC_MAC_GEN_SCHEME */
904898
905899 /* Fetch last two bytes of mac address */
906900 org_toggle_bytes = ntoh16(*((u16 *)&ndev->dev_addr[4]));
....@@ -957,7 +951,7 @@
957951 * released. Ensure to call wl_release_vif_macaddress to free up
958952 * the mac address.
959953 */
960
-#if defined(SPECIFIC_MAC_GEN_SCHEME)
954
+#if defined (SPECIFIC_MAC_GEN_SCHEME)
961955 if (wl_iftype == WL_IF_TYPE_P2P_DISC || wl_iftype == WL_IF_TYPE_AP) {
962956 mac_addr[0] |= 0x02;
963957 } else if ((wl_iftype == WL_IF_TYPE_P2P_GO) || (wl_iftype == WL_IF_TYPE_P2P_GC)) {
....@@ -968,7 +962,7 @@
968962 if (wl_iftype == WL_IF_TYPE_P2P_DISC) {
969963 mac_addr[0] |= 0x02;
970964 }
971
-#endif /* SPECIFIC_MAC_GEN_SCHEME */
965
+#endif /* SEPCIFIC_MAC_GEN_SCHEME */
972966 else {
973967 /* For locally administered mac addresses, we keep the
974968 * OUI part constant and just work on the last two bytes.
....@@ -1337,9 +1331,9 @@
13371331 if (is_p2p_group_iface(ndev->ieee80211_ptr) && (type == NL80211_IFTYPE_STATION)) {
13381332 /* For role downgrade cases, we keep interface role as GC */
13391333 netinfo->iftype = WL_IF_TYPE_P2P_GC;
1340
- WL_DBG_MEM(("[%s] Set base role to GC, current role"
1334
+ WL_DBG_MEM(("[%s] Set base role to GC, current role"
13411335 "ndev->ieee80211_ptr->iftype = %d\n",
1342
- ndev->name, ndev->ieee80211_ptr->iftype));
1336
+ __FUNCTION__, ndev->ieee80211_ptr->iftype));
13431337 } else {
13441338 netinfo->iftype = wl_iftype;
13451339 }
....@@ -1544,16 +1538,11 @@
15441538 s32
15451539 wl_cfg80211_set_channel(struct wiphy *wiphy, struct net_device *dev,
15461540 struct ieee80211_channel *chan,
1547
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
1548
- enum nl80211_channel_type channel_type
1549
-#else
1550
- enum nl80211_chan_width width
1551
-#endif
1552
-)
1541
+ enum nl80211_channel_type channel_type)
15531542 {
15541543 chanspec_t chspec = INVCHANSPEC;
15551544 chanspec_t cur_chspec = INVCHANSPEC;
1556
- u32 band_width = WL_CHANSPEC_BW_20, bw = WL_CHANSPEC_BW_20;
1545
+ u32 bw = WL_CHANSPEC_BW_20;
15571546 s32 err = BCME_OK;
15581547 struct bcm_cfg80211 *cfg = wiphy_priv(wiphy);
15591548 #if defined(CUSTOM_SET_CPUCORE) || defined(APSTA_RESTRICTED_CHANNEL)
....@@ -1562,39 +1551,6 @@
15621551 u16 center_freq = chan->center_freq;
15631552
15641553 dev = ndev_to_wlc_ndev(dev, cfg);
1565
-
1566
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
1567
- switch (channel_type) {
1568
- case NL80211_CHAN_HT40MINUS:
1569
- /* secondary channel is below the control channel */
1570
- band_width = WL_CHANSPEC_BW_40;
1571
- break;
1572
- case NL80211_CHAN_HT40PLUS:
1573
- /* secondary channel is above the control channel */
1574
- band_width = WL_CHANSPEC_BW_40;
1575
- break;
1576
- default:
1577
- band_width = WL_CHANSPEC_BW_20;
1578
- }
1579
-#else
1580
- switch (width)
1581
- {
1582
- case NL80211_CHAN_WIDTH_160:
1583
- band_width = WL_CHANSPEC_BW_160;
1584
- break;
1585
- case NL80211_CHAN_WIDTH_80P80:
1586
- case NL80211_CHAN_WIDTH_80:
1587
- band_width = WL_CHANSPEC_BW_80;
1588
- break;
1589
- case NL80211_CHAN_WIDTH_40:
1590
- band_width = WL_CHANSPEC_BW_40;
1591
- break;
1592
- default:
1593
- band_width = WL_CHANSPEC_BW_20;
1594
- break;
1595
- }
1596
-#endif
1597
-
15981554 #ifdef WL_EXT_IAPSTA
15991555 if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP ||
16001556 dev->ieee80211_ptr->iftype == NL80211_IFTYPE_P2P_GO) {
....@@ -1615,9 +1571,8 @@
16151571 #endif
16161572 chspec = wl_freq_to_chanspec(center_freq);
16171573
1618
- WL_MSG(dev->name, "netdev_ifidx(%d) chan_width(%d) target channel(%s-%d %sMHz)\n",
1619
- dev->ifindex, width, CHSPEC2BANDSTR(chspec),
1620
- CHSPEC_CHANNEL(chspec), WLCWIDTH2STR(band_width));
1574
+ WL_MSG(dev->name, "netdev_ifidx(%d), chan_type(%d) target channel(%s-%d) \n",
1575
+ dev->ifindex, channel_type, CHSPEC2BANDSTR(chspec), CHSPEC_CHANNEL(chspec));
16211576
16221577 #ifdef WL_P2P_6G
16231578 if (!(cfg->p2p_6g_enabled)) {
....@@ -1629,6 +1584,22 @@
16291584 #ifdef WL_P2P_6G
16301585 }
16311586 #endif /* WL_P2P_6G */
1587
+
1588
+#ifdef NOT_YET
1589
+ switch (channel_type) {
1590
+ case NL80211_CHAN_HT40MINUS:
1591
+ /* secondary channel is below the control channel */
1592
+ chspec = CH40MHZ_CHSPEC(CHSPEC_CHANNEL(chspec), WL_CHANSPEC_CTL_SB_UPPER);
1593
+ break;
1594
+ case NL80211_CHAN_HT40PLUS:
1595
+ /* secondary channel is above the control channel */
1596
+ chspec = CH40MHZ_CHSPEC(CHSPEC_CHANNEL(chspec), WL_CHANSPEC_CTL_SB_LOWER);
1597
+ break;
1598
+ default:
1599
+ chspec = CH20MHZ_CHSPEC(CHSPEC_CHANNEL(chspec));
1600
+
1601
+ }
1602
+#endif /* NOT_YET */
16321603
16331604 #if defined(APSTA_RESTRICTED_CHANNEL)
16341605 /* Some customer platform used limited number of channels
....@@ -1671,18 +1642,7 @@
16711642 if (err < 0) {
16721643 WL_ERR(("Failed to get bandwidth information, err=%d\n", err));
16731644 return err;
1674
- } else if (bw < band_width) {
1675
- WL_ERR(("capability force band_width=0x%X to be 0x%X\n", band_width, bw));
1676
- band_width = bw;
16771645 }
1678
-#ifdef HOSTAPD_BW_SUPPORT
1679
- WL_MSG(dev->name, "hostapd bw(%sMHz) <= chip bw(%sMHz)\n",
1680
- wf_chspec_to_bw_str(band_width), wf_chspec_to_bw_str(bw));
1681
-#else
1682
- WL_MSG(dev->name, "hostapd bw(%sMHz) => chip bw(%sMHz)\n",
1683
- wf_chspec_to_bw_str(band_width), wf_chspec_to_bw_str(bw));
1684
- band_width = bw;
1685
-#endif
16861646
16871647 /* In case of 5G downgrade BW to 80MHz as 160MHz channels falls in DFS */
16881648 if (CHSPEC_IS5G(chspec) && (bw == WL_CHANSPEC_BW_160)) {
....@@ -1690,7 +1650,7 @@
16901650 }
16911651 set_channel:
16921652 cur_chspec = wf_create_chspec_from_primary(wf_chspec_primary20_chan(chspec),
1693
- band_width, CHSPEC_BAND(chspec));
1653
+ bw, CHSPEC_BAND(chspec));
16941654 #ifdef WL_6G_BAND
16951655 if (cfg->acs_chspec &&
16961656 CHSPEC_IS6G(cfg->acs_chspec) &&
....@@ -2809,7 +2769,7 @@
28092769 dhd_pub_t *dhd = (dhd_pub_t *)(cfg->pub);
28102770 #endif /* WLEASYMESH */
28112771
2812
- new_chip = dhd_conf_new_chip_check(cfg->pub);
2772
+ new_chip = wl_new_chip_check(dev);
28132773
28142774 if ((bssidx = wl_get_bssidx_by_wdev(cfg, dev->ieee80211_ptr)) < 0) {
28152775 WL_ERR(("Find p2p index from wdev(%p) failed\n", dev->ieee80211_ptr));
....@@ -3718,23 +3678,14 @@
37183678 * hardcoded values in 'wl_cfg80211_set_channel()'.
37193679 */
37203680 #if ((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) && !defined(WL_COMPAT_WIRELESS))
3721
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
3722
- if (!dev->ieee80211_ptr->u.ap.preset_chandef.chan)
3723
-#else
3724
- if (!dev->ieee80211_ptr->preset_chandef.chan)
3725
-#endif
3726
- {
3681
+ if (!dev->ieee80211_ptr->preset_chandef.chan) {
37273682 WL_ERR(("chan is NULL\n"));
37283683 err = -EINVAL;
37293684 goto fail;
37303685 }
37313686 if ((err = wl_cfg80211_set_channel(wiphy, dev,
3732
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
3733
- dev->ieee80211_ptr->u.ap.preset_chandef.chan,
3734
-#else
3735
- dev->ieee80211_ptr->preset_chandef.chan,
3736
-#endif /* CFG80211_BKPORT_MLO */
3737
- info->chandef.width) < 0)) {
3687
+ dev->ieee80211_ptr->preset_chandef.chan,
3688
+ NL80211_CHAN_HT20) < 0)) {
37383689 WL_ERR(("Set channel failed \n"));
37393690 goto fail;
37403691 }
....@@ -3828,11 +3779,7 @@
38283779 if (err) {
38293780 WL_ERR(("ADD/SET beacon failed\n"));
38303781 wl_flush_fw_log_buffer(dev, FW_LOGSET_MASK_ALL);
3831
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
3832
- wl_cfg80211_stop_ap(wiphy, dev, 0);
3833
-#else
38343782 wl_cfg80211_stop_ap(wiphy, dev);
3835
-#endif /* CFG80211_BKPORT_MLO */
38363783 if (dev_role == NL80211_IFTYPE_AP) {
38373784 #ifdef WL_EXT_IAPSTA
38383785 if (!wl_ext_iapsta_iftype_enabled(dev, WL_IF_TYPE_AP)) {
....@@ -3873,11 +3820,7 @@
38733820 s32
38743821 wl_cfg80211_stop_ap(
38753822 struct wiphy *wiphy,
3876
- struct net_device *dev
3877
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
3878
- , unsigned int link_id
3879
-#endif /* CFG80211_BKPORT_MLO */
3880
- )
3823
+ struct net_device *dev)
38813824 {
38823825 int err = 0;
38833826 u32 dev_role = 0;
....@@ -4561,10 +4504,8 @@
45614504 (reason == WLC_E_REASON_INITIAL_ASSOC) &&
45624505 (wl_get_mode_by_netdev(cfg, ndev) == WL_MODE_AP)) {
45634506 if (!wl_get_drv_status(cfg, AP_CREATED, ndev)) {
4564
- char chan_str[64];
45654507 /* AP/GO brought up successfull in firmware */
4566
- wl_ext_get_chan_str(ndev, chan_str, sizeof(chan_str));
4567
- WL_MSG(ndev->name, "AP/GO Link up (%s)\n", chan_str);
4508
+ WL_MSG(ndev->name, "AP/GO Link up\n");
45684509 wl_set_drv_status(cfg, AP_CREATED, ndev);
45694510 if (delayed_work_pending(&cfg->ap_work)) {
45704511 cancel_delayed_work_sync(&cfg->ap_work);
....@@ -5144,42 +5085,44 @@
51445085 }
51455086 #endif /* WL_CFG80211_ACL */
51465087
5088
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0))
51475089 int wl_chspec_chandef(chanspec_t chanspec,
5148
- struct cfg80211_chan_def *chandef, struct wiphy *wiphy)
5090
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
5091
+ struct cfg80211_chan_def *chandef,
5092
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && (LINUX_VERSION_CODE <= (3, 7, 0)))
5093
+ struct chan_info *chaninfo,
5094
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)) */
5095
+ struct wiphy *wiphy)
51495096 {
51505097 uint16 freq = 0;
5098
+ int chan_type = 0;
5099
+ int channel = 0;
51515100 struct ieee80211_channel *chan;
51525101
51535102 if (!chandef) {
51545103 return -1;
5155
- } else {
5156
- memset(chandef, 0, sizeof(*chandef));
51575104 }
5158
-
5159
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
5160
- chandef->center_freq1 = wl_channel_to_frequency(CHSPEC_CHANNEL(chanspec), CHSPEC_BAND(chanspec));
5161
- freq = wl_channel_to_frequency(wf_chspec_primary20_chan(chanspec), CHSPEC_BAND(chanspec));
5162
- chandef->chan = ieee80211_get_channel(wiphy, freq);
5163
- chandef->center_freq2 = 0;
5105
+ channel = CHSPEC_CHANNEL(chanspec);
51645106
51655107 switch (CHSPEC_BW(chanspec)) {
51665108 case WL_CHANSPEC_BW_20:
5167
- chandef->width = NL80211_CHAN_WIDTH_20;
5109
+ chan_type = NL80211_CHAN_HT20;
51685110 break;
5169
-
51705111 case WL_CHANSPEC_BW_40:
5171
- chandef->width = NL80211_CHAN_WIDTH_40;
5112
+ {
5113
+ if (CHSPEC_SB_UPPER(chanspec)) {
5114
+ channel += CH_10MHZ_APART;
5115
+ } else {
5116
+ channel -= CH_10MHZ_APART;
5117
+ }
5118
+ }
5119
+ chan_type = NL80211_CHAN_HT40PLUS;
51725120 break;
51735121
5122
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
51745123 case WL_CHANSPEC_BW_80:
5175
- chandef->width = NL80211_CHAN_WIDTH_80;
5176
- break;
5177
-
51785124 case WL_CHANSPEC_BW_8080:
51795125 {
5180
- /* XXX Left as is but need proper calculation for center_freq2 is used */
5181
- int chan_type = 0;
5182
- int channel = 0;
51835126 uint16 sb = CHSPEC_CTL_SB(chanspec);
51845127
51855128 if (sb == WL_CHANSPEC_CTL_SB_LL) {
....@@ -5197,45 +5140,19 @@
51975140 chan_type = NL80211_CHAN_HT40MINUS;
51985141 else if (sb == WL_CHANSPEC_CTL_SB_UL || sb == WL_CHANSPEC_CTL_SB_UU)
51995142 chan_type = NL80211_CHAN_HT40PLUS;
5200
- freq = wl_channel_to_frequency(channel, CHSPEC_BAND(chanspec));
5201
- chan = ieee80211_get_channel(wiphy, freq);
5202
- cfg80211_chandef_create(chandef, chan, chan_type);
5203
- return 0;
5204
- break;
52055143 }
5206
-
5144
+ break;
52075145 case WL_CHANSPEC_BW_160:
5208
- chandef->width = NL80211_CHAN_WIDTH_160;
5209
- break;
5210
- default:
5211
- chandef->width = NL80211_CHAN_WIDTH_20;
5212
- break;
5213
- }
5214
-
5215
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && \
5216
- (LINUX_VERSION_CODE <= KERNEL_VERSION (3, 7, 0)))
5217
-
5218
- int chan_type = 0;
5219
- int channel = 0;
5220
- channel = CHSPEC_CHANNEL(chanspec);
5221
- switch (CHSPEC_BW(chanspec)) {
5222
- case WL_CHANSPEC_BW_20:
5146
+ channel = wf_chspec_primary20_chan(chanspec);
5147
+ /* Using base chan_type as kernel does not define chan_type for 160 MHz */
52235148 chan_type = NL80211_CHAN_HT20;
52245149 break;
5225
- case WL_CHANSPEC_BW_40:
5226
- if (CHSPEC_SB_UPPER(chanspec)) {
5227
- channel += CH_10MHZ_APART;
5228
- } else {
5229
- channel -= CH_10MHZ_APART;
5230
- }
5231
- chan_type = NL80211_CHAN_HT40PLUS;
5232
- break;
5233
-
5150
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0)) */
52345151 default:
52355152 chan_type = NL80211_CHAN_HT20;
52365153 break;
5237
- }
52385154
5155
+ }
52395156 freq = wl_channel_to_frequency(channel, CHSPEC_BAND(chanspec));
52405157 chan = ieee80211_get_channel(wiphy, freq);
52415158 WL_DBG(("channel:%d freq:%d chan_type: %d chan_ptr:%p \n",
....@@ -5247,19 +5164,24 @@
52475164 return -EINVAL;
52485165 }
52495166
5250
- chandef->freq = freq;
5251
- chandef->chan_type = chan_type;
5167
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
5168
+ cfg80211_chandef_create(chandef, chan, chan_type);
5169
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && (LINUX_VERSION_CODE <= (3, 7, 0)))
5170
+ chaninfo->freq = freq;
5171
+ chaninfo->chan_type = chan_type;
52525172 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0)) */
5253
-
52545173 return 0;
52555174 }
52565175
5257
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0))
52585176 void
52595177 wl_cfg80211_ch_switch_notify(struct net_device *dev, uint16 chanspec, struct wiphy *wiphy)
52605178 {
52615179 u32 freq;
5180
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
52625181 struct cfg80211_chan_def chandef;
5182
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && (LINUX_VERSION_CODE <= (3, 7, 0)))
5183
+ struct chan_info chaninfo;
5184
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0)) */
52635185
52645186 if (!wiphy) {
52655187 WL_ERR(("wiphy is null\n"));
....@@ -5274,21 +5196,21 @@
52745196 }
52755197 #endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION (3, 18, 0)) */
52765198
5277
- if (wl_chspec_chandef(chanspec, &chandef, wiphy)) {
5199
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
5200
+ if (wl_chspec_chandef(chanspec, &chandef, wiphy))
5201
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && (LINUX_VERSION_CODE <= (3, 7, 0)))
5202
+ if (wl_chspec_chandef(chanspec, &chaninfo, wiphy))
5203
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0)) */
5204
+ {
52785205 WL_ERR(("chspec_chandef failed\n"));
52795206 return;
52805207 }
5281
-
52825208 #if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
52835209 freq = chandef.chan ? chandef.chan->center_freq : chandef.center_freq1;
5284
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
5285
- cfg80211_ch_switch_notify(dev, &chandef, 0);
5286
-#else
52875210 cfg80211_ch_switch_notify(dev, &chandef);
5288
-#endif /* CFG80211_BKPORT_MLO */
52895211 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && (LINUX_VERSION_CODE <= (3, 7, 0)))
5290
- freq = chandef.freq;
5291
- cfg80211_ch_switch_notify(dev, freq, chandef.chan_type);
5212
+ freq = chan_info.freq;
5213
+ cfg80211_ch_switch_notify(dev, freq, chan_info.chan_type);
52925214 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0)) */
52935215
52945216 WL_MSG(dev->name, "Channel switch notification for freq: %d chanspec: 0x%x\n",