[PATCH v3 7/7] TWT: Add support to configure TWT of a session using offset in microseconds
Gokul Sivakumar
gokulkumar.sivakumar at infineon.com
Tue Aug 22 07:54:12 PDT 2023
Introduce a new CMD line argument "twt_offset=<u64>" in the existing list
of arguments supported in "$ wpa_cli twt_setup <args>" CMD to set the TWT
in terms of offset from the current remote TSF.
Example: To set a Target Wake Time of 102.4ms from the current remote TSF
$ wpa_cli -i wlan0 twt_setup setup_cmd=0 min_twt=80 mantissa=38400 \
exponent=3 twt_offset=102400 trigger=1 implicit=1 flow_type=0 \
control=0
Signed-off-by: Gokul Sivakumar <gokulkumar.sivakumar at infineon.com>
---
Changes in v2:
- Moved the IFX_VENDOR_ATTR_TWT_PARAM_WAKE_TIME_OFFSET netlink attr declaration
from here to [PATCH 5/7]. This would with help with retaining the current enum
ID number (5) for the WAKE_TIME_OFFSET attribute used by the driver, while not
showing any enum re-numbering across commits in this patch series.
src/drivers/driver.h | 1 +
src/drivers/driver_nl80211.c | 4 ++++
wpa_supplicant/ctrl_iface.c | 11 ++++++++---
wpa_supplicant/twt.c | 22 ++++++++++++----------
wpa_supplicant/wpa_cli.c | 2 +-
wpa_supplicant/wpa_supplicant_i.h | 12 ++++++------
6 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 80e66f100..73b3a6f6d 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -2956,6 +2956,7 @@ struct driver_sta_mlo_info {
struct drv_setup_twt_params {
u8 dtok;
u64 twt;
+ u64 twt_offset;
u8 min_twt;
u8 exponent;
u16 mantissa;
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 6ab012b85..da6799950 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -13686,6 +13686,10 @@ static int nl80211_ifx_setup_twt(struct wpa_driver_nl80211_data *drv,
nla_put_u64(msg, IFX_VENDOR_ATTR_TWT_PARAM_WAKE_TIME,
params->twt)) ||
+ (params->twt_offset &&
+ nla_put_u64(msg, IFX_VENDOR_ATTR_TWT_PARAM_WAKE_TIME_OFFSET,
+ params->twt_offset)) ||
+
nla_put_u8(msg, IFX_VENDOR_ATTR_TWT_PARAM_MIN_WAKE_DURATION,
params->min_twt) ||
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 06daea723..a2c02798b 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -10330,6 +10330,7 @@ static int wpas_ctrl_iface_send_twt_setup(struct wpa_supplicant *wpa_s,
int mantissa = 8192;
u8 min_twt = 255;
unsigned long long twt = 0;
+ unsigned long long twt_offset = 0;
bool requestor = true;
int setup_cmd = 0;
bool trigger = true;
@@ -10368,6 +10369,10 @@ static int wpas_ctrl_iface_send_twt_setup(struct wpa_supplicant *wpa_s,
sscanf(tok_s + os_strlen(" twt="), "%llu", &twt) != 1)
return -1;
+ tok_s = os_strstr(cmd, " twt_offset=");
+ if (tok_s)
+ sscanf(tok_s + os_strlen(" twt_offset="), "%llu", &twt_offset);
+
tok_s = os_strstr(cmd, " requestor=");
if (tok_s)
requestor = atoi(tok_s + os_strlen(" requestor="));
@@ -10401,9 +10406,9 @@ static int wpas_ctrl_iface_send_twt_setup(struct wpa_supplicant *wpa_s,
control = atoi(tok_s + os_strlen(" control="));
return wpas_twt_send_setup(wpa_s, dtok, exponent, mantissa, min_twt,
- setup_cmd, twt, requestor, trigger, implicit,
- flow_type, flow_id, protection, twt_channel,
- control);
+ setup_cmd, twt, twt_offset, requestor,
+ trigger, implicit, flow_type, flow_id,
+ protection, twt_channel, control);
}
diff --git a/wpa_supplicant/twt.c b/wpa_supplicant/twt.c
index 75ebfe56f..c5b88e353 100644
--- a/wpa_supplicant/twt.c
+++ b/wpa_supplicant/twt.c
@@ -109,6 +109,7 @@ int wpas_twt_test_send_setup(struct wpa_supplicant *wpa_s, u8 dtok, int exponent
* @min_twt: Minimum TWT wake duration in units of 256 usec
* @setup_cmd: 0 == request, 1 == suggest, etc. Table 9-297
* @twt: Target Wake Time
+ * @twt_offset: Target Wake Time TSF offset
* @requestor: Specify this is a TWT Requesting / Responding STA
* @trigger: Specify Trigger based / Non-Trigger based TWT Session
* @implicit: Specify Implicit / Explicit TWT session
@@ -122,9 +123,9 @@ int wpas_twt_test_send_setup(struct wpa_supplicant *wpa_s, u8 dtok, int exponent
*/
int wpas_twt_offload_send_setup(struct wpa_supplicant *wpa_s, u8 dtok, int exponent,
int mantissa, u8 min_twt, int setup_cmd, u64 twt,
- bool requestor, bool trigger, bool implicit,
- bool flow_type, u8 flow_id, bool protection,
- u8 twt_channel, u8 control)
+ u64 twt_offset, bool requestor, bool trigger,
+ bool implicit, bool flow_type, u8 flow_id,
+ bool protection, u8 twt_channel, u8 control)
{
int ret = 0;
struct drv_setup_twt_params params;
@@ -237,6 +238,7 @@ fail:
* @min_twt: Minimum TWT wake duration in units of 256 usec
* @setup_cmd: 0 == request, 1 == suggest, etc. Table 9-297
* @twt: Target Wake Time
+ * @twt_offset: Target Wake Time TSF offset
* @requestor: Specify this is a TWT Requesting / Responding STA
* @trigger: Specify Trigger based / Non-Trigger based TWT Session
* @implicit: Specify Implicit / Explicit TWT session
@@ -250,9 +252,9 @@ fail:
*/
int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, u8 dtok, int exponent,
int mantissa, u8 min_twt, int setup_cmd, u64 twt,
- bool requestor, bool trigger, bool implicit,
- bool flow_type, u8 flow_id, bool protection,
- u8 twt_channel, u8 control)
+ u64 twt_offset, bool requestor, bool trigger,
+ bool implicit, bool flow_type, u8 flow_id,
+ bool protection, u8 twt_channel, u8 control)
{
#ifdef CONFIG_TESTING_OPTIONS
return wpas_twt_test_send_setup(wpa_s, dtok, exponent, mantissa,
@@ -263,10 +265,10 @@ int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, u8 dtok, int exponent,
#endif /* CONFIG_TESTING_OPTIONS */
return wpas_twt_offload_send_setup(wpa_s, dtok, exponent, mantissa,
- min_twt, setup_cmd, twt, requestor,
- trigger, implicit, flow_type,
- flow_id, protection, twt_channel,
- control);
+ min_twt, setup_cmd, twt, twt_offset,
+ requestor, trigger, implicit,
+ flow_type, flow_id, protection,
+ twt_channel, control);
}
#ifdef CONFIG_TESTING_OPTIONS
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index 3dc1d779e..7f6cc46f2 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -3946,7 +3946,7 @@ static const struct wpa_cli_cmd wpa_cli_commands[] = {
},
{ "twt_setup",
wpa_cli_cmd_twt_setup, NULL, cli_cmd_flag_none,
- "[dialog=<token>] [exponent=<exponent>] [mantissa=<mantissa>] [min_twt=<Min TWT>] [setup_cmd=<setup-cmd>] [twt=<u64>] [requestor=0|1] [trigger=0|1] [implicit=0|1] [flow_type=0|1] [flow_id=<3-bit-id>] [protection=0|1] [twt_channel=<twt chanel id>] [control=<control-u8>] = Send TWT Setup frame"
+ "[dialog=<token>] [exponent=<exponent>] [mantissa=<mantissa>] [min_twt=<Min TWT>] [setup_cmd=<setup-cmd>] [twt=<u64>] [twt_offset=<u64>] [requestor=0|1] [trigger=0|1] [implicit=0|1] [flow_type=0|1] [flow_id=<3-bit-id>] [protection=0|1] [twt_channel=<twt chanel id>] [control=<control-u8>] = Send TWT Setup frame"
},
{ "twt_teardown",
wpa_cli_cmd_twt_teardown, NULL, cli_cmd_flag_none,
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 4f5e833cf..b7aec4d0b 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -1669,14 +1669,14 @@ int wpas_twt_test_send_setup(struct wpa_supplicant *wpa_s, u8 dtok, int exponent
#endif /* CONFIG_TESTING_OPTIONS */
int wpas_twt_offload_setup_setup(struct wpa_supplicant *wpa_s, u8 dtok, int exponent,
int mantissa, u8 min_twt, int setup_cmd, u64 twt,
- bool requestor, bool trigger, bool implicit,
- bool flow_type, u8 flow_id, bool protection,
- u8 twt_channel, u8 control);
+ u64 twt_offset, bool requestor, bool trigger,
+ bool implicit, bool flow_type, u8 flow_id,
+ bool protection, u8 twt_channel, u8 control);
int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, u8 dtok, int exponent,
int mantissa, u8 min_twt, int setup_cmd, u64 twt,
- bool requestor, bool trigger, bool implicit,
- bool flow_type, u8 flow_id, bool protection,
- u8 twt_channel, u8 control);
+ u64 twt_offset, bool requestor, bool trigger,
+ bool implicit, bool flow_type, u8 flow_id,
+ bool protection, u8 twt_channel, u8 control);
#ifdef CONFIG_TESTING_OPTIONS
int wpas_twt_test_send_teardown(struct wpa_supplicant *wpa_s, u8 flags);
#endif /* CONFIG_TESTING_OPTIONS */
--
2.25.1
More information about the Hostap
mailing list