[PATCH v2 12/12] qtnfmac: prepare for AP_VLAN interface type support

2017-07-27 Thread Sergey Matyukevich
Modify qlink command structures and interface types handling
to prepare adding AP_VLAN support to qtnfmac driver.

Signed-off-by: Igor Mitsyanko 
Signed-off-by: Sergey Matyukevich 
Signed-off-by: Avinash Patil 
---
 drivers/net/wireless/quantenna/qtnfmac/commands.c  | 27 ++
 drivers/net/wireless/quantenna/qtnfmac/qlink.h | 13 ---
 .../net/wireless/quantenna/qtnfmac/qlink_util.c|  3 +++
 3 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c 
b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index 94656106b496..4206886b110c 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -1047,6 +1047,7 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac 
*mac,
 
/* supported modes: STA, AP */
limits[rec].types &= BIT(NL80211_IFTYPE_AP) |
+BIT(NL80211_IFTYPE_AP_VLAN) |
 BIT(NL80211_IFTYPE_STATION);
 
pr_debug("MAC%u: MAX: %u; TYPES: %.4X\n", mac->macid,
@@ -1058,6 +1059,7 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac 
*mac,
default:
break;
}
+
tlv_buf_size -= tlv_full_len;
tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len);
}
@@ -1859,10 +1861,27 @@ int qtnf_cmd_send_change_sta(struct qtnf_vif *vif, 
const u8 *mac,
 
cmd = (struct qlink_cmd_change_sta *)cmd_skb->data;
ether_addr_copy(cmd->sta_addr, mac);
-   cmd->sta_flags_mask = cpu_to_le32(qtnf_encode_sta_flags(
- params->sta_flags_mask));
-   cmd->sta_flags_set = cpu_to_le32(qtnf_encode_sta_flags(
-params->sta_flags_set));
+
+   switch (vif->wdev.iftype) {
+   case NL80211_IFTYPE_AP:
+   cmd->if_type = cpu_to_le16(QLINK_IFTYPE_AP);
+   cmd->sta_flags_mask = cpu_to_le32(qtnf_encode_sta_flags(
+ params->sta_flags_mask));
+   cmd->sta_flags_set = cpu_to_le32(qtnf_encode_sta_flags(
+params->sta_flags_set));
+   break;
+   case NL80211_IFTYPE_STATION:
+   cmd->if_type = cpu_to_le16(QLINK_IFTYPE_STATION);
+   cmd->sta_flags_mask = cpu_to_le32(qtnf_encode_sta_flags(
+ params->sta_flags_mask));
+   cmd->sta_flags_set = cpu_to_le32(qtnf_encode_sta_flags(
+params->sta_flags_set));
+   break;
+   default:
+   pr_err("unsupported iftype %d\n", vif->wdev.iftype);
+   ret = -EINVAL;
+   goto out;
+   }
 
ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, _code);
if (unlikely(ret))
diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h 
b/drivers/net/wireless/quantenna/qtnfmac/qlink.h
index ec5126362494..a8242f678496 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h
@@ -19,7 +19,7 @@
 
 #include 
 
-#define QLINK_PROTO_VER4
+#define QLINK_PROTO_VER5
 
 #define QLINK_MACID_RSVD   0xFF
 #define QLINK_VIFID_RSVD   0xFF
@@ -77,6 +77,7 @@ enum qlink_iface_type {
QLINK_IFTYPE_ADHOC  = 3,
QLINK_IFTYPE_MONITOR= 4,
QLINK_IFTYPE_WDS= 5,
+   QLINK_IFTYPE_AP_VLAN= 6,
 };
 
 /**
@@ -85,12 +86,12 @@ enum qlink_iface_type {
  * Data describing a single virtual interface.
  *
  * @if_type: Mode of interface operation, one of  qlink_iface_type
- * @flags: interface flagsmap.
+ * @vlanid: VLAN ID for AP_VLAN interface type
  * @mac_addr: MAC address of virtual interface.
  */
 struct qlink_intf_info {
__le16 if_type;
-   __le16 flags;
+   __le16 vlanid;
u8 mac_addr[ETH_ALEN];
u8 rsvd[2];
 } __packed;
@@ -292,6 +293,7 @@ struct qlink_cmd_get_sta_info {
  * @pairwise: whether to use pairwise key.
  * @addr: MAC address of a STA key is being installed to.
  * @cipher: cipher suite.
+ * @vlanid: VLAN ID for AP_VLAN interface type
  * @key_data: key data itself.
  */
 struct qlink_cmd_add_key {
@@ -300,6 +302,7 @@ struct qlink_cmd_add_key {
u8 pairwise;
u8 addr[ETH_ALEN];
__le32 cipher;
+   __le16 vlanid;
u8 key_data[0];
 } __packed;
 
@@ -346,12 +349,16 @@ struct qlink_cmd_set_def_mgmt_key {
  *
  * @sta_flags_mask: STA flags mask, bitmap of  qlink_sta_flags
  * @sta_flags_set: STA flags values, bitmap of  qlink_sta_flags
+ * @if_type: Mode of interface operation, one of  

[PATCH v2 11/12] qtnfmac: remove function qtnf_cmd_skb_put_action

2017-07-27 Thread Sergey Matyukevich
This function is not used anymore, so remove it.

Signed-off-by: Igor Mitsyanko 
Signed-off-by: Sergey Matyukevich 
Signed-off-by: Avinash Patil 
---
 drivers/net/wireless/quantenna/qtnfmac/qlink_util.h | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h 
b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h
index c9e882a3a991..de06c1e20b5b 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h
@@ -22,14 +22,6 @@
 
 #include "qlink.h"
 
-static inline void qtnf_cmd_skb_put_action(struct sk_buff *skb, u16 action)
-{
-   __le16 *buf_ptr;
-
-   buf_ptr = skb_put(skb, sizeof(action));
-   *buf_ptr = cpu_to_le16(action);
-}
-
 static inline void
 qtnf_cmd_skb_put_buffer(struct sk_buff *skb, const u8 *buf_src, size_t len)
 {
-- 
2.11.0



[PATCH v2 08/12] qtnfmac: implement cfg80211 channel_switch handler

2017-07-27 Thread Sergey Matyukevich
This patch implements cfg80211 channel_switch handler enabling CSA
channel-switch procedure.

Driver performs only basic validation of the requested new channel
and then sends command to firmware. Beacon IEs are not sent since
beacon update is handled by firmware.

Signed-off-by: Igor Mitsyanko 
Signed-off-by: Sergey Matyukevich 
Signed-off-by: Avinash Patil 
---
 drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 60 +-
 drivers/net/wireless/quantenna/qtnfmac/commands.c | 55 
 drivers/net/wireless/quantenna/qtnfmac/commands.h |  2 +
 drivers/net/wireless/quantenna/qtnfmac/core.h |  6 +++
 drivers/net/wireless/quantenna/qtnfmac/event.c| 61 +++
 drivers/net/wireless/quantenna/qtnfmac/qlink.h| 28 +++
 6 files changed, 210 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c 
b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index d47050934f00..ac8fdc1db482 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -812,6 +812,59 @@ qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev 
*wdev,
return 0;
 }
 
+static int qtnf_channel_switch(struct wiphy *wiphy, struct net_device *dev,
+  struct cfg80211_csa_settings *params)
+{
+   struct qtnf_wmac *mac = wiphy_priv(wiphy);
+   struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
+   int ret;
+
+   pr_debug("%s: chan(%u) count(%u) radar(%u) block_tx(%u)\n", dev->name,
+params->chandef.chan->hw_value, params->count,
+params->radar_required, params->block_tx);
+
+   switch (vif->wdev.iftype) {
+   case NL80211_IFTYPE_AP:
+   if (!(vif->bss_status & QTNF_STATE_AP_START)) {
+   pr_warn("AP not started on %s\n", dev->name);
+   return -ENOTCONN;
+   }
+   break;
+   default:
+   pr_err("unsupported vif type (%d) on %s\n",
+  vif->wdev.iftype, dev->name);
+   return -EOPNOTSUPP;
+   }
+
+   if (vif->vifid != 0) {
+   if (!(mac->status & QTNF_MAC_CSA_ACTIVE))
+   return -EOPNOTSUPP;
+
+   if (!cfg80211_chandef_identical(>chandef,
+   >csa_chandef))
+   return -EINVAL;
+
+   return 0;
+   }
+
+   if (!cfg80211_chandef_valid(>chandef)) {
+   pr_err("%s: invalid channel\n", dev->name);
+   return -EINVAL;
+   }
+
+   if (cfg80211_chandef_identical(>chandef, >chandef)) {
+   pr_err("%s: switch request to the same channel\n", dev->name);
+   return -EALREADY;
+   }
+
+   ret = qtnf_cmd_send_chan_switch(mac, params);
+   if (ret)
+   pr_warn("%s: failed to switch to channel (%u)\n",
+   dev->name, params->chandef.chan->hw_value);
+
+   return ret;
+}
+
 static struct cfg80211_ops qtn_cfg80211_ops = {
.add_virtual_intf   = qtnf_add_virtual_intf,
.change_virtual_intf= qtnf_change_virtual_intf,
@@ -834,7 +887,8 @@ static struct cfg80211_ops qtn_cfg80211_ops = {
.connect= qtnf_connect,
.disconnect = qtnf_disconnect,
.dump_survey= qtnf_dump_survey,
-   .get_channel= qtnf_get_channel
+   .get_channel= qtnf_get_channel,
+   .channel_switch = qtnf_channel_switch
 };
 
 static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in,
@@ -981,6 +1035,7 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, 
struct qtnf_wmac *mac)
 
wiphy->iface_combinations = iface_comb;
wiphy->n_iface_combinations = 1;
+   wiphy->max_num_csa_counters = 2;
 
/* Initialize cipher suits */
wiphy->cipher_suites = qtnf_cipher_suites;
@@ -988,7 +1043,8 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, 
struct qtnf_wmac *mac)
wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
-   WIPHY_FLAG_AP_UAPSD;
+   WIPHY_FLAG_AP_UAPSD |
+   WIPHY_FLAG_HAS_CHANNEL_SWITCH;
 
wiphy->probe_resp_offload = NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2;
diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c 
b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index a3c3dddb194c..524269d2c30c 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -2283,3 +2283,58 @@ int qtnf_cmd_get_chan_stats(struct 

[PATCH v2 09/12] qtnfmac: implement scan timeout

2017-07-27 Thread Sergey Matyukevich
Userspace tools may hang on scan in the case when scan completion event
is not returned by firmware. This patch implements the scan timeout
to avoid such situation.

Signed-off-by: Igor Mitsyanko 
Signed-off-by: Sergey Matyukevich 
Signed-off-by: Avinash Patil 
---
 drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 22 ++
 drivers/net/wireless/quantenna/qtnfmac/cfg80211.h |  4 
 drivers/net/wireless/quantenna/qtnfmac/core.c |  2 ++
 drivers/net/wireless/quantenna/qtnfmac/core.h |  3 +++
 drivers/net/wireless/quantenna/qtnfmac/event.c|  2 ++
 5 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c 
b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index ac8fdc1db482..856fa6e8327e 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -579,19 +579,33 @@ qtnf_del_station(struct wiphy *wiphy, struct net_device 
*dev,
return ret;
 }
 
+static void qtnf_scan_timeout(unsigned long data)
+{
+   struct qtnf_wmac *mac = (struct qtnf_wmac *)data;
+
+   pr_warn("mac%d scan timed out\n", mac->macid);
+   qtnf_scan_done(mac, true);
+}
+
 static int
 qtnf_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
 {
struct qtnf_wmac *mac = wiphy_priv(wiphy);
-   int ret;
 
mac->scan_req = request;
 
-   ret = qtnf_cmd_send_scan(mac);
-   if (ret)
+   if (qtnf_cmd_send_scan(mac)) {
pr_err("MAC%u: failed to start scan\n", mac->macid);
+   mac->scan_req = NULL;
+   return -EFAULT;
+   }
 
-   return ret;
+   mac->scan_timeout.data = (unsigned long)mac;
+   mac->scan_timeout.function = qtnf_scan_timeout;
+   mod_timer(>scan_timeout,
+ jiffies + QTNF_SCAN_TIMEOUT_SEC * HZ);
+
+   return 0;
 }
 
 static int
diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.h 
b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.h
index 5bd33124a7c8..6a4af52522b8 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.h
@@ -34,10 +34,14 @@ static inline void qtnf_scan_done(struct qtnf_wmac *mac, 
bool aborted)
.aborted = aborted,
};
 
+   mutex_lock(>mac_lock);
+
if (mac->scan_req) {
cfg80211_scan_done(mac->scan_req, );
mac->scan_req = NULL;
}
+
+   mutex_unlock(>mac_lock);
 }
 
 #endif /* _QTN_FMAC_CFG80211_H_ */
diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c 
b/drivers/net/wireless/quantenna/qtnfmac/core.c
index 17d17e332a8b..5e60180482d1 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.c
@@ -288,6 +288,8 @@ static struct qtnf_wmac *qtnf_core_mac_alloc(struct 
qtnf_bus *bus,
mac->iflist[i].mac = mac;
mac->iflist[i].vifid = i;
qtnf_sta_list_init(>iflist[i].sta_list);
+   mutex_init(>mac_lock);
+   init_timer(>scan_timeout);
}
 
qtnf_mac_init_primary_intf(mac);
diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.h 
b/drivers/net/wireless/quantenna/qtnfmac/core.h
index 099aad76afeb..066fcd1095a0 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.h
@@ -46,6 +46,7 @@
 #define QTNF_MAX_EVENT_QUEUE_LEN   255
 #define QTNF_DEFAULT_BG_SCAN_PERIOD300
 #define QTNF_MAX_BG_SCAN_PERIOD0x
+#define QTNF_SCAN_TIMEOUT_SEC  15
 
 #define QTNF_DEF_BSS_PRIORITY  0
 #define QTNF_DEF_WDOG_TIMEOUT  5
@@ -147,6 +148,8 @@ struct qtnf_wmac {
struct cfg80211_scan_request *scan_req;
struct cfg80211_chan_def chandef;
struct cfg80211_chan_def csa_chandef;
+   struct mutex mac_lock;  /* lock during wmac speicific ops */
+   struct timer_list scan_timeout;
 };
 
 struct qtnf_hw_info {
diff --git a/drivers/net/wireless/quantenna/qtnfmac/event.c 
b/drivers/net/wireless/quantenna/qtnfmac/event.c
index 43d2e7fd6e02..0fc2814eafad 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/event.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/event.c
@@ -345,6 +345,8 @@ qtnf_event_handle_scan_complete(struct qtnf_wmac *mac,
return -EINVAL;
}
 
+   if (timer_pending(>scan_timeout))
+   del_timer_sync(>scan_timeout);
qtnf_scan_done(mac, le32_to_cpu(status->flags) & QLINK_SCAN_ABORTED);
 
return 0;
-- 
2.11.0



[PATCH v2 10/12] qtnfmac: fix handling of iftype mask reported by firmware

2017-07-27 Thread Sergey Matyukevich
Firmware sends supported interface type rather than mask. As a result,
types field of ieee80211_iface_limit structure may end up having
multiple iftype bits set. This leads to WARN_ON from
wiphy_verify_combinations.

Signed-off-by: Igor Mitsyanko 
Signed-off-by: Sergey Matyukevich 
Signed-off-by: Avinash Patil 
---
 drivers/net/wireless/quantenna/qtnfmac/commands.c  |  9 +
 drivers/net/wireless/quantenna/qtnfmac/qlink.h |  2 +-
 .../net/wireless/quantenna/qtnfmac/qlink_util.c| 23 --
 .../net/wireless/quantenna/qtnfmac/qlink_util.h|  2 +-
 4 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c 
b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index 524269d2c30c..94656106b496 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -989,7 +989,7 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac 
*mac,
struct ieee80211_iface_limit *limits = NULL;
const struct qlink_iface_limit *limit_record;
size_t record_count = 0, rec = 0;
-   u16 tlv_type, tlv_value_len, mask;
+   u16 tlv_type, tlv_value_len;
struct qlink_iface_comb_num *comb;
size_t tlv_full_len;
const struct qlink_tlv_hdr *tlv;
@@ -1042,9 +1042,10 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac 
*mac,
 
limit_record = (void *)tlv->val;
limits[rec].max = le16_to_cpu(limit_record->max_num);
-   mask = le16_to_cpu(limit_record->type_mask);
-   limits[rec].types = qlink_iface_type_mask_to_nl(mask);
-   /* only AP and STA modes are supported */
+   limits[rec].types = qlink_iface_type_to_nl_mask(
+   le16_to_cpu(limit_record->type));
+
+   /* supported modes: STA, AP */
limits[rec].types &= BIT(NL80211_IFTYPE_AP) |
 BIT(NL80211_IFTYPE_STATION);
 
diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h 
b/drivers/net/wireless/quantenna/qtnfmac/qlink.h
index c529cc1994b4..ec5126362494 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h
@@ -873,7 +873,7 @@ struct qlink_tlv_hdr {
 
 struct qlink_iface_limit {
__le16 max_num;
-   __le16 type_mask;
+   __le16 type;
 } __packed;
 
 struct qlink_iface_comb_num {
diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.c 
b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.c
index 49ae652ad9a3..22fa631d692d 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.c
@@ -17,24 +17,27 @@
 
 #include "qlink_util.h"
 
-u16 qlink_iface_type_mask_to_nl(u16 qlink_mask)
+u16 qlink_iface_type_to_nl_mask(u16 qlink_type)
 {
u16 result = 0;
 
-   if (qlink_mask & QLINK_IFTYPE_AP)
+   switch (qlink_type) {
+   case QLINK_IFTYPE_AP:
result |= BIT(NL80211_IFTYPE_AP);
-
-   if (qlink_mask & QLINK_IFTYPE_STATION)
+   break;
+   case QLINK_IFTYPE_STATION:
result |= BIT(NL80211_IFTYPE_STATION);
-
-   if (qlink_mask & QLINK_IFTYPE_ADHOC)
+   break;
+   case QLINK_IFTYPE_ADHOC:
result |= BIT(NL80211_IFTYPE_ADHOC);
-
-   if (qlink_mask & QLINK_IFTYPE_MONITOR)
+   break;
+   case QLINK_IFTYPE_MONITOR:
result |= BIT(NL80211_IFTYPE_MONITOR);
-
-   if (qlink_mask & QLINK_IFTYPE_WDS)
+   break;
+   case QLINK_IFTYPE_WDS:
result |= BIT(NL80211_IFTYPE_WDS);
+   break;
+   }
 
return result;
 }
diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h 
b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h
index 90d7d09a6c63..c9e882a3a991 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h
@@ -68,7 +68,7 @@ static inline void qtnf_cmd_skb_put_tlv_u16(struct sk_buff 
*skb,
memcpy(hdr->val, , sizeof(tmp));
 }
 
-u16 qlink_iface_type_mask_to_nl(u16 qlink_mask);
+u16 qlink_iface_type_to_nl_mask(u16 qlink_type);
 u8 qlink_chan_width_mask_to_nl(u16 qlink_mask);
 
 #endif /* _QTN_FMAC_QLINK_UTIL_H_ */
-- 
2.11.0



[PATCH v2 07/12] qtnfmac: move current channel info from vif to mac

2017-07-27 Thread Sergey Matyukevich
Wireless cfg80211 core supplies channel settings in cfg80211_ap_settings
structure for each BSS in multiple BSS configuration. On the other hand
all the virtual interfaces on one radio are using the same PHY settings
including channel.

Move chandef structure from vif to mac structure in order to mantain
the only instance of cfg80211_chan_def structure in qtnf_wmac
rather than its multiple copies in qtnf_vif.

Signed-off-by: Igor Mitsyanko 
Signed-off-by: Sergey Matyukevich 
Signed-off-by: Avinash Patil 
---
 drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 38 +++
 drivers/net/wireless/quantenna/qtnfmac/commands.c |  6 ++--
 drivers/net/wireless/quantenna/qtnfmac/core.h |  2 +-
 3 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c 
b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index ef8089c163bc..d47050934f00 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -266,11 +266,19 @@ static int qtnf_start_ap(struct wiphy *wiphy, struct 
net_device *dev,
 struct cfg80211_ap_settings *settings)
 {
struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
+   struct qtnf_wmac *mac = wiphy_priv(wiphy);
struct qtnf_bss_config *bss_cfg;
int ret;
 
-   bss_cfg = >bss_cfg;
+   if (!cfg80211_chandef_identical(>chandef, >chandef)) {
+   memcpy(>chandef, >chandef, sizeof(mac->chandef));
+   if (vif->vifid != 0)
+   pr_warn("%s: unexpected chan %u (%u MHz)\n", dev->name,
+   settings->chandef.chan->hw_value,
+   settings->chandef.chan->center_freq);
+   }
 
+   bss_cfg = >bss_cfg;
memset(bss_cfg, 0, sizeof(*bss_cfg));
 
bss_cfg->bcn_period = settings->beacon_interval;
@@ -281,8 +289,6 @@ static int qtnf_start_ap(struct wiphy *wiphy, struct 
net_device *dev,
bss_cfg->ssid_len = settings->ssid_len;
memcpy(_cfg->ssid, settings->ssid, bss_cfg->ssid_len);
 
-   memcpy(_cfg->chandef, >chandef,
-  sizeof(struct cfg80211_chan_def));
memcpy(_cfg->crypto, >crypto,
   sizeof(struct cfg80211_crypto_settings));
 
@@ -593,6 +599,7 @@ qtnf_connect(struct wiphy *wiphy, struct net_device *dev,
 struct cfg80211_connect_params *sme)
 {
struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
+   struct qtnf_wmac *mac = wiphy_priv(wiphy);
struct cfg80211_chan_def chandef;
struct qtnf_bss_config *bss_cfg;
int ret;
@@ -615,7 +622,7 @@ qtnf_connect(struct wiphy *wiphy, struct net_device *dev,
cfg80211_chandef_create(, sme->channel,
NL80211_CHAN_HT20);
 
-   memcpy(_cfg->chandef, , sizeof(bss_cfg->chandef));
+   memcpy(>chandef, , sizeof(mac->chandef));
}
 
bss_cfg->ssid_len = sme->ssid_len;
@@ -695,14 +702,14 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device 
*dev,
 {
struct qtnf_wmac *mac = wiphy_priv(wiphy);
struct ieee80211_supported_band *sband;
-   struct cfg80211_chan_def *bss_chandef;
+   struct cfg80211_chan_def *chandef;
struct ieee80211_channel *chan;
struct qtnf_chan_stats stats;
struct qtnf_vif *vif;
int ret;
 
vif = qtnf_netdev_get_priv(dev);
-   bss_chandef = >bss_cfg.chandef;
+   chandef = >chandef;
 
sband = wiphy->bands[NL80211_BAND_2GHZ];
if (sband && idx >= sband->n_channels) {
@@ -722,9 +729,10 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device 
*dev,
survey->channel = chan;
survey->filled = 0x0;
 
-   if (bss_chandef->chan)
-   if (chan->hw_value == bss_chandef->chan->hw_value)
-   survey->filled |= SURVEY_INFO_IN_USE;
+   if (chandef->chan) {
+   if (chan->hw_value == chandef->chan->hw_value)
+   survey->filled = SURVEY_INFO_IN_USE;
+   }
 
ret = qtnf_cmd_get_chan_stats(mac, chan->hw_value, );
switch (ret) {
@@ -736,7 +744,7 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device 
*dev,
break;
}
 
-   survey->filled = SURVEY_INFO_TIME |
+   survey->filled |= SURVEY_INFO_TIME |
 SURVEY_INFO_TIME_SCAN |
 SURVEY_INFO_TIME_BUSY |
 SURVEY_INFO_TIME_RX |
@@ -768,15 +776,14 @@ static int
 qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
 struct cfg80211_chan_def *chandef)
 {
+   struct qtnf_wmac *mac = wiphy_priv(wiphy);
struct net_device *ndev = wdev->netdev;
-   struct qtnf_bss_config 

[PATCH v2 02/12] qtnfmac: regulatory configuration for self-managed setup

2017-07-27 Thread Sergey Matyukevich
Regdomain information needs to be registered with cfg80211
for devices with REGULATORY_WIPHY_SELF_MANAGED flag set.

Signed-off-by: Igor Mitsyanko 
Signed-off-by: Sergey Matyukevich 
Signed-off-by: Avinash Patil 
---
 drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c 
b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index 7f70b0aae069..e288b1d4432a 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -873,6 +873,15 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, 
struct qtnf_wmac *mac)
}
 
ret = wiphy_register(wiphy);
+   if (ret < 0)
+   goto out;
+
+   if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED)
+   ret = regulatory_set_wiphy_regd(wiphy, hw_info->rd);
+   else if (isalpha(hw_info->rd->alpha2[0]) &&
+isalpha(hw_info->rd->alpha2[1]))
+   ret = regulatory_hint(wiphy, hw_info->rd->alpha2);
+
 out:
if (ret) {
kfree(iface_comb);
-- 
2.11.0



[PATCH v2 06/12] qtnfmac: fix station leave reason endianness

2017-07-27 Thread Sergey Matyukevich
Use proper endianness conversion for client station leave reason.

Signed-off-by: Igor Mitsyanko 
Signed-off-by: Sergey Matyukevich 
Signed-off-by: Avinash Patil 
---
 drivers/net/wireless/quantenna/qtnfmac/event.c | 4 ++--
 drivers/net/wireless/quantenna/qtnfmac/qlink.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/event.c 
b/drivers/net/wireless/quantenna/qtnfmac/event.c
index 9b61e9a83670..00570de918e6 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/event.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/event.c
@@ -211,8 +211,8 @@ qtnf_event_handle_bss_leave(struct qtnf_vif *vif,
 
pr_debug("VIF%u.%u: disconnected\n", vif->mac->macid, vif->vifid);
 
-   cfg80211_disconnected(vif->netdev, leave_info->reason, NULL, 0, 0,
- GFP_KERNEL);
+   cfg80211_disconnected(vif->netdev, le16_to_cpu(leave_info->reason),
+ NULL, 0, 0, GFP_KERNEL);
 
vif->sta_state = QTNF_STA_DISCONNECTED;
netif_carrier_off(vif->netdev);
diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h 
b/drivers/net/wireless/quantenna/qtnfmac/qlink.h
index 6c6940b503a4..5c2d8f0abd7f 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h
@@ -733,7 +733,7 @@ struct qlink_event_bss_join {
  */
 struct qlink_event_bss_leave {
struct qlink_event ehdr;
-   u16 reason;
+   __le16 reason;
 } __packed;
 
 enum qlink_rxmgmt_flags {
-- 
2.11.0



[PATCH v2 05/12] qtnfmac: implement reporting current channel

2017-07-27 Thread Sergey Matyukevich
Implement current channel reporting functionality. Current operating
channel can be obtained either directly using cfg80211 get_channel
callback or from stats reported by cfg80211 survey_dump callback.

Signed-off-by: Igor Mitsyanko 
Signed-off-by: Sergey Matyukevich 
Signed-off-by: Avinash Patil 
---
 drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 62 ++-
 drivers/net/wireless/quantenna/qtnfmac/commands.c |  2 +-
 drivers/net/wireless/quantenna/qtnfmac/qlink.h|  2 +-
 3 files changed, 62 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c 
b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index 23f180b7d43c..ef8089c163bc 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -593,6 +593,7 @@ qtnf_connect(struct wiphy *wiphy, struct net_device *dev,
 struct cfg80211_connect_params *sme)
 {
struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
+   struct cfg80211_chan_def chandef;
struct qtnf_bss_config *bss_cfg;
int ret;
 
@@ -605,9 +606,20 @@ qtnf_connect(struct wiphy *wiphy, struct net_device *dev,
bss_cfg = >bss_cfg;
memset(bss_cfg, 0, sizeof(*bss_cfg));
 
+   if (sme->channel) {
+   /* FIXME: need to set proper nl80211_channel_type value */
+   cfg80211_chandef_create(, sme->channel,
+   NL80211_CHAN_HT20);
+   /* fall-back to minimal safe chandef description */
+   if (!cfg80211_chandef_valid())
+   cfg80211_chandef_create(, sme->channel,
+   NL80211_CHAN_HT20);
+
+   memcpy(_cfg->chandef, , sizeof(bss_cfg->chandef));
+   }
+
bss_cfg->ssid_len = sme->ssid_len;
memcpy(_cfg->ssid, sme->ssid, bss_cfg->ssid_len);
-   bss_cfg->chandef.chan = sme->channel;
bss_cfg->auth_type = sme->auth_type;
bss_cfg->privacy = sme->privacy;
bss_cfg->mfp = sme->mfp;
@@ -683,10 +695,15 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device 
*dev,
 {
struct qtnf_wmac *mac = wiphy_priv(wiphy);
struct ieee80211_supported_band *sband;
+   struct cfg80211_chan_def *bss_chandef;
struct ieee80211_channel *chan;
struct qtnf_chan_stats stats;
+   struct qtnf_vif *vif;
int ret;
 
+   vif = qtnf_netdev_get_priv(dev);
+   bss_chandef = >bss_cfg.chandef;
+
sband = wiphy->bands[NL80211_BAND_2GHZ];
if (sband && idx >= sband->n_channels) {
idx -= sband->n_channels;
@@ -705,6 +722,10 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device 
*dev,
survey->channel = chan;
survey->filled = 0x0;
 
+   if (bss_chandef->chan)
+   if (chan->hw_value == bss_chandef->chan->hw_value)
+   survey->filled |= SURVEY_INFO_IN_USE;
+
ret = qtnf_cmd_get_chan_stats(mac, chan->hw_value, );
switch (ret) {
case 0:
@@ -743,6 +764,42 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device 
*dev,
return ret;
 }
 
+static int
+qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
+struct cfg80211_chan_def *chandef)
+{
+   struct net_device *ndev = wdev->netdev;
+   struct qtnf_bss_config *bss_cfg;
+   struct qtnf_vif *vif;
+
+   if (!ndev)
+   return -ENODEV;
+
+   vif = qtnf_netdev_get_priv(wdev->netdev);
+   bss_cfg = >bss_cfg;
+
+   switch (vif->wdev.iftype) {
+   case NL80211_IFTYPE_STATION:
+   if (vif->sta_state == QTNF_STA_DISCONNECTED) {
+   pr_warn("%s: STA disconnected\n", ndev->name);
+   return -ENODATA;
+   }
+   break;
+   case NL80211_IFTYPE_AP:
+   if (!(vif->bss_status & QTNF_STATE_AP_START)) {
+   pr_warn("%s: AP not started\n", ndev->name);
+   return -ENODATA;
+   }
+   break;
+   default:
+   pr_err("unsupported vif type (%d)\n", vif->wdev.iftype);
+   return -ENODATA;
+   }
+
+   memcpy(chandef, _cfg->chandef, sizeof(*chandef));
+   return 0;
+}
+
 static struct cfg80211_ops qtn_cfg80211_ops = {
.add_virtual_intf   = qtnf_add_virtual_intf,
.change_virtual_intf= qtnf_change_virtual_intf,
@@ -764,7 +821,8 @@ static struct cfg80211_ops qtn_cfg80211_ops = {
.scan   = qtnf_scan,
.connect= qtnf_connect,
.disconnect = qtnf_disconnect,
-   .dump_survey= qtnf_dump_survey
+   .dump_survey= qtnf_dump_survey,
+   .get_channel= qtnf_get_channel
 };
 
 static void 

[PATCH v2 01/12] qtnfmac: updates for regulatory support

2017-07-27 Thread Sergey Matyukevich
On startup driver obtains regulatory rules from firmware and
enables them during wiphy registration. Later on regulatory
domain change can be requested by host. In this case firmware
is notified about the upcoming changes. If the change is valid,
then firmware updates hardware channel configuration and host
driver receives updated channel info for each band.

Signed-off-by: Igor Mitsyanko 
Signed-off-by: Sergey Matyukevich 
Signed-off-by: Avinash Patil 
---
 drivers/net/wireless/quantenna/qtnfmac/cfg80211.c |  81 ++-
 drivers/net/wireless/quantenna/qtnfmac/commands.c | 278 ++
 drivers/net/wireless/quantenna/qtnfmac/commands.h |   1 +
 drivers/net/wireless/quantenna/qtnfmac/core.c |   3 +
 drivers/net/wireless/quantenna/qtnfmac/core.h |   7 +-
 drivers/net/wireless/quantenna/qtnfmac/qlink.h| 126 +-
 6 files changed, 388 insertions(+), 108 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c 
b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index e3c090008125..7f70b0aae069 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -700,66 +700,43 @@ static struct cfg80211_ops qtn_cfg80211_ops = {
.disconnect = qtnf_disconnect
 };
 
-static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy,
+static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in,
   struct regulatory_request *req)
 {
-   struct qtnf_wmac *mac = wiphy_priv(wiphy);
-   struct qtnf_bus *bus;
-   struct qtnf_vif *vif;
-   struct qtnf_wmac *chan_mac;
-   int i;
+   struct qtnf_wmac *mac = wiphy_priv(wiphy_in);
+   struct qtnf_bus *bus = mac->bus;
+   struct wiphy *wiphy;
+   unsigned int mac_idx;
enum nl80211_band band;
-
-   bus = mac->bus;
+   int ret;
 
pr_debug("MAC%u: initiator=%d alpha=%c%c\n", mac->macid, req->initiator,
 req->alpha2[0], req->alpha2[1]);
 
-   vif = qtnf_mac_get_base_vif(mac);
-   if (!vif) {
-   pr_err("MAC%u: primary VIF is not configured\n", mac->macid);
-   return;
-   }
-
-   /* ignore non-ISO3166 country codes */
-   for (i = 0; i < sizeof(req->alpha2); i++) {
-   if (req->alpha2[i] < 'A' || req->alpha2[i] > 'Z') {
-   pr_err("MAC%u: not an ISO3166 code\n", mac->macid);
-   return;
-   }
-   }
-   if (!strncasecmp(req->alpha2, bus->hw_info.alpha2_code,
-sizeof(req->alpha2))) {
-   pr_warn("MAC%u: unchanged country code\n", mac->macid);
-   return;
-   }
-
-   if (qtnf_cmd_send_regulatory_config(mac, req->alpha2)) {
-   pr_err("MAC%u: failed to configure regulatory\n", mac->macid);
+   ret = qtnf_cmd_reg_notify(bus, req);
+   if (ret) {
+   if (ret != -EOPNOTSUPP && ret != -EALREADY)
+   pr_err("failed to update reg domain to %c%c\n",
+  req->alpha2[0], req->alpha2[1]);
return;
}
 
-   for (i = 0; i < bus->hw_info.num_mac; i++) {
-   chan_mac = bus->mac[i];
-
-   if (!chan_mac)
+   for (mac_idx = 0; mac_idx < QTNF_MAX_MAC; ++mac_idx) {
+   if (!(bus->hw_info.mac_bitmap & (1 << mac_idx)))
continue;
 
-   if (!(bus->hw_info.mac_bitmap & BIT(i)))
-   continue;
+   mac = bus->mac[mac_idx];
+   wiphy = priv_to_wiphy(mac);
 
for (band = 0; band < NUM_NL80211_BANDS; ++band) {
if (!wiphy->bands[band])
continue;
 
-   if (qtnf_cmd_get_mac_chan_info(chan_mac,
-  wiphy->bands[band])) {
-   pr_err("MAC%u: can't get channel info\n",
-  chan_mac->macid);
-   qtnf_core_detach(bus);
-
-   return;
-   }
+   ret = qtnf_cmd_get_mac_chan_info(mac,
+wiphy->bands[band]);
+   if (ret)
+   pr_err("failed to get chan info for mac %u band 
%u\n",
+  mac_idx, band);
}
}
 }
@@ -844,10 +821,8 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, 
struct qtnf_wmac *mac)
}
 
iface_comb = kzalloc(sizeof(*iface_comb), GFP_KERNEL);
-   if (!iface_comb) {
-   ret = -ENOMEM;
-   goto out;
-   }
+   if (!iface_comb)
+   return -ENOMEM;
 
ret = 

[PATCH v2 03/12] qtnfmac: add missing bus lock

2017-07-27 Thread Sergey Matyukevich
Add missing bus lock into get_mac_chan_info command.

Signed-off-by: Igor Mitsyanko 
Signed-off-by: Sergey Matyukevich 
Signed-off-by: Avinash Patil 
---
 drivers/net/wireless/quantenna/qtnfmac/commands.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c 
b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index 8be96f02888f..f5a294f3c2a4 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -1442,6 +1442,9 @@ int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac,
 
cmd = (struct qlink_cmd_chans_info_get *)cmd_skb->data;
cmd->band = qband;
+
+   qtnf_bus_lock(mac->bus);
+
ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, _skb, _code,
   sizeof(*resp), _len);
 
@@ -1465,6 +1468,7 @@ int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac,
ret = qtnf_cmd_resp_fill_channels_info(band, resp, info_len);
 
 out:
+   qtnf_bus_unlock(mac->bus);
consume_skb(resp_skb);
 
return ret;
-- 
2.11.0



[PATCH v2 04/12] qtnfmac: implement cfg80211 dump_survey handler

2017-07-27 Thread Sergey Matyukevich
This patch implements cfg80211 dump_survey handler enabling
per-channel survey data reports.

Signed-off-by: Igor Mitsyanko 
Signed-off-by: Sergey Matyukevich 
Signed-off-by: Avinash Patil 
---
 drivers/net/wireless/quantenna/qtnfmac/cfg80211.c |  69 +-
 drivers/net/wireless/quantenna/qtnfmac/commands.c | 107 ++
 drivers/net/wireless/quantenna/qtnfmac/commands.h |   2 +
 drivers/net/wireless/quantenna/qtnfmac/core.h |   9 ++
 drivers/net/wireless/quantenna/qtnfmac/qlink.h|  31 +++
 5 files changed, 217 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c 
b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index e288b1d4432a..23f180b7d43c 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -677,6 +677,72 @@ qtnf_disconnect(struct wiphy *wiphy, struct net_device 
*dev,
return 0;
 }
 
+static int
+qtnf_dump_survey(struct wiphy *wiphy, struct net_device *dev,
+int idx, struct survey_info *survey)
+{
+   struct qtnf_wmac *mac = wiphy_priv(wiphy);
+   struct ieee80211_supported_band *sband;
+   struct ieee80211_channel *chan;
+   struct qtnf_chan_stats stats;
+   int ret;
+
+   sband = wiphy->bands[NL80211_BAND_2GHZ];
+   if (sband && idx >= sband->n_channels) {
+   idx -= sband->n_channels;
+   sband = NULL;
+   }
+
+   if (!sband)
+   sband = wiphy->bands[NL80211_BAND_5GHZ];
+
+   if (!sband || idx >= sband->n_channels)
+   return -ENOENT;
+
+   chan = >channels[idx];
+   memset(, 0, sizeof(stats));
+
+   survey->channel = chan;
+   survey->filled = 0x0;
+
+   ret = qtnf_cmd_get_chan_stats(mac, chan->hw_value, );
+   switch (ret) {
+   case 0:
+   if (unlikely(stats.chan_num != chan->hw_value)) {
+   pr_err("received stats for channel %d instead of %d\n",
+  stats.chan_num, chan->hw_value);
+   ret = -EINVAL;
+   break;
+   }
+
+   survey->filled = SURVEY_INFO_TIME |
+SURVEY_INFO_TIME_SCAN |
+SURVEY_INFO_TIME_BUSY |
+SURVEY_INFO_TIME_RX |
+SURVEY_INFO_TIME_TX |
+SURVEY_INFO_NOISE_DBM;
+
+   survey->time_scan = stats.cca_try;
+   survey->time = stats.cca_try;
+   survey->time_tx = stats.cca_tx;
+   survey->time_rx = stats.cca_rx;
+   survey->time_busy = stats.cca_busy;
+   survey->noise = stats.chan_noise;
+   break;
+   case -ENOENT:
+   pr_debug("no stats for channel %u\n", chan->hw_value);
+   ret = 0;
+   break;
+   default:
+   pr_debug("failed to get chan(%d) stats from card\n",
+chan->hw_value);
+   ret = -EINVAL;
+   break;
+   }
+
+   return ret;
+}
+
 static struct cfg80211_ops qtn_cfg80211_ops = {
.add_virtual_intf   = qtnf_add_virtual_intf,
.change_virtual_intf= qtnf_change_virtual_intf,
@@ -697,7 +763,8 @@ static struct cfg80211_ops qtn_cfg80211_ops = {
.set_default_mgmt_key   = qtnf_set_default_mgmt_key,
.scan   = qtnf_scan,
.connect= qtnf_connect,
-   .disconnect = qtnf_disconnect
+   .disconnect = qtnf_disconnect,
+   .dump_survey= qtnf_dump_survey
 };
 
 static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in,
diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c 
b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index f5a294f3c2a4..a1ce12082e10 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -1333,6 +1333,62 @@ static int qtnf_cmd_resp_proc_phy_params(struct 
qtnf_wmac *mac,
return 0;
 }
 
+static int
+qtnf_cmd_resp_proc_chan_stat_info(struct qtnf_chan_stats *stats,
+ const u8 *payload, size_t payload_len)
+{
+   struct qlink_chan_stats *qlink_stats;
+   const struct qlink_tlv_hdr *tlv;
+   size_t tlv_full_len;
+   u16 tlv_value_len;
+   u16 tlv_type;
+
+   tlv = (struct qlink_tlv_hdr *)payload;
+   while (payload_len >= sizeof(struct qlink_tlv_hdr)) {
+   tlv_type = le16_to_cpu(tlv->type);
+   tlv_value_len = le16_to_cpu(tlv->len);
+   tlv_full_len = tlv_value_len + sizeof(struct qlink_tlv_hdr);
+   if (tlv_full_len > payload_len) {
+   pr_warn("malformed TLV 0x%.2X; LEN: %u\n",
+

[PATCH v2] qtnfmac: add more features to driver

2017-07-27 Thread Sergey Matyukevich
This patch series adds more features and fixes to qtnfmac driver:
- regulatory support updates
- get_channel handler
- dump_survey handler
- channel_switch handler
- update message structures to prepare for adding AP_VLAN
- cleanup and fixes

Signed-off-by: Igor Mitsyanko 
Signed-off-by: Sergey Matyukevich 
Signed-off-by: Avinash Patil 

v1 -> v2
- remove AP_VLAN support: to be submitted separately as RFC
- split patches with multiple changes into a smaller chunks

cfg80211.c   |  315 ++
cfg80211.h   |4 
commands.c   |  486 ---
commands.h   |5 
core.c   |5 
core.h   |   27 ++-
event.c  |   67 +++-
qlink.h  |  202 ++--
qlink_util.c |   26 +--
qlink_util.h |   10 -
10 files changed, 992 insertions(+), 155 deletions(-)


[PATCH] wl3501_cs: fix spelling mistake: "Insupported" -> "Unsupported"

2017-07-27 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in printk message

Signed-off-by: Colin Ian King 
---
 drivers/net/wireless/wl3501_cs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index acec0d9ec422..da62220b9c01 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -965,7 +965,7 @@ static inline void wl3501_md_ind_interrupt(struct 
net_device *dev,
, sizeof(addr4));
if (!(addr4[0] == 0xAA && addr4[1] == 0xAA &&
  addr4[2] == 0x03 && addr4[4] == 0x00)) {
-   printk(KERN_INFO "Insupported packet type!\n");
+   printk(KERN_INFO "Unsupported packet type!\n");
return;
}
pkt_len = sig.size + 12 - 24 - 4 - 6;
-- 
2.11.0



[PATCH] mwifiex: fix spelling mistake: "Insuffient" -> "Insufficient"

2017-07-27 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in mwifiex_dbg debug message

Signed-off-by: Colin Ian King 
---
 drivers/net/wireless/marvell/mwifiex/tdls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/tdls.c 
b/drivers/net/wireless/marvell/mwifiex/tdls.c
index 39cd677d4159..e76af2866a19 100644
--- a/drivers/net/wireless/marvell/mwifiex/tdls.c
+++ b/drivers/net/wireless/marvell/mwifiex/tdls.c
@@ -130,7 +130,7 @@ mwifiex_tdls_append_rates_ie(struct mwifiex_private *priv,
 
if (skb_tailroom(skb) < rates_size + 4) {
mwifiex_dbg(priv->adapter, ERROR,
-   "Insuffient space while adding rates\n");
+   "Insufficient space while adding rates\n");
return -ENOMEM;
}
 
-- 
2.11.0



[PATCH] staging: wilc1000: fix spelling mistake: "Iinitialization" -> "initialization"

2017-07-27 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in netdev_err message

Signed-off-by: Colin Ian King 
---
 drivers/staging/wilc1000/linux_wlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 1266dcccad30..119f3459b5bb 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -813,7 +813,7 @@ int wilc1000_wlan_init(struct net_device *dev, struct 
wilc_vif *vif)
wilc_wlan_cleanup(dev);
 _fail_locks_:
wlan_deinit_locks(dev);
-   netdev_err(dev, "WLAN Iinitialization FAILED\n");
+   netdev_err(dev, "WLAN initialization FAILED\n");
} else {
netdev_dbg(dev, "wilc1000 already initialized\n");
}
-- 
2.11.0



[PATCH net] intersil/hostap: Fix outdated comment about dev->destructor

2017-07-27 Thread Stefano Brivio
After commit cf124db566e6 ("net: Fix inconsistent teardown and
release of private netdev state."), setting
'dev->needs_free_netdev' ensures device data is released, and
'dev->destructor' is not used anymore.

Fixes: cf124db566e6 ("net: Fix inconsistent teardown and release of private 
netdev state.")
Signed-off-by: Stefano Brivio 
---
Despite checkpatch.pl warning against unnecessary changes, this
outdated comment might lead to confusion -- making this change
actually necessary, perhaps.

 drivers/net/wireless/intersil/hostap/hostap_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intersil/hostap/hostap_main.c 
b/drivers/net/wireless/intersil/hostap/hostap_main.c
index a3c066f90afc..012930d35434 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_main.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_main.c
@@ -125,8 +125,8 @@ void hostap_remove_interface(struct net_device *dev, int 
rtnl_locked,
else
unregister_netdev(dev);
 
-   /* dev->destructor = free_netdev() will free the device data, including
-* private data, when removing the device */
+   /* 'dev->needs_free_netdev = true' implies device data, including
+* private data, will be freed when the device is removed */
 }
 
 
-- 
2.9.4



Re: [for-4.13] brcmfmac: fix memleak due to calling brcmf_sdiod_sgtable_alloc() twice

2017-07-27 Thread Kalle Valo
Arend Van Spriel  wrote:

> Due to a bugfix in wireless tree and the commit mentioned below a merge
> was needed which went haywire. So the submitted change resulted in the
> function brcmf_sdiod_sgtable_alloc() being called twice during the probe
> thus leaking the memory of the first call.
> 
> Cc: sta...@vger.kernel.org # 4.6.x
> Fixes: 4d7928959832 ("brcmfmac: switch to new platform data")
> Reported-by: Stefan Wahren 
> Tested-by: Stefan Wahren 
> Reviewed-by: Hante Meuleman 
> Signed-off-by: Arend van Spriel 

Patch applied to wireless-drivers.git, thanks.

5f5d03143de5 brcmfmac: fix memleak due to calling brcmf_sdiod_sgtable_alloc() 
twice

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

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



Re: [for-v4.13,V4] brcmfmac: Don't grow SKB by negative size

2017-07-27 Thread Kalle Valo
Daniel Stone  wrote:

> The commit to rework the headroom check in start_xmit() now calls
> pxskb_expand_head() unconditionally if the header is CoW. Unfortunately,
> it does so with the delta between the extant headroom and the header
> length, which may be negative if there is already sufficient headroom.
> 
> pskb_expand_head() does allow for size being 0, in which case it just
> copies, so clamp the header delta to zero.
> 
> Opening Chrome (and all my tabs) on a PCIE device was enough to reliably
> hit this.
> 
> Fixes: 270a6c1f65fe ("brcmfmac: rework headroom check in .start_xmit()")
> Signed-off-by: Daniel Stone 
> Cc: Arend Van Spriel 
> Cc: James Hughes 
> Cc: Hante Meuleman 
> Cc: Pieter-Paul Giesberts 
> Cc: Franky Lin 
> Tested-by: Hans de Goede 

Patch applied to wireless-drivers.git, thanks.

58f36b4526ad brcmfmac: Don't grow SKB by negative size

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

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



Re: [net] wl1251: add a missing spin_lock_init()

2017-07-27 Thread Kalle Valo
Cong Wang  wrote:

> This fixes the following kernel warning:
> 
>   [ 5668.771453] BUG: spinlock bad magic on CPU#0, kworker/u2:3/9745
>   [ 5668.771850]  lock: 0xce63ef20, .magic: , .owner: /-1,
>   .owner_cpu: 0
>   [ 5668.772277] CPU: 0 PID: 9745 Comm: kworker/u2:3 Tainted: GW
>   4.12.0-03002-gec979a4-dirty #40
>   [ 5668.772796] Hardware name: Nokia RX-51 board
>   [ 5668.773071] Workqueue: phy1 wl1251_irq_work
>   [ 5668.773345] [] (unwind_backtrace) from []
>   (show_stack+0x10/0x14)
>   [ 5668.773803] [] (show_stack) from []
>   (do_raw_spin_lock+0x6c/0xa0)
>   [ 5668.774230] [] (do_raw_spin_lock) from []
>   (_raw_spin_lock_irqsave+0x10/0x18)
>   [ 5668.774658] [] (_raw_spin_lock_irqsave) from []
>   (wl1251_op_tx+0x38/0x5c)
>   [ 5668.775115] [] (wl1251_op_tx) from []
>   (ieee80211_tx_frags+0x188/0x1c0)
>   [ 5668.775543] [] (ieee80211_tx_frags) from []
>   (__ieee80211_tx+0x6c/0x130)
>   [ 5668.775970] [] (__ieee80211_tx) from []
>   (ieee80211_tx+0xdc/0x104)
>   [ 5668.776367] [] (ieee80211_tx) from []
>   (__ieee80211_subif_start_xmit+0x454/0x8c8)
>   [ 5668.776824] [] (__ieee80211_subif_start_xmit) from
>   [] (ieee80211_subif_start_xmit+0x30/0x2fc)
>   [ 5668.777343] [] (ieee80211_subif_start_xmit) from
>   [] (dev_hard_start_xmit+0x80/0x118)
>   ...
> 
> by adding the missing spin_lock_init().
> 
> Reported-by: Pavel Machek 
> Cc: Kalle Valo 
> Signed-off-by: Cong Wang 
> Acked-by: Pavel Machek 

Patch applied to wireless-drivers-next.git, thanks.

6e9aae179f29 wl1251: add a missing spin_lock_init()

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

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



Re: bcma: gpio: Correct number of GPIOs for BCM53573

2017-07-27 Thread Kalle Valo
Florian Fainelli  wrote:

> Broadcom BCM53573 SoCs actually have 32 GPIOs, and not 16.
> 
> Fixes: 3f37ec79dd21 ("bcma: support BCM53573 series of wireless SoCs")
> Signed-off-by: Florian Fainelli 

Patch applied to wireless-drivers-next.git, thanks.

459c35148ef6 bcma: gpio: Correct number of GPIOs for BCM53573

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

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



Re: [-next] rtlwifi: kfree entry until after entry->bssid has been accessed

2017-07-27 Thread Kalle Valo
Colin Ian King  wrote:

> From: Colin Ian King 
> 
> The current code kfree's entry and then dereferences it by accessing
> entry->bssid.  Avoid the dereference-after-free by moving the kfree
> after the access to entry->bssid.
> 
> Detected by CoverityScan, CID#1448600 ("Read from pointer after free")
> 
> Signed-off-by: Colin Ian King 

Patch applied to wireless-drivers-next.git, thanks.

d0116f6f7b30 rtlwifi: kfree entry until after entry->bssid has been accessed

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

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



Re: [PATCH v4 09/10] rtlwifi: use debugfs to debug.

2017-07-27 Thread Kalle Valo
Arend van Spriel  writes:

> On 7/27/2017 12:17 PM, Kalle Valo wrote:
>> Larry Finger  writes:
>>
>>> From: Ping-Ke Shih 
>>>
>>> Use debugfs to dump register and btcoex status.
>>
>> The title is useless and the commit log does not mention anything about
>> what files are added and to which location.
>>
>>> The kbuild test robot  suggested a change to use
>>> simple_open() instead of a local routine.
>>
>> This comment doesn't belong to commit log, it should be in the changelog.
>>
>>> +void rtl_debugfs_add_topdir(void)
>>> +{
>>> +   debugfs_topdir = debugfs_create_dir("rtlwifi", NULL);
>>> +}
>>> +
>>> +void rtl_debugfs_remove_topdir(void)
>>> +{
>>> +   debugfs_remove_recursive(debugfs_topdir);
>>> +}
>>
>> I'm surprised to see that rtlwifi creates it's own top level debugfs
>> directory and does not use wiphy->debugfsdir. So how is this supposed to
>> work when we have multiple rtlwifi devices on the same system?
>
> In brcmfmac we also have our own top level debugfs dir because we do
> wiphy_new()/wiphy_register() kinda late. To cover the multiple devices
> issue we create a subdir per device, ie.
> /sys/kernel/debug/brcmfmac/mmc0:0001:1/.

Yeah, that's fine. If rtlwifi does the same that's good but document
that in the commit log.

-- 
Kalle Valo


Re: [PATCH v4 09/10] rtlwifi: use debugfs to debug.

2017-07-27 Thread Arend van Spriel

On 7/27/2017 12:17 PM, Kalle Valo wrote:

Larry Finger  writes:


From: Ping-Ke Shih 

Use debugfs to dump register and btcoex status.


The title is useless and the commit log does not mention anything about
what files are added and to which location.


The kbuild test robot  suggested a change to use
simple_open() instead of a local routine.


This comment doesn't belong to commit log, it should be in the changelog.


+void rtl_debugfs_add_topdir(void)
+{
+   debugfs_topdir = debugfs_create_dir("rtlwifi", NULL);
+}
+
+void rtl_debugfs_remove_topdir(void)
+{
+   debugfs_remove_recursive(debugfs_topdir);
+}


I'm surprised to see that rtlwifi creates it's own top level debugfs
directory and does not use wiphy->debugfsdir. So how is this supposed to
work when we have multiple rtlwifi devices on the same system?


In brcmfmac we also have our own top level debugfs dir because we do 
wiphy_new()/wiphy_register() kinda late. To cover the multiple devices 
issue we create a subdir per device, ie. 
/sys/kernel/debug/brcmfmac/mmc0:0001:1/.


Regards,
Arend


Re: Patch v4: Clean up brcmfmac driver

2017-07-27 Thread Kalle Valo
Ian Molton  writes:

> On 27/07/17 07:17, Kalle Valo wrote:
>>> Here's a v4 of the cleanup patchset - checkpatch clean(er - I have purposely
>>> left some warnings unaddressed).
>>>
>>> I also dropped an accidental adjustment of a debug macro from v3.
>> Like I said already last time, please split the patchset into reasonable
>> sizes (and submit one patchset at a time). I will automatically drop
>> patchbombs like this.
>
> How many patches would you like at once?

Check my previous email:

https://lkml.kernel.org/r/87k23124gp@purkki.adurom.net

-- 
Kalle Valo


Re: [PATCH v4 09/10] rtlwifi: use debugfs to debug.

2017-07-27 Thread Kalle Valo
Larry Finger  writes:

> From: Ping-Ke Shih 
>
> Use debugfs to dump register and btcoex status. The kbuild test robot
>  suggested a change to use simple_open() instead of
> a local routine.
>
> Signed-off-by: Ping-Ke Shih 
> Signed-off-by: Larry Finger 
> Cc: Yan-Hsuan Chuang 
> Cc: Birming Chiu 
> Cc: Shaofu 
> Cc: Steven Ting 

[...]

> + if (count < 3) {
> + /*printk("argument size is less than 3\n");*/
> + return -EFAULT;
> + }

> + if (num !=  3) {
> + /*printk("invalid write_reg parameter!\n");*/
> + return count;
> + }

> + default:
> + /*printk("error write length=%d", len);*/
> + break;
> + }

Dead code.

> + /* add for debug */
> + rtl_debug_add_one(hw);

> + /* remove form debug */
> + rtl_debug_remove_one(hw);

The comments are useless, the function name already tells the same.

-- 
Kalle Valo


Re: [PATCH v4 09/10] rtlwifi: use debugfs to debug.

2017-07-27 Thread Kalle Valo
Larry Finger  writes:

> From: Ping-Ke Shih 
>
> Use debugfs to dump register and btcoex status.

The title is useless and the commit log does not mention anything about
what files are added and to which location.

> The kbuild test robot  suggested a change to use
> simple_open() instead of a local routine.

This comment doesn't belong to commit log, it should be in the changelog.

> +void rtl_debugfs_add_topdir(void)
> +{
> + debugfs_topdir = debugfs_create_dir("rtlwifi", NULL);
> +}
> +
> +void rtl_debugfs_remove_topdir(void)
> +{
> + debugfs_remove_recursive(debugfs_topdir);
> +}

I'm surprised to see that rtlwifi creates it's own top level debugfs
directory and does not use wiphy->debugfsdir. So how is this supposed to
work when we have multiple rtlwifi devices on the same system?

-- 
Kalle Valo


Re: Patch v4: Clean up brcmfmac driver

2017-07-27 Thread Ian Molton
On 27/07/17 11:09, Arend van Spriel wrote:
>>
>> Hi Arend,
>>
>> Noted for future series. I take it I shouldn't re-spin if you're going
>> through them already?
> 
> My "guess" is a v5 is likely ;-)

No prob. I've spotted a gem in it myself (FIXME comment that crept
through). I'll split it into two series at v5 then.

-Ian


Re: Patch v4: Clean up brcmfmac driver

2017-07-27 Thread Arend van Spriel

On 7/27/2017 12:00 PM, Ian Molton wrote:

On 27/07/17 10:52, Arend van Spriel wrote:


How many patches would you like at once?


Hi Ian,

~10-15 patches should be fine although I am simply ploughing through the
lot right now.


Hi Arend,

Noted for future series. I take it I shouldn't re-spin if you're going
through them already?


My "guess" is a v5 is likely ;-)

Regards,
Arend



Re: [PATCH v4 01/10] rtlwifi: Fill in_4way field by driver

2017-07-27 Thread Kalle Valo
Arend van Spriel  writes:

> On 7/27/2017 11:54 AM, Kalle Valo wrote:
>> Larry Finger  writes:
>>
>>> From: Ping-Ke Shih 
>>>
>>> Because it isn't always correct to use EAPOL to check 4-way,
>>> we add a timer to handle exception.
>>>
>>> Signed-off-by: Ping-Ke Shih 
>>> Signed-off-by: Larry Finger 
>>> Cc: Yan-Hsuan Chuang 
>>> Cc: Birming Chiu 
>>> Cc: Shaofu 
>>> Cc: Steven Ting 
>>
>> [...]
>>
>>> --- a/drivers/net/wireless/realtek/rtlwifi/base.c
>>> +++ b/drivers/net/wireless/realtek/rtlwifi/base.c
>>> @@ -1408,6 +1408,11 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, 
>>> struct sk_buff *skb, u8 is_tx,
>>>
>>> return true;
>>> } else if (ETH_P_PAE == ether_type) {
>>> +   /* EAPOL is seens as in-4way */
>>> +   rtlpriv->btcoexist.btc_info.in_4way = true;
>>> +   rtlpriv->btcoexist.btc_info.in_4way_ts = jiffies;
>>> +   rtlpriv->btcoexist.btc_info.in_4way_ts = jiffies;
>>> +
>>> RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
>>>  "802.1X %s EAPOL pkt!!\n", (is_tx) ? "Tx" : "Rx");
>>
>> The indentation looks wrong.
>
> That wrongly indented line seems a bit redundant anyway :-p

Heh, indeed :)

-- 
Kalle Valo


Re: Patch v4: Clean up brcmfmac driver

2017-07-27 Thread Ian Molton
On 27/07/17 10:52, Arend van Spriel wrote:
>>
>> How many patches would you like at once?
> 
> Hi Ian,
> 
> ~10-15 patches should be fine although I am simply ploughing through the
> lot right now.

Hi Arend,

Noted for future series. I take it I shouldn't re-spin if you're going
through them already?

Thanks,

-Ian


Re: [PATCH v4 02/10] rtlwifi: Add BT_MP_INFO to c2h handler.

2017-07-27 Thread Kalle Valo
Larry Finger  writes:

> From: Ping-Ke Shih 
>
> We use H2C to ask BT's status, and C2H will return the status.
>
> Signed-off-by: Ping-Ke Shih 
> Signed-off-by: Larry Finger 
> Cc: Yan-Hsuan Chuang 
> Cc: Birming Chiu 
> Cc: Shaofu 
> Cc: Steven Ting 

[...]

> --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
> @@ -327,7 +327,22 @@ static void halbtc_aggregation_check(struct btc_coexist 
> *btcoexist)
>  
>  static u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist)
>  {
> - return 0;
> + struct rtl_priv *rtlpriv = btcoexist->adapter;
> + u8 cmd_buffer[4] = {0};
> + u8 oper_ver = 0;
> + u8 req_num = 0x0E;
> +
> + if (btcoexist->bt_info.bt_real_fw_ver)
> + goto label_done;
> +
> + cmd_buffer[0] |= (oper_ver & 0x0f); /* Set OperVer */
> + cmd_buffer[0] |= ((req_num << 4) & 0xf0);   /* Set ReqNum */
> + cmd_buffer[1] = 0; /* BT_OP_GET_BT_VERSION = 0 */
> + rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, 0x67, 4,
> + _buffer[0]);
> +
> +label_done:
> + return btcoexist->bt_info.bt_real_fw_ver;
>  }

I don't remember if I have mentioned before but there's way too much
magic numbers. There should an enum for all req_num values and
cmd_buffer should be a struct so that is serves as documentation at the
same time. No need to resend because of this but take this into account
in the future.

As an example rsi driver is having similar problems and Prameela is
fixing those:

https://patchwork.kernel.org/patch/9832895/

-- 
Kalle Valo


Re: [PATCH v4 01/10] rtlwifi: Fill in_4way field by driver

2017-07-27 Thread Arend van Spriel

On 7/27/2017 11:54 AM, Kalle Valo wrote:

Larry Finger  writes:


From: Ping-Ke Shih 

Because it isn't always correct to use EAPOL to check 4-way,
we add a timer to handle exception.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
Cc: Yan-Hsuan Chuang 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 


[...]


--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -1408,6 +1408,11 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct 
sk_buff *skb, u8 is_tx,

return true;
} else if (ETH_P_PAE == ether_type) {
+   /* EAPOL is seens as in-4way */
+   rtlpriv->btcoexist.btc_info.in_4way = true;
+   rtlpriv->btcoexist.btc_info.in_4way_ts = jiffies;
+   rtlpriv->btcoexist.btc_info.in_4way_ts = jiffies;
+
RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
 "802.1X %s EAPOL pkt!!\n", (is_tx) ? "Tx" : "Rx");


The indentation looks wrong.


That wrongly indented line seems a bit redundant anyway :-p

Regards,
Arend



Re: [PATCH v4 01/10] rtlwifi: Fill in_4way field by driver

2017-07-27 Thread Kalle Valo
Larry Finger  writes:

> From: Ping-Ke Shih 
>
> Because it isn't always correct to use EAPOL to check 4-way,
> we add a timer to handle exception.
>
> Signed-off-by: Ping-Ke Shih 
> Signed-off-by: Larry Finger 
> Cc: Yan-Hsuan Chuang 
> Cc: Birming Chiu 
> Cc: Shaofu 
> Cc: Steven Ting 

[...]

> --- a/drivers/net/wireless/realtek/rtlwifi/base.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/base.c
> @@ -1408,6 +1408,11 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct 
> sk_buff *skb, u8 is_tx,
>  
>   return true;
>   } else if (ETH_P_PAE == ether_type) {
> + /* EAPOL is seens as in-4way */
> + rtlpriv->btcoexist.btc_info.in_4way = true;
> + rtlpriv->btcoexist.btc_info.in_4way_ts = jiffies;
> + rtlpriv->btcoexist.btc_info.in_4way_ts = jiffies;
> +
>   RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
>"802.1X %s EAPOL pkt!!\n", (is_tx) ? "Tx" : "Rx");

The indentation looks wrong.

-- 
Kalle Valo


Re: Patch v4: Clean up brcmfmac driver

2017-07-27 Thread Arend van Spriel

On 7/27/2017 11:47 AM, Ian Molton wrote:

On 27/07/17 07:17, Kalle Valo wrote:

Here's a v4 of the cleanup patchset - checkpatch clean(er - I have purposely
left some warnings unaddressed).

I also dropped an accidental adjustment of a debug macro from v3.

Like I said already last time, please split the patchset into reasonable
sizes (and submit one patchset at a time). I will automatically drop
patchbombs like this.


How many patches would you like at once?


Hi Ian,

~10-15 patches should be fine although I am simply ploughing through the 
lot right now.


Regards,
Arend



Re: Patch v4: Clean up brcmfmac driver

2017-07-27 Thread Ian Molton
On 27/07/17 07:17, Kalle Valo wrote:
>> Here's a v4 of the cleanup patchset - checkpatch clean(er - I have purposely
>> left some warnings unaddressed).
>>
>> I also dropped an accidental adjustment of a debug macro from v3.
> Like I said already last time, please split the patchset into reasonable
> sizes (and submit one patchset at a time). I will automatically drop
> patchbombs like this.

How many patches would you like at once?

-Ian


Re: [v3] rtlwifi: Replace hardcode value with macro

2017-07-27 Thread Kalle Valo
Souptick Joarder  wrote:

> In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
> and hw->max_rate_tries are replaced by macro.
> 
> Signed-off-by: Souptick Joarder 

The comment ("defined these...") in the code does not make sense, it
should be removed.

Patch set to Changes Requested.

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

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



Re: mwifiex: correct channel stat buffer overflows

2017-07-27 Thread Kalle Valo
Brian Norris  wrote:

> mwifiex records information about various channels as it receives scan
> information. It does this by appending to a buffer that was sized
> to the max number of supported channels on any band, but there are
> numerous problems:
> 
> (a) scans can return info from more than one band (e.g., both 2.4 and 5
> GHz), so the determined "max" is not large enough
> (b) some firmware appears to return multiple results for a given
> channel, so the max *really* isn't large enough
> (c) there is no bounds checking when stashing these stats, so problems
> (a) and (b) can easily lead to buffer overflows
> 
> Let's patch this by setting a slightly-more-correct max (that accounts
> for a combination of both 2.4G and 5G bands) and adding a bounds check
> when writing to our statistics buffer.
> 
> Due to problem (b), we still might not properly report all known survey
> information (e.g., with "iw  survey dump"), since duplicate results
> (or otherwise "larger than expected" results) will cause some
> truncation. But that's a problem for a future bugfix.
> 
> (And because of this known deficiency, only log the excess at the WARN
> level, since that isn't visible by default in this driver and would
> otherwise be a bit too noisy.)
> 
> Fixes: bf35443314ac ("mwifiex: channel statistics support for mwifiex")
> Cc: 
> Cc: Avinash Patil 
> Cc: Xinming Hu 
> Signed-off-by: Brian Norris 
> Reviewed-by: Dmitry Torokhov 
> Reviewed-by: Ganapathi Bhat 

Patch applied to wireless-drivers-next.git, thanks.

4b5dde2d6234 mwifiex: correct channel stat buffer overflows

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

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



Re: Patch v4: Clean up brcmfmac driver

2017-07-27 Thread Kalle Valo
Ian Molton  writes:

> Here's a v4 of the cleanup patchset - checkpatch clean(er - I have purposely
> left some warnings unaddressed).
>
> I also dropped an accidental adjustment of a debug macro from v3.

Like I said already last time, please split the patchset into reasonable
sizes (and submit one patchset at a time). I will automatically drop
patchbombs like this.

-- 
Kalle Valo


Re: [PATCH for-v4.13 V4] brcmfmac: Don't grow SKB by negative size

2017-07-27 Thread Kalle Valo
Daniel Stone  writes:

> The commit to rework the headroom check in start_xmit() now calls
> pxskb_expand_head() unconditionally if the header is CoW. Unfortunately,
> it does so with the delta between the extant headroom and the header
> length, which may be negative if there is already sufficient headroom.
>
> pskb_expand_head() does allow for size being 0, in which case it just
> copies, so clamp the header delta to zero.
>
> Opening Chrome (and all my tabs) on a PCIE device was enough to reliably
> hit this.
>
> Fixes: 270a6c1f65fe ("brcmfmac: rework headroom check in .start_xmit()")
> Signed-off-by: Daniel Stone 
> Cc: Arend Van Spriel 
> Cc: James Hughes 
> Cc: Hante Meuleman 
> Cc: Pieter-Paul Giesberts 
> Cc: Franky Lin 

I'll queue this for 4.13.

-- 
Kalle Valo