@@ -389,27 +389,34 @@ static void mlxsw_pci_wqe_frag_unmap(struct mlxsw_pci *mlxsw_pci, char *wqe,
389
389
dma_unmap_single (& pdev -> dev , mapaddr , frag_len , direction );
390
390
}
391
391
392
- static struct sk_buff * mlxsw_pci_rdq_build_skb (struct page * pages [],
392
+ static struct sk_buff * mlxsw_pci_rdq_build_skb (struct mlxsw_pci_queue * q ,
393
+ struct page * pages [],
393
394
u16 byte_count )
394
395
{
396
+ struct mlxsw_pci_queue * cq = q -> u .rdq .cq ;
395
397
unsigned int linear_data_size ;
398
+ struct page_pool * page_pool ;
396
399
struct sk_buff * skb ;
397
400
int page_index = 0 ;
398
401
bool linear_only ;
399
402
void * data ;
400
403
404
+ linear_only = byte_count + MLXSW_PCI_RX_BUF_SW_OVERHEAD <= PAGE_SIZE ;
405
+ linear_data_size = linear_only ? byte_count :
406
+ PAGE_SIZE -
407
+ MLXSW_PCI_RX_BUF_SW_OVERHEAD ;
408
+
409
+ page_pool = cq -> u .cq .page_pool ;
410
+ page_pool_dma_sync_for_cpu (page_pool , pages [page_index ],
411
+ MLXSW_PCI_SKB_HEADROOM , linear_data_size );
412
+
401
413
data = page_address (pages [page_index ]);
402
414
net_prefetch (data );
403
415
404
416
skb = napi_build_skb (data , PAGE_SIZE );
405
417
if (unlikely (!skb ))
406
418
return ERR_PTR (- ENOMEM );
407
419
408
- linear_only = byte_count + MLXSW_PCI_RX_BUF_SW_OVERHEAD <= PAGE_SIZE ;
409
- linear_data_size = linear_only ? byte_count :
410
- PAGE_SIZE -
411
- MLXSW_PCI_RX_BUF_SW_OVERHEAD ;
412
-
413
420
skb_reserve (skb , MLXSW_PCI_SKB_HEADROOM );
414
421
skb_put (skb , linear_data_size );
415
422
@@ -425,6 +432,7 @@ static struct sk_buff *mlxsw_pci_rdq_build_skb(struct page *pages[],
425
432
426
433
page = pages [page_index ];
427
434
frag_size = min (byte_count , PAGE_SIZE );
435
+ page_pool_dma_sync_for_cpu (page_pool , page , 0 , frag_size );
428
436
skb_add_rx_frag (skb , skb_shinfo (skb )-> nr_frags ,
429
437
page , 0 , frag_size , PAGE_SIZE );
430
438
byte_count -= frag_size ;
@@ -760,7 +768,7 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci,
760
768
if (err )
761
769
goto out ;
762
770
763
- skb = mlxsw_pci_rdq_build_skb (pages , byte_count );
771
+ skb = mlxsw_pci_rdq_build_skb (q , pages , byte_count );
764
772
if (IS_ERR (skb )) {
765
773
dev_err_ratelimited (& pdev -> dev , "Failed to build skb for RDQ\n" );
766
774
mlxsw_pci_rdq_pages_recycle (q , pages , num_sg_entries );
0 commit comments