2018-05-29 12:00:23

by Sergey Matyukevich

[permalink] [raw]
Subject: [PATCH 0/9] qtnfmac: bugfixes and cleanups

Hello Kalle and all,

Here is a patch set with various minor fixes and enhancments for qtnfmac driver.

Regards,
Sergey

Andrey Shevchenko (3)
qtnfmac: cancel scan on disconnect
qtnfmac: fix bg_scan_period parameter processing
qtnfmac: remove unused function declarations

Dmitry Lebed (2)
qtnfmac: fix firmware command error path
qtnfmac: improve control path timeout handling

Igor Mitsyanko (1)
qtnfmac: decode error codes from firmware replies

Sergey Matyukevich (3)
qtnfmac: fix invalid STA state on EAPOL failure
qtnfmac: cleanup wdev structure between its uses
qtnfmac: simplify notation


bus.h | 3 ++-
cfg80211.c | 56 ++++++++++++++++++++++++++++++++------------------------
commands.c | 35 ++++++++++++++++++++++++++++-------
commands.h | 5 -----
core.c | 3 +--
core.h | 2 --
event.c | 8 +++-----
pearl/pcie.c | 15 ++++++++++++---
qlink.h | 2 ++
trans.c | 4 +++-
10 files changed, 83 insertions(+), 50 deletions(-)


2018-05-29 12:00:25

by Sergey Matyukevich

[permalink] [raw]
Subject: [PATCH 1/9] qtnfmac: remove unused function declarations

From: Andrey Shevchenko <[email protected]>

Functions qtnf_cmd_resp_parse and qtnf_cmd_resp_check have
been removed. Remove their declarations as well.

Signed-off-by: Andrey Shevchenko <[email protected]>
---
drivers/net/wireless/quantenna/qtnfmac/commands.h | 5 -----
1 file changed, 5 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.h b/drivers/net/wireless/quantenna/qtnfmac/commands.h
index 69a7d56f7e58..cf9274add26d 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.h
@@ -58,11 +58,6 @@ int qtnf_cmd_send_change_sta(struct qtnf_vif *vif, const u8 *mac,
struct station_parameters *params);
int qtnf_cmd_send_del_sta(struct qtnf_vif *vif,
struct station_del_parameters *params);
-
-int qtnf_cmd_resp_parse(struct qtnf_bus *bus, struct sk_buff *resp_skb);
-int qtnf_cmd_resp_check(const struct qtnf_vif *vif,
- const struct sk_buff *resp_skb, u16 cmd_id,
- u16 *result, const u8 **payload, size_t *payload_size);
int qtnf_cmd_send_scan(struct qtnf_wmac *mac);
int qtnf_cmd_send_connect(struct qtnf_vif *vif,
struct cfg80211_connect_params *sme);
--
2.11.0

2018-05-29 12:00:39

by Sergey Matyukevich

[permalink] [raw]
Subject: [PATCH 7/9] qtnfmac: fix bg_scan_period parameter processing

From: Andrey Shevchenko <[email protected]>

Do not process bg_scan_period parameter in qtnfmac driver.
Pass correct values as is. In the case of invalid values
pass default value. Leave further processing to firmware.

Signed-off-by: Andrey Shevchenko <[email protected]>
---
drivers/net/wireless/quantenna/qtnfmac/commands.c | 8 +++-----
drivers/net/wireless/quantenna/qtnfmac/core.h | 2 --
2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index e2fc57be1cdd..5eb143667539 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -2339,13 +2339,11 @@ int qtnf_cmd_send_connect(struct qtnf_vif *vif,
else
eth_zero_addr(cmd->prev_bssid);

- if ((sme->bg_scan_period > 0) &&
- (sme->bg_scan_period <= QTNF_MAX_BG_SCAN_PERIOD))
+ if ((sme->bg_scan_period >= 0) &&
+ (sme->bg_scan_period <= SHRT_MAX))
cmd->bg_scan_period = cpu_to_le16(sme->bg_scan_period);
- else if (sme->bg_scan_period == -1)
- cmd->bg_scan_period = cpu_to_le16(QTNF_DEFAULT_BG_SCAN_PERIOD);
else
- cmd->bg_scan_period = 0; /* disabled */
+ cmd->bg_scan_period = cpu_to_le16(-1); /* use default value */

if (sme->flags & ASSOC_REQ_DISABLE_HT)
connect_flags |= QLINK_STA_CONNECT_DISABLE_HT;
diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.h b/drivers/net/wireless/quantenna/qtnfmac/core.h
index 3b884c80b6ab..214435448335 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.h
@@ -44,8 +44,6 @@
#define QTNF_MAX_VSIE_LEN 255
#define QTNF_MAX_INTF 8
#define QTNF_MAX_EVENT_QUEUE_LEN 255
-#define QTNF_DEFAULT_BG_SCAN_PERIOD 300
-#define QTNF_MAX_BG_SCAN_PERIOD 0xffff
#define QTNF_SCAN_TIMEOUT_SEC 15

#define QTNF_DEF_BSS_PRIORITY 0
--
2.11.0

2018-05-29 12:00:45

by Sergey Matyukevich

[permalink] [raw]
Subject: [PATCH 8/9] qtnfmac: cancel scan on disconnect

From: Andrey Shevchenko <[email protected]>

Cancel scan operation on STA disconnect.

Signed-off-by: Andrey Shevchenko <[email protected]>
---
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index 2089cb095283..1fcd94bf7c59 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -660,6 +660,8 @@ qtnf_disconnect(struct wiphy *wiphy, struct net_device *dev,
if (vif->wdev.iftype != NL80211_IFTYPE_STATION)
return -EOPNOTSUPP;

+ qtnf_scan_done(mac, true);
+
if (vif->sta_state == QTNF_STA_DISCONNECTED)
return 0;

--
2.11.0

2018-05-29 12:00:32

by Sergey Matyukevich

[permalink] [raw]
Subject: [PATCH 4/9] qtnfmac: cleanup wdev structure between its uses

Driver uses statically allocated wdev structures for each virtual
interface. However wdev structure is not properly cleaned up between
its uses. As a result, various bugs appear when userspace tools
like hostapd were not gracefully stopped.

In particular, this commit fixes the following issue:
- start hostapd with more than 2 mBSS
- kill hostapd using SIGKILL
- start again hostapd with more than 2 mBSS
However only two mBSS entities will be started: primary
and the last BSS listed in hostapd config.

Signed-off-by: Sergey Matyukevich <[email protected]>
---
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 8 +++-----
drivers/net/wireless/quantenna/qtnfmac/core.c | 1 -
2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index bf624d975953..2089cb095283 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -177,8 +177,6 @@ int qtnf_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
vif->netdev->ieee80211_ptr = NULL;
vif->netdev = NULL;
vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED;
- eth_zero_addr(vif->mac_addr);
- eth_zero_addr(vif->bssid);

return 0;
}
@@ -216,10 +214,12 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy,
}

eth_zero_addr(vif->mac_addr);
+ eth_zero_addr(vif->bssid);
vif->bss_priority = QTNF_DEF_BSS_PRIORITY;
+ vif->sta_state = QTNF_STA_DISCONNECTED;
+ memset(&vif->wdev, 0, sizeof(vif->wdev));
vif->wdev.wiphy = wiphy;
vif->wdev.iftype = type;
- vif->sta_state = QTNF_STA_DISCONNECTED;
break;
default:
pr_err("MAC%u: unsupported IF type %d\n", mac->macid, type);
@@ -255,8 +255,6 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy,
qtnf_cmd_send_del_intf(vif);
err_cmd:
vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED;
- eth_zero_addr(vif->mac_addr);
- eth_zero_addr(vif->bssid);

return ERR_PTR(-EFAULT);
}
diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c
index b3bfb4faa918..3ccbc427cf56 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.c
@@ -394,7 +394,6 @@ int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *vif,
dev = alloc_netdev_mqs(sizeof(struct qtnf_vif *), name,
name_assign_type, ether_setup, 1, 1);
if (!dev) {
- memset(&vif->wdev, 0, sizeof(vif->wdev));
vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED;
return -ENOMEM;
}
--
2.11.0

2018-05-29 12:00:48

by Sergey Matyukevich

[permalink] [raw]
Subject: [PATCH 9/9] qtnfmac: fix invalid STA state on EAPOL failure

Driver switches vif sta_state into QTNF_STA_CONNECTING when cfg80211
core initiates connect procedure. Further this state is changed either
to QTNF_STA_CONNECTED or to QTNF_STA_DISCONNECTED by BSS_JOIN and
BSS_LEAVE events from firmware. However it is possible that no such
events will be sent by firmware, e.g. if EAPOL timed out.

In this case vif sta_mode will remain in QTNF_STA_CONNECTING state and
all subsequent connection attempts will fail with -EBUSY error code.
Fix this by perfroming STA state transition from QTNF_STA_CONNECTING
to QTNF_STA_DISCONNECTED in cfg80211 disconnect callback.
No need to rely upon firmware events in this case.

Signed-off-by: Sergey Matyukevich <[email protected]>
---
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 21 ++++++++++++++-------
drivers/net/wireless/quantenna/qtnfmac/event.c | 8 +++-----
2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index 1fcd94bf7c59..220e2b710208 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -649,30 +649,37 @@ qtnf_disconnect(struct wiphy *wiphy, struct net_device *dev,
{
struct qtnf_wmac *mac = wiphy_priv(wiphy);
struct qtnf_vif *vif;
- int ret;
+ int ret = 0;

vif = qtnf_mac_get_base_vif(mac);
if (!vif) {
pr_err("MAC%u: primary VIF is not configured\n", mac->macid);
- return -EFAULT;
+ ret = -EFAULT;
+ goto out;
}

- if (vif->wdev.iftype != NL80211_IFTYPE_STATION)
- return -EOPNOTSUPP;
+ if (vif->wdev.iftype != NL80211_IFTYPE_STATION) {
+ ret = -EOPNOTSUPP;
+ goto out;
+ }

qtnf_scan_done(mac, true);

if (vif->sta_state == QTNF_STA_DISCONNECTED)
- return 0;
+ goto out;

ret = qtnf_cmd_send_disconnect(vif, reason_code);
if (ret) {
pr_err("VIF%u.%u: failed to disconnect\n", mac->macid,
vif->vifid);
- return ret;
+ goto out;
}

- return 0;
+out:
+ if (vif->sta_state == QTNF_STA_CONNECTING)
+ vif->sta_state = QTNF_STA_DISCONNECTED;
+
+ return ret;
}

static int
diff --git a/drivers/net/wireless/quantenna/qtnfmac/event.c b/drivers/net/wireless/quantenna/qtnfmac/event.c
index 16617c44f81b..68da81bec4e9 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/event.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/event.c
@@ -211,11 +211,9 @@ qtnf_event_handle_bss_leave(struct qtnf_vif *vif,
return -EPROTO;
}

- if (vif->sta_state != QTNF_STA_CONNECTED) {
- pr_err("VIF%u.%u: BSS_LEAVE event when STA is not connected\n",
- vif->mac->macid, vif->vifid);
- return -EPROTO;
- }
+ if (vif->sta_state != QTNF_STA_CONNECTED)
+ pr_warn("VIF%u.%u: BSS_LEAVE event when STA is not connected\n",
+ vif->mac->macid, vif->vifid);

pr_debug("VIF%u.%u: disconnected\n", vif->mac->macid, vif->vifid);

--
2.11.0

2018-05-29 12:00:34

by Sergey Matyukevich

[permalink] [raw]
Subject: [PATCH 5/9] qtnfmac: improve control path timeout handling

From: Dmitry Lebed <[email protected]>

Control path will not be operational after firmware failure. Change bus
state to QTNF_FW_STATE_EP_DEAD after the control path timeout.
Don't wait for timeout if control path is already dead.

Signed-off-by: Dmitry Lebed <[email protected]>
---
drivers/net/wireless/quantenna/qtnfmac/bus.h | 3 ++-
drivers/net/wireless/quantenna/qtnfmac/core.c | 2 +-
drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c | 15 ++++++++++++---
3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/bus.h b/drivers/net/wireless/quantenna/qtnfmac/bus.h
index 0a1604683bab..323e47cea1e2 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/bus.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/bus.h
@@ -27,7 +27,8 @@ enum qtnf_fw_state {
QTNF_FW_STATE_FW_DNLD_DONE,
QTNF_FW_STATE_BOOT_DONE,
QTNF_FW_STATE_ACTIVE,
- QTNF_FW_STATE_DEAD,
+ QTNF_FW_STATE_DETACHED,
+ QTNF_FW_STATE_EP_DEAD,
};

struct qtnf_bus;
diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c
index 3ccbc427cf56..a6a450984f9a 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.c
@@ -628,7 +628,7 @@ void qtnf_core_detach(struct qtnf_bus *bus)
if (bus->fw_state == QTNF_FW_STATE_ACTIVE)
qtnf_cmd_send_deinit_fw(bus);

- bus->fw_state = QTNF_FW_STATE_DEAD;
+ bus->fw_state = QTNF_FW_STATE_DETACHED;

if (bus->workqueue) {
flush_workqueue(bus->workqueue);
diff --git a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
index 6c1e139bb8f7..3120d49df565 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
@@ -751,8 +751,16 @@ static int qtnf_pcie_data_tx(struct qtnf_bus *bus, struct sk_buff *skb)
static int qtnf_pcie_control_tx(struct qtnf_bus *bus, struct sk_buff *skb)
{
struct qtnf_pcie_bus_priv *priv = (void *)get_bus_priv(bus);
+ int ret;
+
+ ret = qtnf_shm_ipc_send(&priv->shm_ipc_ep_in, skb->data, skb->len);

- return qtnf_shm_ipc_send(&priv->shm_ipc_ep_in, skb->data, skb->len);
+ if (ret == -ETIMEDOUT) {
+ pr_err("EP firmware is dead\n");
+ bus->fw_state = QTNF_FW_STATE_EP_DEAD;
+ }
+
+ return ret;
}

static irqreturn_t qtnf_interrupt(int irq, void *data)
@@ -1238,7 +1246,7 @@ static void qtnf_fw_work_handler(struct work_struct *work)
goto fw_load_exit;

fw_load_fail:
- bus->fw_state = QTNF_FW_STATE_DEAD;
+ bus->fw_state = QTNF_FW_STATE_DETACHED;

fw_load_exit:
complete(&bus->firmware_init_complete);
@@ -1408,7 +1416,8 @@ static void qtnf_pcie_remove(struct pci_dev *pdev)

wait_for_completion(&bus->firmware_init_complete);

- if (bus->fw_state == QTNF_FW_STATE_ACTIVE)
+ if (bus->fw_state == QTNF_FW_STATE_ACTIVE ||
+ bus->fw_state == QTNF_FW_STATE_EP_DEAD)
qtnf_core_detach(bus);

priv = get_bus_priv(bus);
--
2.11.0

2018-05-30 19:20:45

by Kalle Valo

[permalink] [raw]
Subject: Re: [1/9] qtnfmac: remove unused function declarations

Sergey Matyukevich <[email protected]> wrote:

> From: Andrey Shevchenko <[email protected]>
>
> Functions qtnf_cmd_resp_parse and qtnf_cmd_resp_check have
> been removed. Remove their declarations as well.
>
> Signed-off-by: Andrey Shevchenko <[email protected]>

9 patches applied to wireless-drivers-next.git, thanks.

6d89265d7841 qtnfmac: remove unused function declarations
d62b622ca409 qtnfmac: simplify notation
36e8c538b374 qtnfmac: decode error codes from firmware replies
9a3beeb5b73a qtnfmac: cleanup wdev structure between its uses
9e33e7fb4772 qtnfmac: improve control path timeout handling
b60769e2dff0 qtnfmac: fix firmware command error path
f5d2ff43b9ed qtnfmac: fix bg_scan_period parameter processing
40d68dbb986d qtnfmac: cancel scan on disconnect
480daa9cb62c qtnfmac: fix invalid STA state on EAPOL failure

--
https://patchwork.kernel.org/patch/10435101/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2018-05-29 12:00:27

by Sergey Matyukevich

[permalink] [raw]
Subject: [PATCH 2/9] qtnfmac: simplify notation

Shorten line lengths using a more compact notation to access mac info.

Signed-off-by: Sergey Matyukevich <[email protected]>
---
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 25 ++++++++++++-----------
1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index 5122dc798064..bf624d975953 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -955,6 +955,7 @@ qtnf_wiphy_setup_if_comb(struct wiphy *wiphy, struct qtnf_mac_info *mac_info)
int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac)
{
struct wiphy *wiphy = priv_to_wiphy(mac);
+ struct qtnf_mac_info *macinfo = &mac->macinfo;
int ret;

if (!wiphy) {
@@ -962,20 +963,20 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac)
return -EFAULT;
}

- wiphy->frag_threshold = mac->macinfo.frag_thr;
- wiphy->rts_threshold = mac->macinfo.rts_thr;
- wiphy->retry_short = mac->macinfo.sretry_limit;
- wiphy->retry_long = mac->macinfo.lretry_limit;
- wiphy->coverage_class = mac->macinfo.coverage_class;
+ wiphy->frag_threshold = macinfo->frag_thr;
+ wiphy->rts_threshold = macinfo->rts_thr;
+ wiphy->retry_short = macinfo->sretry_limit;
+ wiphy->retry_long = macinfo->lretry_limit;
+ wiphy->coverage_class = macinfo->coverage_class;

wiphy->max_scan_ssids = QTNF_MAX_SSID_LIST_LENGTH;
wiphy->max_scan_ie_len = QTNF_MAX_VSIE_LEN;
wiphy->mgmt_stypes = qtnf_mgmt_stypes;
wiphy->max_remain_on_channel_duration = 5000;
- wiphy->max_acl_mac_addrs = mac->macinfo.max_acl_mac_addrs;
+ wiphy->max_acl_mac_addrs = macinfo->max_acl_mac_addrs;
wiphy->max_num_csa_counters = 2;

- ret = qtnf_wiphy_setup_if_comb(wiphy, &mac->macinfo);
+ ret = qtnf_wiphy_setup_if_comb(wiphy, macinfo);
if (ret)
goto out;

@@ -994,12 +995,12 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac)
wiphy->probe_resp_offload = NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2;

- wiphy->available_antennas_tx = mac->macinfo.num_tx_chain;
- wiphy->available_antennas_rx = mac->macinfo.num_rx_chain;
+ wiphy->available_antennas_tx = macinfo->num_tx_chain;
+ wiphy->available_antennas_rx = macinfo->num_rx_chain;

- wiphy->max_ap_assoc_sta = mac->macinfo.max_ap_assoc_sta;
- wiphy->ht_capa_mod_mask = &mac->macinfo.ht_cap_mod_mask;
- wiphy->vht_capa_mod_mask = &mac->macinfo.vht_cap_mod_mask;
+ wiphy->max_ap_assoc_sta = macinfo->max_ap_assoc_sta;
+ wiphy->ht_capa_mod_mask = &macinfo->ht_cap_mod_mask;
+ wiphy->vht_capa_mod_mask = &macinfo->vht_cap_mod_mask;

ether_addr_copy(wiphy->perm_addr, mac->macaddr);

--
2.11.0

2018-05-29 12:00:29

by Sergey Matyukevich

[permalink] [raw]
Subject: [PATCH 3/9] qtnfmac: decode error codes from firmware replies

From: Igor Mitsyanko <[email protected]>

Introduce a function that will map an error code reported in reply
to a firmware command, into one of standard errno codes.
Use additional error codes to improve error reporting
for MAC address changes.

Signed-off-by: Igor Mitsyanko <[email protected]>
---
drivers/net/wireless/quantenna/qtnfmac/commands.c | 26 +++++++++++++++++++++--
drivers/net/wireless/quantenna/qtnfmac/qlink.h | 2 ++
2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index deca0060eb27..9dc4560be5d8 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -55,6 +55,28 @@ static int qtnf_cmd_check_reply_header(const struct qlink_resp *resp,
return 0;
}

+static int qtnf_cmd_resp_result_decode(enum qlink_cmd_result qcode)
+{
+ switch (qcode) {
+ case QLINK_CMD_RESULT_OK:
+ return 0;
+ case QLINK_CMD_RESULT_INVALID:
+ return -EINVAL;
+ case QLINK_CMD_RESULT_ENOTSUPP:
+ return -ENOTSUPP;
+ case QLINK_CMD_RESULT_ENOTFOUND:
+ return -ENOENT;
+ case QLINK_CMD_RESULT_EALREADY:
+ return -EALREADY;
+ case QLINK_CMD_RESULT_EADDRINUSE:
+ return -EADDRINUSE;
+ case QLINK_CMD_RESULT_EADDRNOTAVAIL:
+ return -EADDRNOTAVAIL;
+ default:
+ return -EFAULT;
+ }
+}
+
static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
struct sk_buff *cmd_skb,
struct sk_buff **response_skb,
@@ -810,10 +832,10 @@ static int qtnf_cmd_send_add_change_intf(struct qtnf_vif *vif,
if (unlikely(ret))
goto out;

- if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
+ ret = qtnf_cmd_resp_result_decode(res_code);
+ if (ret) {
pr_err("VIF%u.%u: CMD %d failed: %u\n", vif->mac->macid,
vif->vifid, cmd_type, res_code);
- ret = -EFAULT;
goto out;
}

diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h
index 9ab27e158023..f85deda703fb 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h
@@ -674,6 +674,8 @@ enum qlink_cmd_result {
QLINK_CMD_RESULT_ENOTSUPP,
QLINK_CMD_RESULT_ENOTFOUND,
QLINK_CMD_RESULT_EALREADY,
+ QLINK_CMD_RESULT_EADDRINUSE,
+ QLINK_CMD_RESULT_EADDRNOTAVAIL,
};

/**
--
2.11.0

2018-05-29 12:00:36

by Sergey Matyukevich

[permalink] [raw]
Subject: [PATCH 6/9] qtnfmac: fix firmware command error path

From: Dmitry Lebed <[email protected]>

Free command skb if bus state is not QTNF_FW_STATE_ACTIVE.

Signed-off-by: Dmitry Lebed <[email protected]>
---
drivers/net/wireless/quantenna/qtnfmac/commands.c | 1 +
drivers/net/wireless/quantenna/qtnfmac/trans.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index 9dc4560be5d8..e2fc57be1cdd 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -102,6 +102,7 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
pr_warn("VIF%u.%u: drop cmd 0x%.4X in fw state %d\n",
mac_id, vif_id, le16_to_cpu(cmd->cmd_id),
bus->fw_state);
+ dev_kfree_skb(cmd_skb);
return -ENODEV;
}

diff --git a/drivers/net/wireless/quantenna/qtnfmac/trans.c b/drivers/net/wireless/quantenna/qtnfmac/trans.c
index ccddfebc508a..345f34ec9750 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/trans.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/trans.c
@@ -35,8 +35,10 @@ int qtnf_trans_send_cmd_with_resp(struct qtnf_bus *bus, struct sk_buff *cmd_skb,
bool resp_not_handled = true;
struct sk_buff *resp_skb = NULL;

- if (unlikely(!response_skb))
+ if (unlikely(!response_skb)) {
+ dev_kfree_skb(cmd_skb);
return -EFAULT;
+ }

spin_lock(&ctl_node->resp_lock);
ctl_node->seq_num++;
--
2.11.0