net: l2: wifi: Modify btwt_setup usage.
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. Usage: wifi twt btwt_setup <sta_wait> <offset> <twtli> <session_num> <id0> <mantissa0> <exponent0> <nominal_wake0> <id1> <mantissa1> <exponent1> <nominal_wake1> <idx> <mantissax> <exponentx> <nominal_wakex> The total number of '0, 1, ..., x' is session_num For example: wifi twt btwt_setup 0 0 0 2 0 112 10 128 1 32 10 64 Signed-off-by: Qiankun Li <qiankun.li@nxp.com>
This commit is contained in:
parent
8d2010e1e1
commit
448b787c82
2 changed files with 88 additions and 34 deletions
|
@ -702,6 +702,20 @@ struct wifi_ps_params {
|
||||||
enum wifi_ps_exit_strategy exit_strategy;
|
enum wifi_ps_exit_strategy exit_strategy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define WIFI_BTWT_AGREEMENT_MAX 5
|
||||||
|
|
||||||
|
/** @brief Wi-Fi broadcast TWT parameters */
|
||||||
|
struct wifi_btwt_params {
|
||||||
|
/** Broadcast TWT ID */
|
||||||
|
uint8_t btwt_id;
|
||||||
|
/** Broadcast TWT mantissa */
|
||||||
|
uint16_t btwt_mantissa;
|
||||||
|
/** Broadcast TWT exponent */
|
||||||
|
uint8_t btwt_exponent;
|
||||||
|
/** Broadcast TWT range */
|
||||||
|
uint8_t btwt_nominal_wake;
|
||||||
|
};
|
||||||
|
|
||||||
/** @brief Wi-Fi TWT parameters */
|
/** @brief Wi-Fi TWT parameters */
|
||||||
struct wifi_twt_params {
|
struct wifi_twt_params {
|
||||||
/** TWT operation, see enum wifi_twt_operation */
|
/** TWT operation, see enum wifi_twt_operation */
|
||||||
|
@ -748,20 +762,16 @@ struct wifi_twt_params {
|
||||||
} setup;
|
} setup;
|
||||||
/** Setup specific parameters */
|
/** Setup specific parameters */
|
||||||
struct {
|
struct {
|
||||||
/** Broadcast TWT AP config */
|
/** Broadcast TWT station wait time */
|
||||||
uint16_t sub_id;
|
uint8_t btwt_sta_wait;
|
||||||
/** Range 64-255 */
|
/** Broadcast TWT offset */
|
||||||
uint8_t nominal_wake;
|
uint16_t btwt_offset;
|
||||||
/** Max STA support */
|
/** In multiple of 4 beacon interval */
|
||||||
uint8_t max_sta_support;
|
uint8_t btwt_li;
|
||||||
/** TWT mantissa */
|
/** Broadcast TWT agreement count */
|
||||||
uint16_t twt_mantissa;
|
uint8_t btwt_count;
|
||||||
/** TWT offset */
|
/** Broadcast TWT agreement sets */
|
||||||
uint16_t twt_offset;
|
struct wifi_btwt_params btwt_set_cfg[WIFI_BTWT_AGREEMENT_MAX];
|
||||||
/** TWT exponent */
|
|
||||||
uint8_t twt_exponent;
|
|
||||||
/** SP gap */
|
|
||||||
uint8_t sp_gap;
|
|
||||||
} btwt;
|
} btwt;
|
||||||
/** Teardown specific parameters */
|
/** Teardown specific parameters */
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -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 net_if *iface = get_iface(IFACE_TYPE_SAP, argc, argv);
|
||||||
struct wifi_twt_params params = {0};
|
struct wifi_twt_params params = {0};
|
||||||
int idx = 1;
|
int idx = 1;
|
||||||
long value;
|
int err = 0;
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
context.sh = sh;
|
context.sh = sh;
|
||||||
|
|
||||||
params.btwt.sub_id = (uint16_t)shell_strtol(argv[idx++], 10, &ret);
|
params.btwt.btwt_sta_wait = (uint8_t)shell_strtol(argv[idx++], 10, &err);
|
||||||
params.btwt.nominal_wake = (uint8_t)shell_strtol(argv[idx++], 10, &ret);
|
if (err) {
|
||||||
params.btwt.max_sta_support = (uint8_t)shell_strtol(argv[idx++], 10, &ret);
|
PR_ERROR("Parse btwt sta_wait (err %d)\n", err);
|
||||||
|
|
||||||
if (!parse_number(sh, &value, argv[idx++], NULL, 1, 0xFFFF)) {
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
params.btwt.twt_mantissa = (uint16_t)value;
|
|
||||||
|
|
||||||
params.btwt.twt_offset = (uint16_t)shell_strtol(argv[idx++], 10, &ret);
|
params.btwt.btwt_offset = (uint16_t)shell_strtol(argv[idx++], 10, &err);
|
||||||
|
if (err) {
|
||||||
if (!parse_number(sh, &value, argv[idx++], NULL, 0, WIFI_MAX_TWT_EXPONENT)) {
|
PR_ERROR("Parse btwt offset (err %d)\n", err);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
params.btwt.twt_exponent = (uint8_t)value;
|
|
||||||
|
|
||||||
params.btwt.sp_gap = (uint8_t)shell_strtol(argv[idx++], 10, &ret);
|
params.btwt.btwt_li = (uint8_t)shell_strtol(argv[idx++], 10, &err);
|
||||||
|
if (err) {
|
||||||
if (ret) {
|
PR_ERROR("Parse btwt_li (err %d)\n", err);
|
||||||
PR_ERROR("Invalid argument (ret %d)\n", ret);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params.btwt.btwt_count = (uint8_t)shell_strtol(argv[idx++], 10, &err);
|
||||||
|
if (err) {
|
||||||
|
PR_ERROR("Parse btwt count (err %d)\n", err);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 (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))) {
|
if (net_mgmt(NET_REQUEST_WIFI_BTWT, iface, ¶ms, sizeof(params))) {
|
||||||
PR_WARNING("Failed reason : %s\n",
|
PR_WARNING("Failed reason : %s\n",
|
||||||
wifi_twt_get_err_code_str(params.fail_reason));
|
wifi_twt_get_err_code_str(params.fail_reason));
|
||||||
|
@ -3855,11 +3896,14 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_twt_ops,
|
||||||
SHELL_CMD_ARG(
|
SHELL_CMD_ARG(
|
||||||
btwt_setup, NULL,
|
btwt_setup, NULL,
|
||||||
" Start a BTWT flow:\n"
|
" Start a BTWT flow:\n"
|
||||||
"<sub_id: Broadcast TWT AP config> <nominal_wake: 64-255> <max_sta_support>"
|
"<sta_wait> <offset> <twtli> <session_num>: 2-5\n"
|
||||||
"<twt_mantissa:0-sizeof(UINT16)> <twt_offset> <twt_exponent: 0-31> <sp_gap>.\n"
|
"<id0> <mantissa0> <exponent0> <nominal_wake0>: 64-255\n"
|
||||||
"[-i, --iface=<interface index>] : Interface index.\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,
|
cmd_wifi_btwt_setup,
|
||||||
8, 2),
|
13, 2),
|
||||||
SHELL_CMD_ARG(teardown, NULL, " Teardown a TWT flow:\n"
|
SHELL_CMD_ARG(teardown, NULL, " Teardown a TWT flow:\n"
|
||||||
"<negotiation_type, 0: Individual, 1: Broadcast, 2: Wake TBTT>\n"
|
"<negotiation_type, 0: Individual, 1: Broadcast, 2: Wake TBTT>\n"
|
||||||
"<setup_cmd: 0: Request, 1: Suggest, 2: Demand>\n"
|
"<setup_cmd: 0: Request, 1: Suggest, 2: Demand>\n"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue