@@ -136,12 +136,12 @@ int emac_tx_complete_packets(struct prueth_emac *emac, int chn,
136
136
struct net_device * ndev = emac -> ndev ;
137
137
struct cppi5_host_desc_t * desc_tx ;
138
138
struct netdev_queue * netif_txq ;
139
+ struct prueth_swdata * swdata ;
139
140
struct prueth_tx_chn * tx_chn ;
140
141
unsigned int total_bytes = 0 ;
141
142
struct sk_buff * skb ;
142
143
dma_addr_t desc_dma ;
143
144
int res , num_tx = 0 ;
144
- void * * swdata ;
145
145
146
146
tx_chn = & emac -> tx_chns [chn ];
147
147
@@ -161,16 +161,11 @@ int emac_tx_complete_packets(struct prueth_emac *emac, int chn,
161
161
desc_tx = k3_cppi_desc_pool_dma2virt (tx_chn -> desc_pool ,
162
162
desc_dma );
163
163
swdata = cppi5_hdesc_get_swdata (desc_tx );
164
-
165
- /* was this command's TX complete? */
166
- if (emac -> is_sr1 && * (swdata ) == emac -> cmd_data ) {
167
- prueth_xmit_free (tx_chn , desc_tx );
168
- continue ;
169
- }
170
-
171
- skb = * (swdata );
172
164
prueth_xmit_free (tx_chn , desc_tx );
165
+ if (swdata -> type != PRUETH_SWDATA_SKB )
166
+ continue ;
173
167
168
+ skb = swdata -> data .skb ;
174
169
ndev = skb -> dev ;
175
170
ndev -> stats .tx_packets ++ ;
176
171
ndev -> stats .tx_bytes += skb -> len ;
@@ -472,9 +467,9 @@ int prueth_dma_rx_push_mapped(struct prueth_emac *emac,
472
467
{
473
468
struct net_device * ndev = emac -> ndev ;
474
469
struct cppi5_host_desc_t * desc_rx ;
470
+ struct prueth_swdata * swdata ;
475
471
dma_addr_t desc_dma ;
476
472
dma_addr_t buf_dma ;
477
- void * * swdata ;
478
473
479
474
buf_dma = page_pool_get_dma_addr (page ) + PRUETH_HEADROOM ;
480
475
desc_rx = k3_cppi_desc_pool_alloc (rx_chn -> desc_pool );
@@ -490,7 +485,8 @@ int prueth_dma_rx_push_mapped(struct prueth_emac *emac,
490
485
cppi5_hdesc_attach_buf (desc_rx , buf_dma , buf_len , buf_dma , buf_len );
491
486
492
487
swdata = cppi5_hdesc_get_swdata (desc_rx );
493
- * swdata = page ;
488
+ swdata -> type = PRUETH_SWDATA_PAGE ;
489
+ swdata -> data .page = page ;
494
490
495
491
return k3_udma_glue_push_rx_chn (rx_chn -> rx_chn , PRUETH_RX_FLOW_DATA ,
496
492
desc_rx , desc_dma );
@@ -539,11 +535,11 @@ static int emac_rx_packet(struct prueth_emac *emac, u32 flow_id)
539
535
u32 buf_dma_len , pkt_len , port_id = 0 ;
540
536
struct net_device * ndev = emac -> ndev ;
541
537
struct cppi5_host_desc_t * desc_rx ;
538
+ struct prueth_swdata * swdata ;
542
539
dma_addr_t desc_dma , buf_dma ;
543
540
struct page * page , * new_page ;
544
541
struct page_pool * pool ;
545
542
struct sk_buff * skb ;
546
- void * * swdata ;
547
543
u32 * psdata ;
548
544
void * pa ;
549
545
int ret ;
@@ -561,7 +557,13 @@ static int emac_rx_packet(struct prueth_emac *emac, u32 flow_id)
561
557
562
558
desc_rx = k3_cppi_desc_pool_dma2virt (rx_chn -> desc_pool , desc_dma );
563
559
swdata = cppi5_hdesc_get_swdata (desc_rx );
564
- page = * swdata ;
560
+ if (swdata -> type != PRUETH_SWDATA_PAGE ) {
561
+ netdev_err (ndev , "rx_pkt: invalid swdata->type %d\n" , swdata -> type );
562
+ k3_cppi_desc_pool_free (rx_chn -> desc_pool , desc_rx );
563
+ return 0 ;
564
+ }
565
+
566
+ page = swdata -> data .page ;
565
567
page_pool_dma_sync_for_cpu (pool , page , 0 , PAGE_SIZE );
566
568
cppi5_hdesc_get_obuf (desc_rx , & buf_dma , & buf_dma_len );
567
569
k3_udma_glue_rx_cppi5_to_dma_addr (rx_chn -> rx_chn , & buf_dma );
@@ -626,15 +628,18 @@ static void prueth_rx_cleanup(void *data, dma_addr_t desc_dma)
626
628
{
627
629
struct prueth_rx_chn * rx_chn = data ;
628
630
struct cppi5_host_desc_t * desc_rx ;
631
+ struct prueth_swdata * swdata ;
629
632
struct page_pool * pool ;
630
633
struct page * page ;
631
- void * * swdata ;
632
634
633
635
pool = rx_chn -> pg_pool ;
634
636
desc_rx = k3_cppi_desc_pool_dma2virt (rx_chn -> desc_pool , desc_dma );
635
637
swdata = cppi5_hdesc_get_swdata (desc_rx );
636
- page = * swdata ;
637
- page_pool_recycle_direct (pool , page );
638
+ if (swdata -> type == PRUETH_SWDATA_PAGE ) {
639
+ page = swdata -> data .page ;
640
+ page_pool_recycle_direct (pool , page );
641
+ }
642
+
638
643
k3_cppi_desc_pool_free (rx_chn -> desc_pool , desc_rx );
639
644
}
640
645
@@ -671,13 +676,13 @@ enum netdev_tx icssg_ndo_start_xmit(struct sk_buff *skb, struct net_device *ndev
671
676
struct prueth_emac * emac = netdev_priv (ndev );
672
677
struct prueth * prueth = emac -> prueth ;
673
678
struct netdev_queue * netif_txq ;
679
+ struct prueth_swdata * swdata ;
674
680
struct prueth_tx_chn * tx_chn ;
675
681
dma_addr_t desc_dma , buf_dma ;
676
682
u32 pkt_len , dst_tag_id ;
677
683
int i , ret = 0 , q_idx ;
678
684
bool in_tx_ts = 0 ;
679
685
int tx_ts_cookie ;
680
- void * * swdata ;
681
686
u32 * epib ;
682
687
683
688
pkt_len = skb_headlen (skb );
@@ -739,7 +744,8 @@ enum netdev_tx icssg_ndo_start_xmit(struct sk_buff *skb, struct net_device *ndev
739
744
k3_udma_glue_tx_dma_to_cppi5_addr (tx_chn -> tx_chn , & buf_dma );
740
745
cppi5_hdesc_attach_buf (first_desc , buf_dma , pkt_len , buf_dma , pkt_len );
741
746
swdata = cppi5_hdesc_get_swdata (first_desc );
742
- * swdata = skb ;
747
+ swdata -> type = PRUETH_SWDATA_SKB ;
748
+ swdata -> data .skb = skb ;
743
749
744
750
/* Handle the case where skb is fragmented in pages */
745
751
cur_desc = first_desc ;
@@ -842,15 +848,17 @@ static void prueth_tx_cleanup(void *data, dma_addr_t desc_dma)
842
848
{
843
849
struct prueth_tx_chn * tx_chn = data ;
844
850
struct cppi5_host_desc_t * desc_tx ;
851
+ struct prueth_swdata * swdata ;
845
852
struct sk_buff * skb ;
846
- void * * swdata ;
847
853
848
854
desc_tx = k3_cppi_desc_pool_dma2virt (tx_chn -> desc_pool , desc_dma );
849
855
swdata = cppi5_hdesc_get_swdata (desc_tx );
850
- skb = * (swdata );
851
- prueth_xmit_free (tx_chn , desc_tx );
856
+ if (swdata -> type == PRUETH_SWDATA_SKB ) {
857
+ skb = swdata -> data .skb ;
858
+ dev_kfree_skb_any (skb );
859
+ }
852
860
853
- dev_kfree_skb_any ( skb );
861
+ prueth_xmit_free ( tx_chn , desc_tx );
854
862
}
855
863
856
864
irqreturn_t prueth_rx_irq (int irq , void * dev_id )
0 commit comments