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

Iot ncs main #16097

Closed
wants to merge 6 commits into from
Closed
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
2 changes: 2 additions & 0 deletions drivers/wifi/nrf700x/inc/fmac_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ struct nrf_wifi_vif_ctx_zep {
#endif /* CONFIG_NRF700X_DATA_TX */
unsigned long rssi_record_timestamp_us;
signed short rssi;
unsigned char dms_id_map;
unsigned char dms_id_in_progress_map;
#endif /* CONFIG_NRF700X_STA_MODE */
#ifdef CONFIG_NRF700X_AP_MODE
int inactive_time_sec;
Expand Down
6 changes: 6 additions & 0 deletions drivers/wifi/nrf700x/inc/wifi_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,10 @@ int nrf_wifi_filter(const struct device *dev,

int nrf_wifi_set_rts_threshold(const struct device *dev,
unsigned int rts_threshold);
int nrf_wifi_req_dms(const struct device *dev,
struct wifi_dms_params *dms_params);

void nrf_wifi_event_proc_dms_zep(void *vif_ctx,
struct nrf_wifi_umac_cmd_config_dms *dms_accept_info,
unsigned int event_len);
#endif /* __ZEPHYR_WIFI_MGMT_H__ */
2 changes: 2 additions & 0 deletions drivers/wifi/nrf700x/src/fmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ static int nrf_wifi_drv_main_zep(const struct device *dev)
callbk_fns.event_get_wiphy = nrf_wifi_wpa_supp_event_get_wiphy;
callbk_fns.mgmt_rx_callbk_fn = nrf_wifi_wpa_supp_event_mgmt_rx_callbk_fn;
callbk_fns.get_conn_info_callbk_fn = nrf_wifi_supp_event_proc_get_conn_info;
callbk_fns.dms_callbk_fn = nrf_wifi_event_proc_dms_zep;
#endif /* CONFIG_NRF700X_STA_MODE */

rpu_drv_priv_zep.fmac_priv = nrf_wifi_fmac_init(&data_config,
Expand Down Expand Up @@ -839,6 +840,7 @@ static struct wifi_mgmt_ops nrf_wifi_mgmt_ops = {
.reg_domain = nrf_wifi_reg_domain,
.get_power_save_config = nrf_wifi_get_power_save_config,
.set_rts_threshold = nrf_wifi_set_rts_threshold,
.req_dms = nrf_wifi_req_dms,
#endif /* CONFIG_NRF700X_STA_MODE */
#ifdef CONFIG_NRF700X_SYSTEM_WITH_RAW_MODES
.mode = nrf_wifi_mode,
Expand Down
184 changes: 178 additions & 6 deletions drivers/wifi/nrf700x/src/wifi_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,20 +508,20 @@ int nrf_wifi_set_twt(const struct device *dev,
twt_params->flow_id >= WIFI_MAX_TWT_FLOWS) {
LOG_ERR("%s: Invalid flow id: %d",
__func__, twt_params->flow_id);
twt_params->fail_reason = WIFI_TWT_FAIL_INVALID_FLOW_ID;
twt_params->fail_reason = WIFI_FAIL_INVALID_FLOW_ID;
goto out;
}

switch (twt_params->operation) {
case WIFI_TWT_SETUP:
if (vif_ctx_zep->twt_flow_in_progress_map & BIT(twt_params->flow_id)) {
twt_params->fail_reason = WIFI_TWT_FAIL_OPERATION_IN_PROGRESS;
twt_params->fail_reason = WIFI_FAIL_OPERATION_IN_PROGRESS;
goto out;
}

if (twt_params->setup_cmd == WIFI_TWT_SETUP_CMD_REQUEST) {
if (vif_ctx_zep->twt_flows_map & BIT(twt_params->flow_id)) {
twt_params->fail_reason = WIFI_TWT_FAIL_FLOW_ALREADY_EXISTS;
twt_params->fail_reason = WIFI_FAIL_FLOW_ALREADY_EXISTS;
goto out;
}
}
Expand Down Expand Up @@ -559,7 +559,7 @@ int nrf_wifi_set_twt(const struct device *dev,

if (!twt_params->teardown.teardown_all) {
if (!(vif_ctx_zep->twt_flows_map & BIT(twt_params->flow_id))) {
twt_params->fail_reason = WIFI_TWT_FAIL_INVALID_FLOW_ID;
twt_params->fail_reason = WIFI_FAIL_INVALID_FLOW_ID;
goto out;
}
start_flow_id = twt_params->flow_id;
Expand Down Expand Up @@ -966,7 +966,6 @@ int nrf_wifi_set_rts_threshold(const struct device *dev,

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

vif_ctx_zep = dev->data;
Expand All @@ -983,7 +982,6 @@ int nrf_wifi_set_rts_threshold(const struct device *dev,
return ret;
}


if (!rpu_ctx_zep->rpu_ctx) {
LOG_ERR("%s: RPU context not initialized", __func__);
return ret;
Expand Down Expand Up @@ -1019,3 +1017,177 @@ int nrf_wifi_set_rts_threshold(const struct device *dev,

return ret;
}

static void nrf_wifi_dms_update_internal_state(struct nrf_wifi_vif_ctx_zep *vif_ctx_zep,
bool add, unsigned char dmsid)
{
if (add) {
vif_ctx_zep->dms_id_map |= BIT(dmsid);
vif_ctx_zep->dms_id_in_progress_map &= ~BIT(dmsid);
} else {
vif_ctx_zep->dms_id_map &= ~BIT(dmsid);
}
}

int nrf_wifi_req_dms(const struct device *dev,
struct wifi_dms_params *dms_params)
{
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_config_dms_info dms_info = {0};
int ret = -1;

if (!dev || !dms_params) {
LOG_ERR("%s: dev or dms_params 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;
}

k_mutex_lock(&vif_ctx_zep->vif_lock, K_FOREVER);
if (!rpu_ctx_zep->rpu_ctx) {
LOG_DBG("%s: RPU context not initialized", __func__);
goto out;
}

switch (dms_params->operation) {
case WIFI_DMS_REQ_ADD:
if (vif_ctx_zep->dms_id_in_progress_map & BIT(dms_params->dmsid)) {
dms_params->fail_reason = WIFI_FAIL_OPERATION_IN_PROGRESS;
goto out;
}

if (dms_params->operation == WIFI_DMS_REQ_ADD) {
if (vif_ctx_zep->dms_id_map & BIT(dms_params->dmsid)) {
dms_params->fail_reason = WIFI_FAIL_FLOW_ALREADY_EXISTS;
goto out;
}
}

dms_info.req_type = NRF_WIFI_DMS_REQ_ADD;
break;
case WIFI_DMS_REQ_REMOVE:
/* Time being don't check this.
* This needs event from UMAC (currently not-supported)
* Just pass the command to UMAC
*/
/*
if (!(vif_ctx_zep->dms_id_map & BIT(dms_params->dmsid))) {
dms_params->fail_reason = WIFI_FAIL_INVALID_DMS_ID;
goto out;
}*/
dms_info.req_type = NRF_WIFI_DMS_REQ_REMOVE;
break;
case WIFI_DMS_REQ_CHANGE:
/* Time being don't check this.
* This needs event from UMAC (currently not-supported)
* Just pass the command to UMAC
*/
/*
if (vif_ctx_zep->dms_id_in_progress_map & BIT(dms_params->dmsid)) {
dms_params->fail_reason = WIFI_FAIL_OPERATION_IN_PROGRESS;
goto out;
}
if (!(vif_ctx_zep->dms_id_map & BIT(dms_params->dmsid))) {
dms_params->fail_reason = WIFI_FAIL_INVALID_DMS_ID;
goto out;
}
*/
dms_info.req_type = NRF_WIFI_DMS_REQ_CHANGE;
break;
default:
LOG_ERR("Unknown DMS operation");
status = NRF_WIFI_STATUS_FAIL;
goto out;
}

dms_info.dmsid = dms_params->dmsid;
dms_info.dialog_token = dms_params->dialog_token;
dms_info.up = dms_params->tclas_elem.up;
dms_info.tclas_type = dms_params->tclas_elem.classifier_info.type;
dms_info.tclas_mask = dms_params->tclas_elem.classifier_info.mask;
dms_info.version = dms_params->tclas_elem.classifier_info.param_info.version;
dms_info.src_ip_addr = dms_params->tclas_elem.classifier_info.param_info.src_ip_addr;
dms_info.src_port = dms_params->tclas_elem.classifier_info.param_info.src_port;
dms_info.dest_ip_addr = dms_params->tclas_elem.classifier_info.param_info.dest_ip_addr;
dms_info.dest_port = dms_params->tclas_elem.classifier_info.param_info.dest_port;
dms_info.dscp = dms_params->tclas_elem.classifier_info.param_info.dscp;
dms_info.protocol = dms_params->tclas_elem.classifier_info.param_info.protocol;

status = nrf_wifi_fmac_req_dms(rpu_ctx_zep->rpu_ctx,
vif_ctx_zep->vif_idx,
&dms_info);

if (status != NRF_WIFI_STATUS_SUCCESS) {
LOG_ERR("%s: nrf_wifi_req_dms %s failed",
__func__,
(dms_params->operation == WIFI_DMS_REQ_ADD) ? "add" :
(dms_params->operation == WIFI_DMS_REQ_REMOVE) ? "remove" : "change");
goto out;
}

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

return ret;
}

void nrf_wifi_event_proc_dms_zep(void *vif_ctx,
struct nrf_wifi_umac_cmd_config_dms *dms_info,
unsigned int event_len)
{
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
struct wifi_dms_params dms_params;

if (!vif_ctx || !dms_info) {
return;
}

vif_ctx_zep = vif_ctx;

dms_params.dmsid = dms_info->info.dmsid;
dms_params.dialog_token = dms_info->info.dialog_token;
dms_params.tclas_elem.up = dms_info->info.up;
dms_params.tclas_elem.classifier_info.param_info.version = dms_info->info.version;
dms_params.tclas_elem.classifier_info.param_info.src_ip_addr = dms_info->info.src_ip_addr;
dms_params.tclas_elem.classifier_info.param_info.src_port = dms_info->info.src_port;
dms_params.tclas_elem.classifier_info.param_info.dest_ip_addr = dms_info->info.dest_ip_addr;
dms_params.tclas_elem.classifier_info.param_info.dest_port = dms_info->info.dest_port;
dms_params.tclas_elem.classifier_info.param_info.dscp = dms_info->info.dscp;
dms_params.tclas_elem.classifier_info.param_info.protocol = dms_info->info.protocol;
dms_params.tclas_elem.classifier_info.type = dms_info->info.tclas_type;
dms_params.tclas_elem.classifier_info.mask = dms_info->info.tclas_mask;

switch(dms_info->event_type) {
case NRF_WIFI_DMS_EVENT_ACCEPT:
dms_params.operation = WIFI_DMS_REQ_ADD;
if (dms_info->dms_resp_status == 0) {
nrf_wifi_dms_update_internal_state(vif_ctx_zep, true, dms_params.dmsid);
}
break;
case NRF_WIFI_DMS_EVENT_REJECT:
break;
case NRF_WIFI_DMS_EVENT_TERMINATE:
nrf_wifi_dms_update_internal_state(vif_ctx_zep, false, dms_params.dmsid);
break;
case NRF_WIFI_DMS_EVENT_INVALID:
LOG_ERR("Unknown DMS event received");
break;
}

wifi_mgmt_raise_dms_event(vif_ctx_zep->zep_net_if_ctx, &dms_params);
}
47 changes: 47 additions & 0 deletions drivers/wifi/nrf700x/src/wifi_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ static int nrf_wifi_util_show_cfg(const struct shell *shell,
"rate_flag = %d, rate_val = %d\n",
ctx->conf_params.tx_pkt_tput_mode,
ctx->conf_params.tx_pkt_rate);

shell_fprintf(shell,
SHELL_INFO,
"quiet_period = %u\n",
conf_params->quiet_period);
return 0;
}

Expand Down Expand Up @@ -884,6 +889,42 @@ static int nrf_wifi_util_trigger_rpu_recovery(const struct shell *shell,
}
#endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */

static int nrf_wifi_util_set_quiet_period(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;

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

if ((val < 0) || (val > UINT_MAX)) {
shell_fprintf(shell,
SHELL_ERROR,
"Invalid value(%lu).\n",
val);
shell_help(shell);
return -ENOEXEC;
}

status = nrf_wifi_fmac_set_quiet_period(ctx->rpu_ctx,
0,
(unsigned int)val);

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

ctx->conf_params.quiet_period = val;

return 0;
}

SHELL_STATIC_SUBCMD_SET_CREATE(
nrf_wifi_util_subcmds,
SHELL_CMD_ARG(he_ltf,
Expand Down Expand Up @@ -981,6 +1022,12 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
1,
0),
#endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */
SHELL_CMD_ARG(quiet_period,
NULL,
"<val> - Value > 0 seconds",
nrf_wifi_util_set_quiet_period,
2,
0),
SHELL_SUBCMD_SET_END);


Expand Down
5 changes: 5 additions & 0 deletions drivers/wifi/nrf700x/src/wpa_supp_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,11 @@ int nrf_wifi_wpa_supp_associate(void *if_priv, struct wpa_driver_associate_param

}

assoc_info.conn_type = NRF_WIFI_CONN_TYPE_OPEN;
if (!(params->key_mgmt_suite & WPA_KEY_MGMT_NONE)) {
assoc_info.conn_type = NRF_WIFI_CONN_TYPE_SECURE;
}

if (params->wpa_ie) {
assoc_info.wpa_ie.ie_len = params->wpa_ie_len;
memcpy(assoc_info.wpa_ie.ie, params->wpa_ie, params->wpa_ie_len);
Expand Down
35 changes: 35 additions & 0 deletions modules/hostap/src/supp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,41 @@ int z_wpa_supplicant_set_rts_threshold(const struct device *dev,
return wifi_mgmt_api->set_rts_threshold(dev, rts_threshold);
}

int z_wpa_supplicant_set_bss_max_idle_period(const struct device *dev,
unsigned short bss_max_idle_period)
{
struct wpa_supplicant *wpa_s;
int ret = 0;

k_mutex_lock(&wpa_supplicant_mutex, K_FOREVER);

wpa_s = get_wpa_s_handle(dev);

if (!wpa_s) {
wpa_printf(MSG_ERROR, "Interface %s not found", dev->name);
ret = -1;
goto out;
}

wpa_s->conf->bss_max_idle_period = bss_max_idle_period;
out:
k_mutex_unlock(&wpa_supplicant_mutex);
return ret;
}

int z_wpa_supplicant_req_dms(const struct device *dev,
struct wifi_dms_params *params)
{
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_mgmt_api(dev);

if (!wifi_mgmt_api || !wifi_mgmt_api->req_dms) {
wpa_printf(MSG_ERROR, "Request DMS ops not supported");
return -ENOTSUP;
}

return wifi_mgmt_api->req_dms(dev, params);
}

#ifdef CONFIG_AP
int z_wpa_supplicant_ap_enable(const struct device *dev,
struct wifi_connect_req_params *params)
Expand Down
Loading