wifi: rtl8xxxu: Add central frequency offset tracking
PATCH v2 1/5 wifi: rtl8xxxu: Add central frequency offset tracking
According to Realtek programmers, "to adjust oscillator to align central frequency of connected AP. Then, it can yield better performance." From commit fb8517f4fade ("rtw88: 8822c: add CFO tracking").
The RTL8192CU and a version of RTL8723AU apparently don't have the ability to adjust the oscillator, so this doesn't apply to them.
This also doesn't apply to the wifi + bluetooth combo chips (RTL8723AU and RTL8723BU) because the CFO tracking should only be done when bluetooth is disabled, and determining that looked complicated.
That leaves only the RTL8192EU and RTL8188FU chips. I tested this with the latter.
---
v2:
- Suggestions from Ping-Ke Shih:
- Use FIELD_PREP().
- Let packet_count wrap around.
- Use clamp().
--- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 21 ++- .../realtek/rtl8xxxu/rtl8xxxu_8188f.c | 39 ++++- .../realtek/rtl8xxxu/rtl8xxxu_8192e.c | 4 +- .../realtek/rtl8xxxu/rtl8xxxu_8723a.c | 38 ++++- .../realtek/rtl8xxxu/rtl8xxxu_8723b.c | 4 +- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 137 ++++++++++++++++-- .../wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 1 + 7 files changed, 212 insertions(+), 32 deletions(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +18 -3
@@ -570,7 +570,7 @@ struct rtl8723au_phy_stats {u8 cck_rpt_b_ofdm_cfosho_b;u8 reserved_1;u8 noise_power_db_msb; -u8 path_cfotail[RTL8723A_MAX_RF_PATHS ]; +s8 path_cfotail[RTL8723A_MAX_RF_PATHS ];u8 pcts_mask[RTL8723A_MAX_RF_PATHS ];s8 stream_rxevm[RTL8723A_MAX_RF_PATHS ];u8 path_rxsnr[RTL8723A_MAX_RF_PATHS ];
@@ -1323,6 +1323,19 @@ struct rtl8xxxu_ra_report {u8 desc_rate; }; +#define CFO_TH_XTAL_HIGH 20/* kHz */ +#define CFO_TH_XTAL_LOW 10/* kHz */ +#define CFO_TH_ATC 80/* kHz */ + +struct rtl8xxxu_cfo_tracking { +bool adjust; +bool atc_status; +int cfo_tail[2 ]; +u8 crystal_cap; +u32 packet_count; +u32 packet_count_pre; +}; +struct rtl8xxxu_priv {struct ieee80211_hw *hw;struct usb_device *udev;
@@ -1381,9 +1394,8 @@ struct rtl8xxxu_priv { u32 ep_tx_high_queue:1; u32 ep_tx_normal_queue:1; u32 ep_tx_low_queue:1; - u32 has_xtalk:1; u32 rx_buf_aggregation:1; -u8 xtalk; +u8 default_crystal_cap;unsigned int pipe_interrupt;unsigned int pipe_in;unsigned int pipe_out[TXDESC_QUEUE_MAX ];
@@ -1441,6 +1453,7 @@ struct rtl8xxxu_priv {struct sk_buff_head c2hcmd_queue;struct rtl8xxxu_btcoex bt_coex;struct rtl8xxxu_ra_report ra_report; +struct rtl8xxxu_cfo_tracking cfo_tracking; };struct rtl8xxxu_rx_urb {
@@ -1486,6 +1499,7 @@ struct rtl8xxxu_fileops { struct rtl8xxxu_txdesc32 *tx_desc, bool sgi, bool short_preamble, bool ampdu_enable, u32 rts_rate); +void (*set_crystal_cap) (struct rtl8xxxu_priv *priv,u8 crystal_cap);int writeN_block_size;int rx_agg_buf_size;char tx_desc_size;
@@ -1596,6 +1610,7 @@ void rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,void rtl8723bu_set_ps_tdma (struct rtl8xxxu_priv *priv,u8 arg1,u8 arg2,u8 arg3,u8 arg4,u8 arg5);void rtl8723bu_phy_init_antenna_selection (struct rtl8xxxu_priv *priv); +void rtl8723a_set_crystal_cap (struct rtl8xxxu_priv *priv,u8 crystal_cap);extern struct rtl8xxxu_fileops rtl8188fu_fops;extern struct rtl8xxxu_fileops rtl8192cu_fops;
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c +31 -8
@@ -703,7 +703,7 @@ static int rtl8188fu_parse_efuse(struct rtl8xxxu_priv *priv) priv->ofdm_tx_power_diff[0 ].a = efuse->tx_power_index_A.ht20_ofdm_1s_diff.a; priv->ht20_tx_power_diff[0 ].a = efuse->tx_power_index_A.ht20_ofdm_1s_diff.b; - priv->xtalk = efuse->xtal_k &0x3f ; + priv->default_crystal_cap = efuse->xtal_k &0x3f ;dev_info (&priv->udev->dev,"Vendor: %.7s\n" , efuse->vendor_name);dev_info (&priv->udev->dev,"Product: %.7s\n" , efuse->device_name);
@@ -737,7 +737,6 @@ static void rtl8188fu_init_phy_bb(struct rtl8xxxu_priv *priv) {u8 val8;u16 val16; -u32 val32;/* Enable BB and RF */ val16 =rtl8xxxu_read16 (priv,REG_SYS_FUNC );
@@ -759,12 +758,6 @@ static void rtl8188fu_init_phy_bb(struct rtl8xxxu_priv *priv)rtl8xxxu_init_phy_regs (priv, rtl8188fu_phy_init_table);rtl8xxxu_init_phy_regs (priv, rtl8188f_agc_table); - - val32 =rtl8xxxu_read32 (priv,REG_AFE_XTAL_CTRL ); - val8 = priv->xtalk; - val32 &= ~0x007FF800 ; - val32 |= ((val8 | (val8 <<6 )) <<11 ); -rtl8xxxu_write32 (priv,REG_AFE_XTAL_CTRL , val32); }static int rtl8188fu_init_phy_rf (struct rtl8xxxu_priv *priv)
@@ -1636,6 +1629,35 @@ static void rtl8188f_usb_quirks(struct rtl8xxxu_priv *priv)rtl8xxxu_write32 (priv,REG_TXDMA_OFFSET_CHK , val32); } +#define XTAL1 GENMASK(22, 17) +#define XTAL0 GENMASK(16, 11) + +static void rtl8188f_set_crystal_cap (struct rtl8xxxu_priv *priv,u8 crystal_cap) +{ +struct rtl8xxxu_cfo_tracking *cfo = &priv->cfo_tracking; +u32 val32; + +if (crystal_cap == cfo->crystal_cap) +return ; + + val32 =rtl8xxxu_read32 (priv,REG_AFE_XTAL_CTRL ); + +dev_dbg (&priv->udev->dev, +"%s: Adjusting crystal cap from 0x%x (actually 0x%lx 0x%lx) to 0x%x\n" , + __func__, + cfo->crystal_cap, +FIELD_GET (XTAL1 , val32), +FIELD_GET (XTAL0 , val32), + crystal_cap); + + val32 &= ~(XTAL1 |XTAL0 ); + val32 |=FIELD_PREP (XTAL1 , crystal_cap) | +FIELD_PREP (XTAL0 , crystal_cap); +rtl8xxxu_write32 (priv,REG_AFE_XTAL_CTRL , val32); + + cfo->crystal_cap = crystal_cap; +} +struct rtl8xxxu_fileops rtl8188fu_fops = { .parse_efuse = rtl8188fu_parse_efuse, .load_firmware = rtl8188fu_load_firmware,
@@ -1660,6 +1682,7 @@ struct rtl8xxxu_fileops rtl8188fu_fops = { .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, .report_connect = rtl8xxxu_gen2_report_connect, .fill_txdesc = rtl8xxxu_fill_txdesc_v2, + .set_crystal_cap = rtl8188f_set_crystal_cap, .writeN_block_size = 128, .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40),
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +2 -2
@@ -635,8 +635,7 @@ static int rtl8192eu_parse_efuse(struct rtl8xxxu_priv *priv) efuse->tx_power_index_B.pwr_diff[i -1 ].ht40; } - priv->has_xtalk =1 ; - priv->xtalk = priv->efuse_wifi.efuse8192eu.xtal_k &0x3f ; + priv->default_crystal_cap = priv->efuse_wifi.efuse8192eu.xtal_k &0x3f ;/* * device_info section seems to be laid out as records
@@ -1711,6 +1710,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = { .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, .report_connect = rtl8xxxu_gen2_report_connect, .fill_txdesc = rtl8xxxu_fill_txdesc_v2, + .set_crystal_cap = rtl8723a_set_crystal_cap, .writeN_block_size = 128, .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24),
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c +34 -4
@@ -166,10 +166,10 @@ static int rtl8723au_parse_efuse(struct rtl8xxxu_priv *priv) efuse->ht20_max_power_offset, sizeof(efuse->ht20_max_power_offset)); -if (priv->efuse_wifi.efuse8723.version >=0x01 ) { - priv->has_xtalk =1 ; - priv->xtalk = priv->efuse_wifi.efuse8723.xtal_k &0x3f ; - } +if (priv->efuse_wifi.efuse8723.version >=0x01 ) + priv->default_crystal_cap = priv->efuse_wifi.efuse8723.xtal_k &0x3f ; +else + priv->fops->set_crystal_cap =NULL ; priv->power_base = &rtl8723a_power_base;
@@ -357,6 +357,35 @@ static int rtl8723au_power_on(struct rtl8xxxu_priv *priv)return ret; } +#define XTAL1 GENMASK(23, 18) +#define XTAL0 GENMASK(17, 12) + +void rtl8723a_set_crystal_cap (struct rtl8xxxu_priv *priv,u8 crystal_cap) +{ +struct rtl8xxxu_cfo_tracking *cfo = &priv->cfo_tracking; +u32 val32; + +if (crystal_cap == cfo->crystal_cap) +return ; + + val32 =rtl8xxxu_read32 (priv,REG_MAC_PHY_CTRL ); + +dev_dbg (&priv->udev->dev, +"%s: Adjusting crystal cap from 0x%x (actually 0x%lx 0x%lx) to 0x%x\n" , + __func__, + cfo->crystal_cap, +FIELD_GET (XTAL1 , val32), +FIELD_GET (XTAL0 , val32), + crystal_cap); + + val32 &= ~(XTAL1 |XTAL0 ); + val32 |=FIELD_PREP (XTAL1 , crystal_cap) | +FIELD_PREP (XTAL0 , crystal_cap); +rtl8xxxu_write32 (priv,REG_MAC_PHY_CTRL , val32); + + cfo->crystal_cap = crystal_cap; +} +struct rtl8xxxu_fileops rtl8723au_fops = { .parse_efuse = rtl8723au_parse_efuse, .load_firmware = rtl8723au_load_firmware,
@@ -378,6 +407,7 @@ struct rtl8xxxu_fileops rtl8723au_fops = { .update_rate_mask = rtl8xxxu_update_rate_mask, .report_connect = rtl8xxxu_gen1_report_connect, .fill_txdesc = rtl8xxxu_fill_txdesc_v1, + .set_crystal_cap = rtl8723a_set_crystal_cap, .writeN_block_size = 1024, .rx_agg_buf_size = 16000, .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c +2 -2
@@ -445,8 +445,7 @@ static int rtl8723bu_parse_efuse(struct rtl8xxxu_priv *priv) efuse->tx_power_index_B.pwr_diff[i -1 ].ht40; } - priv->has_xtalk =1 ; - priv->xtalk = priv->efuse_wifi.efuse8723bu.xtal_k &0x3f ; + priv->default_crystal_cap = priv->efuse_wifi.efuse8723bu.xtal_k &0x3f ;dev_info (&priv->udev->dev,"Vendor: %.7s\n" , efuse->vendor_name);dev_info (&priv->udev->dev,"Product: %.41s\n" , efuse->device_name);
@@ -1664,6 +1663,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = { .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, .report_connect = rtl8xxxu_gen2_report_connect, .fill_txdesc = rtl8xxxu_fill_txdesc_v2, + .set_crystal_cap = rtl8723a_set_crystal_cap, .writeN_block_size = 1024, .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24),
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +124 -13
191 lines not on this page · raw message
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +1 -0
@@ -1027,6 +1027,7 @@#define REG_OFDM1_TRX_PATH_ENABLE 0x0d04#define REG_OFDM1_CFO_TRACKING 0x0d2c +#define CFO_TRACKING_ATC_STATUS BIT(11)#define REG_OFDM1_CSI_FIX_MASK1 0x0d40#define REG_OFDM1_CSI_FIX_MASK2 0x0d44
Signature · 1 line
2.38.0
PATCH v2 2/5 wifi: rtl8xxxu: Fix the CCK RSSI calculation
The CCK RSSI calculation is incorrect for the RTL8723BU, RTL8192EU, and RTL8188FU. Add new functions for these chips with code copied from their vendor drivers. Use the old code only for the RTL8723AU and RTL8192CU.
I didn't notice any difference in the reported signal strength with my RTL8188FU, but I didn't look very hard either.
---
v2:
- No change.
--- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 3 ++ .../realtek/rtl8xxxu/rtl8xxxu_8188f.c | 32 ++++++++++++++++ .../realtek/rtl8xxxu/rtl8xxxu_8192c.c | 1 + .../realtek/rtl8xxxu/rtl8xxxu_8192e.c | 23 +++++++++++ .../realtek/rtl8xxxu/rtl8xxxu_8723a.c | 23 +++++++++++ .../realtek/rtl8xxxu/rtl8xxxu_8723b.c | 29 ++++++++++++++ .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 38 ++++++++++++------- 7 files changed, 135 insertions(+), 14 deletions(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +3 -0
@@ -1395,6 +1395,7 @@ struct rtl8xxxu_priv { u32 ep_tx_normal_queue:1; u32 ep_tx_low_queue:1; u32 rx_buf_aggregation:1; + u32 cck_agc_report_type:1;u8 default_crystal_cap;unsigned int pipe_interrupt;unsigned int pipe_in;
@@ -1500,6 +1501,7 @@ struct rtl8xxxu_fileops { bool short_preamble, bool ampdu_enable, u32 rts_rate);void (*set_crystal_cap) (struct rtl8xxxu_priv *priv,u8 crystal_cap); +s8 (*cck_rssi) (struct rtl8xxxu_priv *priv,u8 cck_agc_rpt);int writeN_block_size;int rx_agg_buf_size;char tx_desc_size;
@@ -1611,6 +1613,7 @@ void rtl8723bu_set_ps_tdma(struct rtl8xxxu_priv *priv, u8 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5);void rtl8723bu_phy_init_antenna_selection (struct rtl8xxxu_priv *priv);void rtl8723a_set_crystal_cap (struct rtl8xxxu_priv *priv,u8 crystal_cap); +s8 rtl8723a_cck_rssi (struct rtl8xxxu_priv *priv,u8 cck_agc_rpt);extern struct rtl8xxxu_fileops rtl8188fu_fops;extern struct rtl8xxxu_fileops rtl8192cu_fops;
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c +32 -0
@@ -1658,6 +1658,37 @@ static void rtl8188f_set_crystal_cap(struct rtl8xxxu_priv *priv, u8 crystal_cap) cfo->crystal_cap = crystal_cap; } +static s8 rtl8188f_cck_rssi (struct rtl8xxxu_priv *priv,u8 cck_agc_rpt) +{ +s8 rx_pwr_all =0x00 ; +u8 vga_idx, lna_idx; + + lna_idx = (cck_agc_rpt &0xE0 ) >>5 ; + vga_idx = cck_agc_rpt &0x1F ; + +switch (lna_idx) { +case 7 : +if (vga_idx <=27 ) + rx_pwr_all =-100 +2 * (27 - vga_idx); +else + rx_pwr_all =-100 ; +break ; +case 5 : + rx_pwr_all =-74 +2 * (21 - vga_idx); +break ; +case 3 : + rx_pwr_all =-60 +2 * (20 - vga_idx); +break ; +case 1 : + rx_pwr_all =-44 +2 * (19 - vga_idx); +break ; +default : +break ; + } + +return rx_pwr_all; +} +struct rtl8xxxu_fileops rtl8188fu_fops = { .parse_efuse = rtl8188fu_parse_efuse, .load_firmware = rtl8188fu_load_firmware,
@@ -1683,6 +1714,7 @@ struct rtl8xxxu_fileops rtl8188fu_fops = { .report_connect = rtl8xxxu_gen2_report_connect, .fill_txdesc = rtl8xxxu_fill_txdesc_v2, .set_crystal_cap = rtl8188f_set_crystal_cap, + .cck_rssi = rtl8188f_cck_rssi, .writeN_block_size = 128, .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40),
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c +1 -0
@@ -561,6 +561,7 @@ struct rtl8xxxu_fileops rtl8192cu_fops = { .update_rate_mask = rtl8xxxu_update_rate_mask, .report_connect = rtl8xxxu_gen1_report_connect, .fill_txdesc = rtl8xxxu_fill_txdesc_v1, + .cck_rssi = rtl8723a_cck_rssi, .writeN_block_size = 128, .rx_agg_buf_size = 16000, .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +23 -0
@@ -1689,6 +1689,28 @@ static void rtl8192eu_init_aggregation(struct rtl8xxxu_priv *priv)rtl8xxxu_write32 (priv,REG_RXDMA_AGG_PG_TH , agg_rx); } +static s8 rtl8192e_cck_rssi (struct rtl8xxxu_priv *priv,u8 cck_agc_rpt) +{ +static const s8 lna_gain_table_0[8 ] = {15 ,9 ,-10 ,-21 ,-23 ,-27 ,-43 ,-44 }; +static const s8 lna_gain_table_1[8 ] = {24 ,18 ,13 ,-4 ,-11 ,-18 ,-31 ,-36 }; + +s8 rx_pwr_all =0x00 ; +u8 vga_idx, lna_idx; +s8 lna_gain =0 ; + + lna_idx = (cck_agc_rpt &0xE0 ) >>5 ; + vga_idx = cck_agc_rpt &0x1F ; + +if (priv->cck_agc_report_type ==0 ) + lna_gain = lna_gain_table_0[lna_idx]; +else + lna_gain = lna_gain_table_1[lna_idx]; + + rx_pwr_all = lna_gain - (2 * vga_idx); + +return rx_pwr_all; +} +struct rtl8xxxu_fileops rtl8192eu_fops = { .parse_efuse = rtl8192eu_parse_efuse, .load_firmware = rtl8192eu_load_firmware,
@@ -1711,6 +1733,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = { .report_connect = rtl8xxxu_gen2_report_connect, .fill_txdesc = rtl8xxxu_fill_txdesc_v2, .set_crystal_cap = rtl8723a_set_crystal_cap, + .cck_rssi = rtl8192e_cck_rssi, .writeN_block_size = 128, .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24),
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c +23 -0
@@ -386,6 +386,28 @@ void rtl8723a_set_crystal_cap(struct rtl8xxxu_priv *priv, u8 crystal_cap) cfo->crystal_cap = crystal_cap; } +s8 rtl8723a_cck_rssi (struct rtl8xxxu_priv *priv,u8 cck_agc_rpt) +{ +s8 rx_pwr_all =0x00 ; + +switch (cck_agc_rpt &0xc0 ) { +case 0xc0 : + rx_pwr_all =-46 - (cck_agc_rpt &0x3e ); +break ; +case 0x80 : + rx_pwr_all =-26 - (cck_agc_rpt &0x3e ); +break ; +case 0x40 : + rx_pwr_all =-12 - (cck_agc_rpt &0x3e ); +break ; +case 0x00 : + rx_pwr_all =16 - (cck_agc_rpt &0x3e ); +break ; + } + +return rx_pwr_all; +} +struct rtl8xxxu_fileops rtl8723au_fops = { .parse_efuse = rtl8723au_parse_efuse, .load_firmware = rtl8723au_load_firmware,
@@ -408,6 +430,7 @@ struct rtl8xxxu_fileops rtl8723au_fops = { .report_connect = rtl8xxxu_gen1_report_connect, .fill_txdesc = rtl8xxxu_fill_txdesc_v1, .set_crystal_cap = rtl8723a_set_crystal_cap, + .cck_rssi = rtl8723a_cck_rssi, .writeN_block_size = 1024, .rx_agg_buf_size = 16000, .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c +29 -0
@@ -1639,6 +1639,34 @@ static void rtl8723bu_init_statistics(struct rtl8xxxu_priv *priv)rtl8xxxu_write32 (priv,REG_OFDM0_FA_RSTC , val32); } +static s8 rtl8723b_cck_rssi (struct rtl8xxxu_priv *priv,u8 cck_agc_rpt) +{ +s8 rx_pwr_all =0x00 ; +u8 vga_idx, lna_idx; + + lna_idx = (cck_agc_rpt &0xE0 ) >>5 ; + vga_idx = cck_agc_rpt &0x1F ; + +switch (lna_idx) { +case 6 : + rx_pwr_all =-34 - (2 * vga_idx); +break ; +case 4 : + rx_pwr_all =-14 - (2 * vga_idx); +break ; +case 1 : + rx_pwr_all =6 - (2 * vga_idx); +break ; +case 0 : + rx_pwr_all =16 - (2 * vga_idx); +break ; +default : +break ; + } + +return rx_pwr_all; +} +struct rtl8xxxu_fileops rtl8723bu_fops = { .parse_efuse = rtl8723bu_parse_efuse, .load_firmware = rtl8723bu_load_firmware,
@@ -1664,6 +1692,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = { .report_connect = rtl8xxxu_gen2_report_connect, .fill_txdesc = rtl8xxxu_fill_txdesc_v2, .set_crystal_cap = rtl8723a_set_crystal_cap, + .cck_rssi = rtl8723b_cck_rssi, .writeN_block_size = 1024, .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24),
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +24 -14
@@ -4325,6 +4325,29 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw) val32 &=0xfff00fff ; val32 |=0x0007e000 ;rtl8xxxu_write32 (priv,REG_AFE_MISC , val32); + +/* +* 0x824[9] = 0x82C[9] = 0xA80[7] those registers setting +* should be equal or CCK RSSI report may be incorrect +*/ + val32 =rtl8xxxu_read32 (priv,REG_FPGA0_XA_HSSI_PARM2 ); + priv->cck_agc_report_type = val32 &FPGA0_HSSI_PARM2_CCK_HIGH_PWR ; + + val32 =rtl8xxxu_read32 (priv,REG_FPGA0_XB_HSSI_PARM2 ); +if (priv->cck_agc_report_type != (bool )(val32 &FPGA0_HSSI_PARM2_CCK_HIGH_PWR )) { +if (priv->cck_agc_report_type) + val32 |=FPGA0_HSSI_PARM2_CCK_HIGH_PWR ; +else + val32 &= ~FPGA0_HSSI_PARM2_CCK_HIGH_PWR ; +rtl8xxxu_write32 (priv,REG_FPGA0_XB_HSSI_PARM2 , val32); + } + + val32 =rtl8xxxu_read32 (priv,0xa80 ); +if (priv->cck_agc_report_type) + val32 |=BIT (7 ); +else + val32 &= ~BIT (7 ); +rtl8xxxu_write32 (priv,0xa80 , val32); }/* Initialise the center frequency offset tracking */
@@ -5314,20 +5337,7 @@ static void rtl8xxxu_rx_parse_phystats(struct rtl8xxxu_priv *priv,*/ u8 cck_agc_rpt = phy_stats->cck_agc_rpt_ofdm_cfosho_a; -switch (cck_agc_rpt &0xc0 ) { -case 0xc0 : - rx_status->signal =-46 - (cck_agc_rpt &0x3e ); -break ; -case 0x80 : - rx_status->signal =-26 - (cck_agc_rpt &0x3e ); -break ; -case 0x40 : - rx_status->signal =-12 - (cck_agc_rpt &0x3e ); -break ; -case 0x00 : - rx_status->signal =16 - (cck_agc_rpt &0x3e ); -break ; - } + rx_status->signal = priv->fops->cck_rssi (priv, cck_agc_rpt); }else {bool parse_cfo = priv->fops->set_crystal_cap && priv->vif &&
Signature · 1 line
2.38.0
RE: [PATCH v2 2/5] wifi: rtl8xxxu: Fix the CCK RSSI calculation
Quoted 31 lines
-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Tuesday, October 25, 2022 4:55 AM
To: [email protected]
Cc: Jes Sorensen <[email protected]>
Subject: [PATCH v2 2/5] wifi: rtl8xxxu: Fix the CCK RSSI calculationThe CCK RSSI calculation is incorrect for the RTL8723BU, RTL8192EU, and RTL8188FU. Add new functions for these chips with code copied from their vendor drivers. Use the old code only for the RTL8723AU and RTL8192CU.
I didn't notice any difference in the reported signal strength with my RTL8188FU, but I didn't look very hard either.
Signed-off-by Bitterblue Smith <[email protected]>---
v2:
- No change.--- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 3 ++ .../realtek/rtl8xxxu/rtl8xxxu_8188f.c | 32 ++++++++++++++++ .../realtek/rtl8xxxu/rtl8xxxu_8192c.c | 1 + .../realtek/rtl8xxxu/rtl8xxxu_8192e.c | 23 +++++++++++ .../realtek/rtl8xxxu/rtl8xxxu_8723a.c | 23 +++++++++++ .../realtek/rtl8xxxu/rtl8xxxu_8723b.c | 29 ++++++++++++++ .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 38 ++++++++++++------- 7 files changed, 135 insertions(+), 14 deletions(-)
[...]
Quoted 21 lines
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +12
-0@@ -4325,6 +4325,29 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw) val32 &=0xfff00fff ; val32 |=0x0007e000 ;rtl8xxxu_write32 (priv,REG_AFE_MISC , val32); + +/* +* 0x824[9] = 0x82C[9] = 0xA80[7] those registers setting +* should be equal or CCK RSSI report may be incorrect +*/ + val32 =rtl8xxxu_read32 (priv,REG_FPGA0_XA_HSSI_PARM2 ); + priv->cck_agc_report_type = val32 &FPGA0_HSSI_PARM2_CCK_HIGH_PWR ; + + val32 =rtl8xxxu_read32 (priv,REG_FPGA0_XB_HSSI_PARM2 ); +if (priv->cck_agc_report_type != (bool )(val32 &FPGA0_HSSI_PARM2_CCK_HIGH_PWR )) { +if (priv->cck_agc_report_type) + val32 |=FPGA0_HSSI_PARM2_CCK_HIGH_PWR ;
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c static int rtl8xxxu_init_device(struct ieee80211_hw *hw) · line 4349
Quoted 10 lines
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +10
-0+else + val32 &= ~FPGA0_HSSI_PARM2_CCK_HIGH_PWR ; +rtl8xxxu_write32 (priv,REG_FPGA0_XB_HSSI_PARM2 , val32); + } + + val32 =rtl8xxxu_read32 (priv,0xa80 ); +if (priv->cck_agc_report_type) + val32 |=BIT (7 ); +else + val32 &= ~BIT (7 );
We can give a name to 0xA80[7]:
#define REG_AGC_RPT 0x0a80
#define AGC_RTP_CCK BIT(7)
Re: [PATCH v2 2/5] wifi: rtl8xxxu: Fix the CCK RSSI calculation
Quoted 68 lines · Ping-Ke Shih
Quoted 31 lines
-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Tuesday, October 25, 2022 4:55 AM
To: [email protected]
Cc: Jes Sorensen <[email protected]>
Subject: [PATCH v2 2/5] wifi: rtl8xxxu: Fix the CCK RSSI calculationThe CCK RSSI calculation is incorrect for the RTL8723BU, RTL8192EU, and RTL8188FU. Add new functions for these chips with code copied from their vendor drivers. Use the old code only for the RTL8723AU and RTL8192CU.
I didn't notice any difference in the reported signal strength with my RTL8188FU, but I didn't look very hard either.
Signed-off-by Bitterblue Smith <[email protected]>---
v2:
- No change.--- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 3 ++ .../realtek/rtl8xxxu/rtl8xxxu_8188f.c | 32 ++++++++++++++++ .../realtek/rtl8xxxu/rtl8xxxu_8192c.c | 1 + .../realtek/rtl8xxxu/rtl8xxxu_8192e.c | 23 +++++++++++ .../realtek/rtl8xxxu/rtl8xxxu_8723a.c | 23 +++++++++++ .../realtek/rtl8xxxu/rtl8xxxu_8723b.c | 29 ++++++++++++++ .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 38 ++++++++++++------- 7 files changed, 135 insertions(+), 14 deletions(-)[...]
Quoted 21 lines
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +12
-0@@ -4325,6 +4325,29 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw) val32 &=0xfff00fff ; val32 |=0x0007e000 ;rtl8xxxu_write32 (priv,REG_AFE_MISC , val32); + +/* +* 0x824[9] = 0x82C[9] = 0xA80[7] those registers setting +* should be equal or CCK RSSI report may be incorrect +*/ + val32 =rtl8xxxu_read32 (priv,REG_FPGA0_XA_HSSI_PARM2 ); + priv->cck_agc_report_type = val32 &FPGA0_HSSI_PARM2_CCK_HIGH_PWR ; + + val32 =rtl8xxxu_read32 (priv,REG_FPGA0_XB_HSSI_PARM2 ); +if (priv->cck_agc_report_type != (bool )(val32 &FPGA0_HSSI_PARM2_CCK_HIGH_PWR )) { +if (priv->cck_agc_report_type) + val32 |=FPGA0_HSSI_PARM2_CCK_HIGH_PWR ;drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c static int rtl8xxxu_init_device(struct ieee80211_hw *hw) · line 4349
Quoted 10 lines
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +10
-0+else + val32 &= ~FPGA0_HSSI_PARM2_CCK_HIGH_PWR ; +rtl8xxxu_write32 (priv,REG_FPGA0_XB_HSSI_PARM2 , val32); + } + + val32 =rtl8xxxu_read32 (priv,0xa80 ); +if (priv->cck_agc_report_type) + val32 |=BIT (7 ); +else + val32 &= ~BIT (7 );We can give a name to 0xA80[7]:
Quoted 4 lines
#define
REG_AGC_RPT0x0a80
#defineAGC_RTP_CCKBIT(7)
Thanks, I'll add it.
PATCH v2 3/5 wifi: rtl8xxxu: Recognise all possible chip cuts
In reply to Bitterblue SmithThe chip cut, also known as the chip version, is a letter from A (0) to P (15). Recognise them all instead of printing "unknown" when it's greater than E.
---
v2:
- Suggestion from Ping-Ke Shih:
- Don't use array of letters.
--- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +5 -21
@@ -1574,30 +1574,14 @@ rtl8xxxu_set_spec_sifs(struct rtl8xxxu_priv *priv, u16 cck, u16 ofdm)static void rtl8xxxu_print_chipinfo (struct rtl8xxxu_priv *priv) {struct device *dev = &priv->udev->dev; -char *cut; +char cut ='?' ; -switch (priv->chip_cut) { -case 0 : - cut ="A" ; -break ; -case 1 : - cut ="B" ; -break ; -case 2 : - cut ="C" ; -break ; -case 3 : - cut ="D" ; -break ; -case 4 : - cut ="E" ; -break ; -default : - cut ="unknown" ; - } +/* Currently always true: chip_cut is 4 bits. */ +if (priv->chip_cut <=15 ) + cut ='A' + priv->chip_cut;dev_info (dev, -"RTL%s rev %s (%s) %iT%iR, TX queues %i, WiFi=%i, BT=%i, GPS=%i, HI PA=%i\n" , +"RTL%s rev %c (%s) %iT%iR, TX queues %i, WiFi=%i, BT=%i, GPS=%i, HI PA=%i\n" , priv->chip_name, cut, priv->chip_vendor, priv->tx_paths, priv->rx_paths, priv->ep_tx_count, priv->has_wifi, priv->has_bluetooth, priv->has_gps, priv->hi_pa);
Signature · 1 line
2.38.0
RE: [PATCH v2 3/5] wifi: rtl8xxxu: Recognise all possible chip cuts
Quoted 9 lines
-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Tuesday, October 25, 2022 4:57 AM
To: [email protected]
Cc: Jes Sorensen <[email protected]>
Subject: [PATCH v2 3/5] wifi: rtl8xxxu: Recognise all possible chip cuts
Quoted 5 lines
The chip cut, also known as the chip version, is a letter from A (0) to P (15). Recognise them all instead of printing "unknown" when it's greater than E.
Signed-off-by Bitterblue Smith <[email protected]>
Quoted 8 lines
---
v2:
- Suggestion from Ping-Ke Shih:
- Don't use array of letters.--- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-)
[...]
PATCH v2 4/5 wifi: rtl8xxxu: Set IEEE80211_HW_SUPPORT_FAST_XMIT
In reply to Bitterblue SmithAccording to commit 60d7900dcb98 ("wlcore: enable IEEE80211_HW_SUPPORT_FAST_XMIT"), we can use this because all the chips have hardware rate control.
This is one of the things mac80211 requires before it will handle MSDU aggregation for us.
---
v2:
- No change.
--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +1 -0
@@ -7005,6 +7005,7 @@ static int rtl8xxxu_probe(struct usb_interface *interface,* The firmware handles rate control */ ieee80211_hw_set (hw,HAS_RATE_CONTROL ); +ieee80211_hw_set (hw,SUPPORT_FAST_XMIT );ieee80211_hw_set (hw,AMPDU_AGGREGATION );wiphy_ext_feature_set (hw->wiphy,NL80211_EXT_FEATURE_CQM_RSSI_LIST );
Signature · 1 line
2.38.0
RE: [PATCH v2 4/5] wifi: rtl8xxxu: Set IEEE80211_HW_SUPPORT_FAST_XMIT
Quoted 9 lines
-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Tuesday, October 25, 2022 4:58 AM
To: [email protected]
Cc: Jes Sorensen <[email protected]>
Subject: [PATCH v2 4/5] wifi: rtl8xxxu: SetIEEE80211_HW_SUPPORT_FAST_XMIT
Quoted 8 lines
According to commit
60d7900dcb98("wlcore: enableIEEE80211_HW_SUPPORT_FAST_XMIT"), we can use this because all the chips have hardware rate control.This is one of the things mac80211 requires before it will handle MSDU aggregation for us.
Signed-off-by Bitterblue Smith <[email protected]>
Quoted 24 lines
---
v2:
- No change.--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 1 + 1 file changed, 1 insertion(+)drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +1
-1@@ -7005,6 +7005,7 @@ static int rtl8xxxu_probe(struct usb_interface *interface,* The firmware handles rate control */ ieee80211_hw_set (hw,HAS_RATE_CONTROL ); +ieee80211_hw_set (hw,SUPPORT_FAST_XMIT );ieee80211_hw_set (hw,AMPDU_AGGREGATION );wiphy_ext_feature_set (hw->wiphy,NL80211_EXT_FEATURE_CQM_RSSI_LIST ); --2.38.0
------Please consider the environment before printing this e-mail.
PATCH v2 5/5 wifi: rtl8xxxu: Use dev_info instead of pr_info
In reply to Bitterblue SmithReplace two instances of bare pr_info with dev_info.
Also make their messages a little more informative.
---
v2:
- No change.
--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +4 -2
@@ -2015,7 +2015,8 @@ static int rtl8xxxu_download_firmware(struct rtl8xxxu_priv *priv) val8 =rtl8xxxu_read8 (priv,REG_MCU_FW_DL );if (val8 &MCU_FW_RAM_SEL ) { -pr_info ("do the RAM reset\n" ); +dev_info (&priv->udev->dev, +"Firmware is already running, resetting the MCU.\n" );rtl8xxxu_write8 (priv,REG_MCU_FW_DL ,0x00 ); priv->fops->reset_8051 (priv); }
@@ -5420,7 +5421,8 @@ static void rtl8xxxu_rx_urb_work(struct work_struct *work)rtl8xxxu_queue_rx_urb (priv, rx_urb);break ;default : -pr_info ("failed to requeue urb %i\n" , ret); +dev_info (&priv->udev->dev, +"failed to requeue urb with error %i\n" , ret); skb = (struct sk_buff *)rx_urb->urb.context;dev_kfree_skb (skb);usb_free_urb (&rx_urb->urb);
Signature · 1 line
2.38.0
RE: [PATCH v2 5/5] wifi: rtl8xxxu: Use dev_info instead of pr_info
Quoted 9 lines
-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Tuesday, October 25, 2022 4:59 AM
To: [email protected]
Cc: Jes Sorensen <[email protected]>
Subject: [PATCH v2 5/5] wifi: rtl8xxxu: Usedev_infoinstead ofpr_info
Quoted 5 lines
Replace two instances of bare
pr_infowithdev_info.Also make their messages a little more informative.
Signed-off-by Bitterblue Smith <[email protected]>
Quoted 36 lines
---
v2:
- No change.--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +4
-3@@ -2015,7 +2015,8 @@ static int rtl8xxxu_download_firmware(struct rtl8xxxu_priv *priv) val8 =rtl8xxxu_read8 (priv,REG_MCU_FW_DL );if (val8 &MCU_FW_RAM_SEL ) { -pr_info ("do the RAM reset\n" ); +dev_info (&priv->udev->dev, +"Firmware is already running, resetting the MCU.\n" );rtl8xxxu_write8 (priv,REG_MCU_FW_DL ,0x00 ); priv->fops->reset_8051 (priv); }@@ -5420,7 +5421,8 @@ static void rtl8xxxu_rx_urb_work(struct work_struct *work)rtl8xxxu_queue_rx_urb (priv, rx_urb);break ;default : -pr_info ("failed to requeue urb %i\n" , ret); +dev_info (&priv->udev->dev, +"failed to requeue urb with error %i\n" , ret); skb = (struct sk_buff *)rx_urb->urb.context;dev_kfree_skb (skb);usb_free_urb (&rx_urb->urb); --2.38.0
------Please consider the environment before printing this e-mail.
Quoted 16 lines
-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Tuesday, October 25, 2022 4:53 AM
To: [email protected]
Cc: Jes Sorensen <[email protected]>
Subject: [PATCH v2 1/5] wifi: rtl8xxxu: Add central frequency offset trackingAccording to Realtek programmers, "to adjust oscillator to align central frequency of connected AP. Then, it can yield better performance." From commit
fb8517f4fade("rtw88: 8822c: add CFO tracking").The RTL8192CU and a version of RTL8723AU apparently don't have the ability to adjust the oscillator, so this doesn't apply to them.
Quoted 8 lines
This also doesn't apply to the wifi + bluetooth combo chips (RTL8723AU and RTL8723BU) because the CFO tracking should only be done when bluetooth is disabled, and determining that looked complicated.
That leaves only the RTL8192EU and RTL8188FU chips. I tested this with the latter.
Signed-off-by Bitterblue Smith <[email protected]>
Quoted 16 lines
---
v2:
- Suggestions from Ping-Ke Shih:
- UseFIELD_PREP().
- Letpacket_countwrap around.
- Useclamp().--- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 21 ++- .../realtek/rtl8xxxu/rtl8xxxu_8188f.c | 39 ++++- .../realtek/rtl8xxxu/rtl8xxxu_8192e.c | 4 +- .../realtek/rtl8xxxu/rtl8xxxu_8723a.c | 38 ++++- .../realtek/rtl8xxxu/rtl8xxxu_8723b.c | 4 +- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 137 ++++++++++++++++-- .../wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 1 + 7 files changed, 212 insertions(+), 32 deletions(-)
[...]