@@ -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
278323out :
@@ -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 */
0 commit comments