qtnfmac: update firmware protocol
cover qtnfmac: update firmware protocol
Hello Kalle and all,
Here is a patch set with multiple changes and cleanups for firmware communication protocol preceding release of firmware and sdk for Topaz platform. Several patches introduce breaking changes to the protocol in order to finally improve forward/backward compatibility between firmware and driver in the future.
Major changes include the following bits:
- use MAJOR.MINOR firmware versioning
- improve alignment in firmware protocol
- simplify command flow: merge PHY and MAC init commands
- prepare for 6GHz: modify survey dump and channel switch commands
Regards,
Sergey
Igor Mitsyanko (9):
qtnfmac: use MAJOR.MINOR format for firmware protocol
qtnfmac: pass hardware capabilities in TLV element
qtnfmac: merge PHY_PARAMS_GET into MAC_INFO
qtnfmac: drop QTN_TLV_ID_NUM_IFACE_COMB TLV type
qtnfmac: implement extendable channel survey dump
qtnfmac: pass max scan SSIDs limit on per-radio basis
qtnfmac: cleanup alignment in firmware communication protocol
qtnfmac: update channel switch command to support 6GHz band
qtnfmac: drop unnecessary TLVs from scan command
Sergey Matyukevich (1):
qtnfmac: fix potential Spectre vulnerabilities
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 64 +- drivers/net/wireless/quantenna/qtnfmac/commands.c | 651 +++++++++------------ drivers/net/wireless/quantenna/qtnfmac/commands.h | 4 +- drivers/net/wireless/quantenna/qtnfmac/core.c | 47 +- drivers/net/wireless/quantenna/qtnfmac/core.h | 26 +- drivers/net/wireless/quantenna/qtnfmac/event.c | 67 +-- .../wireless/quantenna/qtnfmac/pcie/pearl_pcie.c | 2 +- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 329 ++++++++--- .../net/wireless/quantenna/qtnfmac/qlink_util.h | 45 +- 9 files changed, 608 insertions(+), 627 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/10 qtnfmac: use MAJOR.MINOR format for firmware protocol
From: Igor Mitsyanko <[email protected]>
Use MAJOR.MINOR format for QLink firmware protocol. MAJOR part is incremented when backward compatibility is broken. Normally this part should not be incremented unless there is a good reason for that. MINOR part is incremented each time when new features are added to qlink.h, e.g. new TLVs, events, commands. These changes should not break backward compatibility. For instance, older firmware versions may not be able to parse new flags or send new types of events, but this does not impact normal system operations.
As part of initialization sequence, driver requests protocol version from firmware and refuses to start in case there is a mismatch in MAJOR part of the version.
--- drivers/net/wireless/quantenna/qtnfmac/commands.c | 59 ++++++++++++++--------- drivers/net/wireless/quantenna/qtnfmac/core.c | 16 +++--- drivers/net/wireless/quantenna/qtnfmac/core.h | 2 +- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 42 ++++++++++++++-- 4 files changed, 86 insertions(+), 33 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/commands.c +37 -22
@@ -900,7 +900,6 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus, hwinfo->num_mac = resp->num_mac; hwinfo->mac_bitmap = resp->mac_bitmap; hwinfo->fw_ver =le32_to_cpu (resp->fw_ver); - hwinfo->ql_proto_ver =le16_to_cpu (resp->ql_proto_ver); hwinfo->total_tx_chain = resp->total_tx_chain; hwinfo->total_rx_chain = resp->total_rx_chain; hwinfo->hw_capab =le32_to_cpu (resp->hw_capab);
@@ -954,25 +953,29 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus, tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); } -pr_info ("fw_version=%d, MACs map %#x, chains Tx=%u Rx=%u, capab=0x%x\n" , - hwinfo->fw_ver, hwinfo->mac_bitmap, - hwinfo->total_tx_chain, hwinfo->total_rx_chain, - hwinfo->hw_capab); - -pr_info ("\nBuild name: %s" \ -"\nBuild revision: %s" \ -"\nBuild type: %s" \ -"\nBuild label: %s" \ -"\nBuild timestamp: %lu" \ -"\nPlatform ID: %lu" \ -"\nHardware ID: %s" \ -"\nCalibration version: %s" \ -"\nU-Boot version: %s" \ -"\nHardware version: 0x%08x\n" , +pr_info ("\nBuild name: %s\n" +"Build revision: %s\n" +"Build type: %s\n" +"Build label: %s\n" +"Build timestamp: %lu\n" +"Platform ID: %lu\n" +"Hardware ID: %s\n" +"Calibration version: %s\n" +"U-Boot version: %s\n" +"Hardware version: 0x%08x\n" +"Qlink ver: %u.%u\n" +"MACs map: %#x\n" +"Chains Rx-Tx: %ux%u\n" +"FW version: 0x%x\n" , bld_name, bld_rev, bld_type, bld_label, (unsigned long )bld_tmstamp, (unsigned long )plat_id, - hw_id, calibration_ver, uboot_ver, hw_ver); + hw_id, calibration_ver, uboot_ver, hw_ver, +QLINK_VER_MAJOR (bus->hw_info.ql_proto_ver), +QLINK_VER_MINOR (bus->hw_info.ql_proto_ver), + hwinfo->mac_bitmap, + hwinfo->total_rx_chain, hwinfo->total_tx_chain, + hwinfo->fw_ver);strlcpy (hwinfo->fw_version, bld_label,sizeof (hwinfo->fw_version)); hwinfo->hw_version = hw_ver;
@@ -1866,23 +1869,35 @@ int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed)int qtnf_cmd_send_init_fw (struct qtnf_bus *bus) { +struct sk_buff *resp_skb =NULL ; +struct qlink_resp_init_fw *resp; +struct qlink_cmd_init_fw *cmd;struct sk_buff *cmd_skb; -int ret =0 ; +size_t info_len =0 ; +int ret; cmd_skb =qtnf_cmd_alloc_new_cmdskb (QLINK_MACID_RSVD ,QLINK_VIFID_RSVD ,QLINK_CMD_FW_INIT , -sizeof (struct qlink_cmd )); +sizeof (*cmd));if (!cmd_skb)return -ENOMEM ; + cmd = (struct qlink_cmd_init_fw *)cmd_skb->data; + cmd->qlink_proto_ver =cpu_to_le32 (QLINK_PROTO_VER ); +qtnf_bus_lock (bus); - ret =qtnf_cmd_send (bus, cmd_skb); + ret =qtnf_cmd_send_with_reply (bus, cmd_skb, &resp_skb, +sizeof (*resp), &info_len); +qtnf_bus_unlock (bus); +if (ret) goto out; -out: -qtnf_bus_unlock (bus); + resp = (struct qlink_resp_init_fw *)resp_skb->data; + bus->hw_info.ql_proto_ver =le32_to_cpu (resp->qlink_proto_ver); +out: +consume_skb (resp_skb);return ret; }
drivers/net/wireless/quantenna/qtnfmac/core.c +9 -7
@@ -756,6 +756,15 @@ int qtnf_core_attach(struct qtnf_bus *bus) goto error; } +if (QLINK_VER_MAJOR (bus->hw_info.ql_proto_ver) != +QLINK_PROTO_VER_MAJOR ) { +pr_err ("qlink driver vs FW version mismatch: %u vs %u\n" , +QLINK_PROTO_VER_MAJOR , +QLINK_VER_MAJOR (bus->hw_info.ql_proto_ver)); + ret = -EPROTONOSUPPORT ; + goto error; + } + bus->fw_state =QTNF_FW_STATE_ACTIVE ; ret =qtnf_cmd_get_hw_info (bus);if (ret) {
@@ -763,13 +772,6 @@ int qtnf_core_attach(struct qtnf_bus *bus) goto error; } -if (bus->hw_info.ql_proto_ver !=QLINK_PROTO_VER ) { -pr_err ("qlink version mismatch %u != %u\n" , -QLINK_PROTO_VER , bus->hw_info.ql_proto_ver); - ret = -EPROTONOSUPPORT ; - goto error; - } -if ((bus->hw_info.hw_capab &QLINK_HW_CAPAB_HW_BRIDGE ) && bus->bus_ops->data_tx_use_meta_set) bus->bus_ops->data_tx_use_meta_set (bus, true);
drivers/net/wireless/quantenna/qtnfmac/core.h +1 -1
@@ -117,7 +117,7 @@ struct qtnf_wmac { };struct qtnf_hw_info { -u16 ql_proto_ver; +u32 ql_proto_ver;u8 num_mac;u8 mac_bitmap;u32 fw_ver;
drivers/net/wireless/quantenna/qtnfmac/qlink.h +39 -3
72 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH 01/10] qtnfmac: use MAJOR.MINOR format for firmware protocol
Quoted 11 lines · Sergey Matyukevich
From: Igor Mitsyanko <[email protected]>
Use MAJOR.MINOR format for QLink firmware protocol. MAJOR part is incremented when backward compatibility is broken. Normally this part should not be incremented unless there is a good reason for that. MINOR part is incremented each time when new features are added to
qlink.h, e.g. new TLVs, events, commands. These changes should not break backward compatibility. For instance, older firmware versions may not be able to parse new flags or send new types of events, but this does not impact normal system operations.
Quoted 5 lines
As part of initialization sequence, driver requests protocol version from firmware and refuses to start in case there is a mismatch in MAJOR part of the version.
Signed-off-by Igor Mitsyanko <[email protected]>
10 patches applied to wireless-drivers-next.git, thanks.
a3ebb0335c54 qtnfmac: use MAJOR.MINOR format for firmware protocol 310cd5dd5070 qtnfmac: pass hardware capabilities in TLV element e70cf22bc7b2 qtnfmac: merge PHY_PARAMS_GET into MAC_INFO bc5db734c1c4 qtnfmac: drop QTN_TLV_ID_NUM_IFACE_COMB TLV type 601ce21ff88d qtnfmac: implement extendable channel survey dump 0d18a9c0a387 qtnfmac: pass max scan SSIDs limit on per-radio basis 8b0b5f1ba9e0 qtnfmac: cleanup alignment in firmware communication protocol 5edadc5a3f11 qtnfmac: update channel switch command to support 6GHz band 501c3be1ec3c qtnfmac: drop unnecessary TLVs from scan command 946d077a4256 qtnfmac: fix potential Spectre vulnerabilities
Signature · 3 lines
https://patchwork.kernel.org/patch/11352415/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH 2/10 qtnfmac: pass hardware capabilities in TLV element
In reply to Sergey MatyukevichFrom: Igor Mitsyanko <[email protected]>
To support any number of capabilities bits in the future, replace u32 capabilities bitmask by array. Pass capabilities from firmware using TLV element.
--- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 20 +++++----- drivers/net/wireless/quantenna/qtnfmac/commands.c | 19 ++++++---- drivers/net/wireless/quantenna/qtnfmac/core.c | 9 +++-- drivers/net/wireless/quantenna/qtnfmac/core.h | 10 ++++- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 45 ++++++++++++++--------- 5 files changed, 63 insertions(+), 40 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +10 -10
@@ -248,7 +248,7 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy, goto error_del_vif; } -if (mac->bus->hw_info.hw_capab &QLINK_HW_CAPAB_HW_BRIDGE ) { +if (qtnf_hwcap_is_set (&mac->bus->hw_info,QLINK_HW_CAPAB_HW_BRIDGE )) { ret =qtnf_cmd_netdev_changeupper (vif, vif->netdev->ifindex);if (ret) {unregister_netdevice (vif->netdev);
@@ -1080,10 +1080,10 @@ struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus)struct wiphy *wiphy;if (qtnf_dfs_offload_get () && - (bus->hw_info.hw_capab &QLINK_HW_CAPAB_DFS_OFFLOAD )) +qtnf_hwcap_is_set (&bus->hw_info,QLINK_HW_CAPAB_DFS_OFFLOAD )) qtn_cfg80211_ops.start_radar_detection =NULL ; -if (!(bus->hw_info.hw_capab &QLINK_HW_CAPAB_PWR_MGMT )) +if (!qtnf_hwcap_is_set (&bus->hw_info,QLINK_HW_CAPAB_PWR_MGMT )) qtn_cfg80211_ops.set_power_mgmt =NULL ; wiphy =wiphy_new (&qtn_cfg80211_ops,sizeof (struct qtnf_wmac ));
@@ -1166,10 +1166,10 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT ;if (qtnf_dfs_offload_get () && - (hw_info->hw_capab &QLINK_HW_CAPAB_DFS_OFFLOAD )) +qtnf_hwcap_is_set (hw_info,QLINK_HW_CAPAB_DFS_OFFLOAD ))wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_DFS_OFFLOAD ); -if (hw_info->hw_capab &QLINK_HW_CAPAB_SCAN_DWELL ) +if (qtnf_hwcap_is_set (hw_info,QLINK_HW_CAPAB_SCAN_DWELL ))wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_SET_SCAN_DWELL );
@@ -1185,16 +1185,16 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac)ether_addr_copy (wiphy->perm_addr, mac->macaddr); -if (hw_info->hw_capab &QLINK_HW_CAPAB_STA_INACT_TIMEOUT ) +if (qtnf_hwcap_is_set (hw_info,QLINK_HW_CAPAB_STA_INACT_TIMEOUT )) wiphy->features |=NL80211_FEATURE_INACTIVITY_TIMER ; -if (hw_info->hw_capab &QLINK_HW_CAPAB_SCAN_RANDOM_MAC_ADDR ) +if (qtnf_hwcap_is_set (hw_info,QLINK_HW_CAPAB_SCAN_RANDOM_MAC_ADDR )) wiphy->features |=NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR ; -if (!(hw_info->hw_capab &QLINK_HW_CAPAB_OBSS_SCAN )) +if (!qtnf_hwcap_is_set (hw_info,QLINK_HW_CAPAB_OBSS_SCAN )) wiphy->features |=NL80211_FEATURE_NEED_OBSS_SCAN ; -if (hw_info->hw_capab &QLINK_HW_CAPAB_SAE ) +if (qtnf_hwcap_is_set (hw_info,QLINK_HW_CAPAB_SAE )) wiphy->features |=NL80211_FEATURE_SAE ;#ifdef CONFIG_PM
@@ -1205,7 +1205,7 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) regdomain_is_known =isalpha (mac->rd->alpha2[0 ]) &&isalpha (mac->rd->alpha2[1 ]); -if (hw_info->hw_capab &QLINK_HW_CAPAB_REG_UPDATE ) { +if (qtnf_hwcap_is_set (hw_info,QLINK_HW_CAPAB_REG_UPDATE )) { wiphy->reg_notifier = qtnf_cfg80211_reg_notifier;if (mac->rd->alpha2[0 ] =='9' && mac->rd->alpha2[1 ] =='9' ) {
drivers/net/wireless/quantenna/qtnfmac/commands.c +11 -8
@@ -599,7 +599,7 @@ qtnf_cmd_sta_info_parse(struct station_info *sinfo, tlv_len =le16_to_cpu (tlv->len);switch (le16_to_cpu (tlv->type)) { -case QTN_TLV_ID_STA_STATS_MAP : +case QTN_TLV_ID_BITMAP : map_len = tlv_len; map = tlv->val;break ;
@@ -895,14 +895,13 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus,const char *uboot_ver =NULL ;u32 hw_ver =0 ;u16 tlv_type; -u16 tlv_value_len; +u16 tlv_len; hwinfo->num_mac = resp->num_mac; hwinfo->mac_bitmap = resp->mac_bitmap; hwinfo->fw_ver =le32_to_cpu (resp->fw_ver); hwinfo->total_tx_chain = resp->total_tx_chain; hwinfo->total_rx_chain = resp->total_rx_chain; - hwinfo->hw_capab =le32_to_cpu (resp->hw_capab); bld_tmstamp =le32_to_cpu (resp->bld_tmstamp); plat_id =le32_to_cpu (resp->plat_id);
@@ -912,11 +911,11 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus,while (info_len >=sizeof (*tlv)) { tlv_type =le16_to_cpu (tlv->type); - tlv_value_len =le16_to_cpu (tlv->len); + tlv_len =le16_to_cpu (tlv->len); -if (tlv_value_len +sizeof (*tlv) > info_len) { +if (tlv_len +sizeof (*tlv) > info_len) {pr_warn ("malformed TLV 0x%.2X; LEN: %u\n" , - tlv_type, tlv_value_len); + tlv_type, tlv_len);return -EINVAL ; }
@@ -945,12 +944,16 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus,case QTN_TLV_ID_MAX_SCAN_SSIDS : hwinfo->max_scan_ssids = *tlv->val;break ; +case QTN_TLV_ID_BITMAP : +memcpy (hwinfo->hw_capab, tlv->val, +min (sizeof (hwinfo->hw_capab), (size_t )tlv_len)); +break ;default :break ; } - info_len -= tlv_value_len +sizeof (*tlv); - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); + info_len -= tlv_len +sizeof (*tlv); + tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_len); } pr_info("\nBuild name: %s\n"
drivers/net/wireless/quantenna/qtnfmac/core.c +5 -4
@@ -497,7 +497,7 @@ int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *vif, dev->tx_queue_len =100 ; dev->ethtool_ops = &qtnf_ethtool_ops; -if (mac->bus->hw_info.hw_capab &QLINK_HW_CAPAB_HW_BRIDGE ) +if (qtnf_hwcap_is_set (&mac->bus->hw_info,QLINK_HW_CAPAB_HW_BRIDGE )) dev->needed_tailroom =sizeof (struct qtnf_frame_meta_info ); qdev_vif =netdev_priv (dev);
@@ -639,7 +639,7 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid) goto error_del_vif; } -if (bus->hw_info.hw_capab &QLINK_HW_CAPAB_HW_BRIDGE ) { +if (qtnf_hwcap_is_set (&bus->hw_info,QLINK_HW_CAPAB_HW_BRIDGE )) { ret =qtnf_cmd_netdev_changeupper (vif, vif->netdev->ifindex);if (ret) goto error;
@@ -705,7 +705,8 @@ static int qtnf_core_netdevice_event(struct notifier_block *nb, info->linking ? "add" : "del");if (IS_ENABLED (CONFIG_NET_SWITCHDEV ) && - (bus->hw_info.hw_capab &QLINK_HW_CAPAB_HW_BRIDGE )) { +qtnf_hwcap_is_set (&bus->hw_info, +QLINK_HW_CAPAB_HW_BRIDGE )) {if (info->linking) br_domain = brdev->ifindex;else
@@ -772,7 +773,7 @@ int qtnf_core_attach(struct qtnf_bus *bus) goto error; } -if ((bus->hw_info.hw_capab &QLINK_HW_CAPAB_HW_BRIDGE ) && +if (qtnf_hwcap_is_set (&bus->hw_info,QLINK_HW_CAPAB_HW_BRIDGE ) && bus->bus_ops->data_tx_use_meta_set) bus->bus_ops->data_tx_use_meta_set (bus, true);
drivers/net/wireless/quantenna/qtnfmac/core.h +9 -1
@@ -23,6 +23,7 @@#include "qlink.h" #include "trans.h" +#include "qlink_util.h" #undef pr_fmt#define pr_fmt (fmt) KBUILD_MODNAME ": %s: " fmt, __func__
@@ -121,12 +122,12 @@ struct qtnf_hw_info {u8 num_mac;u8 mac_bitmap;u32 fw_ver; -u32 hw_capab;u8 total_tx_chain;u8 total_rx_chain;char fw_version[ETHTOOL_FWVERS_LEN ];u32 hw_version;u8 max_scan_ssids; +u8 hw_capab[QLINK_HW_CAPAB_NUM /BITS_PER_BYTE +1 ]; };struct qtnf_vif *qtnf_mac_get_free_vif (struct qtnf_wmac *mac);
@@ -160,4 +161,11 @@ static inline struct qtnf_vif *qtnf_netdev_get_priv(struct net_device *dev) return *((void **)netdev_priv(dev)); } +static inline bool qtnf_hwcap_is_set (const struct qtnf_hw_info *info, +unsigned int bit) +{ +return qtnf_utils_is_bit_set (info->hw_capab, bit, +sizeof (info->hw_capab)); +} +#endif /* _QTN_FMAC_CORE_H_ */
drivers/net/wireless/quantenna/qtnfmac/qlink.h +28 -17
89 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 3/10 qtnfmac: merge PHY_PARAMS_GET into MAC_INFO
In reply to Sergey MatyukevichFrom: Igor Mitsyanko <[email protected]>
QLINK_CMD_PHY_PARAMS_GET command does not need to be separate, it can be included into GET_MAC_INFO command. Merge these two commands adding all the missing wiphy data.
--- drivers/net/wireless/quantenna/qtnfmac/commands.c | 102 ++-------------------- drivers/net/wireless/quantenna/qtnfmac/core.c | 18 ++-- drivers/net/wireless/quantenna/qtnfmac/core.h | 3 +- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 64 ++++++++------ 4 files changed, 49 insertions(+), 138 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/commands.c +6 -96
@@ -1291,7 +1291,12 @@ qtnf_cmd_resp_proc_mac_info(struct qtnf_wmac *mac, mac_info->radar_detect_widths =qlink_chan_width_mask_to_nl (le16_to_cpu ( resp_info->radar_detect_widths)); - mac_info->max_acl_mac_addrs =le32_to_cpu (resp_info->max_acl_mac_addrs); + mac_info->max_acl_mac_addrs =le16_to_cpu (resp_info->max_acl_mac_addrs); + mac_info->frag_thr =le32_to_cpu (resp_info->frag_threshold); + mac_info->rts_thr =le32_to_cpu (resp_info->rts_threshold); + mac_info->sretry_limit = resp_info->retry_short; + mac_info->lretry_limit = resp_info->retry_long; + mac_info->coverage_class = resp_info->coverage_class;memcpy (&mac_info->ht_cap_mod_mask, &resp_info->ht_cap_mod_mask,sizeof (mac_info->ht_cap_mod_mask));
@@ -1576,72 +1581,6 @@ qtnf_cmd_resp_fill_band_info(struct ieee80211_supported_band *band,return ret; } -static int qtnf_cmd_resp_proc_phy_params (struct qtnf_wmac *mac, -const u8 *payload,size_t payload_len) -{ -struct qtnf_mac_info *mac_info; -struct qlink_tlv_frag_rts_thr *phy_thr; -struct qlink_tlv_rlimit *limit; -struct qlink_tlv_cclass *class; -u16 tlv_type; -u16 tlv_value_len; -size_t tlv_full_len; -const struct qlink_tlv_hdr *tlv; - - mac_info = &mac->macinfo; - - 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 ("MAC%u: malformed TLV 0x%.2X; LEN: %u\n" , - mac->macid, tlv_type, tlv_value_len); -return -EINVAL ; - } - -switch (tlv_type) { -case QTN_TLV_ID_FRAG_THRESH : - phy_thr = (void *)tlv; - mac_info->frag_thr =le32_to_cpu (phy_thr->thr); -break ; -case QTN_TLV_ID_RTS_THRESH : - phy_thr = (void *)tlv; - mac_info->rts_thr =le32_to_cpu (phy_thr->thr); -break ; -case QTN_TLV_ID_SRETRY_LIMIT : - limit = (void *)tlv; - mac_info->sretry_limit = limit->rlimit; -break ; -case QTN_TLV_ID_LRETRY_LIMIT : - limit = (void *)tlv; - mac_info->lretry_limit = limit->rlimit; -break ; -case QTN_TLV_ID_COVERAGE_CLASS : - class = (void *)tlv; - mac_info->coverage_class = class->cclass; -break ; -default : -pr_err ("MAC%u: Unknown TLV type: %#x\n" , mac->macid, -le16_to_cpu (tlv->type)); -break ; - } - - payload_len -= tlv_full_len; - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); - } - -if (payload_len) { -pr_warn ("MAC%u: malformed TLV buf; bytes left: %zu\n" , - mac->macid, payload_len); -return -EINVAL ; - } - -return 0 ; -} -static int qtnf_cmd_resp_proc_chan_stat_info (struct qtnf_chan_stats *stats,const u8 *payload,size_t payload_len)
@@ -1799,35 +1738,6 @@ int qtnf_cmd_band_info_get(struct qtnf_wmac *mac,return ret; } -int qtnf_cmd_send_get_phy_params (struct qtnf_wmac *mac) -{ -struct sk_buff *cmd_skb, *resp_skb =NULL ; -struct qlink_resp_phy_params *resp; -size_t response_size =0 ; -int ret =0 ; - - cmd_skb =qtnf_cmd_alloc_new_cmdskb (mac->macid,0 , -QLINK_CMD_PHY_PARAMS_GET , -sizeof (struct qlink_cmd )); -if (!cmd_skb) -return -ENOMEM ; - -qtnf_bus_lock (mac->bus); - ret =qtnf_cmd_send_with_reply (mac->bus, cmd_skb, &resp_skb, -sizeof (*resp), &response_size); -if (ret) - goto out; - - resp = (struct qlink_resp_phy_params *)resp_skb->data; - ret =qtnf_cmd_resp_proc_phy_params (mac, resp->info, response_size); - -out: -qtnf_bus_unlock (mac->bus); -consume_skb (resp_skb); - -return ret; -} -int qtnf_cmd_send_update_phy_params (struct qtnf_wmac *mac,u32 changed) {struct wiphy *wiphy =priv_to_wiphy (mac);
drivers/net/wireless/quantenna/qtnfmac/core.c +6 -12
@@ -585,16 +585,6 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid)return PTR_ERR (mac); } - ret =qtnf_cmd_get_mac_info (mac); -if (ret) { -pr_err ("MAC%u: failed to get info\n" , macid); - goto error; - } - -/* Use MAC address of the first active radio as a unique device ID */ -if (is_zero_ether_addr (mac->bus->hw_id)) -ether_addr_copy (mac->bus->hw_id, mac->macaddr); - vif =qtnf_mac_get_base_vif (mac);if (!vif) {pr_err ("MAC%u: primary VIF is not ready\n" , macid);
@@ -609,12 +599,16 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid) goto error; } - ret =qtnf_cmd_send_get_phy_params (mac); + ret =qtnf_cmd_get_mac_info (mac);if (ret) { -pr_err ("MAC%u: failed to get PHY settings\n" , macid); +pr_err ("MAC%u: failed to get MAC info\n" , macid); goto error_del_vif; } +/* Use MAC address of the first active radio as a unique device ID */ +if (is_zero_ether_addr (mac->bus->hw_id)) +ether_addr_copy (mac->bus->hw_id, mac->macaddr); + ret =qtnf_mac_init_bands (mac);if (ret) {pr_err ("MAC%u: failed to init bands\n" , macid);
drivers/net/wireless/quantenna/qtnfmac/core.h +1 -2
@@ -84,7 +84,7 @@ struct qtnf_mac_info {u8 sretry_limit;u8 coverage_class;u8 radar_detect_widths; -u32 max_acl_mac_addrs; +u16 max_acl_mac_addrs;struct ieee80211_ht_cap ht_cap_mod_mask;struct ieee80211_vht_cap vht_cap_mod_mask;struct ieee80211_iface_combination *if_comb;
@@ -141,7 +141,6 @@ int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *priv, const char *name, unsigned char name_assign_type);void qtnf_main_work_queue (struct work_struct *work);int qtnf_cmd_send_update_phy_params (struct qtnf_wmac *mac,u32 changed); -int qtnf_cmd_send_get_phy_params (struct qtnf_wmac *mac);struct qtnf_wmac *qtnf_core_get_mac (const struct qtnf_bus *bus,u8 macid);struct net_device *qtnf_classify_skb (struct qtnf_bus *bus,struct sk_buff *skb);
drivers/net/wireless/quantenna/qtnfmac/qlink.h +36 -28
94 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 4/10 qtnfmac: drop QTN_TLV_ID_NUM_IFACE_COMB TLV type
In reply to Sergey MatyukevichFrom: Igor Mitsyanko <[email protected]>
Information about interface combinations is now available in a fixed portion of struct qlink_resp_get_mac_info. Use that information to get interface combinations. TLV type QTN_TLV_ID_NUM_IFACE_COMB is not needed anymore and can be dropped.
--- drivers/net/wireless/quantenna/qtnfmac/commands.c | 48 +++++++++-------------- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 5 --- 2 files changed, 18 insertions(+), 35 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/commands.c +18 -30
@@ -1023,10 +1023,9 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, size_t tlv_buf_size) {const u8 *tlv_buf = resp->var_info; -struct ieee80211_iface_combination *comb =NULL ; +struct ieee80211_iface_combination *comb = mac->macinfo.if_comb;size_t n_comb =0 ;struct ieee80211_iface_limit *limits; -const struct qlink_iface_comb_num *comb_num;const struct qlink_iface_limit_record *rec;const struct qlink_iface_limit *lim;const struct qlink_wowlan_capab_data *wowlan;
@@ -1084,32 +1083,6 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, }switch (tlv_type) { -case QTN_TLV_ID_NUM_IFACE_COMB : -if (tlv_value_len !=sizeof (*comb_num)) -return -EINVAL ; - - comb_num = (void *)tlv->val; - -/* free earlier iface comb memory */ -qtnf_mac_iface_comb_free (mac); - - mac->macinfo.n_if_comb = -le32_to_cpu (comb_num->iface_comb_num); - - mac->macinfo.if_comb = -kcalloc (mac->macinfo.n_if_comb, -sizeof (*mac->macinfo.if_comb), -GFP_KERNEL ); - -if (!mac->macinfo.if_comb) -return -ENOMEM ; - - comb = mac->macinfo.if_comb; - -pr_debug ("MAC%u: %zu iface combinations\n" , - mac->macid, mac->macinfo.n_if_comb); - -break ;case QTN_TLV_ID_IFACE_LIMIT :if (unlikely (!comb)) { pr_warn("MAC%u: no combinations advertised\n",
@@ -1266,13 +1239,15 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac,return 0 ; } -static void +static int qtnf_cmd_resp_proc_mac_info (struct qtnf_wmac *mac,const struct qlink_resp_get_mac_info *resp_info) {struct qtnf_mac_info *mac_info;struct qtnf_vif *vif; +qtnf_mac_iface_comb_free (mac); + mac_info = &mac->macinfo; mac_info->bands_cap = resp_info->bands_cap;
@@ -1302,6 +1277,16 @@ qtnf_cmd_resp_proc_mac_info(struct qtnf_wmac *mac, sizeof(mac_info->ht_cap_mod_mask));memcpy (&mac_info->vht_cap_mod_mask, &resp_info->vht_cap_mod_mask,sizeof (mac_info->vht_cap_mod_mask)); + + mac_info->n_if_comb = resp_info->n_iface_combinations; + mac_info->if_comb =kcalloc (mac->macinfo.n_if_comb, +sizeof (*mac->macinfo.if_comb), +GFP_KERNEL ); + +if (!mac->macinfo.if_comb) +return -ENOMEM ; + +return 0 ; } static void qtnf_cmd_resp_band_fill_htcap(const u8 *info,
@@ -1657,7 +1642,10 @@ int qtnf_cmd_get_mac_info(struct qtnf_wmac *mac) goto out; resp = (const struct qlink_resp_get_mac_info *)resp_skb->data; -qtnf_cmd_resp_proc_mac_info (mac, resp); + ret =qtnf_cmd_resp_proc_mac_info (mac, resp); +if (ret) + goto out; + ret =qtnf_parse_variable_mac_info (mac, resp, var_data_len); out:
drivers/net/wireless/quantenna/qtnfmac/qlink.h +0 -5
@@ -1399,7 +1399,6 @@ enum qlink_tlv_id {QTN_TLV_ID_STA_STATS =0x0212 ,QTN_TLV_ID_COVERAGE_CLASS =0x0213 ,QTN_TLV_ID_IFACE_LIMIT =0x0214 , -QTN_TLV_ID_NUM_IFACE_COMB =0x0215 ,QTN_TLV_ID_CHANNEL_STATS =0x0216 ,QTN_TLV_ID_KEY =0x0302 , QTN_TLV_ID_SEQ = 0x0303,
@@ -1430,10 +1429,6 @@ struct qlink_tlv_hdr {u8 val[0 ]; } __packed; -struct qlink_iface_comb_num { -__le32 iface_comb_num; -} __packed; -struct qlink_iface_limit {__le16 max_num;__le16 type;
Signature · 1 line
2.11.0
PATCH 5/10 qtnfmac: implement extendable channel survey dump
In reply to Sergey MatyukevichFrom: Igor Mitsyanko <[email protected]>
Switch to extendable implementation of channel survey dump to make sure that any new channel statistics can be added in the future without any backwards compatibility issues. For this purpose use a separate variable length bitmap to pass the list of valid statistics in firmware response. Besides, switch to using channel frequency instead of IEEE channel number to prepare for adding support of 6GHz band.
--- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 42 +----- drivers/net/wireless/quantenna/qtnfmac/commands.c | 174 ++++++++++++++-------- drivers/net/wireless/quantenna/qtnfmac/commands.h | 4 +- drivers/net/wireless/quantenna/qtnfmac/core.h | 9 -- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 66 ++++++-- 5 files changed, 173 insertions(+), 122 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +4 -38
@@ -739,7 +739,6 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device *dev,struct ieee80211_supported_band *sband;const struct cfg80211_chan_def *chandef = &wdev->chandef;struct ieee80211_channel *chan; -struct qtnf_chan_stats stats;int ret; sband = wiphy->bands[NL80211_BAND_2GHZ ];
@@ -755,49 +754,16 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device *dev,return -ENOENT ; chan = &sband->channels[idx]; -memset (&stats,0 ,sizeof (stats)); - survey->channel = chan; survey->filled =0x0 ; -if (chandef->chan) { -if (chan->hw_value == chandef->chan->hw_value) - survey->filled =SURVEY_INFO_IN_USE ; - } +if (chan == chandef->chan) + survey->filled =SURVEY_INFO_IN_USE ; - ret =qtnf_cmd_get_chan_stats (mac, chan->hw_value, &stats); -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 : + ret =qtnf_cmd_get_chan_stats (mac, chan->center_freq, survey); +if (ret)pr_debug ("failed to get chan(%d) stats from card\n" , chan->hw_value); -break ; - }return ret; }
drivers/net/wireless/quantenna/qtnfmac/commands.c +111 -63
203 lines not on this page · raw message
drivers/net/wireless/quantenna/qtnfmac/commands.h +2 -2
@@ -59,8 +59,8 @@ int qtnf_cmd_send_updown_intf(struct qtnf_vif *vif, bool up);int qtnf_cmd_reg_notify (struct qtnf_wmac *mac,struct regulatory_request *req,bool slave_radar,bool dfs_offload); -int qtnf_cmd_get_chan_stats (struct qtnf_wmac *mac,u16 channel, -struct qtnf_chan_stats *stats); +int qtnf_cmd_get_chan_stats (struct qtnf_wmac *mac,u32 chan_freq, +struct survey_info *survey);int qtnf_cmd_send_chan_switch (struct qtnf_vif *vif,struct cfg80211_csa_settings *params);int qtnf_cmd_get_channel (struct qtnf_vif *vif,struct cfg80211_chan_def *chdef);
drivers/net/wireless/quantenna/qtnfmac/core.h +0 -9
@@ -95,15 +95,6 @@ struct qtnf_mac_info {struct wiphy_wowlan_support *wowlan; }; -struct qtnf_chan_stats { -u32 chan_num; -u32 cca_tx; -u32 cca_rx; -u32 cca_busy; -u32 cca_try; -s8 chan_noise; -}; -struct qtnf_wmac {u8 macid;u8 wiphy_registered;
drivers/net/wireless/quantenna/qtnfmac/qlink.h +56 -10
104 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 6/10 qtnfmac: pass max scan SSIDs limit on per-radio basis
In reply to Sergey MatyukevichFrom: Igor Mitsyanko <[email protected]>
Each radio on a given wifi device may have different max scan SSIDs limitation, so take this information from a per-radio info structure.
--- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 2 +- drivers/net/wireless/quantenna/qtnfmac/commands.c | 4 +--- drivers/net/wireless/quantenna/qtnfmac/core.h | 2 +- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 4 +--- 4 files changed, 4 insertions(+), 8 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +1 -1
@@ -1108,7 +1108,7 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) wiphy->coverage_class = macinfo->coverage_class; wiphy->max_scan_ssids = - (hw_info->max_scan_ssids) ? hw_info->max_scan_ssids :1 ; + (macinfo->max_scan_ssids) ? macinfo->max_scan_ssids :1 ; wiphy->max_scan_ie_len =QTNF_MAX_VSIE_LEN ; wiphy->mgmt_stypes = qtnf_mgmt_stypes; wiphy->max_remain_on_channel_duration =5000 ;
drivers/net/wireless/quantenna/qtnfmac/commands.c +1 -3
@@ -941,9 +941,6 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus,case QTN_TLV_ID_UBOOT_VER : uboot_ver = (const void *)tlv->val;break ; -case QTN_TLV_ID_MAX_SCAN_SSIDS : - hwinfo->max_scan_ssids = *tlv->val; -break ;case QTN_TLV_ID_BITMAP :memcpy (hwinfo->hw_capab, tlv->val,min (sizeof (hwinfo->hw_capab), (size_t )tlv_len));
@@ -1272,6 +1269,7 @@ qtnf_cmd_resp_proc_mac_info(struct qtnf_wmac *mac, mac_info->sretry_limit = resp_info->retry_short; mac_info->lretry_limit = resp_info->retry_long; mac_info->coverage_class = resp_info->coverage_class; + mac_info->max_scan_ssids = resp_info->max_scan_ssids;memcpy (&mac_info->ht_cap_mod_mask, &resp_info->ht_cap_mod_mask,sizeof (mac_info->ht_cap_mod_mask));
drivers/net/wireless/quantenna/qtnfmac/core.h +1 -1
@@ -84,6 +84,7 @@ struct qtnf_mac_info {u8 sretry_limit;u8 coverage_class;u8 radar_detect_widths; +u8 max_scan_ssids;u16 max_acl_mac_addrs;struct ieee80211_ht_cap ht_cap_mod_mask;struct ieee80211_vht_cap vht_cap_mod_mask;
@@ -117,7 +118,6 @@ struct qtnf_hw_info {u8 total_rx_chain;char fw_version[ETHTOOL_FWVERS_LEN ];u32 hw_version; -u8 max_scan_ssids;u8 hw_capab[QLINK_HW_CAPAB_NUM /BITS_PER_BYTE +1 ]; };
drivers/net/wireless/quantenna/qtnfmac/qlink.h +1 -3
@@ -965,6 +965,7 @@ enum qlink_dfs_regions {* @num_rx_chain: Number of receive chains used by WMAC. * @vht_cap_mod_mask: mask specifying which VHT capabilities can be altered. * @ht_cap_mod_mask: mask specifying which HT capabilities can be altered. +* @max_scan_ssids: maximum number of SSIDs the device can scan for in any scan. * @bands_cap: wireless bands WMAC can operate in, bitmap of &enum qlink_band. * @max_ap_assoc_sta: Maximum number of associations supported by WMAC. * @radar_detect_widths: bitmask of channels BW for which WMAC can detect radar.
@@ -1378,8 +1379,6 @@ struct qlink_event_mic_failure {* @QTN_TLV_ID_STA_STATS: per-STA statistics as defined by * &struct qlink_sta_stats. Valid values are marked as such in a bitmap * carried by QTN_TLV_ID_BITMAP. -* @QTN_TLV_ID_MAX_SCAN_SSIDS: maximum number of SSIDs the device can scan -* for in any given scan. * @QTN_TLV_ID_SCAN_DWELL_ACTIVE: time spent on a single channel for an active * scan. * @QTN_TLV_ID_SCAN_DWELL_PASSIVE: time spent on a single channel for a passive
@@ -1415,7 +1414,6 @@ enum qlink_tlv_id {QTN_TLV_ID_CALIBRATION_VER =0x0406 ,QTN_TLV_ID_UBOOT_VER =0x0407 ,QTN_TLV_ID_RANDOM_MAC_ADDR =0x0408 , -QTN_TLV_ID_MAX_SCAN_SSIDS =0x0409 ,QTN_TLV_ID_WOWLAN_CAPAB =0x0410 ,QTN_TLV_ID_WOWLAN_PATTERN =0x0411 , QTN_TLV_ID_SCAN_FLUSH = 0x0412,
Signature · 1 line
2.11.0
PATCH 7/10 qtnfmac: cleanup alignment in firmware communication protocol
In reply to Sergey MatyukevichFrom: Igor Mitsyanko <[email protected]>
Make sure that all elements in QLINK protocol message are aligned to 4 bytes. For this purpose add necessary amount of padding bytes to each message. Besides, add padding for non-aligned variable length fields, e.g. SSID, so that the first byte of the next variable length element is aligned. to 4 bytes. Finally, introduce TLV parsing helpers to reduce boilerplate TLV parsing code.
--- drivers/net/wireless/quantenna/qtnfmac/commands.c | 142 ++++++++------------- drivers/net/wireless/quantenna/qtnfmac/event.c | 58 ++------- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 27 +++- .../net/wireless/quantenna/qtnfmac/qlink_util.h | 37 +++--- 4 files changed, 103 insertions(+), 161 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/commands.c +52 -90
@@ -175,7 +175,8 @@ static void qtnf_cmd_tlv_ie_set_add(struct sk_buff *cmd_skb, u8 frame_type, {struct qlink_tlv_ie_set *tlv; - tlv = (struct qlink_tlv_ie_set *)skb_put (cmd_skb,sizeof (*tlv) + len); + tlv = (struct qlink_tlv_ie_set *)skb_put (cmd_skb,sizeof (*tlv) + +round_up (len,QLINK_ALIGN )); tlv->hdr.type =cpu_to_le16 (QTN_TLV_ID_IE_SET ); tlv->hdr.len =cpu_to_le16 (len +sizeof (*tlv) -sizeof (tlv->hdr)); tlv->type = frame_type;
@@ -190,20 +191,24 @@ static bool qtnf_cmd_start_ap_can_fit(const struct qtnf_vif *vif, {unsigned int len =sizeof (struct qlink_cmd_start_ap ); - len += s->ssid_len; - len += s->beacon.head_len; - len += s->beacon.tail_len; - len += s->beacon.beacon_ies_len; - len += s->beacon.proberesp_ies_len; - len += s->beacon.assocresp_ies_len; - len += s->beacon.probe_resp_len; + len +=round_up (s->ssid_len,QLINK_ALIGN ); + len +=round_up (s->beacon.head_len,QLINK_ALIGN ); + len +=round_up (s->beacon.tail_len,QLINK_ALIGN ); + len +=round_up (s->beacon.beacon_ies_len,QLINK_ALIGN ); + len +=round_up (s->beacon.proberesp_ies_len,QLINK_ALIGN ); + len +=round_up (s->beacon.assocresp_ies_len,QLINK_ALIGN ); + len +=round_up (s->beacon.probe_resp_len,QLINK_ALIGN );if (cfg80211_chandef_valid (&s->chandef)) len +=sizeof (struct qlink_tlv_chandef ); -if (s->acl) +if (s->acl) { +unsigned int acl_len =struct_size (s->acl, mac_addrs, + s->acl->n_acl_entries); + len +=sizeof (struct qlink_tlv_hdr ) + -struct_size (s->acl, mac_addrs, s->acl->n_acl_entries); +round_up (acl_len,QLINK_ALIGN ); + }if (len > (sizeof (struct qlink_cmd ) +QTNF_MAX_CMD_BUF_SIZE )) { pr_err("VIF%u.%u: can not fit AP settings: %u\n",
@@ -315,7 +320,8 @@ int qtnf_cmd_send_start_ap(struct qtnf_vif *vif,if (s->ht_cap) {struct qlink_tlv_hdr *tlv = (struct qlink_tlv_hdr *) -skb_put (cmd_skb,sizeof (*tlv) +sizeof (*s->ht_cap)); +skb_put (cmd_skb,sizeof (*tlv) + +round_up (sizeof (*s->ht_cap),QLINK_ALIGN )); tlv->type =cpu_to_le16 (WLAN_EID_HT_CAPABILITY ); tlv->len =cpu_to_le16 (sizeof (*s->ht_cap));
@@ -339,7 +345,8 @@ int qtnf_cmd_send_start_ap(struct qtnf_vif *vif,size_t acl_size =struct_size (s->acl, mac_addrs, s->acl->n_acl_entries);struct qlink_tlv_hdr *tlv = -skb_put (cmd_skb,sizeof (*tlv) + acl_size); +skb_put (cmd_skb, +sizeof (*tlv) +round_up (acl_size,QLINK_ALIGN )); tlv->type =cpu_to_le16 (QTN_TLV_ID_ACL_DATA ); tlv->len =cpu_to_le16 (acl_size);
@@ -581,10 +588,10 @@ qtnf_sta_info_parse_flags(struct nl80211_sta_flag_update *dst, }static void -qtnf_cmd_sta_info_parse (struct station_info *sinfo, -const struct qlink_tlv_hdr *tlv, +qtnf_cmd_sta_info_parse (struct station_info *sinfo,const u8 *data,size_t resp_size) { +const struct qlink_tlv_hdr *tlv;const struct qlink_sta_stats *stats =NULL ;const u8 *map =NULL ;unsigned int map_len =0 ;
@@ -595,7 +602,7 @@ qtnf_cmd_sta_info_parse(struct station_info *sinfo, (qtnf_utils_is_bit_set (map, bitn, map_len) && \ (offsetofend(struct qlink_sta_stats, stat_name) <= stats_len)) -while (resp_size >=sizeof (*tlv)) { +qlink_for_each_tlv (tlv, data, resp_size) { tlv_len =le16_to_cpu (tlv->len);switch (le16_to_cpu (tlv->type)) {
@@ -610,9 +617,11 @@ qtnf_cmd_sta_info_parse(struct station_info *sinfo,default :break ; } + } - resp_size -= tlv_len +sizeof (*tlv); - tlv = (const struct qlink_tlv_hdr *)(tlv->val + tlv_len); +if (!qlink_tlv_parsing_ok (tlv, data, resp_size)) { +pr_err ("Malformed TLV buffer\n" ); +return ; }if (!map || !stats)
@@ -736,9 +745,7 @@ int qtnf_cmd_get_sta_info(struct qtnf_vif *vif, const u8 *sta_mac, goto out; } -qtnf_cmd_sta_info_parse (sinfo, - (const struct qlink_tlv_hdr *)resp->info, - var_resp_len); +qtnf_cmd_sta_info_parse (sinfo, resp->info, var_resp_len); out:qtnf_bus_unlock (vif->mac->bus);
@@ -907,18 +914,10 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus, plat_id =le32_to_cpu (resp->plat_id); hw_ver =le32_to_cpu (resp->hw_ver); - tlv = (const struct qlink_tlv_hdr *)resp->info; - -while (info_len >=sizeof (*tlv)) { +qlink_for_each_tlv (tlv, resp->info, info_len) { tlv_type =le16_to_cpu (tlv->type); tlv_len =le16_to_cpu (tlv->len); -if (tlv_len +sizeof (*tlv) > info_len) { -pr_warn ("malformed TLV 0x%.2X; LEN: %u\n" , - tlv_type, tlv_len); -return -EINVAL ; - } -switch (tlv_type) {case QTN_TLV_ID_BUILD_NAME : bld_name = (const void *)tlv->val;
@@ -948,9 +947,11 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus,default :break ; } + } - info_len -= tlv_len +sizeof (*tlv); - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_len); +if (!qlink_tlv_parsing_ok (tlv, resp->info, info_len)) { +pr_err ("Malformed TLV buffer\n" ); +return -EINVAL ; } pr_info("\nBuild name: %s\n"
@@ -1019,7 +1020,6 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, const struct qlink_resp_get_mac_info *resp, size_t tlv_buf_size) { - const u8 *tlv_buf = resp->var_info;struct ieee80211_iface_combination *comb = mac->macinfo.if_comb;size_t n_comb =0 ;struct ieee80211_iface_limit *limits;
@@ -1029,7 +1029,6 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac,u16 rec_len;u16 tlv_type;u16 tlv_value_len; -size_t tlv_full_len;const struct qlink_tlv_hdr *tlv;u8 *ext_capa =NULL ;u8 *ext_capa_mask =NULL ;
@@ -1068,16 +1067,9 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac,break ; } - tlv = (const struct qlink_tlv_hdr *)tlv_buf; -while (tlv_buf_size >=sizeof (struct qlink_tlv_hdr )) { +qlink_for_each_tlv (tlv, resp->var_info, tlv_buf_size) { 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 > tlv_buf_size) { -pr_warn ("MAC%u: malformed TLV 0x%.2X; LEN: %u\n" , - mac->macid, tlv_type, tlv_value_len); -return -EINVAL ; - }switch (tlv_type) {case QTN_TLV_ID_IFACE_LIMIT :
@@ -1183,14 +1175,10 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, mac->macid, tlv_type);break ; } - - tlv_buf_size -= tlv_full_len; - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); } -if (tlv_buf_size) { -pr_warn ("MAC%u: malformed TLV buf; bytes left: %zu\n" , - mac->macid, tlv_buf_size); +if (!qlink_tlv_parsing_ok (tlv, resp->var_info, tlv_buf_size)) { +pr_err ("Malformed TLV buffer\n" );return -EINVAL ; }
@@ -1383,7 +1371,6 @@ qtnf_cmd_resp_fill_band_info(struct ieee80211_supported_band *band, size_t payload_len) {u16 tlv_type; -size_t tlv_len;size_t tlv_dlen;const struct qlink_tlv_hdr *tlv;const struct qlink_channel *qchan;
@@ -1418,24 +1405,15 @@ qtnf_cmd_resp_fill_band_info(struct ieee80211_supported_band *band,return -ENOMEM ; } - tlv = (struct qlink_tlv_hdr *)resp->info; - -while (payload_len >=sizeof (*tlv)) { +qlink_for_each_tlv (tlv, resp->info, payload_len) { tlv_type =le16_to_cpu (tlv->type); tlv_dlen =le16_to_cpu (tlv->len); - tlv_len = tlv_dlen +sizeof (*tlv); - -if (tlv_len > payload_len) { -pr_warn ("malformed TLV 0x%.2X; LEN: %zu\n" , - tlv_type, tlv_len); - goto error_ret; - }switch (tlv_type) {case QTN_TLV_ID_CHANNEL :if (unlikely (tlv_dlen !=sizeof (*qchan))) {pr_err ("invalid channel TLV len %zu\n" , - tlv_len); + tlv_dlen); goto error_ret; }
@@ -1538,13 +1516,10 @@ qtnf_cmd_resp_fill_band_info(struct ieee80211_supported_band *band,pr_warn ("unknown TLV type: %#x\n" , tlv_type);break ; } - - payload_len -= tlv_len; - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_dlen); } -if (payload_len) { -pr_err ("malformed TLV buf; bytes left: %zu\n" , payload_len); +if (!qlink_tlv_parsing_ok (tlv, resp->info, payload_len)) { +pr_err ("Malformed TLV buffer\n" ); goto error_ret; }
@@ -1689,16 +1664,16 @@ int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed)qtnf_cmd_skb_put_tlv_u32 (cmd_skb,QTN_TLV_ID_RTS_THRESH , wiphy->rts_threshold);if (changed &WIPHY_PARAM_COVERAGE_CLASS ) -qtnf_cmd_skb_put_tlv_u8 (cmd_skb,QTN_TLV_ID_COVERAGE_CLASS , - wiphy->coverage_class); +qtnf_cmd_skb_put_tlv_u32 (cmd_skb,QTN_TLV_ID_COVERAGE_CLASS , + wiphy->coverage_class);if (changed &WIPHY_PARAM_RETRY_LONG ) -qtnf_cmd_skb_put_tlv_u8 (cmd_skb,QTN_TLV_ID_LRETRY_LIMIT , - wiphy->retry_long); +qtnf_cmd_skb_put_tlv_u32 (cmd_skb,QTN_TLV_ID_LRETRY_LIMIT , + wiphy->retry_long);if (changed &WIPHY_PARAM_RETRY_SHORT ) -qtnf_cmd_skb_put_tlv_u8 (cmd_skb,QTN_TLV_ID_SRETRY_LIMIT , - wiphy->retry_short); +qtnf_cmd_skb_put_tlv_u32 (cmd_skb,QTN_TLV_ID_SRETRY_LIMIT , + wiphy->retry_short); ret =qtnf_cmd_send (mac->bus, cmd_skb);if (ret)
@@ -2054,13 +2029,13 @@ static void qtnf_cmd_scan_set_dwell(struct qtnf_wmac *mac, scan_req->duration_mandatory ?"mandatory" :"max" , dwell_active, dwell_passive, duration); -qtnf_cmd_skb_put_tlv_u16 (cmd_skb, +qtnf_cmd_skb_put_tlv_u32 (cmd_skb,QTN_TLV_ID_SCAN_DWELL_ACTIVE , dwell_active); -qtnf_cmd_skb_put_tlv_u16 (cmd_skb, +qtnf_cmd_skb_put_tlv_u32 (cmd_skb,QTN_TLV_ID_SCAN_DWELL_PASSIVE , dwell_passive); -qtnf_cmd_skb_put_tlv_u16 (cmd_skb, +qtnf_cmd_skb_put_tlv_u32 (cmd_skb,QTN_TLV_ID_SCAN_SAMPLE_DURATION , duration); }
@@ -2416,25 +2391,15 @@ qtnf_cmd_resp_proc_chan_stat_info(struct survey_info *survey, {const struct qlink_chan_stats *stats =NULL ;const struct qlink_tlv_hdr *tlv; -size_t tlv_full_len;u16 tlv_value_len;u16 tlv_type;const u8 *map =NULL ;unsigned int map_len =0 ;unsigned int stats_len =0 ; - tlv = (struct qlink_tlv_hdr *)payload; - -while (payload_len >=sizeof (*tlv)) { +qlink_for_each_tlv (tlv, payload, payload_len) { tlv_type =le16_to_cpu (tlv->type); tlv_value_len =le16_to_cpu (tlv->len); - tlv_full_len = tlv_value_len +sizeof (*tlv); - -if (tlv_full_len > payload_len) { -pr_warn ("malformed TLV 0x%.2X; LEN: %u\n" , - tlv_type, tlv_value_len); -return -ENOSPC ; - }switch (tlv_type) {case QTN_TLV_ID_BITMAP :
@@ -2449,13 +2414,10 @@ qtnf_cmd_resp_proc_chan_stat_info(struct survey_info *survey,pr_info ("Unknown TLV type: %#x\n" , tlv_type);break ; } - - payload_len -= tlv_full_len; - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); } -if (payload_len) { -pr_warn ("malformed TLV buf; bytes left: %zu\n" , payload_len); +if (!qlink_tlv_parsing_ok (tlv, payload, payload_len)) { +pr_err ("Malformed TLV buffer\n" );return -EINVAL ; }
@@ -2657,7 +2619,7 @@ int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif,if (!cmd_skb)return -ENOMEM ; - tlv =skb_put (cmd_skb,sizeof (*tlv) + acl_size); + tlv =skb_put (cmd_skb,sizeof (*tlv) +round_up (acl_size,QLINK_ALIGN )); tlv->type =cpu_to_le16 (QTN_TLV_ID_ACL_DATA ); tlv->len =cpu_to_le16 (acl_size);qlink_acl_data_cfg2q (params, (struct qlink_acl_data *)tlv->val);
drivers/net/wireless/quantenna/qtnfmac/event.c +14 -44
142 lines not on this page · raw message
drivers/net/wireless/quantenna/qtnfmac/qlink.h +22 -5
@@ -19,6 +19,8 @@#define QLINK_PROTO_VER \ QLINK_VER(QLINK_PROTO_VER_MAJOR, QLINK_PROTO_VER_MINOR) +#define QLINK_ALIGN 4 +#define QLINK_MACID_RSVD 0xFF#define QLINK_VIFID_RSVD 0xFF
@@ -184,7 +186,7 @@ struct qlink_chandef {__le16 center_freq1;__le16 center_freq2;u8 width; -u8 rsvd; +u8 rsvd[3 ]; } __packed;#define QLINK_MAX_NR_CIPHER_SUITES 5
@@ -340,9 +342,9 @@ struct qlink_cmd {struct qlink_msg_header mhdr;__le16 cmd_id;__le16 seq_num; -u8 rsvd[2 ];u8 macid;u8 vifid; +u8 rsvd[2 ]; } __packed;/**
@@ -404,6 +406,7 @@ struct qlink_cmd_mgmt_frame_register {struct qlink_cmd chdr;__le16 frame_type;u8 do_register; +u8 rsvd[1 ]; } __packed;/**
@@ -441,6 +444,7 @@ struct qlink_cmd_frame_tx {struct qlink_cmd_get_sta_info {struct qlink_cmd chdr;u8 sta_addr[ETH_ALEN ]; +u8 rsvd[2 ]; } __packed;/**
@@ -460,6 +464,7 @@ struct qlink_cmd_add_key {u8 addr[ETH_ALEN ];__le32 cipher;__le16 vlanid; +u8 rsvd[2 ];u8 key_data[0 ]; } __packed;
@@ -489,6 +494,7 @@ struct qlink_cmd_set_def_key {u8 key_index;u8 unicast;u8 multicast; +u8 rsvd[1 ]; } __packed;/**
@@ -499,6 +505,7 @@ struct qlink_cmd_set_def_key {struct qlink_cmd_set_def_mgmt_key {struct qlink_cmd chdr;u8 key_index; +u8 rsvd[3 ]; } __packed;/**
@@ -515,6 +522,7 @@ struct qlink_cmd_change_sta {__le16 if_type;__le16 vlanid;u8 sta_addr[ETH_ALEN ]; +u8 rsvd[2 ]; } __packed;/**
@@ -525,8 +533,9 @@ struct qlink_cmd_change_sta {struct qlink_cmd_del_sta {struct qlink_cmd chdr;__le16 reason_code; -u8 subtype;u8 sta_addr[ETH_ALEN ]; +u8 subtype; +u8 rsvd[3 ]; } __packed;enum qlink_sta_connect_flags {
@@ -593,6 +602,7 @@ struct qlink_cmd_external_auth {struct qlink_cmd_disconnect {struct qlink_cmd chdr;__le16 reason; +u8 rsvd[2 ]; } __packed;/**
@@ -604,6 +614,7 @@ struct qlink_cmd_disconnect {struct qlink_cmd_updown {struct qlink_cmd chdr;u8 if_up; +u8 rsvd[3 ]; } __packed;/**
@@ -627,6 +638,7 @@ enum qlink_band {struct qlink_cmd_band_info_get {struct qlink_cmd chdr;u8 band; +u8 rsvd[3 ]; } __packed;/**
@@ -702,6 +714,7 @@ struct qlink_cmd_chan_switch {u8 radar_required;u8 block_tx;u8 beacon_count; +u8 rsvd[3 ]; } __packed;/**
@@ -805,6 +818,7 @@ struct qlink_cmd_pm_set {struct qlink_cmd chdr;__le32 pm_standby_timer;u8 pm_mode; +u8 rsvd[3 ]; } __packed;/**
@@ -1225,6 +1239,7 @@ struct qlink_event_bss_join {struct qlink_event_bss_leave {struct qlink_event ehdr;__le16 reason; +u8 rsvd[2 ]; } __packed;/**
@@ -1341,10 +1356,10 @@ struct qlink_event_radar {*/ struct qlink_event_external_auth {struct qlink_event ehdr; +__le32 akm_suite;u8 ssid[IEEE80211_MAX_SSID_LEN ]; -u8 ssid_len;u8 bssid[ETH_ALEN ]; -__le32 akm_suite; +u8 ssid_len;u8 action; } __packed;
@@ -1560,6 +1575,7 @@ struct qlink_tlv_ie_set {struct qlink_tlv_hdr hdr;u8 type;u8 flags; +u8 rsvd[2 ];u8 ie_data[0 ]; } __packed;
@@ -1572,6 +1588,7 @@ struct qlink_tlv_ie_set {struct qlink_tlv_ext_ie {struct qlink_tlv_hdr hdr;u8 eid_ext; +u8 rsvd[3 ];u8 ie_data[0 ]; } __packed;
drivers/net/wireless/quantenna/qtnfmac/qlink_util.h +15 -22
@@ -20,8 +20,9 @@ static inline void qtnf_cmd_skb_put_tlv_arr(struct sk_buff *skb, u16 tlv_id, const u8 arr[], size_t arr_len) { - struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + arr_len); + struct qlink_tlv_hdr *hdr; + hdr =skb_put (skb,sizeof (*hdr) +round_up (arr_len,QLINK_ALIGN )); hdr->type =cpu_to_le16 (tlv_id); hdr->len =cpu_to_le16 (arr_len);memcpy (hdr->val, arr, arr_len);
@@ -35,27 +36,6 @@ static inline void qtnf_cmd_skb_put_tlv_tag(struct sk_buff *skb, u16 tlv_id) hdr->len =cpu_to_le16 (0 ); } -static inline void qtnf_cmd_skb_put_tlv_u8 (struct sk_buff *skb,u16 tlv_id, -u8 value) -{ -struct qlink_tlv_hdr *hdr =skb_put (skb,sizeof (*hdr) +sizeof (value)); - - hdr->type =cpu_to_le16 (tlv_id); - hdr->len =cpu_to_le16 (sizeof (value)); - *hdr->val = value; -} - -static inline void qtnf_cmd_skb_put_tlv_u16 (struct sk_buff *skb, -u16 tlv_id,u16 value) -{ -struct qlink_tlv_hdr *hdr =skb_put (skb,sizeof (*hdr) +sizeof (value)); -__le16 tmp =cpu_to_le16 (value); - - hdr->type =cpu_to_le16 (tlv_id); - hdr->len =cpu_to_le16 (sizeof (value)); -memcpy (hdr->val, &tmp,sizeof (tmp)); -} -static inline void qtnf_cmd_skb_put_tlv_u32 (struct sk_buff *skb,u16 tlv_id,u32 value) {
@@ -85,4 +65,17 @@ u32 qlink_utils_chflags_cfg2q(u32 cfgflags);void qlink_utils_regrule_q2nl (struct ieee80211_reg_rule *rule,const struct qlink_tlv_reg_rule *tlv_rule); +#define qlink_for_each_tlv (_tlv, _start, _datalen) \ + for (_tlv = (const struct qlink_tlv_hdr *)(_start); \ + (const u8 *)(_start) + (_datalen) - (const u8 *)_tlv >= \ + (int)sizeof(*_tlv) && \ + (const u8 *)(_start) + (_datalen) - (const u8 *)_tlv >= \ + (int)sizeof(*_tlv) + le16_to_cpu(_tlv->len); \ + _tlv = (const struct qlink_tlv_hdr *)(_tlv->val + \ + round_up(le16_to_cpu(_tlv->len), QLINK_ALIGN))) + +#define qlink_tlv_parsing_ok (_tlv_last, _start, _datalen) \ + ((const u8 *)(_tlv_last) == \ + (const u8 *)(_start) + round_up(_datalen, QLINK_ALIGN)) +#endif /* _QTN_FMAC_QLINK_UTIL_H_ */
Signature · 1 line
2.11.0
PATCH 8/10 qtnfmac: update channel switch command to support 6GHz band
In reply to Sergey MatyukevichFrom: Igor Mitsyanko <[email protected]>
With an addition of 6GHz band support, channel number can no longer be used to uniquely identify a specific channel. Modify channel switch command to use chandef data.
--- drivers/net/wireless/quantenna/qtnfmac/commands.c | 17 +++++++-------- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 25 +++++++++++++++++------ 2 files changed, 28 insertions(+), 14 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/commands.c +9 -8
@@ -2519,6 +2519,7 @@ int qtnf_cmd_send_chan_switch(struct qtnf_vif *vif,struct qlink_cmd_chan_switch *cmd;struct sk_buff *cmd_skb;int ret; +u64 flags =0 ; cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, vif->vifid, QLINK_CMD_CHAN_SWITCH,
@@ -2526,19 +2527,19 @@ int qtnf_cmd_send_chan_switch(struct qtnf_vif *vif,if (!cmd_skb)return -ENOMEM ; -qtnf_bus_lock (mac->bus); +if (params->radar_required) + flags |=QLINK_CHAN_SW_RADAR_REQUIRED ; + +if (params->block_tx) + flags |=QLINK_CHAN_SW_BLOCK_TX ; cmd = (struct qlink_cmd_chan_switch *)cmd_skb->data; - cmd->channel =cpu_to_le16 (params->chandef.chan->hw_value); - cmd->radar_required = params->radar_required; - cmd->block_tx = params->block_tx; +qlink_chandef_cfg2q (¶ms->chandef, &cmd->channel); + cmd->flags =cpu_to_le64 (flags); cmd->beacon_count = params->count; +qtnf_bus_lock (mac->bus); ret =qtnf_cmd_send (mac->bus, cmd_skb); -if (ret) - goto out; - -out:qtnf_bus_unlock (mac->bus);return ret;
drivers/net/wireless/quantenna/qtnfmac/qlink.h +19 -6
@@ -701,18 +701,31 @@ struct qlink_cmd_reg_notify { } __packed;/** +* enum qlink_chan_sw_flags - channel switch control flags +* +* @QLINK_CHAN_SW_RADAR_REQUIRED: whether radar detection is required on a new +* channel. +* @QLINK_CHAN_SW_BLOCK_TX: whether transmissions should be blocked while +* changing a channel. +*/ +enum qlink_chan_sw_flags { +QLINK_CHAN_SW_RADAR_REQUIRED =BIT (0 ), +QLINK_CHAN_SW_BLOCK_TX =BIT (1 ), +}; + +/** * struct qlink_cmd_chan_switch - data for QLINK_CMD_CHAN_SWITCH command * -* @channel: channel number according to 802.11 17.3.8.3.2 and Annex J -* @radar_required: whether radar detection is required on the new channel -* @block_tx: whether transmissions should be blocked while changing +* @channel: channel to switch to. +* @flags: flags to control channel switch, bitmap of &enum qlink_chan_sw_flags. * @beacon_count: number of beacons until switch */ struct qlink_cmd_chan_switch {struct qlink_cmd chdr; -__le16 channel; -u8 radar_required; -u8 block_tx; +struct qlink_chandef channel; +__le64 flags; +__le32 n_counter_offsets_beacon; +__le32 n_counter_offsets_presp;u8 beacon_count;u8 rsvd[3 ]; } __packed;
Signature · 1 line
2.11.0
PATCH 9/10 qtnfmac: drop unnecessary TLVs from scan command
In reply to Sergey MatyukevichFrom: Igor Mitsyanko <[email protected]>
Most part of scan command data is always present, so no need to keep it in TLV. Simplify scan command processing moving most part of its parameters into a fixed part of qlink_cmd_scan message.
Use fixed dwell time values for normal scan when device is not connected, and allow wireless card decide on dwell times by itself if it's operating as a STA and is connected. When connected, card can select dwell times dynamically based on traffic conditions to get best results.
--- drivers/net/wireless/quantenna/qtnfmac/commands.c | 130 +++++++++------------ drivers/net/wireless/quantenna/qtnfmac/qlink.h | 51 ++++++-- .../net/wireless/quantenna/qtnfmac/qlink_util.h | 8 -- 3 files changed, 96 insertions(+), 93 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/commands.c +56 -74
@@ -11,11 +11,11 @@#include "bus.h" #include "commands.h" +/* Let device itself to select best values for current conditions */ #define QTNF_SCAN_TIME_AUTO 0 -/* Let device itself to select best values for current conditions */ -#define QTNF_SCAN_DWELL_ACTIVE_DEFAULT QTNF_SCAN_TIME_AUTO -#define QTNF_SCAN_DWELL_PASSIVE_DEFAULT QTNF_SCAN_TIME_AUTO +#define QTNF_SCAN_DWELL_ACTIVE_DEFAULT 90 +#define QTNF_SCAN_DWELL_PASSIVE_DEFAULT 100#define QTNF_SCAN_SAMPLE_DURATION_DEFAULT QTNF_SCAN_TIME_AUTO static int qtnf_cmd_check_reply_header(const struct qlink_resp *resp,
@@ -2011,108 +2011,90 @@ static void qtnf_cmd_randmac_tlv_add(struct sk_buff *cmd_skb,memcpy (randmac->mac_addr_mask, mac_addr_mask,ETH_ALEN ); } -static void qtnf_cmd_scan_set_dwell (struct qtnf_wmac *mac, -struct sk_buff *cmd_skb) +int qtnf_cmd_send_scan (struct qtnf_wmac *mac) {struct cfg80211_scan_request *scan_req = mac->scan_req; -u16 dwell_active =QTNF_SCAN_DWELL_ACTIVE_DEFAULT ;u16 dwell_passive =QTNF_SCAN_DWELL_PASSIVE_DEFAULT ; -u16 duration =QTNF_SCAN_SAMPLE_DURATION_DEFAULT ; - -if (scan_req->duration) { - dwell_active = scan_req->duration; - dwell_passive = scan_req->duration; - } - -pr_debug ("MAC%u: %s scan dwell active=%u, passive=%u, duration=%u\n" , - mac->macid, - scan_req->duration_mandatory ?"mandatory" :"max" , - dwell_active, dwell_passive, duration); - -qtnf_cmd_skb_put_tlv_u32 (cmd_skb, -QTN_TLV_ID_SCAN_DWELL_ACTIVE , - dwell_active); -qtnf_cmd_skb_put_tlv_u32 (cmd_skb, -QTN_TLV_ID_SCAN_DWELL_PASSIVE , - dwell_passive); -qtnf_cmd_skb_put_tlv_u32 (cmd_skb, -QTN_TLV_ID_SCAN_SAMPLE_DURATION , - duration); -} - -int qtnf_cmd_send_scan (struct qtnf_wmac *mac) -{ -struct sk_buff *cmd_skb; +u16 dwell_active =QTNF_SCAN_DWELL_ACTIVE_DEFAULT ; +struct wireless_dev *wdev = scan_req->wdev;struct ieee80211_channel *sc; -struct cfg80211_scan_request *scan_req = mac->scan_req; -int n_channels; -int count =0 ; +struct qlink_cmd_scan *cmd; +struct sk_buff *cmd_skb; +int n_channels =0 ; +u64 flags =0 ; +int count;int ret; cmd_skb =qtnf_cmd_alloc_new_cmdskb (mac->macid,QLINK_VIFID_RSVD ,QLINK_CMD_SCAN , -sizeof (struct qlink_cmd )); +sizeof (*cmd));if (!cmd_skb)return -ENOMEM ; -qtnf_bus_lock (mac->bus); + cmd = (struct qlink_cmd_scan *)cmd_skb->data; -if (scan_req->n_ssids !=0 ) { -while (count < scan_req->n_ssids) { -qtnf_cmd_skb_put_tlv_arr (cmd_skb,WLAN_EID_SSID , - scan_req->ssids[count].ssid, - scan_req->ssids[count].ssid_len); - count++; - } +if (scan_req->duration) { + dwell_active = scan_req->duration; + dwell_passive = scan_req->duration; + }else if (wdev->iftype ==NL80211_IFTYPE_STATION && + wdev->current_bss) { +/* let device select dwell based on traffic conditions */ + dwell_active =QTNF_SCAN_TIME_AUTO ; + dwell_passive =QTNF_SCAN_TIME_AUTO ; + } + + cmd->n_ssids =cpu_to_le16 (scan_req->n_ssids); +for (count =0 ; count < scan_req->n_ssids; ++count) { +qtnf_cmd_skb_put_tlv_arr (cmd_skb,WLAN_EID_SSID , + scan_req->ssids[count].ssid, + scan_req->ssids[count].ssid_len); }if (scan_req->ie_len !=0 )qtnf_cmd_tlv_ie_set_add (cmd_skb,QLINK_IE_SET_PROBE_REQ , scan_req->ie, scan_req->ie_len); -if (scan_req->n_channels) { - n_channels = scan_req->n_channels; - count =0 ; - -while (n_channels !=0 ) { - sc = scan_req->channels[count]; -if (sc->flags &IEEE80211_CHAN_DISABLED ) { - n_channels--; -continue ; - } +for (count =0 ; count < scan_req->n_channels; ++count) { + sc = scan_req->channels[count]; +if (sc->flags &IEEE80211_CHAN_DISABLED ) +continue ; -pr_debug ("MAC%u: scan chan=%d, freq=%d, flags=%#x\n" , - mac->macid, sc->hw_value, sc->center_freq, - sc->flags); +pr_debug ("[MAC%u] scan chan=%d, freq=%d, flags=%#x\n" , + mac->macid, sc->hw_value, sc->center_freq, + sc->flags); -qtnf_cmd_channel_tlv_add (cmd_skb, sc); - n_channels--; - count++; - } +qtnf_cmd_channel_tlv_add (cmd_skb, sc); + ++n_channels; } -qtnf_cmd_scan_set_dwell (mac, cmd_skb); +if (scan_req->flags &NL80211_SCAN_FLAG_FLUSH ) + flags |=QLINK_SCAN_FLAG_FLUSH ; + +if (scan_req->duration_mandatory) + flags |=QLINK_SCAN_FLAG_DURATION_MANDATORY ; + + cmd->n_channels =cpu_to_le16 (n_channels); + cmd->active_dwell =cpu_to_le16 (dwell_active); + cmd->passive_dwell =cpu_to_le16 (dwell_passive); + cmd->sample_duration =cpu_to_le16 (QTNF_SCAN_SAMPLE_DURATION_DEFAULT ); + cmd->flags =cpu_to_le64 (flags); + +pr_debug ("[MAC%u] %s scan dwell active=%u passive=%u duration=%u\n" , + mac->macid, + scan_req->duration_mandatory ?"mandatory" :"max" , + dwell_active, dwell_passive, +QTNF_SCAN_SAMPLE_DURATION_DEFAULT );if (scan_req->flags &NL80211_SCAN_FLAG_RANDOM_ADDR ) { -pr_debug ("MAC%u: scan with random addr=%pM, mask=%pM\n" , +pr_debug ("[MAC%u] scan with random addr=%pM, mask=%pM\n" , mac->macid, scan_req->mac_addr, scan_req->mac_addr_mask); -qtnf_cmd_randmac_tlv_add (cmd_skb, scan_req->mac_addr, scan_req->mac_addr_mask); } -if (scan_req->flags &NL80211_SCAN_FLAG_FLUSH ) { -pr_debug ("MAC%u: flush cache before scan\n" , mac->macid); - -qtnf_cmd_skb_put_tlv_tag (cmd_skb,QTN_TLV_ID_SCAN_FLUSH ); - } - +qtnf_bus_lock (mac->bus); ret =qtnf_cmd_send (mac->bus, cmd_skb); -if (ret) - goto out; - -out:qtnf_bus_unlock (mac->bus);return ret;
drivers/net/wireless/quantenna/qtnfmac/qlink.h +40 -11
69 lines not on this page · raw message
drivers/net/wireless/quantenna/qtnfmac/qlink_util.h +0 -8
@@ -28,14 +28,6 @@ static inline void qtnf_cmd_skb_put_tlv_arr(struct sk_buff *skb,memcpy (hdr->val, arr, arr_len); } -static inline void qtnf_cmd_skb_put_tlv_tag (struct sk_buff *skb,u16 tlv_id) -{ -struct qlink_tlv_hdr *hdr =skb_put (skb,sizeof (*hdr)); - - hdr->type =cpu_to_le16 (tlv_id); - hdr->len =cpu_to_le16 (0 ); -} -static inline void qtnf_cmd_skb_put_tlv_u32 (struct sk_buff *skb,u16 tlv_id,u32 value) {
Signature · 1 line
2.11.0
PATCH 10/10 qtnfmac: fix potential Spectre vulnerabilities
In reply to Sergey MatyukevichFix potential Spectre vulnerabilities and other warnings reported by smatch:
drivers/net/wireless/quantenna/qtnfmac/core.c:49 qtnf_core_get_mac() warn: potential spectre issue 'bus->mac' [r] (local cap) drivers/net/wireless/quantenna/qtnfmac/core.c:51 qtnf_core_get_mac() warn: possible spectre second half. 'mac' drivers/net/wireless/quantenna/qtnfmac/event.c:671 qtnf_event_parse() warn: potential spectre issue 'mac->iflist' [r] (local cap) drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c:912 qtnf_pcie_skb_send() warn: variable dereferenced before check 'skb' (see line 881)
--- drivers/net/wireless/quantenna/qtnfmac/core.c | 4 +++- drivers/net/wireless/quantenna/qtnfmac/event.c | 9 ++++++--- drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/core.c +3 -1
@@ -4,6 +4,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/if_ether.h> +#include <linux/nospec.h> #include "core.h" #include "bus.h"
@@ -41,11 +42,12 @@ struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid) {struct qtnf_wmac *mac =NULL ; -if (unlikely (macid >=QTNF_MAX_MAC )) { +if (macid >=QTNF_MAX_MAC ) {pr_err ("invalid MAC index %u\n" , macid);return NULL ; } + macid =array_index_nospec (macid,QTNF_MAX_MAC ); mac = bus->mac[macid];if (unlikely (!mac)) {
drivers/net/wireless/quantenna/qtnfmac/event.c +6 -3
@@ -4,6 +4,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/slab.h> +#include <linux/nospec.h> #include "cfg80211.h" #include "core.h"
@@ -632,18 +633,20 @@ static int qtnf_event_parse(struct qtnf_wmac *mac,int ret =-1 ;u16 event_id;u16 event_len; +u8 vifid; event = (const struct qlink_event *)event_skb->data; event_id =le16_to_cpu (event->event_id); event_len =le16_to_cpu (event->mhdr.len); -if (likely (event->vifid <QTNF_MAX_INTF )) { - vif = &mac->iflist[event->vifid]; - }else { +if (event->vifid >=QTNF_MAX_INTF ) {pr_err ("invalid vif(%u)\n" , event->vifid);return -EINVAL ; } + vifid =array_index_nospec (event->vifid,QTNF_MAX_INTF ); + vif = &mac->iflist[vifid]; +switch (event_id) {case QLINK_EVENT_STA_ASSOCIATED : ret = qtnf_event_handle_sta_assoc(mac, vif, (const void *)event,
drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c +1 -1
@@ -593,7 +593,7 @@ static int qtnf_pcie_skb_send(struct qtnf_bus *bus, struct sk_buff *skb) priv->tx_bd_w_index = i; tx_done: -if (ret && skb) { +if (ret) {pr_err_ratelimited ("drop skb\n" );if (skb->dev) skb->dev->stats.tx_dropped++;
Signature · 1 line
2.11.0