Commit 639ec6d6 authored by Zong-Zhe Yang's avatar Zong-Zhe Yang Committed by Kalle Valo

wifi: rtw89: fw: use generic flow to set/check features

In early feature bitmap obtained from rtw89_early_fw_feature_recognize(),
the bits needed to check get increased. It's more friendly to work with
RTW89_CHK_FW_FEATURE(). So, we concentrate the flow of iterating FW feature
configures and calling RTW89_SET_FW_FEATURE() for various uses. And then,
we adjust rtw89_early_fw_feature_recognize() for RTW89_CHK_FW_FEATURE().
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/20230320130606.20777-2-pkshih@realtek.com
parent c5280e5f
...@@ -3754,23 +3754,23 @@ struct rtw89_dev *rtw89_alloc_ieee80211_hw(struct device *device, ...@@ -3754,23 +3754,23 @@ struct rtw89_dev *rtw89_alloc_ieee80211_hw(struct device *device,
u32 bus_data_size, u32 bus_data_size,
const struct rtw89_chip_info *chip) const struct rtw89_chip_info *chip)
{ {
struct rtw89_fw_info early_fw = {};
const struct firmware *firmware; const struct firmware *firmware;
struct ieee80211_hw *hw; struct ieee80211_hw *hw;
struct rtw89_dev *rtwdev; struct rtw89_dev *rtwdev;
struct ieee80211_ops *ops; struct ieee80211_ops *ops;
u32 driver_data_size; u32 driver_data_size;
u32 early_feat_map = 0;
bool no_chanctx; bool no_chanctx;
firmware = rtw89_early_fw_feature_recognize(device, chip, &early_feat_map); firmware = rtw89_early_fw_feature_recognize(device, chip, &early_fw);
ops = kmemdup(&rtw89_ops, sizeof(rtw89_ops), GFP_KERNEL); ops = kmemdup(&rtw89_ops, sizeof(rtw89_ops), GFP_KERNEL);
if (!ops) if (!ops)
goto err; goto err;
no_chanctx = chip->support_chanctx_num == 0 || no_chanctx = chip->support_chanctx_num == 0 ||
!(early_feat_map & BIT(RTW89_FW_FEATURE_SCAN_OFFLOAD)) || !RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD, &early_fw) ||
!(early_feat_map & BIT(RTW89_FW_FEATURE_BEACON_FILTER)); !RTW89_CHK_FW_FEATURE(BEACON_FILTER, &early_fw);
if (no_chanctx) { if (no_chanctx) {
ops->add_chanctx = NULL; ops->add_chanctx = NULL;
......
...@@ -269,38 +269,45 @@ static const struct __fw_feat_cfg fw_feat_tbl[] = { ...@@ -269,38 +269,45 @@ static const struct __fw_feat_cfg fw_feat_tbl[] = {
__CFG_FW_FEAT(RTL8852C, ge, 0, 27, 56, 10, BEACON_FILTER), __CFG_FW_FEAT(RTL8852C, ge, 0, 27, 56, 10, BEACON_FILTER),
}; };
static void rtw89_fw_iterate_feature_cfg(struct rtw89_fw_info *fw,
const struct rtw89_chip_info *chip,
u32 ver_code)
{
int i;
for (i = 0; i < ARRAY_SIZE(fw_feat_tbl); i++) {
const struct __fw_feat_cfg *ent = &fw_feat_tbl[i];
if (chip->chip_id != ent->chip_id)
continue;
if (ent->cond(ver_code, ent->ver_code))
RTW89_SET_FW_FEATURE(ent->feature, fw);
}
}
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;
const struct __fw_feat_cfg *ent;
const struct rtw89_fw_suit *fw_suit; const struct rtw89_fw_suit *fw_suit;
u32 suit_ver_code; u32 suit_ver_code;
int i;
fw_suit = rtw89_fw_suit_get(rtwdev, RTW89_FW_NORMAL); fw_suit = rtw89_fw_suit_get(rtwdev, RTW89_FW_NORMAL);
suit_ver_code = RTW89_FW_SUIT_VER_CODE(fw_suit); suit_ver_code = RTW89_FW_SUIT_VER_CODE(fw_suit);
for (i = 0; i < ARRAY_SIZE(fw_feat_tbl); i++) { rtw89_fw_iterate_feature_cfg(&rtwdev->fw, chip, suit_ver_code);
ent = &fw_feat_tbl[i];
if (chip->chip_id != ent->chip_id)
continue;
if (ent->cond(suit_ver_code, ent->ver_code))
RTW89_SET_FW_FEATURE(ent->feature, &rtwdev->fw);
}
} }
const struct firmware * const struct firmware *
rtw89_early_fw_feature_recognize(struct device *device, rtw89_early_fw_feature_recognize(struct device *device,
const struct rtw89_chip_info *chip, const struct rtw89_chip_info *chip,
u32 *early_feat_map) struct rtw89_fw_info *early_fw)
{ {
union rtw89_compat_fw_hdr buf = {}; union rtw89_compat_fw_hdr buf = {};
const struct firmware *firmware; const struct firmware *firmware;
bool full_req = false; bool full_req = false;
u32 ver_code; u32 ver_code;
int ret; int ret;
int i;
/* If SECURITY_LOADPIN_ENFORCE is enabled, reading partial files will /* If SECURITY_LOADPIN_ENFORCE is enabled, reading partial files will
* be denied (-EPERM). Then, we don't get right firmware things as * be denied (-EPERM). Then, we don't get right firmware things as
...@@ -329,15 +336,7 @@ rtw89_early_fw_feature_recognize(struct device *device, ...@@ -329,15 +336,7 @@ rtw89_early_fw_feature_recognize(struct device *device,
if (!ver_code) if (!ver_code)
goto out; goto out;
for (i = 0; i < ARRAY_SIZE(fw_feat_tbl); i++) { rtw89_fw_iterate_feature_cfg(early_fw, chip, ver_code);
const struct __fw_feat_cfg *ent = &fw_feat_tbl[i];
if (chip->chip_id != ent->chip_id)
continue;
if (ent->cond(ver_code, ent->ver_code))
*early_feat_map |= BIT(ent->feature);
}
out: out:
if (full_req) if (full_req)
......
...@@ -3658,7 +3658,7 @@ int rtw89_fw_recognize(struct rtw89_dev *rtwdev); ...@@ -3658,7 +3658,7 @@ int rtw89_fw_recognize(struct rtw89_dev *rtwdev);
const struct firmware * const struct firmware *
rtw89_early_fw_feature_recognize(struct device *device, rtw89_early_fw_feature_recognize(struct device *device,
const struct rtw89_chip_info *chip, const struct rtw89_chip_info *chip,
u32 *early_feat_map); struct rtw89_fw_info *early_fw);
int rtw89_fw_download(struct rtw89_dev *rtwdev, enum rtw89_fw_type type); int rtw89_fw_download(struct rtw89_dev *rtwdev, enum rtw89_fw_type type);
int rtw89_load_firmware(struct rtw89_dev *rtwdev); int rtw89_load_firmware(struct rtw89_dev *rtwdev);
void rtw89_unload_firmware(struct rtw89_dev *rtwdev); void rtw89_unload_firmware(struct rtw89_dev *rtwdev);
......
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