@@ -830,19 +830,19 @@ static void am65_cpsw_nuss_tx_cleanup(void *data, dma_addr_t desc_dma)
830830{
831831 struct am65_cpsw_tx_chn * tx_chn = data ;
832832 enum am65_cpsw_tx_buf_type buf_type ;
833+ struct am65_cpsw_tx_swdata * swdata ;
833834 struct cppi5_host_desc_t * desc_tx ;
834835 struct xdp_frame * xdpf ;
835836 struct sk_buff * skb ;
836- void * * swdata ;
837837
838838 desc_tx = k3_cppi_desc_pool_dma2virt (tx_chn -> desc_pool , desc_dma );
839839 swdata = cppi5_hdesc_get_swdata (desc_tx );
840840 buf_type = am65_cpsw_nuss_buf_type (tx_chn , desc_dma );
841841 if (buf_type == AM65_CPSW_TX_BUF_TYPE_SKB ) {
842- skb = * ( swdata ) ;
842+ skb = swdata -> skb ;
843843 dev_kfree_skb_any (skb );
844844 } else {
845- xdpf = * ( swdata ) ;
845+ xdpf = swdata -> xdpf ;
846846 xdp_return_frame (xdpf );
847847 }
848848
@@ -1099,10 +1099,10 @@ static int am65_cpsw_xdp_tx_frame(struct net_device *ndev,
10991099 struct am65_cpsw_common * common = am65_ndev_to_common (ndev );
11001100 struct am65_cpsw_port * port = am65_ndev_to_port (ndev );
11011101 struct cppi5_host_desc_t * host_desc ;
1102+ struct am65_cpsw_tx_swdata * swdata ;
11021103 struct netdev_queue * netif_txq ;
11031104 dma_addr_t dma_desc , dma_buf ;
11041105 u32 pkt_len = xdpf -> len ;
1105- void * * swdata ;
11061106 int ret ;
11071107
11081108 host_desc = k3_cppi_desc_pool_alloc (tx_chn -> desc_pool );
@@ -1132,7 +1132,8 @@ static int am65_cpsw_xdp_tx_frame(struct net_device *ndev,
11321132 cppi5_hdesc_attach_buf (host_desc , dma_buf , pkt_len , dma_buf , pkt_len );
11331133
11341134 swdata = cppi5_hdesc_get_swdata (host_desc );
1135- * (swdata ) = xdpf ;
1135+ swdata -> ndev = ndev ;
1136+ swdata -> xdpf = xdpf ;
11361137
11371138 /* Report BQL before sending the packet */
11381139 netif_txq = netdev_get_tx_queue (ndev , tx_chn -> id );
@@ -1435,52 +1436,6 @@ static int am65_cpsw_nuss_rx_poll(struct napi_struct *napi_rx, int budget)
14351436 return num_rx ;
14361437}
14371438
1438- static struct sk_buff *
1439- am65_cpsw_nuss_tx_compl_packet_skb (struct am65_cpsw_tx_chn * tx_chn ,
1440- dma_addr_t desc_dma )
1441- {
1442- struct cppi5_host_desc_t * desc_tx ;
1443- struct sk_buff * skb ;
1444- void * * swdata ;
1445-
1446- desc_tx = k3_cppi_desc_pool_dma2virt (tx_chn -> desc_pool ,
1447- desc_dma );
1448- swdata = cppi5_hdesc_get_swdata (desc_tx );
1449- skb = * (swdata );
1450- am65_cpsw_nuss_xmit_free (tx_chn , desc_tx );
1451-
1452- am65_cpts_tx_timestamp (tx_chn -> common -> cpts , skb );
1453-
1454- dev_sw_netstats_tx_add (skb -> dev , 1 , skb -> len );
1455-
1456- return skb ;
1457- }
1458-
1459- static struct xdp_frame *
1460- am65_cpsw_nuss_tx_compl_packet_xdp (struct am65_cpsw_common * common ,
1461- struct am65_cpsw_tx_chn * tx_chn ,
1462- dma_addr_t desc_dma ,
1463- struct net_device * * ndev )
1464- {
1465- struct cppi5_host_desc_t * desc_tx ;
1466- struct am65_cpsw_port * port ;
1467- struct xdp_frame * xdpf ;
1468- u32 port_id = 0 ;
1469- void * * swdata ;
1470-
1471- desc_tx = k3_cppi_desc_pool_dma2virt (tx_chn -> desc_pool , desc_dma );
1472- cppi5_desc_get_tags_ids (& desc_tx -> hdr , NULL , & port_id );
1473- swdata = cppi5_hdesc_get_swdata (desc_tx );
1474- xdpf = * (swdata );
1475- am65_cpsw_nuss_xmit_free (tx_chn , desc_tx );
1476-
1477- port = am65_common_get_port (common , port_id );
1478- dev_sw_netstats_tx_add (port -> ndev , 1 , xdpf -> len );
1479- * ndev = port -> ndev ;
1480-
1481- return xdpf ;
1482- }
1483-
14841439static void am65_cpsw_nuss_tx_wake (struct am65_cpsw_tx_chn * tx_chn , struct net_device * ndev ,
14851440 struct netdev_queue * netif_txq )
14861441{
@@ -1503,6 +1458,8 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
15031458{
15041459 bool single_port = AM65_CPSW_IS_CPSW2G (common );
15051460 enum am65_cpsw_tx_buf_type buf_type ;
1461+ struct am65_cpsw_tx_swdata * swdata ;
1462+ struct cppi5_host_desc_t * desc_tx ;
15061463 struct device * dev = common -> dev ;
15071464 struct am65_cpsw_tx_chn * tx_chn ;
15081465 struct netdev_queue * netif_txq ;
@@ -1533,15 +1490,18 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
15331490 break ;
15341491 }
15351492
1493+ desc_tx = k3_cppi_desc_pool_dma2virt (tx_chn -> desc_pool ,
1494+ desc_dma );
1495+ swdata = cppi5_hdesc_get_swdata (desc_tx );
1496+ ndev = swdata -> ndev ;
15361497 buf_type = am65_cpsw_nuss_buf_type (tx_chn , desc_dma );
15371498 if (buf_type == AM65_CPSW_TX_BUF_TYPE_SKB ) {
1538- skb = am65_cpsw_nuss_tx_compl_packet_skb ( tx_chn , desc_dma ) ;
1539- ndev = skb -> dev ;
1499+ skb = swdata -> skb ;
1500+ am65_cpts_tx_timestamp ( tx_chn -> common -> cpts , skb ) ;
15401501 pkt_len = skb -> len ;
15411502 napi_consume_skb (skb , budget );
15421503 } else {
1543- xdpf = am65_cpsw_nuss_tx_compl_packet_xdp (common , tx_chn ,
1544- desc_dma , & ndev );
1504+ xdpf = swdata -> xdpf ;
15451505 pkt_len = xdpf -> len ;
15461506 if (buf_type == AM65_CPSW_TX_BUF_TYPE_XDP_TX )
15471507 xdp_return_frame_rx_napi (xdpf );
@@ -1551,7 +1511,8 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
15511511
15521512 total_bytes += pkt_len ;
15531513 num_tx ++ ;
1554-
1514+ am65_cpsw_nuss_xmit_free (tx_chn , desc_tx );
1515+ dev_sw_netstats_tx_add (ndev , 1 , pkt_len );
15551516 if (!single_port ) {
15561517 /* as packets from multi ports can be interleaved
15571518 * on the same channel, we have to figure out the
@@ -1634,12 +1595,12 @@ static netdev_tx_t am65_cpsw_nuss_ndo_slave_xmit(struct sk_buff *skb,
16341595 struct am65_cpsw_common * common = am65_ndev_to_common (ndev );
16351596 struct cppi5_host_desc_t * first_desc , * next_desc , * cur_desc ;
16361597 struct am65_cpsw_port * port = am65_ndev_to_port (ndev );
1598+ struct am65_cpsw_tx_swdata * swdata ;
16371599 struct device * dev = common -> dev ;
16381600 struct am65_cpsw_tx_chn * tx_chn ;
16391601 struct netdev_queue * netif_txq ;
16401602 dma_addr_t desc_dma , buf_dma ;
16411603 int ret , q_idx , i ;
1642- void * * swdata ;
16431604 u32 * psdata ;
16441605 u32 pkt_len ;
16451606
@@ -1685,7 +1646,8 @@ static netdev_tx_t am65_cpsw_nuss_ndo_slave_xmit(struct sk_buff *skb,
16851646 k3_udma_glue_tx_dma_to_cppi5_addr (tx_chn -> tx_chn , & buf_dma );
16861647 cppi5_hdesc_attach_buf (first_desc , buf_dma , pkt_len , buf_dma , pkt_len );
16871648 swdata = cppi5_hdesc_get_swdata (first_desc );
1688- * (swdata ) = skb ;
1649+ swdata -> ndev = ndev ;
1650+ swdata -> skb = skb ;
16891651 psdata = cppi5_hdesc_get_psdata (first_desc );
16901652
16911653 /* HW csum offload if enabled */
@@ -3527,6 +3489,10 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
35273489 __be64 id_temp ;
35283490 int ret , i ;
35293491
3492+ BUILD_BUG_ON_MSG (sizeof (struct am65_cpsw_tx_swdata ) > AM65_CPSW_NAV_SW_DATA_SIZE ,
3493+ "TX SW_DATA size exceeds AM65_CPSW_NAV_SW_DATA_SIZE" );
3494+ BUILD_BUG_ON_MSG (sizeof (struct am65_cpsw_swdata ) > AM65_CPSW_NAV_SW_DATA_SIZE ,
3495+ "SW_DATA size exceeds AM65_CPSW_NAV_SW_DATA_SIZE" );
35303496 common = devm_kzalloc (dev , sizeof (struct am65_cpsw_common ), GFP_KERNEL );
35313497 if (!common )
35323498 return - ENOMEM ;
0 commit comments