Skip to content
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

drivers: nrf_wifi: Add check for wrong regulatory domain #241

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include "host_rpu_sys_if.h"

#define NRF_WIFI_FMAC_PARAMS_RECV_TIMEOUT 100 /* ms */

/**
* @brief Structure to hold per device context information for the UMAC IF layer.
*
Expand All @@ -29,6 +31,7 @@
struct nrf_wifi_off_raw_tx_fmac_dev_ctx {
enum nrf_wifi_cmd_status off_raw_tx_cmd_status;
bool off_raw_tx_cmd_done;
unsigned char country_code[NRF_WIFI_COUNTRY_CODE_LEN];
};

// extern struct nrf_wifi_off_raw_tx_fmac_dev_ctx *def_dev_ctx_off_raw_tx;
Expand Down
15 changes: 15 additions & 0 deletions drivers/nrf_wifi/fw_if/umac_if/src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx
#elif NRF70_RADIO_TEST
struct nrf_wifi_reg *get_reg_event = NULL;
struct nrf_wifi_event_regulatory_change *reg_change_event = NULL;
#elif NRF70_OFFLOADED_RAW_TX
struct nrf_wifi_off_raw_tx_fmac_dev_ctx *def_dev_ctx_off_raw_tx = NULL;
struct nrf_wifi_reg *get_reg_event = NULL;
#endif /* !NRF70_RADIO_TEST && !NRF70_OFFLOADED_RAW_TX */
unsigned char if_id = 0;
unsigned int event_num = 0;
Expand All @@ -170,6 +173,10 @@ static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx

#endif /* !NRF70_RADIO_TEST && !NRF70_OFFLOADED_RAW_TX */

#ifdef NRF70_OFFLOADED_RAW_TX
def_dev_ctx_off_raw_tx = wifi_dev_priv(fmac_dev_ctx);
#endif /* NRF70_OFFLOADED_RAW_TX */

umac_hdr = event_data;
if_id = umac_hdr->ids.wdev_id;
event_num = umac_hdr->cmd_evnt;
Expand Down Expand Up @@ -219,6 +226,14 @@ static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx
sizeof(get_reg_event->nrf_wifi_alpha2));
fmac_dev_ctx->alpha2_valid = true;
#endif /* NRF70_RADIO_TEST */
#ifdef NRF70_OFFLOADED_RAW_TX
get_reg_event = (struct nrf_wifi_reg *)event_data;

nrf_wifi_osal_mem_cpy(&def_dev_ctx_off_raw_tx->country_code,
&get_reg_event->nrf_wifi_alpha2,
sizeof(get_reg_event->nrf_wifi_alpha2));
fmac_dev_ctx->alpha2_valid = true;
#endif /* NRF70_OFFLOADED_RAW_TX */
break;
case NRF_WIFI_UMAC_EVENT_REG_CHANGE:
#ifdef NRF70_STA_MODE
Expand Down
2 changes: 1 addition & 1 deletion drivers/nrf_wifi/fw_if/umac_if/src/fmac_api_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ enum nrf_wifi_status nrf_wifi_fmac_set_reg(struct nrf_wifi_fmac_dev_ctx *fmac_de

return status;
}
#endif /* !NRF70_OFFLOADED_RAW_TX */

enum nrf_wifi_status nrf_wifi_fmac_get_reg(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
struct nrf_wifi_fmac_reg_info *reg_info)
Expand Down Expand Up @@ -911,7 +912,6 @@ enum nrf_wifi_status nrf_wifi_fmac_get_reg(struct nrf_wifi_fmac_dev_ctx *fmac_de
}
return status;
}
#endif

int nrf_wifi_phy_rf_params_init(struct nrf_wifi_phy_rf_params *prf,
unsigned int package_info,
Expand Down
21 changes: 19 additions & 2 deletions drivers/nrf_wifi/fw_if/umac_if/src/offload_raw_tx/fmac_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ enum nrf_wifi_status nrf_wifi_fmac_off_raw_tx_conf(struct nrf_wifi_fmac_dev_ctx
{
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
struct nrf_wifi_off_raw_tx_fmac_dev_ctx *def_dev_ctx_off_raw_tx;
struct nrf_wifi_fmac_reg_info reg_domain_info = {0};
unsigned char count = 0;

if (!fmac_dev_ctx) {
Expand Down Expand Up @@ -240,14 +241,30 @@ enum nrf_wifi_status nrf_wifi_fmac_off_raw_tx_conf(struct nrf_wifi_fmac_dev_ctx
nrf_wifi_osal_sleep_ms(1);
count++;
} while ((def_dev_ctx_off_raw_tx->off_raw_tx_cmd_done == true) &&
(count < NRF_WIFI_FMAC_STATS_RECV_TIMEOUT));
(count < NRF_WIFI_FMAC_PARAMS_RECV_TIMEOUT));

if (count == NRF_WIFI_FMAC_STATS_RECV_TIMEOUT) {
if (count == NRF_WIFI_FMAC_PARAMS_RECV_TIMEOUT) {
nrf_wifi_osal_log_err("%s: Timed out",
__func__);
goto out;
}

if (def_dev_ctx_off_raw_tx->off_raw_tx_cmd_status != NRF_WIFI_UMAC_CMD_SUCCESS) {
status = nrf_wifi_fmac_get_reg(fmac_dev_ctx, &reg_domain_info);
if (status != NRF_WIFI_STATUS_SUCCESS) {
nrf_wifi_osal_log_err("%s: Failed to get regulatory domain",
__func__);
goto out;
}

nrf_wifi_osal_log_err("%s: Failed to set configuration, check config against %.2s regulatory domain rules",
__func__,
def_dev_ctx_off_raw_tx->country_code);
status = NRF_WIFI_STATUS_FAIL;
goto out;
}

status = NRF_WIFI_STATUS_SUCCESS;
out:
return status;
}
Expand Down