Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nrf fromlist] net: shell: Early wake up for TWT power save #1433

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions include/zephyr/net/wifi_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,12 @@ struct wifi_twt_params {
bool announce;
/** Wake up time */
uint32_t twt_wake_interval;
/* Wake ahead notification is sent earlier than
* TWT Service period (SP) start based on this duration.
* This should give applications ample time to
* prepare the data before TWT SP starts.
*/
uint32_t twt_wake_ahead_duration;
} setup;
/** Teardown specific parameters */
struct {
Expand All @@ -514,6 +520,7 @@ struct wifi_twt_params {
#define WIFI_MAX_TWT_INTERVAL_US (LONG_MAX - 1)
/* 256 (u8) * 1TU */
#define WIFI_MAX_TWT_WAKE_INTERVAL_US 262144
#define WIFI_MAX_TWT_WAKE_AHEAD_DURATION_US (LONG_MAX - 1)

/** Wi-Fi TWT flow information */
struct wifi_twt_flow_info {
Expand All @@ -535,6 +542,8 @@ struct wifi_twt_flow_info {
bool announce;
/** Wake up time */
uint32_t twt_wake_interval;
/* wake ahead duration */
uint32_t twt_wake_ahead_duration;
};

/** Wi-Fi power save configuration */
Expand Down
15 changes: 12 additions & 3 deletions subsys/net/l2/wifi/wifi_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,9 @@ static int cmd_wifi_ps(const struct shell *sh, size_t argc, char *argv[])
config.twt_flows[i].trigger,
config.twt_flows[i].twt_wake_interval,
config.twt_flows[i].twt_interval);
shell_fprintf(context.sh, SHELL_NORMAL,
"TWT Wake ahead duration : %d us\n",
config.twt_flows[i].twt_wake_ahead_duration);
}
}
return 0;
Expand Down Expand Up @@ -1133,7 +1136,7 @@ static int cmd_wifi_twt_setup(const struct shell *sh, size_t argc,

context.sh = sh;

if (argc != 11) {
if (argc != 12) {
shell_fprintf(sh, SHELL_WARNING, "Invalid number of arguments\n");
shell_help(sh);
return -ENOEXEC;
Expand Down Expand Up @@ -1193,6 +1196,11 @@ static int cmd_wifi_twt_setup(const struct shell *sh, size_t argc,
}
params.setup.twt_interval = (uint64_t)value;

if (!parse_number(sh, &value, argv[idx++], 0, WIFI_MAX_TWT_WAKE_AHEAD_DURATION_US)) {
return -EINVAL;
}
params.setup.twt_wake_ahead_duration = (uint32_t)value;

if (net_mgmt(NET_REQUEST_WIFI_TWT, iface, &params, sizeof(params))) {
shell_fprintf(sh, SHELL_WARNING, "%s with %s failed. reason : %s\n",
wifi_twt_operation_txt(params.operation),
Expand Down Expand Up @@ -1910,9 +1918,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_twt_ops,
"<negotiation_type, 0: Individual, 1: Broadcast, 2: Wake TBTT>\n"
"<setup_cmd: 0: Request, 1: Suggest, 2: Demand>\n"
"<dialog_token: 1-255> <flow_id: 0-7> <responder: 0/1> <trigger: 0/1> <implicit:0/1> "
"<announce: 0/1> <twt_wake_interval: 1-262144us> <twt_interval: 1us-2^31us>.\n",
"<announce: 0/1> <twt_wake_interval: 1-262144us> <twt_interval: 1us-2^31us>.\n"
"<twt_wake_ahead_duration>: 0us-2^31us>\n",
cmd_wifi_twt_setup,
11, 0),
12, 0),
SHELL_CMD_ARG(teardown, NULL, " Teardown a TWT flow:\n"
"<negotiation_type, 0: Individual, 1: Broadcast, 2: Wake TBTT>\n"
"<setup_cmd: 0: Request, 1: Suggest, 2: Demand>\n"
Expand Down
Loading