qtnfmac: regular portion of fixes and features
v2 cover qtnfmac: regular portion of fixes and features
Hello Kalle and all,
Here is the next set of patches for qtnfmac driver. This set enables the following features:
- radar detection and CAC support
- MAC-based ACL support
- make GET_STA_STATS format more flexible and future-proof
- inform wireless core about supported extended capabilities
Besides, several issues has been fixed. The most notable among them are:
- fix RSSI data passed from qtnfmac to wireless core
- pass complete channel information between firmware and driver, including both primary channel and center frequency
The last fix enables proper operation channel report by iw tool and fixes ACS mode in hostapd.
Changes v1 -> v2
- remove conditional enablement of WIPHY_FLAG_HAVE_AP_SME when non-zero max_acl_mac_addrs is reported by firmware
- rebase on top of the latest wireless-drivers-next/master
Regards,
Sergey
Igor Mitsyanko (6):
qtnfmac: check that MAC exists in regulatory notifier
qtnfmac: add support for radar detection and CAC
qtnfmac: change default interface mode from AP to STA
qtnfmac: check for passed channel being NULL in MGMT_TX
qtnfmac: modify GET_STA_STATS cmd format for
qtnfmac: keeping track of "generation" for STA info
Sergey Matyukevich (2):
qtnfmac: pass complete channel data between driver and
qtnfmac: fix rssi data passed to wireless core
Vasily Ulyanov (2):
qtnfmac: fill wiphy's extended capabilities
qtnfmac: support MAC address based access control
cfg80211.c | 60 ++++++++- commands.c | 375 ++++++++++++++++++++++++++++++++++++++++++----------------- commands.h | 5 core.c | 13 -- core.h | 8 - event.c | 76 ++++++++++- qlink.h | 340 ++++++++++++++++++++++++++++++++++++++++------------- qlink_util.c | 78 +++++++----- qlink_util.h | 4 util.c | 8 - util.h | 4 11 files changed, 725 insertions(+), 246 deletions(-)
PATCH v2 1/10 qtnfmac: check that MAC exists in regulatory notifier
From: Igor Mitsyanko <[email protected]>
It is possible that regulatory notifier is called before MAC data was allocated. We need to verify that MAC data exists before trying to send a regulatory change event.
--- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +3 -0
@@ -802,6 +802,9 @@ static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in,continue ; mac = bus->mac[mac_idx]; +if (!mac) +continue ; + wiphy =priv_to_wiphy (mac);for (band =0 ; band <NUM_NL80211_BANDS ; ++band) {
Signature · 1 line
2.11.0
Re: [v2,01/10] qtnfmac: check that MAC exists in regulatory notifier
Quoted 7 lines · Sergey Matyukevich
From: Igor Mitsyanko <[email protected]>
It is possible that regulatory notifier is called before MAC data was allocated. We need to verify that MAC data exists before trying to send a regulatory change event.
Signed-off-by Igor Mitsyanko <[email protected]>
10 patches applied to wireless-drivers-next.git, thanks.
4fd045cdb239 qtnfmac: check that MAC exists in regulatory notifier 5bf374ab91ad qtnfmac: pass complete channel data between driver and firmware b05ee456fd21 qtnfmac: add support for radar detection and CAC e6ef8cd05145 qtnfmac: change default interface mode from AP to STA e6e594aff26a qtnfmac: check for passed channel being NULL in MGMT_TX command fbad963a28e4 qtnfmac: fix rssi data passed to wireless core 9cbd599966d8 qtnfmac: fill wiphy's extended capabilities4d2a7a1cfa68 qtnfmac: modify GET_STA_STATS cmd format for back/forward compatibility 7a4d3a3bc84e qtnfmac: keeping track of "generation" for STA info f1398fd2dd8c qtnfmac: support MAC address based access control
Signature · 3 lines
https://patchwork.kernel.org/patch/10123079/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [v2,01/10] qtnfmac: check that MAC exists in regulatory notifier
Thanks Kalle,
Quoted 8 lines
Quoted 5 lines
It is possible that regulatory notifier is called before MAC data was allocated. We need to verify that MAC data exists before trying to send a regulatory change event.
Signed-off-by Igor Mitsyanko <[email protected]>10 patches applied to wireless-drivers-next.git, thanks.
Quoted 10 lines
4fd045cdb239qtnfmac: check that MAC exists in regulatory notifier5bf374ab91adqtnfmac: pass complete channel data between driver and firmwareb05ee456fd21qtnfmac: add support for radar detection and CACe6ef8cd05145qtnfmac: change default interface mode from AP to STAe6e594aff26aqtnfmac: check for passed channel being NULL inMGMT_TXcommandfbad963a28e4qtnfmac: fix rssi data passed to wireless core9cbd599966d8qtnfmac: fill wiphy's extended capabilities4d2a7a1cfa68qtnfmac: modifyGET_STA_STATScmd format for back/forward compatibility7a4d3a3bc84eqtnfmac: keeping track of "generation" for STA infof1398fd2dd8cqtnfmac: support MAC address based access control
Just to understand the timelines... Could you please clarify if these patches are still going to make it into 4.16 merge window ?
Regards,
Sergey
Re: [v2,01/10] qtnfmac: check that MAC exists in regulatory notifier
Quoted 21 lines · Sergey Matyukevich
Thanks Kalle,
Quoted 8 lines
Quoted 5 lines
It is possible that regulatory notifier is called before MAC data was allocated. We need to verify that MAC data exists before trying to send a regulatory change event.
Signed-off-by Igor Mitsyanko <[email protected]>10 patches applied to wireless-drivers-next.git, thanks.
Quoted 10 lines
4fd045cdb239qtnfmac: check that MAC exists in regulatory notifier5bf374ab91adqtnfmac: pass complete channel data between driver and firmwareb05ee456fd21qtnfmac: add support for radar detection and CACe6ef8cd05145qtnfmac: change default interface mode from AP to STAe6e594aff26aqtnfmac: check for passed channel being NULL inMGMT_TXcommandfbad963a28e4qtnfmac: fix rssi data passed to wireless core9cbd599966d8qtnfmac: fill wiphy's extended capabilities4d2a7a1cfa68qtnfmac: modifyGET_STA_STATScmd format for back/forward compatibility7a4d3a3bc84eqtnfmac: keeping track of "generation" for STA infof1398fd2dd8cqtnfmac: support MAC address based access control
Quoted 2 lines
Just to understand the timelines... Could you please clarify if these patches are still going to make it into 4.16 merge window ?
They should, but of course I can't promise anything.
My deadline is that when merge window opens the patches need to be in net-next. You can follow the predictions for the schedule here:
Signature · 1 line
Kalle Valo
PATCH v2 2/10 qtnfmac: pass complete channel data between driver and firmware
In reply to Sergey MatyukevichCenter frequency is not enough to describe the channel in HT and VHT modes. For 40MHz and 80MHz channels both primary channel and center frequency should be specified in order to qualify channel completely. This change adds primary channel info into qlink_chandef structure.
--- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 3 +- drivers/net/wireless/quantenna/qtnfmac/commands.c | 14 +++--- drivers/net/wireless/quantenna/qtnfmac/event.c | 3 +- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 57 ++++++++++++++++------ .../net/wireless/quantenna/qtnfmac/qlink_util.c | 48 ++++++++---------- 5 files changed, 74 insertions(+), 51 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +2 -1
@@ -717,7 +717,8 @@ qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, }if (!cfg80211_chandef_valid (chandef)) { -pr_err ("%s: bad chan freq1=%u freq2=%u bw=%u\n" , ndev->name, +pr_err ("%s: bad channel freq=%u cf1=%u cf2=%u bw=%u\n" , + ndev->name, chandef->chan->center_freq, chandef->center_freq1, chandef->center_freq2, chandef->width); ret = -ENODATA ;
drivers/net/wireless/quantenna/qtnfmac/commands.c +7 -7
@@ -247,7 +247,7 @@ int qtnf_cmd_send_start_ap(struct qtnf_vif *vif, chtlv->hdr.type =cpu_to_le16 (QTN_TLV_ID_CHANDEF ); chtlv->hdr.len =cpu_to_le16 (sizeof (*chtlv) -sizeof (chtlv->hdr)); -qlink_chandef_cfg2q (&s->chandef, &chtlv->chan); +qlink_chandef_cfg2q (&s->chandef, &chtlv->chdef); } qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_BEACON_HEAD,
@@ -1186,7 +1186,7 @@ qtnf_cmd_resp_fill_band_info(struct ieee80211_supported_band *band,size_t tlv_len;size_t tlv_dlen;const struct qlink_tlv_hdr *tlv; -const struct qlink_tlv_channel *qchan; +const struct qlink_channel *qchan;struct ieee80211_channel *chan;unsigned int chidx =0 ;u32 qflags;
@@ -1232,7 +1232,7 @@ qtnf_cmd_resp_fill_band_info(struct ieee80211_supported_band *band,switch (tlv_type) {case QTN_TLV_ID_CHANNEL : -if (unlikely (tlv_len !=sizeof (*qchan))) { +if (unlikely (tlv_dlen !=sizeof (*qchan))) {pr_err ("invalid channel TLV len %zu\n" , tlv_len); goto error_ret;
@@ -1243,7 +1243,7 @@ qtnf_cmd_resp_fill_band_info(struct ieee80211_supported_band *band, goto error_ret; } - qchan = (const struct qlink_tlv_channel *)tlv; + qchan = (const struct qlink_channel *)tlv->val; chan = &band->channels[chidx++]; qflags =le32_to_cpu (qchan->flags);
@@ -2037,8 +2037,8 @@ static void qtnf_cmd_channel_tlv_add(struct sk_buff *cmd_skb, qchan =skb_put_zero (cmd_skb,sizeof (*qchan)); qchan->hdr.type =cpu_to_le16 (QTN_TLV_ID_CHANNEL ); qchan->hdr.len =cpu_to_le16 (sizeof (*qchan) -sizeof (qchan->hdr)); - qchan->center_freq =cpu_to_le16 (sc->center_freq); - qchan->hw_value =cpu_to_le16 (sc->hw_value); + qchan->chan.center_freq =cpu_to_le16 (sc->center_freq); + qchan->chan.hw_value =cpu_to_le16 (sc->hw_value);if (sc->flags &IEEE80211_CHAN_NO_IR ) flags |=QLINK_CHAN_NO_IR ;
@@ -2046,7 +2046,7 @@ static void qtnf_cmd_channel_tlv_add(struct sk_buff *cmd_skb,if (sc->flags &IEEE80211_CHAN_RADAR ) flags |=QLINK_CHAN_RADAR ; - qchan->flags =cpu_to_le32 (flags); + qchan->chan.flags =cpu_to_le32 (flags); }int qtnf_cmd_send_scan (struct qtnf_wmac *mac)
drivers/net/wireless/quantenna/qtnfmac/event.c +2 -1
@@ -369,7 +369,8 @@ qtnf_event_handle_freq_change(struct qtnf_wmac *mac,qlink_chandef_q2cfg (wiphy, &data->chan, &chandef);if (!cfg80211_chandef_valid (&chandef)) { -pr_err ("MAC%u: bad channel f1=%u f2=%u bw=%u\n" , mac->macid, +pr_err ("MAC%u: bad channel freq=%u cf1=%u cf2=%u bw=%u\n" , + mac->macid, chandef.chan->center_freq, chandef.center_freq1, chandef.center_freq2, chandef.width);return -EINVAL ;
drivers/net/wireless/quantenna/qtnfmac/qlink.h +43 -14
93 lines not on this page · raw message
drivers/net/wireless/quantenna/qtnfmac/qlink_util.c +20 -28
63 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v2 3/10 qtnfmac: add support for radar detection and CAC
In reply to Sergey MatyukevichFrom: Igor Mitsyanko <[email protected]>
Implement two parts of radar handling logic:
- cfg80211 .start_radar_detect callback to allow nl80211 to initiate CAC
- radar event to allow wlan device to advertize CAC and radar events
--- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 18 ++++++- drivers/net/wireless/quantenna/qtnfmac/commands.c | 38 ++++++++++++++ drivers/net/wireless/quantenna/qtnfmac/commands.h | 3 ++ drivers/net/wireless/quantenna/qtnfmac/event.c | 61 +++++++++++++++++++++++ drivers/net/wireless/quantenna/qtnfmac/qlink.h | 36 +++++++++++++ 5 files changed, 155 insertions(+), 1 deletion(-)
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +17 -1
@@ -751,6 +751,21 @@ static int qtnf_channel_switch(struct wiphy *wiphy, struct net_device *dev,return ret; } +static int qtnf_start_radar_detection (struct wiphy *wiphy, +struct net_device *ndev, +struct cfg80211_chan_def *chandef, +u32 cac_time_ms) +{ +struct qtnf_vif *vif =qtnf_netdev_get_priv (ndev); +int ret; + + ret =qtnf_cmd_start_cac (vif, chandef, cac_time_ms); +if (ret) +pr_err ("%s: failed to start CAC ret=%d\n" , ndev->name, ret); + +return ret; +} +static struct cfg80211_ops qtn_cfg80211_ops = { .add_virtual_intf = qtnf_add_virtual_intf, .change_virtual_intf = qtnf_change_virtual_intf,
@@ -774,7 +789,8 @@ static struct cfg80211_ops qtn_cfg80211_ops = { .disconnect = qtnf_disconnect, .dump_survey = qtnf_dump_survey, .get_channel = qtnf_get_channel, - .channel_switch = qtnf_channel_switch + .channel_switch = qtnf_channel_switch, + .start_radar_detection = qtnf_start_radar_detection, }; static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in,
drivers/net/wireless/quantenna/qtnfmac/commands.c +38 -0
@@ -2512,3 +2512,41 @@ int qtnf_cmd_get_channel(struct qtnf_vif *vif, struct cfg80211_chan_def *chdef)consume_skb (resp_skb);return ret; } + +int qtnf_cmd_start_cac (const struct qtnf_vif *vif, +const struct cfg80211_chan_def *chdef, +u32 cac_time_ms) +{ +struct qtnf_bus *bus = vif->mac->bus; +struct sk_buff *cmd_skb; +struct qlink_cmd_start_cac *cmd; +int ret; +u16 res_code; + + cmd_skb =qtnf_cmd_alloc_new_cmdskb (vif->mac->macid, vif->vifid, +QLINK_CMD_START_CAC , +sizeof (*cmd)); +if (unlikely (!cmd_skb)) +return -ENOMEM ; + + cmd = (struct qlink_cmd_start_cac *)cmd_skb->data; + cmd->cac_time_ms =cpu_to_le32 (cac_time_ms); +qlink_chandef_cfg2q (chdef, &cmd->chan); + +qtnf_bus_lock (bus); + ret =qtnf_cmd_send (bus, cmd_skb, &res_code); +qtnf_bus_unlock (bus); + +if (ret) +return ret; + +switch (res_code) { +case QLINK_CMD_RESULT_OK : +break ; +default : + ret = -EOPNOTSUPP ; +break ; + } + +return ret; +}
drivers/net/wireless/quantenna/qtnfmac/commands.h +3 -0
@@ -76,5 +76,8 @@ int qtnf_cmd_get_chan_stats(struct qtnf_wmac *mac, u16 channel,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); +int qtnf_cmd_start_cac (const struct qtnf_vif *vif, +const struct cfg80211_chan_def *chdef, +u32 cac_time_ms);#endif /* QLINK_COMMANDS_H_ */
drivers/net/wireless/quantenna/qtnfmac/event.c +61 -0
73 lines not on this page · raw message
drivers/net/wireless/quantenna/qtnfmac/qlink.h +36 -0
@@ -205,6 +205,7 @@ struct qlink_auth_encr {* @QLINK_CMD_REG_NOTIFY: notify device about regulatory domain change. This * command is supported only if device reports QLINK_HW_SUPPORTS_REG_UPDATE * capability. +* @QLINK_CMD_START_CAC: start radar detection procedure on a specified channel. */ enum qlink_cmd_type {QLINK_CMD_FW_INIT =0x0001 ,
@@ -224,6 +225,7 @@ enum qlink_cmd_type {QLINK_CMD_BAND_INFO_GET =0x001A ,QLINK_CMD_CHAN_SWITCH =0x001B ,QLINK_CMD_CHAN_GET =0x001C , +QLINK_CMD_START_CAC =0x001D ,QLINK_CMD_START_AP =0x0021 ,QLINK_CMD_STOP_AP =0x0022 , QLINK_CMD_GET_STA_INFO = 0x0030,
@@ -617,6 +619,18 @@ struct qlink_cmd_start_ap {u8 info[0 ]; } __packed; +/** +* struct qlink_cmd_start_cac - data for QLINK_CMD_START_CAC command +* +* @chan: a channel to start a radar detection procedure on. +* @cac_time_ms: CAC time. +*/ +struct qlink_cmd_start_cac { +struct qlink_cmd chdr; +struct qlink_chandef chan; +__le32 cac_time_ms; +} __packed; +/* QLINK Command Responses messages related definitions */
@@ -814,6 +828,7 @@ enum qlink_event_type {QLINK_EVENT_BSS_JOIN =0x0026 ,QLINK_EVENT_BSS_LEAVE =0x0027 ,QLINK_EVENT_FREQ_CHANGE =0x0028 , + QLINK_EVENT_RADAR = 0x0029, };/**
@@ -963,6 +978,27 @@ struct qlink_event_scan_complete {__le32 flags; } __packed; +enum qlink_radar_event { +QLINK_RADAR_DETECTED , +QLINK_RADAR_CAC_FINISHED , +QLINK_RADAR_CAC_ABORTED , +QLINK_RADAR_NOP_FINISHED , +QLINK_RADAR_PRE_CAC_EXPIRED , +}; + +/** +* struct qlink_event_radar - data for QLINK_EVENT_RADAR event +* +* @chan: channel on which radar event happened. +* @event: radar event type, one of &enum qlink_radar_event. +*/ +struct qlink_event_radar { +struct qlink_event ehdr; +struct qlink_chandef chan; +u8 event; +u8 rsvd[3 ]; +} __packed; +/* QLINK TLVs (Type-Length Values) definitions */
Signature · 1 line
2.11.0
PATCH v2 4/10 qtnfmac: change default interface mode from AP to STA
In reply to Sergey MatyukevichFrom: Igor Mitsyanko <[email protected]>
To mimic mac80211 behaviour, change default interface type from AP to STA.
--- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 2 +- drivers/net/wireless/quantenna/qtnfmac/core.c | 11 ++++------- drivers/net/wireless/quantenna/qtnfmac/core.h | 3 +-- 3 files changed, 6 insertions(+), 10 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +1 -1
@@ -190,7 +190,7 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy, goto err_mac; } -if (qtnf_core_net_attach (mac, vif, name, name_assign_t, type)) { +if (qtnf_core_net_attach (mac, vif, name, name_assign_t)) {pr_err ("VIF%u.%u: failed to attach netdev\n" , mac->macid, vif->vifid); goto err_net;
drivers/net/wireless/quantenna/qtnfmac/core.c +4 -7
@@ -258,7 +258,7 @@ static void qtnf_mac_init_primary_intf(struct qtnf_wmac *mac) {struct qtnf_vif *vif = &mac->iflist[QTNF_PRIMARY_VIF_IDX ]; - vif->wdev.iftype =NL80211_IFTYPE_AP ; + vif->wdev.iftype =NL80211_IFTYPE_STATION ; vif->bss_priority =QTNF_DEF_BSS_PRIORITY ; vif->wdev.wiphy =priv_to_wiphy (mac);INIT_WORK (&vif->reset_work, qtnf_vif_reset_handler);
@@ -298,8 +298,7 @@ static struct qtnf_wmac *qtnf_core_mac_alloc(struct qtnf_bus *bus, }int qtnf_core_net_attach (struct qtnf_wmac *mac,struct qtnf_vif *vif, -const char *name,unsigned char name_assign_type, -enum nl80211_iftype iftype) +const char *name,unsigned char name_assign_type) {struct wiphy *wiphy =priv_to_wiphy (mac);struct net_device *dev;
@@ -320,7 +319,6 @@ int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *vif, dev->needs_free_netdev = true;dev_net_set (dev,wiphy_net (wiphy)); dev->ieee80211_ptr = &vif->wdev; - dev->ieee80211_ptr->iftype = iftype;ether_addr_copy (dev->dev_addr, vif->mac_addr);SET_NETDEV_DEV (dev,wiphy_dev (wiphy)); dev->flags |=IFF_BROADCAST |IFF_MULTICAST ;
@@ -418,7 +416,7 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid) goto error; } - ret =qtnf_cmd_send_add_intf (vif,NL80211_IFTYPE_AP , vif->mac_addr); + ret =qtnf_cmd_send_add_intf (vif, vif->wdev.iftype, vif->mac_addr);if (ret) {pr_err ("MAC%u: failed to add VIF\n" , macid); goto error;
@@ -446,8 +444,7 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid)rtnl_lock (); - ret =qtnf_core_net_attach (mac, vif,"wlan%d" ,NET_NAME_ENUM , -NL80211_IFTYPE_AP ); + ret =qtnf_core_net_attach (mac, vif,"wlan%d" ,NET_NAME_ENUM );rtnl_unlock ();if (ret) {
drivers/net/wireless/quantenna/qtnfmac/core.h +1 -2
@@ -144,8 +144,7 @@ struct qtnf_vif *qtnf_mac_get_free_vif(struct qtnf_wmac *mac);struct qtnf_vif *qtnf_mac_get_base_vif (struct qtnf_wmac *mac);struct wiphy *qtnf_wiphy_allocate (struct qtnf_bus *bus);int qtnf_core_net_attach (struct qtnf_wmac *mac,struct qtnf_vif *priv, -const char *name,unsigned char name_assign_type, -enum nl80211_iftype iftype); +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);
Signature · 1 line
2.11.0
PATCH v2 5/10 qtnfmac: check for passed channel being NULL in MGMT_TX command
In reply to Sergey MatyukevichFrom: Igor Mitsyanko <[email protected]>
Parameters passed into .mgmt_tx callback may have a NULL channel in case userspace wants to send a frame on current channel. Make sure this case is handled, pass "freq==0" in case channel is not specififed to tell wlan device to use current channel.
--- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +11 -2
@@ -381,6 +381,7 @@ qtnf_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,const struct ieee80211_mgmt *mgmt_frame = (void *)params->buf;u32 short_cookie =prandom_u32 ();u16 flags =0 ; +u16 freq; *cookie = short_cookie;
@@ -393,13 +394,21 @@ qtnf_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,if (params->dont_wait_for_ack) flags |=QLINK_MGMT_FRAME_TX_FLAG_ACK_NOWAIT ; +/* If channel is not specified, pass "freq = 0" to tell device +* firmware to use current channel. +*/ +if (params->chan) + freq = params->chan->center_freq; +else + freq =0 ; +pr_debug ("%s freq:%u; FC:%.4X; DA:%pM; len:%zu; C:%.8X; FL:%.4X\n" , - wdev->netdev->name, params->chan->center_freq, + wdev->netdev->name, freq,le16_to_cpu (mgmt_frame->frame_control), mgmt_frame->da, params->len, short_cookie, flags);return qtnf_cmd_send_mgmt_frame (vif, short_cookie, flags, - params->chan->center_freq, + freq, params->buf, params->len); }
Signature · 1 line
2.11.0
PATCH v2 6/10 qtnfmac: fix rssi data passed to wireless core
In reply to Sergey MatyukevichFix RSSI values passed to wireless core by qtnfmac driver:
- fix RSSI values in scan results:
driver registers wiphy with CFG80211_SIGNAL_TYPE_MBM signal type, so mBm should be passed using DBM_TO_MBM macro
- accompany firmware changes fixing RSSI values in received mgmt frames update qlink message format and pass correct signed values to core
--- drivers/net/wireless/quantenna/qtnfmac/event.c | 7 +++---- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 11 ++++++----- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/event.c +3 -4
@@ -237,9 +237,8 @@ qtnf_event_handle_mgmt_received(struct qtnf_vif *vif,pr_debug ("%s LEN:%u FC:%.4X SA:%pM\n" , vif->netdev->name, frame_len,le16_to_cpu (frame->frame_control), frame->addr2); -cfg80211_rx_mgmt (&vif->wdev,le32_to_cpu (rxmgmt->freq), -le32_to_cpu (rxmgmt->sig_dbm), rxmgmt->frame_data, - frame_len, flags); +cfg80211_rx_mgmt (&vif->wdev,le32_to_cpu (rxmgmt->freq), rxmgmt->sig_dbm, + rxmgmt->frame_data, frame_len, flags);return 0 ; }
@@ -324,7 +323,7 @@ qtnf_event_handle_scan_results(struct qtnf_vif *vif, sr->bssid,get_unaligned_le64 (&sr->tsf),le16_to_cpu (sr->capab),le16_to_cpu (sr->bintval), ies, ies_len, - sr->signal, GFP_KERNEL); + DBM_TO_MBM(sr->sig_dbm), GFP_KERNEL);if (!bss)return -ENOMEM ;
drivers/net/wireless/quantenna/qtnfmac/qlink.h +6 -5
@@ -19,7 +19,7 @@#include <linux/ieee80211.h> -#define QLINK_PROTO_VER 7 +#define QLINK_PROTO_VER 8#define QLINK_MACID_RSVD 0xFF#define QLINK_VIFID_RSVD 0xFF
@@ -916,15 +916,16 @@ enum qlink_rxmgmt_flags {* struct qlink_event_rxmgmt - data for QLINK_EVENT_MGMT_RECEIVED event * * @freq: Frequency on which the frame was received in MHz. -* @sig_dbm: signal strength in dBm. * @flags: bitmap of &enum qlink_rxmgmt_flags. +* @sig_dbm: signal strength in dBm. * @frame_data: data of Rx'd frame itself. */ struct qlink_event_rxmgmt {struct qlink_event ehdr;__le32 freq; -__le32 sig_dbm;__le32 flags; +s8 sig_dbm; +u8 rsvd[3 ];u8 frame_data[0 ]; } __packed;
@@ -936,7 +937,7 @@ struct qlink_event_rxmgmt {* event was generated was discovered. * @capab: capabilities field. * @bintval: beacon interval announced by discovered BSS. -* @signal: signal strength. +* @sig_dbm: signal strength in dBm. * @bssid: BSSID announced by discovered BSS. * @ssid_len: length of SSID announced by BSS. * @ssid: SSID announced by discovered BSS.
@@ -948,7 +949,7 @@ struct qlink_event_scan_result {__le16 freq;__le16 capab;__le16 bintval; -s8 signal; +s8 sig_dbm;u8 ssid_len;u8 ssid[IEEE80211_MAX_SSID_LEN ];u8 bssid[ETH_ALEN ];
Signature · 1 line
2.11.0
PATCH v2 7/10 qtnfmac: fill wiphy's extended capabilities
In reply to Sergey MatyukevichFrom: Vasily Ulyanov <[email protected]>
These are needed to inform userspace about features the hardware supports (e.g. BSS Transition Management 802.11v)
--- drivers/net/wireless/quantenna/qtnfmac/commands.c | 44 +++++++++++++++++++++++ drivers/net/wireless/quantenna/qtnfmac/core.c | 2 ++ drivers/net/wireless/quantenna/qtnfmac/core.h | 3 ++ drivers/net/wireless/quantenna/qtnfmac/qlink.h | 1 + 4 files changed, 50 insertions(+)
drivers/net/wireless/quantenna/qtnfmac/commands.c +44 -0
@@ -1029,6 +1029,10 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac,struct qlink_iface_comb_num *comb;size_t tlv_full_len;const struct qlink_tlv_hdr *tlv; +u8 *ext_capa =NULL ; +u8 *ext_capa_mask =NULL ; +u8 ext_capa_len =0 ; +u8 ext_capa_mask_len =0 ; mac->macinfo.n_limits =0 ;
@@ -1092,6 +1096,18 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac,if (limits[rec].types) rec++;break ; +case WLAN_EID_EXT_CAPABILITY : +if (unlikely (tlv_value_len >U8_MAX )) +return -EINVAL ; + ext_capa = (u8 *)tlv->val; + ext_capa_len = tlv_value_len; +break ; +case QTN_TLV_ID_EXT_CAPABILITY_MASK : +if (unlikely (tlv_value_len >U8_MAX )) +return -EINVAL ; + ext_capa_mask = (u8 *)tlv->val; + ext_capa_mask_len = tlv_value_len; +break ;default :break ; }
@@ -1112,6 +1128,34 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac,return -EINVAL ; } +if (ext_capa_len != ext_capa_mask_len) { +pr_err ("MAC%u: ext_capa/_mask lengths mismatch: %u != %u\n" , + mac->macid, ext_capa_len, ext_capa_mask_len); +return -EINVAL ; + } + +if (ext_capa_len >0 ) { + ext_capa =kmemdup (ext_capa, ext_capa_len,GFP_KERNEL ); +if (!ext_capa) +return -ENOMEM ; + + ext_capa_mask = +kmemdup (ext_capa_mask, ext_capa_mask_len,GFP_KERNEL ); +if (!ext_capa_mask) { +kfree (ext_capa); +return -ENOMEM ; + } + }else { + ext_capa =NULL ; + ext_capa_mask =NULL ; + } + +kfree (mac->macinfo.extended_capabilities); +kfree (mac->macinfo.extended_capabilities_mask); + mac->macinfo.extended_capabilities = ext_capa; + mac->macinfo.extended_capabilities_mask = ext_capa_mask; + mac->macinfo.extended_capabilities_len = ext_capa_len; +return 0 ; }
drivers/net/wireless/quantenna/qtnfmac/core.c +2 -0
@@ -381,6 +381,8 @@ static void qtnf_core_mac_detach(struct qtnf_bus *bus, unsigned int macid) }kfree (mac->macinfo.limits); +kfree (mac->macinfo.extended_capabilities); +kfree (mac->macinfo.extended_capabilities_mask);kfree (wiphy->iface_combinations);wiphy_free (wiphy); bus->mac[macid] =NULL ;
drivers/net/wireless/quantenna/qtnfmac/core.h +3 -0
@@ -106,6 +106,9 @@ struct qtnf_mac_info {struct ieee80211_vht_cap vht_cap_mod_mask;struct ieee80211_iface_limit *limits;size_t n_limits; +u8 *extended_capabilities; +u8 *extended_capabilities_mask; +u8 extended_capabilities_len; };struct qtnf_chan_stats {
drivers/net/wireless/quantenna/qtnfmac/qlink.h +1 -0
@@ -1020,6 +1020,7 @@ enum qlink_tlv_id {QTN_TLV_ID_KEY =0x0302 ,QTN_TLV_ID_SEQ =0x0303 ,QTN_TLV_ID_IE_SET =0x0305 , + QTN_TLV_ID_EXT_CAPABILITY_MASK = 0x0306, }; struct qlink_tlv_hdr {
Signature · 1 line
2.11.0
PATCH v2 8/10 qtnfmac: modify GET_STA_STATS cmd format for back/forward compatibility
In reply to Sergey MatyukevichFrom: Igor Mitsyanko <[email protected]>
A set of per-STA statistics can potentially change quite often. To ensure backwards and forward compatibility,
modify GET_STA_STATS command format:
- introduce two TLV types
- first TLV is a variable-sized bitmap of statistics values that are filled by firmware
- second TLV is a structure with statistics itself
Only values specified in first TLV are valid.
--- drivers/net/wireless/quantenna/qtnfmac/commands.c | 217 +++++++++++---------- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 204 ++++++++++++------- .../net/wireless/quantenna/qtnfmac/qlink_util.c | 12 ++ .../net/wireless/quantenna/qtnfmac/qlink_util.h | 2 + 4 files changed, 267 insertions(+), 168 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/commands.c +116 -101
@@ -461,30 +461,8 @@ int qtnf_cmd_send_mgmt_set_appie(struct qtnf_vif *vif, u8 frame_type, }static void -qtnf_sta_info_parse_basic_counters (struct station_info *sinfo, -const struct qlink_sta_stat_basic_counters *counters) -{ - sinfo->filled |=BIT (NL80211_STA_INFO_RX_BYTES ) | -BIT (NL80211_STA_INFO_TX_BYTES ); - sinfo->rx_bytes =get_unaligned_le64 (&counters->rx_bytes); - sinfo->tx_bytes =get_unaligned_le64 (&counters->tx_bytes); - - sinfo->filled |=BIT (NL80211_STA_INFO_RX_PACKETS ) | -BIT (NL80211_STA_INFO_TX_PACKETS ) | -BIT (NL80211_STA_INFO_BEACON_RX ); - sinfo->rx_packets =get_unaligned_le32 (&counters->rx_packets); - sinfo->tx_packets =get_unaligned_le32 (&counters->tx_packets); - sinfo->rx_beacon =get_unaligned_le64 (&counters->rx_beacons); - - sinfo->filled |=BIT (NL80211_STA_INFO_RX_DROP_MISC ) | -BIT (NL80211_STA_INFO_TX_FAILED ); - sinfo->rx_dropped_misc =get_unaligned_le32 (&counters->rx_dropped); - sinfo->tx_failed =get_unaligned_le32 (&counters->tx_failed); -} - -static void qtnf_sta_info_parse_rate (struct rate_info *rate_dst, -const struct qlink_sta_info_rate *rate_src) +const struct qlink_sta_info_rate *rate_src) { rate_dst->legacy =get_unaligned_le16 (&rate_src->rate) *10 ;
@@ -493,22 +471,23 @@ qtnf_sta_info_parse_rate(struct rate_info *rate_dst, rate_dst->flags =0 ;switch (rate_src->bw) { -case QLINK_STA_INFO_RATE_BW_5 : +case QLINK_CHAN_WIDTH_5 : rate_dst->bw =RATE_INFO_BW_5 ;break ; -case QLINK_STA_INFO_RATE_BW_10 : +case QLINK_CHAN_WIDTH_10 : rate_dst->bw =RATE_INFO_BW_10 ;break ; -case QLINK_STA_INFO_RATE_BW_20 : +case QLINK_CHAN_WIDTH_20 : +case QLINK_CHAN_WIDTH_20_NOHT : rate_dst->bw =RATE_INFO_BW_20 ;break ; -case QLINK_STA_INFO_RATE_BW_40 : +case QLINK_CHAN_WIDTH_40 : rate_dst->bw =RATE_INFO_BW_40 ;break ; -case QLINK_STA_INFO_RATE_BW_80 : +case QLINK_CHAN_WIDTH_80 : rate_dst->bw =RATE_INFO_BW_80 ;break ; -case QLINK_STA_INFO_RATE_BW_160 : +case QLINK_CHAN_WIDTH_160 : rate_dst->bw =RATE_INFO_BW_160 ;break ;default :
@@ -578,87 +557,125 @@ qtnf_sta_info_parse_flags(struct nl80211_sta_flag_update *dst, }static void -qtnf_sta_info_parse_generic_info (struct station_info *sinfo, -const struct qlink_sta_info_generic *info) +qtnf_cmd_sta_info_parse (struct station_info *sinfo, +const struct qlink_tlv_hdr *tlv, +size_t resp_size) { - sinfo->filled |=BIT (NL80211_STA_INFO_CONNECTED_TIME ) | -BIT (NL80211_STA_INFO_INACTIVE_TIME ); - sinfo->connected_time =get_unaligned_le32 (&info->connected_time); - sinfo->inactive_time =get_unaligned_le32 (&info->inactive_time); +const struct qlink_sta_stats *stats =NULL ; +const u8 *map =NULL ; +unsigned int map_len =0 ; +unsigned int stats_len =0 ; +u16 tlv_len; + +#define qtnf_sta_stat_avail (stat_name, bitn) \ + (qtnf_utils_is_bit_set(map, bitn, map_len) && \ + (offsetofend(struct qlink_sta_stats, stat_name) <= stats_len)) + +while (resp_size >=sizeof (*tlv)) { + tlv_len =le16_to_cpu (tlv->len); + +switch (le16_to_cpu (tlv->type)) { +case QTN_TLV_ID_STA_STATS_MAP : + map_len = tlv_len; + map = tlv->val; +break ; +case QTN_TLV_ID_STA_STATS : + stats_len = tlv_len; + stats = (const struct qlink_sta_stats *)tlv->val; +break ; +default : +break ; + } + + resp_size -= tlv_len +sizeof (*tlv); + tlv = (const struct qlink_tlv_hdr *)(tlv->val + tlv_len); + } - sinfo->filled |=BIT (NL80211_STA_INFO_SIGNAL ) | -BIT (NL80211_STA_INFO_SIGNAL_AVG ); - sinfo->signal = info->rssi -120 ; - sinfo->signal_avg = info->rssi_avg -QLINK_RSSI_OFFSET ; +if (!map || !stats) +return ; + +if (qtnf_sta_stat_avail (inactive_time,QLINK_STA_INFO_INACTIVE_TIME )) { + sinfo->filled |=BIT (NL80211_STA_INFO_INACTIVE_TIME ); + sinfo->inactive_time =le32_to_cpu (stats->inactive_time); + } -if (info->rx_rate.rate) { +if (qtnf_sta_stat_avail (connected_time, +QLINK_STA_INFO_CONNECTED_TIME )) { + sinfo->filled |=BIT (NL80211_STA_INFO_CONNECTED_TIME ); + sinfo->connected_time =le32_to_cpu (stats->connected_time); + } + +if (qtnf_sta_stat_avail (signal,QLINK_STA_INFO_SIGNAL )) { + sinfo->filled |=BIT (NL80211_STA_INFO_SIGNAL ); + sinfo->signal = stats->signal -QLINK_RSSI_OFFSET ; + } + +if (qtnf_sta_stat_avail (signal_avg,QLINK_STA_INFO_SIGNAL_AVG )) { + sinfo->filled |=BIT (NL80211_STA_INFO_SIGNAL_AVG ); + sinfo->signal_avg = stats->signal_avg -QLINK_RSSI_OFFSET ; + } + +if (qtnf_sta_stat_avail (rxrate,QLINK_STA_INFO_RX_BITRATE )) { sinfo->filled |=BIT (NL80211_STA_INFO_RX_BITRATE ); -qtnf_sta_info_parse_rate (&sinfo->rxrate, &info->rx_rate); +qtnf_sta_info_parse_rate (&sinfo->rxrate, &stats->rxrate); } -if (info->tx_rate.rate) { +if (qtnf_sta_stat_avail (txrate,QLINK_STA_INFO_TX_BITRATE )) { sinfo->filled |=BIT (NL80211_STA_INFO_TX_BITRATE ); -qtnf_sta_info_parse_rate (&sinfo->txrate, &info->tx_rate); +qtnf_sta_info_parse_rate (&sinfo->txrate, &stats->txrate); } - sinfo->filled |=BIT (NL80211_STA_INFO_STA_FLAGS ); -qtnf_sta_info_parse_flags (&sinfo->sta_flags, &info->state); -} +if (qtnf_sta_stat_avail (sta_flags,QLINK_STA_INFO_STA_FLAGS )) { + sinfo->filled |=BIT (NL80211_STA_INFO_STA_FLAGS ); +qtnf_sta_info_parse_flags (&sinfo->sta_flags, &stats->sta_flags); + } -static int qtnf_cmd_sta_info_parse (struct station_info *sinfo, -const u8 *payload,size_t payload_size) -{ -const struct qlink_sta_stat_basic_counters *counters; -const struct qlink_sta_info_generic *sta_info; -u16 tlv_type; -u16 tlv_value_len; -size_t tlv_full_len; -const struct qlink_tlv_hdr *tlv; +if (qtnf_sta_stat_avail (rx_bytes,QLINK_STA_INFO_RX_BYTES )) { + sinfo->filled |=BIT (NL80211_STA_INFO_RX_BYTES ); + sinfo->rx_bytes =le64_to_cpu (stats->rx_bytes); + } - sinfo->filled =0 ; +if (qtnf_sta_stat_avail (tx_bytes,QLINK_STA_INFO_TX_BYTES )) { + sinfo->filled |=BIT (NL80211_STA_INFO_TX_BYTES ); + sinfo->tx_bytes =le64_to_cpu (stats->tx_bytes); + } - tlv = (const struct qlink_tlv_hdr *)payload; -while (payload_size >=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_size) { -pr_warn ("malformed TLV 0x%.2X; LEN: %u\n" , - tlv_type, tlv_value_len); -return -EINVAL ; - } -switch (tlv_type) { -case QTN_TLV_ID_STA_BASIC_COUNTERS : -if (unlikely (tlv_value_len <sizeof (*counters))) { -pr_err ("invalid TLV size %.4X: %u\n" , - tlv_type, tlv_value_len); -break ; - } +if (qtnf_sta_stat_avail (rx_bytes,QLINK_STA_INFO_RX_BYTES64 )) { + sinfo->filled |=BIT (NL80211_STA_INFO_RX_BYTES64 ); + sinfo->rx_bytes =le64_to_cpu (stats->rx_bytes); + } - counters = (void *)tlv->val; -qtnf_sta_info_parse_basic_counters (sinfo, counters); -break ; -case QTN_TLV_ID_STA_GENERIC_INFO : -if (unlikely (tlv_value_len <sizeof (*sta_info))) -break ; +if (qtnf_sta_stat_avail (tx_bytes,QLINK_STA_INFO_TX_BYTES64 )) { + sinfo->filled |=BIT (NL80211_STA_INFO_TX_BYTES64 ); + sinfo->tx_bytes =le64_to_cpu (stats->tx_bytes); + } - sta_info = (void *)tlv->val; -qtnf_sta_info_parse_generic_info (sinfo, sta_info); -break ; -default : -pr_warn ("unexpected TLV type: %.4X\n" , tlv_type); -break ; - } - payload_size -= tlv_full_len; - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); +if (qtnf_sta_stat_avail (rx_packets,QLINK_STA_INFO_RX_PACKETS )) { + sinfo->filled |=BIT (NL80211_STA_INFO_RX_PACKETS ); + sinfo->rx_packets =le32_to_cpu (stats->rx_packets); } -if (payload_size) { -pr_warn ("malformed TLV buf; bytes left: %zu\n" , payload_size); -return -EINVAL ; +if (qtnf_sta_stat_avail (tx_packets,QLINK_STA_INFO_TX_PACKETS )) { + sinfo->filled |=BIT (NL80211_STA_INFO_TX_PACKETS ); + sinfo->tx_packets =le32_to_cpu (stats->tx_packets); } -return 0 ; +if (qtnf_sta_stat_avail (rx_beacon,QLINK_STA_INFO_BEACON_RX )) { + sinfo->filled |=BIT (NL80211_STA_INFO_BEACON_RX ); + sinfo->rx_beacon =le64_to_cpu (stats->rx_beacon); + } + +if (qtnf_sta_stat_avail (rx_dropped_misc,QLINK_STA_INFO_RX_DROP_MISC )) { + sinfo->filled |=BIT (NL80211_STA_INFO_RX_DROP_MISC ); + sinfo->rx_dropped_misc =le32_to_cpu (stats->rx_dropped_misc); + } + +if (qtnf_sta_stat_avail (tx_failed,QLINK_STA_INFO_TX_FAILED )) { + sinfo->filled |=BIT (NL80211_STA_INFO_TX_FAILED ); + sinfo->tx_failed =le32_to_cpu (stats->tx_failed); + } + +#undef qtnf_sta_stat_avail } int qtnf_cmd_get_sta_info(struct qtnf_vif *vif, const u8 *sta_mac,
@@ -715,7 +732,9 @@ int qtnf_cmd_get_sta_info(struct qtnf_vif *vif, const u8 *sta_mac, goto out; } - ret =qtnf_cmd_sta_info_parse (sinfo, resp->info, var_resp_len); +qtnf_cmd_sta_info_parse (sinfo, + (const struct qlink_tlv_hdr *)resp->info, + var_resp_len); out:qtnf_bus_unlock (vif->mac->bus);
@@ -1992,21 +2011,17 @@ 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->flag_update.mask = +cpu_to_le32 (qtnf_encode_sta_flags (params->sta_flags_mask)); + cmd->flag_update.value = +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);
drivers/net/wireless/quantenna/qtnfmac/qlink.h +137 -67
272 lines not on this page · raw message
drivers/net/wireless/quantenna/qtnfmac/qlink_util.c +12 -0
@@ -164,3 +164,15 @@ enum qlink_hidden_ssid qlink_hidden_ssid_nl2q(enum nl80211_hidden_ssid nl_val)return QLINK_HIDDEN_SSID_NOT_IN_USE ; } } + +bool qtnf_utils_is_bit_set (const u8 *arr,unsigned int bit, +unsigned int arr_max_len) +{ +unsigned int idx = bit /BITS_PER_BYTE ; +u8 mask =1 << (bit - (idx *BITS_PER_BYTE )); + +if (idx >= arr_max_len) +return false; + +return arr[idx] & mask; +}
drivers/net/wireless/quantenna/qtnfmac/qlink_util.h +2 -0
@@ -69,5 +69,7 @@ void qlink_chandef_q2cfg(struct wiphy *wiphy,void qlink_chandef_cfg2q (const struct cfg80211_chan_def *chdef,struct qlink_chandef *qch);enum qlink_hidden_ssid qlink_hidden_ssid_nl2q (enum nl80211_hidden_ssid nl_val); +bool qtnf_utils_is_bit_set (const u8 *arr,unsigned int bit, +unsigned int arr_max_len);#endif /* _QTN_FMAC_QLINK_UTIL_H_ */
Signature · 1 line
2.11.0
PATCH v2 9/10 qtnfmac: keeping track of "generation" for STA info
In reply to Sergey MatyukevichFrom: Igor Mitsyanko <[email protected]>
Keep generation in per-VIF data structure and increment it whenever STA list is changed. Use generation value to fill struct station_info when required.
--- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 5 ++++- drivers/net/wireless/quantenna/qtnfmac/core.h | 1 + drivers/net/wireless/quantenna/qtnfmac/event.c | 5 +++-- drivers/net/wireless/quantenna/qtnfmac/util.c | 8 ++++++-- drivers/net/wireless/quantenna/qtnfmac/util.h | 4 ++-- 5 files changed, 16 insertions(+), 7 deletions(-)
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +4 -1
@@ -418,6 +418,7 @@ qtnf_get_station(struct wiphy *wiphy, struct net_device *dev, {struct qtnf_vif *vif =qtnf_netdev_get_priv (dev); + sinfo->generation = vif->generation;return qtnf_cmd_get_sta_info (vif, mac, sinfo); }
@@ -439,11 +440,13 @@ qtnf_dump_station(struct wiphy *wiphy, struct net_device *dev, ret =qtnf_cmd_get_sta_info (vif, sta_node->mac_addr, sinfo);if (unlikely (ret == -ENOENT )) { -qtnf_sta_list_del (&vif->sta_list, mac); +qtnf_sta_list_del (vif, mac);cfg80211_del_sta (vif->netdev, mac,GFP_KERNEL ); sinfo->filled =0 ; } + sinfo->generation = vif->generation; +return ret; }
drivers/net/wireless/quantenna/qtnfmac/core.h +1 -0
@@ -88,6 +88,7 @@ struct qtnf_vif {struct work_struct reset_work;struct qtnf_sta_list sta_list;unsigned long cons_tx_timeout_cnt; +int generation; };struct qtnf_mac_info {
drivers/net/wireless/quantenna/qtnfmac/event.c +3 -2
@@ -59,10 +59,11 @@ qtnf_event_handle_sta_assoc(struct qtnf_wmac *mac, struct qtnf_vif *vif,pr_debug ("VIF%u.%u: MAC:%pM FC:%x\n" , mac->macid, vif->vifid, sta_addr, frame_control); -qtnf_sta_list_add (&vif->sta_list, sta_addr); +qtnf_sta_list_add (vif, sta_addr); sinfo.assoc_req_ies =NULL ; sinfo.assoc_req_ies_len =0 ; + sinfo.generation = vif->generation; payload_len = len -sizeof (*sta_assoc); tlv = (const struct qlink_tlv_hdr *)sta_assoc->ies;
@@ -132,7 +133,7 @@ qtnf_event_handle_sta_deauth(struct qtnf_wmac *mac, struct qtnf_vif *vif,pr_debug ("VIF%u.%u: MAC:%pM reason:%x\n" , mac->macid, vif->vifid, sta_addr, reason); -if (qtnf_sta_list_del (&vif->sta_list, sta_addr)) +if (qtnf_sta_list_del (vif, sta_addr))cfg80211_del_sta (vif->netdev, sta_deauth->sta_addr,GFP_KERNEL );
drivers/net/wireless/quantenna/qtnfmac/util.c +6 -2
@@ -57,9 +57,10 @@ struct qtnf_sta_node *qtnf_sta_list_lookup_index(struct qtnf_sta_list *list,return NULL ; } -struct qtnf_sta_node *qtnf_sta_list_add (struct qtnf_sta_list *list, +struct qtnf_sta_node *qtnf_sta_list_add (struct qtnf_vif *vif,const u8 *mac) { +struct qtnf_sta_list *list = &vif->sta_list;struct qtnf_sta_node *node;if (unlikely (!mac))
@@ -77,13 +78,15 @@ struct qtnf_sta_node *qtnf_sta_list_add(struct qtnf_sta_list *list,ether_addr_copy (node->mac_addr, mac);list_add_tail (&node->list, &list->head);atomic_inc (&list->size); + ++vif->generation; done:return node; } -bool qtnf_sta_list_del (struct qtnf_sta_list *list,const u8 *mac) +bool qtnf_sta_list_del (struct qtnf_vif *vif,const u8 *mac) { +struct qtnf_sta_list *list = &vif->sta_list;struct qtnf_sta_node *node;bool ret = false;
@@ -93,6 +96,7 @@ bool qtnf_sta_list_del(struct qtnf_sta_list *list, const u8 *mac)list_del (&node->list);atomic_dec (&list->size);kfree (node); + ++vif->generation; ret = true; }
drivers/net/wireless/quantenna/qtnfmac/util.h +2 -2
@@ -26,9 +26,9 @@ struct qtnf_sta_node *qtnf_sta_list_lookup(struct qtnf_sta_list *list, const u8 *mac);struct qtnf_sta_node *qtnf_sta_list_lookup_index (struct qtnf_sta_list *list,size_t index); -struct qtnf_sta_node *qtnf_sta_list_add (struct qtnf_sta_list *list, +struct qtnf_sta_node *qtnf_sta_list_add (struct qtnf_vif *vif,const u8 *mac); -bool qtnf_sta_list_del (struct qtnf_sta_list *list,const u8 *mac); +bool qtnf_sta_list_del (struct qtnf_vif *vif,const u8 *mac);void qtnf_sta_list_free (struct qtnf_sta_list *list);
Signature · 1 line
2.11.0
PATCH v2 10/10 qtnfmac: support MAC address based access control
In reply to Sergey MatyukevichFrom: Vasily Ulyanov <[email protected]>
This allows a running AP to blacklist STAs by their MAC addresses respecting the configured policy (either accept or deny unless listed). It can be setup on .start_ap or with .set_mac_acl commands.
--- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 16 ++++++ drivers/net/wireless/quantenna/qtnfmac/commands.c | 62 ++++++++++++++++++++++ drivers/net/wireless/quantenna/qtnfmac/commands.h | 2 + drivers/net/wireless/quantenna/qtnfmac/core.h | 1 + drivers/net/wireless/quantenna/qtnfmac/qlink.h | 37 ++++++++++++- .../net/wireless/quantenna/qtnfmac/qlink_util.c | 18 +++++++ .../net/wireless/quantenna/qtnfmac/qlink_util.h | 2 + 7 files changed, 137 insertions(+), 1 deletion(-)
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +16 -0
@@ -778,6 +778,20 @@ static int qtnf_start_radar_detection(struct wiphy *wiphy,return ret; } +static int qtnf_set_mac_acl (struct wiphy *wiphy, +struct net_device *dev, +const struct cfg80211_acl_data *params) +{ +struct qtnf_vif *vif =qtnf_netdev_get_priv (dev); +int ret; + + ret =qtnf_cmd_set_mac_acl (vif, params); +if (ret) +pr_err ("%s: failed to set mac ACL ret=%d\n" , dev->name, ret); + +return ret; +} +static struct cfg80211_ops qtn_cfg80211_ops = { .add_virtual_intf = qtnf_add_virtual_intf, .change_virtual_intf = qtnf_change_virtual_intf,
@@ -803,6 +817,7 @@ static struct cfg80211_ops qtn_cfg80211_ops = { .get_channel = qtnf_get_channel, .channel_switch = qtnf_channel_switch, .start_radar_detection = qtnf_start_radar_detection, + .set_mac_acl = qtnf_set_mac_acl, }; static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in,
@@ -918,6 +933,7 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) wiphy->max_scan_ie_len =QTNF_MAX_VSIE_LEN ; wiphy->mgmt_stypes = qtnf_mgmt_stypes; wiphy->max_remain_on_channel_duration =5000 ; + wiphy->max_acl_mac_addrs = mac->macinfo.max_acl_mac_addrs; wiphy->iface_combinations = iface_comb; wiphy->n_iface_combinations =1 ;
drivers/net/wireless/quantenna/qtnfmac/commands.c +62 -0
89 lines not on this page · raw message
drivers/net/wireless/quantenna/qtnfmac/commands.h +2 -0
@@ -79,5 +79,7 @@ int qtnf_cmd_get_channel(struct qtnf_vif *vif, struct cfg80211_chan_def *chdef);int qtnf_cmd_start_cac (const struct qtnf_vif *vif,const struct cfg80211_chan_def *chdef,u32 cac_time_ms); +int qtnf_cmd_set_mac_acl (const struct qtnf_vif *vif, +const struct cfg80211_acl_data *params);#endif /* QLINK_COMMANDS_H_ */
drivers/net/wireless/quantenna/qtnfmac/core.h +1 -0
@@ -103,6 +103,7 @@ struct qtnf_mac_info {u8 sretry_limit;u8 coverage_class;u8 radar_detect_widths; +u32 max_acl_mac_addrs;struct ieee80211_ht_cap ht_cap_mod_mask;struct ieee80211_vht_cap vht_cap_mod_mask;struct ieee80211_iface_limit *limits;
drivers/net/wireless/quantenna/qtnfmac/qlink.h +36 -1
@@ -19,7 +19,7 @@#include <linux/ieee80211.h> -#define QLINK_PROTO_VER 9 +#define QLINK_PROTO_VER 10#define QLINK_MACID_RSVD 0xFF#define QLINK_VIFID_RSVD 0xFF
@@ -239,6 +239,7 @@ enum qlink_cmd_type {QLINK_CMD_START_CAC =0x001D ,QLINK_CMD_START_AP =0x0021 ,QLINK_CMD_STOP_AP =0x0022 , +QLINK_CMD_SET_MAC_ACL =0x0023 ,QLINK_CMD_GET_STA_INFO =0x0030 ,QLINK_CMD_ADD_KEY =0x0040 , QLINK_CMD_DEL_KEY = 0x0041,
@@ -640,6 +641,38 @@ struct qlink_cmd_start_cac {__le32 cac_time_ms; } __packed; +enum qlink_acl_policy { +QLINK_ACL_POLICY_ACCEPT_UNLESS_LISTED , +QLINK_ACL_POLICY_DENY_UNLESS_LISTED , +}; + +struct qlink_mac_address { +u8 addr[ETH_ALEN ]; +} __packed; + +/** +* struct qlink_acl_data - ACL data +* +* @policy: filter policy, one of &enum qlink_acl_policy. +* @num_entries: number of MAC addresses in array. +* @mac_address: MAC addresses array. +*/ +struct qlink_acl_data { +__le32 policy; +__le32 num_entries; +struct qlink_mac_address mac_addrs[0 ]; +} __packed; + +/** +* struct qlink_cmd_set_mac_acl - data for QLINK_CMD_SET_MAC_ACL command +* +* @acl: ACL data. +*/ +struct qlink_cmd_set_mac_acl { +struct qlink_cmd chdr; +struct qlink_acl_data acl; +} __packed; +/* QLINK Command Responses messages related definitions */
@@ -701,6 +734,7 @@ struct qlink_resp_get_mac_info {struct ieee80211_ht_cap ht_cap_mod_mask;__le16 max_ap_assoc_sta;__le16 radar_detect_widths; +__le32 max_acl_mac_addrs;u8 bands_cap;u8 rsvd[1 ];u8 var_info[0 ];
@@ -1049,6 +1083,7 @@ enum qlink_tlv_id {QTN_TLV_ID_SEQ =0x0303 ,QTN_TLV_ID_IE_SET =0x0305 ,QTN_TLV_ID_EXT_CAPABILITY_MASK =0x0306 , + QTN_TLV_ID_ACL_DATA = 0x0307, }; struct qlink_tlv_hdr {
drivers/net/wireless/quantenna/qtnfmac/qlink_util.c +18 -0
@@ -176,3 +176,21 @@ bool qtnf_utils_is_bit_set(const u8 *arr, unsigned int bit,return arr[idx] & mask; } + +void qlink_acl_data_cfg2q (const struct cfg80211_acl_data *acl, +struct qlink_acl_data *qacl) +{ +switch (acl->acl_policy) { +case NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED : + qacl->policy = +cpu_to_le32 (QLINK_ACL_POLICY_ACCEPT_UNLESS_LISTED ); +break ; +case NL80211_ACL_POLICY_DENY_UNLESS_LISTED : + qacl->policy =cpu_to_le32 (QLINK_ACL_POLICY_DENY_UNLESS_LISTED ); +break ; + } + + qacl->num_entries =cpu_to_le32 (acl->n_acl_entries); +memcpy (qacl->mac_addrs, acl->mac_addrs, + acl->n_acl_entries *sizeof (*qacl->mac_addrs)); +}
drivers/net/wireless/quantenna/qtnfmac/qlink_util.h +2 -0
@@ -71,5 +71,7 @@ void qlink_chandef_cfg2q(const struct cfg80211_chan_def *chdef,enum qlink_hidden_ssid qlink_hidden_ssid_nl2q (enum nl80211_hidden_ssid nl_val);bool qtnf_utils_is_bit_set (const u8 *arr,unsigned int bit,unsigned int arr_max_len); +void qlink_acl_data_cfg2q (const struct cfg80211_acl_data *acl, +struct qlink_acl_data *qacl);#endif /* _QTN_FMAC_QLINK_UTIL_H_ */
Signature · 1 line
2.11.0