We proposed firmware elements to have PHY parameters that are simple tuple
of {addr, value}, and this patchset is to add nine kinds of TX power tables
to firmware elements. Since TX power tables can be possibly increasing
dimension or value range in the future, it is much complicated than
parameter tables.
We keep existing WiFi 6 chips use tables built-in arrays in drivers, but
preserve rooms to make it possible to move arrays into firmware file
as well. So, patches in this patchset adjust struct also for this purpose.
About backward/forward compatibility:
This is the most important and complicated stuff of this patchset. The
method basically to achieve compatibility is to pad zeros.
1. encode scheme
Consider a TX power value in driver
power[x][y] = a
The indices part are also encoded into firmware file
x, y, a
For example,
power[5][6] = 9 --> 05 06 09
2. compatibility
When array dimension is increasing, it could become something like
power[x][y][z] = b
For example,
power[5][6][4] = 9 --> 05 06 09 04
^^
(note: the new dimension must be encoded as the last digit)
(I explain further based on these examples)
2.1. driver backward compatibility (new driver + old firmware)
From driver point of view, a tuple from firmware is 3 digits, so it
allocates a expected 4-digit tuple array first, and copy 3 digits into
the array. Base on above example, tuple in old firmware is recognized as
05 06 09 00 --> power[5][6][0] = 9
^^ This pending zero is existing in firmware, but driver adds it
2.2. driver forward compatibility (old driver + new firmware)
Like above example, old driver allocates 3-digit tuple array first, and
only copy 3-digits into the array if remaining digits are zeros. For
example,
05 06 09 04 --> only for new driver; don't recognize
05 06 09 00 --> power[5][6] = 9
^^ remaining digits must be zeros
Summarize the flow:
1. pre-condition
n = tuple size in firmware
m = tuple size expected by driver
2.1. n == m
- copy n digits into array
2.2. n < m (new driver + old firmware)
- allocate/zero m digits tuple array
- copy n digits into array
2.3. n > m (old driver + new firmware)
- if m + 1 ~ n digits aren't all zeros, ignore this tuple
- copy m digits into array
3. from tuple to regular C array.
Patch 1/7~6/7 are to adjust enum and struct, and patch 7/7 is to load
TX power from firmware. The remaining patches in hand are to set TX power
to WiFi 7 chips. I will submit them later.
Firmware elements layout for reference:
+===========================================+
| WiFi CPU multi-firmware |
| +-------------+
| | padding |
+===========================================+
| elm ID 1 | elm size | other header data |
+----------+----------+ |
| |
+-------------------------------------------+
| content (variable length) |
| +-------------+
| | padding |
+===========================================+
| elm ID 2 | elm size | other header data |
+----------+----------+ |
| |
+-------------------------------------------+
| content (variable length) |
| +-----------------------+
| |
+===================+
Element header:
+===========================================+
| elm ID | elm size | version | rsvd0 |
+----------+----------+----------+----------+
| rsvd1/2 | element_priv[] |
+-------------------------------------------+
Ping-Ke Shih (1):
wifi: rtw89: add subband index of primary channel to struct rtw89_chan
Zong-Zhe Yang (6):
wifi: rtw89: indicate TX shape table inside RFE parameter
wifi: rtw89: indicate TX power by rate table inside RFE parameter
wifi: rtw89: phy: refine helpers used for raw TX power
wifi: rtw89: load TX power by rate when RFE parms setup
wifi: rtw89: phy: extend TX power common stuffs for Wi-Fi 7 chips
wifi: rtw89: load TX power related tables from FW elements
drivers/net/wireless/realtek/rtw89/chan.c | 15 +
drivers/net/wireless/realtek/rtw89/core.c | 25 +-
drivers/net/wireless/realtek/rtw89/core.h | 152 ++++-
drivers/net/wireless/realtek/rtw89/fw.c | 530 ++++++++++++++++++
drivers/net/wireless/realtek/rtw89/fw.h | 130 +++++
drivers/net/wireless/realtek/rtw89/phy.c | 97 ++--
drivers/net/wireless/realtek/rtw89/phy.h | 3 +
drivers/net/wireless/realtek/rtw89/rtw8851b.c | 6 +-
.../wireless/realtek/rtw89/rtw8851b_table.c | 6 +
.../wireless/realtek/rtw89/rtw8851b_table.h | 3 -
drivers/net/wireless/realtek/rtw89/rtw8852a.c | 1 -
.../wireless/realtek/rtw89/rtw8852a_table.c | 2 +
.../wireless/realtek/rtw89/rtw8852a_table.h | 1 -
drivers/net/wireless/realtek/rtw89/rtw8852b.c | 6 +-
.../wireless/realtek/rtw89/rtw8852b_table.c | 4 +
.../wireless/realtek/rtw89/rtw8852b_table.h | 3 -
drivers/net/wireless/realtek/rtw89/rtw8852c.c | 6 +-
.../wireless/realtek/rtw89/rtw8852c_table.c | 4 +
.../wireless/realtek/rtw89/rtw8852c_table.h | 3 -
19 files changed, 910 insertions(+), 87 deletions(-)
--
2.25.1
From: Zong-Zhe Yang <[email protected]>
The following are introduced for Wi-Fi 7 chips.
1. take BW/OFDMA into account on TX power by rate
2. increase TX power offset types up to EHT
3. split TX shape into tx_shape_lmt and tx_shape_lmt_ru
If functions which are only for AX, they always access TX power by rate
with BW/OFDMA = 0/0, and they don't access tx_shape's lmt_ru section.
Signed-off-by: Zong-Zhe Yang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
---
drivers/net/wireless/realtek/rtw89/core.h | 48 +++++++++++++++----
drivers/net/wireless/realtek/rtw89/phy.c | 26 +++++-----
drivers/net/wireless/realtek/rtw89/rtw8851b.c | 4 +-
.../wireless/realtek/rtw89/rtw8851b_table.c | 4 +-
drivers/net/wireless/realtek/rtw89/rtw8852b.c | 4 +-
.../wireless/realtek/rtw89/rtw8852b_table.c | 2 +-
drivers/net/wireless/realtek/rtw89/rtw8852c.c | 4 +-
.../wireless/realtek/rtw89/rtw8852c_table.c | 2 +-
8 files changed, 63 insertions(+), 31 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 71ed4d59ef53..4ab7abfa8b1f 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -640,12 +640,29 @@ enum rtw89_rate_section {
RTW89_RS_TX_SHAPE_NUM = RTW89_RS_OFDM + 1,
};
+enum rtw89_rate_offset_indexes {
+ RTW89_RATE_OFFSET_HE,
+ RTW89_RATE_OFFSET_VHT,
+ RTW89_RATE_OFFSET_HT,
+ RTW89_RATE_OFFSET_OFDM,
+ RTW89_RATE_OFFSET_CCK,
+ RTW89_RATE_OFFSET_DLRU_EHT,
+ RTW89_RATE_OFFSET_DLRU_HE,
+ RTW89_RATE_OFFSET_EHT,
+ __RTW89_RATE_OFFSET_NUM,
+
+ RTW89_RATE_OFFSET_NUM_AX = RTW89_RATE_OFFSET_CCK + 1,
+ RTW89_RATE_OFFSET_NUM_BE = RTW89_RATE_OFFSET_EHT + 1,
+};
+
enum rtw89_rate_num {
RTW89_RATE_CCK_NUM = 4,
RTW89_RATE_OFDM_NUM = 8,
- RTW89_RATE_MCS_NUM = 12,
RTW89_RATE_HEDCM_NUM = 4, /* for HEDCM MCS0/1/3/4 */
- RTW89_RATE_OFFSET_NUM = 5, /* for HE(HEDCM)/VHT/HT/OFDM/CCK offset */
+
+ RTW89_RATE_MCS_NUM_AX = 12,
+ RTW89_RATE_MCS_NUM_BE = 16,
+ __RTW89_RATE_MCS_NUM = 16,
};
enum rtw89_nss {
@@ -670,6 +687,12 @@ enum rtw89_beamforming_type {
RTW89_BF_NUM,
};
+enum rtw89_ofdma_type {
+ RTW89_NON_OFDMA = 0,
+ RTW89_OFDMA = 1,
+ RTW89_OFDMA_NUM,
+};
+
enum rtw89_regulation_type {
RTW89_WW = 0,
RTW89_ETSI = 1,
@@ -715,9 +738,9 @@ enum rtw89_fw_pkt_ofld_type {
struct rtw89_txpwr_byrate {
s8 cck[RTW89_RATE_CCK_NUM];
s8 ofdm[RTW89_RATE_OFDM_NUM];
- s8 mcs[RTW89_NSS_NUM][RTW89_RATE_MCS_NUM];
- s8 hedcm[RTW89_NSS_HEDCM_NUM][RTW89_RATE_HEDCM_NUM];
- s8 offset[RTW89_RATE_OFFSET_NUM];
+ s8 mcs[RTW89_OFDMA_NUM][RTW89_NSS_NUM][__RTW89_RATE_MCS_NUM];
+ s8 hedcm[RTW89_OFDMA_NUM][RTW89_NSS_HEDCM_NUM][RTW89_RATE_HEDCM_NUM];
+ s8 offset[__RTW89_RATE_OFFSET_NUM];
s8 trap;
};
@@ -754,6 +777,7 @@ struct rtw89_txpwr_limit_ru {
struct rtw89_rate_desc {
enum rtw89_nss nss;
enum rtw89_rate_section rs;
+ enum rtw89_ofdma_type ofdma;
u8 idx;
};
@@ -861,13 +885,16 @@ enum rtw89_ps_mode {
#define RTW89_2G_BW_NUM (RTW89_CHANNEL_WIDTH_40 + 1)
#define RTW89_5G_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1)
-#define RTW89_6G_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1)
+#define RTW89_6G_BW_NUM (RTW89_CHANNEL_WIDTH_320 + 1)
+#define RTW89_BYR_BW_NUM (RTW89_CHANNEL_WIDTH_320 + 1)
#define RTW89_PPE_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1)
enum rtw89_ru_bandwidth {
RTW89_RU26 = 0,
RTW89_RU52 = 1,
RTW89_RU106 = 2,
+ RTW89_RU52_26 = 3,
+ RTW89_RU106_26 = 4,
RTW89_RU_NUM,
};
@@ -3355,12 +3382,17 @@ struct rtw89_txpwr_rule_6ghz {
[RTW89_6G_CH_NUM];
};
+struct rtw89_tx_shape {
+ const u8 (*lmt)[RTW89_BAND_NUM][RTW89_RS_TX_SHAPE_NUM][RTW89_REGD_NUM];
+ const u8 (*lmt_ru)[RTW89_BAND_NUM][RTW89_REGD_NUM];
+};
+
struct rtw89_rfe_parms {
const struct rtw89_txpwr_table *byr_tbl;
struct rtw89_txpwr_rule_2ghz rule_2ghz;
struct rtw89_txpwr_rule_5ghz rule_5ghz;
struct rtw89_txpwr_rule_6ghz rule_6ghz;
- const u8 (*tx_shape)[RTW89_BAND_NUM][RTW89_RS_TX_SHAPE_NUM][RTW89_REGD_NUM];
+ struct rtw89_tx_shape tx_shape;
};
struct rtw89_rfe_parms_conf {
@@ -4597,7 +4629,7 @@ struct rtw89_dev {
bool is_bt_iqk_timeout;
struct rtw89_fem_info fem;
- struct rtw89_txpwr_byrate byr[RTW89_BAND_NUM];
+ struct rtw89_txpwr_byrate byr[RTW89_BAND_NUM][RTW89_BYR_BW_NUM];
struct rtw89_tssi_info tssi;
struct rtw89_power_trim_info pwr_trim;
diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c
index f9f203295ee4..03e79d80e32c 100644
--- a/drivers/net/wireless/realtek/rtw89/phy.c
+++ b/drivers/net/wireless/realtek/rtw89/phy.c
@@ -1522,9 +1522,9 @@ EXPORT_SYMBOL(rtw89_phy_write_reg3_tbl);
static const u8 rtw89_rs_idx_num[] = {
[RTW89_RS_CCK] = RTW89_RATE_CCK_NUM,
[RTW89_RS_OFDM] = RTW89_RATE_OFDM_NUM,
- [RTW89_RS_MCS] = RTW89_RATE_MCS_NUM,
+ [RTW89_RS_MCS] = RTW89_RATE_MCS_NUM_AX,
[RTW89_RS_HEDCM] = RTW89_RATE_HEDCM_NUM,
- [RTW89_RS_OFFSET] = RTW89_RATE_OFFSET_NUM,
+ [RTW89_RS_OFFSET] = RTW89_RATE_OFFSET_NUM_AX,
};
static const u8 rtw89_rs_nss_num[] = {
@@ -1546,9 +1546,9 @@ s8 *rtw89_phy_raw_byr_seek(struct rtw89_dev *rtwdev,
case RTW89_RS_OFDM:
return &head->ofdm[desc->idx];
case RTW89_RS_MCS:
- return &head->mcs[desc->nss][desc->idx];
+ return &head->mcs[desc->ofdma][desc->nss][desc->idx];
case RTW89_RS_HEDCM:
- return &head->hedcm[desc->nss][desc->idx];
+ return &head->hedcm[desc->ofdma][desc->nss][desc->idx];
case RTW89_RS_OFFSET:
return &head->offset[desc->idx];
default:
@@ -1569,7 +1569,7 @@ void rtw89_phy_load_txpwr_byrate(struct rtw89_dev *rtwdev,
u8 i;
for (; cfg < end; cfg++) {
- byr_head = &rtwdev->byr[cfg->band];
+ byr_head = &rtwdev->byr[cfg->band][0];
desc.rs = cfg->rs;
desc.nss = cfg->nss;
data = cfg->data;
@@ -1591,7 +1591,7 @@ static s8 rtw89_phy_txpwr_rf_to_mac(struct rtw89_dev *rtwdev, s8 txpwr_rf)
}
static
-s8 rtw89_phy_read_txpwr_byrate(struct rtw89_dev *rtwdev, u8 band,
+s8 rtw89_phy_read_txpwr_byrate(struct rtw89_dev *rtwdev, u8 band, u8 bw,
const struct rtw89_rate_desc *rate_desc)
{
struct rtw89_txpwr_byrate *byr_head;
@@ -1600,7 +1600,7 @@ s8 rtw89_phy_read_txpwr_byrate(struct rtw89_dev *rtwdev, u8 band,
if (rate_desc->rs == RTW89_RS_CCK)
band = RTW89_BAND_2G;
- byr_head = &rtwdev->byr[band];
+ byr_head = &rtwdev->byr[band][bw];
byr = rtw89_phy_raw_byr_seek(rtwdev, byr_head, rate_desc);
return rtw89_phy_txpwr_rf_to_mac(rtwdev, *byr);
@@ -2110,7 +2110,7 @@ void rtw89_phy_set_txpwr_byrate(struct rtw89_dev *rtwdev,
RTW89_RS_MCS,
RTW89_RS_HEDCM,
};
- struct rtw89_rate_desc cur;
+ struct rtw89_rate_desc cur = {};
u8 band = chan->band_type;
u8 ch = chan->channel;
u32 addr, val;
@@ -2136,7 +2136,7 @@ void rtw89_phy_set_txpwr_byrate(struct rtw89_dev *rtwdev,
cur.idx++) {
v[cur.idx % 4] =
rtw89_phy_read_txpwr_byrate(rtwdev,
- band,
+ band, 0,
&cur);
if ((cur.idx + 1) % 4)
@@ -2165,15 +2165,15 @@ void rtw89_phy_set_txpwr_offset(struct rtw89_dev *rtwdev,
.rs = RTW89_RS_OFFSET,
};
u8 band = chan->band_type;
- s8 v[RTW89_RATE_OFFSET_NUM] = {};
+ s8 v[RTW89_RATE_OFFSET_NUM_AX] = {};
u32 val;
rtw89_debug(rtwdev, RTW89_DBG_TXPWR, "[TXPWR] set txpwr offset\n");
- for (desc.idx = 0; desc.idx < RTW89_RATE_OFFSET_NUM; desc.idx++)
- v[desc.idx] = rtw89_phy_read_txpwr_byrate(rtwdev, band, &desc);
+ for (desc.idx = 0; desc.idx < RTW89_RATE_OFFSET_NUM_AX; desc.idx++)
+ v[desc.idx] = rtw89_phy_read_txpwr_byrate(rtwdev, band, 0, &desc);
- BUILD_BUG_ON(RTW89_RATE_OFFSET_NUM != 5);
+ BUILD_BUG_ON(RTW89_RATE_OFFSET_NUM_AX != 5);
val = FIELD_PREP(GENMASK(3, 0), v[0]) |
FIELD_PREP(GENMASK(7, 4), v[1]) |
FIELD_PREP(GENMASK(11, 8), v[2]) |
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8851b.c b/drivers/net/wireless/realtek/rtw89/rtw8851b.c
index 826228117160..f9599fcd5ac7 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8851b.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8851b.c
@@ -1707,8 +1707,8 @@ static void rtw8851b_set_tx_shape(struct rtw89_dev *rtwdev,
const struct rtw89_rfe_parms *rfe_parms = rtwdev->rfe_parms;
u8 band = chan->band_type;
u8 regd = rtw89_regd_get(rtwdev, band);
- u8 tx_shape_cck = (*rfe_parms->tx_shape)[band][RTW89_RS_CCK][regd];
- u8 tx_shape_ofdm = (*rfe_parms->tx_shape)[band][RTW89_RS_OFDM][regd];
+ u8 tx_shape_cck = (*rfe_parms->tx_shape.lmt)[band][RTW89_RS_CCK][regd];
+ u8 tx_shape_ofdm = (*rfe_parms->tx_shape.lmt)[band][RTW89_RS_OFDM][regd];
if (band == RTW89_BAND_2G)
rtw8851b_bb_set_tx_shape_dfir(rtwdev, chan, tx_shape_cck, phy_idx);
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8851b_table.c b/drivers/net/wireless/realtek/rtw89/rtw8851b_table.c
index bd9655385318..888e5e75b40f 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8851b_table.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8851b_table.c
@@ -14821,7 +14821,7 @@ const struct rtw89_rfe_parms rtw89_8851b_dflt_parms = {
.lmt = &rtw89_8851b_txpwr_lmt_5g,
.lmt_ru = &rtw89_8851b_txpwr_lmt_ru_5g,
},
- .tx_shape = &rtw89_8851b_tx_shape,
+ .tx_shape.lmt = &rtw89_8851b_tx_shape,
};
static const struct rtw89_rfe_parms rtw89_8851b_rfe_parms_type2 = {
@@ -14834,7 +14834,7 @@ static const struct rtw89_rfe_parms rtw89_8851b_rfe_parms_type2 = {
.lmt = &rtw89_8851b_txpwr_lmt_5g_type2,
.lmt_ru = &rtw89_8851b_txpwr_lmt_ru_5g_type2,
},
- .tx_shape = &rtw89_8851b_tx_shape,
+ .tx_shape.lmt = &rtw89_8851b_tx_shape,
};
const struct rtw89_rfe_parms_conf rtw89_8851b_rfe_parms_conf[] = {
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852b.c b/drivers/net/wireless/realtek/rtw89/rtw8852b.c
index eec421e88697..3c1f5a9284dc 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8852b.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8852b.c
@@ -1692,8 +1692,8 @@ static void rtw8852b_set_tx_shape(struct rtw89_dev *rtwdev,
const struct rtw89_rfe_parms *rfe_parms = rtwdev->rfe_parms;
u8 band = chan->band_type;
u8 regd = rtw89_regd_get(rtwdev, band);
- u8 tx_shape_cck = (*rfe_parms->tx_shape)[band][RTW89_RS_CCK][regd];
- u8 tx_shape_ofdm = (*rfe_parms->tx_shape)[band][RTW89_RS_OFDM][regd];
+ u8 tx_shape_cck = (*rfe_parms->tx_shape.lmt)[band][RTW89_RS_CCK][regd];
+ u8 tx_shape_ofdm = (*rfe_parms->tx_shape.lmt)[band][RTW89_RS_OFDM][regd];
if (band == RTW89_BAND_2G)
rtw8852b_bb_set_tx_shape_dfir(rtwdev, chan, tx_shape_cck, phy_idx);
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852b_table.c b/drivers/net/wireless/realtek/rtw89/rtw8852b_table.c
index e319e216f5c4..8aa6b978cbbf 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8852b_table.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8852b_table.c
@@ -22892,5 +22892,5 @@ const struct rtw89_rfe_parms rtw89_8852b_dflt_parms = {
.lmt = &rtw89_8852b_txpwr_lmt_5g,
.lmt_ru = &rtw89_8852b_txpwr_lmt_ru_5g,
},
- .tx_shape = &rtw89_8852b_tx_shape,
+ .tx_shape.lmt = &rtw89_8852b_tx_shape,
};
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852c.c b/drivers/net/wireless/realtek/rtw89/rtw8852c.c
index aaed74135af2..2ec48fe3769f 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8852c.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8852c.c
@@ -1969,8 +1969,8 @@ static void rtw8852c_set_tx_shape(struct rtw89_dev *rtwdev,
const struct rtw89_rfe_parms *rfe_parms = rtwdev->rfe_parms;
u8 band = chan->band_type;
u8 regd = rtw89_regd_get(rtwdev, band);
- u8 tx_shape_cck = (*rfe_parms->tx_shape)[band][RTW89_RS_CCK][regd];
- u8 tx_shape_ofdm = (*rfe_parms->tx_shape)[band][RTW89_RS_OFDM][regd];
+ u8 tx_shape_cck = (*rfe_parms->tx_shape.lmt)[band][RTW89_RS_CCK][regd];
+ u8 tx_shape_ofdm = (*rfe_parms->tx_shape.lmt)[band][RTW89_RS_OFDM][regd];
if (band == RTW89_BAND_2G)
rtw8852c_bb_set_tx_shape_dfir(rtwdev, chan, tx_shape_cck, phy_idx);
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852c_table.c b/drivers/net/wireless/realtek/rtw89/rtw8852c_table.c
index c42aa8778c4d..0c3850c90712 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8852c_table.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8852c_table.c
@@ -56476,5 +56476,5 @@ const struct rtw89_rfe_parms rtw89_8852c_dflt_parms = {
.lmt = &rtw89_8852c_txpwr_lmt_6g,
.lmt_ru = &rtw89_8852c_txpwr_lmt_ru_6g,
},
- .tx_shape = &rtw89_8852c_tx_shape,
+ .tx_shape.lmt = &rtw89_8852c_tx_shape,
};
--
2.25.1
The subband index is a hardware value of relationship between primary
channel and bandwidth, and it is used by setting channel/bandwidth to
specify the primary channel.
Because this index is only needed when bandwidth >= 20 MHz, adjust
order of enumerator bandwidth to access offsets array easier. To prevent
misuse RTW89_CHANNEL_WIDTH_NUM as size, change it to
RTW89_CHANNEL_WIDTH_ORDINARY_NUM that will be the size of array. The
enumerator values of bandwidth (before ordinary number) will be also
used by upcoming TX power table built in firmware file, so add a comment
to remind keeping the order.
Signed-off-by: Ping-Ke Shih <[email protected]>
---
drivers/net/wireless/realtek/rtw89/chan.c | 15 +++++++++++++++
drivers/net/wireless/realtek/rtw89/core.h | 12 +++++++++---
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/chan.c b/drivers/net/wireless/realtek/rtw89/chan.c
index fb68d7f8ec3a..85c25213bf02 100644
--- a/drivers/net/wireless/realtek/rtw89/chan.c
+++ b/drivers/net/wireless/realtek/rtw89/chan.c
@@ -87,6 +87,19 @@ static enum rtw89_sc_offset rtw89_get_primary_chan_idx(enum rtw89_bandwidth bw,
return primary_chan_idx;
}
+static u8 rtw89_get_primary_sb_idx(u8 central_ch, u8 pri_ch,
+ enum rtw89_bandwidth bw)
+{
+ static const u8 prisb_cal_ofst[RTW89_CHANNEL_WIDTH_ORDINARY_NUM] = {
+ 0, 2, 6, 14, 30
+ };
+
+ if (bw >= RTW89_CHANNEL_WIDTH_ORDINARY_NUM)
+ return 0;
+
+ return (prisb_cal_ofst[bw] + pri_ch - central_ch) / 4;
+}
+
void rtw89_chan_create(struct rtw89_chan *chan, u8 center_chan, u8 primary_chan,
enum rtw89_band band, enum rtw89_bandwidth bandwidth)
{
@@ -106,6 +119,8 @@ void rtw89_chan_create(struct rtw89_chan *chan, u8 center_chan, u8 primary_chan,
chan->subband_type = rtw89_get_subband_type(band, center_chan);
chan->pri_ch_idx = rtw89_get_primary_chan_idx(bandwidth, center_freq,
primary_freq);
+ chan->pri_sb_idx = rtw89_get_primary_sb_idx(center_chan, primary_chan,
+ bandwidth);
}
bool rtw89_assign_entity_chan(struct rtw89_dev *rtwdev,
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 08fa83995e17..cafc1e09f4d6 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -841,9 +841,14 @@ enum rtw89_bandwidth {
RTW89_CHANNEL_WIDTH_40 = 1,
RTW89_CHANNEL_WIDTH_80 = 2,
RTW89_CHANNEL_WIDTH_160 = 3,
- RTW89_CHANNEL_WIDTH_80_80 = 4,
- RTW89_CHANNEL_WIDTH_5 = 5,
- RTW89_CHANNEL_WIDTH_10 = 6,
+ RTW89_CHANNEL_WIDTH_320 = 4,
+
+ /* keep index order above */
+ RTW89_CHANNEL_WIDTH_ORDINARY_NUM = 5,
+
+ RTW89_CHANNEL_WIDTH_80_80 = 5,
+ RTW89_CHANNEL_WIDTH_5 = 6,
+ RTW89_CHANNEL_WIDTH_10 = 7,
};
enum rtw89_ps_mode {
@@ -898,6 +903,7 @@ struct rtw89_chan {
u32 freq;
enum rtw89_subband subband_type;
enum rtw89_sc_offset pri_ch_idx;
+ u8 pri_sb_idx;
};
struct rtw89_chan_rcd {
--
2.25.1
From: Zong-Zhe Yang <[email protected]>
Originally, these helpers were implemented by macros. We rewrite them
by normal functions. In the new function to seek raw TX power by rate,
we access the array according to rate section and discard the original
pointer arithmetic.
Signed-off-by: Zong-Zhe Yang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
---
drivers/net/wireless/realtek/rtw89/core.h | 1 +
drivers/net/wireless/realtek/rtw89/phy.c | 77 ++++++++++++-----------
2 files changed, 43 insertions(+), 35 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 62b0cdecb0f7..71ed4d59ef53 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -718,6 +718,7 @@ struct rtw89_txpwr_byrate {
s8 mcs[RTW89_NSS_NUM][RTW89_RATE_MCS_NUM];
s8 hedcm[RTW89_NSS_HEDCM_NUM][RTW89_RATE_HEDCM_NUM];
s8 offset[RTW89_RATE_OFFSET_NUM];
+ s8 trap;
};
enum rtw89_bandwidth_section_num {
diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c
index d9f56c510eed..f86de8c8ce18 100644
--- a/drivers/net/wireless/realtek/rtw89/phy.c
+++ b/drivers/net/wireless/realtek/rtw89/phy.c
@@ -1535,68 +1535,75 @@ static const u8 rtw89_rs_nss_num[] = {
[RTW89_RS_OFFSET] = 1,
};
-static const u8 _byr_of_rs[] = {
- [RTW89_RS_CCK] = offsetof(struct rtw89_txpwr_byrate, cck),
- [RTW89_RS_OFDM] = offsetof(struct rtw89_txpwr_byrate, ofdm),
- [RTW89_RS_MCS] = offsetof(struct rtw89_txpwr_byrate, mcs),
- [RTW89_RS_HEDCM] = offsetof(struct rtw89_txpwr_byrate, hedcm),
- [RTW89_RS_OFFSET] = offsetof(struct rtw89_txpwr_byrate, offset),
-};
-
-#define _byr_seek(rs, raw) ((s8 *)(raw) + _byr_of_rs[rs])
-#define _byr_idx(rs, nss, idx) ((nss) * rtw89_rs_idx_num[rs] + (idx))
-#define _byr_chk(rs, nss, idx) \
- ((nss) < rtw89_rs_nss_num[rs] && (idx) < rtw89_rs_idx_num[rs])
+static
+s8 *rtw89_phy_raw_byr_seek(struct rtw89_dev *rtwdev,
+ struct rtw89_txpwr_byrate *head,
+ const struct rtw89_rate_desc *desc)
+{
+ switch (desc->rs) {
+ case RTW89_RS_CCK:
+ return &head->cck[desc->idx];
+ case RTW89_RS_OFDM:
+ return &head->ofdm[desc->idx];
+ case RTW89_RS_MCS:
+ return &head->mcs[desc->nss][desc->idx];
+ case RTW89_RS_HEDCM:
+ return &head->hedcm[desc->nss][desc->idx];
+ case RTW89_RS_OFFSET:
+ return &head->offset[desc->idx];
+ default:
+ rtw89_warn(rtwdev, "unrecognized byr rs: %d\n", desc->rs);
+ return &head->trap;
+ }
+}
void rtw89_phy_load_txpwr_byrate(struct rtw89_dev *rtwdev,
const struct rtw89_txpwr_table *tbl)
{
const struct rtw89_txpwr_byrate_cfg *cfg = tbl->data;
const struct rtw89_txpwr_byrate_cfg *end = cfg + tbl->size;
+ struct rtw89_txpwr_byrate *byr_head;
+ struct rtw89_rate_desc desc = {};
s8 *byr;
u32 data;
- u8 i, idx;
+ u8 i;
for (; cfg < end; cfg++) {
- byr = _byr_seek(cfg->rs, &rtwdev->byr[cfg->band]);
+ byr_head = &rtwdev->byr[cfg->band];
+ desc.rs = cfg->rs;
+ desc.nss = cfg->nss;
data = cfg->data;
for (i = 0; i < cfg->len; i++, data >>= 8) {
- idx = _byr_idx(cfg->rs, cfg->nss, (cfg->shf + i));
- byr[idx] = (s8)(data & 0xff);
+ desc.idx = cfg->shf + i;
+ byr = rtw89_phy_raw_byr_seek(rtwdev, byr_head, &desc);
+ *byr = data & 0xff;
}
}
}
EXPORT_SYMBOL(rtw89_phy_load_txpwr_byrate);
-#define _phy_txpwr_rf_to_mac(rtwdev, txpwr_rf) \
-({ \
- const struct rtw89_chip_info *__c = (rtwdev)->chip; \
- (txpwr_rf) >> (__c->txpwr_factor_rf - __c->txpwr_factor_mac); \
-})
+static s8 rtw89_phy_txpwr_rf_to_mac(struct rtw89_dev *rtwdev, s8 txpwr_rf)
+{
+ const struct rtw89_chip_info *chip = rtwdev->chip;
+
+ return txpwr_rf >> (chip->txpwr_factor_rf - chip->txpwr_factor_mac);
+}
static
s8 rtw89_phy_read_txpwr_byrate(struct rtw89_dev *rtwdev, u8 band,
const struct rtw89_rate_desc *rate_desc)
{
+ struct rtw89_txpwr_byrate *byr_head;
s8 *byr;
- u8 idx;
if (rate_desc->rs == RTW89_RS_CCK)
band = RTW89_BAND_2G;
- if (!_byr_chk(rate_desc->rs, rate_desc->nss, rate_desc->idx)) {
- rtw89_debug(rtwdev, RTW89_DBG_TXPWR,
- "[TXPWR] unknown byrate desc rs=%d nss=%d idx=%d\n",
- rate_desc->rs, rate_desc->nss, rate_desc->idx);
-
- return 0;
- }
-
- byr = _byr_seek(rate_desc->rs, &rtwdev->byr[band]);
- idx = _byr_idx(rate_desc->rs, rate_desc->nss, rate_desc->idx);
+ byr_head = &rtwdev->byr[band];
+ byr = rtw89_phy_raw_byr_seek(rtwdev, byr_head, rate_desc);
- return _phy_txpwr_rf_to_mac(rtwdev, byr[idx]);
+ return rtw89_phy_txpwr_rf_to_mac(rtwdev, *byr);
}
static u8 rtw89_channel_6g_to_idx(struct rtw89_dev *rtwdev, u8 channel_6g)
@@ -1688,7 +1695,7 @@ s8 rtw89_phy_read_txpwr_limit(struct rtw89_dev *rtwdev, u8 band,
return 0;
}
- lmt = _phy_txpwr_rf_to_mac(rtwdev, lmt);
+ lmt = rtw89_phy_txpwr_rf_to_mac(rtwdev, lmt);
sar = rtw89_query_sar(rtwdev, freq);
return min(lmt, sar);
@@ -1945,7 +1952,7 @@ static s8 rtw89_phy_read_txpwr_limit_ru(struct rtw89_dev *rtwdev, u8 band,
return 0;
}
- lmt_ru = _phy_txpwr_rf_to_mac(rtwdev, lmt_ru);
+ lmt_ru = rtw89_phy_txpwr_rf_to_mac(rtwdev, lmt_ru);
sar = rtw89_query_sar(rtwdev, freq);
return min(lmt_ru, sar);
--
2.25.1
From: Zong-Zhe Yang <[email protected]>
Table of TX power by rate only needs to be loaded once. But, we originally
loaded it every time we start core. Now, we load it one time along as RFE
(RF Front End) parameters are determined.
Signed-off-by: Zong-Zhe Yang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
---
drivers/net/wireless/realtek/rtw89/core.c | 14 ++++++++++----
drivers/net/wireless/realtek/rtw89/phy.c | 3 ---
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 362aa0922339..f9467adf0a14 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -4008,21 +4008,27 @@ static void rtw89_core_setup_rfe_parms(struct rtw89_dev *rtwdev)
const struct rtw89_chip_info *chip = rtwdev->chip;
const struct rtw89_rfe_parms_conf *conf = chip->rfe_parms_conf;
struct rtw89_efuse *efuse = &rtwdev->efuse;
+ const struct rtw89_rfe_parms *sel;
u8 rfe_type = efuse->rfe_type;
- if (!conf)
+ if (!conf) {
+ sel = chip->dflt_parms;
goto out;
+ }
while (conf->rfe_parms) {
if (rfe_type == conf->rfe_type) {
- rtwdev->rfe_parms = conf->rfe_parms;
- return;
+ sel = conf->rfe_parms;
+ goto out;
}
conf++;
}
+ sel = chip->dflt_parms;
+
out:
- rtwdev->rfe_parms = chip->dflt_parms;
+ rtwdev->rfe_parms = sel;
+ rtw89_load_txpwr_table(rtwdev, sel->byr_tbl);
}
static int rtw89_chip_efuse_info_setup(struct rtw89_dev *rtwdev)
diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c
index f86de8c8ce18..f9f203295ee4 100644
--- a/drivers/net/wireless/realtek/rtw89/phy.c
+++ b/drivers/net/wireless/realtek/rtw89/phy.c
@@ -4481,8 +4481,6 @@ static void rtw89_phy_env_monitor_init(struct rtw89_dev *rtwdev)
void rtw89_phy_dm_init(struct rtw89_dev *rtwdev)
{
- const struct rtw89_rfe_parms *rfe_parms = rtwdev->rfe_parms;
-
rtw89_phy_stat_init(rtwdev);
rtw89_chip_bb_sethw(rtwdev);
@@ -4498,7 +4496,6 @@ void rtw89_phy_dm_init(struct rtw89_dev *rtwdev)
rtw89_phy_init_rf_nctl(rtwdev);
rtw89_chip_rfk_init(rtwdev);
- rtw89_load_txpwr_table(rtwdev, rfe_parms->byr_tbl);
rtw89_chip_set_txpwr_ctrl(rtwdev);
rtw89_chip_power_trim(rtwdev);
rtw89_chip_cfg_txrx_path(rtwdev);
--
2.25.1
From: Zong-Zhe Yang <[email protected]>
The following FW elements are recognized, and then the valid entries
in them are loaded into SW struct case by case.
* TX power by rate
* TX power limit 2 GHz
* TX power limit 5 GHz
* TX power limit 6 GHz
* TX power limit RU 2 GHz
* TX power limit RU 5 GHz
* TX power limit RU 6 GHz
* TX shape limit
* TX shape limit RU
One single firmware file can contain multiples of each of the above FW
elements. Each of them is configured with a target RFE (RF front end)
type. We choose one of the multiples to load based on RFE type. If there
are multiples of the same FW elements with the same target RFE type. The
last one will be applied.
We don't want to have many loading variants for above FW elements. Even if
between different chips or between different generations, we would like to
maintain only one single set of loadings. So, the loadings are designed to
consider compatibility. The main concepts are listed below.
* The driver structures, which are used to cast binary entry from FW,
cannot insert new members in the middle. If there are something new,
they should always be appended at the tail.
* Each binary entry from FW uses a dictionary way containing a key set
and a data. The keys in the key set indicate where to put the data.
* If size of driver struct and size of binary entry do not match when
loading, it means the number of keys in the key set are different.
Then, we deal with compatibility. No matter which one has more keys,
we take/use zero on those mismatched keys.
If driver struct is bigger (backward compatibility):
e.g. SW uses two keys, but FW is built with one key.
Then, put the data of FW(keyX) into SW[keyX][0].
If binary entry is bigger (forward compatibility):
e.g. FW is built with two keys, but SW uses one key.
Then, only take the data of FW(keyX, keyY = 0) into SW[keyX]
Besides, chip info setup flow is tweaked a bit for the following.
* Before loading FW elements, we need to determine chip RFE via efuse.
* Setting up RFE parameters depends on loading FW elements ahead.
Signed-off-by: Zong-Zhe Yang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
---
drivers/net/wireless/realtek/rtw89/core.c | 15 +-
drivers/net/wireless/realtek/rtw89/core.h | 90 ++++
drivers/net/wireless/realtek/rtw89/fw.c | 530 ++++++++++++++++++++++
drivers/net/wireless/realtek/rtw89/fw.h | 130 ++++++
drivers/net/wireless/realtek/rtw89/phy.c | 1 -
drivers/net/wireless/realtek/rtw89/phy.h | 3 +
6 files changed, 761 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index f9467adf0a14..03704c4752a5 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -4027,8 +4027,8 @@ static void rtw89_core_setup_rfe_parms(struct rtw89_dev *rtwdev)
sel = chip->dflt_parms;
out:
- rtwdev->rfe_parms = sel;
- rtw89_load_txpwr_table(rtwdev, sel->byr_tbl);
+ rtwdev->rfe_parms = rtw89_load_rfe_data_from_fw(rtwdev, sel);
+ rtw89_load_txpwr_table(rtwdev, rtwdev->rfe_parms->byr_tbl);
}
static int rtw89_chip_efuse_info_setup(struct rtw89_dev *rtwdev)
@@ -4052,7 +4052,6 @@ static int rtw89_chip_efuse_info_setup(struct rtw89_dev *rtwdev)
return ret;
rtw89_core_setup_phycap(rtwdev);
- rtw89_core_setup_rfe_parms(rtwdev);
rtw89_mac_pwr_off(rtwdev);
@@ -4084,20 +4083,21 @@ int rtw89_chip_info_setup(struct rtw89_dev *rtwdev)
return ret;
}
+ ret = rtw89_chip_efuse_info_setup(rtwdev);
+ if (ret)
+ return ret;
+
ret = rtw89_fw_recognize_elements(rtwdev);
if (ret) {
rtw89_err(rtwdev, "failed to recognize firmware elements\n");
return ret;
}
- ret = rtw89_chip_efuse_info_setup(rtwdev);
- if (ret)
- return ret;
-
ret = rtw89_chip_board_info_setup(rtwdev);
if (ret)
return ret;
+ rtw89_core_setup_rfe_parms(rtwdev);
rtwdev->ps_mode = rtw89_update_ps_mode(rtwdev);
return 0;
@@ -4309,6 +4309,7 @@ EXPORT_SYMBOL(rtw89_alloc_ieee80211_hw);
void rtw89_free_ieee80211_hw(struct rtw89_dev *rtwdev)
{
kfree(rtwdev->ops);
+ kfree(rtwdev->rfe_data);
release_firmware(rtwdev->fw.req.firmware);
ieee80211_free_hw(rtwdev->hw);
}
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 4ab7abfa8b1f..ac09785c21a6 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -3400,6 +3400,95 @@ struct rtw89_rfe_parms_conf {
u8 rfe_type;
};
+#define RTW89_TXPWR_CONF_DFLT_RFE_TYPE 0x0
+
+struct rtw89_txpwr_conf {
+ u8 rfe_type;
+ u8 ent_sz;
+ u32 num_ents;
+ const void *data;
+};
+
+#define rtw89_txpwr_conf_valid(conf) (!!(conf)->data)
+
+#define rtw89_for_each_in_txpwr_conf(entry, cursor, conf) \
+ for (typecheck(const void *, cursor), (cursor) = (conf)->data, \
+ memcpy(&(entry), cursor, \
+ min_t(u8, sizeof(entry), (conf)->ent_sz)); \
+ (cursor) < (conf)->data + (conf)->num_ents * (conf)->ent_sz; \
+ (cursor) += (conf)->ent_sz, \
+ memcpy(&(entry), cursor, \
+ min_t(u8, sizeof(entry), (conf)->ent_sz)))
+
+struct rtw89_txpwr_byrate_data {
+ struct rtw89_txpwr_conf conf;
+ struct rtw89_txpwr_table tbl;
+};
+
+struct rtw89_txpwr_lmt_2ghz_data {
+ struct rtw89_txpwr_conf conf;
+ s8 v[RTW89_2G_BW_NUM][RTW89_NTX_NUM]
+ [RTW89_RS_LMT_NUM][RTW89_BF_NUM]
+ [RTW89_REGD_NUM][RTW89_2G_CH_NUM];
+};
+
+struct rtw89_txpwr_lmt_5ghz_data {
+ struct rtw89_txpwr_conf conf;
+ s8 v[RTW89_5G_BW_NUM][RTW89_NTX_NUM]
+ [RTW89_RS_LMT_NUM][RTW89_BF_NUM]
+ [RTW89_REGD_NUM][RTW89_5G_CH_NUM];
+};
+
+struct rtw89_txpwr_lmt_6ghz_data {
+ struct rtw89_txpwr_conf conf;
+ s8 v[RTW89_6G_BW_NUM][RTW89_NTX_NUM]
+ [RTW89_RS_LMT_NUM][RTW89_BF_NUM]
+ [RTW89_REGD_NUM][NUM_OF_RTW89_REG_6GHZ_POWER]
+ [RTW89_6G_CH_NUM];
+};
+
+struct rtw89_txpwr_lmt_ru_2ghz_data {
+ struct rtw89_txpwr_conf conf;
+ s8 v[RTW89_RU_NUM][RTW89_NTX_NUM]
+ [RTW89_REGD_NUM][RTW89_2G_CH_NUM];
+};
+
+struct rtw89_txpwr_lmt_ru_5ghz_data {
+ struct rtw89_txpwr_conf conf;
+ s8 v[RTW89_RU_NUM][RTW89_NTX_NUM]
+ [RTW89_REGD_NUM][RTW89_5G_CH_NUM];
+};
+
+struct rtw89_txpwr_lmt_ru_6ghz_data {
+ struct rtw89_txpwr_conf conf;
+ s8 v[RTW89_RU_NUM][RTW89_NTX_NUM]
+ [RTW89_REGD_NUM][NUM_OF_RTW89_REG_6GHZ_POWER]
+ [RTW89_6G_CH_NUM];
+};
+
+struct rtw89_tx_shape_lmt_data {
+ struct rtw89_txpwr_conf conf;
+ u8 v[RTW89_BAND_NUM][RTW89_RS_TX_SHAPE_NUM][RTW89_REGD_NUM];
+};
+
+struct rtw89_tx_shape_lmt_ru_data {
+ struct rtw89_txpwr_conf conf;
+ u8 v[RTW89_BAND_NUM][RTW89_REGD_NUM];
+};
+
+struct rtw89_rfe_data {
+ struct rtw89_txpwr_byrate_data byrate;
+ struct rtw89_txpwr_lmt_2ghz_data lmt_2ghz;
+ struct rtw89_txpwr_lmt_5ghz_data lmt_5ghz;
+ struct rtw89_txpwr_lmt_6ghz_data lmt_6ghz;
+ struct rtw89_txpwr_lmt_ru_2ghz_data lmt_ru_2ghz;
+ struct rtw89_txpwr_lmt_ru_5ghz_data lmt_ru_5ghz;
+ struct rtw89_txpwr_lmt_ru_6ghz_data lmt_ru_6ghz;
+ struct rtw89_tx_shape_lmt_data tx_shape_lmt;
+ struct rtw89_tx_shape_lmt_ru_data tx_shape_lmt_ru;
+ struct rtw89_rfe_parms rfe_parms;
+};
+
struct rtw89_page_regs {
u32 hci_fc_ctrl;
u32 ch_page_ctrl;
@@ -4582,6 +4671,7 @@ struct rtw89_dev {
struct rtw89_hci_info hci;
struct rtw89_efuse efuse;
struct rtw89_traffic_stats stats;
+ struct rtw89_rfe_data *rfe_data;
/* ensures exclusive access from mac80211 callbacks */
struct mutex mutex;
diff --git a/drivers/net/wireless/realtek/rtw89/fw.c b/drivers/net/wireless/realtek/rtw89/fw.c
index 0f6ac26870b5..f5e7475af381 100644
--- a/drivers/net/wireless/realtek/rtw89/fw.c
+++ b/drivers/net/wireless/realtek/rtw89/fw.c
@@ -601,6 +601,49 @@ int rtw89_build_phy_tbl_from_elm(struct rtw89_dev *rtwdev,
return -ENOMEM;
}
+static
+int rtw89_fw_recognize_txpwr_from_elm(struct rtw89_dev *rtwdev,
+ const struct rtw89_fw_element_hdr *elm,
+ const void *data)
+{
+ const struct __rtw89_fw_txpwr_element *txpwr_elm = &elm->u.txpwr;
+ const unsigned long offset = (const unsigned long)data;
+ struct rtw89_efuse *efuse = &rtwdev->efuse;
+ struct rtw89_txpwr_conf *conf;
+
+ if (!rtwdev->rfe_data) {
+ rtwdev->rfe_data = kzalloc(sizeof(*rtwdev->rfe_data), GFP_KERNEL);
+ if (!rtwdev->rfe_data)
+ return -ENOMEM;
+ }
+
+ conf = (void *)rtwdev->rfe_data + offset;
+
+ /* if multiple matched, take the last eventually */
+ if (txpwr_elm->rfe_type == efuse->rfe_type)
+ goto setup;
+
+ /* without one is matched, accept default */
+ if (txpwr_elm->rfe_type == RTW89_TXPWR_CONF_DFLT_RFE_TYPE &&
+ (!rtw89_txpwr_conf_valid(conf) ||
+ conf->rfe_type == RTW89_TXPWR_CONF_DFLT_RFE_TYPE))
+ goto setup;
+
+ rtw89_debug(rtwdev, RTW89_DBG_FW, "skip txpwr element ID %u RFE %u\n",
+ elm->id, txpwr_elm->rfe_type);
+ return 0;
+
+setup:
+ rtw89_debug(rtwdev, RTW89_DBG_FW, "take txpwr element ID %u RFE %u\n",
+ elm->id, txpwr_elm->rfe_type);
+
+ conf->rfe_type = txpwr_elm->rfe_type;
+ conf->ent_sz = txpwr_elm->ent_sz;
+ conf->num_ents = le32_to_cpu(txpwr_elm->num_ents);
+ conf->data = txpwr_elm->content;
+ return 0;
+}
+
struct rtw89_fw_element_handler {
int (*fn)(struct rtw89_dev *rtwdev,
const struct rtw89_fw_element_hdr *elm, const void *data);
@@ -624,6 +667,42 @@ static const struct rtw89_fw_element_handler __fw_element_handlers[] = {
[RTW89_FW_ELEMENT_ID_RADIO_D] = {rtw89_build_phy_tbl_from_elm,
(const void *)RF_PATH_D, NULL},
[RTW89_FW_ELEMENT_ID_RF_NCTL] = {rtw89_build_phy_tbl_from_elm, NULL, "NCTL"},
+ [RTW89_FW_ELEMENT_ID_TXPWR_BYRATE] = {
+ rtw89_fw_recognize_txpwr_from_elm,
+ (const void *)offsetof(struct rtw89_rfe_data, byrate.conf), "TXPWR",
+ },
+ [RTW89_FW_ELEMENT_ID_TXPWR_LMT_2GHZ] = {
+ rtw89_fw_recognize_txpwr_from_elm,
+ (const void *)offsetof(struct rtw89_rfe_data, lmt_2ghz.conf), NULL,
+ },
+ [RTW89_FW_ELEMENT_ID_TXPWR_LMT_5GHZ] = {
+ rtw89_fw_recognize_txpwr_from_elm,
+ (const void *)offsetof(struct rtw89_rfe_data, lmt_5ghz.conf), NULL,
+ },
+ [RTW89_FW_ELEMENT_ID_TXPWR_LMT_6GHZ] = {
+ rtw89_fw_recognize_txpwr_from_elm,
+ (const void *)offsetof(struct rtw89_rfe_data, lmt_6ghz.conf), NULL,
+ },
+ [RTW89_FW_ELEMENT_ID_TXPWR_LMT_RU_2GHZ] = {
+ rtw89_fw_recognize_txpwr_from_elm,
+ (const void *)offsetof(struct rtw89_rfe_data, lmt_ru_2ghz.conf), NULL,
+ },
+ [RTW89_FW_ELEMENT_ID_TXPWR_LMT_RU_5GHZ] = {
+ rtw89_fw_recognize_txpwr_from_elm,
+ (const void *)offsetof(struct rtw89_rfe_data, lmt_ru_5ghz.conf), NULL,
+ },
+ [RTW89_FW_ELEMENT_ID_TXPWR_LMT_RU_6GHZ] = {
+ rtw89_fw_recognize_txpwr_from_elm,
+ (const void *)offsetof(struct rtw89_rfe_data, lmt_ru_6ghz.conf), NULL,
+ },
+ [RTW89_FW_ELEMENT_ID_TX_SHAPE_LMT] = {
+ rtw89_fw_recognize_txpwr_from_elm,
+ (const void *)offsetof(struct rtw89_rfe_data, tx_shape_lmt.conf), NULL,
+ },
+ [RTW89_FW_ELEMENT_ID_TX_SHAPE_LMT_RU] = {
+ rtw89_fw_recognize_txpwr_from_elm,
+ (const void *)offsetof(struct rtw89_rfe_data, tx_shape_lmt_ru.conf), NULL,
+ },
};
int rtw89_fw_recognize_elements(struct rtw89_dev *rtwdev)
@@ -4666,3 +4745,454 @@ int rtw89_fw_h2c_mcc_set_duration(struct rtw89_dev *rtwdev,
cond = RTW89_MCC_WAIT_COND(p->group, H2C_FUNC_MCC_SET_DURATION);
return rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond);
}
+
+static bool __fw_txpwr_entry_zero_ext(const void *ext_ptr, u8 ext_len)
+{
+ static const u8 zeros[U8_MAX] = {};
+
+ return memcmp(ext_ptr, zeros, ext_len) == 0;
+}
+
+#define __fw_txpwr_entry_acceptable(e, cursor, ent_sz) \
+({ \
+ u8 __var_sz = sizeof(*(e)); \
+ bool __accept; \
+ if (__var_sz >= (ent_sz)) \
+ __accept = true; \
+ else \
+ __accept = __fw_txpwr_entry_zero_ext((cursor) + __var_sz,\
+ (ent_sz) - __var_sz);\
+ __accept; \
+})
+
+static bool
+fw_txpwr_byrate_entry_valid(const struct rtw89_fw_txpwr_byrate_entry *e,
+ const void *cursor,
+ const struct rtw89_txpwr_conf *conf)
+{
+ if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz))
+ return false;
+
+ if (e->band >= RTW89_BAND_NUM || e->bw >= RTW89_BYR_BW_NUM)
+ return false;
+
+ switch (e->rs) {
+ case RTW89_RS_CCK:
+ if (e->shf + e->len > RTW89_RATE_CCK_NUM)
+ return false;
+ break;
+ case RTW89_RS_OFDM:
+ if (e->shf + e->len > RTW89_RATE_OFDM_NUM)
+ return false;
+ break;
+ case RTW89_RS_MCS:
+ if (e->shf + e->len > __RTW89_RATE_MCS_NUM ||
+ e->nss >= RTW89_NSS_NUM ||
+ e->ofdma >= RTW89_OFDMA_NUM)
+ return false;
+ break;
+ case RTW89_RS_HEDCM:
+ if (e->shf + e->len > RTW89_RATE_HEDCM_NUM ||
+ e->nss >= RTW89_NSS_HEDCM_NUM ||
+ e->ofdma >= RTW89_OFDMA_NUM)
+ return false;
+ break;
+ case RTW89_RS_OFFSET:
+ if (e->shf + e->len > __RTW89_RATE_OFFSET_NUM)
+ return false;
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+static
+void rtw89_fw_load_txpwr_byrate(struct rtw89_dev *rtwdev,
+ const struct rtw89_txpwr_table *tbl)
+{
+ const struct rtw89_txpwr_conf *conf = tbl->data;
+ struct rtw89_fw_txpwr_byrate_entry entry = {};
+ struct rtw89_txpwr_byrate *byr_head;
+ struct rtw89_rate_desc desc = {};
+ const void *cursor;
+ u32 data;
+ s8 *byr;
+ int i;
+
+ rtw89_for_each_in_txpwr_conf(entry, cursor, conf) {
+ if (!fw_txpwr_byrate_entry_valid(&entry, cursor, conf))
+ continue;
+
+ byr_head = &rtwdev->byr[entry.band][entry.bw];
+ data = le32_to_cpu(entry.data);
+ desc.ofdma = entry.ofdma;
+ desc.nss = entry.nss;
+ desc.rs = entry.rs;
+
+ for (i = 0; i < entry.len; i++, data >>= 8) {
+ desc.idx = entry.shf + i;
+ byr = rtw89_phy_raw_byr_seek(rtwdev, byr_head, &desc);
+ *byr = data & 0xff;
+ }
+ }
+}
+
+static bool
+fw_txpwr_lmt_2ghz_entry_valid(const struct rtw89_fw_txpwr_lmt_2ghz_entry *e,
+ const void *cursor,
+ const struct rtw89_txpwr_conf *conf)
+{
+ if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz))
+ return false;
+
+ if (e->bw >= RTW89_2G_BW_NUM)
+ return false;
+ if (e->nt >= RTW89_NTX_NUM)
+ return false;
+ if (e->rs >= RTW89_RS_LMT_NUM)
+ return false;
+ if (e->bf >= RTW89_BF_NUM)
+ return false;
+ if (e->regd >= RTW89_REGD_NUM)
+ return false;
+ if (e->ch_idx >= RTW89_2G_CH_NUM)
+ return false;
+
+ return true;
+}
+
+static
+void rtw89_fw_load_txpwr_lmt_2ghz(struct rtw89_txpwr_lmt_2ghz_data *data)
+{
+ const struct rtw89_txpwr_conf *conf = &data->conf;
+ struct rtw89_fw_txpwr_lmt_2ghz_entry entry = {};
+ const void *cursor;
+
+ rtw89_for_each_in_txpwr_conf(entry, cursor, conf) {
+ if (!fw_txpwr_lmt_2ghz_entry_valid(&entry, cursor, conf))
+ continue;
+
+ data->v[entry.bw][entry.nt][entry.rs][entry.bf][entry.regd]
+ [entry.ch_idx] = entry.v;
+ }
+}
+
+static bool
+fw_txpwr_lmt_5ghz_entry_valid(const struct rtw89_fw_txpwr_lmt_5ghz_entry *e,
+ const void *cursor,
+ const struct rtw89_txpwr_conf *conf)
+{
+ if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz))
+ return false;
+
+ if (e->bw >= RTW89_5G_BW_NUM)
+ return false;
+ if (e->nt >= RTW89_NTX_NUM)
+ return false;
+ if (e->rs >= RTW89_RS_LMT_NUM)
+ return false;
+ if (e->bf >= RTW89_BF_NUM)
+ return false;
+ if (e->regd >= RTW89_REGD_NUM)
+ return false;
+ if (e->ch_idx >= RTW89_5G_CH_NUM)
+ return false;
+
+ return true;
+}
+
+static
+void rtw89_fw_load_txpwr_lmt_5ghz(struct rtw89_txpwr_lmt_5ghz_data *data)
+{
+ const struct rtw89_txpwr_conf *conf = &data->conf;
+ struct rtw89_fw_txpwr_lmt_5ghz_entry entry = {};
+ const void *cursor;
+
+ rtw89_for_each_in_txpwr_conf(entry, cursor, conf) {
+ if (!fw_txpwr_lmt_5ghz_entry_valid(&entry, cursor, conf))
+ continue;
+
+ data->v[entry.bw][entry.nt][entry.rs][entry.bf][entry.regd]
+ [entry.ch_idx] = entry.v;
+ }
+}
+
+static bool
+fw_txpwr_lmt_6ghz_entry_valid(const struct rtw89_fw_txpwr_lmt_6ghz_entry *e,
+ const void *cursor,
+ const struct rtw89_txpwr_conf *conf)
+{
+ if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz))
+ return false;
+
+ if (e->bw >= RTW89_6G_BW_NUM)
+ return false;
+ if (e->nt >= RTW89_NTX_NUM)
+ return false;
+ if (e->rs >= RTW89_RS_LMT_NUM)
+ return false;
+ if (e->bf >= RTW89_BF_NUM)
+ return false;
+ if (e->regd >= RTW89_REGD_NUM)
+ return false;
+ if (e->reg_6ghz_power >= NUM_OF_RTW89_REG_6GHZ_POWER)
+ return false;
+ if (e->ch_idx >= RTW89_6G_CH_NUM)
+ return false;
+
+ return true;
+}
+
+static
+void rtw89_fw_load_txpwr_lmt_6ghz(struct rtw89_txpwr_lmt_6ghz_data *data)
+{
+ const struct rtw89_txpwr_conf *conf = &data->conf;
+ struct rtw89_fw_txpwr_lmt_6ghz_entry entry = {};
+ const void *cursor;
+
+ rtw89_for_each_in_txpwr_conf(entry, cursor, conf) {
+ if (!fw_txpwr_lmt_6ghz_entry_valid(&entry, cursor, conf))
+ continue;
+
+ data->v[entry.bw][entry.nt][entry.rs][entry.bf][entry.regd]
+ [entry.reg_6ghz_power][entry.ch_idx] = entry.v;
+ }
+}
+
+static bool
+fw_txpwr_lmt_ru_2ghz_entry_valid(const struct rtw89_fw_txpwr_lmt_ru_2ghz_entry *e,
+ const void *cursor,
+ const struct rtw89_txpwr_conf *conf)
+{
+ if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz))
+ return false;
+
+ if (e->ru >= RTW89_RU_NUM)
+ return false;
+ if (e->nt >= RTW89_NTX_NUM)
+ return false;
+ if (e->regd >= RTW89_REGD_NUM)
+ return false;
+ if (e->ch_idx >= RTW89_2G_CH_NUM)
+ return false;
+
+ return true;
+}
+
+static
+void rtw89_fw_load_txpwr_lmt_ru_2ghz(struct rtw89_txpwr_lmt_ru_2ghz_data *data)
+{
+ const struct rtw89_txpwr_conf *conf = &data->conf;
+ struct rtw89_fw_txpwr_lmt_ru_2ghz_entry entry = {};
+ const void *cursor;
+
+ rtw89_for_each_in_txpwr_conf(entry, cursor, conf) {
+ if (!fw_txpwr_lmt_ru_2ghz_entry_valid(&entry, cursor, conf))
+ continue;
+
+ data->v[entry.ru][entry.nt][entry.regd][entry.ch_idx] = entry.v;
+ }
+}
+
+static bool
+fw_txpwr_lmt_ru_5ghz_entry_valid(const struct rtw89_fw_txpwr_lmt_ru_5ghz_entry *e,
+ const void *cursor,
+ const struct rtw89_txpwr_conf *conf)
+{
+ if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz))
+ return false;
+
+ if (e->ru >= RTW89_RU_NUM)
+ return false;
+ if (e->nt >= RTW89_NTX_NUM)
+ return false;
+ if (e->regd >= RTW89_REGD_NUM)
+ return false;
+ if (e->ch_idx >= RTW89_5G_CH_NUM)
+ return false;
+
+ return true;
+}
+
+static
+void rtw89_fw_load_txpwr_lmt_ru_5ghz(struct rtw89_txpwr_lmt_ru_5ghz_data *data)
+{
+ const struct rtw89_txpwr_conf *conf = &data->conf;
+ struct rtw89_fw_txpwr_lmt_ru_5ghz_entry entry = {};
+ const void *cursor;
+
+ rtw89_for_each_in_txpwr_conf(entry, cursor, conf) {
+ if (!fw_txpwr_lmt_ru_5ghz_entry_valid(&entry, cursor, conf))
+ continue;
+
+ data->v[entry.ru][entry.nt][entry.regd][entry.ch_idx] = entry.v;
+ }
+}
+
+static bool
+fw_txpwr_lmt_ru_6ghz_entry_valid(const struct rtw89_fw_txpwr_lmt_ru_6ghz_entry *e,
+ const void *cursor,
+ const struct rtw89_txpwr_conf *conf)
+{
+ if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz))
+ return false;
+
+ if (e->ru >= RTW89_RU_NUM)
+ return false;
+ if (e->nt >= RTW89_NTX_NUM)
+ return false;
+ if (e->regd >= RTW89_REGD_NUM)
+ return false;
+ if (e->reg_6ghz_power >= NUM_OF_RTW89_REG_6GHZ_POWER)
+ return false;
+ if (e->ch_idx >= RTW89_6G_CH_NUM)
+ return false;
+
+ return true;
+}
+
+static
+void rtw89_fw_load_txpwr_lmt_ru_6ghz(struct rtw89_txpwr_lmt_ru_6ghz_data *data)
+{
+ const struct rtw89_txpwr_conf *conf = &data->conf;
+ struct rtw89_fw_txpwr_lmt_ru_6ghz_entry entry = {};
+ const void *cursor;
+
+ rtw89_for_each_in_txpwr_conf(entry, cursor, conf) {
+ if (!fw_txpwr_lmt_ru_6ghz_entry_valid(&entry, cursor, conf))
+ continue;
+
+ data->v[entry.ru][entry.nt][entry.regd][entry.reg_6ghz_power]
+ [entry.ch_idx] = entry.v;
+ }
+}
+
+static bool
+fw_tx_shape_lmt_entry_valid(const struct rtw89_fw_tx_shape_lmt_entry *e,
+ const void *cursor,
+ const struct rtw89_txpwr_conf *conf)
+{
+ if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz))
+ return false;
+
+ if (e->band >= RTW89_BAND_NUM)
+ return false;
+ if (e->tx_shape_rs >= RTW89_RS_TX_SHAPE_NUM)
+ return false;
+ if (e->regd >= RTW89_REGD_NUM)
+ return false;
+
+ return true;
+}
+
+static
+void rtw89_fw_load_tx_shape_lmt(struct rtw89_tx_shape_lmt_data *data)
+{
+ const struct rtw89_txpwr_conf *conf = &data->conf;
+ struct rtw89_fw_tx_shape_lmt_entry entry = {};
+ const void *cursor;
+
+ rtw89_for_each_in_txpwr_conf(entry, cursor, conf) {
+ if (!fw_tx_shape_lmt_entry_valid(&entry, cursor, conf))
+ continue;
+
+ data->v[entry.band][entry.tx_shape_rs][entry.regd] = entry.v;
+ }
+}
+
+static bool
+fw_tx_shape_lmt_ru_entry_valid(const struct rtw89_fw_tx_shape_lmt_ru_entry *e,
+ const void *cursor,
+ const struct rtw89_txpwr_conf *conf)
+{
+ if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz))
+ return false;
+
+ if (e->band >= RTW89_BAND_NUM)
+ return false;
+ if (e->regd >= RTW89_REGD_NUM)
+ return false;
+
+ return true;
+}
+
+static
+void rtw89_fw_load_tx_shape_lmt_ru(struct rtw89_tx_shape_lmt_ru_data *data)
+{
+ const struct rtw89_txpwr_conf *conf = &data->conf;
+ struct rtw89_fw_tx_shape_lmt_ru_entry entry = {};
+ const void *cursor;
+
+ rtw89_for_each_in_txpwr_conf(entry, cursor, conf) {
+ if (!fw_tx_shape_lmt_ru_entry_valid(&entry, cursor, conf))
+ continue;
+
+ data->v[entry.band][entry.regd] = entry.v;
+ }
+}
+
+const struct rtw89_rfe_parms *
+rtw89_load_rfe_data_from_fw(struct rtw89_dev *rtwdev,
+ const struct rtw89_rfe_parms *init)
+{
+ struct rtw89_rfe_data *rfe_data = rtwdev->rfe_data;
+ struct rtw89_rfe_parms *parms;
+
+ if (!rfe_data)
+ return init;
+
+ parms = &rfe_data->rfe_parms;
+ if (init)
+ *parms = *init;
+
+ if (rtw89_txpwr_conf_valid(&rfe_data->byrate.conf)) {
+ rfe_data->byrate.tbl.data = &rfe_data->byrate.conf;
+ rfe_data->byrate.tbl.size = 0; /* don't care here */
+ rfe_data->byrate.tbl.load = rtw89_fw_load_txpwr_byrate;
+ parms->byr_tbl = &rfe_data->byrate.tbl;
+ }
+
+ if (rtw89_txpwr_conf_valid(&rfe_data->lmt_2ghz.conf)) {
+ rtw89_fw_load_txpwr_lmt_2ghz(&rfe_data->lmt_2ghz);
+ parms->rule_2ghz.lmt = &rfe_data->lmt_2ghz.v;
+ }
+
+ if (rtw89_txpwr_conf_valid(&rfe_data->lmt_5ghz.conf)) {
+ rtw89_fw_load_txpwr_lmt_5ghz(&rfe_data->lmt_5ghz);
+ parms->rule_5ghz.lmt = &rfe_data->lmt_5ghz.v;
+ }
+
+ if (rtw89_txpwr_conf_valid(&rfe_data->lmt_6ghz.conf)) {
+ rtw89_fw_load_txpwr_lmt_6ghz(&rfe_data->lmt_6ghz);
+ parms->rule_6ghz.lmt = &rfe_data->lmt_6ghz.v;
+ }
+
+ if (rtw89_txpwr_conf_valid(&rfe_data->lmt_ru_2ghz.conf)) {
+ rtw89_fw_load_txpwr_lmt_ru_2ghz(&rfe_data->lmt_ru_2ghz);
+ parms->rule_2ghz.lmt_ru = &rfe_data->lmt_ru_2ghz.v;
+ }
+
+ if (rtw89_txpwr_conf_valid(&rfe_data->lmt_ru_5ghz.conf)) {
+ rtw89_fw_load_txpwr_lmt_ru_5ghz(&rfe_data->lmt_ru_5ghz);
+ parms->rule_5ghz.lmt_ru = &rfe_data->lmt_ru_5ghz.v;
+ }
+
+ if (rtw89_txpwr_conf_valid(&rfe_data->lmt_ru_6ghz.conf)) {
+ rtw89_fw_load_txpwr_lmt_ru_6ghz(&rfe_data->lmt_ru_6ghz);
+ parms->rule_6ghz.lmt_ru = &rfe_data->lmt_ru_6ghz.v;
+ }
+
+ if (rtw89_txpwr_conf_valid(&rfe_data->tx_shape_lmt.conf)) {
+ rtw89_fw_load_tx_shape_lmt(&rfe_data->tx_shape_lmt);
+ parms->tx_shape.lmt = &rfe_data->tx_shape_lmt.v;
+ }
+
+ if (rtw89_txpwr_conf_valid(&rfe_data->tx_shape_lmt_ru.conf)) {
+ rtw89_fw_load_tx_shape_lmt_ru(&rfe_data->tx_shape_lmt_ru);
+ parms->tx_shape.lmt_ru = &rfe_data->tx_shape_lmt_ru.v;
+ }
+
+ return parms;
+}
diff --git a/drivers/net/wireless/realtek/rtw89/fw.h b/drivers/net/wireless/realtek/rtw89/fw.h
index f965e2423447..d4db9ab0b5e8 100644
--- a/drivers/net/wireless/realtek/rtw89/fw.h
+++ b/drivers/net/wireless/realtek/rtw89/fw.h
@@ -3417,10 +3417,46 @@ enum rtw89_fw_element_id {
RTW89_FW_ELEMENT_ID_RADIO_C = 6,
RTW89_FW_ELEMENT_ID_RADIO_D = 7,
RTW89_FW_ELEMENT_ID_RF_NCTL = 8,
+ RTW89_FW_ELEMENT_ID_TXPWR_BYRATE = 9,
+ RTW89_FW_ELEMENT_ID_TXPWR_LMT_2GHZ = 10,
+ RTW89_FW_ELEMENT_ID_TXPWR_LMT_5GHZ = 11,
+ RTW89_FW_ELEMENT_ID_TXPWR_LMT_6GHZ = 12,
+ RTW89_FW_ELEMENT_ID_TXPWR_LMT_RU_2GHZ = 13,
+ RTW89_FW_ELEMENT_ID_TXPWR_LMT_RU_5GHZ = 14,
+ RTW89_FW_ELEMENT_ID_TXPWR_LMT_RU_6GHZ = 15,
+ RTW89_FW_ELEMENT_ID_TX_SHAPE_LMT = 16,
+ RTW89_FW_ELEMENT_ID_TX_SHAPE_LMT_RU = 17,
RTW89_FW_ELEMENT_ID_NUM,
};
+#define BITS_OF_RTW89_TXPWR_FW_ELEMENTS \
+ (BIT(RTW89_FW_ELEMENT_ID_TXPWR_BYRATE) | \
+ BIT(RTW89_FW_ELEMENT_ID_TXPWR_LMT_2GHZ) | \
+ BIT(RTW89_FW_ELEMENT_ID_TXPWR_LMT_5GHZ) | \
+ BIT(RTW89_FW_ELEMENT_ID_TXPWR_LMT_6GHZ) | \
+ BIT(RTW89_FW_ELEMENT_ID_TXPWR_LMT_RU_2GHZ) | \
+ BIT(RTW89_FW_ELEMENT_ID_TXPWR_LMT_RU_5GHZ) | \
+ BIT(RTW89_FW_ELEMENT_ID_TXPWR_LMT_RU_6GHZ) | \
+ BIT(RTW89_FW_ELEMENT_ID_TX_SHAPE_LMT) | \
+ BIT(RTW89_FW_ELEMENT_ID_TX_SHAPE_LMT_RU))
+
+#define RTW89_BE_GEN_DEF_NEEDED_FW_ELEMENTS (BIT(RTW89_FW_ELEMENT_ID_BBMCU0) | \
+ BIT(RTW89_FW_ELEMENT_ID_BB_REG) | \
+ BIT(RTW89_FW_ELEMENT_ID_RADIO_A) | \
+ BIT(RTW89_FW_ELEMENT_ID_RADIO_B) | \
+ BIT(RTW89_FW_ELEMENT_ID_RF_NCTL) | \
+ BITS_OF_RTW89_TXPWR_FW_ELEMENTS)
+
+struct __rtw89_fw_txpwr_element {
+ u8 rsvd0;
+ u8 rsvd1;
+ u8 rfe_type;
+ u8 ent_sz;
+ __le32 num_ents;
+ u8 content[];
+} __packed;
+
struct rtw89_fw_element_hdr {
__le32 id; /* enum rtw89_fw_element_id */
__le32 size; /* exclude header size */
@@ -3441,6 +3477,7 @@ struct rtw89_fw_element_hdr {
__le32 data;
} __packed regs[];
} __packed reg2;
+ struct __rtw89_fw_txpwr_element txpwr;
} __packed u;
} __packed;
@@ -3778,4 +3815,97 @@ static inline void rtw89_fw_h2c_init_ba_cam(struct rtw89_dev *rtwdev)
rtw89_fw_h2c_init_dynamic_ba_cam_v0_ext(rtwdev);
}
+/* must consider compatibility; don't insert new in the mid */
+struct rtw89_fw_txpwr_byrate_entry {
+ u8 band;
+ u8 nss;
+ u8 rs;
+ u8 shf;
+ u8 len;
+ __le32 data;
+ u8 bw;
+ u8 ofdma;
+} __packed;
+
+/* must consider compatibility; don't insert new in the mid */
+struct rtw89_fw_txpwr_lmt_2ghz_entry {
+ u8 bw;
+ u8 nt;
+ u8 rs;
+ u8 bf;
+ u8 regd;
+ u8 ch_idx;
+ s8 v;
+} __packed;
+
+/* must consider compatibility; don't insert new in the mid */
+struct rtw89_fw_txpwr_lmt_5ghz_entry {
+ u8 bw;
+ u8 nt;
+ u8 rs;
+ u8 bf;
+ u8 regd;
+ u8 ch_idx;
+ s8 v;
+} __packed;
+
+/* must consider compatibility; don't insert new in the mid */
+struct rtw89_fw_txpwr_lmt_6ghz_entry {
+ u8 bw;
+ u8 nt;
+ u8 rs;
+ u8 bf;
+ u8 regd;
+ u8 reg_6ghz_power;
+ u8 ch_idx;
+ s8 v;
+} __packed;
+
+/* must consider compatibility; don't insert new in the mid */
+struct rtw89_fw_txpwr_lmt_ru_2ghz_entry {
+ u8 ru;
+ u8 nt;
+ u8 regd;
+ u8 ch_idx;
+ s8 v;
+} __packed;
+
+/* must consider compatibility; don't insert new in the mid */
+struct rtw89_fw_txpwr_lmt_ru_5ghz_entry {
+ u8 ru;
+ u8 nt;
+ u8 regd;
+ u8 ch_idx;
+ s8 v;
+} __packed;
+
+/* must consider compatibility; don't insert new in the mid */
+struct rtw89_fw_txpwr_lmt_ru_6ghz_entry {
+ u8 ru;
+ u8 nt;
+ u8 regd;
+ u8 reg_6ghz_power;
+ u8 ch_idx;
+ s8 v;
+} __packed;
+
+/* must consider compatibility; don't insert new in the mid */
+struct rtw89_fw_tx_shape_lmt_entry {
+ u8 band;
+ u8 tx_shape_rs;
+ u8 regd;
+ u8 v;
+} __packed;
+
+/* must consider compatibility; don't insert new in the mid */
+struct rtw89_fw_tx_shape_lmt_ru_entry {
+ u8 band;
+ u8 regd;
+ u8 v;
+} __packed;
+
+const struct rtw89_rfe_parms *
+rtw89_load_rfe_data_from_fw(struct rtw89_dev *rtwdev,
+ const struct rtw89_rfe_parms *init);
+
#endif
diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c
index 03e79d80e32c..6e1f4d6c345c 100644
--- a/drivers/net/wireless/realtek/rtw89/phy.c
+++ b/drivers/net/wireless/realtek/rtw89/phy.c
@@ -1535,7 +1535,6 @@ static const u8 rtw89_rs_nss_num[] = {
[RTW89_RS_OFFSET] = 1,
};
-static
s8 *rtw89_phy_raw_byr_seek(struct rtw89_dev *rtwdev,
struct rtw89_txpwr_byrate *head,
const struct rtw89_rate_desc *desc)
diff --git a/drivers/net/wireless/realtek/rtw89/phy.h b/drivers/net/wireless/realtek/rtw89/phy.h
index d6dc0cbbae43..4684feac97b2 100644
--- a/drivers/net/wireless/realtek/rtw89/phy.h
+++ b/drivers/net/wireless/realtek/rtw89/phy.h
@@ -613,6 +613,9 @@ void rtw89_phy_write32_idx(struct rtw89_dev *rtwdev, u32 addr, u32 mask,
u32 data, enum rtw89_phy_idx phy_idx);
u32 rtw89_phy_read32_idx(struct rtw89_dev *rtwdev, u32 addr, u32 mask,
enum rtw89_phy_idx phy_idx);
+s8 *rtw89_phy_raw_byr_seek(struct rtw89_dev *rtwdev,
+ struct rtw89_txpwr_byrate *head,
+ const struct rtw89_rate_desc *desc);
void rtw89_phy_load_txpwr_byrate(struct rtw89_dev *rtwdev,
const struct rtw89_txpwr_table *tbl);
s8 rtw89_phy_read_txpwr_limit(struct rtw89_dev *rtwdev, u8 band,
--
2.25.1
Ping-Ke Shih <[email protected]> wrote:
> The subband index is a hardware value of relationship between primary
> channel and bandwidth, and it is used by setting channel/bandwidth to
> specify the primary channel.
>
> Because this index is only needed when bandwidth >= 20 MHz, adjust
> order of enumerator bandwidth to access offsets array easier. To prevent
> misuse RTW89_CHANNEL_WIDTH_NUM as size, change it to
> RTW89_CHANNEL_WIDTH_ORDINARY_NUM that will be the size of array. The
> enumerator values of bandwidth (before ordinary number) will be also
> used by upcoming TX power table built in firmware file, so add a comment
> to remind keeping the order.
>
> Signed-off-by: Ping-Ke Shih <[email protected]>
7 patches applied to wireless-next.git, thanks.
9483d8b3aac8 wifi: rtw89: add subband index of primary channel to struct rtw89_chan
1bf24172cc75 wifi: rtw89: indicate TX shape table inside RFE parameter
4cc05e315650 wifi: rtw89: indicate TX power by rate table inside RFE parameter
634fd9920c28 wifi: rtw89: phy: refine helpers used for raw TX power
9707ea6d6822 wifi: rtw89: load TX power by rate when RFE parms setup
f6d601c7590f wifi: rtw89: phy: extend TX power common stuffs for Wi-Fi 7 chips
5ee7b2ea07cc wifi: rtw89: load TX power related tables from FW elements
--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches