Commit 3ead1e01 authored by Lior David's avatar Lior David Committed by Kalle Valo

wil6210: refresh FW capabilities during interface up

FW capabilities are currently retrieved only during module
initialization, but userspace can replace the firmware while
interface is down, so refresh the FW capabilities when
interface is up (after FW is loaded) to ensure driver
functionality matches the loaded FW.
Signed-off-by: default avatarLior David <qca_liord@qca.qualcomm.com>
Signed-off-by: default avatarMaya Erez <qca_merez@qca.qualcomm.com>
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent 5fad7241
...@@ -124,24 +124,19 @@ static int fw_ignore_section(struct wil6210_priv *wil, const void *data, ...@@ -124,24 +124,19 @@ static int fw_ignore_section(struct wil6210_priv *wil, const void *data,
return 0; return 0;
} }
static int fw_handle_comment(struct wil6210_priv *wil, const void *data,
size_t size)
{
wil_hex_dump_fw("", DUMP_PREFIX_OFFSET, 16, 1, data, size, true);
return 0;
}
static int static int
fw_handle_capabilities(struct wil6210_priv *wil, const void *data, fw_handle_comment(struct wil6210_priv *wil, const void *data,
size_t size) size_t size)
{ {
const struct wil_fw_record_capabilities *rec = data; const struct wil_fw_record_capabilities *rec = data;
size_t capa_size; size_t capa_size;
if (size < sizeof(*rec) || if (size < sizeof(*rec) ||
le32_to_cpu(rec->magic) != WIL_FW_CAPABILITIES_MAGIC) le32_to_cpu(rec->magic) != WIL_FW_CAPABILITIES_MAGIC) {
wil_hex_dump_fw("", DUMP_PREFIX_OFFSET, 16, 1,
data, size, true);
return 0; return 0;
}
capa_size = size - offsetof(struct wil_fw_record_capabilities, capa_size = size - offsetof(struct wil_fw_record_capabilities,
capabilities); capabilities);
...@@ -422,7 +417,7 @@ static const struct { ...@@ -422,7 +417,7 @@ static const struct {
int (*parse_handler)(struct wil6210_priv *wil, const void *data, int (*parse_handler)(struct wil6210_priv *wil, const void *data,
size_t size); size_t size);
} wil_fw_handlers[] = { } wil_fw_handlers[] = {
{wil_fw_type_comment, fw_handle_comment, fw_handle_capabilities}, {wil_fw_type_comment, fw_handle_comment, fw_handle_comment},
{wil_fw_type_data, fw_handle_data, fw_ignore_section}, {wil_fw_type_data, fw_handle_data, fw_ignore_section},
{wil_fw_type_fill, fw_handle_fill, fw_ignore_section}, {wil_fw_type_fill, fw_handle_fill, fw_ignore_section},
/* wil_fw_type_action */ /* wil_fw_type_action */
...@@ -517,7 +512,7 @@ int wil_request_firmware(struct wil6210_priv *wil, const char *name, ...@@ -517,7 +512,7 @@ int wil_request_firmware(struct wil6210_priv *wil, const char *name,
rc = request_firmware(&fw, name, wil_to_dev(wil)); rc = request_firmware(&fw, name, wil_to_dev(wil));
if (rc) { if (rc) {
wil_err_fw(wil, "Failed to load firmware %s\n", name); wil_err_fw(wil, "Failed to load firmware %s rc %d\n", name, rc);
return rc; return rc;
} }
wil_dbg_fw(wil, "Loading <%s>, %zu bytes\n", name, fw->size); wil_dbg_fw(wil, "Loading <%s>, %zu bytes\n", name, fw->size);
......
...@@ -760,6 +760,8 @@ static void wil_collect_fw_info(struct wil6210_priv *wil) ...@@ -760,6 +760,8 @@ static void wil_collect_fw_info(struct wil6210_priv *wil)
u8 retry_short; u8 retry_short;
int rc; int rc;
wil_refresh_fw_capabilities(wil);
rc = wmi_get_mgmt_retry(wil, &retry_short); rc = wmi_get_mgmt_retry(wil, &retry_short);
if (!rc) { if (!rc) {
wiphy->retry_short = retry_short; wiphy->retry_short = retry_short;
...@@ -767,6 +769,25 @@ static void wil_collect_fw_info(struct wil6210_priv *wil) ...@@ -767,6 +769,25 @@ static void wil_collect_fw_info(struct wil6210_priv *wil)
} }
} }
void wil_refresh_fw_capabilities(struct wil6210_priv *wil)
{
struct wiphy *wiphy = wil_to_wiphy(wil);
wil->keep_radio_on_during_sleep =
wil->platform_ops.keep_radio_on_during_sleep &&
wil->platform_ops.keep_radio_on_during_sleep(
wil->platform_handle) &&
test_bit(WMI_FW_CAPABILITY_D3_SUSPEND, wil->fw_capabilities);
wil_info(wil, "keep_radio_on_during_sleep (%d)\n",
wil->keep_radio_on_during_sleep);
if (test_bit(WMI_FW_CAPABILITY_RSSI_REPORTING, wil->fw_capabilities))
wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
else
wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC;
}
void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r) void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r)
{ {
le32_to_cpus(&r->base); le32_to_cpus(&r->base);
...@@ -1071,11 +1092,11 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw) ...@@ -1071,11 +1092,11 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
return rc; return rc;
} }
wil_collect_fw_info(wil);
if (wil->ps_profile != WMI_PS_PROFILE_TYPE_DEFAULT) if (wil->ps_profile != WMI_PS_PROFILE_TYPE_DEFAULT)
wil_ps_update(wil, wil->ps_profile); wil_ps_update(wil, wil->ps_profile);
wil_collect_fw_info(wil);
if (wil->platform_ops.notify) { if (wil->platform_ops.notify) {
rc = wil->platform_ops.notify(wil->platform_handle, rc = wil->platform_ops.notify(wil->platform_handle,
WIL_PLATFORM_EVT_FW_RDY); WIL_PLATFORM_EVT_FW_RDY);
......
...@@ -83,9 +83,7 @@ void wil_set_capabilities(struct wil6210_priv *wil) ...@@ -83,9 +83,7 @@ void wil_set_capabilities(struct wil6210_priv *wil)
/* extract FW capabilities from file without loading the FW */ /* extract FW capabilities from file without loading the FW */
wil_request_firmware(wil, wil->wil_fw_name, false); wil_request_firmware(wil, wil->wil_fw_name, false);
wil_refresh_fw_capabilities(wil);
if (test_bit(WMI_FW_CAPABILITY_RSSI_REPORTING, wil->fw_capabilities))
wil_to_wiphy(wil)->signal_type = CFG80211_SIGNAL_TYPE_MBM;
} }
void wil_disable_irq(struct wil6210_priv *wil) void wil_disable_irq(struct wil6210_priv *wil)
...@@ -295,15 +293,6 @@ static int wil_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -295,15 +293,6 @@ static int wil_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
wil_set_capabilities(wil); wil_set_capabilities(wil);
wil6210_clear_irq(wil); wil6210_clear_irq(wil);
wil->keep_radio_on_during_sleep =
wil->platform_ops.keep_radio_on_during_sleep &&
wil->platform_ops.keep_radio_on_during_sleep(
wil->platform_handle) &&
test_bit(WMI_FW_CAPABILITY_D3_SUSPEND, wil->fw_capabilities);
wil_info(wil, "keep_radio_on_during_sleep (%d)\n",
wil->keep_radio_on_during_sleep);
/* FW should raise IRQ when ready */ /* FW should raise IRQ when ready */
rc = wil_if_pcie_enable(wil); rc = wil_if_pcie_enable(wil);
if (rc) { if (rc) {
......
...@@ -870,6 +870,7 @@ int wil_up(struct wil6210_priv *wil); ...@@ -870,6 +870,7 @@ int wil_up(struct wil6210_priv *wil);
int __wil_up(struct wil6210_priv *wil); int __wil_up(struct wil6210_priv *wil);
int wil_down(struct wil6210_priv *wil); int wil_down(struct wil6210_priv *wil);
int __wil_down(struct wil6210_priv *wil); int __wil_down(struct wil6210_priv *wil);
void wil_refresh_fw_capabilities(struct wil6210_priv *wil);
void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r); void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r);
int wil_find_cid(struct wil6210_priv *wil, const u8 *mac); int wil_find_cid(struct wil6210_priv *wil, const u8 *mac);
void wil_set_ethtoolops(struct net_device *ndev); void wil_set_ethtoolops(struct net_device *ndev);
......
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