-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Modify btwt_setup usage #89294
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
Open
NXP-Liam-Li
wants to merge
2
commits into
zephyrproject-rtos:main
Choose a base branch
from
nxp-upstream:update_btwt_usage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Modify btwt_setup usage #89294
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1918,34 +1918,75 @@ static int cmd_wifi_btwt_setup(const struct shell *sh, size_t argc, char *argv[] | |
struct net_if *iface = get_iface(IFACE_TYPE_SAP, argc, argv); | ||
struct wifi_twt_params params = {0}; | ||
int idx = 1; | ||
long value; | ||
int ret = 0; | ||
int err = 0; | ||
|
||
context.sh = sh; | ||
|
||
params.btwt.sub_id = (uint16_t)shell_strtol(argv[idx++], 10, &ret); | ||
params.btwt.nominal_wake = (uint8_t)shell_strtol(argv[idx++], 10, &ret); | ||
params.btwt.max_sta_support = (uint8_t)shell_strtol(argv[idx++], 10, &ret); | ||
params.btwt.btwt_sta_wait = (uint8_t)shell_strtol(argv[idx++], 10, &err); | ||
if (err) { | ||
PR_ERROR("Parse btwt sta_wait (err %d)\n", err); | ||
return -EINVAL; | ||
} | ||
|
||
if (!parse_number(sh, &value, argv[idx++], NULL, 1, 0xFFFF)) { | ||
params.btwt.btwt_offset = (uint16_t)shell_strtol(argv[idx++], 10, &err); | ||
if (err) { | ||
PR_ERROR("Parse btwt offset (err %d)\n", err); | ||
return -EINVAL; | ||
} | ||
params.btwt.twt_mantissa = (uint16_t)value; | ||
|
||
params.btwt.twt_offset = (uint16_t)shell_strtol(argv[idx++], 10, &ret); | ||
params.btwt.btwt_li = (uint8_t)shell_strtol(argv[idx++], 10, &err); | ||
if (err) { | ||
PR_ERROR("Parse btwt_li (err %d)\n", err); | ||
return -EINVAL; | ||
} | ||
|
||
if (!parse_number(sh, &value, argv[idx++], NULL, 0, WIFI_MAX_TWT_EXPONENT)) { | ||
params.btwt.btwt_count = (uint8_t)shell_strtol(argv[idx++], 10, &err); | ||
if (err) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, the error status needs to be checked after every conversion call. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
PR_ERROR("Parse btwt count (err %d)\n", err); | ||
return -EINVAL; | ||
} | ||
params.btwt.twt_exponent = (uint8_t)value; | ||
|
||
params.btwt.sp_gap = (uint8_t)shell_strtol(argv[idx++], 10, &ret); | ||
if (params.btwt.btwt_count < 2 || params.btwt.btwt_count > 5) { | ||
PR_ERROR("Invalid broadcast twt count. Count rang: 2-5.\n"); | ||
return -EINVAL; | ||
} | ||
|
||
if (ret) { | ||
PR_ERROR("Invalid argument (ret %d)\n", ret); | ||
if (argc != 5 + params.btwt.btwt_count * 4) { | ||
PR_ERROR("Invalid number of broadcast parameters.\n"); | ||
return -EINVAL; | ||
} | ||
|
||
for (int i = 0; i < params.btwt.btwt_count; i++) { | ||
params.btwt.btwt_set_cfg[i].btwt_id | ||
= (uint8_t)shell_strtol(argv[idx++], 10, &err); | ||
if (err) { | ||
PR_ERROR("Parse btwt [%d] id (err %d)\n", i, err); | ||
return -EINVAL; | ||
} | ||
|
||
params.btwt.btwt_set_cfg[i].btwt_mantissa | ||
= (uint16_t)shell_strtol(argv[idx++], 10, &err); | ||
if (err) { | ||
PR_ERROR("Parse btwt [%d] mantissa (err %d)\n", i, err); | ||
return -EINVAL; | ||
} | ||
|
||
params.btwt.btwt_set_cfg[i].btwt_exponent | ||
= (uint8_t)shell_strtol(argv[idx++], 10, &err); | ||
if (err) { | ||
PR_ERROR("Parse btwt [%d] exponent (err %d)\n", i, err); | ||
return -EINVAL; | ||
} | ||
|
||
params.btwt.btwt_set_cfg[i].btwt_nominal_wake | ||
= (uint8_t)shell_strtol(argv[idx++], 10, &err); | ||
if (err) { | ||
PR_ERROR("Parse btwt [%d] nominal_wake (err %d)\n", i, err); | ||
return -EINVAL; | ||
} | ||
} | ||
|
||
|
||
if (net_mgmt(NET_REQUEST_WIFI_BTWT, iface, ¶ms, sizeof(params))) { | ||
PR_WARNING("Failed reason : %s\n", | ||
wifi_twt_get_err_code_str(params.fail_reason)); | ||
|
@@ -3855,11 +3896,14 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_twt_ops, | |
SHELL_CMD_ARG( | ||
btwt_setup, NULL, | ||
" Start a BTWT flow:\n" | ||
"<sub_id: Broadcast TWT AP config> <nominal_wake: 64-255> <max_sta_support>" | ||
"<twt_mantissa:0-sizeof(UINT16)> <twt_offset> <twt_exponent: 0-31> <sp_gap>.\n" | ||
"<sta_wait> <offset> <twtli> <session_num>: 2-5\n" | ||
"<id0> <mantissa0> <exponent0> <nominal_wake0>: 64-255\n" | ||
"<id1> <mantissa1> <exponent1> <nominal_wake1>: 64-255\n" | ||
"<idx> <mantissax> <exponentx> <nominal_wakex>: 64-255\n" | ||
" The total number of '0, 1, ..., x' is session_num\n" | ||
"[-i, --iface=<interface index>] : Interface index.\n", | ||
cmd_wifi_btwt_setup, | ||
8, 2), | ||
13, 2), | ||
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" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message is missing why this change is needed.
Also information about this change could be placed to migration guide
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Soft ap supports WIFI_BTWT_AGREEMENT_MAX BTWT sessions. The BTWT parameters for each session can be different.
The current usage can only set one set of parameters. All sessions follow this set of parameters.
Add enhance code to support setting different BTWT parameters for every sessions.
Also add this information in commit message.