@@ -136,12 +136,12 @@ int emac_tx_complete_packets(struct prueth_emac *emac, int chn,
136136 struct net_device * ndev = emac -> ndev ;
137137 struct cppi5_host_desc_t * desc_tx ;
138138 struct netdev_queue * netif_txq ;
139+ struct prueth_swdata * swdata ;
139140 struct prueth_tx_chn * tx_chn ;
140141 unsigned int total_bytes = 0 ;
141142 struct sk_buff * skb ;
142143 dma_addr_t desc_dma ;
143144 int res , num_tx = 0 ;
144- void * * swdata ;
145145
146146 tx_chn = & emac -> tx_chns [chn ];
147147
@@ -161,16 +161,11 @@ int emac_tx_complete_packets(struct prueth_emac *emac, int chn,
161161 desc_tx = k3_cppi_desc_pool_dma2virt (tx_chn -> desc_pool ,
162162 desc_dma );
163163 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 );
172164 prueth_xmit_free (tx_chn , desc_tx );
165+ if (swdata -> type != PRUETH_SWDATA_SKB )
166+ continue ;
173167
168+ skb = swdata -> data .skb ;
174169 ndev = skb -> dev ;
175170 ndev -> stats .tx_packets ++ ;
176171 ndev -> stats .tx_bytes += skb -> len ;
@@ -472,9 +467,9 @@ int prueth_dma_rx_push_mapped(struct prueth_emac *emac,
472467{
473468 struct net_device * ndev = emac -> ndev ;
474469 struct cppi5_host_desc_t * desc_rx ;
470+ struct prueth_swdata * swdata ;
475471 dma_addr_t desc_dma ;
476472 dma_addr_t buf_dma ;
477- void * * swdata ;
478473
479474 buf_dma = page_pool_get_dma_addr (page ) + PRUETH_HEADROOM ;
480475 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,
490485 cppi5_hdesc_attach_buf (desc_rx , buf_dma , buf_len , buf_dma , buf_len );
491486
492487 swdata = cppi5_hdesc_get_swdata (desc_rx );
493- * swdata = page ;
488+ swdata -> type = PRUETH_SWDATA_PAGE ;
489+ swdata -> data .page = page ;
494490
495491 return k3_udma_glue_push_rx_chn (rx_chn -> rx_chn , PRUETH_RX_FLOW_DATA ,
496492 desc_rx , desc_dma );
@@ -539,11 +535,11 @@ static int emac_rx_packet(struct prueth_emac *emac, u32 flow_id)
539535 u32 buf_dma_len , pkt_len , port_id = 0 ;
540536 struct net_device * ndev = emac -> ndev ;
541537 struct cppi5_host_desc_t * desc_rx ;
538+ struct prueth_swdata * swdata ;
542539 dma_addr_t desc_dma , buf_dma ;
543540 struct page * page , * new_page ;
544541 struct page_pool * pool ;
545542 struct sk_buff * skb ;
546- void * * swdata ;
547543 u32 * psdata ;
548544 void * pa ;
549545 int ret ;
@@ -561,7 +557,13 @@ static int emac_rx_packet(struct prueth_emac *emac, u32 flow_id)
561557
562558 desc_rx = k3_cppi_desc_pool_dma2virt (rx_chn -> desc_pool , desc_dma );
563559 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 ;
565567 page_pool_dma_sync_for_cpu (pool , page , 0 , PAGE_SIZE );
566568 cppi5_hdesc_get_obuf (desc_rx , & buf_dma , & buf_dma_len );
567569 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)
626628{
627629 struct prueth_rx_chn * rx_chn = data ;
628630 struct cppi5_host_desc_t * desc_rx ;
631+ struct prueth_swdata * swdata ;
629632 struct page_pool * pool ;
630633 struct page * page ;
631- void * * swdata ;
632634
633635 pool = rx_chn -> pg_pool ;
634636 desc_rx = k3_cppi_desc_pool_dma2virt (rx_chn -> desc_pool , desc_dma );
635637 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+
638643 k3_cppi_desc_pool_free (rx_chn -> desc_pool , desc_rx );
639644}
640645
@@ -671,13 +676,13 @@ enum netdev_tx icssg_ndo_start_xmit(struct sk_buff *skb, struct net_device *ndev
671676 struct prueth_emac * emac = netdev_priv (ndev );
672677 struct prueth * prueth = emac -> prueth ;
673678 struct netdev_queue * netif_txq ;
679+ struct prueth_swdata * swdata ;
674680 struct prueth_tx_chn * tx_chn ;
675681 dma_addr_t desc_dma , buf_dma ;
676682 u32 pkt_len , dst_tag_id ;
677683 int i , ret = 0 , q_idx ;
678684 bool in_tx_ts = 0 ;
679685 int tx_ts_cookie ;
680- void * * swdata ;
681686 u32 * epib ;
682687
683688 pkt_len = skb_headlen (skb );
@@ -739,7 +744,8 @@ enum netdev_tx icssg_ndo_start_xmit(struct sk_buff *skb, struct net_device *ndev
739744 k3_udma_glue_tx_dma_to_cppi5_addr (tx_chn -> tx_chn , & buf_dma );
740745 cppi5_hdesc_attach_buf (first_desc , buf_dma , pkt_len , buf_dma , pkt_len );
741746 swdata = cppi5_hdesc_get_swdata (first_desc );
742- * swdata = skb ;
747+ swdata -> type = PRUETH_SWDATA_SKB ;
748+ swdata -> data .skb = skb ;
743749
744750 /* Handle the case where skb is fragmented in pages */
745751 cur_desc = first_desc ;
@@ -842,15 +848,17 @@ static void prueth_tx_cleanup(void *data, dma_addr_t desc_dma)
842848{
843849 struct prueth_tx_chn * tx_chn = data ;
844850 struct cppi5_host_desc_t * desc_tx ;
851+ struct prueth_swdata * swdata ;
845852 struct sk_buff * skb ;
846- void * * swdata ;
847853
848854 desc_tx = k3_cppi_desc_pool_dma2virt (tx_chn -> desc_pool , desc_dma );
849855 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+ }
852860
853- dev_kfree_skb_any ( skb );
861+ prueth_xmit_free ( tx_chn , desc_tx );
854862}
855863
856864irqreturn_t prueth_rx_irq (int irq , void * dev_id )
0 commit comments