hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_cfgvif.c
....@@ -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", __FUNCTION__));
522
+ WL_DBG_MEM(("%s, Change to GC base role\n", p2p_ndev->name));
523523 return WL_IF_TYPE_P2P_GC;
524524 }
525525
....@@ -888,6 +888,7 @@
888888 WL_DBG(("%s:Mac addr" MACDBG "\n",
889889 __FUNCTION__, MAC2STRDBG(mac_addr)));
890890
891
+#if defined(SPECIFIC_MAC_GEN_SCHEME)
891892 if ((wl_iftype == WL_IF_TYPE_P2P_DISC) || (wl_iftype == WL_IF_TYPE_AP) ||
892893 (wl_iftype == WL_IF_TYPE_P2P_GO) || (wl_iftype == WL_IF_TYPE_P2P_GC)) {
893894 /* Avoid invoking release mac addr code for interfaces using
....@@ -895,6 +896,11 @@
895896 */
896897 return BCME_OK;
897898 }
899
+#else
900
+ if (wl_iftype == WL_IF_TYPE_P2P_DISC) {
901
+ return BCME_OK;
902
+ }
903
+#endif /* SPECIFIC_MAC_GEN_SCHEME */
898904
899905 /* Fetch last two bytes of mac address */
900906 org_toggle_bytes = ntoh16(*((u16 *)&ndev->dev_addr[4]));
....@@ -951,7 +957,7 @@
951957 * released. Ensure to call wl_release_vif_macaddress to free up
952958 * the mac address.
953959 */
954
-#if defined (SPECIFIC_MAC_GEN_SCHEME)
960
+#if defined(SPECIFIC_MAC_GEN_SCHEME)
955961 if (wl_iftype == WL_IF_TYPE_P2P_DISC || wl_iftype == WL_IF_TYPE_AP) {
956962 mac_addr[0] |= 0x02;
957963 } else if ((wl_iftype == WL_IF_TYPE_P2P_GO) || (wl_iftype == WL_IF_TYPE_P2P_GC)) {
....@@ -962,7 +968,7 @@
962968 if (wl_iftype == WL_IF_TYPE_P2P_DISC) {
963969 mac_addr[0] |= 0x02;
964970 }
965
-#endif /* SEPCIFIC_MAC_GEN_SCHEME */
971
+#endif /* SPECIFIC_MAC_GEN_SCHEME */
966972 else {
967973 /* For locally administered mac addresses, we keep the
968974 * OUI part constant and just work on the last two bytes.
....@@ -1331,9 +1337,9 @@
13311337 if (is_p2p_group_iface(ndev->ieee80211_ptr) && (type == NL80211_IFTYPE_STATION)) {
13321338 /* For role downgrade cases, we keep interface role as GC */
13331339 netinfo->iftype = WL_IF_TYPE_P2P_GC;
1334
- WL_DBG_MEM(("[%s] Set base role to GC, current role"
1340
+ WL_DBG_MEM(("[%s] Set base role to GC, current role"
13351341 "ndev->ieee80211_ptr->iftype = %d\n",
1336
- __FUNCTION__, ndev->ieee80211_ptr->iftype));
1342
+ ndev->name, ndev->ieee80211_ptr->iftype));
13371343 } else {
13381344 netinfo->iftype = wl_iftype;
13391345 }
....@@ -1538,11 +1544,16 @@
15381544 s32
15391545 wl_cfg80211_set_channel(struct wiphy *wiphy, struct net_device *dev,
15401546 struct ieee80211_channel *chan,
1541
- enum nl80211_channel_type channel_type)
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
+)
15421553 {
15431554 chanspec_t chspec = INVCHANSPEC;
15441555 chanspec_t cur_chspec = INVCHANSPEC;
1545
- u32 bw = WL_CHANSPEC_BW_20;
1556
+ u32 band_width = WL_CHANSPEC_BW_20, bw = WL_CHANSPEC_BW_20;
15461557 s32 err = BCME_OK;
15471558 struct bcm_cfg80211 *cfg = wiphy_priv(wiphy);
15481559 #if defined(CUSTOM_SET_CPUCORE) || defined(APSTA_RESTRICTED_CHANNEL)
....@@ -1551,6 +1562,39 @@
15511562 u16 center_freq = chan->center_freq;
15521563
15531564 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
+
15541598 #ifdef WL_EXT_IAPSTA
15551599 if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP ||
15561600 dev->ieee80211_ptr->iftype == NL80211_IFTYPE_P2P_GO) {
....@@ -1571,9 +1615,9 @@
15711615 #endif
15721616 chspec = wl_freq_to_chanspec(center_freq);
15731617
1574
- WL_MSG(dev->name, "netdev_ifidx(%d) chan_type(%d) target channel(%s-%d %sMHz)\n",
1575
- dev->ifindex, channel_type, CHSPEC2BANDSTR(chspec),
1576
- CHSPEC_CHANNEL(chspec), wf_chspec_to_bw_str(chspec));
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));
15771621
15781622 #ifdef WL_P2P_6G
15791623 if (!(cfg->p2p_6g_enabled)) {
....@@ -1585,22 +1629,6 @@
15851629 #ifdef WL_P2P_6G
15861630 }
15871631 #endif /* WL_P2P_6G */
1588
-
1589
-#ifdef NOT_YET
1590
- switch (channel_type) {
1591
- case NL80211_CHAN_HT40MINUS:
1592
- /* secondary channel is below the control channel */
1593
- chspec = CH40MHZ_CHSPEC(CHSPEC_CHANNEL(chspec), WL_CHANSPEC_CTL_SB_UPPER);
1594
- break;
1595
- case NL80211_CHAN_HT40PLUS:
1596
- /* secondary channel is above the control channel */
1597
- chspec = CH40MHZ_CHSPEC(CHSPEC_CHANNEL(chspec), WL_CHANSPEC_CTL_SB_LOWER);
1598
- break;
1599
- default:
1600
- chspec = CH20MHZ_CHSPEC(CHSPEC_CHANNEL(chspec));
1601
-
1602
- }
1603
-#endif /* NOT_YET */
16041632
16051633 #if defined(APSTA_RESTRICTED_CHANNEL)
16061634 /* Some customer platform used limited number of channels
....@@ -1643,7 +1671,18 @@
16431671 if (err < 0) {
16441672 WL_ERR(("Failed to get bandwidth information, err=%d\n", err));
16451673 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;
16461677 }
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
16471686
16481687 /* In case of 5G downgrade BW to 80MHz as 160MHz channels falls in DFS */
16491688 if (CHSPEC_IS5G(chspec) && (bw == WL_CHANSPEC_BW_160)) {
....@@ -1651,7 +1690,7 @@
16511690 }
16521691 set_channel:
16531692 cur_chspec = wf_create_chspec_from_primary(wf_chspec_primary20_chan(chspec),
1654
- bw, CHSPEC_BAND(chspec));
1693
+ band_width, CHSPEC_BAND(chspec));
16551694 #ifdef WL_6G_BAND
16561695 if (cfg->acs_chspec &&
16571696 CHSPEC_IS6G(cfg->acs_chspec) &&
....@@ -3694,8 +3733,8 @@
36943733 dev->ieee80211_ptr->u.ap.preset_chandef.chan,
36953734 #else
36963735 dev->ieee80211_ptr->preset_chandef.chan,
3697
-#endif
3698
- NL80211_CHAN_HT20) < 0)) {
3736
+#endif /* CFG80211_BKPORT_MLO */
3737
+ info->chandef.width) < 0)) {
36993738 WL_ERR(("Set channel failed \n"));
37003739 goto fail;
37013740 }
....@@ -3793,7 +3832,7 @@
37933832 wl_cfg80211_stop_ap(wiphy, dev, 0);
37943833 #else
37953834 wl_cfg80211_stop_ap(wiphy, dev);
3796
-#endif
3835
+#endif /* CFG80211_BKPORT_MLO */
37973836 if (dev_role == NL80211_IFTYPE_AP) {
37983837 #ifdef WL_EXT_IAPSTA
37993838 if (!wl_ext_iapsta_iftype_enabled(dev, WL_IF_TYPE_AP)) {
....@@ -3837,7 +3876,7 @@
38373876 struct net_device *dev
38383877 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
38393878 , unsigned int link_id
3840
-#endif
3879
+#endif /* CFG80211_BKPORT_MLO */
38413880 )
38423881 {
38433882 int err = 0;
....@@ -5246,7 +5285,7 @@
52465285 cfg80211_ch_switch_notify(dev, &chandef, 0);
52475286 #else
52485287 cfg80211_ch_switch_notify(dev, &chandef);
5249
-#endif
5288
+#endif /* CFG80211_BKPORT_MLO */
52505289 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && (LINUX_VERSION_CODE <= (3, 7, 0)))
52515290 freq = chandef.freq;
52525291 cfg80211_ch_switch_notify(dev, freq, chandef.chan_type);