Skip to content

Commit

Permalink
net: wifi: hostap: add set RTS threshold command support
Browse files Browse the repository at this point in the history
Add set RTS threshold command support for sta and sap.

(cherry picked from commit d22026c)

Original-Signed-off-by: Qingling Wu <qingling.wu@nxp.com>
GitOrigin-RevId: d22026c
Cr-Build-Id: 8728219973957200769
Cr-Build-Url: https://cr-buildbucket.appspot.com/build/8728219973957200769
Copybot-Job-Name: zephyr-main-copybot-downstream
Change-Id: I0cde216abf1c21298b0a792eda65d2b34a79c2bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/6104907
Commit-Queue: Jonathon Murphy <jpmurphy@google.com>
Reviewed-by: Dawid Niedźwiecki <dawidn@google.com>
Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
Tested-by: Dawid Niedźwiecki <dawidn@google.com>
  • Loading branch information
Qingling Wu authored and Chromeos LUCI committed Dec 20, 2024
1 parent ec57baa commit 626baa6
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/zephyr/net/wifi_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ enum net_request_wifi_cmd {
NET_REQUEST_WIFI_CMD_AP_ENABLE,
/** Disable AP mode */
NET_REQUEST_WIFI_CMD_AP_DISABLE,
/** Set AP RTS threshold */
NET_REQUEST_WIFI_CMD_AP_RTS_THRESHOLD,
/** Get interface status */
NET_REQUEST_WIFI_CMD_IFACE_STATUS,
/** Set or get 11k status */
Expand Down Expand Up @@ -168,6 +170,12 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_ENABLE);

NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_DISABLE);

/** Request a Wi-Fi RTS threshold */
#define NET_REQUEST_WIFI_AP_RTS_THRESHOLD \
(_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_AP_RTS_THRESHOLD)

NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_RTS_THRESHOLD);

/** Request a Wi-Fi network interface status */
#define NET_REQUEST_WIFI_IFACE_STATUS \
(_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_IFACE_STATUS)
Expand Down
1 change: 1 addition & 0 deletions modules/hostap/src/supp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ static const struct wifi_mgmt_ops mgmt_ap_ops = {
.dpp_dispatch = hapd_dpp_dispatch,
#endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP */
.ap_config_params = supplicant_ap_config_params,
.set_rts_threshold = supplicant_set_rts_threshold,
#ifdef CONFIG_WIFI_NM_HOSTAPD_CRYPTO_ENTERPRISE
.enterprise_creds = supplicant_add_enterprise_creds,
#endif
Expand Down
20 changes: 20 additions & 0 deletions subsys/net/l2/wifi/wifi_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,26 @@ static int wifi_ap_config_params(uint32_t mgmt_request, struct net_if *iface,

NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_CONFIG_PARAM, wifi_ap_config_params);

static int wifi_ap_set_rts_threshold(uint32_t mgmt_request, struct net_if *iface,
void *data, size_t len)
{
const struct device *dev = net_if_get_device(iface);
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_api(iface);
unsigned int *rts_threshold = data;

if (wifi_mgmt_api == NULL || wifi_mgmt_api->set_rts_threshold == NULL) {
return -ENOTSUP;
}

if (data == NULL || len != sizeof(*rts_threshold)) {
return -EINVAL;
}

return wifi_mgmt_api->set_rts_threshold(dev, *rts_threshold);
}

NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_RTS_THRESHOLD, wifi_ap_set_rts_threshold);

static int wifi_iface_status(uint32_t mgmt_request, struct net_if *iface,
void *data, size_t len)
{
Expand Down
40 changes: 40 additions & 0 deletions subsys/net/l2/wifi/wifi_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,40 @@ static int cmd_wifi_ap_config_params(const struct shell *sh, size_t argc,
return 0;
}

static int cmd_wifi_ap_set_rts_threshold(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_wifi_sap();
unsigned int rts_threshold = -1; /* Default value if user supplies "off" argument */
int err = 0;

context.sh = sh;

if (strcmp(argv[1], "off") != 0) {
long rts_val = shell_strtol(argv[1], 10, &err);

if (err) {
shell_error(sh, "Unable to parse input (err %d)", err);
return err;
}

rts_threshold = (unsigned int)rts_val;
}

if (net_mgmt(NET_REQUEST_WIFI_AP_RTS_THRESHOLD, iface,
&rts_threshold, sizeof(rts_threshold))) {
shell_fprintf(sh, SHELL_WARNING,
"Setting RTS threshold failed.\n");
return -ENOEXEC;
}

if ((int)rts_threshold >= 0)
shell_fprintf(sh, SHELL_NORMAL, "RTS threshold: %d\n", rts_threshold);
else
shell_fprintf(sh, SHELL_NORMAL, "RTS threshold is off\n");

return 0;
}

static int cmd_wifi_reg_domain(const struct shell *sh, size_t argc,
char *argv[])
{
Expand Down Expand Up @@ -3426,6 +3460,12 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
"[pin] Only applicable for set.\n",
cmd_wifi_ap_wps_pin, 1, 1),
SHELL_CMD_ARG(status, NULL, "Status of Wi-Fi SAP\n", cmd_wifi_ap_status, 1, 0),
SHELL_CMD_ARG(rts_threshold,
NULL,
"<rts_threshold: rts threshold/off>.\n",
cmd_wifi_ap_set_rts_threshold,
2,
0),
SHELL_SUBCMD_SET_END);

SHELL_SUBCMD_ADD((wifi), ap, &wifi_cmd_ap,
Expand Down

0 comments on commit 626baa6

Please sign in to comment.