Skip to contentSkip to conversation

staging: rtl8723bs: add get_channel implementation

PATCH Superseded Fabio Aiuto 2 participants 8 messages Jul 14, 2021 – Jul 17, 2021 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover staging: rtl8723bs: add get_channel implementation

This patchset adds cfg80211 get_channel implementation. One of the benefits is having displayed channel info in iw dev output.

Done some code cleaning as well.

Tested-on: Lenovo Ideapad MiiX-300-10IBY

Fabio Aiuto (3):
staging: rtl8723bs: add get_channel cfg80211 implementation
staging: rtl8723bs: convert IsSupportedHT to snake_case
staging: rtl8723bs: fix camel case issue

 .../staging/rtl8723bs/core/rtw_ioctl_set.c    |  2 +-
 .../staging/rtl8723bs/core/rtw_wlan_util.c    |  2 +-
 drivers/staging/rtl8723bs/include/ieee80211.h |  2 +-
 .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 53 ++++++++++++++++++-
 4 files changed, 55 insertions(+), 4 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/3 staging: rtl8723bs: add get_channel cfg80211 implementation

add get_channel cfg80211 implementation to let userspace programs rely on nl80211 protocol to display channel information.

Old iw dev output:

phy#0

	Interface wlan0
		ifindex 2
		wdev 0x1
		addr 34:c3:d2:73:eb:c7
		ssid Fabio
		type managed
		txpower 12.00 dBm

Fixed output:

phy#0

	Interface wlan0
		ifindex 2
		wdev 0x1
		addr 34:c3:d2:73:eb:c7
		ssid Fabio
		type managed
	new-->	channel 11 (2462 MHz), width: 20 MHz, center1: 2462 Mhz
		txpower 12.00 dBm
---
 .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 53 ++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +52 -1
index fd747c8d920e..d198d10ec272 100644
@@ -2100,7 +2100,58 @@ void rtw_cfg80211_indicate_sta_disassoc(struct adapter *padapter, unsigned char
 	cfg80211_del_sta(ndev, da, GFP_ATOMIC);
 }
 
+static u8 rtw_get_chan_type(struct adapter *adapter)
+{
+	struct mlme_ext_priv *mlme_ext = &adapter->mlmeextpriv;
+
+	switch (mlme_ext->cur_bwmode) {
+	case CHANNEL_WIDTH_20:
+		if (IsSupportedHT(adapter->registrypriv.wireless_mode))
+			return NL80211_CHAN_HT20;
+		else
+			return NL80211_CHAN_NO_HT;
+	case CHANNEL_WIDTH_40:
+		if (mlme_ext->cur_ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER)
+			return NL80211_CHAN_HT40PLUS;
+		else
+			return NL80211_CHAN_HT40MINUS;
+	default:
+		return NL80211_CHAN_HT20;
+	}
 
+	return NL80211_CHAN_HT20;
+}
+
+static int cfg80211_rtw_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
+				    struct cfg80211_chan_def *chandef)
+{
+	struct adapter *adapter = wiphy_to_adapter(wiphy);
+	struct registry_priv *registrypriv = &adapter->registrypriv;
+	enum nl80211_channel_type chan_type;
+	struct ieee80211_channel *chan = NULL;
+	int channel;
+	int freq;
+
+	if (!adapter->rtw_wdev)
+		return -ENODEV;
+
+	channel = rtw_get_oper_ch(adapter);
+	if (!channel)
+		return -ENODATA;
+
+	freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ);
+
+	chan = ieee80211_get_channel(adapter->rtw_wdev->wiphy, freq);
+
+	if (registrypriv->ht_enable) {
+		chan_type = rtw_get_chan_type(adapter);
+		cfg80211_chandef_create(chandef, chan, chan_type);
+	} else {
+		cfg80211_chandef_create(chandef, chan, NL80211_CHAN_NO_HT);
+	}
+
+	return 0;
+}
 
 static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struct net_device *ndev)
 {
@@ -2838,7 +2889,7 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
 	.set_pmksa = cfg80211_rtw_set_pmksa,
 	.del_pmksa = cfg80211_rtw_del_pmksa,
 	.flush_pmksa = cfg80211_rtw_flush_pmksa,
-
+	.get_channel = cfg80211_rtw_get_channel,
 	.add_virtual_intf = cfg80211_rtw_add_virtual_intf,
 	.del_virtual_intf = cfg80211_rtw_del_virtual_intf,
 
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/3 staging: rtl8723bs: convert IsSupportedHT to snake_case

In reply to Fabio Aiuto

convert IsSupportedHT to snake case is_supported_ht.

---
 drivers/staging/rtl8723bs/core/rtw_ioctl_set.c    | 2 +-
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c    | 2 +-
 drivers/staging/rtl8723bs/include/ieee80211.h     | 2 +-
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +1 -1
index bd5056507f53..fcbbdbe5448b 100644
@@ -554,7 +554,7 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter)
 
 	short_GI = query_ra_short_GI(psta);
 
-	if (IsSupportedHT(psta->wireless_mode)) {
+	if (is_supported_ht(psta->wireless_mode)) {
 		rtw_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
 
 		max_rate = rtw_mcs_rate(rf_type,
drivers/staging/rtl8723bs/core/rtw_wlan_util.c +1 -1
index c06b74f6569a..56c5cb318fdf 100644
@@ -55,7 +55,7 @@ u8 networktype_to_raid_ex(struct adapter *adapter, struct sta_info *psta)
 
 	if (cur_rf_type == RF_1T1R) {
 		rf_type = RF_1T1R;
-	} else if (IsSupportedHT(psta->wireless_mode)) {
+	} else if (is_supported_ht(psta->wireless_mode)) {
 		if (psta->ra_mask & 0xfff00000)
 			rf_type = RF_2T2R;
 	}
drivers/staging/rtl8723bs/include/ieee80211.h +1 -1
index 378c21595e05..8eb0557a077a 100644
@@ -167,7 +167,7 @@ enum network_type {
 
 #define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false)
 #define IsSupportedTxOFDM(NetType) (((NetType) & (WIRELESS_11G) ? true : false)
-#define IsSupportedHT(NetType) (((NetType) & (WIRELESS_11_24N)) ? true : false)
+#define is_supported_ht(NetType) (((NetType) & (WIRELESS_11_24N)) ? true : false)
 
 struct ieee_param {
 	u32 cmd;
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +1 -1
index d198d10ec272..368e575c24af 100644
@@ -2106,7 +2106,7 @@ static u8 rtw_get_chan_type(struct adapter *adapter)
 
 	switch (mlme_ext->cur_bwmode) {
 	case CHANNEL_WIDTH_20:
-		if (IsSupportedHT(adapter->registrypriv.wireless_mode))
+		if (is_supported_ht(adapter->registrypriv.wireless_mode))
 			return NL80211_CHAN_HT20;
 		else
 			return NL80211_CHAN_NO_HT;
Signature · 1 line
2.20.1
#3 lore raw

PATCH 3/3 staging: rtl8723bs: fix camel case issue

In reply to Fabio Aiuto

fix following post commit hook checkpatch issue:

CHECK: Avoid CamelCase: <NetType>
45: FILE: drivers/staging/rtl8723bs/include/ieee80211.h:170:
+#define is_supported_ht(NetType) (((NetType)

	& (WIRELESS_11_24N)) ? true : false)
---
 drivers/staging/rtl8723bs/include/ieee80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/ieee80211.h +1 -1
index 8eb0557a077a..b2c1a7dafcee 100644
@@ -167,7 +167,7 @@ enum network_type {
 
 #define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false)
 #define IsSupportedTxOFDM(NetType) (((NetType) & (WIRELESS_11G) ? true : false)
-#define is_supported_ht(NetType) (((NetType) & (WIRELESS_11_24N)) ? true : false)
+#define is_supported_ht(net_type) (((net_type) & (WIRELESS_11_24N)) ? true : false)
 
 struct ieee_param {
 	u32 cmd;
Signature · 1 line
2.20.1
#4 lore raw

Re: [PATCH 3/3] staging: rtl8723bs: fix camel case issue

Quoted 17 lines · Fabio Aiuto

fix following post commit hook checkpatch issue:

CHECK: Avoid CamelCase: <NetType>
45: FILE: drivers/staging/rtl8723bs/include/ieee80211.h:170:
+#define is_supported_ht(NetType) (((NetType)

	& (WIRELESS_11_24N)) ? true : false)
---
 drivers/staging/rtl8723bs/include/ieee80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/ieee80211.h +0 -0
index 8eb0557a077a..b2c1a7dafcee 100644

drivers/staging/rtl8723bs/include/ieee80211.h enum network_type { · line 169

Quoted 3 lines
drivers/staging/rtl8723bs/include/ieee80211.h +0 -0
@@ -167,7 +167,7 @@ enum network_type {
 
 #define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false)
 #define IsSupportedTxOFDM(NetType) (((NetType) & (WIRELESS_11G) ? true : false)

These are the same.

drivers/staging/rtl8723bs/include/ieee80211.h enum network_type { · line 171

Quoted 3 lines
drivers/staging/rtl8723bs/include/ieee80211.h +1 -1
-#define is_supported_ht(NetType) (((NetType) & (WIRELESS_11_24N)) ? true : false)
+#define is_supported_ht(net_type) (((net_type) & (WIRELESS_11_24N)) ? true : false)
 

regards,
dan carpenter

#5 lore raw

Re: [PATCH 3/3] staging: rtl8723bs: fix camel case issue

Hello Dan,

Quoted 19 lines · Dan Carpenter
Quoted 18 lines · Fabio Aiuto

fix following post commit hook checkpatch issue:

CHECK: Avoid CamelCase: <NetType>
45: FILE: drivers/staging/rtl8723bs/include/ieee80211.h:170:
+#define is_supported_ht(NetType) (((NetType)

	& (WIRELESS_11_24N)) ? true : false)
---
 drivers/staging/rtl8723bs/include/ieee80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/ieee80211.h +0 -0
index 8eb0557a077a..b2c1a7dafcee 100644
@@ -167,7 +167,7 @@ enum network_type {
 
Quoted 8 lines

drivers/staging/rtl8723bs/include/ieee80211.h enum network_type { · line 169

Quoted 2 lines
drivers/staging/rtl8723bs/include/ieee80211.h +0 -0
 #define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false)
 #define IsSupportedTxOFDM(NetType) (((NetType) & (WIRELESS_11G) ? true : false)

These are the same.

drivers/staging/rtl8723bs/include/ieee80211.h enum network_type { · line 171

Quoted 3 lines
drivers/staging/rtl8723bs/include/ieee80211.h +1 -1
-#define is_supported_ht(NetType) (((NetType) & (WIRELESS_11_24N)) ? true : false)
+#define is_supported_ht(net_type) (((net_type) & (WIRELESS_11_24N)) ? true : false)
 

NetType -> net_type, or did you mean something else?

Quoted 3 lines

regards,
dan carpenter

thank you,

fabio

#6 lore raw

Re: [PATCH 3/3] staging: rtl8723bs: fix camel case issue

Quoted 27 lines · Fabio Aiuto

Hello Dan,

Quoted 24 lines · Dan Carpenter
Quoted 17 lines · Fabio Aiuto

fix following post commit hook checkpatch issue:

CHECK: Avoid CamelCase: <NetType>
45: FILE: drivers/staging/rtl8723bs/include/ieee80211.h:170:
+#define is_supported_ht(NetType) (((NetType)

	& (WIRELESS_11_24N)) ? true : false)
---
 drivers/staging/rtl8723bs/include/ieee80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/ieee80211.h +0 -0
index 8eb0557a077a..b2c1a7dafcee 100644

drivers/staging/rtl8723bs/include/ieee80211.h enum network_type { · line 169

Quoted 3 lines
drivers/staging/rtl8723bs/include/ieee80211.h +0 -0
@@ -167,7 +167,7 @@ enum network_type {
 
 #define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false)
 #define IsSupportedTxOFDM(NetType) (((NetType) & (WIRELESS_11G) ? true : false)

These are the same.

Quoted 5 lines
Quoted 3 lines

drivers/staging/rtl8723bs/include/ieee80211.h enum network_type { · line 171

Quoted 3 lines
drivers/staging/rtl8723bs/include/ieee80211.h +1 -1
-#define is_supported_ht(NetType) (((NetType) & (WIRELESS_11_24N)) ? true : false)
+#define is_supported_ht(net_type) (((net_type) & (WIRELESS_11_24N)) ? true : false)
 

NetType -> net_type, or did you mean something else?

Yes. If you're going to change it then change the surrounding code as well.

regards,
dan carpenter

#7 lore raw

Re: [PATCH 3/3] staging: rtl8723bs: fix camel case issue

Hi Dan,

Quoted 34 lines · Dan Carpenter
Quoted 27 lines · Fabio Aiuto

Hello Dan,

Quoted 24 lines · Dan Carpenter
Quoted 17 lines · Fabio Aiuto

fix following post commit hook checkpatch issue:

CHECK: Avoid CamelCase: <NetType>
45: FILE: drivers/staging/rtl8723bs/include/ieee80211.h:170:
+#define is_supported_ht(NetType) (((NetType)

	& (WIRELESS_11_24N)) ? true : false)
---
 drivers/staging/rtl8723bs/include/ieee80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/ieee80211.h +0 -0
index 8eb0557a077a..b2c1a7dafcee 100644

drivers/staging/rtl8723bs/include/ieee80211.h enum network_type { · line 169

Quoted 3 lines
drivers/staging/rtl8723bs/include/ieee80211.h +0 -0
@@ -167,7 +167,7 @@ enum network_type {
 
 #define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false)
 #define IsSupportedTxOFDM(NetType) (((NetType) & (WIRELESS_11G) ? true : false)

These are the same.

Quoted 5 lines
Quoted 3 lines

drivers/staging/rtl8723bs/include/ieee80211.h enum network_type { · line 171

Quoted 3 lines
drivers/staging/rtl8723bs/include/ieee80211.h +1 -1
-#define is_supported_ht(NetType) (((NetType) & (WIRELESS_11_24N)) ? true : false)
+#define is_supported_ht(net_type) (((net_type) & (WIRELESS_11_24N)) ? true : false)
 

NetType -> net_type, or did you mean something else?

Quoted 6 lines

Yes. If you're going to change it then change the surrounding code as well.

regards,
dan carpenter

ok, will add a patch in next v2,

thank you,

fabio