@@ -830,19 +830,19 @@ static void am65_cpsw_nuss_tx_cleanup(void *data, dma_addr_t desc_dma)
830
830
{
831
831
struct am65_cpsw_tx_chn * tx_chn = data ;
832
832
enum am65_cpsw_tx_buf_type buf_type ;
833
+ struct am65_cpsw_tx_swdata * swdata ;
833
834
struct cppi5_host_desc_t * desc_tx ;
834
835
struct xdp_frame * xdpf ;
835
836
struct sk_buff * skb ;
836
- void * * swdata ;
837
837
838
838
desc_tx = k3_cppi_desc_pool_dma2virt (tx_chn -> desc_pool , desc_dma );
839
839
swdata = cppi5_hdesc_get_swdata (desc_tx );
840
840
buf_type = am65_cpsw_nuss_buf_type (tx_chn , desc_dma );
841
841
if (buf_type == AM65_CPSW_TX_BUF_TYPE_SKB ) {
842
- skb = * ( swdata ) ;
842
+ skb = swdata -> skb ;
843
843
dev_kfree_skb_any (skb );
844
844
} else {
845
- xdpf = * ( swdata ) ;
845
+ xdpf = swdata -> xdpf ;
846
846
xdp_return_frame (xdpf );
847
847
}
848
848
@@ -1099,10 +1099,10 @@ static int am65_cpsw_xdp_tx_frame(struct net_device *ndev,
1099
1099
struct am65_cpsw_common * common = am65_ndev_to_common (ndev );
1100
1100
struct am65_cpsw_port * port = am65_ndev_to_port (ndev );
1101
1101
struct cppi5_host_desc_t * host_desc ;
1102
+ struct am65_cpsw_tx_swdata * swdata ;
1102
1103
struct netdev_queue * netif_txq ;
1103
1104
dma_addr_t dma_desc , dma_buf ;
1104
1105
u32 pkt_len = xdpf -> len ;
1105
- void * * swdata ;
1106
1106
int ret ;
1107
1107
1108
1108
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,
1132
1132
cppi5_hdesc_attach_buf (host_desc , dma_buf , pkt_len , dma_buf , pkt_len );
1133
1133
1134
1134
swdata = cppi5_hdesc_get_swdata (host_desc );
1135
- * (swdata ) = xdpf ;
1135
+ swdata -> ndev = ndev ;
1136
+ swdata -> xdpf = xdpf ;
1136
1137
1137
1138
/* Report BQL before sending the packet */
1138
1139
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)
1435
1436
return num_rx ;
1436
1437
}
1437
1438
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
-
1484
1439
static void am65_cpsw_nuss_tx_wake (struct am65_cpsw_tx_chn * tx_chn , struct net_device * ndev ,
1485
1440
struct netdev_queue * netif_txq )
1486
1441
{
@@ -1503,6 +1458,8 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
1503
1458
{
1504
1459
bool single_port = AM65_CPSW_IS_CPSW2G (common );
1505
1460
enum am65_cpsw_tx_buf_type buf_type ;
1461
+ struct am65_cpsw_tx_swdata * swdata ;
1462
+ struct cppi5_host_desc_t * desc_tx ;
1506
1463
struct device * dev = common -> dev ;
1507
1464
struct am65_cpsw_tx_chn * tx_chn ;
1508
1465
struct netdev_queue * netif_txq ;
@@ -1533,15 +1490,18 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
1533
1490
break ;
1534
1491
}
1535
1492
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 ;
1536
1497
buf_type = am65_cpsw_nuss_buf_type (tx_chn , desc_dma );
1537
1498
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 ) ;
1540
1501
pkt_len = skb -> len ;
1541
1502
napi_consume_skb (skb , budget );
1542
1503
} else {
1543
- xdpf = am65_cpsw_nuss_tx_compl_packet_xdp (common , tx_chn ,
1544
- desc_dma , & ndev );
1504
+ xdpf = swdata -> xdpf ;
1545
1505
pkt_len = xdpf -> len ;
1546
1506
if (buf_type == AM65_CPSW_TX_BUF_TYPE_XDP_TX )
1547
1507
xdp_return_frame_rx_napi (xdpf );
@@ -1551,7 +1511,8 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
1551
1511
1552
1512
total_bytes += pkt_len ;
1553
1513
num_tx ++ ;
1554
-
1514
+ am65_cpsw_nuss_xmit_free (tx_chn , desc_tx );
1515
+ dev_sw_netstats_tx_add (ndev , 1 , pkt_len );
1555
1516
if (!single_port ) {
1556
1517
/* as packets from multi ports can be interleaved
1557
1518
* 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,
1634
1595
struct am65_cpsw_common * common = am65_ndev_to_common (ndev );
1635
1596
struct cppi5_host_desc_t * first_desc , * next_desc , * cur_desc ;
1636
1597
struct am65_cpsw_port * port = am65_ndev_to_port (ndev );
1598
+ struct am65_cpsw_tx_swdata * swdata ;
1637
1599
struct device * dev = common -> dev ;
1638
1600
struct am65_cpsw_tx_chn * tx_chn ;
1639
1601
struct netdev_queue * netif_txq ;
1640
1602
dma_addr_t desc_dma , buf_dma ;
1641
1603
int ret , q_idx , i ;
1642
- void * * swdata ;
1643
1604
u32 * psdata ;
1644
1605
u32 pkt_len ;
1645
1606
@@ -1685,7 +1646,8 @@ static netdev_tx_t am65_cpsw_nuss_ndo_slave_xmit(struct sk_buff *skb,
1685
1646
k3_udma_glue_tx_dma_to_cppi5_addr (tx_chn -> tx_chn , & buf_dma );
1686
1647
cppi5_hdesc_attach_buf (first_desc , buf_dma , pkt_len , buf_dma , pkt_len );
1687
1648
swdata = cppi5_hdesc_get_swdata (first_desc );
1688
- * (swdata ) = skb ;
1649
+ swdata -> ndev = ndev ;
1650
+ swdata -> skb = skb ;
1689
1651
psdata = cppi5_hdesc_get_psdata (first_desc );
1690
1652
1691
1653
/* HW csum offload if enabled */
@@ -3527,6 +3489,10 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
3527
3489
__be64 id_temp ;
3528
3490
int ret , i ;
3529
3491
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" );
3530
3496
common = devm_kzalloc (dev , sizeof (struct am65_cpsw_common ), GFP_KERNEL );
3531
3497
if (!common )
3532
3498
return - ENOMEM ;
0 commit comments