Skip to contentSkip to conversation

rtw88: minor throughput improvement

PATCH Superseded [email protected] 4 participants 21 messages Oct 16, 2019 – Nov 7, 2019 Realtek wireless driver (rtw88)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover rtw88: minor throughput improvement

From: Yan-Hsuan Chuang <[email protected]>

This patchset mainly adds support for beamforming and power tracking. Power tracking can monitor the thermal value of the device and adjust corresponding power indexes, to make sure the RF output power is expected.

And another thing is to add a debugfs for physical layer information. This is useful when sometimes the environment is too harsh for the device, and provides the activities for us to debug.

v1 -> v2
* Do not use cast on "const" pointers
* Add macros for checking current band, also used in power tracking
* Some refinement for power tracking
* Remove regulatory's module parameter for user's hint, and enable it by choosing the Kconfig
* Add some description for beamforming module parameter

Tsang-Shian Lin (1):
rtw88: add phy_info debugfs to show Tx/Rx physical status

Tzu-En Huang (4):
rtw88: add power tracking support
rtw88: Enable 802.11ac beamformee support
rtw88: update regulatory settings implementaion
rtw88: add set_bitrate_mask support

Yan-Hsuan Chuang (1):
rtw88: use macro to check the current band

 drivers/net/wireless/realtek/rtw88/Kconfig    |  10 +
 drivers/net/wireless/realtek/rtw88/Makefile   |   1 +
 drivers/net/wireless/realtek/rtw88/bf.c       | 409 ++++++++++++++++
 drivers/net/wireless/realtek/rtw88/bf.h       |  92 ++++
 drivers/net/wireless/realtek/rtw88/debug.c    | 174 ++++++-
 drivers/net/wireless/realtek/rtw88/debug.h    |   1 +
 drivers/net/wireless/realtek/rtw88/fw.c       |   1 +
 drivers/net/wireless/realtek/rtw88/mac.c      |   2 +-
 drivers/net/wireless/realtek/rtw88/mac80211.c |  64 +++
 drivers/net/wireless/realtek/rtw88/main.c     | 154 +++++-
 drivers/net/wireless/realtek/rtw88/main.h     | 168 ++++++-
 drivers/net/wireless/realtek/rtw88/phy.c      | 137 +++++-
 drivers/net/wireless/realtek/rtw88/phy.h      |  12 +
 drivers/net/wireless/realtek/rtw88/reg.h      |   1 +
 drivers/net/wireless/realtek/rtw88/regd.c     |  61 ++-
 drivers/net/wireless/realtek/rtw88/rtw8822b.c | 461 +++++++++++++++++-
 drivers/net/wireless/realtek/rtw88/rtw8822b.h |  12 +
 drivers/net/wireless/realtek/rtw88/rtw8822c.c | 351 ++++++++++++-
 drivers/net/wireless/realtek/rtw88/rtw8822c.h |  12 +
 drivers/net/wireless/realtek/rtw88/rx.c       |  69 ++-
 20 files changed, 2097 insertions(+), 95 deletions(-)
 create mode 100644 drivers/net/wireless/realtek/rtw88/bf.c
 create mode 100644 drivers/net/wireless/realtek/rtw88/bf.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/6 rtw88: use macro to check the current band

From: Yan-Hsuan Chuang <[email protected]>

Add macros to see which band we are, based on the current channel.

---

v1 -> v2
* Add this patch for checking current band,
also used for power tracking

 drivers/net/wireless/realtek/rtw88/mac.c      |  2 +-
 drivers/net/wireless/realtek/rtw88/main.h     | 13 ++++++
 drivers/net/wireless/realtek/rtw88/phy.c      |  2 +-
 drivers/net/wireless/realtek/rtw88/rtw8822b.c | 40 +++++++++----------
 drivers/net/wireless/realtek/rtw88/rtw8822c.c | 16 ++++----
 5 files changed, 41 insertions(+), 32 deletions(-)
drivers/net/wireless/realtek/rtw88/mac.c +1 -1
index 8d72825ed3a7..c471117b1472 100644
@@ -47,7 +47,7 @@ void rtw_set_channel_mac(struct rtw_dev *rtwdev, u8 channel, u8 bw,
 
 	value8 = rtw_read8(rtwdev, REG_CCK_CHECK);
 	value8 = value8 & ~BIT_CHECK_CCK_EN;
-	if (channel > 35)
+	if (IS_CH_5G_BAND(channel))
 		value8 |= BIT_CHECK_CCK_EN;
 	rtw_write8(rtwdev, REG_CCK_CHECK, value8);
 }
drivers/net/wireless/realtek/rtw88/main.h +13 -0
index 4759d6a0ca6e..492a2bfc0d5a 100644
@@ -58,6 +58,19 @@ struct rtw_hci {
 	u8 bulkout_num;
 };
 
+#define IS_CH_5G_BAND_1(channel) ((channel) >= 36 && (channel <= 48))
+#define IS_CH_5G_BAND_2(channel) ((channel) >= 52 && (channel <= 64))
+#define IS_CH_5G_BAND_3(channel) ((channel) >= 100 && (channel <= 144))
+#define IS_CH_5G_BAND_4(channel) ((channel) >= 149 && (channel <= 177))
+
+#define IS_CH_5G_BAND_MID(channel) \
+	(IS_CH_5G_BAND_2(channel) || IS_CH_5G_BAND_3(channel))
+
+#define IS_CH_2G_BAND(channel) ((channel) <= 14)
+#define IS_CH_5G_BAND(channel) \
+	(IS_CH_5G_BAND_1(channel) || IS_CH_5G_BAND_2(channel) || \
+	 IS_CH_5G_BAND_3(channel) || IS_CH_5G_BAND_4(channel))
+
 enum rtw_supported_band {
 	RTW_BAND_2G = 1 << 0,
 	RTW_BAND_5G = 1 << 1,
drivers/net/wireless/realtek/rtw88/phy.c +1 -1
index 8ebe1f4b76ad..ae5ecefb424e 100644
@@ -1748,7 +1748,7 @@ void rtw_get_tx_power_params(struct rtw_dev *rtwdev, u8 path, u8 rate, u8 bw,
 	group = rtw_get_channel_group(ch);
 
 	/* base power index for 2.4G/5G */
-	if (ch <= 14) {
+	if (IS_CH_2G_BAND(ch)) {
 		band = PHY_BAND_2G;
 		*base = rtw_phy_get_2g_tx_power_index(rtwdev,
 						      &pwr_idx->pwr_idx_2g,
drivers/net/wireless/realtek/rtw88/rtw8822b.c +18 -22
index 1e20c4465bc9..baf5091fa253 100644
@@ -211,9 +211,8 @@ static int rtw8822b_mac_init(struct rtw_dev *rtwdev)
 static void rtw8822b_set_channel_rfe_efem(struct rtw_dev *rtwdev, u8 channel)
 {
 	struct rtw_hal *hal = &rtwdev->hal;
-	bool is_channel_2g = (channel <= 14) ? true : false;
 
-	if (is_channel_2g) {
+	if (IS_CH_2G_BAND(channel)) {
 		rtw_write32s_mask(rtwdev, REG_RFESEL0, 0xffffff, 0x705770);
 		rtw_write32s_mask(rtwdev, REG_RFESEL8, MASKBYTE1, 0x57);
 		rtw_write32s_mask(rtwdev, REG_RFECTL, BIT(4), 0);
@@ -241,9 +240,8 @@ static void rtw8822b_set_channel_rfe_efem(struct rtw_dev *rtwdev, u8 channel)
 static void rtw8822b_set_channel_rfe_ifem(struct rtw_dev *rtwdev, u8 channel)
 {
 	struct rtw_hal *hal = &rtwdev->hal;
-	bool is_channel_2g = (channel <= 14) ? true : false;
 
-	if (is_channel_2g) {
+	if (IS_CH_2G_BAND(channel)) {
 		/* signal source */
 		rtw_write32s_mask(rtwdev, REG_RFESEL0, 0xffffff, 0x745774);
 		rtw_write32s_mask(rtwdev, REG_RFESEL8, MASKBYTE1, 0x57);
@@ -255,7 +253,7 @@ static void rtw8822b_set_channel_rfe_ifem(struct rtw_dev *rtwdev, u8 channel)
 
 	rtw_write32s_mask(rtwdev, REG_RFEINV, BIT(11) | BIT(10) | 0x3f, 0x0);
 
-	if (is_channel_2g) {
+	if (IS_CH_2G_BAND(channel)) {
 		if (hal->antenna_rx == BB_PATH_AB ||
 		    hal->antenna_tx == BB_PATH_AB) {
 			/* 2TX or 2RX */
@@ -350,7 +348,7 @@ static void rtw8822b_set_channel_cca(struct rtw_dev *rtwdev, u8 channel, u8 bw,
 	u32 reg82c, reg830, reg838;
 	bool is_efem_cca = false, is_ifem_cca = false, is_rfe_type = false;
 
-	if (channel <= 14) {
+	if (IS_CH_2G_BAND(channel)) {
 		cca_ccut = rfe_info->cca_ccut_2g;
 
 		if (hal->antenna_rx == BB_PATH_A ||
@@ -381,7 +379,7 @@ static void rtw8822b_set_channel_cca(struct rtw_dev *rtwdev, u8 channel, u8 bw,
 		is_efem_cca = true;
 		break;
 	case RTW_RFE_IFEM2G_EFEM5G:
-		if (channel <= 14)
+		if (IS_CH_2G_BAND(channel))
 			is_ifem_cca = true;
 		else
 			is_efem_cca = true;
@@ -405,9 +403,7 @@ static void rtw8822b_set_channel_cca(struct rtw_dev *rtwdev, u8 channel, u8 bw,
 	if (is_efem_cca && !(hal->cut_version == RTW_CHIP_VER_CUT_B))
 		rtw_write32_mask(rtwdev, REG_L1WT, MASKDWORD, 0x9194b2b9);
 
-	if (bw == RTW_CHANNEL_WIDTH_20 &&
-	    ((channel >= 52 && channel <= 64) ||
-	     (channel >= 100 && channel <= 144)))
+	if (bw == RTW_CHANNEL_WIDTH_20 && IS_CH_5G_BAND_MID(channel))
 		rtw_write32_mask(rtwdev, REG_CCA2ND, 0xf0, 0x4);
 }
 
@@ -442,7 +438,7 @@ static void rtw8822b_set_channel_rf(struct rtw_dev *rtwdev, u8 channel, u8 bw)
 	rf_reg18 &= ~(RF18_BAND_MASK | RF18_CHANNEL_MASK | RF18_RFSI_MASK |
 		      RF18_BW_MASK);
 
-	rf_reg18 |= (channel <= 14 ? RF18_BAND_2G : RF18_BAND_5G);
+	rf_reg18 |= (IS_CH_2G_BAND(channel) ? RF18_BAND_2G : RF18_BAND_5G);
 	rf_reg18 |= (channel & RF18_CHANNEL_MASK);
 	if (channel > 144)
 		rf_reg18 |= RF18_RFSI_GT_CH144;
@@ -464,13 +460,13 @@ static void rtw8822b_set_channel_rf(struct rtw_dev *rtwdev, u8 channel, u8 bw)
 		break;
 	}
 
-	if (channel <= 14)
+	if (IS_CH_2G_BAND(channel))
 		rf_reg_be = 0x0;
-	else if (channel >= 36 && channel <= 64)
+	else if (IS_CH_5G_BAND_1(channel) || IS_CH_5G_BAND_2(channel))
 		rf_reg_be = low_band[(channel - 36) >> 1];
-	else if (channel >= 100 && channel <= 144)
+	else if (IS_CH_5G_BAND_3(channel))
 		rf_reg_be = middle_band[(channel - 100) >> 1];
-	else if (channel >= 149 && channel <= 177)
+	else if (IS_CH_5G_BAND_4(channel))
 		rf_reg_be = high_band[(channel - 149) >> 1];
 	else
 		goto err;
@@ -539,7 +535,7 @@ static void rtw8822b_set_channel_bb(struct rtw_dev *rtwdev, u8 channel, u8 bw,
 	u8 rfe_option = efuse->rfe_option;
 	u32 val32;
 
-	if (channel <= 14) {
+	if (IS_CH_2G_BAND(channel)) {
 		rtw_write32_mask(rtwdev, REG_RXPSEL, BIT(28), 0x1);
 		rtw_write32_mask(rtwdev, REG_CCK_CHECK, BIT(7), 0x0);
 		rtw_write32_mask(rtwdev, REG_ENTXCCK, BIT(18), 0x0);
@@ -556,22 +552,22 @@ static void rtw8822b_set_channel_bb(struct rtw_dev *rtwdev, u8 channel, u8 bw,
 		}
 
 		rtw_write32_mask(rtwdev, REG_RFEINV, 0x300, 0x2);
-	} else if (channel > 35) {
+	} else if (IS_CH_5G_BAND(channel)) {
 		rtw_write32_mask(rtwdev, REG_ENTXCCK, BIT(18), 0x1);
 		rtw_write32_mask(rtwdev, REG_CCK_CHECK, BIT(7), 0x1);
 		rtw_write32_mask(rtwdev, REG_RXPSEL, BIT(28), 0x0);
 		rtw_write32_mask(rtwdev, REG_RXCCAMSK, 0x0000FC00, 34);
 
-		if (channel >= 36 && channel <= 64)
+		if (IS_CH_5G_BAND_1(channel) || IS_CH_5G_BAND_2(channel))
 			rtw_write32_mask(rtwdev, REG_ACGG2TBL, 0x1f, 0x1);
-		else if (channel >= 100 && channel <= 144)
+		else if (IS_CH_5G_BAND_3(channel))
 			rtw_write32_mask(rtwdev, REG_ACGG2TBL, 0x1f, 0x2);
-		else if (channel >= 149)
+		else if (IS_CH_5G_BAND_4(channel))
 			rtw_write32_mask(rtwdev, REG_ACGG2TBL, 0x1f, 0x3);
 
-		if (channel >= 36 && channel <= 48)
+		if (IS_CH_5G_BAND_1(channel))
 			rtw_write32_mask(rtwdev, REG_CLKTRK, 0x1ffe0000, 0x494);
-		else if (channel >= 52 && channel <= 64)
+		else if (IS_CH_5G_BAND_2(channel))
 			rtw_write32_mask(rtwdev, REG_CLKTRK, 0x1ffe0000, 0x453);
 		else if (channel >= 100 && channel <= 116)
 			rtw_write32_mask(rtwdev, REG_CLKTRK, 0x1ffe0000, 0x452);
drivers/net/wireless/realtek/rtw88/rtw8822c.c +8 -8
index 690934386b85..167af317c7c5 100644
@@ -1287,11 +1287,11 @@ static void rtw8822c_set_channel_rf(struct rtw_dev *rtwdev, u8 channel, u8 bw)
 	rf_reg18 &= ~(RF18_BAND_MASK | RF18_CHANNEL_MASK | RF18_RFSI_MASK |
 		      RF18_BW_MASK);
 
-	rf_reg18 |= (channel <= 14 ? RF18_BAND_2G : RF18_BAND_5G);
+	rf_reg18 |= (IS_CH_2G_BAND(channel) ? RF18_BAND_2G : RF18_BAND_5G);
 	rf_reg18 |= (channel & RF18_CHANNEL_MASK);
-	if (channel > 144)
+	if (IS_CH_5G_BAND_4(channel))
 		rf_reg18 |= RF18_RFSI_GT_CH140;
-	else if (channel >= 80)
+	else if (IS_CH_5G_BAND_3(channel))
 		rf_reg18 |= RF18_RFSI_GE_CH80;
 
 	switch (bw) {
@@ -1341,7 +1341,7 @@ static void rtw8822c_toggle_igi(struct rtw_dev *rtwdev)
 static void rtw8822c_set_channel_bb(struct rtw_dev *rtwdev, u8 channel, u8 bw,
 				    u8 primary_ch_idx)
 {
-	if (channel <= 14) {
+	if (IS_CH_2G_BAND(channel)) {
 		rtw_write32_clr(rtwdev, REG_BGCTRL, BITS_RX_IQ_WEIGHT);
 		rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0xf0000000, 0x8);
 		rtw_write32_set(rtwdev, REG_TXF4, BIT(20));
@@ -1406,7 +1406,7 @@ static void rtw8822c_set_channel_bb(struct rtw_dev *rtwdev, u8 channel, u8 bw,
 			rtw_write32_mask(rtwdev, REG_TXDFIR0, 0x70, 0x3);
 		else
 			rtw_write32_mask(rtwdev, REG_TXDFIR0, 0x70, 0x1);
-	} else if (channel > 35) {
+	} else if (IS_CH_5G_BAND(channel)) {
 		rtw_write32_set(rtwdev, REG_CCKTXONLY, BIT_BB_CCK_CHECK_EN);
 		rtw_write32_set(rtwdev, REG_CCK_CHECK, BIT_CHECK_CCK_EN);
 		rtw_write32_set(rtwdev, REG_BGCTRL, BITS_RX_IQ_WEIGHT);
@@ -1414,17 +1414,17 @@ static void rtw8822c_set_channel_bb(struct rtw_dev *rtwdev, u8 channel, u8 bw,
 		rtw_write32_mask(rtwdev, REG_RXCCKSEL, 0xf0000000, 0x0);
 		rtw_write32_mask(rtwdev, REG_CCAMSK, 0x3F000000, 0x22);
 		rtw_write32_mask(rtwdev, REG_TXDFIR0, 0x70, 0x3);
-		if (channel >= 36 && channel <= 64) {
+		if (IS_CH_5G_BAND_1(channel) || IS_CH_5G_BAND_2(channel)) {
 			rtw_write32_mask(rtwdev, REG_RXAGCCTL0, BITS_RXAGC_OFDM,
 					 0x1);
 			rtw_write32_mask(rtwdev, REG_RXAGCCTL, BITS_RXAGC_OFDM,
 					 0x1);
-		} else if (channel >= 100 && channel <= 144) {
+		} else if (IS_CH_5G_BAND_3(channel)) {
 			rtw_write32_mask(rtwdev, REG_RXAGCCTL0, BITS_RXAGC_OFDM,
 					 0x2);
 			rtw_write32_mask(rtwdev, REG_RXAGCCTL, BITS_RXAGC_OFDM,
 					 0x2);
-		} else if (channel >= 149) {
+		} else if (IS_CH_5G_BAND_4(channel)) {
 			rtw_write32_mask(rtwdev, REG_RXAGCCTL0, BITS_RXAGC_OFDM,
 					 0x3);
 			rtw_write32_mask(rtwdev, REG_RXAGCCTL, BITS_RXAGC_OFDM,
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v2 1/6] rtw88: use macro to check the current band

drivers/net/wireless/realtek/rtw88/main.h struct rtw_hci { · line 64

Quoted 11 lines · On Wed, Oct 16, 2019 at 5:33 AM <[email protected]> wrote:

index 4759d6a0ca6e..492a2bfc0d5a 100644

drivers/net/wireless/realtek/rtw88/main.h +4 -0
@@ -58,6 +58,19 @@ struct rtw_hci {
        u8 bulkout_num;
 };
 
+#define IS_CH_5G_BAND_1(channel) ((channel) >= 36 && (channel <= 48))
+#define IS_CH_5G_BAND_2(channel) ((channel) >= 52 && (channel <= 64))
+#define IS_CH_5G_BAND_3(channel) ((channel) >= 100 && (channel <= 144))
+#define IS_CH_5G_BAND_4(channel) ((channel) >= 149 && (channel <= 177))

There are channels between 48 and 52, 64 and 100, and 144 and 149. What are you doing with those?

drivers/net/wireless/realtek/rtw88/main.h struct rtw_hci { · line 72

Quoted 7 lines
drivers/net/wireless/realtek/rtw88/main.h +7 -0
+#define IS_CH_5G_BAND_MID(channel) \
+       (IS_CH_5G_BAND_2(channel) || IS_CH_5G_BAND_3(channel))
+
+#define IS_CH_2G_BAND(channel) ((channel) <= 14)
+#define IS_CH_5G_BAND(channel) \
+       (IS_CH_5G_BAND_1(channel) || IS_CH_5G_BAND_2(channel) || \
+        IS_CH_5G_BAND_3(channel) || IS_CH_5G_BAND_4(channel))

Given the above (you have major holes in 5G_BAND{1,2,3,4}), this macro seems like a regression.

Brian

#3 lore raw

RE: [PATCH v2 1/6] rtw88: use macro to check the current band

From: Brian Norris

Quoted 12 lines · On Wed, Oct 16, 2019 at 5:33 AM <[email protected]> wrote:

drivers/net/wireless/realtek/rtw88/main.h struct rtw_hci { · line 63

Quoted 10 lines

index 4759d6a0ca6e..492a2bfc0d5a 100644

drivers/net/wireless/realtek/rtw88/main.h +3 -0
@@ -58,6 +58,19 @@ struct rtw_hci {
        u8 bulkout_num;
 };
 
+#define IS_CH_5G_BAND_1(channel) ((channel) >= 36 && (channel <= 48))
+#define IS_CH_5G_BAND_2(channel) ((channel) >= 52 && (channel <= 64))
+#define IS_CH_5G_BAND_3(channel) ((channel) >= 100 && (channel <=

144))

Quoted 5 lines

drivers/net/wireless/realtek/rtw88/main.h struct rtw_hci { · line 64

Quoted 1 line
drivers/net/wireless/realtek/rtw88/main.h +1 -0
+#define IS_CH_5G_BAND_4(channel) ((channel) >= 149 && (channel <=

177))

There are channels between 48 and 52, 64 and 100, and 144 and 149. What are you doing with those?

These devices are not supporting those channels you mentioned. So I hope if some unsupported channels are used, they should hit the "else" case, or throw such a warn.

Quoted 12 lines

drivers/net/wireless/realtek/rtw88/main.h struct rtw_hci { · line 72

Quoted 8 lines
drivers/net/wireless/realtek/rtw88/main.h +7 -0
+#define IS_CH_5G_BAND_MID(channel) \
+       (IS_CH_5G_BAND_2(channel) || IS_CH_5G_BAND_3(channel))
+
+#define IS_CH_2G_BAND(channel) ((channel) <= 14)
+#define IS_CH_5G_BAND(channel) \
+       (IS_CH_5G_BAND_1(channel) || IS_CH_5G_BAND_2(channel) || \
+        IS_CH_5G_BAND_3(channel) || IS_CH_5G_BAND_4(channel))

Given the above (you have major holes in 5G_BAND{1,2,3,4}), this macro seems like a regression.

Yan-Hsuan

#4 lore raw

Re: [PATCH v2 1/6] rtw88: use macro to check the current band

A little late on this...

Quoted 14 lines · Tony Chuang

From: Brian Norris

Quoted 13 lines · On Wed, Oct 16, 2019 at 5:33 AM <[email protected]> wrote:

drivers/net/wireless/realtek/rtw88/main.h struct rtw_hci { · line 63

Quoted 10 lines

index 4759d6a0ca6e..492a2bfc0d5a 100644

drivers/net/wireless/realtek/rtw88/main.h +3 -0
@@ -58,6 +58,19 @@ struct rtw_hci {
        u8 bulkout_num;
 };
 
+#define IS_CH_5G_BAND_1(channel) ((channel) >= 36 && (channel <= 48))
+#define IS_CH_5G_BAND_2(channel) ((channel) >= 52 && (channel <= 64))
+#define IS_CH_5G_BAND_3(channel) ((channel) >= 100 && (channel <=

144))

Quoted 1 line
drivers/net/wireless/realtek/rtw88/main.h +1 -0
+#define IS_CH_5G_BAND_4(channel) ((channel) >= 149 && (channel <=
Quoted 8 lines
Quoted 4 lines

177))

There are channels between 48 and 52, 64 and 100, and 144 and 149. What are you doing with those?

These devices are not supporting those channels you mentioned. So I hope if some unsupported channels are used, they should hit the "else" case, or throw such a warn.

Maybe that argument makes sense on its own, but see below:

Quoted 10 lines
Quoted 10 lines

drivers/net/wireless/realtek/rtw88/main.h struct rtw_hci { · line 72

Quoted 7 lines
drivers/net/wireless/realtek/rtw88/main.h +7 -0
+#define IS_CH_5G_BAND_MID(channel) \
+       (IS_CH_5G_BAND_2(channel) || IS_CH_5G_BAND_3(channel))
+
+#define IS_CH_2G_BAND(channel) ((channel) <= 14)
+#define IS_CH_5G_BAND(channel) \
+       (IS_CH_5G_BAND_1(channel) || IS_CH_5G_BAND_2(channel) || \
+        IS_CH_5G_BAND_3(channel) || IS_CH_5G_BAND_4(channel))

Given the above (you have major holes in 5G_BAND{1,2,3,4}), this macro seems like a regression.

I still think it's a terrible idea to write an intentionally misleading macro named "IS 5G BAND" that returns false for 5G channels. It just gives you a nice way to stub your toe if you ever have chips that do support these channels.

Brian

#5 lore raw

RE: [PATCH v2 1/6] rtw88: use macro to check the current band

Quoted 43 lines

Subject: Re: [PATCH v2 1/6] rtw88: use macro to check the current band

A little late on this...

Quoted 10 lines · Tony Chuang

From: Brian Norris

Quoted 9 lines · On Wed, Oct 16, 2019 at 5:33 AM <[email protected]> wrote:

drivers/net/wireless/realtek/rtw88/main.h struct rtw_hci { · line 61

Quoted 8 lines

index 4759d6a0ca6e..492a2bfc0d5a 100644

drivers/net/wireless/realtek/rtw88/main.h +1 -0
@@ -58,6 +58,19 @@ struct rtw_hci {
        u8 bulkout_num;
 };
 
+#define IS_CH_5G_BAND_1(channel) ((channel) >= 36 && (channel <=

48))

Quoted 1 line
Quoted 1 line

drivers/net/wireless/realtek/rtw88/main.h struct rtw_hci { · line 62

Quoted 1 line
drivers/net/wireless/realtek/rtw88/main.h +1 -0
+#define IS_CH_5G_BAND_2(channel) ((channel) >= 52 && (channel <=

64))

Quoted 11 lines
Quoted 7 lines

drivers/net/wireless/realtek/rtw88/main.h struct rtw_hci { · line 63

Quoted 1 line
drivers/net/wireless/realtek/rtw88/main.h +1 -0
+#define IS_CH_5G_BAND_3(channel) ((channel) >= 100 && (channel <=

144))

drivers/net/wireless/realtek/rtw88/main.h struct rtw_hci { · line 64

Quoted 1 line
drivers/net/wireless/realtek/rtw88/main.h +1 -0
+#define IS_CH_5G_BAND_4(channel) ((channel) >= 149 && (channel <=

177))

There are channels between 48 and 52, 64 and 100, and 144 and 149. What are you doing with those?

These devices are not supporting those channels you mentioned. So I hope if some unsupported channels are used, they should hit the "else" case, or throw such a warn.

Maybe that argument makes sense on its own, but see below:

Quoted 6 lines
Quoted 6 lines

drivers/net/wireless/realtek/rtw88/main.h struct rtw_hci {

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/main.h +6 -0
+#define IS_CH_5G_BAND_MID(channel) \
+       (IS_CH_5G_BAND_2(channel) || IS_CH_5G_BAND_3(channel))
+
+#define IS_CH_2G_BAND(channel) ((channel) <= 14)
+#define IS_CH_5G_BAND(channel) \
+       (IS_CH_5G_BAND_1(channel) || IS_CH_5G_BAND_2(channel)
|| \
> > > +        IS_CH_5G_BAND_3(channel) ||

IS_CH_5G_BAND_4(channel))

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

Given the above (you have major holes in 5G_BAND{1,2,3,4}), this macro seems like a regression.

I still think it's a terrible idea to write an intentionally misleading macro named "IS 5G BAND" that returns false for 5G channels. It just gives you a nice way to stub your toe if you ever have chips that do support these channels.

You're probably right, but I really don't think those 802.11ac devices are going to support these channels, unless rtw88 is going to add support for 802.11ax devices. And I'll take care of it when it comes.

At least the current 802.11ac devices such as 8821C/8822B/8822C do not support it.

Yan-Hsuan

#6 lore raw

PATCH v2 2/6 rtw88: add power tracking support

In reply to [email protected]

From: Tzu-En Huang <[email protected]>

The temperature of the chip can affect the output power of the RF components. Hence driver requires to compensate the power by adjusting the power index recorded in the power swing table.

And if the difference of current thermal value to the default thermal value exceeds a threshold, the RF IQK should be triggered to re-calibrate the characteristics of the RF components, to keep the output IQ vectors of the RF components orthogonal enough.

---

v1 -> v2
* Use macros to check current band
* Some coding style refinement
* Not casting "const" pointers

 drivers/net/wireless/realtek/rtw88/fw.c       |   1 +
 drivers/net/wireless/realtek/rtw88/main.h     |  49 ++-
 drivers/net/wireless/realtek/rtw88/phy.c      | 126 +++++++
 drivers/net/wireless/realtek/rtw88/phy.h      |  12 +
 drivers/net/wireless/realtek/rtw88/rtw8822b.c | 330 ++++++++++++++++++
 drivers/net/wireless/realtek/rtw88/rtw8822c.c | 228 ++++++++++++
 6 files changed, 745 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/fw.c +1 -0
index 65594393dd1e..b8c581161f61 100644
@@ -117,6 +117,7 @@ static void rtw_fw_ra_report_handle(struct rtw_dev *rtwdev, u8 *payload,
 	if (WARN(length < 7, "invalid ra report c2h length\n"))
 		return;
 
+	rtwdev->dm_info.tx_rate = GET_RA_REPORT_RATE(payload);
 	ra_data.rtwdev = rtwdev;
 	ra_data.payload = payload;
 	rtw_iterate_stas_atomic(rtwdev, rtw_fw_ra_report_iter, &ra_data);
drivers/net/wireless/realtek/rtw88/main.h +48 -1

85 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/phy.c +126 -0

141 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/phy.h +12 -0
index e79b084628e7..0dc7720aaad7 100644
@@ -41,9 +41,21 @@ void rtw_phy_cfg_rf(struct rtw_dev *rtwdev, const struct rtw_table *tbl,
 		    u32 addr, u32 data);
 void rtw_phy_init_tx_power(struct rtw_dev *rtwdev);
 void rtw_phy_load_tables(struct rtw_dev *rtwdev);
+u8 rtw_phy_get_tx_power_index(struct rtw_dev *rtwdev, u8 rf_path, u8 rate,
+			      enum rtw_bandwidth bw, u8 channel, u8 regd);
 void rtw_phy_set_tx_power_level(struct rtw_dev *rtwdev, u8 channel);
 void rtw_phy_tx_power_by_rate_config(struct rtw_hal *hal);
 void rtw_phy_tx_power_limit_config(struct rtw_hal *hal);
+void rtw_phy_pwrtrack_avg(struct rtw_dev *rtwdev, u8 thermal, u8 path);
+bool rtw_phy_pwrtrack_thermal_changed(struct rtw_dev *rtwdev, u8 thermal,
+				      u8 path);
+u8 rtw_phy_pwrtrack_get_delta(struct rtw_dev *rtwdev, u8 path);
+s8 rtw_phy_pwrtrack_get_pwridx(struct rtw_dev *rtwdev,
+			       struct rtw_swing_table *swing_table,
+			       u8 tbl_path, u8 therm_path, u8 delta);
+bool rtw_phy_pwrtrack_need_iqk(struct rtw_dev *rtwdev);
+void rtw_phy_config_swing_table(struct rtw_dev *rtwdev,
+				struct rtw_swing_table *swing_table);
 
 struct rtw_txpwr_lmt_cfg_pair {
 	u8 regd;
drivers/net/wireless/realtek/rtw88/rtw8822b.c +330 -0

372 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/rtw8822c.c +228 -0

270 lines not on this page · raw message

Signature · 1 line
2.17.1
#7 lore raw

Re: [PATCH v2 2/6] rtw88: add power tracking support

Quoted 25 lines · On Wed, Oct 16, 2019 at 8:33 PM <[email protected]> wrote:

From: Tzu-En Huang <[email protected]>

The temperature of the chip can affect the output power of the RF components. Hence driver requires to compensate the power by adjusting the power index recorded in the power swing table.

And if the difference of current thermal value to the default thermal value exceeds a threshold, the RF IQK should be triggered to re-calibrate the characteristics of the RF components, to keep the output IQ vectors of the RF components orthogonal enough.

---

v1 -> v2
* Use macros to check current band
* Some coding style refinement
* Not casting "const" pointers

drivers/net/wireless/realtek/rtw88/main.h struct rtw_efuse { · line 1269

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/main.h +2 -1
@@ -1220,7 +1265,9 @@ struct rtw_efuse {
        u8 country_code[2];
        u8 rf_board_option;
        u8 rfe_option;
-       u8 thermal_meter;
+       u8 power_track_type;
+       u8 thermal_meter[2];

The '2' is related to RTW_RF_PATH_MAX or something else? Please have a descriptive macro for this.

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/phy.c +3 -0
+       u8 thermal_meter_k;
        u8 crystal_cap;
        u8 ant_div_cfg;
        u8 ant_div_type;
+
+bool rtw_phy_pwrtrack_thermal_changed(struct rtw_dev *rtwdev, u8 thermal,

drivers/net/wireless/realtek/rtw88/phy.c void rtw_phy_init_tx_power(struct rtw_dev *rtwdev) · line 2038

Quoted 10 lines
drivers/net/wireless/realtek/rtw88/phy.c +10 -0
+                                     u8 path)
+{
+       struct rtw_dm_info *dm_info = &rtwdev->dm_info;
+       u8 avg = ewma_thermal_read(&dm_info->avg_thermal[path]);
+
+       if (avg == thermal)
+               return false;
+
+       return true;
+}

Why not simplify this as pure if-else? It's a bit confusing.

drivers/net/wireless/realtek/rtw88/phy.c void rtw_phy_init_tx_power(struct rtw_dev *rtwdev) · line 2096

Quoted 12 lines
drivers/net/wireless/realtek/rtw88/phy.c +12 -0
+bool rtw_phy_pwrtrack_need_iqk(struct rtw_dev *rtwdev)
+{
+       struct rtw_dm_info *dm_info = &rtwdev->dm_info;
+       u8 delta_iqk;
+
+       delta_iqk = abs(dm_info->thermal_avg[0] - dm_info->thermal_meter_k);
+       if (delta_iqk >= rtwdev->chip->iqk_threshold) {
+               dm_info->thermal_meter_k = dm_info->thermal_avg[0];
+               return true;
+       }
+       return false;
+}

Is 'thermal_avg[0]' for RF_PATH_A? Or it means something else? And it's also good to simplify it as a simple if-else.

Quoted 14 lines
drivers/net/wireless/realtek/rtw88/rtw8822b.c +2 -0
index baf5091fa253..8a018aefbe16 100644
@@ -43,6 +43,8 @@ static int rtw8822b_read_efuse(struct rtw_dev *rtwdev, u8 *log_map)
        efuse->country_code[1] = map->country_code[1];
        efuse->bt_setting = map->rf_bt_setting;
        efuse->regd = map->rf_board_option & 0x7;
+       efuse->thermal_meter[0] = map->thermal_meter;
+       efuse->thermal_meter_k = map->thermal_meter;
 
        for (i = 0; i < 4; i++)
                efuse->txpwr_idx_table[i] = map->txpwr_idx_table[i];

drivers/net/wireless/realtek/rtw88/rtw8822b.c static void rtw8822b_phy_rfe_init(struct rtw_dev *rtwdev) · line 79

Quoted 3 lines
drivers/net/wireless/realtek/rtw88/rtw8822b.c +0 -0
@@ -75,6 +77,49 @@ static void rtw8822b_phy_rfe_init(struct rtw_dev *rtwdev)
        rtw_write32_mask(rtwdev, 0x974, (BIT(11) | BIT(10)), 0x3);
 }
 

Is 'thermal_meter[0]' for RF_PATH_A, 1 for PATH_B?
Dose the '4' refer to RTW_RF_PATH_MAX or totally irrelevant? Same question for the rtw8822c.c

- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c
@@ -40,6 +40,11 @@ static int rtw8822c_read_efuse(struct rtw_dev *rtwdev, u8 *log_map)

        efuse->country_code[1] = map->country_code[1];
        efuse->bt_setting = map->rf_bt_setting;
        efuse->regd = map->rf_board_option & 0x7;
+       efuse->thermal_meter[0] = map->path_a_thermal;
+       efuse->thermal_meter[1] = map->path_b_thermal;
+       efuse->thermal_meter_k =

+ (map->path_a_thermal + map->path_b_thermal) >> 1;
+ efuse->power_track_type = (map->tx_pwr_calibrate_rate >> 4) & 0xf;

        for (i = 0; i < 4; i++)
                efuse->txpwr_idx_table[i] = map->txpwr_idx_table[i];

Same as above.

Quoted 3 lines
drivers/net/wireless/realtek/rtw88/rtw8822b.c +1 -0
+

2.17.1

#8 lore raw

PATCH v2 3/6 rtw88: Enable 802.11ac beamformee support

In reply to [email protected]

From: Tzu-En Huang <[email protected]>

Enable MU-MIMO transmit beamformee support for chipset 8822b and 8822c.

If the driver is in station mode and associated with an AP, and the capabilities of both meet the requirement of beamforming, driver will run as a beamformee and the corresponding chip settings will be set.

In addition, module parameter support_bf is added to enable or disable beamforming. Sometimes driver will need to disable for inter-operate issues, and it would be easier for driver to debug.

---

v1 -> v2
* Not casting "const" pointers
* Add some description for having a module parameter

 drivers/net/wireless/realtek/rtw88/Makefile   |   1 +
 drivers/net/wireless/realtek/rtw88/bf.c       | 409 ++++++++++++++++++
 drivers/net/wireless/realtek/rtw88/bf.h       |  92 ++++
 drivers/net/wireless/realtek/rtw88/debug.h    |   1 +
 drivers/net/wireless/realtek/rtw88/mac80211.c |  11 +
 drivers/net/wireless/realtek/rtw88/main.c     |  38 ++
 drivers/net/wireless/realtek/rtw88/main.h     |  43 ++
 drivers/net/wireless/realtek/rtw88/reg.h      |   1 +
 drivers/net/wireless/realtek/rtw88/rtw8822b.c |  46 ++
 drivers/net/wireless/realtek/rtw88/rtw8822c.c |  59 +++
 10 files changed, 701 insertions(+)
 create mode 100644 drivers/net/wireless/realtek/rtw88/bf.c
 create mode 100644 drivers/net/wireless/realtek/rtw88/bf.h
drivers/net/wireless/realtek/rtw88/Makefile +1 -0
index 77edee2df8b8..15e12155a04c 100644
@@ -14,6 +14,7 @@ rtw88-y += main.o \
 	   fw.o \
 	   ps.o \
 	   sec.o \
+	   bf.o \
 	   regd.o
 
 rtw88-$(CONFIG_RTW88_8822BE)	+= rtw8822b.o rtw8822b_table.o
drivers/net/wireless/realtek/rtw88/bf.c new file +409 -0

409 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/bf.h new file +92 -0

92 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/debug.h +1 -0
index 9449105f4259..cd28f675e9cb 100644
@@ -17,6 +17,7 @@ enum rtw_debug_mask {
 	RTW_DBG_REGD		= 0x00000100,
 	RTW_DBG_DEBUGFS		= 0x00000200,
 	RTW_DBG_PS		= 0x00000400,
+	RTW_DBG_BF		= 0x00000800,
 
 	RTW_DBG_ALL		= 0xffffffff
 };
drivers/net/wireless/realtek/rtw88/mac80211.c +11 -0
index 8d7a3429ea06..bc04cc280a96 100644
@@ -10,6 +10,7 @@
 #include "coex.h"
 #include "ps.h"
 #include "reg.h"
+#include "bf.h"
 #include "debug.h"
 
 static void rtw_ops_tx(struct ieee80211_hw *hw,
@@ -157,6 +158,7 @@ static int rtw_ops_add_interface(struct ieee80211_hw *hw,
 	rtwvif->stats.tx_cnt = 0;
 	rtwvif->stats.rx_cnt = 0;
 	rtwvif->in_lps = false;
+	memset(&rtwvif->bfee, 0, sizeof(struct rtw_bfee));
 	rtwvif->conf = &rtw_vif_port[port];
 	rtw_txq_init(rtwdev, vif->txq);
 
@@ -348,11 +350,14 @@ static void rtw_ops_bss_info_changed(struct ieee80211_hw *hw,
 			rtw_fw_download_rsvd_page(rtwdev, vif);
 			rtw_send_rsvd_page_h2c(rtwdev);
 			rtw_coex_media_status_notify(rtwdev, conf->assoc);
+			if (rtw_bf_support)
+				rtw_bf_assoc(rtwdev, vif, conf);
 		} else {
 			rtw_leave_lps(rtwdev);
 			net_type = RTW_NET_NO_LINK;
 			rtwvif->aid = 0;
 			rtw_reset_rsvd_page(rtwdev);
+			rtw_bf_disassoc(rtwdev, vif, conf);
 		}
 
 		rtwvif->net_type = net_type;
@@ -368,6 +373,12 @@ static void rtw_ops_bss_info_changed(struct ieee80211_hw *hw,
 	if (changed & BSS_CHANGED_BEACON)
 		rtw_fw_download_rsvd_page(rtwdev, vif);
 
+	if (changed & BSS_CHANGED_MU_GROUPS) {
+		struct rtw_chip_info *chip = rtwdev->chip;
+
+		chip->ops->set_gid_table(rtwdev, vif, conf);
+	}
+
 	if (changed & BSS_CHANGED_ERP_SLOT)
 		rtw_conf_tx(rtwdev, rtwvif);
 
drivers/net/wireless/realtek/rtw88/main.c +38 -0
index 5343d860189b..47e74f0aec06 100644
@@ -14,16 +14,20 @@
 #include "efuse.h"
 #include "tx.h"
 #include "debug.h"
+#include "bf.h"
 
 unsigned int rtw_fw_lps_deep_mode;
 EXPORT_SYMBOL(rtw_fw_lps_deep_mode);
+bool rtw_bf_support = true;
 unsigned int rtw_debug_mask;
 EXPORT_SYMBOL(rtw_debug_mask);
 
 module_param_named(lps_deep_mode, rtw_fw_lps_deep_mode, uint, 0644);
+module_param_named(support_bf, rtw_bf_support, bool, 0644);
 module_param_named(debug_mask, rtw_debug_mask, uint, 0644);
 
 MODULE_PARM_DESC(lps_deep_mode, "Deeper PS mode. If 0, deep PS is disabled");
+MODULE_PARM_DESC(support_bf, "Set Y to enable beamformee support");
 MODULE_PARM_DESC(debug_mask, "Debugging mask");
 
 static struct ieee80211_channel rtw_channeltable_2g[] = {
@@ -126,9 +130,29 @@ static struct ieee80211_supported_band rtw_band_5ghz = {
 };
 
 struct rtw_watch_dog_iter_data {
+	struct rtw_dev *rtwdev;
 	struct rtw_vif *rtwvif;
 };
 
+static void rtw_dynamic_csi_rate(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif)
+{
+	struct rtw_bf_info *bf_info = &rtwdev->bf_info;
+	struct rtw_chip_info *chip = rtwdev->chip;
+	u8 fix_rate_enable = 0;
+	u8 new_csi_rate_idx;
+
+	if (rtwvif->bfee.role != RTW_BFEE_SU &&
+	    rtwvif->bfee.role != RTW_BFEE_MU)
+		return;
+
+	chip->ops->cfg_csi_rate(rtwdev, rtwdev->dm_info.min_rssi,
+				bf_info->cur_csi_rpt_rate,
+				fix_rate_enable, &new_csi_rate_idx);
+
+	if (new_csi_rate_idx != bf_info->cur_csi_rpt_rate)
+		bf_info->cur_csi_rpt_rate = new_csi_rate_idx;
+}
+
 static void rtw_vif_watch_dog_iter(void *data, u8 *mac,
 				   struct ieee80211_vif *vif)
 {
@@ -139,6 +163,8 @@ static void rtw_vif_watch_dog_iter(void *data, u8 *mac,
 		if (vif->bss_conf.assoc)
 			iter_data->rtwvif = rtwvif;
 
+	rtw_dynamic_csi_rate(iter_data->rtwdev, rtwvif);
+
 	rtwvif->stats.tx_unicast = 0;
 	rtwvif->stats.rx_unicast = 0;
 	rtwvif->stats.tx_cnt = 0;
@@ -192,6 +218,7 @@ static void rtw_watch_dog_work(struct work_struct *work)
 
 	rtw_phy_dynamic_mechanism(rtwdev);
 
+	data.rtwdev = rtwdev;
 	/* use atomic version to avoid taking local->iflist_mtx mutex */
 	rtw_iterate_vifs_atomic(rtwdev, rtw_vif_watch_dog_iter, &data);
 
@@ -870,6 +897,12 @@ static void rtw_init_vht_cap(struct rtw_dev *rtwdev,
 		       IEEE80211_VHT_CAP_HTC_VHT |
 		       IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK |
 		       0;
+
+	vht_cap->cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE |
+			IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
+	vht_cap->cap |= (rtwdev->hal.bfee_sts_cap <<
+			IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT);
+
 	mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_9 << 0 |
 		  IEEE80211_VHT_MCS_NOT_SUPPORTED << 4 |
 		  IEEE80211_VHT_MCS_NOT_SUPPORTED << 6 |
@@ -1005,6 +1038,8 @@ static int rtw_chip_parameter_setup(struct rtw_dev *rtwdev)
 	/* default use ack */
 	rtwdev->hal.rcr |= BIT_VHT_DACK;
 
+	hal->bfee_sts_cap = 3;
+
 	return ret;
 }
 
@@ -1342,6 +1377,9 @@ int rtw_register_hw(struct rtw_dev *rtwdev, struct ieee80211_hw *hw)
 
 	rtw_debugfs_init(rtwdev);
 
+	rtwdev->bf_info.bfer_mu_cnt = 0;
+	rtwdev->bf_info.bfer_su_cnt = 0;
+
 	return 0;
 }
 EXPORT_SYMBOL(rtw_register_hw);
drivers/net/wireless/realtek/rtw88/main.h +43 -0

85 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/reg.h +1 -0
index 330574a9f55a..7e817bc997eb 100644
@@ -326,6 +326,7 @@
 #define REG_RXFLTMAP0		0x06A0
 #define REG_RXFLTMAP1		0x06A2
 #define REG_RXFLTMAP2		0x06A4
+#define REG_RXFLTMAP4		0x068A
 #define REG_BT_COEX_TABLE0	0x06C0
 #define REG_BT_COEX_TABLE1	0x06C4
 #define REG_BT_COEX_BRK_TABLE	0x06C8
drivers/net/wireless/realtek/rtw88/rtw8822b.c +46 -0

82 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/rtw8822c.c +59 -0

89 lines not on this page · raw message

Signature · 1 line
2.17.1
#9 lore raw

Re: [PATCH v2 3/6] rtw88: Enable 802.11ac beamformee support

Hi,

On Wed, Oct 16, 2019 at 08:32:58PM +0800, [email protected] wrote:
...

Quoted 5 lines
drivers/net/wireless/realtek/rtw88/bf.h new file +0 -0
new file mode 100644
index 000000000000..96a8216dd11f

...

drivers/net/wireless/realtek/rtw88/bf.h line 75

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/bf.h new file +6 -0
+void rtw_bf_disassoc(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
+		     struct ieee80211_bss_conf *bss_conf);
+void rtw_bf_assoc(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
+		  struct ieee80211_bss_conf *bss_conf);
+void rtw_bf_init_bfer_entry_mu(struct rtw_dev *rtwdev,
+			       struct mu_bfer_init_para *param);

Not used outside bf.c, so you should make it static in bf.c and drop the declaration here.

drivers/net/wireless/realtek/rtw88/bf.h line 77

Quoted 2 lines
drivers/net/wireless/realtek/rtw88/bf.h new file +2 -0
+void rtw_bf_cfg_sounding(struct rtw_dev *rtwdev, struct rtw_vif *vif,
+			 enum rtw_trx_desc_rate rate);

Same.

Quoted 1 line

+void rtw_bf_cfg_mu_bfee(struct rtw_dev *rtwdev, struct cfg_mumimo_para *param);

Same.

Quoted 1 line

+void rtw_bf_del_bfer_entry_mu(struct rtw_dev *rtwdev);

Same.

Quoted 1 line

+void rtw_bf_del_sounding(struct rtw_dev *rtwdev);

Same.

drivers/net/wireless/realtek/rtw88/bf.h line 92

Quoted 12 lines
drivers/net/wireless/realtek/rtw88/bf.h new file +12 -0
+void rtw_bf_enable_bfee_su(struct rtw_dev *rtwdev, struct rtw_vif *vif,
+			   struct rtw_bfee *bfee);
+void rtw_bf_enable_bfee_mu(struct rtw_dev *rtwdev, struct rtw_vif *vif,
+			   struct rtw_bfee *bfee);
+void rtw_bf_remove_bfee_su(struct rtw_dev *rtwdev, struct rtw_bfee *bfee);
+void rtw_bf_remove_bfee_mu(struct rtw_dev *rtwdev, struct rtw_bfee *bfee);
+void rtw_bf_set_gid_table(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
+			  struct ieee80211_bss_conf *conf);
+void rtw_bf_phy_init(struct rtw_dev *rtwdev);
+void rtw_bf_cfg_csi_rate(struct rtw_dev *rtwdev, u8 rssi, u8 cur_rate,
+			 u8 fixrate_en, u8 *new_rate);
+#endif

Brian

#10 lore raw

RE: [PATCH v2 3/6] rtw88: Enable 802.11ac beamformee support

From: Brian Norris [mailto:[email protected]]

Quoted 50 lines

Subject: Re: [PATCH v2 3/6] rtw88: Enable 802.11ac beamformee support

Hi,

On Wed, Oct 16, 2019 at 08:32:58PM +0800, [email protected] wrote:
...

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/net/wireless/realtek/rtw88/bf.h

Quoted 4 lines

new file mode 100644
index 000000000000..96a8216dd11f

drivers/net/wireless/realtek/rtw88/bf.h new file +0 -0

...

drivers/net/wireless/realtek/rtw88/bf.h line 75

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/bf.h new file +6 -0
+void rtw_bf_disassoc(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
+		     struct ieee80211_bss_conf *bss_conf);
+void rtw_bf_assoc(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
+		  struct ieee80211_bss_conf *bss_conf);
+void rtw_bf_init_bfer_entry_mu(struct rtw_dev *rtwdev,
+			       struct mu_bfer_init_para *param);

Not used outside bf.c, so you should make it static in bf.c and drop the declaration here.

drivers/net/wireless/realtek/rtw88/bf.h line 77

Quoted 2 lines
drivers/net/wireless/realtek/rtw88/bf.h new file +2 -0
+void rtw_bf_cfg_sounding(struct rtw_dev *rtwdev, struct rtw_vif *vif,
+			 enum rtw_trx_desc_rate rate);

Same.

Quoted 1 line

+void rtw_bf_cfg_mu_bfee(struct rtw_dev *rtwdev, struct

cfg_mumimo_para *param);

Same.

Quoted 1 line

+void rtw_bf_del_bfer_entry_mu(struct rtw_dev *rtwdev);

Same.

Quoted 1 line

+void rtw_bf_del_sounding(struct rtw_dev *rtwdev);

Same.

drivers/net/wireless/realtek/rtw88/bf.h

Quoted 5 lines
drivers/net/wireless/realtek/rtw88/bf.h new file +5 -0
+void rtw_bf_enable_bfee_su(struct rtw_dev *rtwdev, struct rtw_vif *vif,
+			   struct rtw_bfee *bfee);
+void rtw_bf_enable_bfee_mu(struct rtw_dev *rtwdev, struct rtw_vif *vif,
+			   struct rtw_bfee *bfee);
+void rtw_bf_remove_bfee_su(struct rtw_dev *rtwdev, struct rtw_bfee

*bfee);

Quoted 1 line

+void rtw_bf_remove_bfee_mu(struct rtw_dev *rtwdev, struct rtw_bfee

Quoted 9 lines

*bfee);

Quoted 1 line

+void rtw_bf_set_gid_table(struct rtw_dev *rtwdev, struct ieee80211_vif

*vif,

drivers/net/wireless/realtek/rtw88/bf.h line 92

Quoted 5 lines
drivers/net/wireless/realtek/rtw88/bf.h new file +5 -0
+			  struct ieee80211_bss_conf *conf);
+void rtw_bf_phy_init(struct rtw_dev *rtwdev);
+void rtw_bf_cfg_csi_rate(struct rtw_dev *rtwdev, u8 rssi, u8 cur_rate,
+			 u8 fixrate_en, u8 *new_rate);
+#endif

OK, that should be static if not being used.
Will send a v3 to fix them.

Yan-Hsuan

#11 lore raw

PATCH v2 4/6 rtw88: update regulatory settings implementaion

In reply to [email protected]

From: Tzu-En Huang <[email protected]>

There are two kinds of country/regulatory efuse settings for Realtek's chipset, one is worldwide and the other is a specific country. For the chipset with the country setting being a specific country, driver needs to ensure that the setting will not be modified when connecting to an AP.

For the chipset with the country setting is worldwide, driver will follow the NL80211_REGDOM_SET_BY_COUNTRY_IE regulatory notification from the mac80211 stack.

This also supports user regulatory hints, and it should only be enabled for specific distributions that need this to correct the cards reglutory.

---

v1 -> v2
* Enable user's hint by choosing Kconfig, not module parameter

 drivers/net/wireless/realtek/rtw88/Kconfig | 10 ++++
 drivers/net/wireless/realtek/rtw88/main.c  |  6 ++-
 drivers/net/wireless/realtek/rtw88/main.h  |  2 +
 drivers/net/wireless/realtek/rtw88/regd.c  | 61 ++++++++++++++++++----
 4 files changed, 66 insertions(+), 13 deletions(-)
drivers/net/wireless/realtek/rtw88/Kconfig +10 -0
index 33bd7ed797ff..04b84ec1dfc1 100644
@@ -52,4 +52,14 @@ config RTW88_DEBUGFS
 
 	  If unsure, say Y to simplify debug problems
 
+config RTW88_REGD_USER_REG_HINTS
+	bool "Realtek rtw88 user regulatory hints"
+	depends on RTW88_CORE
+	default n
+	help
+	  Enable regulatoy user hints
+
+	  If unsure, say N. This should only be allowed on distributions
+	  that need this to correct the regulatory.
+
 endif
drivers/net/wireless/realtek/rtw88/main.c +4 -2
index 47e74f0aec06..2f8dc056b2a8 100644
@@ -1372,8 +1372,10 @@ int rtw_register_hw(struct rtw_dev *rtwdev, struct ieee80211_hw *hw)
 		return ret;
 	}
 
-	if (regulatory_hint(hw->wiphy, rtwdev->regd.alpha2))
-		rtw_err(rtwdev, "regulatory_hint fail\n");
+	if (!rtwdev->efuse.country_worldwide) {
+		if (regulatory_hint(hw->wiphy, rtwdev->efuse.country_code))
+			rtw_err(rtwdev, "regulatory_hint fail\n");
+	}
 
 	rtw_debugfs_init(rtwdev);
 
drivers/net/wireless/realtek/rtw88/main.h +2 -0
index 4498c933a4ed..5f7560a532c8 100644
@@ -32,6 +32,7 @@
 extern bool rtw_bf_support;
 extern unsigned int rtw_fw_lps_deep_mode;
 extern unsigned int rtw_debug_mask;
+extern bool rtw_allow_user_reg_set;
 extern const struct ieee80211_ops rtw_ops;
 extern struct rtw_chip_info rtw8822b_hw_spec;
 extern struct rtw_chip_info rtw8822c_hw_spec;
@@ -1304,6 +1305,7 @@ struct rtw_efuse {
 	u8 addr[ETH_ALEN];
 	u8 channel_plan;
 	u8 country_code[2];
+	bool country_worldwide;
 	u8 rf_board_option;
 	u8 rfe_option;
 	u8 power_track_type;
drivers/net/wireless/realtek/rtw88/regd.c +50 -11

101 lines not on this page · raw message

Signature · 1 line
2.17.1
#12 lore raw

Re: [PATCH v2 4/6] rtw88: update regulatory settings implementaion

Quoted 3 lines · On Wed, Oct 16, 2019 at 5:33 AM <[email protected]> wrote:

This also supports user regulatory hints, and it should only be enabled for specific distributions that need this to correct the cards reglutory.

s/cards/card's/
s/reglutory/regulatory/

There should be a pretty high bar for introducing either new CONFIG_* options or module parameters, in my opinion, and I'm not sure you really satisfied it. Why "should only be enabled" by certain distributions? Your opinion? If it's the technical limitation you refer to ("efuse settings"), then just detect the efuse and prevent user hints only on those modules.

Brian

#13 lore raw

RE: [PATCH v2 4/6] rtw88: update regulatory settings implementaion

From: Brian Norris

Quoted 8 lines · On Wed, Oct 16, 2019 at 5:33 AM <[email protected]> wrote:
Quoted 3 lines

This also supports user regulatory hints, and it should only be enabled for specific distributions that need this to correct the cards reglutory.

s/cards/card's/
s/reglutory/regulatory/

Typo should be fixed in v3 :)

Quoted 8 lines

There should be a pretty high bar for introducing either new CONFIG_* options or module parameters, in my opinion, and I'm not sure you really satisfied it. Why "should only be enabled" by certain distributions? Your opinion? If it's the technical limitation you refer to ("efuse settings"), then just detect the efuse and prevent user hints only on those modules.

Because the efuse/module does not contain the information if the user's hint is allowed. But sometimes distributions require to set the regulatory via "NL80211_CMD_SET_REG".
So we are leaving the CONFIG_* here for some reason that needs it.

Yan-Hsuan

#14 lore raw

Re: [PATCH v2 4/6] rtw88: update regulatory settings implementaion

Quoted 7 lines · Tony Chuang

From: Brian Norris

Quoted 5 lines · On Wed, Oct 16, 2019 at 5:33 AM <[email protected]> wrote:
Quoted 3 lines

This also supports user regulatory hints, and it should only be enabled for specific distributions that need this to correct the cards reglutory.

...

Quoted 8 lines
Quoted 7 lines

There should be a pretty high bar for introducing either new CONFIG_* options or module parameters, in my opinion, and I'm not sure you really satisfied it. Why "should only be enabled" by certain distributions? Your opinion? If it's the technical limitation you refer to ("efuse settings"), then just detect the efuse and prevent user hints only on those modules.

Quoted 4 lines

Because the efuse/module does not contain the information if the user's hint is allowed. But sometimes distributions require to set the regulatory via "NL80211_CMD_SET_REG".
So we are leaving the CONFIG_* here for some reason that needs it.

Is there ever a case where user hint is not allowed? For what reason? If not efuse, then what?

Or alternatively: if someone sets CONFIG_RTW88_REGD_USER_REG_HINTS=y, then what problems will they have? Technical problems (e.g., firmware will crash on certain modules) or <other> problems?

(If "<other>" means "legal", then just blink twice to acknowledge. Or just don't answer.)

Brian

#15 lore raw

Re: [PATCH v2 4/6] rtw88: update regulatory settings implementaion

Quoted 22 lines · Brian Norris
Quoted 7 lines · Tony Chuang

From: Brian Norris

Quoted 5 lines · On Wed, Oct 16, 2019 at 5:33 AM <[email protected]> wrote:
Quoted 3 lines

This also supports user regulatory hints, and it should only be enabled for specific distributions that need this to correct the cards reglutory.

...

Quoted 8 lines
Quoted 7 lines

There should be a pretty high bar for introducing either new CONFIG_* options or module parameters, in my opinion, and I'm not sure you really satisfied it. Why "should only be enabled" by certain distributions? Your opinion? If it's the technical limitation you refer to ("efuse settings"), then just detect the efuse and prevent user hints only on those modules.

Quoted 4 lines

Because the efuse/module does not contain the information if the user's hint is allowed. But sometimes distributions require to set the regulatory via "NL80211_CMD_SET_REG".
So we are leaving the CONFIG_* here for some reason that needs it.

Quoted 6 lines

Is there ever a case where user hint is not allowed? For what reason? If not efuse, then what?

Or alternatively: if someone sets CONFIG_RTW88_REGD_USER_REG_HINTS=y, then what problems will they have? Technical problems (e.g., firmware will crash on certain modules) or <other> problems?

I'm not convinced either that a Kconfig option is the correct thing to do here. We need to understand more about the background first.

This patch needs a lot more discussion, please move it out from this patchset and handle it separately. That way it won't block other patches.

Signature · 1 line
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#16 lore raw

PATCH v2 5/6 rtw88: add set_bitrate_mask support

In reply to [email protected]

From: Tzu-En Huang <[email protected]>

Support setting bit rate from upper layer.
After configuring the original rate control result in the driver, the result is then masked by the bit rate mask received from the ops set_bitrate_mask. Lastly, the masked result will be sent to firmware.

---

v1 -> v2
* No change

 drivers/net/wireless/realtek/rtw88/mac80211.c | 53 ++++++++++++++
 drivers/net/wireless/realtek/rtw88/main.c     | 73 +++++++++++++++----
 drivers/net/wireless/realtek/rtw88/main.h     |  3 +
 3 files changed, 113 insertions(+), 16 deletions(-)
drivers/net/wireless/realtek/rtw88/mac80211.c +53 -0
index bc04cc280a96..2247bd61e716 100644
@@ -475,6 +475,8 @@ static int rtw_ops_sta_remove(struct ieee80211_hw *hw,
 	for (i = 0; i < ARRAY_SIZE(sta->txq); i++)
 		rtw_txq_cleanup(rtwdev, sta->txq[i]);
 
+	kfree(si->mask);
+
 	rtwdev->sta_cnt--;
 
 	rtw_info(rtwdev, "sta %pM with macid %d left\n",
@@ -684,6 +686,56 @@ static void rtw_ops_flush(struct ieee80211_hw *hw,
 	mutex_unlock(&rtwdev->mutex);
 }
 
+struct rtw_iter_bitrate_mask_data {
+	struct rtw_dev *rtwdev;
+	struct ieee80211_vif *vif;
+	const struct cfg80211_bitrate_mask *mask;
+};
+
+static void rtw_ra_mask_info_update_iter(void *data, struct ieee80211_sta *sta)
+{
+	struct rtw_iter_bitrate_mask_data *br_data = data;
+	struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv;
+
+	if (si->vif != br_data->vif)
+		return;
+
+	/* free previous mask setting */
+	kfree(si->mask);
+	si->mask = kmemdup(br_data->mask, sizeof(struct cfg80211_bitrate_mask),
+			   GFP_ATOMIC);
+	if (!si->mask) {
+		si->use_cfg_mask = false;
+		return;
+	}
+
+	si->use_cfg_mask = true;
+	rtw_update_sta_info(br_data->rtwdev, si);
+}
+
+static void rtw_ra_mask_info_update(struct rtw_dev *rtwdev,
+				    struct ieee80211_vif *vif,
+				    const struct cfg80211_bitrate_mask *mask)
+{
+	struct rtw_iter_bitrate_mask_data br_data;
+
+	br_data.rtwdev = rtwdev;
+	br_data.vif = vif;
+	br_data.mask = mask;
+	rtw_iterate_stas_atomic(rtwdev, rtw_ra_mask_info_update_iter, &br_data);
+}
+
+static int rtw_ops_set_bitrate_mask(struct ieee80211_hw *hw,
+				    struct ieee80211_vif *vif,
+				    const struct cfg80211_bitrate_mask *mask)
+{
+	struct rtw_dev *rtwdev = hw->priv;
+
+	rtw_ra_mask_info_update(rtwdev, vif, mask);
+
+	return 0;
+}
+
 const struct ieee80211_ops rtw_ops = {
 	.tx			= rtw_ops_tx,
 	.wake_tx_queue		= rtw_ops_wake_tx_queue,
@@ -705,5 +757,6 @@ const struct ieee80211_ops rtw_ops = {
 	.set_rts_threshold	= rtw_ops_set_rts_threshold,
 	.sta_statistics		= rtw_ops_sta_statistics,
 	.flush			= rtw_ops_flush,
+	.set_bitrate_mask	= rtw_ops_set_bitrate_mask,
 };
 EXPORT_SYMBOL(rtw_ops);
drivers/net/wireless/realtek/rtw88/main.c +57 -16

90 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/main.h +3 -0
index 5f7560a532c8..dcc5f3988451 100644
@@ -647,6 +647,9 @@ struct rtw_sta_info {
 	DECLARE_BITMAP(tid_ba, IEEE80211_NUM_TIDS);
 
 	struct rtw_ra_report ra_report;
+
+	bool use_cfg_mask;
+	struct cfg80211_bitrate_mask *mask;
 };
 
 enum rtw_bfee_role {
Signature · 1 line
2.17.1
#17 lore raw

Re: [PATCH v2 5/6] rtw88: add set_bitrate_mask support

Quoted 21 lines · On Wed, Oct 16, 2019 at 8:33 PM <[email protected]> wrote:

From: Tzu-En Huang <[email protected]>

drivers/net/wireless/realtek/rtw88/main.c +17 -0
+
+       band = hal->current_band_type;
+       if (band == RTW_BAND_2G) {
+               band = NL80211_BAND_2GHZ;
+               cfg_mask = mask->control[band].legacy;
+       } else if (band == RTW_BAND_5G) {
+               band = NL80211_BAND_5GHZ;
+               cfg_mask = mask->control[band].legacy << 4;
+       }
+
+       if (!is_vht_enable) {
+               if (ra_mask & RA_MASK_HT_RATES_1SS)
+                       cfg_mask |= mask->control[band].ht_mcs[0] << 12;
+               if (ra_mask & RA_MASK_HT_RATES_2SS)
+                       cfg_mask |= mask->control[band].ht_mcs[1] << 20;
+       } else {
+               if (ra_mask & RA_MASK_VHT_RATES_1SS)

drivers/net/wireless/realtek/rtw88/main.c static u8 get_rate_id(u8 wireless_set, enum rtw_bandwidth bw_mode, u8 tx_num) · line 669

Quoted 10 lines
drivers/net/wireless/realtek/rtw88/main.c +10 -0
+                       cfg_mask |= mask->control[band].vht_mcs[0] << 12;
+               if (ra_mask & RA_MASK_VHT_RATES_2SS)
+                       cfg_mask |= mask->control[band].vht_mcs[1] << 22;
+       }
+
+       ra_mask &= cfg_mask;
+
+       return ra_mask;
+}
+

I believe you can replace the 4, 12, 20, 22 with a more descriptive macro.

Chris

Quoted 3 lines

--
2.17.1

#18 lore raw

Re: [PATCH v2 5/6] rtw88: add set_bitrate_mask support

Quoted 26 lines · Chris Chiu
Quoted 25 lines · On Wed, Oct 16, 2019 at 8:33 PM <[email protected]> wrote:

From: Tzu-En Huang <[email protected]>

drivers/net/wireless/realtek/rtw88/main.c +21 -0
+
+       band = hal->current_band_type;
+       if (band == RTW_BAND_2G) {
+               band = NL80211_BAND_2GHZ;
+               cfg_mask = mask->control[band].legacy;
+       } else if (band == RTW_BAND_5G) {
+               band = NL80211_BAND_5GHZ;
+               cfg_mask = mask->control[band].legacy << 4;
+       }
+
+       if (!is_vht_enable) {
+               if (ra_mask & RA_MASK_HT_RATES_1SS)
+                       cfg_mask |= mask->control[band].ht_mcs[0] << 12;
+               if (ra_mask & RA_MASK_HT_RATES_2SS)
+                       cfg_mask |= mask->control[band].ht_mcs[1] << 20;
+       } else {
+               if (ra_mask & RA_MASK_VHT_RATES_1SS)
+                       cfg_mask |= mask->control[band].vht_mcs[0] << 12;
+               if (ra_mask & RA_MASK_VHT_RATES_2SS)
+                       cfg_mask |= mask->control[band].vht_mcs[1] << 22;
+       }
Quoted 8 lines

drivers/net/wireless/realtek/rtw88/main.c static u8 get_rate_id(u8 wireless_set, enum rtw_bandwidth bw_mode, u8 tx_num) · line 669

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/main.c +6 -0
+
+       ra_mask &= cfg_mask;
+
+       return ra_mask;
+}
+

I believe you can replace the 4, 12, 20, 22 with a more descriptive macro.

Good point. GENMASK() and FIELD_PREP() are my favourites. Or maybe u64_encode_bits() is actually better than FIELD_PREP(), as cfg_mask is u64?

Signature · 1 line
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#19 lore raw

PATCH v2 6/6 rtw88: add phy_info debugfs to show Tx/Rx physical status

In reply to [email protected]

From: Tsang-Shian Lin <[email protected]>

This commit adds several Tx/Rx physical information to phy_info debugfs for 8822B/8822C. By this debugfs, we can know physical information, such as Tx/Rx rate, RSSI, EVM,SNR, etc. The information is gotten from the packets of Tx/Rx path. It has no impact for the performance of 8822B/8822C.

In the fields, we may meet different kinds of problems, but we may have no professional instrument to check them. At this moment, this debugfs is a good tool, and it may provide useful information for debug.

---

v1 -> v2
* No change

 drivers/net/wireless/realtek/rtw88/debug.c    | 174 +++++++++++++++---
 drivers/net/wireless/realtek/rtw88/main.c     |  37 +++-
 drivers/net/wireless/realtek/rtw88/main.h     |  58 ++++++
 drivers/net/wireless/realtek/rtw88/phy.c      |   9 +
 drivers/net/wireless/realtek/rtw88/rtw8822b.c |  45 +++++
 drivers/net/wireless/realtek/rtw88/rtw8822b.h |  12 ++
 drivers/net/wireless/realtek/rtw88/rtw8822c.c |  48 +++++
 drivers/net/wireless/realtek/rtw88/rtw8822c.h |  12 ++
 drivers/net/wireless/realtek/rtw88/rx.c       |  69 ++++++-
 9 files changed, 431 insertions(+), 33 deletions(-)
drivers/net/wireless/realtek/rtw88/debug.c +153 -21
index 6ad985e98e42..5a181e01ebef 100644
@@ -498,12 +498,32 @@ static void rtw_print_vht_rate_txt(struct seq_file *m, u8 rate)
 	seq_printf(m, " VHT%uSMCS%u", n_ss, mcs_n);
 }
 
+static void rtw_print_rate(struct seq_file *m, u8 rate)
+{
+	switch (rate) {
+	case DESC_RATE1M...DESC_RATE11M:
+		rtw_print_cck_rate_txt(m, rate);
+		break;
+	case DESC_RATE6M...DESC_RATE54M:
+		rtw_print_ofdm_rate_txt(m, rate);
+		break;
+	case DESC_RATEMCS0...DESC_RATEMCS15:
+		rtw_print_ht_rate_txt(m, rate);
+		break;
+	case DESC_RATEVHT1SS_MCS0...DESC_RATEVHT2SS_MCS9:
+		rtw_print_vht_rate_txt(m, rate);
+		break;
+	default:
+		seq_printf(m, " Unknown rate=0x%x\n", rate);
+		break;
+	}
+}
+
 static int rtw_debugfs_get_tx_pwr_tbl(struct seq_file *m, void *v)
 {
 	struct rtw_debugfs_priv *debugfs_priv = m->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 	struct rtw_hal *hal = &rtwdev->hal;
-	void (*print_rate)(struct seq_file *, u8) = NULL;
 	u8 path, rate;
 	struct rtw_power_params pwr_param = {0};
 	u8 bw = hal->current_band_width;
@@ -528,30 +548,11 @@ static int rtw_debugfs_get_tx_pwr_tbl(struct seq_file *m, void *v)
 			    rate < DESC_RATEVHT1SS_MCS0)
 				continue;
 
-			switch (rate) {
-			case DESC_RATE1M...DESC_RATE11M:
-				print_rate = rtw_print_cck_rate_txt;
-				break;
-			case DESC_RATE6M...DESC_RATE54M:
-				print_rate = rtw_print_ofdm_rate_txt;
-				break;
-			case DESC_RATEMCS0...DESC_RATEMCS15:
-				print_rate = rtw_print_ht_rate_txt;
-				break;
-			case DESC_RATEVHT1SS_MCS0...DESC_RATEVHT2SS_MCS9:
-				print_rate = rtw_print_vht_rate_txt;
-				break;
-			default:
-				print_rate = NULL;
-				break;
-			}
-
 			rtw_get_tx_power_params(rtwdev, path, rate, bw,
 						ch, regd, &pwr_param);
 
 			seq_printf(m, "%4c ", path + 'A');
-			if (print_rate)
-				print_rate(m, rate);
+			rtw_print_rate(m, rate);
 			seq_printf(m, " %3u(0x%02x) %4u %4d (%4d %4d)\n",
 				   hal->tx_pwr_tbl[path][rate],
 				   hal->tx_pwr_tbl[path][rate],
@@ -567,6 +568,132 @@ static int rtw_debugfs_get_tx_pwr_tbl(struct seq_file *m, void *v)
 	return 0;
 }
 
+static int rtw_debugfs_get_phy_info(struct seq_file *m, void *v)
+{
+	struct rtw_debugfs_priv *debugfs_priv = m->private;
+	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
+	struct rtw_traffic_stats *stats = &rtwdev->stats;
+	struct rtw_pkt_count *last_cnt = &dm_info->last_pkt_count;
+	struct rtw_efuse *efuse = &rtwdev->efuse;
+	struct ewma_evm *ewma_evm = dm_info->ewma_evm;
+	struct ewma_snr *ewma_snr = dm_info->ewma_snr;
+	u8 ss, rate_id;
+
+	seq_puts(m, "==========[Common Info]========\n");
+	seq_printf(m, "Is link = %c\n", rtw_is_assoc(rtwdev) ? 'Y' : 'N');
+	seq_printf(m, "Current CH(fc) = %u\n", rtwdev->hal.current_channel);
+	seq_printf(m, "Current BW = %u\n", rtwdev->hal.current_band_width);
+	seq_printf(m, "Current IGI = 0x%x\n", dm_info->igi_history[0]);
+	seq_printf(m, "TP {Tx, Rx} = {%u, %u}Mbps\n\n",
+		   stats->tx_throughput, stats->rx_throughput);
+
+	seq_puts(m, "==========[Tx Phy Info]========\n");
+	seq_puts(m, "[Tx Rate] = ");
+	rtw_print_rate(m, dm_info->tx_rate);
+	seq_printf(m, "(0x%x)\n\n", dm_info->tx_rate);
+
+	seq_puts(m, "==========[Rx Phy Info]========\n");
+	seq_printf(m, "[Rx Beacon Count] = %u\n", last_cnt->num_bcn_pkt);
+	seq_puts(m, "[Rx Rate] = ");
+	rtw_print_rate(m, dm_info->curr_rx_rate);
+	seq_printf(m, "(0x%x)\n", dm_info->curr_rx_rate);
+
+	seq_puts(m, "[Rx Rate Count]:\n");
+	seq_printf(m, " * CCK = {%u, %u, %u, %u}\n",
+		   last_cnt->num_qry_pkt[DESC_RATE1M],
+		   last_cnt->num_qry_pkt[DESC_RATE2M],
+		   last_cnt->num_qry_pkt[DESC_RATE5_5M],
+		   last_cnt->num_qry_pkt[DESC_RATE11M]);
+
+	seq_printf(m, " * OFDM = {%u, %u, %u, %u, %u, %u, %u, %u}\n",
+		   last_cnt->num_qry_pkt[DESC_RATE6M],
+		   last_cnt->num_qry_pkt[DESC_RATE9M],
+		   last_cnt->num_qry_pkt[DESC_RATE12M],
+		   last_cnt->num_qry_pkt[DESC_RATE18M],
+		   last_cnt->num_qry_pkt[DESC_RATE24M],
+		   last_cnt->num_qry_pkt[DESC_RATE36M],
+		   last_cnt->num_qry_pkt[DESC_RATE48M],
+		   last_cnt->num_qry_pkt[DESC_RATE54M]);
+
+	for (ss = 0; ss < efuse->hw_cap.nss; ss++) {
+		rate_id = DESC_RATEMCS0 + ss * 8;
+		seq_printf(m, " * HT_MCS[%u:%u] = {%u, %u, %u, %u, %u, %u, %u, %u}\n",
+			   ss * 8, ss * 8 + 7,
+			   last_cnt->num_qry_pkt[rate_id],
+			   last_cnt->num_qry_pkt[rate_id + 1],
+			   last_cnt->num_qry_pkt[rate_id + 2],
+			   last_cnt->num_qry_pkt[rate_id + 3],
+			   last_cnt->num_qry_pkt[rate_id + 4],
+			   last_cnt->num_qry_pkt[rate_id + 5],
+			   last_cnt->num_qry_pkt[rate_id + 6],
+			   last_cnt->num_qry_pkt[rate_id + 7]);
+	}
+
+	for (ss = 0; ss < efuse->hw_cap.nss; ss++) {
+		rate_id = DESC_RATEVHT1SS_MCS0 + ss * 10;
+		seq_printf(m, " * VHT_MCS-%uss MCS[0:9] = {%u, %u, %u, %u, %u, %u, %u, %u, %u, %u}\n",
+			   ss + 1,
+			   last_cnt->num_qry_pkt[rate_id],
+			   last_cnt->num_qry_pkt[rate_id + 1],
+			   last_cnt->num_qry_pkt[rate_id + 2],
+			   last_cnt->num_qry_pkt[rate_id + 3],
+			   last_cnt->num_qry_pkt[rate_id + 4],
+			   last_cnt->num_qry_pkt[rate_id + 5],
+			   last_cnt->num_qry_pkt[rate_id + 6],
+			   last_cnt->num_qry_pkt[rate_id + 7],
+			   last_cnt->num_qry_pkt[rate_id + 8],
+			   last_cnt->num_qry_pkt[rate_id + 9]);
+	}
+
+	seq_printf(m, "[RSSI(dBm)] = {%d, %d}\n",
+		   dm_info->rssi[RF_PATH_A] - 100,
+		   dm_info->rssi[RF_PATH_B] - 100);
+	seq_printf(m, "[Rx EVM(dB)] = {-%d, -%d}\n",
+		   dm_info->rx_evm_dbm[RF_PATH_A],
+		   dm_info->rx_evm_dbm[RF_PATH_B]);
+	seq_printf(m, "[Rx SNR] = {%d, %d}\n",
+		   dm_info->rx_snr[RF_PATH_A],
+		   dm_info->rx_snr[RF_PATH_B]);
+	seq_printf(m, "[CFO_tail(KHz)] = {%d, %d}\n",
+		   dm_info->cfo_tail[RF_PATH_A],
+		   dm_info->cfo_tail[RF_PATH_B]);
+
+	if (dm_info->curr_rx_rate >= DESC_RATE11M) {
+		seq_puts(m, "[Rx Average Status]:\n");
+		seq_printf(m, " * OFDM, EVM: {-%d}, SNR: {%d}\n",
+			   (u8)ewma_evm_read(&ewma_evm[RTW_EVM_OFDM]),
+			   (u8)ewma_snr_read(&ewma_snr[RTW_SNR_OFDM_A]));
+		seq_printf(m, " * 1SS, EVM: {-%d}, SNR: {%d}\n",
+			   (u8)ewma_evm_read(&ewma_evm[RTW_EVM_1SS]),
+			   (u8)ewma_snr_read(&ewma_snr[RTW_SNR_1SS_A]));
+		seq_printf(m, " * 2SS, EVM: {-%d, -%d}, SNR: {%d, %d}\n",
+			   (u8)ewma_evm_read(&ewma_evm[RTW_EVM_2SS_A]),
+			   (u8)ewma_evm_read(&ewma_evm[RTW_EVM_2SS_B]),
+			   (u8)ewma_snr_read(&ewma_snr[RTW_SNR_2SS_A]),
+			   (u8)ewma_snr_read(&ewma_snr[RTW_SNR_2SS_B]));
+	}
+
+	seq_puts(m, "[Rx Counter]:\n");
+	seq_printf(m, " * CCA (CCK, OFDM, Total) = (%u, %u, %u)\n",
+		   dm_info->cck_cca_cnt,
+		   dm_info->ofdm_cca_cnt,
+		   dm_info->total_cca_cnt);
+	seq_printf(m, " * False Alarm (CCK, OFDM, Total) = (%u, %u, %u)\n",
+		   dm_info->cck_fa_cnt,
+		   dm_info->ofdm_fa_cnt,
+		   dm_info->total_fa_cnt);
+	seq_printf(m, " * CCK cnt (ok, err) = (%u, %u)\n",
+		   dm_info->cck_ok_cnt, dm_info->cck_err_cnt);
+	seq_printf(m, " * OFDM cnt (ok, err) = (%u, %u)\n",
+		   dm_info->ofdm_ok_cnt, dm_info->ofdm_err_cnt);
+	seq_printf(m, " * HT cnt (ok, err) = (%u, %u)\n",
+		   dm_info->ht_ok_cnt, dm_info->ht_err_cnt);
+	seq_printf(m, " * VHT cnt (ok, err) = (%u, %u)\n",
+		   dm_info->vht_ok_cnt, dm_info->vht_err_cnt);
+	return 0;
+}
+
 #define rtw_debug_impl_mac(page, addr)				\
 static struct rtw_debugfs_priv rtw_debug_priv_mac_ ##page = {	\
 	.cb_read = rtw_debug_get_mac_page,			\
@@ -653,6 +780,10 @@ static struct rtw_debugfs_priv rtw_debug_priv_rsvd_page = {
 	.cb_read = rtw_debugfs_get_rsvd_page,
 };
 
+static struct rtw_debugfs_priv rtw_debug_priv_phy_info = {
+	.cb_read = rtw_debugfs_get_phy_info,
+};
+
 #define rtw_debugfs_add_core(name, mode, fopname, parent)		\
 	do {								\
 		rtw_debug_priv_ ##name.rtwdev = rtwdev;			\
@@ -682,6 +813,7 @@ void rtw_debugfs_init(struct rtw_dev *rtwdev)
 	rtw_debugfs_add_rw(rf_read);
 	rtw_debugfs_add_rw(dump_cam);
 	rtw_debugfs_add_rw(rsvd_page);
+	rtw_debugfs_add_r(phy_info);
 	rtw_debugfs_add_r(mac_0);
 	rtw_debugfs_add_r(mac_1);
 	rtw_debugfs_add_r(mac_2);
drivers/net/wireless/realtek/rtw88/main.c +31 -6
index 8049c40e0369..805cc159d33a 100644
@@ -178,6 +178,7 @@ static void rtw_watch_dog_work(struct work_struct *work)
 {
 	struct rtw_dev *rtwdev = container_of(work, struct rtw_dev,
 					      watch_dog_work.work);
+	struct rtw_traffic_stats *stats = &rtwdev->stats;
 	struct rtw_watch_dog_iter_data data = {};
 	bool busy_traffic = test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags);
 	bool ps_active;
@@ -198,17 +199,24 @@ static void rtw_watch_dog_work(struct work_struct *work)
 	if (busy_traffic != test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags))
 		rtw_coex_wl_status_change_notify(rtwdev);
 
-	if (rtwdev->stats.tx_cnt > RTW_LPS_THRESHOLD ||
-	    rtwdev->stats.rx_cnt > RTW_LPS_THRESHOLD)
+	if (stats->tx_cnt > RTW_LPS_THRESHOLD ||
+	    stats->rx_cnt > RTW_LPS_THRESHOLD)
 		ps_active = true;
 	else
 		ps_active = false;
 
+	ewma_tp_add(&stats->tx_ewma_tp,
+		    (u32)(stats->tx_unicast >> RTW_TP_SHIFT));
+	ewma_tp_add(&stats->rx_ewma_tp,
+		    (u32)(stats->rx_unicast >> RTW_TP_SHIFT));
+	stats->tx_throughput = ewma_tp_read(&stats->tx_ewma_tp);
+	stats->rx_throughput = ewma_tp_read(&stats->rx_ewma_tp);
+
 	/* reset tx/rx statictics */
-	rtwdev->stats.tx_unicast = 0;
-	rtwdev->stats.rx_unicast = 0;
-	rtwdev->stats.tx_cnt = 0;
-	rtwdev->stats.rx_cnt = 0;
+	stats->tx_unicast = 0;
+	stats->rx_unicast = 0;
+	stats->tx_cnt = 0;
+	stats->rx_cnt = 0;
 
 	if (test_bit(RTW_FLAG_SCANNING, rtwdev->flags))
 		goto unlock;
@@ -1276,6 +1284,21 @@ int rtw_chip_info_setup(struct rtw_dev *rtwdev)
 }
 EXPORT_SYMBOL(rtw_chip_info_setup);
 
+static void rtw_stats_init(struct rtw_dev *rtwdev)
+{
+	struct rtw_traffic_stats *stats = &rtwdev->stats;
+	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
+	int i;
+
+	ewma_tp_init(&stats->tx_ewma_tp);
+	ewma_tp_init(&stats->rx_ewma_tp);
+
+	for (i = 0; i < RTW_EVM_NUM; i++)
+		ewma_evm_init(&dm_info->ewma_evm[i]);
+	for (i = 0; i < RTW_SNR_NUM; i++)
+		ewma_snr_init(&dm_info->ewma_snr[i]);
+}
+
 int rtw_core_init(struct rtw_dev *rtwdev)
 {
 	struct rtw_chip_info *chip = rtwdev->chip;
@@ -1324,6 +1347,8 @@ int rtw_core_init(struct rtw_dev *rtwdev)
 	rtw_add_rsvd_page(rtwdev, RSVD_BEACON, false);
 	mutex_unlock(&rtwdev->mutex);
 
+	rtw_stats_init(rtwdev);
+
 	/* default rx filter setting */
 	rtwdev->hal.rcr = BIT_APP_FCS | BIT_APP_MIC | BIT_APP_ICV |
 			  BIT_HTC_LOC_CTRL | BIT_APP_PHYSTS |
drivers/net/wireless/realtek/rtw88/main.h +58 -0

102 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/phy.c +9 -0
index 0fa8d91a882b..69e7edb629f4 100644
@@ -222,10 +222,19 @@ static void rtw_phy_stat_rssi(struct rtw_dev *rtwdev)
 	dm_info->min_rssi = data.min_rssi;
 }
 
+static void rtw_phy_stat_rate_cnt(struct rtw_dev *rtwdev)
+{
+	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
+
+	dm_info->last_pkt_count = dm_info->cur_pkt_count;
+	memset(&dm_info->cur_pkt_count, 0, sizeof(dm_info->cur_pkt_count));
+}
+
 static void rtw_phy_statistics(struct rtw_dev *rtwdev)
 {
 	rtw_phy_stat_rssi(rtwdev);
 	rtw_phy_stat_false_alarm(rtwdev);
+	rtw_phy_stat_rate_cnt(rtwdev);
 }
 
 #define DIG_PERF_FA_TH_LOW			250
drivers/net/wireless/realtek/rtw88/rtw8822b.c +45 -0

82 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/rtw8822b.h +12 -0
index 0cb93d7d4cfd..6211f4b547b9 100644
@@ -127,6 +127,18 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
 	le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(11, 8))
 #define GET_PHY_STAT_P1_HT_RXSC(phy_stat)                                      \
 	le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(15, 12))
+#define GET_PHY_STAT_P1_RXEVM_A(phy_stat)                                      \
+	le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(7, 0))
+#define GET_PHY_STAT_P1_RXEVM_B(phy_stat)                                      \
+	le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(15, 8))
+#define GET_PHY_STAT_P1_CFO_TAIL_A(phy_stat)                                 \
+	le32_get_bits(*((__le32 *)(phy_stat) + 0x05), GENMASK(7, 0))
+#define GET_PHY_STAT_P1_CFO_TAIL_B(phy_stat)                                 \
+	le32_get_bits(*((__le32 *)(phy_stat) + 0x05), GENMASK(15, 8))
+#define GET_PHY_STAT_P1_RXSNR_A(phy_stat)                                      \
+	le32_get_bits(*((__le32 *)(phy_stat) + 0x06), GENMASK(7, 0))
+#define GET_PHY_STAT_P1_RXSNR_B(phy_stat)                                      \
+	le32_get_bits(*((__le32 *)(phy_stat) + 0x06), GENMASK(15, 8))
 
 #define REG_HTSTFWT	0x800
 #define REG_RXPSEL	0x808
drivers/net/wireless/realtek/rtw88/rtw8822c.c +48 -0

86 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/rtw8822c.h +12 -0
index 438db74d8e7a..abd9f300bedd 100644
@@ -149,6 +149,18 @@ const struct rtw_table name ## _tbl = {			\
 	le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(11, 8))
 #define GET_PHY_STAT_P1_HT_RXSC(phy_stat)                                      \
 	le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(15, 12))
+#define GET_PHY_STAT_P1_RXEVM_A(phy_stat)                                      \
+	le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(7, 0))
+#define GET_PHY_STAT_P1_RXEVM_B(phy_stat)                                      \
+	le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(15, 8))
+#define GET_PHY_STAT_P1_CFO_TAIL_A(phy_stat)                                 \
+	le32_get_bits(*((__le32 *)(phy_stat) + 0x05), GENMASK(7, 0))
+#define GET_PHY_STAT_P1_CFO_TAIL_B(phy_stat)                                 \
+	le32_get_bits(*((__le32 *)(phy_stat) + 0x05), GENMASK(15, 8))
+#define GET_PHY_STAT_P1_RXSNR_A(phy_stat)                                      \
+	le32_get_bits(*((__le32 *)(phy_stat) + 0x06), GENMASK(7, 0))
+#define GET_PHY_STAT_P1_RXSNR_B(phy_stat)                                      \
+	le32_get_bits(*((__le32 *)(phy_stat) + 0x06), GENMASK(15, 8))
 
 #define REG_ANAPARLDO_POW_MAC	0x0029
 #define BIT_LDOE25_PON		BIT(0)
drivers/net/wireless/realtek/rtw88/rx.c +63 -6

89 lines not on this page · raw message

Signature · 1 line
2.17.1
#20 lore raw

Re: [PATCH v2 6/6] rtw88: add phy_info debugfs to show Tx/Rx physical status

Quoted 56 lines · On Wed, Oct 16, 2019 at 8:33 PM <[email protected]> wrote:

From: Tsang-Shian Lin <[email protected]>

This commit adds several Tx/Rx physical information to phy_info debugfs for 8822B/8822C. By this debugfs, we can know physical information, such as Tx/Rx rate, RSSI, EVM,SNR, etc. The information is gotten from the packets of Tx/Rx path. It has no impact for the performance of 8822B/8822C.

In the fields, we may meet different kinds of problems, but we may have no professional instrument to check them. At this moment, this debugfs is a good tool, and it may provide useful information for debug.

---

v1 -> v2
* No change

drivers/net/wireless/realtek/rtw88/main.h +20 -0
@@ -528,10 +556,16 @@ struct rtw_rx_pkt_stat {
        s8 rx_power[RTW_RF_PATH_MAX];
        u8 rssi;
        u8 rxsc;
+       s8 rx_snr[RTW_RF_PATH_MAX];
+       u8 rx_evm[RTW_RF_PATH_MAX];
+       s8 cfo_tail[RTW_RF_PATH_MAX];
+
        struct rtw_sta_info *si;
        struct ieee80211_vif *vif;
 };
 
+DECLARE_EWMA(tp, 10, 2);
+
 struct rtw_traffic_stats {
        /* units in bytes */
        u64 tx_unicast;
@@ -853,6 +860,34 @@ static void query_phy_status_page1(struct rtw_dev *rtwdev, u8 *phy_status,
        pkt_stat->signal_power = max3(pkt_stat->rx_power[RF_PATH_A],
                                      pkt_stat->rx_power[RF_PATH_B],
                                      min_rx_power);
+
+       dm_info->curr_rx_rate = pkt_stat->rate;
+
+       pkt_stat->rx_evm[RF_PATH_A] = GET_PHY_STAT_P1_RXEVM_A(phy_status);
+       pkt_stat->rx_evm[RF_PATH_B] = GET_PHY_STAT_P1_RXEVM_B(phy_status);
+
+       pkt_stat->rx_snr[RF_PATH_A] = GET_PHY_STAT_P1_RXSNR_A(phy_status);
+       pkt_stat->rx_snr[RF_PATH_B] = GET_PHY_STAT_P1_RXSNR_B(phy_status);
+
+       pkt_stat->cfo_tail[RF_PATH_A] = GET_PHY_STAT_P1_CFO_TAIL_A(phy_status);
+       pkt_stat->cfo_tail[RF_PATH_B] = GET_PHY_STAT_P1_CFO_TAIL_B(phy_status);
+
+       for (path = 0; path <= rtwdev->hal.rf_path_num; path++) {
+               rssi = rtw_phy_rf_power_2_rssi(&pkt_stat->rx_power[path], 1);

drivers/net/wireless/realtek/rtw88/main.h static void query_phy_status_page1(struct rtw_dev *rtwdev, u8 *phy_status, · line 886

Quoted 10 lines
drivers/net/wireless/realtek/rtw88/main.h +10 -0
+               dm_info->rssi[path] = rssi;
+               dm_info->rx_snr[path] = pkt_stat->rx_snr[path] >> 1;
+               dm_info->cfo_tail[path] = (pkt_stat->cfo_tail[path] * 5) >> 1;
+
+               rx_evm = pkt_stat->rx_evm[path];
+
+               if (rx_evm < 0) {
+                       evm_dbm = ((u8)-rx_evm >> 1);
+
+                       if (evm_dbm == 64)

Does the 64 means the S8_MAX >> 1 or something else?
Can you give a more straightforward expression for EVM boundary check? Same for the following rtw8822c.c

Quoted 9 lines
drivers/net/wireless/realtek/rtw88/rtw8822b.c +4 -1
+                               evm_dbm = 0;
+               }
+               dm_info->rx_evm_dbm[path] = evm_dbm;
+       }
 }
 
--

2.17.1