Skip to content

Commit bb382d7

Browse files
committed
nrf71: Add support for RX buffer refilling to UMAC
Instead of filling buffers directly to LMAC, send them to the UMAC first which will take care of relaying them to LMAC, this is done via IPC instead of relying on internal memory acccess. Signed-off-by: Chaitanya Tata <[email protected]>
1 parent bb57ea0 commit bb382d7

File tree

8 files changed

+361
-80
lines changed

8 files changed

+361
-80
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ target_compile_definitions(
107107
WIFI_NRF70_LOG_LEVEL=${CONFIG_WIFI_NRF70_LOG_LEVEL}
108108
)
109109

110+
if (CONFIG_NRF71_ON_IPC)
111+
target_compile_definitions(
112+
nrf-wifi-osal
113+
PUBLIC
114+
NRF_WIFI_RX_BUFF_PROG_UMAC
115+
)
116+
endif()
117+
110118
target_include_directories(
111119
nrf-wifi-osal
112120
PUBLIC

fw_if/umac_if/inc/system/fmac_api.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,22 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_conf_ltf_gi(struct nrf_wifi_fmac_dev_ctx
11741174
enum nrf_wifi_status nrf_wifi_sys_fmac_stats_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
11751175
enum rpu_op_mode op_mode,
11761176
struct rpu_sys_op_stats *stats);
1177+
#ifdef NRF_WIFI_RX_BUFF_PROG_UMAC
1178+
/**
1179+
* @brief Send Rx buffer details to firmware.
1180+
* @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device.
1181+
* @param nrf_wifi_rx_buf RX buffer info.
1182+
* @param num_buffs Number of buffers.
1183+
*
1184+
* This function is used to send host Rx buffers to UMAC module
1185+
*
1186+
*@retval NRF_WIFI_STATUS_SUCCESS On success
1187+
*@retval NRF_WIFI_STATUS_FAIL On failure to execute command
1188+
*/
1189+
enum nrf_wifi_status nrf_wifi_fmac_prog_rx_buf_info(void *fmac_dev_ctx,
1190+
struct nrf_wifi_rx_buf *rx_buf,
1191+
unsigned int num_buffs);
1192+
#endif /*NRF_WIFI_RX_BUFF_PROG_UMAC*/
11771193

11781194
/**
11791195
* @}

fw_if/umac_if/inc/system/fmac_rx.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_event_process(struct nrf_wifi_fmac_dev_ctx
3838

3939
void nrf_wifi_fmac_rx_tasklet(void *data);
4040

41+
#ifdef NRF_WIFI_RX_BUFF_PROG_UMAC
42+
unsigned long nrf_wifi_fmac_get_rx_buf_map_addr(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
43+
unsigned int desc_id);
44+
#endif /* NRF_WIFI_RX_BUFF_PROG_UMAC */
45+
4146
#endif /* __FMAC_RX_H__ */

fw_if/umac_if/src/system/fmac_api.c

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ static enum nrf_wifi_status nrf_wifi_sys_fmac_fw_init(struct nrf_wifi_fmac_dev_c
206206
unsigned long start_time_us = 0;
207207
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
208208
struct nrf_wifi_sys_fmac_priv *sys_fpriv = NULL;
209+
#ifdef NRF_WIFI_RX_BUFF_PROG_UMAC
210+
struct nrf_wifi_rx_buf *rx_buf_ipc = NULL, *rx_buf_info_iter = NULL;
211+
unsigned int desc_id = 0;
212+
unsigned int buf_addr = 0;
213+
#endif /*NRF_WIFI_RX_BUFF_PROG_UMAC */
209214

210215
sys_fpriv = wifi_fmac_priv(fmac_dev_ctx->fpriv);
211216

@@ -273,6 +278,46 @@ static enum nrf_wifi_status nrf_wifi_sys_fmac_fw_init(struct nrf_wifi_fmac_dev_c
273278
goto out;
274279
}
275280

281+
#ifdef NRF_WIFI_RX_BUFF_PROG_UMAC
282+
rx_buf_ipc = nrf_wifi_osal_mem_zalloc(sys_fpriv->num_rx_bufs * sizeof(struct nrf_wifi_rx_buf));
283+
284+
rx_buf_info_iter = rx_buf_ipc;
285+
286+
for (desc_id = 0; desc_id < sys_fpriv->num_rx_bufs; desc_id++) {
287+
buf_addr = (unsigned int) nrf_wifi_fmac_get_rx_buf_map_addr(fmac_dev_ctx, desc_id);
288+
if (buf_addr) {
289+
rx_buf_info_iter->skb_pointer = buf_addr;
290+
nrf_wifi_osal_log_dbg("%s: RX buffer mapped for desc_id = %d, buf_addr = %p",
291+
__func__,
292+
desc_id,
293+
(void *)buf_addr);
294+
rx_buf_info_iter->skb_desc_no = desc_id;
295+
rx_buf_info_iter++;
296+
} else {
297+
nrf_wifi_osal_log_err("%s: UMAC rx buff not mapped \
298+
for desc_id = %d\n", desc_id,
299+
__func__);
300+
status = NRF_WIFI_STATUS_FAIL;
301+
goto out;
302+
}
303+
}
304+
status = nrf_wifi_fmac_prog_rx_buf_info(fmac_dev_ctx,
305+
rx_buf_ipc,
306+
sys_fpriv->num_rx_bufs);
307+
if (status != NRF_WIFI_STATUS_SUCCESS) {
308+
nrf_wifi_osal_log_err("%s: UMAC rx buff \
309+
programming failed \n",
310+
__func__);
311+
status = NRF_WIFI_STATUS_FAIL;
312+
goto out;
313+
} else {
314+
nrf_wifi_osal_log_dbg("%s During initialization UMAC rx buff \
315+
programmed for num_buffs= %d\n",
316+
__func__,
317+
sys_fpriv->num_rx_bufs);
318+
nrf_wifi_osal_mem_free(rx_buf_ipc);
319+
}
320+
#endif /*NRF_WIFI_RX_BUFF_PROG_UMAC */
276321
status = NRF_WIFI_STATUS_SUCCESS;
277322

278323
out:
@@ -3907,3 +3952,81 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_get_host_rpu_ps_ctrl_state(void *dev_ctx,
39073952
}
39083953
#endif /* NRF_WIFI_LOW_POWER */
39093954
#endif /* NRF70_UTIL */
3955+
3956+
3957+
#ifdef NRF_WIFI_RX_BUFF_PROG_UMAC
3958+
#define MAX_BUFS_PER_CMD 32
3959+
enum nrf_wifi_status nrf_wifi_fmac_prog_rx_buf_info(void *dev_ctx,
3960+
struct nrf_wifi_rx_buf *rx_buf,
3961+
unsigned int rx_buf_nums)
3962+
{
3963+
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
3964+
struct nrf_wifi_cmd_rx_buf_info *rx_buf_cmd = NULL;
3965+
struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL;
3966+
struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL;
3967+
struct nrf_wifi_rx_buf *rx_buf_iter = NULL;
3968+
int i = 0, remained_buf_cnt = 0, counter = 0, rx_buff_prog_cnt = 0;
3969+
3970+
fmac_dev_ctx = dev_ctx;
3971+
def_dev_ctx = wifi_dev_priv(fmac_dev_ctx);
3972+
3973+
if (rx_buf_nums > MAX_BUFS_PER_CMD) {
3974+
rx_buff_prog_cnt = MAX_BUFS_PER_CMD;
3975+
remained_buf_cnt = rx_buf_nums % MAX_BUFS_PER_CMD;
3976+
counter = rx_buf_nums / MAX_BUFS_PER_CMD;
3977+
} else {
3978+
rx_buff_prog_cnt = rx_buf_nums;
3979+
counter = 1;
3980+
}
3981+
3982+
rx_buf_iter = rx_buf;
3983+
3984+
for (i = 0; i < counter; i++) {
3985+
rx_buf_cmd = nrf_wifi_osal_mem_zalloc(sizeof(*rx_buf_cmd) +
3986+
rx_buff_prog_cnt * sizeof(struct nrf_wifi_rx_buf));
3987+
if (!rx_buf_cmd) {
3988+
nrf_wifi_osal_log_err("%s: Unable to allocate memory\n", __func__);
3989+
goto out;
3990+
}
3991+
3992+
rx_buf_cmd->umac_hdr.cmd_evnt = NRF_WIFI_UMAC_CMD_CONFIG_RX_BUF;
3993+
nrf_wifi_osal_mem_cpy(&rx_buf_cmd->info,
3994+
rx_buf,
3995+
rx_buff_prog_cnt * sizeof(struct nrf_wifi_rx_buf));
3996+
3997+
rx_buf_cmd->rx_buf_num = rx_buff_prog_cnt;
3998+
3999+
status = umac_cmd_cfg(fmac_dev_ctx,
4000+
rx_buf_cmd,
4001+
sizeof(*rx_buf_cmd) +
4002+
rx_buff_prog_cnt * sizeof(struct nrf_wifi_rx_buf));
4003+
if (rx_buf_cmd) {
4004+
nrf_wifi_osal_mem_free(rx_buf_cmd);
4005+
}
4006+
}
4007+
if (remained_buf_cnt > 0) {
4008+
rx_buf_cmd = nrf_wifi_osal_mem_zalloc(sizeof(*rx_buf_cmd) +
4009+
remained_buf_cnt * sizeof(struct nrf_wifi_rx_buf));
4010+
if (!rx_buf_cmd) {
4011+
nrf_wifi_osal_log_err("%s: Unable to allocate memory\n", __func__);
4012+
goto out;
4013+
}
4014+
4015+
rx_buf_cmd->umac_hdr.cmd_evnt = NRF_WIFI_UMAC_CMD_CONFIG_RX_BUF;
4016+
nrf_wifi_osal_mem_cpy(&rx_buf_cmd->info,
4017+
rx_buf + (MAX_BUFS_PER_CMD),
4018+
remained_buf_cnt * sizeof(struct nrf_wifi_rx_buf));
4019+
4020+
rx_buf_cmd->rx_buf_num = remained_buf_cnt;
4021+
4022+
status = umac_cmd_cfg(fmac_dev_ctx,
4023+
rx_buf_cmd,
4024+
sizeof(*rx_buf_cmd) + remained_buf_cnt * sizeof(struct nrf_wifi_rx_buf));
4025+
if (rx_buf_cmd) {
4026+
nrf_wifi_osal_mem_free(rx_buf_cmd);
4027+
}
4028+
}
4029+
out:
4030+
return status;
4031+
}
4032+
#endif /*NRF_WIFI_RX_BUFF_PROG_UMAC */

fw_if/umac_if/src/system/fmac_event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ nrf_wifi_fmac_data_event_process(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
315315
#endif /* NRF_WIFI_CMD_EVENT_LOG */
316316

317317
switch (event) {
318-
case NRF_WIFI_CMD_RX_BUFF:
318+
case NRF_WIFI_NRF_WIFI_RX_BUFF_PROG_UMAC:
319319
#ifdef NRF70_RX_DONE_WQ_ENABLED
320320
struct nrf_wifi_rx_buff *config = nrf_wifi_osal_mem_zalloc(
321321
sizeof(struct nrf_wifi_rx_buff));

0 commit comments

Comments
 (0)