Skip to content

Commit d22026c

Browse files
Qingling-Wukartben
authored andcommitted
net: wifi: hostap: add set RTS threshold command support
Add set RTS threshold command support for sta and sap. Signed-off-by: Qingling Wu <[email protected]>
1 parent 4553a21 commit d22026c

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

include/zephyr/net/wifi_mgmt.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ enum net_request_wifi_cmd {
7575
NET_REQUEST_WIFI_CMD_AP_ENABLE,
7676
/** Disable AP mode */
7777
NET_REQUEST_WIFI_CMD_AP_DISABLE,
78+
/** Set AP RTS threshold */
79+
NET_REQUEST_WIFI_CMD_AP_RTS_THRESHOLD,
7880
/** Get interface status */
7981
NET_REQUEST_WIFI_CMD_IFACE_STATUS,
8082
/** Set or get 11k status */
@@ -168,6 +170,12 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_ENABLE);
168170

169171
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_DISABLE);
170172

173+
/** Request a Wi-Fi RTS threshold */
174+
#define NET_REQUEST_WIFI_AP_RTS_THRESHOLD \
175+
(_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_AP_RTS_THRESHOLD)
176+
177+
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_RTS_THRESHOLD);
178+
171179
/** Request a Wi-Fi network interface status */
172180
#define NET_REQUEST_WIFI_IFACE_STATUS \
173181
(_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_IFACE_STATUS)

modules/hostap/src/supp_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static const struct wifi_mgmt_ops mgmt_ap_ops = {
113113
.dpp_dispatch = hapd_dpp_dispatch,
114114
#endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP */
115115
.ap_config_params = supplicant_ap_config_params,
116+
.set_rts_threshold = supplicant_set_rts_threshold,
116117
#ifdef CONFIG_WIFI_NM_HOSTAPD_CRYPTO_ENTERPRISE
117118
.enterprise_creds = supplicant_add_enterprise_creds,
118119
#endif

subsys/net/l2/wifi/wifi_mgmt.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,26 @@ static int wifi_ap_config_params(uint32_t mgmt_request, struct net_if *iface,
690690

691691
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_CONFIG_PARAM, wifi_ap_config_params);
692692

693+
static int wifi_ap_set_rts_threshold(uint32_t mgmt_request, struct net_if *iface,
694+
void *data, size_t len)
695+
{
696+
const struct device *dev = net_if_get_device(iface);
697+
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_api(iface);
698+
unsigned int *rts_threshold = data;
699+
700+
if (wifi_mgmt_api == NULL || wifi_mgmt_api->set_rts_threshold == NULL) {
701+
return -ENOTSUP;
702+
}
703+
704+
if (data == NULL || len != sizeof(*rts_threshold)) {
705+
return -EINVAL;
706+
}
707+
708+
return wifi_mgmt_api->set_rts_threshold(dev, *rts_threshold);
709+
}
710+
711+
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_RTS_THRESHOLD, wifi_ap_set_rts_threshold);
712+
693713
static int wifi_iface_status(uint32_t mgmt_request, struct net_if *iface,
694714
void *data, size_t len)
695715
{

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,6 +2112,40 @@ static int cmd_wifi_ap_config_params(const struct shell *sh, size_t argc,
21122112
return 0;
21132113
}
21142114

2115+
static int cmd_wifi_ap_set_rts_threshold(const struct shell *sh, size_t argc, char *argv[])
2116+
{
2117+
struct net_if *iface = net_if_get_wifi_sap();
2118+
unsigned int rts_threshold = -1; /* Default value if user supplies "off" argument */
2119+
int err = 0;
2120+
2121+
context.sh = sh;
2122+
2123+
if (strcmp(argv[1], "off") != 0) {
2124+
long rts_val = shell_strtol(argv[1], 10, &err);
2125+
2126+
if (err) {
2127+
shell_error(sh, "Unable to parse input (err %d)", err);
2128+
return err;
2129+
}
2130+
2131+
rts_threshold = (unsigned int)rts_val;
2132+
}
2133+
2134+
if (net_mgmt(NET_REQUEST_WIFI_AP_RTS_THRESHOLD, iface,
2135+
&rts_threshold, sizeof(rts_threshold))) {
2136+
shell_fprintf(sh, SHELL_WARNING,
2137+
"Setting RTS threshold failed.\n");
2138+
return -ENOEXEC;
2139+
}
2140+
2141+
if ((int)rts_threshold >= 0)
2142+
shell_fprintf(sh, SHELL_NORMAL, "RTS threshold: %d\n", rts_threshold);
2143+
else
2144+
shell_fprintf(sh, SHELL_NORMAL, "RTS threshold is off\n");
2145+
2146+
return 0;
2147+
}
2148+
21152149
static int cmd_wifi_reg_domain(const struct shell *sh, size_t argc,
21162150
char *argv[])
21172151
{
@@ -3426,6 +3460,12 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
34263460
"[pin] Only applicable for set.\n",
34273461
cmd_wifi_ap_wps_pin, 1, 1),
34283462
SHELL_CMD_ARG(status, NULL, "Status of Wi-Fi SAP\n", cmd_wifi_ap_status, 1, 0),
3463+
SHELL_CMD_ARG(rts_threshold,
3464+
NULL,
3465+
"<rts_threshold: rts threshold/off>.\n",
3466+
cmd_wifi_ap_set_rts_threshold,
3467+
2,
3468+
0),
34293469
SHELL_SUBCMD_SET_END);
34303470

34313471
SHELL_SUBCMD_ADD((wifi), ap, &wifi_cmd_ap,

0 commit comments

Comments
 (0)