Skip to content

Commit fc959fc

Browse files
ajayparidanashif
authored andcommitted
net: shell: Early wake up for TWT power save
Provision of configurable parameter for generating unblock event ahead of TWT slot. Host application depending upon latencies can configure this to wakeup rpu ahead of the TWT slot. Signed-off-by: Ajay Parida <[email protected]>
1 parent e021ccf commit fc959fc

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

include/zephyr/net/wifi_mgmt.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,12 @@ struct wifi_twt_params {
491491
bool announce;
492492
/** Wake up time */
493493
uint32_t twt_wake_interval;
494+
/* Wake ahead notification is sent earlier than
495+
* TWT Service period (SP) start based on this duration.
496+
* This should give applications ample time to
497+
* prepare the data before TWT SP starts.
498+
*/
499+
uint32_t twt_wake_ahead_duration;
494500
} setup;
495501
/** Teardown specific parameters */
496502
struct {
@@ -507,6 +513,7 @@ struct wifi_twt_params {
507513
#define WIFI_MAX_TWT_INTERVAL_US (LONG_MAX - 1)
508514
/* 256 (u8) * 1TU */
509515
#define WIFI_MAX_TWT_WAKE_INTERVAL_US 262144
516+
#define WIFI_MAX_TWT_WAKE_AHEAD_DURATION_US (LONG_MAX - 1)
510517

511518
/** Wi-Fi TWT flow information */
512519
struct wifi_twt_flow_info {
@@ -528,6 +535,8 @@ struct wifi_twt_flow_info {
528535
bool announce;
529536
/** Wake up time */
530537
uint32_t twt_wake_interval;
538+
/* wake ahead duration */
539+
uint32_t twt_wake_ahead_duration;
531540
};
532541

533542
/** Wi-Fi power save configuration */

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,9 @@ static int cmd_wifi_ps(const struct shell *sh, size_t argc, char *argv[])
887887
config.twt_flows[i].trigger,
888888
config.twt_flows[i].twt_wake_interval,
889889
config.twt_flows[i].twt_interval);
890+
shell_fprintf(context.sh, SHELL_NORMAL,
891+
"TWT Wake ahead duration : %d us\n",
892+
config.twt_flows[i].twt_wake_ahead_duration);
890893
}
891894
}
892895
return 0;
@@ -1045,7 +1048,7 @@ static int cmd_wifi_twt_setup(const struct shell *sh, size_t argc,
10451048

10461049
context.sh = sh;
10471050

1048-
if (argc != 11) {
1051+
if (argc != 12) {
10491052
shell_fprintf(sh, SHELL_WARNING, "Invalid number of arguments\n");
10501053
shell_help(sh);
10511054
return -ENOEXEC;
@@ -1105,6 +1108,11 @@ static int cmd_wifi_twt_setup(const struct shell *sh, size_t argc,
11051108
}
11061109
params.setup.twt_interval = (uint64_t)value;
11071110

1111+
if (!parse_number(sh, &value, argv[idx++], 0, WIFI_MAX_TWT_WAKE_AHEAD_DURATION_US)) {
1112+
return -EINVAL;
1113+
}
1114+
params.setup.twt_wake_ahead_duration = (uint32_t)value;
1115+
11081116
if (net_mgmt(NET_REQUEST_WIFI_TWT, iface, &params, sizeof(params))) {
11091117
shell_fprintf(sh, SHELL_WARNING, "%s with %s failed. reason : %s\n",
11101118
wifi_twt_operation_txt(params.operation),
@@ -1798,9 +1806,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_twt_ops,
17981806
"<negotiation_type, 0: Individual, 1: Broadcast, 2: Wake TBTT>\n"
17991807
"<setup_cmd: 0: Request, 1: Suggest, 2: Demand>\n"
18001808
"<dialog_token: 1-255> <flow_id: 0-7> <responder: 0/1> <trigger: 0/1> <implicit:0/1> "
1801-
"<announce: 0/1> <twt_wake_interval: 1-262144us> <twt_interval: 1us-2^31us>.\n",
1809+
"<announce: 0/1> <twt_wake_interval: 1-262144us> <twt_interval: 1us-2^31us>.\n"
1810+
"<twt_wake_ahead_duration>: 0us-2^31us>\n",
18021811
cmd_wifi_twt_setup,
1803-
11, 0),
1812+
12, 0),
18041813
SHELL_CMD_ARG(teardown, NULL, " Teardown a TWT flow:\n"
18051814
"<negotiation_type, 0: Individual, 1: Broadcast, 2: Wake TBTT>\n"
18061815
"<setup_cmd: 0: Request, 1: Suggest, 2: Demand>\n"

0 commit comments

Comments
 (0)