[PATCH 03/12] staging: rtl8723au: Use struct ieee80211_mcs_info to describe MCS information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx>

The original RTL code defined the MCS information as a 16 byte array
and blindly applied it's masking over the full array, ignoring the
fact that only the first 10 bytes describe the rx_mask and the rest
are different fields.

Signed-off-by: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx>
---
 drivers/staging/rtl8723au/core/rtw_ieee80211.c | 52 +++++++++++++-------------
 drivers/staging/rtl8723au/core/rtw_ioctl_set.c |  2 +-
 drivers/staging/rtl8723au/core/rtw_mlme.c      |  6 +--
 drivers/staging/rtl8723au/core/rtw_mlme_ext.c  |  4 +-
 drivers/staging/rtl8723au/core/rtw_wlan_util.c | 12 +++---
 drivers/staging/rtl8723au/include/ieee80211.h  |  3 +-
 drivers/staging/rtl8723au/include/wifi.h       |  2 +-
 7 files changed, 40 insertions(+), 41 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c
index adb86a5..2809e8b 100644
--- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c
@@ -972,69 +972,69 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork)
 
 /* show MCS rate, unit: 100Kbps */
 u16 rtw_mcs_rate23a(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40,
-		 unsigned char * MCS_rate)
+		    struct ieee80211_mcs_info *mcs)
 {
 	u16 max_rate = 0;
 
 	if (rf_type == RF_1T1R) {
-		if (MCS_rate[0] & BIT(7))
+		if (mcs->rx_mask[0] & BIT(7))
 			max_rate = (bw_40MHz) ? ((short_GI_40)?1500:1350):
 				((short_GI_20)?722:650);
-		else if (MCS_rate[0] & BIT(6))
+		else if (mcs->rx_mask[0] & BIT(6))
 			max_rate = (bw_40MHz) ? ((short_GI_40)?1350:1215):
 				((short_GI_20)?650:585);
-		else if (MCS_rate[0] & BIT(5))
+		else if (mcs->rx_mask[0] & BIT(5))
 			max_rate = (bw_40MHz) ? ((short_GI_40)?1200:1080):
 				((short_GI_20)?578:520);
-		else if (MCS_rate[0] & BIT(4))
+		else if (mcs->rx_mask[0] & BIT(4))
 			max_rate = (bw_40MHz) ? ((short_GI_40)?900:810):
 				((short_GI_20)?433:390);
-		else if (MCS_rate[0] & BIT(3))
+		else if (mcs->rx_mask[0] & BIT(3))
 			max_rate = (bw_40MHz) ? ((short_GI_40)?600:540):
 				((short_GI_20)?289:260);
-		else if (MCS_rate[0] & BIT(2))
+		else if (mcs->rx_mask[0] & BIT(2))
 			max_rate = (bw_40MHz) ? ((short_GI_40)?450:405):
 				((short_GI_20)?217:195);
-		else if (MCS_rate[0] & BIT(1))
+		else if (mcs->rx_mask[0] & BIT(1))
 			max_rate = (bw_40MHz) ? ((short_GI_40)?300:270):
 				((short_GI_20)?144:130);
-		else if (MCS_rate[0] & BIT(0))
+		else if (mcs->rx_mask[0] & BIT(0))
 			max_rate = (bw_40MHz) ? ((short_GI_40)?150:135):
 				((short_GI_20)?72:65);
 	} else {
-		if (MCS_rate[1]) {
-			if (MCS_rate[1] & BIT(7))
+		if (mcs->rx_mask[1]) {
+			if (mcs->rx_mask[1] & BIT(7))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?3000:2700):((short_GI_20)?1444:1300);
-			else if (MCS_rate[1] & BIT(6))
+			else if (mcs->rx_mask[1] & BIT(6))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?2700:2430):((short_GI_20)?1300:1170);
-			else if (MCS_rate[1] & BIT(5))
+			else if (mcs->rx_mask[1] & BIT(5))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?2400:2160):((short_GI_20)?1156:1040);
-			else if (MCS_rate[1] & BIT(4))
+			else if (mcs->rx_mask[1] & BIT(4))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?1800:1620):((short_GI_20)?867:780);
-			else if (MCS_rate[1] & BIT(3))
+			else if (mcs->rx_mask[1] & BIT(3))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?1200:1080):((short_GI_20)?578:520);
-			else if (MCS_rate[1] & BIT(2))
+			else if (mcs->rx_mask[1] & BIT(2))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?900:810):((short_GI_20)?433:390);
-			else if (MCS_rate[1] & BIT(1))
+			else if (mcs->rx_mask[1] & BIT(1))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?600:540):((short_GI_20)?289:260);
-			else if (MCS_rate[1] & BIT(0))
+			else if (mcs->rx_mask[1] & BIT(0))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?300:270):((short_GI_20)?144:130);
 		} else {
-			if (MCS_rate[0] & BIT(7))
+			if (mcs->rx_mask[0] & BIT(7))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?1500:1350):((short_GI_20)?722:650);
-			else if (MCS_rate[0] & BIT(6))
+			else if (mcs->rx_mask[0] & BIT(6))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?1350:1215):((short_GI_20)?650:585);
-			else if (MCS_rate[0] & BIT(5))
+			else if (mcs->rx_mask[0] & BIT(5))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?1200:1080):((short_GI_20)?578:520);
-			else if (MCS_rate[0] & BIT(4))
+			else if (mcs->rx_mask[0] & BIT(4))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?900:810):((short_GI_20)?433:390);
-			else if (MCS_rate[0] & BIT(3))
+			else if (mcs->rx_mask[0] & BIT(3))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?600:540):((short_GI_20)?289:260);
-			else if (MCS_rate[0] & BIT(2))
+			else if (mcs->rx_mask[0] & BIT(2))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?450:405):((short_GI_20)?217:195);
-			else if (MCS_rate[0] & BIT(1))
+			else if (mcs->rx_mask[0] & BIT(1))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?300:270):((short_GI_20)?144:130);
-			else if (MCS_rate[0] & BIT(0))
+			else if (mcs->rx_mask[0] & BIT(0))
 				max_rate = (bw_40MHz) ? ((short_GI_40)?150:135):((short_GI_20)?72:65);
 		}
 	}
diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c
index cf897c7..30474f5 100644
--- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c
+++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c
@@ -406,7 +406,7 @@ u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter)
 			max_rate = rtw_mcs_rate23a(rf_type, bw_40MHz &
 						pregistrypriv->cbw40_enable,
 						short_GI_20, short_GI_40,
-						pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate
+						&pmlmeinfo->HT_caps.u.HT_cap_element.mcs_info
 			);
 		}
 	} else {
diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c
index bd86237..5b9f60d 100644
--- a/drivers/staging/rtl8723au/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723au/core/rtw_mlme.c
@@ -2329,11 +2329,11 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len)
 		rf_type = rtl8723a_get_rf_type(padapter);
 
 		/* update the MCS rates */
-		for (i = 0; i < 16; i++) {
+		for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) {
 			if (rf_type == RF_1T1R || rf_type == RF_1T2R)
-				pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R23A[i];
+				pmlmeinfo->HT_caps.u.HT_cap_element.mcs_info.rx_mask[i] &= MCS_rate_1R23A[i];
 			else
-				pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_2R23A[i];
+				pmlmeinfo->HT_caps.u.HT_cap_element.mcs_info.rx_mask[i] &= MCS_rate_2R23A[i];
 		}
 		/* switch to the 40M Hz mode accoring to the AP */
 		pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40;
diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
index c72a810..53d2f00 100644
--- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
@@ -3492,7 +3492,7 @@ static void issue_assocreq(struct rtw_adapter *padapter)
 				if (pregpriv->rx_stbc)
 					pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0100);
 
-				memcpy(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_rate_1R23A, 16);
+				memcpy(&pmlmeinfo->HT_caps.u.HT_cap_element.mcs_info, MCS_rate_1R23A, 16);
 				break;
 
 			case RF_2T2R:
@@ -3513,7 +3513,7 @@ static void issue_assocreq(struct rtw_adapter *padapter)
 						  "STBC\n");
 					pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0200);/* RX STBC two spatial stream */
 				}
-				memcpy(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_rate_2R23A, 16);
+				memcpy(&pmlmeinfo->HT_caps.u.HT_cap_element.mcs_info, MCS_rate_2R23A, 16);
 				break;
 			}
 			pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info =
diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c
index 579a4a8..b63248b 100644
--- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c
@@ -762,13 +762,11 @@ void HT_caps_handler23a(struct rtw_adapter *padapter, u8 *p)
 	rf_type = rtl8723a_get_rf_type(padapter);
 
 	/* update the MCS rates */
-	for (i = 0; i < 16; i++) {
+	for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) {
 		if (rf_type == RF_1T1R || rf_type == RF_1T2R)
-			pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &=
-				MCS_rate_1R23A[i];
+			pmlmeinfo->HT_caps.u.HT_cap_element.mcs_info.rx_mask[i] &= MCS_rate_1R23A[i];
 		else
-			pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &=
-				MCS_rate_2R23A[i];
+			pmlmeinfo->HT_caps.u.HT_cap_element.mcs_info.rx_mask[i] &= MCS_rate_2R23A[i];
 	}
 	return;
 }
@@ -1344,8 +1342,8 @@ unsigned int update_MSC_rate23a(struct HT_caps_element *pHT_caps)
 {
 	unsigned int mask = 0;
 
-	mask = pHT_caps->u.HT_cap_element.MCS_rate[0] << 12 |
-		pHT_caps->u.HT_cap_element.MCS_rate[1] << 20;
+	mask = pHT_caps->u.HT_cap_element.mcs_info.rx_mask[0] << 12 |
+		pHT_caps->u.HT_cap_element.mcs_info.rx_mask[1] << 20;
 
 	return mask;
 }
diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h
index 69c0f5c..b680ee0 100644
--- a/drivers/staging/rtl8723au/include/ieee80211.h
+++ b/drivers/staging/rtl8723au/include/ieee80211.h
@@ -448,7 +448,8 @@ int rtw_check_network_type23a(unsigned char *rate, int ratelen, int channel);
 
 void rtw_get_bcn_info23a(struct wlan_network *pnetwork);
 
-u16 rtw_mcs_rate23a(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsigned char * MCS_rate);
+u16 rtw_mcs_rate23a(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40,
+		    struct ieee80211_mcs_info *mcs);
 
 const char *action_public_str23a(u8 action);
 
diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h
index cccea6a..f731833 100644
--- a/drivers/staging/rtl8723au/include/wifi.h
+++ b/drivers/staging/rtl8723au/include/wifi.h
@@ -81,7 +81,7 @@ struct HT_caps_element {
 		struct {
 			unsigned short	HT_caps_info;
 			unsigned char	AMPDU_para;
-			unsigned char	MCS_rate[16];
+			struct ieee80211_mcs_info mcs_info;
 			unsigned short	HT_ext_caps;
 			unsigned int	Beamforming_caps;
 			unsigned char	ASEL_caps;
-- 
1.9.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux