Skip to content

Commit

Permalink
drivers: wifi: Set RTS threshold
Browse files Browse the repository at this point in the history
[SHEL-2307] Configure RTS threshold to firmware.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
  • Loading branch information
ajayparida authored and rlubos committed Apr 26, 2024
1 parent 9ed228b commit 45563e9
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ This section provides detailed lists of changes by :ref:`driver <drivers>`.
Wi-Fi drivers
-------------

|no_changes_yet_note|
* Removed support for setting RTS threshold through ``wifi_util`` command.

Libraries
=========
Expand Down
2 changes: 2 additions & 0 deletions drivers/wifi/nrf700x/inc/wifi_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,6 @@ int nrf_wifi_filter(const struct device *dev,
struct wifi_filter_info *filter);
#endif /* CONFIG_NRF700X_RAW_DATA_RX || CONFIG_NRF700X_PROMISC_DATA_RX */

int nrf_wifi_set_rts_threshold(const struct device *dev,
unsigned int rts_threshold);
#endif /* __ZEPHYR_WIFI_MGMT_H__ */
1 change: 1 addition & 0 deletions drivers/wifi/nrf700x/src/fmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ static struct wifi_mgmt_ops nrf_wifi_mgmt_ops = {
.set_twt = nrf_wifi_set_twt,
.reg_domain = nrf_wifi_reg_domain,
.get_power_save_config = nrf_wifi_get_power_save_config,
.set_rts_threshold = nrf_wifi_set_rts_threshold,
#endif /* CONFIG_NRF700X_STA_MODE */
#ifdef CONFIG_NRF700X_SYSTEM_WITH_RAW_MODES
.mode = nrf_wifi_mode,
Expand Down
65 changes: 65 additions & 0 deletions drivers/wifi/nrf700x/src/wifi_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -948,3 +948,68 @@ int nrf_wifi_filter(const struct device *dev,
return ret;
}
#endif /* CONFIG_NRF700X_RAW_DATA_RX || CONFIG_NRF700X_PROMISC_DATA_RX */

int nrf_wifi_set_rts_threshold(const struct device *dev,
unsigned int rts_threshold)
{
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
struct nrf_wifi_umac_set_wiphy_info wiphy_info;
int ret = -1;

if (!dev) {
LOG_ERR("%s: dev is NULL", __func__);
return ret;
}

vif_ctx_zep = dev->data;

if (!vif_ctx_zep) {
LOG_ERR("%s: vif_ctx_zep is NULL", __func__);
return ret;
}

rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep;

if (!rpu_ctx_zep) {
LOG_ERR("%s: rpu_ctx_zep is NULL", __func__);
return ret;
}


if (!rpu_ctx_zep->rpu_ctx) {
LOG_ERR("%s: RPU context not initialized", __func__);
return ret;
}

if ((int)rts_threshold < -1) {
/* 0 or any positive value is passed to f/w.
* For RTS off, -1 is passed to f/w.
* All other negative values considered as invalid.
*/
LOG_ERR("%s: Invalid threshold value : %d", __func__, (int)rts_threshold);
return ret;
}

memset(&wiphy_info, 0, sizeof(struct nrf_wifi_umac_set_wiphy_info));

wiphy_info.rts_threshold = (int)rts_threshold;

k_mutex_lock(&vif_ctx_zep->vif_lock, K_FOREVER);

status = nrf_wifi_fmac_set_wiphy_params(rpu_ctx_zep->rpu_ctx,
vif_ctx_zep->vif_idx,
&wiphy_info);

if (status != NRF_WIFI_STATUS_SUCCESS) {
LOG_ERR("%s: Configuring rts threshold failed\n", __func__);
goto out;
}

ret = 0;
out:
k_mutex_unlock(&vif_ctx_zep->vif_lock);

return ret;
}
46 changes: 0 additions & 46 deletions drivers/wifi/nrf700x/src/wifi_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,41 +178,6 @@ static int nrf_wifi_util_set_he_ltf_gi(const struct shell *shell,
return 0;
}


static int nrf_wifi_util_set_rts_threshold(const struct shell *shell,
size_t argc,
const char *argv[])
{
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
char *ptr = NULL;
unsigned long val = 0;
struct nrf_wifi_umac_set_wiphy_info wiphy_info;

memset(&wiphy_info, 0, sizeof(struct nrf_wifi_umac_set_wiphy_info));

val = strtoul(argv[1], &ptr, 10);

if (ctx->conf_params.rts_threshold != val) {

wiphy_info.rts_threshold = val;

status = nrf_wifi_fmac_set_wiphy_params(ctx->rpu_ctx,
0,
&wiphy_info);

if (status != NRF_WIFI_STATUS_SUCCESS) {
shell_fprintf(shell,
SHELL_ERROR,
"Programming threshold failed\n");
return -ENOEXEC;
}

ctx->conf_params.rts_threshold = val;
}

return 0;
}

#ifdef CONFIG_NRF700X_STA_MODE
static int nrf_wifi_util_set_uapsd_queue(const struct shell *shell,
size_t argc,
Expand Down Expand Up @@ -283,11 +248,6 @@ static int nrf_wifi_util_show_cfg(const struct shell *shell,
"set_he_ltf_gi = %d\n",
conf_params->set_he_ltf_gi);

shell_fprintf(shell,
SHELL_INFO,
"rts_threshold = %d\n",
conf_params->rts_threshold);

shell_fprintf(shell,
SHELL_INFO,
"uapsd_queue = %d\n",
Expand Down Expand Up @@ -916,12 +876,6 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
nrf_wifi_util_set_he_ltf_gi,
2,
0),
SHELL_CMD_ARG(rts_threshold,
NULL,
"<val> - Value > 0",
nrf_wifi_util_set_rts_threshold,
2,
0),
#ifdef CONFIG_NRF700X_STA_MODE
SHELL_CMD_ARG(uapsd_queue,
NULL,
Expand Down
13 changes: 13 additions & 0 deletions modules/hostap/src/supp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,19 @@ int z_wpa_supplicant_channel(const struct device *dev,
return wifi_mgmt_api->channel(dev, channel);
}

int z_wpa_supplicant_set_rts_threshold(const struct device *dev,
unsigned int rts_threshold)
{
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_mgmt_api(dev);

if (!wifi_mgmt_api || !wifi_mgmt_api->set_rts_threshold) {
wpa_printf(MSG_ERROR, "Set RTS not supported");
return -ENOTSUP;
}

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

#ifdef CONFIG_AP
int z_wpa_supplicant_ap_enable(const struct device *dev,
struct wifi_connect_req_params *params)
Expand Down
10 changes: 10 additions & 0 deletions modules/hostap/src/supp_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ int z_wpa_supplicant_filter(const struct device *dev,
int z_wpa_supplicant_channel(const struct device *dev,
struct wifi_channel_info *channel);

/**
* @brief Set Wi-Fi RTS threshold
*
* @param dev Wi-Fi interface handle to use
* @param rts_threshold RTS threshold to set
* @return 0 for OK; -1 for ERROR
*/
int z_wpa_supplicant_set_rts_threshold(const struct device *dev,
unsigned int rts_threshold);

#ifdef CONFIG_AP
/**
* @brief Set Wi-Fi AP configuration
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 @@ -83,6 +83,7 @@ static const struct wifi_mgmt_ops wpa_supp_ops = {
.mode = z_wpa_supplicant_mode,
.filter = z_wpa_supplicant_filter,
.channel = z_wpa_supplicant_channel,
.set_rts_threshold = z_wpa_supplicant_set_rts_threshold,
#ifdef CONFIG_AP
.ap_enable = z_wpa_supplicant_ap_enable,
.ap_disable = z_wpa_supplicant_ap_disable,
Expand Down

0 comments on commit 45563e9

Please sign in to comment.