Commit 11fe4ccd authored by Zong-Zhe Yang's avatar Zong-Zhe Yang Committed by Kalle Valo

rtw89: reconstruct fw feature

As the fw features gradually increase, it would be better that
we have a set of methods to maintain fw features instead of using
scattered bool variables.

We reconstruct the way fw recognize features, and introduce
RTW89_CHK_FW_FEATURE() / RTW89_SET_FW_FEATURE() to check / set
fw features for uses.
Signed-off-by: default avatarZong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220314071250.40292-8-pkshih@realtek.com
parent f5e24684
...@@ -759,7 +759,7 @@ static void ...@@ -759,7 +759,7 @@ static void
rtw89_core_tx_wake(struct rtw89_dev *rtwdev, rtw89_core_tx_wake(struct rtw89_dev *rtwdev,
struct rtw89_core_tx_request *tx_req) struct rtw89_core_tx_request *tx_req)
{ {
if (!rtwdev->fw.tx_wake) if (!RTW89_CHK_FW_FEATURE(TX_WAKE, &rtwdev->fw))
return; return;
if (!test_bit(RTW89_FLAG_LOW_POWER_MODE, rtwdev->flags)) if (!test_bit(RTW89_FLAG_LOW_POWER_MODE, rtwdev->flags))
...@@ -1454,7 +1454,8 @@ static void rtw89_core_update_rx_status(struct rtw89_dev *rtwdev, ...@@ -1454,7 +1454,8 @@ static void rtw89_core_update_rx_status(struct rtw89_dev *rtwdev,
rx_status->freq = hw->conf.chandef.chan->center_freq; rx_status->freq = hw->conf.chandef.chan->center_freq;
rx_status->band = hw->conf.chandef.chan->band; rx_status->band = hw->conf.chandef.chan->band;
if (rtwdev->scanning && rtwdev->fw.scan_offload) { if (rtwdev->scanning &&
RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD, &rtwdev->fw)) {
rx_status->freq = rx_status->freq =
ieee80211_channel_to_frequency(hal->current_channel, ieee80211_channel_to_frequency(hal->current_channel,
hal->current_band_type); hal->current_band_type);
......
...@@ -2396,6 +2396,12 @@ enum rtw89_fw_type { ...@@ -2396,6 +2396,12 @@ enum rtw89_fw_type {
RTW89_FW_WOWLAN = 3, RTW89_FW_WOWLAN = 3,
}; };
enum rtw89_fw_feature {
RTW89_FW_FEATURE_OLD_HT_RA_FORMAT,
RTW89_FW_FEATURE_SCAN_OFFLOAD,
RTW89_FW_FEATURE_TX_WAKE,
};
struct rtw89_fw_suit { struct rtw89_fw_suit {
const u8 *data; const u8 *data;
u32 size; u32 size;
...@@ -2425,11 +2431,15 @@ struct rtw89_fw_info { ...@@ -2425,11 +2431,15 @@ struct rtw89_fw_info {
struct rtw89_fw_suit normal; struct rtw89_fw_suit normal;
struct rtw89_fw_suit wowlan; struct rtw89_fw_suit wowlan;
bool fw_log_enable; bool fw_log_enable;
bool old_ht_ra_format; u32 feature_map;
bool scan_offload;
bool tx_wake;
}; };
#define RTW89_CHK_FW_FEATURE(_feat, _fw) \
(!!((_fw)->feature_map & BIT(RTW89_FW_FEATURE_ ## _feat)))
#define RTW89_SET_FW_FEATURE(_fw_feature, _fw) \
((_fw)->feature_map |= BIT(_fw_feature))
struct rtw89_cam_info { struct rtw89_cam_info {
DECLARE_BITMAP(addr_cam_map, RTW89_MAX_ADDR_CAM_NUM); DECLARE_BITMAP(addr_cam_map, RTW89_MAX_ADDR_CAM_NUM);
DECLARE_BITMAP(bssid_cam_map, RTW89_MAX_BSSID_CAM_NUM); DECLARE_BITMAP(bssid_cam_map, RTW89_MAX_BSSID_CAM_NUM);
......
...@@ -193,22 +193,55 @@ int __rtw89_fw_recognize(struct rtw89_dev *rtwdev, enum rtw89_fw_type type) ...@@ -193,22 +193,55 @@ int __rtw89_fw_recognize(struct rtw89_dev *rtwdev, enum rtw89_fw_type type)
return 0; return 0;
} }
#define __DEF_FW_FEAT_COND(__cond, __op) \
static bool __fw_feat_cond_ ## __cond(u32 suit_ver_code, u32 comp_ver_code) \
{ \
return suit_ver_code __op comp_ver_code; \
}
__DEF_FW_FEAT_COND(ge, >=); /* greater or equal */
__DEF_FW_FEAT_COND(le, <=); /* less or equal */
struct __fw_feat_cfg {
enum rtw89_core_chip_id chip_id;
enum rtw89_fw_feature feature;
u32 ver_code;
bool (*cond)(u32 suit_ver_code, u32 comp_ver_code);
};
#define __CFG_FW_FEAT(_chip, _cond, _maj, _min, _sub, _idx, _feat) \
{ \
.chip_id = _chip, \
.feature = RTW89_FW_FEATURE_ ## _feat, \
.ver_code = RTW89_FW_VER_CODE(_maj, _min, _sub, _idx), \
.cond = __fw_feat_cond_ ## _cond, \
}
static const struct __fw_feat_cfg fw_feat_tbl[] = {
__CFG_FW_FEAT(RTL8852A, le, 0, 13, 29, 0, OLD_HT_RA_FORMAT),
__CFG_FW_FEAT(RTL8852A, ge, 0, 13, 35, 0, SCAN_OFFLOAD),
__CFG_FW_FEAT(RTL8852A, ge, 0, 13, 35, 0, TX_WAKE),
};
static void rtw89_fw_recognize_features(struct rtw89_dev *rtwdev) static void rtw89_fw_recognize_features(struct rtw89_dev *rtwdev)
{ {
const struct rtw89_chip_info *chip = rtwdev->chip; const struct rtw89_chip_info *chip = rtwdev->chip;
struct rtw89_fw_suit *fw_suit = rtw89_fw_suit_get(rtwdev, RTW89_FW_NORMAL); const struct __fw_feat_cfg *ent;
const struct rtw89_fw_suit *fw_suit;
u32 suit_ver_code;
int i;
if (chip->chip_id == RTL8852A && fw_suit = rtw89_fw_suit_get(rtwdev, RTW89_FW_NORMAL);
RTW89_FW_SUIT_VER_CODE(fw_suit) <= RTW89_FW_VER_CODE(0, 13, 29, 0)) suit_ver_code = RTW89_FW_SUIT_VER_CODE(fw_suit);
rtwdev->fw.old_ht_ra_format = true;
if (chip->chip_id == RTL8852A && for (i = 0; i < ARRAY_SIZE(fw_feat_tbl); i++) {
RTW89_FW_SUIT_VER_CODE(fw_suit) >= RTW89_FW_VER_CODE(0, 13, 35, 0)) ent = &fw_feat_tbl[i];
rtwdev->fw.scan_offload = true; if (chip->chip_id != ent->chip_id)
continue;
if (chip->chip_id == RTL8852A && if (ent->cond(suit_ver_code, ent->ver_code))
RTW89_FW_SUIT_VER_CODE(fw_suit) >= RTW89_FW_VER_CODE(0, 13, 35, 0)) RTW89_SET_FW_FEATURE(ent->feature, &rtwdev->fw);
rtwdev->fw.tx_wake = true; }
} }
int rtw89_fw_recognize(struct rtw89_dev *rtwdev) int rtw89_fw_recognize(struct rtw89_dev *rtwdev)
......
...@@ -725,7 +725,7 @@ static int rtw89_ops_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, ...@@ -725,7 +725,7 @@ static int rtw89_ops_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct rtw89_dev *rtwdev = hw->priv; struct rtw89_dev *rtwdev = hw->priv;
int ret = 0; int ret = 0;
if (!rtwdev->fw.scan_offload) if (!RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD, &rtwdev->fw))
return 1; return 1;
if (rtwdev->scanning) if (rtwdev->scanning)
...@@ -748,7 +748,7 @@ static void rtw89_ops_cancel_hw_scan(struct ieee80211_hw *hw, ...@@ -748,7 +748,7 @@ static void rtw89_ops_cancel_hw_scan(struct ieee80211_hw *hw,
{ {
struct rtw89_dev *rtwdev = hw->priv; struct rtw89_dev *rtwdev = hw->priv;
if (!rtwdev->fw.scan_offload) if (!RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD, &rtwdev->fw))
return; return;
if (!rtwdev->scanning) if (!rtwdev->scanning)
......
...@@ -1686,7 +1686,7 @@ static void rtw89_phy_c2h_ra_rpt_iter(void *data, struct ieee80211_sta *sta) ...@@ -1686,7 +1686,7 @@ static void rtw89_phy_c2h_ra_rpt_iter(void *data, struct ieee80211_sta *sta)
break; break;
case RTW89_RA_RPT_MODE_HT: case RTW89_RA_RPT_MODE_HT:
ra_report->txrate.flags |= RATE_INFO_FLAGS_MCS; ra_report->txrate.flags |= RATE_INFO_FLAGS_MCS;
if (rtwdev->fw.old_ht_ra_format) if (RTW89_CHK_FW_FEATURE(OLD_HT_RA_FORMAT, &rtwdev->fw))
rate = RTW89_MK_HT_RATE(FIELD_GET(RTW89_RA_RATE_MASK_NSS, rate), rate = RTW89_MK_HT_RATE(FIELD_GET(RTW89_RA_RATE_MASK_NSS, rate),
FIELD_GET(RTW89_RA_RATE_MASK_MCS, rate)); FIELD_GET(RTW89_RA_RATE_MASK_MCS, rate));
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment