1313#include "system/fmac_rx.h"
1414#include "common/fmac_util.h"
1515#include "system/fmac_promisc.h"
16+ #ifdef NRF71_RX_BUFF
17+ #include "system/fmac_api.h"
18+ #endif /* NRF71_RX_BUFF */
1619
1720static enum nrf_wifi_status
1821nrf_wifi_fmac_map_desc_to_pool (struct nrf_wifi_fmac_dev_ctx * fmac_dev_ctx ,
@@ -165,6 +168,47 @@ static void nrf_wifi_convert_to_eth(void *nwb,
165168}
166169#endif /* NRF70_STA_MODE */
167170
171+ #ifdef NRF71_RX_BUFF
172+ unsigned long nrf_wifi_fmac_get_rx_buf_map_addr (struct nrf_wifi_fmac_dev_ctx * fmac_dev_ctx ,
173+ unsigned int desc_id )
174+ {
175+ enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL ;
176+ struct nrf_wifi_sys_fmac_dev_ctx * sys_dev_ctx = NULL ;
177+ struct nrf_wifi_sys_fmac_priv * sys_fpriv = NULL ;
178+ struct nrf_wifi_fmac_buf_map_info * rx_buf_info = NULL ;
179+ struct nrf_wifi_fmac_rx_pool_map_info pool_info ;
180+ unsigned long phy_addr = 0 ;
181+
182+ sys_dev_ctx = wifi_dev_priv (fmac_dev_ctx );
183+ sys_fpriv = wifi_fmac_priv (fmac_dev_ctx -> fpriv );
184+
185+ status = nrf_wifi_fmac_map_desc_to_pool (fmac_dev_ctx ,
186+ desc_id ,
187+ & pool_info );
188+
189+ if (status != NRF_WIFI_STATUS_SUCCESS ) {
190+ nrf_wifi_osal_log_err ("%s: nrf_wifi_fmac_map_desc_to_pool failed\n" ,
191+ __func__ );
192+ goto out ;
193+ }
194+
195+ rx_buf_info = & sys_dev_ctx -> rx_buf_info [desc_id ];
196+
197+ if (rx_buf_info -> mapped ) {
198+ phy_addr = nrf_wifi_sys_hal_get_buf_map_rx (fmac_dev_ctx -> hal_dev_ctx ,
199+ pool_info .pool_id ,
200+ pool_info .buf_id );
201+ return phy_addr ;
202+ } else {
203+ nrf_wifi_osal_log_err ("%s: rx buffer not mapped for desc_id= %d\n" ,
204+ __func__ ,
205+ desc_id );
206+ }
207+ out :
208+ return 0 ;
209+ }
210+ #endif /* NRF71_RX_BUFF */
211+
168212enum nrf_wifi_status nrf_wifi_fmac_rx_cmd_send (struct nrf_wifi_fmac_dev_ctx * fmac_dev_ctx ,
169213 enum nrf_wifi_fmac_rx_cmd_type cmd_type ,
170214 unsigned int desc_id )
@@ -245,12 +289,14 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_cmd_send(struct nrf_wifi_fmac_dev_ctx *fma
245289#else
246290 rx_cmd .addr = (unsigned int )nwb_data ;
247291#endif /* NRF71_ON_IPC */
292+ #ifndef NRF71_RX_BUFF
248293 status = nrf_wifi_sys_hal_data_cmd_send (fmac_dev_ctx -> hal_dev_ctx ,
249294 NRF_WIFI_HAL_MSG_TYPE_CMD_DATA_RX ,
250295 & rx_cmd ,
251296 sizeof (rx_cmd ),
252297 desc_id ,
253298 pool_info .pool_id );
299+ #endif /* NRF71_RX_BUFF */
254300 } else if (cmd_type == NRF_WIFI_FMAC_RX_CMD_TYPE_DEINIT ) {
255301#ifndef NRF71_ON_IPC
256302 /* TODO: Need to initialize a command and send it to LMAC
@@ -359,6 +405,10 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_event_process(struct nrf_wifi_fmac_dev_ctx
359405#endif /* NRF70_STA_MODE */
360406 struct nrf_wifi_sys_fmac_dev_ctx * sys_dev_ctx = NULL ;
361407 struct nrf_wifi_sys_fmac_priv * sys_fpriv = NULL ;
408+ #ifdef NRF71_RX_BUFF
409+ unsigned int buf_addr = 0 ;
410+ struct nrf_wifi_rx_buf * rx_buf_ipc = NULL , * rx_buf_info_iter = NULL ;
411+ #endif /* NRF71_RX_BUFF */
362412
363413 sys_dev_ctx = wifi_dev_priv (fmac_dev_ctx );
364414 sys_fpriv = wifi_fmac_priv (fmac_dev_ctx -> fpriv );
@@ -373,6 +423,12 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_event_process(struct nrf_wifi_fmac_dev_ctx
373423#endif /* NRF70_STA_MODE */
374424 num_pkts = config -> rx_pkt_cnt ;
375425
426+ #ifdef NRF71_RX_BUFF
427+ rx_buf_ipc = nrf_wifi_osal_mem_zalloc (num_pkts *
428+ sizeof (struct nrf_wifi_rx_buf ));
429+ rx_buf_info_iter = rx_buf_ipc ;
430+ #endif /* NRF71_RX_BUFF */
431+
376432 for (i = 0 ; i < num_pkts ; i ++ ) {
377433 desc_id = config -> rx_buff_info [i ].descriptor_id ;
378434 pkt_len = config -> rx_buff_info [i ].rx_pkt_len ;
@@ -548,8 +604,38 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_event_process(struct nrf_wifi_fmac_dev_ctx
548604 __func__ );
549605 continue ;
550606 }
607+ #ifdef NRF71_RX_BUFF
608+ buf_addr = (unsigned int ) nrf_wifi_fmac_get_rx_buf_map_addr (fmac_dev_ctx ,
609+ desc_id );
610+ if (buf_addr ) {
611+ rx_buf_info_iter -> skb_pointer = buf_addr ;
612+ rx_buf_info_iter -> skb_desc_no = desc_id ;
613+ rx_buf_info_iter ++ ;
614+ } else {
615+ nrf_wifi_osal_log_err ("%s: UMAC rx buff not mapped\
616+ for desc_id = %d\n" ,
617+ __func__ ,
618+ desc_id );
619+ continue ;
620+ }
621+ #endif /* NRF71_RX_BUFF */
551622 }
552-
623+ #ifdef NRF71_RX_BUFF
624+ status = nrf_wifi_sys_fmac_prog_rx_buf_info (fmac_dev_ctx ,
625+ rx_buf_ipc ,
626+ num_pkts );
627+ if (status != NRF_WIFI_STATUS_SUCCESS ) {
628+ nrf_wifi_osal_log_err ("%s: UMAC rx buff\
629+ programming failed \n" ,
630+ __func__ );
631+ status = NRF_WIFI_STATUS_FAIL ;
632+ } else {
633+ nrf_wifi_osal_log_dbg ("%s: UMAC rx buff refill\
634+ programmed for num_buffs= %d \n" ,
635+ __func__ , num_pkts );
636+ nrf_wifi_osal_mem_free (rx_buf_ipc );
637+ }
638+ #endif /* NRF71_RX_BUFF */
553639 /* A single failure returns failure for the entire event */
554640 return status ;
555641}
0 commit comments