Skip to content

Commit 65aae9c

Browse files
Krishna Tcarlescufi
authored andcommitted
net: wifi: Use micro seconds for precision for TWT intervals
In order to take granular input use micro seconds as input for TWT intervals, this helps us in providing inputs such as 65.28ms without the need of using floating points. This also expands the TWT wake interval range to 262.144ms, earlier as we want to use uint8, limited to 256ms. Also, remove the units from the variable names, this is unnecessary and also avoids doing breaking changes. Update release notes as this is a breaking change, both type and variable names are changed. Signed-off-by: Krishna T <[email protected]>
1 parent 3c89bbf commit 65aae9c

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

doc/releases/release-notes-3.4.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ Trusted Firmware-M
340340

341341
Networking
342342
**********
343+
* Wi-Fi
344+
345+
* TWT intervals are changed from milli-seconds to micro-seconds, interval variables are also renamed.
343346

344347
USB
345348
***

include/zephyr/net/wifi_mgmt.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,13 @@ struct wifi_twt_params {
212212
union {
213213
struct {
214214
/* Interval = Wake up time + Sleeping time */
215-
uint32_t twt_interval_ms;
215+
uint64_t twt_interval;
216216
bool responder;
217217
bool trigger;
218218
bool implicit;
219219
bool announce;
220220
/* Wake up time */
221-
uint8_t twt_wake_interval_ms;
221+
uint32_t twt_wake_interval;
222222
} setup;
223223
struct {
224224
/* Only for Teardown */
@@ -229,10 +229,10 @@ struct wifi_twt_params {
229229

230230
/* Flow ID is only 3 bits */
231231
#define WIFI_MAX_TWT_FLOWS 8
232-
#define WIFI_MAX_TWT_INTERVAL_MS 0x7FFFFFFF
232+
#define WIFI_MAX_TWT_INTERVAL_US (ULONG_MAX - 1)
233233
struct wifi_twt_flow_info {
234234
/* Interval = Wake up time + Sleeping time */
235-
uint32_t twt_interval_ms;
235+
uint64_t twt_interval;
236236
/* Map requests to responses */
237237
uint8_t dialog_token;
238238
/* Map setup with teardown */
@@ -243,7 +243,7 @@ struct wifi_twt_flow_info {
243243
bool implicit;
244244
bool announce;
245245
/* Wake up time */
246-
uint8_t twt_wake_interval_ms;
246+
uint32_t twt_wake_interval;
247247
};
248248

249249
struct wifi_ps_config {

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ static void handle_wifi_twt_event(struct net_mgmt_event_callback *cb)
160160
/* If accepted, then no need to print TWT params */
161161
if (resp->setup_cmd != WIFI_TWT_SETUP_CMD_ACCEPT) {
162162
print(context.sh, SHELL_NORMAL,
163-
"TWT parameters: trigger: %s wake_interval: %d ms, interval: %d ms\n",
163+
"TWT parameters: trigger: %s wake_interval: %d us, interval: %lld us\n",
164164
resp->setup.trigger ? "trigger" : "no_trigger",
165-
resp->setup.twt_wake_interval_ms,
166-
resp->setup.twt_interval_ms);
165+
resp->setup.twt_wake_interval,
166+
resp->setup.twt_interval);
167167
}
168168
} else {
169169
print(context.sh, SHELL_NORMAL, "TWT response timed out\n");
@@ -478,10 +478,10 @@ static int cmd_wifi_ps(const struct shell *sh, size_t argc, char *argv[])
478478
config.twt_flows[i].trigger ? "true" : "false");
479479
shell_fprintf(sh, SHELL_NORMAL, "TWT announce: %s\n",
480480
config.twt_flows[i].announce ? "true" : "false");
481-
shell_fprintf(sh, SHELL_NORMAL, "TWT wake interval: %d ms\n",
482-
config.twt_flows[i].twt_wake_interval_ms);
483-
shell_fprintf(sh, SHELL_NORMAL, "TWT interval: %d ms\n",
484-
config.twt_flows[i].twt_interval_ms);
481+
shell_fprintf(sh, SHELL_NORMAL, "TWT wake interval: %d us\n",
482+
config.twt_flows[i].twt_wake_interval);
483+
shell_fprintf(sh, SHELL_NORMAL, "TWT interval: %lld us\n",
484+
config.twt_flows[i].twt_interval);
485485
shell_fprintf(sh, SHELL_NORMAL, "========================\n");
486486
}
487487
}
@@ -599,9 +599,9 @@ static int cmd_wifi_twt_setup_quick(const struct shell *sh, size_t argc,
599599
params.setup.trigger = 1;
600600
params.setup.announce = 0;
601601

602-
if (!parse_number(sh, (long *)&params.setup.twt_wake_interval_ms, argv[idx++], 1, 255) ||
603-
!parse_number(sh, (long *)&params.setup.twt_interval_ms, argv[idx++], 1,
604-
WIFI_MAX_TWT_INTERVAL_MS))
602+
if (!parse_number(sh, (long *)&params.setup.twt_wake_interval, argv[idx++], 1, 255) ||
603+
!parse_number(sh, (long *)&params.setup.twt_interval, argv[idx++], 1,
604+
WIFI_MAX_TWT_INTERVAL_US))
605605
return -EINVAL;
606606

607607
if (net_mgmt(NET_REQUEST_WIFI_TWT, iface, &params, sizeof(params))) {
@@ -648,9 +648,9 @@ static int cmd_wifi_twt_setup(const struct shell *sh, size_t argc,
648648
!parse_number(sh, (long *)&params.setup.trigger, argv[idx++], 0, 1) ||
649649
!parse_number(sh, (long *)&params.setup.implicit, argv[idx++], 0, 1) ||
650650
!parse_number(sh, (long *)&params.setup.announce, argv[idx++], 0, 1) ||
651-
!parse_number(sh, (long *)&params.setup.twt_wake_interval_ms, argv[idx++], 1, 255) ||
652-
!parse_number(sh, (long *)&params.setup.twt_interval_ms, argv[idx++], 1,
653-
WIFI_MAX_TWT_INTERVAL_MS))
651+
!parse_number(sh, (long *)&params.setup.twt_wake_interval, argv[idx++], 1, 255) ||
652+
!parse_number(sh, (long *)&params.setup.twt_interval, argv[idx++], 1,
653+
WIFI_MAX_TWT_INTERVAL_US))
654654
return -EINVAL;
655655

656656
params.negotiation_type = neg_type;
@@ -849,13 +849,13 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_cmd_ap,
849849

850850
SHELL_STATIC_SUBCMD_SET_CREATE(wifi_twt_ops,
851851
SHELL_CMD(quick_setup, NULL, " Start a TWT flow with defaults:\n"
852-
"<twt_wake_interval_ms: 1-256ms> <twt_interval_ms: 1ms-2^32ms>\n",
852+
"<twt_wake_interval: 1-262144us> <twt_interval: 1us-2^64us>\n",
853853
cmd_wifi_twt_setup_quick),
854854
SHELL_CMD(setup, NULL, " Start a TWT flow:\n"
855855
"<negotiation_type, 0: Individual, 1: Broadcast, 2: Wake TBTT>\n"
856856
"<setup_cmd: 0: Request, 1: Suggest, 2: Demand>\n"
857857
"<dialog_token: 1-255> <flow_id: 1-255> <responder: 0/1> <trigger: 0/1> <implicit:0/1> "
858-
"<announce: 0/1> <twt_wake_interval_ms: 1-256ms> <twt_interval_ms: 1ms-2^32ms>\n",
858+
"<announce: 0/1> <twt_wake_interval: 1-262144us> <twt_interval: 1us-2^64us>\n",
859859
cmd_wifi_twt_setup),
860860
SHELL_CMD(teardown, NULL, " Teardown a TWT flow:\n"
861861
"<negotiation_type, 0: Individual, 1: Broadcast, 2: Wake TBTT>\n"

0 commit comments

Comments
 (0)