2019-04-26 09:44:09

by John Crispin

[permalink] [raw]
Subject: [PATCH V2 0/3] mac80211: notify the driver when it should enable TWT

The ath11k FW has dedicated calls for setting the TWT state. Trigger these
via the BSS config changes.

In a later step we need to also add calls for manually starting TWT dialogs.

Changes in V2
* add NLA_POLICY_RANGE for NL80211_ATTR_TWT_RESPONDER

John Crispin (3):
mac80211: allow turning TWT responder support on and off via netlink
mac80211: dynamically turn TWT requester support on and off
ath11k: add TWT support

drivers/net/wireless/ath/ath11k/mac.c | 7 +++
drivers/net/wireless/ath/ath11k/wmi.c | 91 +++++++++++++++++++++++++++++++++++
drivers/net/wireless/ath/ath11k/wmi.h | 71 +++++++++++++++++++++++++++
include/net/cfg80211.h | 2 +
include/net/mac80211.h | 5 ++
include/uapi/linux/nl80211.h | 4 ++
net/mac80211/cfg.c | 6 +++
net/mac80211/mlme.c | 20 +++++++-
net/wireless/nl80211.c | 6 +++
9 files changed, 210 insertions(+), 2 deletions(-)

--
2.11.0



2019-04-26 09:42:59

by John Crispin

[permalink] [raw]
Subject: [PATCH V2 3/3] ath11k: add TWT support

Add target wait time wmi calls to the driver. En/disable the support
from when the bss_config changes. We ignore the cmd completion events.

Signed-off-by: Shashidhar Lakkavalli <[email protected]>
Signed-off-by: John Crispin <[email protected]>
---
drivers/net/wireless/ath/ath11k/mac.c | 7 +++
drivers/net/wireless/ath/ath11k/wmi.c | 91 +++++++++++++++++++++++++++++++++++
drivers/net/wireless/ath/ath11k/wmi.h | 71 +++++++++++++++++++++++++++
3 files changed, 169 insertions(+)

diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index 8bb4ff82fb6f..a38c101e0140 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -1938,6 +1938,13 @@ static void ath11k_bss_info_changed(struct ieee80211_hw *hw,
ath11k_mac_txpower_recalc(ar);
}

+ if (changed & BSS_CHANGED_TWT) {
+ if (info->twt_responder || info->twt_responder)
+ ath11k_wmi_send_twt_enable_cmd(ar, ar->pdev_idx);
+ else
+ ath11k_wmi_send_twt_disable_cmd(ar, ar->pdev_idx);
+ }
+
mutex_unlock(&ar->conf_mutex);
}

diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c
index 7edaed5c97df..52d6fb200d07 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -1797,6 +1797,10 @@ ath11k_wmi_copy_peer_flags(struct wmi_peer_assoc_complete_cmd *cmd,
cmd->peer_flags |= WMI_PEER_VHT;
if (param->he_flag)
cmd->peer_flags |= WMI_PEER_HE;
+ if (param->twt_requester)
+ cmd->peer_flags |= WMI_PEER_TWT_REQ;
+ if (param->twt_responder)
+ cmd->peer_flags |= WMI_PEER_TWT_RESP;
}

/* Suppress authorization for all AUTH modes that need 4-way handshake
@@ -2787,6 +2791,86 @@ int ath11k_wmi_pdev_pktlog_disable(struct ath11k *ar)
return ret;
}

+int
+ath11k_wmi_send_twt_enable_cmd(struct ath11k *ar, u32 pdev_id)
+{
+ struct ath11k_pdev_wmi *wmi = ar->wmi;
+ struct ath11k_base *ab = wmi->wmi_sc->sc;
+ struct wmi_twt_enable_params_cmd *cmd;
+ struct sk_buff *skb;
+ int ret, len;
+
+ len = sizeof(*cmd);
+
+ skb = ath11k_wmi_alloc_skb(wmi->wmi_sc, len);
+ if (!skb)
+ return -ENOMEM;
+
+ cmd = (void *)skb->data;
+ cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_TWT_ENABLE_CMD) |
+ FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE);
+ cmd->pdev_id = pdev_id;
+ cmd->sta_cong_timer_ms = ATH11K_TWT_DEF_STA_CONG_TIMER_MS;
+ cmd->default_slot_size = ATH11K_TWT_DEF_DEFAULT_SLOT_SIZE;
+ cmd->congestion_thresh_setup = ATH11K_TWT_DEF_CONGESTION_THRESH_SETUP;
+ cmd->congestion_thresh_teardown =
+ ATH11K_TWT_DEF_CONGESTION_THRESH_TEARDOWN;
+ cmd->congestion_thresh_critical =
+ ATH11K_TWT_DEF_CONGESTION_THRESH_CRITICAL;
+ cmd->interference_thresh_teardown =
+ ATH11K_TWT_DEF_INTERFERENCE_THRESH_TEARDOWN;
+ cmd->interference_thresh_setup =
+ ATH11K_TWT_DEF_INTERFERENCE_THRESH_SETUP;
+ cmd->min_no_sta_setup = ATH11K_TWT_DEF_MIN_NO_STA_SETUP;
+ cmd->min_no_sta_teardown = ATH11K_TWT_DEF_MIN_NO_STA_TEARDOWN;
+ cmd->no_of_bcast_mcast_slots = ATH11K_TWT_DEF_NO_OF_BCAST_MCAST_SLOTS;
+ cmd->min_no_twt_slots = ATH11K_TWT_DEF_MIN_NO_TWT_SLOTS;
+ cmd->max_no_sta_twt = ATH11K_TWT_DEF_MAX_NO_STA_TWT;
+ cmd->mode_check_interval = ATH11K_TWT_DEF_MODE_CHECK_INTERVAL;
+ cmd->add_sta_slot_interval = ATH11K_TWT_DEF_ADD_STA_SLOT_INTERVAL;
+ cmd->remove_sta_slot_interval =
+ ATH11K_TWT_DEF_REMOVE_STA_SLOT_INTERVAL;
+ /* TODO add MBSSID support */
+ cmd->mbss_support = 0;
+
+ ret = ath11k_wmi_cmd_send(wmi, skb,
+ WMI_TWT_ENABLE_CMDID);
+ if (ret) {
+ ath11k_warn(ab, "Failed to send WMI_TWT_ENABLE_CMDID");
+ dev_kfree_skb(skb);
+ }
+ return ret;
+}
+
+int
+ath11k_wmi_send_twt_disable_cmd(struct ath11k *ar, u32 pdev_id)
+{
+ struct ath11k_pdev_wmi *wmi = ar->wmi;
+ struct ath11k_base *ab = wmi->wmi_sc->sc;
+ struct wmi_twt_disable_params_cmd *cmd;
+ struct sk_buff *skb;
+ int ret, len;
+
+ len = sizeof(*cmd);
+
+ skb = ath11k_wmi_alloc_skb(wmi->wmi_sc, len);
+ if (!skb)
+ return -ENOMEM;
+
+ cmd = (void *)skb->data;
+ cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_TWT_DISABLE_CMD) |
+ FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE);
+ cmd->pdev_id = pdev_id;
+
+ ret = ath11k_wmi_cmd_send(wmi, skb,
+ WMI_TWT_DISABLE_CMDID);
+ if (ret) {
+ ath11k_warn(ab, "Failed to send WMI_TWT_DIeABLE_CMDID");
+ dev_kfree_skb(skb);
+ }
+ return ret;
+}
+
static inline void ath11k_fill_band_to_mac_param(struct ath11k_base *soc,
struct wmi_host_pdev_band_to_mac *band_to_mac)
{
@@ -2877,6 +2961,9 @@ ath11k_wmi_copy_resource_config(struct wmi_resource_config *wmi_cfg,
wmi_cfg->use_pdev_id = tg_cfg->use_pdev_id;
wmi_cfg->flag1 = tg_cfg->atf_config;
wmi_cfg->peer_map_unmap_v2_support = tg_cfg->peer_map_unmap_v2_support;
+ wmi_cfg->sched_params = tg_cfg->sched_params;
+ wmi_cfg->twt_ap_pdev_count = tg_cfg->twt_ap_pdev_count;
+ wmi_cfg->twt_ap_sta_count = tg_cfg->twt_ap_sta_count;
}

static int ath11k_init_cmd_send(struct ath11k_pdev_wmi *wmi,
@@ -3068,6 +3155,8 @@ int ath11k_wmi_cmd_init(struct ath11k_base *sc)
config.beacon_tx_offload_max_vdev = sc->num_radios * TARGET_MAX_BCN_OFFLD;
config.rx_batchmode = TARGET_RX_BATCHMODE;
config.peer_map_unmap_v2_support = 1;
+ config.twt_ap_pdev_count = 2;
+ config.twt_ap_sta_count = 1000;

memcpy(&wmi_sc->wlan_resource_config, &config, sizeof(config));

@@ -5859,6 +5948,8 @@ static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb)
/* add Unsupported events here */
case WMI_TBTTOFFSET_EXT_UPDATE_EVENTID:
case WMI_VDEV_DELETE_RESP_EVENTID:
+ case WMI_TWT_ENABLE_EVENTID:
+ case WMI_TWT_DISABLE_EVENTID:
ath11k_dbg(ab, ATH11K_DBG_WMI,
"ignoring unsupported event 0x%x\n", id);
break;
diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h
index 071537850c68..99f69fc3cf53 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.h
+++ b/drivers/net/wireless/ath/ath11k/wmi.h
@@ -169,6 +169,10 @@ enum wmi_cmd_group {
WMI_GRP_MONITOR, /* 0x39 */
WMI_GRP_REGULATORY, /* 0x3a */
WMI_GRP_HW_DATA_FILTER, /* 0x3b */
+ WMI_GRP_WLM, /* 0x3c */
+ WMI_GRP_11K_OFFLOAD, /* 0x3d */
+ WMI_GRP_TWT, /* 0x3e */
+
};

#define WMI_CMD_GRP(grp_id) (((grp_id) << 12) | 0x1)
@@ -531,6 +535,12 @@ enum wmi_tlv_cmd_id {
WMI_NDP_RESPONDER_REQ_CMDID,
WMI_NDP_END_REQ_CMDID,
WMI_HW_DATA_FILTER_CMDID = WMI_TLV_CMD(WMI_GRP_HW_DATA_FILTER),
+ WMI_TWT_ENABLE_CMDID = WMI_TLV_CMD(WMI_GRP_TWT),
+ WMI_TWT_DISABLE_CMDID,
+ WMI_TWT_ADD_DIALOG_CMDID,
+ WMI_TWT_DEL_DIALOG_CMDID,
+ WMI_TWT_PAUSE_DIALOG_CMDID,
+ WMI_TWT_RESUME_DIALOG_CMDID,
};

enum wmi_tlv_event_id {
@@ -713,6 +723,13 @@ enum wmi_tlv_event_id {
WMI_NDP_INDICATION_EVENTID,
WMI_NDP_CONFIRM_EVENTID,
WMI_NDP_END_INDICATION_EVENTID,
+
+ WMI_TWT_ENABLE_EVENTID = WMI_TLV_CMD(WMI_GRP_TWT),
+ WMI_TWT_DISABLE_EVENTID,
+ WMI_TWT_ADD_DIALOG_EVENTID,
+ WMI_TWT_DEL_DIALOG_EVENTID,
+ WMI_TWT_PAUSE_DIALOG_EVENTID,
+ WMI_TWT_RESUME_DIALOG_EVENTID,
};

enum wmi_tlv_pdev_param {
@@ -2736,6 +2753,9 @@ struct wmi_resource_config {
u32 max_num_dbs_scan_duty_cycle;
u32 max_num_group_keys;
u32 peer_map_unmap_v2_support;
+ u32 sched_params;
+ u32 twt_ap_pdev_count;
+ u32 twt_ap_sta_count;
} __packed;

struct wmi_service_ready_event {
@@ -3907,6 +3927,8 @@ struct peer_assoc_params {
u32 peer_he_mcs_count;
u32 peer_he_rx_mcs_set[WMI_HOST_MAX_HE_RATE_SET];
u32 peer_he_tx_mcs_set[WMI_HOST_MAX_HE_RATE_SET];
+ bool twt_responder;
+ bool twt_requester;
struct ath11k_ppe_threshold peer_ppet;
};

@@ -4130,6 +4152,8 @@ struct wmi_pktlog_disable_cmd {
#define WMI_PEER_DYN_MIMOPS 0x00020000
#define WMI_PEER_STATIC_MIMOPS 0x00040000
#define WMI_PEER_SPATIAL_MUX 0x00200000
+#define WMI_PEER_TWT_REQ 0x00400000
+#define WMI_PEER_TWT_RESP 0x00800000
#define WMI_PEER_VHT 0x02000000
#define WMI_PEER_80MHZ 0x04000000
#define WMI_PEER_PMF 0x08000000
@@ -5005,6 +5029,48 @@ struct wmi_wmm_params_all_arg {
struct wmi_wmm_params_arg ac_vo;
};

+#define ATH11K_TWT_DEF_STA_CONG_TIMER_MS 5000
+#define ATH11K_TWT_DEF_DEFAULT_SLOT_SIZE 10
+#define ATH11K_TWT_DEF_CONGESTION_THRESH_SETUP 50
+#define ATH11K_TWT_DEF_CONGESTION_THRESH_TEARDOWN 20
+#define ATH11K_TWT_DEF_CONGESTION_THRESH_CRITICAL 100
+#define ATH11K_TWT_DEF_INTERFERENCE_THRESH_TEARDOWN 80
+#define ATH11K_TWT_DEF_INTERFERENCE_THRESH_SETUP 50
+#define ATH11K_TWT_DEF_MIN_NO_STA_SETUP 10
+#define ATH11K_TWT_DEF_MIN_NO_STA_TEARDOWN 2
+#define ATH11K_TWT_DEF_NO_OF_BCAST_MCAST_SLOTS 2
+#define ATH11K_TWT_DEF_MIN_NO_TWT_SLOTS 2
+#define ATH11K_TWT_DEF_MAX_NO_STA_TWT 500
+#define ATH11K_TWT_DEF_MODE_CHECK_INTERVAL 10000
+#define ATH11K_TWT_DEF_ADD_STA_SLOT_INTERVAL 1000
+#define ATH11K_TWT_DEF_REMOVE_STA_SLOT_INTERVAL 5000
+
+struct wmi_twt_enable_params_cmd {
+ u32 tlv_header;
+ u32 pdev_id;
+ u32 sta_cong_timer_ms;
+ u32 mbss_support;
+ u32 default_slot_size;
+ u32 congestion_thresh_setup;
+ u32 congestion_thresh_teardown;
+ u32 congestion_thresh_critical;
+ u32 interference_thresh_teardown;
+ u32 interference_thresh_setup;
+ u32 min_no_sta_setup;
+ u32 min_no_sta_teardown;
+ u32 no_of_bcast_mcast_slots;
+ u32 min_no_twt_slots;
+ u32 max_no_sta_twt;
+ u32 mode_check_interval;
+ u32 add_sta_slot_interval;
+ u32 remove_sta_slot_interval;
+};
+
+struct wmi_twt_disable_params_cmd {
+ u32 tlv_header;
+ u32 pdev_id;
+};
+
struct target_resource_config {
u32 num_vdevs;
u32 num_peers;
@@ -5065,6 +5131,9 @@ struct target_resource_config {
u32 max_bssid_rx_filters;
u32 use_pdev_id;
u32 peer_map_unmap_v2_support;
+ u32 sched_params;
+ u32 twt_ap_pdev_count;
+ u32 twt_ap_sta_count;
};

#define WMI_MAX_MEM_REQS 32
@@ -5190,4 +5259,6 @@ size_t ath11k_wmi_fw_stats_num_vdevs(struct list_head *head);
void ath11k_wmi_fw_stats_fill(struct ath11k *ar,
struct ath11k_fw_stats *fw_stats, u32 stats_id,
char *buf);
+int ath11k_wmi_send_twt_enable_cmd(struct ath11k *ar, u32 pdev_id);
+int ath11k_wmi_send_twt_disable_cmd(struct ath11k *ar, u32 pdev_id);
#endif
--
2.11.0


2019-04-26 09:42:59

by John Crispin

[permalink] [raw]
Subject: [PATCH V2 1/3] mac80211: allow turning TWT responder support on and off via netlink

Allow the userland daemon to en/disable TWT support for an AP.

Signed-off-by: Shashidhar Lakkavalli <[email protected]>
Signed-off-by: John Crispin <[email protected]>
---
include/net/cfg80211.h | 2 ++
include/net/mac80211.h | 5 +++++
include/uapi/linux/nl80211.h | 4 ++++
net/mac80211/cfg.c | 6 ++++++
net/wireless/nl80211.c | 6 ++++++
5 files changed, 23 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index bb307a11ee63..8a20f5a42977 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1511,6 +1511,7 @@ struct mpath_info {
* (u16 = opmode, -1 = do not change)
* @p2p_ctwindow: P2P CT Window (-1 = no change)
* @p2p_opp_ps: P2P opportunistic PS (-1 = no change)
+ * @twt_responder: HE Target Wait Time support.
*/
struct bss_parameters {
int use_cts_prot;
@@ -1521,6 +1522,7 @@ struct bss_parameters {
int ap_isolate;
int ht_opmode;
s8 p2p_ctwindow, p2p_opp_ps;
+ int twt_responder;
};

/**
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index ac2ed8ec662b..87a6e149abda 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -317,6 +317,7 @@ struct ieee80211_vif_chanctx_switch {
* @BSS_CHANGED_MCAST_RATE: Multicast Rate setting changed for this interface
* @BSS_CHANGED_FTM_RESPONDER: fime timing reasurement request responder
* functionality changed for this BSS (AP mode).
+ * @BSS_CHANGED_TWT: TWT enable status changed
*
*/
enum ieee80211_bss_change {
@@ -347,6 +348,7 @@ enum ieee80211_bss_change {
BSS_CHANGED_KEEP_ALIVE = 1<<24,
BSS_CHANGED_MCAST_RATE = 1<<25,
BSS_CHANGED_FTM_RESPONDER = 1<<26,
+ BSS_CHANGED_TWT = 1<<27,

/* when adding here, make sure to change ieee80211_reconfig */
};
@@ -504,6 +506,8 @@ struct ieee80211_ftm_responder_params {
* @he_support: does this BSS support HE
* @twt_requester: does this BSS support TWT requester (relevant for managed
* mode only, set if the AP advertises TWT responder role)
+ * @twt_responder: does this BSS support TWT responder (relevant for AP
+ * mode only, set if the AP advertises TWT responder role)
* @assoc: association status
* @ibss_joined: indicates whether this station is part of an IBSS
* or not
@@ -611,6 +615,7 @@ struct ieee80211_bss_conf {
u16 frame_time_rts_th;
bool he_support;
bool twt_requester;
+ bool twt_responder;
/* association related data */
bool assoc, ibss_joined;
bool ibss_creator;
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index dd4f86ee286e..ba1f69751a4a 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2308,6 +2308,8 @@ enum nl80211_commands {
* @NL80211_ATTR_AIRTIME_WEIGHT: Station's weight when scheduled by the airtime
* scheduler.
*
+ * @NL80211_ATTR_TWT_RESPONDER: Enable target wait time responder support.
+ *
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2759,6 +2761,8 @@ enum nl80211_attrs {

NL80211_ATTR_AIRTIME_WEIGHT,

+ NL80211_ATTR_TWT_RESPONDER,
+
/* add attributes here, update the policy in nl80211.c */

__NL80211_ATTR_AFTER_LAST,
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 09dd1c2860fc..a66600bf9cef 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2176,6 +2176,12 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
changed |= BSS_CHANGED_P2P_PS;
}

+ if (params->twt_responder >= 0) {
+ sdata->vif.bss_conf.twt_responder =
+ params->twt_responder;
+ changed |= BSS_CHANGED_TWT;
+ }
+
ieee80211_bss_info_change_notify(sdata, changed);

return 0;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 25a9e3b5c154..afd04a98a601 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -541,6 +541,7 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
[NL80211_ATTR_PEER_MEASUREMENTS] =
NLA_POLICY_NESTED(nl80211_pmsr_attr_policy),
[NL80211_ATTR_AIRTIME_WEIGHT] = NLA_POLICY_MIN(NLA_U16, 1),
+ [NL80211_ATTR_BSS_SHORT_PREAMBLE] = NLA_POLICY_RANGE(NLA_U8, 0, 1),
};

/* policy for the key attributes */
@@ -6105,6 +6106,7 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
params.ht_opmode = -1;
params.p2p_ctwindow = -1;
params.p2p_opp_ps = -1;
+ params.twt_responder = -1;

if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
params.use_cts_prot =
@@ -6149,6 +6151,10 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
return -EINVAL;
}

+ if (info->attrs[NL80211_ATTR_TWT_RESPONDER])
+ params.twt_responder =
+ nla_get_u8(info->attrs[NL80211_ATTR_TWT_RESPONDER]);
+
if (!rdev->ops->change_bss)
return -EOPNOTSUPP;

--
2.11.0


2019-04-26 09:44:10

by John Crispin

[permalink] [raw]
Subject: [PATCH V2 2/3] mac80211: dynamically turn TWT requester support on and off

Turn TWT on/off for STA interfaces when they associate and/or receive a
beacon where the twt_responder bit has changed.

Signed-off-by: Shashidhar Lakkavalli <[email protected]>
Signed-off-by: John Crispin <[email protected]>
---
net/mac80211/mlme.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 2dbcf5d5512e..f3563670ed58 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -3151,6 +3151,21 @@ static bool ieee80211_twt_req_supported(const struct sta_info *sta,
IEEE80211_HE_MAC_CAP0_TWT_RES;
}

+static int ieee80211_recalc_twt_req(struct ieee80211_sub_if_data *sdata,
+ struct sta_info *sta,
+ struct ieee802_11_elems *elems)
+{
+ bool twt_req;
+
+ twt_req = ieee80211_twt_req_supported(sta, elems);
+
+ if (sdata->vif.bss_conf.twt_requester != twt_req) {
+ sdata->vif.bss_conf.twt_requester = twt_req;
+ return BSS_CHANGED_TWT;
+ }
+ return 0;
+}
+
static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
struct cfg80211_bss *cbss,
struct ieee80211_mgmt *mgmt, size_t len)
@@ -3333,8 +3348,7 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
sta);

bss_conf->he_support = sta->sta.he_cap.has_he;
- bss_conf->twt_requester =
- ieee80211_twt_req_supported(sta, &elems);
+ changed |= ieee80211_recalc_twt_req(sdata, sta, &elems);
} else {
bss_conf->he_support = false;
bss_conf->twt_requester = false;
@@ -3994,6 +4008,8 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
mutex_lock(&local->sta_mtx);
sta = sta_info_get(sdata, bssid);

+ changed |= ieee80211_recalc_twt_req(sdata, sta, &elems);
+
if (ieee80211_config_bw(sdata, sta,
elems.ht_cap_elem, elems.ht_operation,
elems.vht_operation, elems.he_operation,
--
2.11.0


2019-04-26 19:52:07

by John Crispin

[permalink] [raw]
Subject: Re: [PATCH V2 1/3] mac80211: allow turning TWT responder support on and off via netlink


On 26/04/2019 11:41, John Crispin wrote:
> @@ -6105,6 +6106,7 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
> params.ht_opmode = -1;
> params.p2p_ctwindow = -1;
> params.p2p_opp_ps = -1;
> + params.twt_responder = -1;
>
> if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
> params.use_cts_prot =
> @@ -6149,6 +6151,10 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
> return -EINVAL;
> }
>
> + if (info->attrs[NL80211_ATTR_TWT_RESPONDER])
> + params.twt_responder =
> + nla_get_u8(info->attrs[NL80211_ATTR_TWT_RESPONDER]);
> +
> if (!rdev->ops->change_bss)
> return -EOPNOTSUPP;

Hi,

this should probably be moved to nl80211_start_ap() instead of
nl80211_set_bss() as we probably dont want to change this at runtime ?

    John


2019-04-26 19:52:07

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH V2 1/3] mac80211: allow turning TWT responder support on and off via netlink

On Fri, 2019-04-26 at 21:50 +0200, John Crispin wrote:
> On 26/04/2019 11:41, John Crispin wrote:
> > @@ -6105,6 +6106,7 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
> > params.ht_opmode = -1;
> > params.p2p_ctwindow = -1;
> > params.p2p_opp_ps = -1;
> > + params.twt_responder = -1;
> >
> > if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
> > params.use_cts_prot =
> > @@ -6149,6 +6151,10 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
> > return -EINVAL;
> > }
> >
> > + if (info->attrs[NL80211_ATTR_TWT_RESPONDER])
> > + params.twt_responder =
> > + nla_get_u8(info->attrs[NL80211_ATTR_TWT_RESPONDER]);
> > +
> > if (!rdev->ops->change_bss)
> > return -EOPNOTSUPP;
>
> Hi,
>
> this should probably be moved to nl80211_start_ap() instead of
> nl80211_set_bss() as we probably dont want to change this at runtime ?

I have no idea, can we change it at runtime? Is it a capability or an
operational state?

johannes


2019-04-26 19:55:07

by John Crispin

[permalink] [raw]
Subject: Re: [PATCH V2 1/3] mac80211: allow turning TWT responder support on and off via netlink


On 26/04/2019 21:51, Johannes Berg wrote:
> On Fri, 2019-04-26 at 21:50 +0200, John Crispin wrote:
>> On 26/04/2019 11:41, John Crispin wrote:
>>> @@ -6105,6 +6106,7 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
>>> params.ht_opmode = -1;
>>> params.p2p_ctwindow = -1;
>>> params.p2p_opp_ps = -1;
>>> + params.twt_responder = -1;
>>>
>>> if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
>>> params.use_cts_prot =
>>> @@ -6149,6 +6151,10 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
>>> return -EINVAL;
>>> }
>>>
>>> + if (info->attrs[NL80211_ATTR_TWT_RESPONDER])
>>> + params.twt_responder =
>>> + nla_get_u8(info->attrs[NL80211_ATTR_TWT_RESPONDER]);
>>> +
>>> if (!rdev->ops->change_bss)
>>> return -EOPNOTSUPP;
>> Hi,
>>
>> this should probably be moved to nl80211_start_ap() instead of
>> nl80211_set_bss() as we probably dont want to change this at runtime ?
> I have no idea, can we change it at runtime? Is it a capability or an
> operational state?
>
> johannes

its a capability, only the twt_required bit is an operational state. so
I shall send a V3 moving it to start_ap() :-)

    John


2019-04-30 06:43:44

by Rajkumar Manoharan

[permalink] [raw]
Subject: Re: [PATCH V2 1/3] mac80211: allow turning TWT responder support on and off via netlink

On 2019-04-26 02:41, John Crispin wrote:
> Allow the userland daemon to en/disable TWT support for an AP.
>
> Signed-off-by: Shashidhar Lakkavalli <[email protected]>
> Signed-off-by: John Crispin <[email protected]>
> ---
> include/net/cfg80211.h | 2 ++
> include/net/mac80211.h | 5 +++++
> include/uapi/linux/nl80211.h | 4 ++++
> net/mac80211/cfg.c | 6 ++++++
> net/wireless/nl80211.c | 6 ++++++
> 5 files changed, 23 insertions(+)
>
> diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
> index bb307a11ee63..8a20f5a42977 100644
> --- a/include/net/cfg80211.h
> +++ b/include/net/cfg80211.h
> @@ -1511,6 +1511,7 @@ struct mpath_info {
> * (u16 = opmode, -1 = do not change)
> * @p2p_ctwindow: P2P CT Window (-1 = no change)
> * @p2p_opp_ps: P2P opportunistic PS (-1 = no change)
> + * @twt_responder: HE Target Wait Time support.
>

Responder support. Perhaps it could named as he_twt_resp to
differentiate from ah.

> */
> struct bss_parameters {
> int use_cts_prot;
> @@ -1521,6 +1522,7 @@ struct bss_parameters {
> int ap_isolate;
> int ht_opmode;
> s8 p2p_ctwindow, p2p_opp_ps;
> + int twt_responder;
> };
>
Same here. Better fix he_ in other places as well. thoughts?

> /**
> diff --git a/include/net/mac80211.h b/include/net/mac80211.h
> index ac2ed8ec662b..87a6e149abda 100644
> --- a/include/net/mac80211.h
> +++ b/include/net/mac80211.h
> @@ -317,6 +317,7 @@ struct ieee80211_vif_chanctx_switch {
> * @BSS_CHANGED_MCAST_RATE: Multicast Rate setting changed for this
> interface
> * @BSS_CHANGED_FTM_RESPONDER: fime timing reasurement request
> responder
> * functionality changed for this BSS (AP mode).
> + * @BSS_CHANGED_TWT: TWT enable status changed
> *
> */
> enum ieee80211_bss_change {
> @@ -347,6 +348,7 @@ enum ieee80211_bss_change {
> BSS_CHANGED_KEEP_ALIVE = 1<<24,
> BSS_CHANGED_MCAST_RATE = 1<<25,
> BSS_CHANGED_FTM_RESPONDER = 1<<26,
> + BSS_CHANGED_TWT = 1<<27,
>
> /* when adding here, make sure to change ieee80211_reconfig */
> };
> @@ -504,6 +506,8 @@ struct ieee80211_ftm_responder_params {
> * @he_support: does this BSS support HE
> * @twt_requester: does this BSS support TWT requester (relevant for
> managed
> * mode only, set if the AP advertises TWT responder role)
> + * @twt_responder: does this BSS support TWT responder (relevant for
> AP
> + * mode only, set if the AP advertises TWT responder role)
> * @assoc: association status
> * @ibss_joined: indicates whether this station is part of an IBSS
> * or not
> @@ -611,6 +615,7 @@ struct ieee80211_bss_conf {
> u16 frame_time_rts_th;
> bool he_support;
> bool twt_requester;
> + bool twt_responder;
>
ah.. I see existing twt_requester config.

> /* association related data */
> bool assoc, ibss_joined;
> bool ibss_creator;
> diff --git a/include/uapi/linux/nl80211.h
> b/include/uapi/linux/nl80211.h
> index dd4f86ee286e..ba1f69751a4a 100644
> --- a/include/uapi/linux/nl80211.h
> +++ b/include/uapi/linux/nl80211.h
> @@ -2308,6 +2308,8 @@ enum nl80211_commands {
> * @NL80211_ATTR_AIRTIME_WEIGHT: Station's weight when scheduled by
> the airtime
> * scheduler.
> *
> + * @NL80211_ATTR_TWT_RESPONDER: Enable target wait time responder
> support.
> + *
> * @NUM_NL80211_ATTR: total number of nl80211_attrs available
> * @NL80211_ATTR_MAX: highest attribute number currently defined
> * @__NL80211_ATTR_AFTER_LAST: internal use
> @@ -2759,6 +2761,8 @@ enum nl80211_attrs {
>
> NL80211_ATTR_AIRTIME_WEIGHT,
>
> + NL80211_ATTR_TWT_RESPONDER,
> +
> /* add attributes here, update the policy in nl80211.c */
>
> __NL80211_ATTR_AFTER_LAST,
> diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
> index 09dd1c2860fc..a66600bf9cef 100644
> --- a/net/mac80211/cfg.c
> +++ b/net/mac80211/cfg.c
> @@ -2176,6 +2176,12 @@ static int ieee80211_change_bss(struct wiphy
> *wiphy,
> changed |= BSS_CHANGED_P2P_PS;
> }
>
> + if (params->twt_responder >= 0) {
> + sdata->vif.bss_conf.twt_responder =
> + params->twt_responder;
> + changed |= BSS_CHANGED_TWT;
> + }
> +
> ieee80211_bss_info_change_notify(sdata, changed);
>
> return 0;
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index 25a9e3b5c154..afd04a98a601 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -541,6 +541,7 @@ const struct nla_policy
> nl80211_policy[NUM_NL80211_ATTR] = {
> [NL80211_ATTR_PEER_MEASUREMENTS] =
> NLA_POLICY_NESTED(nl80211_pmsr_attr_policy),
> [NL80211_ATTR_AIRTIME_WEIGHT] = NLA_POLICY_MIN(NLA_U16, 1),
> + [NL80211_ATTR_BSS_SHORT_PREAMBLE] = NLA_POLICY_RANGE(NLA_U8, 0, 1),
> };
>
Why SHORT_PREAMBLE? Why not attribute be NLA_FLAG?

-Rajkumar

2019-04-30 06:46:27

by Rajkumar Manoharan

[permalink] [raw]
Subject: Re: [PATCH V2 2/3] mac80211: dynamically turn TWT requester support on and off

On 2019-04-26 02:41, John Crispin wrote:
> Turn TWT on/off for STA interfaces when they associate and/or receive a
> beacon where the twt_responder bit has changed.
>

Does it mean that TWT responder can be turn on/off when AP is UP and
running?
I thought any change in beacon needs AP restart. no?

-Rajkumar

2019-04-30 06:50:45

by Rajkumar Manoharan

[permalink] [raw]
Subject: Re: [PATCH V2 3/3] ath11k: add TWT support

On 2019-04-26 02:41, John Crispin wrote:
> diff --git a/drivers/net/wireless/ath/ath11k/mac.c
> b/drivers/net/wireless/ath/ath11k/mac.c
> index 8bb4ff82fb6f..a38c101e0140 100644
> --- a/drivers/net/wireless/ath/ath11k/mac.c
> +++ b/drivers/net/wireless/ath/ath11k/mac.c
> @@ -1938,6 +1938,13 @@ static void ath11k_bss_info_changed(struct
> ieee80211_hw *hw,
> ath11k_mac_txpower_recalc(ar);
> }
>
> + if (changed & BSS_CHANGED_TWT) {
> + if (info->twt_responder || info->twt_responder)
>
typo? two twt_responder checks?

-Rajkumar

2019-04-30 06:59:47

by John Crispin

[permalink] [raw]
Subject: Re: [PATCH V2 2/3] mac80211: dynamically turn TWT requester support on and off


On 30/04/2019 08:45, Rajkumar Manoharan wrote:
> On 2019-04-26 02:41, John Crispin wrote:
>> Turn TWT on/off for STA interfaces when they associate and/or receive a
>> beacon where the twt_responder bit has changed.
>>
>
> Does it mean that TWT responder can be turn on/off when AP is UP and
> running?
> I thought any change in beacon needs AP restart. no?
>
> -Rajkumar
>
> _______________________________________________
> ath11k mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/ath11k

Hi Rajkumar,

I am about to send a V2 that already addresses allthose comments, Thanks
for the review

    John