[PATCH 7/7] TWT: Add support to configure TWT of a session using offset in microseconds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
---
 src/common/ifx_vendor.h           |  3 +++
 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 ++++++------
 7 files changed, 35 insertions(+), 20 deletions(-)

diff --git a/src/common/ifx_vendor.h b/src/common/ifx_vendor.h
index 3450b6d09..edf30302e 100644
--- a/src/common/ifx_vendor.h
+++ b/src/common/ifx_vendor.h
@@ -195,6 +195,8 @@ enum ifx_twt_oper {
  *
  * @IFX_VENDOR_ATTR_TWT_PARAM_WAKE_TIME: Target Wake Time.
  *
+ * @IFX_VENDOR_ATTR_TWT_PARAM_WAKE_TIME_OFFSET: Target Wake Time Offset.
+ *
  * @IFX_VENDOR_ATTR_TWT_PARAM_MIN_WAKE_DURATION: Nominal Minimum TWT Wake Duration.
  *
  * @IFX_VENDOR_ATTR_TWT_PARAM_WAKE_INTVL_EXPONENT: TWT Wake Interval Exponent.
@@ -238,6 +240,7 @@ enum ifx_vendor_attr_twt_param {
 	IFX_VENDOR_ATTR_TWT_PARAM_SETUP_CMD_TYPE,
 	IFX_VENDOR_ATTR_TWT_PARAM_DIALOG_TOKEN,
 	IFX_VENDOR_ATTR_TWT_PARAM_WAKE_TIME,
+	IFX_VENDOR_ATTR_TWT_PARAM_WAKE_TIME_OFFSET,
 	IFX_VENDOR_ATTR_TWT_PARAM_MIN_WAKE_DURATION,
 	IFX_VENDOR_ATTR_TWT_PARAM_WAKE_INTVL_EXPONENT,
 	IFX_VENDOR_ATTR_TWT_PARAM_WAKE_INTVL_MANTISSA,
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 9edd3ba97..dbf3ea79b 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -2927,6 +2927,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 4b52496c6..c3a8ba4dc 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -13490,6 +13490,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 9da15f7a2..44840cbb3 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -1668,14 +1668,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


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux