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
....@@ -1571,9 +1571,8 @@
15711571 #endif
15721572 chspec = wl_freq_to_chanspec(center_freq);
15731573
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));
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));
15771576
15781577 #ifdef WL_P2P_6G
15791578 if (!(cfg->p2p_6g_enabled)) {
....@@ -2770,7 +2769,7 @@
27702769 dhd_pub_t *dhd = (dhd_pub_t *)(cfg->pub);
27712770 #endif /* WLEASYMESH */
27722771
2773
- new_chip = dhd_conf_new_chip_check(cfg->pub);
2772
+ new_chip = wl_new_chip_check(dev);
27742773
27752774 if ((bssidx = wl_get_bssidx_by_wdev(cfg, dev->ieee80211_ptr)) < 0) {
27762775 WL_ERR(("Find p2p index from wdev(%p) failed\n", dev->ieee80211_ptr));
....@@ -3679,23 +3678,14 @@
36793678 * hardcoded values in 'wl_cfg80211_set_channel()'.
36803679 */
36813680 #if ((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) && !defined(WL_COMPAT_WIRELESS))
3682
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
3683
- if (!dev->ieee80211_ptr->u.ap.preset_chandef.chan)
3684
-#else
3685
- if (!dev->ieee80211_ptr->preset_chandef.chan)
3686
-#endif
3687
- {
3681
+ if (!dev->ieee80211_ptr->preset_chandef.chan) {
36883682 WL_ERR(("chan is NULL\n"));
36893683 err = -EINVAL;
36903684 goto fail;
36913685 }
36923686 if ((err = wl_cfg80211_set_channel(wiphy, dev,
3693
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
3694
- dev->ieee80211_ptr->u.ap.preset_chandef.chan,
3695
-#else
3696
- dev->ieee80211_ptr->preset_chandef.chan,
3697
-#endif
3698
- NL80211_CHAN_HT20) < 0)) {
3687
+ dev->ieee80211_ptr->preset_chandef.chan,
3688
+ NL80211_CHAN_HT20) < 0)) {
36993689 WL_ERR(("Set channel failed \n"));
37003690 goto fail;
37013691 }
....@@ -3789,11 +3779,7 @@
37893779 if (err) {
37903780 WL_ERR(("ADD/SET beacon failed\n"));
37913781 wl_flush_fw_log_buffer(dev, FW_LOGSET_MASK_ALL);
3792
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
3793
- wl_cfg80211_stop_ap(wiphy, dev, 0);
3794
-#else
37953782 wl_cfg80211_stop_ap(wiphy, dev);
3796
-#endif
37973783 if (dev_role == NL80211_IFTYPE_AP) {
37983784 #ifdef WL_EXT_IAPSTA
37993785 if (!wl_ext_iapsta_iftype_enabled(dev, WL_IF_TYPE_AP)) {
....@@ -3834,11 +3820,7 @@
38343820 s32
38353821 wl_cfg80211_stop_ap(
38363822 struct wiphy *wiphy,
3837
- struct net_device *dev
3838
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
3839
- , unsigned int link_id
3840
-#endif
3841
- )
3823
+ struct net_device *dev)
38423824 {
38433825 int err = 0;
38443826 u32 dev_role = 0;
....@@ -4522,10 +4504,8 @@
45224504 (reason == WLC_E_REASON_INITIAL_ASSOC) &&
45234505 (wl_get_mode_by_netdev(cfg, ndev) == WL_MODE_AP)) {
45244506 if (!wl_get_drv_status(cfg, AP_CREATED, ndev)) {
4525
- char chan_str[64];
45264507 /* AP/GO brought up successfull in firmware */
4527
- wl_ext_get_chan_str(ndev, chan_str, sizeof(chan_str));
4528
- WL_MSG(ndev->name, "AP/GO Link up (%s)\n", chan_str);
4508
+ WL_MSG(ndev->name, "AP/GO Link up\n");
45294509 wl_set_drv_status(cfg, AP_CREATED, ndev);
45304510 if (delayed_work_pending(&cfg->ap_work)) {
45314511 cancel_delayed_work_sync(&cfg->ap_work);
....@@ -5105,42 +5085,44 @@
51055085 }
51065086 #endif /* WL_CFG80211_ACL */
51075087
5088
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0))
51085089 int wl_chspec_chandef(chanspec_t chanspec,
5109
- 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)
51105096 {
51115097 uint16 freq = 0;
5098
+ int chan_type = 0;
5099
+ int channel = 0;
51125100 struct ieee80211_channel *chan;
51135101
51145102 if (!chandef) {
51155103 return -1;
5116
- } else {
5117
- memset(chandef, 0, sizeof(*chandef));
51185104 }
5119
-
5120
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
5121
- chandef->center_freq1 = wl_channel_to_frequency(CHSPEC_CHANNEL(chanspec), CHSPEC_BAND(chanspec));
5122
- freq = wl_channel_to_frequency(wf_chspec_primary20_chan(chanspec), CHSPEC_BAND(chanspec));
5123
- chandef->chan = ieee80211_get_channel(wiphy, freq);
5124
- chandef->center_freq2 = 0;
5105
+ channel = CHSPEC_CHANNEL(chanspec);
51255106
51265107 switch (CHSPEC_BW(chanspec)) {
51275108 case WL_CHANSPEC_BW_20:
5128
- chandef->width = NL80211_CHAN_WIDTH_20;
5109
+ chan_type = NL80211_CHAN_HT20;
51295110 break;
5130
-
51315111 case WL_CHANSPEC_BW_40:
5132
- 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;
51335120 break;
51345121
5122
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
51355123 case WL_CHANSPEC_BW_80:
5136
- chandef->width = NL80211_CHAN_WIDTH_80;
5137
- break;
5138
-
51395124 case WL_CHANSPEC_BW_8080:
51405125 {
5141
- /* XXX Left as is but need proper calculation for center_freq2 is used */
5142
- int chan_type = 0;
5143
- int channel = 0;
51445126 uint16 sb = CHSPEC_CTL_SB(chanspec);
51455127
51465128 if (sb == WL_CHANSPEC_CTL_SB_LL) {
....@@ -5158,45 +5140,19 @@
51585140 chan_type = NL80211_CHAN_HT40MINUS;
51595141 else if (sb == WL_CHANSPEC_CTL_SB_UL || sb == WL_CHANSPEC_CTL_SB_UU)
51605142 chan_type = NL80211_CHAN_HT40PLUS;
5161
- freq = wl_channel_to_frequency(channel, CHSPEC_BAND(chanspec));
5162
- chan = ieee80211_get_channel(wiphy, freq);
5163
- cfg80211_chandef_create(chandef, chan, chan_type);
5164
- return 0;
5165
- break;
51665143 }
5167
-
5144
+ break;
51685145 case WL_CHANSPEC_BW_160:
5169
- chandef->width = NL80211_CHAN_WIDTH_160;
5170
- break;
5171
- default:
5172
- chandef->width = NL80211_CHAN_WIDTH_20;
5173
- break;
5174
- }
5175
-
5176
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && \
5177
- (LINUX_VERSION_CODE <= KERNEL_VERSION (3, 7, 0)))
5178
-
5179
- int chan_type = 0;
5180
- int channel = 0;
5181
- channel = CHSPEC_CHANNEL(chanspec);
5182
- switch (CHSPEC_BW(chanspec)) {
5183
- 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 */
51845148 chan_type = NL80211_CHAN_HT20;
51855149 break;
5186
- case WL_CHANSPEC_BW_40:
5187
- if (CHSPEC_SB_UPPER(chanspec)) {
5188
- channel += CH_10MHZ_APART;
5189
- } else {
5190
- channel -= CH_10MHZ_APART;
5191
- }
5192
- chan_type = NL80211_CHAN_HT40PLUS;
5193
- break;
5194
-
5150
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0)) */
51955151 default:
51965152 chan_type = NL80211_CHAN_HT20;
51975153 break;
5198
- }
51995154
5155
+ }
52005156 freq = wl_channel_to_frequency(channel, CHSPEC_BAND(chanspec));
52015157 chan = ieee80211_get_channel(wiphy, freq);
52025158 WL_DBG(("channel:%d freq:%d chan_type: %d chan_ptr:%p \n",
....@@ -5208,19 +5164,24 @@
52085164 return -EINVAL;
52095165 }
52105166
5211
- chandef->freq = freq;
5212
- 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;
52135172 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0)) */
5214
-
52155173 return 0;
52165174 }
52175175
5218
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0))
52195176 void
52205177 wl_cfg80211_ch_switch_notify(struct net_device *dev, uint16 chanspec, struct wiphy *wiphy)
52215178 {
52225179 u32 freq;
5180
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
52235181 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)) */
52245185
52255186 if (!wiphy) {
52265187 WL_ERR(("wiphy is null\n"));
....@@ -5235,21 +5196,21 @@
52355196 }
52365197 #endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION (3, 18, 0)) */
52375198
5238
- 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
+ {
52395205 WL_ERR(("chspec_chandef failed\n"));
52405206 return;
52415207 }
5242
-
52435208 #if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
52445209 freq = chandef.chan ? chandef.chan->center_freq : chandef.center_freq1;
5245
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO)
5246
- cfg80211_ch_switch_notify(dev, &chandef, 0);
5247
-#else
52485210 cfg80211_ch_switch_notify(dev, &chandef);
5249
-#endif
52505211 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && (LINUX_VERSION_CODE <= (3, 7, 0)))
5251
- freq = chandef.freq;
5252
- 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);
52535214 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0)) */
52545215
52555216 WL_MSG(dev->name, "Channel switch notification for freq: %d chanspec: 0x%x\n",