Skip to content

Commit 4425e78

Browse files
ajayparidarlubos
authored andcommitted
[SHEL-2596] nrf_wifi: Process regulatory event for radio test mode
Before setting regulatory to firmware, host enquires firmware about current regulatory domain. The event handling for this command was enabled for STA mode, for which command was failing. Added regulatory related events handling for radio test mode. Signed-off-by: Ajay Parida <[email protected]>
1 parent 3ee527d commit 4425e78

File tree

1 file changed

+71
-27
lines changed

1 file changed

+71
-27
lines changed

nrf_wifi/fw_if/umac_if/src/event.c

Lines changed: 71 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,25 @@ static void umac_event_connect(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
139139
}
140140
#endif /* CONFIG_NRF700X_STA_MODE */
141141

142-
#ifndef CONFIG_NRF700X_RADIO_TEST
143142
static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
144143
void *event_data,
145144
unsigned int event_len)
146145
{
147146
enum nrf_wifi_status status = NRF_WIFI_STATUS_SUCCESS;
148147
struct nrf_wifi_umac_hdr *umac_hdr = NULL;
148+
#ifndef CONFIG_NRF700X_RADIO_TEST
149149
struct nrf_wifi_fmac_vif_ctx *vif_ctx = NULL;
150150
struct nrf_wifi_fmac_callbk_fns *callbk_fns = NULL;
151151
struct nrf_wifi_umac_event_vif_state *evnt_vif_state = NULL;
152-
unsigned char if_id = 0;
153-
unsigned int event_num = 0;
154-
bool more_res = false;
155152
struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL;
156153
struct nrf_wifi_fmac_priv_def *def_priv = NULL;
154+
bool more_res = false;
155+
#else
156+
struct nrf_wifi_reg *get_reg_event = NULL;
157+
struct nrf_wifi_event_regulatory_change *reg_change_event = NULL;
158+
#endif /* !CONFIG_NRF700X_RADIO_TEST */
159+
unsigned char if_id = 0;
160+
unsigned int event_num = 0;
157161

158162
if (!fmac_dev_ctx || !event_data) {
159163
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
@@ -162,13 +166,16 @@ static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx
162166
goto out;
163167
}
164168

169+
#ifndef CONFIG_NRF700X_RADIO_TEST
165170
def_priv = wifi_fmac_priv(fmac_dev_ctx->fpriv);
166171
def_dev_ctx = wifi_dev_priv(fmac_dev_ctx);
167172

168173
if (!def_priv || !def_dev_ctx) {
169174
goto out;
170175
}
171176

177+
#endif /* !CONFIG_NRF700X_RADIO_TEST */
178+
172179
umac_hdr = event_data;
173180
if_id = umac_hdr->ids.wdev_id;
174181
event_num = umac_hdr->cmd_evnt;
@@ -182,15 +189,72 @@ static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx
182189
goto out;
183190
}
184191

192+
#ifndef CONFIG_NRF700X_RADIO_TEST
185193
vif_ctx = def_dev_ctx->vif_ctx[if_id];
186194
callbk_fns = &def_priv->callbk_fns;
195+
#endif /* !CONFIG_NRF700X_RADIO_TEST */
187196

188197
nrf_wifi_osal_log_dbg(fmac_dev_ctx->fpriv->opriv,
189198
"%s: Event %d received from UMAC",
190199
__func__,
191200
event_num);
192201

193202
switch (umac_hdr->cmd_evnt) {
203+
case NRF_WIFI_UMAC_EVENT_GET_REG:
204+
#ifdef CONFIG_NRF700X_STA_MODE
205+
if (callbk_fns->event_get_reg)
206+
callbk_fns->event_get_reg(vif_ctx->os_vif_ctx,
207+
event_data,
208+
event_len);
209+
else
210+
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
211+
"%s: No callback registered for event %d",
212+
__func__,
213+
umac_hdr->cmd_evnt);
214+
#endif /* CONFIG_NRF700X_STA_MODE */
215+
#ifdef CONFIG_NRF700X_RADIO_TEST
216+
get_reg_event = (struct nrf_wifi_reg *)event_data;
217+
218+
nrf_wifi_osal_mem_cpy(fmac_dev_ctx->fpriv->opriv,
219+
&fmac_dev_ctx->alpha2,
220+
&get_reg_event->nrf_wifi_alpha2,
221+
sizeof(get_reg_event->nrf_wifi_alpha2));
222+
fmac_dev_ctx->alpha2_valid = true;
223+
#endif /* CONFIG_NRF700X_RADIO_TEST */
224+
break;
225+
case NRF_WIFI_UMAC_EVENT_REG_CHANGE:
226+
#ifdef CONFIG_NRF700X_STA_MODE
227+
if (callbk_fns->reg_change_callbk_fn)
228+
callbk_fns->reg_change_callbk_fn(vif_ctx->os_vif_ctx,
229+
event_data,
230+
event_len);
231+
else
232+
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
233+
"%s: No callback registered for event %d",
234+
__func__,
235+
umac_hdr->cmd_evnt);
236+
#endif /* CONFIG_NRF700X_STA_MODE */
237+
#ifdef CONFIG_NRF700X_RADIO_TEST
238+
reg_change_event = (struct nrf_wifi_event_regulatory_change *)event_data;
239+
240+
fmac_dev_ctx->reg_change = nrf_wifi_osal_mem_zalloc(fmac_dev_ctx->fpriv->opriv,
241+
sizeof(*reg_change_event));
242+
243+
if (!fmac_dev_ctx->reg_change) {
244+
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
245+
"%s: Failed to allocate memory for reg_change",
246+
__func__);
247+
goto out;
248+
}
249+
250+
nrf_wifi_osal_mem_cpy(fmac_dev_ctx->fpriv->opriv,
251+
fmac_dev_ctx->reg_change,
252+
reg_change_event,
253+
sizeof(*reg_change_event));
254+
fmac_dev_ctx->reg_set_status = true;
255+
#endif /* CONFIG_NRF700X_RADIO_TEST */
256+
break;
257+
#ifndef CONFIG_NRF700X_RADIO_TEST
194258
case NRF_WIFI_UMAC_EVENT_TRIGGER_SCAN_START:
195259
if (callbk_fns->scan_start_callbk_fn)
196260
callbk_fns->scan_start_callbk_fn(vif_ctx->os_vif_ctx,
@@ -471,17 +535,6 @@ static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx
471535
case NRF_WIFI_UMAC_EVENT_DISCONNECT:
472536
/* Nothing to be done */
473537
break;
474-
case NRF_WIFI_UMAC_EVENT_GET_REG:
475-
if (callbk_fns->event_get_reg)
476-
callbk_fns->event_get_reg(vif_ctx->os_vif_ctx,
477-
event_data,
478-
event_len);
479-
else
480-
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
481-
"%s: No callback registered for event %d",
482-
__func__,
483-
umac_hdr->cmd_evnt);
484-
break;
485538
case NRF_WIFI_UMAC_EVENT_GET_POWER_SAVE_INFO:
486539
if (callbk_fns->event_get_ps_info)
487540
callbk_fns->event_get_ps_info(vif_ctx->os_vif_ctx,
@@ -535,18 +588,8 @@ static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx
535588
__func__,
536589
umac_hdr->cmd_evnt);
537590
break;
538-
case NRF_WIFI_UMAC_EVENT_REG_CHANGE:
539-
if (callbk_fns->reg_change_callbk_fn)
540-
callbk_fns->reg_change_callbk_fn(vif_ctx->os_vif_ctx,
541-
event_data,
542-
event_len);
543-
else
544-
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
545-
"%s: No callback registered for event %d",
546-
__func__,
547-
umac_hdr->cmd_evnt);
548-
break;
549591
#endif /* CONFIG_NRF700X_STA_MODE */
592+
#endif /* !CONFIG_NRF700X_RADIO_TEST */
550593
default:
551594
nrf_wifi_osal_log_dbg(fmac_dev_ctx->fpriv->opriv,
552595
"%s: No callback registered for event %d",
@@ -564,6 +607,7 @@ static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx
564607
return status;
565608
}
566609

610+
#ifndef CONFIG_NRF700X_RADIO_TEST
567611
static enum nrf_wifi_status
568612
nrf_wifi_fmac_data_event_process(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
569613
void *umac_head)
@@ -1088,6 +1132,7 @@ enum nrf_wifi_status nrf_wifi_fmac_event_callback(void *mac_dev_ctx,
10881132
status = nrf_wifi_fmac_data_events_process(fmac_dev_ctx,
10891133
rpu_msg);
10901134
break;
1135+
#endif /* !CONFIG_NRF700X_RADIO_TEST */
10911136
case NRF_WIFI_HOST_RPU_MSG_TYPE_UMAC:
10921137
status = umac_event_ctrl_process(fmac_dev_ctx,
10931138
rpu_msg->msg,
@@ -1100,7 +1145,6 @@ enum nrf_wifi_status nrf_wifi_fmac_event_callback(void *mac_dev_ctx,
11001145
goto out;
11011146
}
11021147
break;
1103-
#endif /* !CONFIG_NRF700X_RADIO_TEST */
11041148
case NRF_WIFI_HOST_RPU_MSG_TYPE_SYSTEM:
11051149
status = umac_process_sys_events(fmac_dev_ctx,
11061150
rpu_msg);

0 commit comments

Comments
 (0)