Skip to content

Commit fee723a

Browse files
WeiFang-NXPPaolo Abeni
authored andcommitted
net: fec: improve fec_enet_tx_queue()
To support AF_XDP zero-copy mode in the subsequent patch, the following adjustments have been made to fec_tx_queue(). 1. Change the parameters of fec_tx_queue(). 2. Some variables are initialized at the time of declaration, and the order of local variables is updated to follow the reverse xmas tree style. 3. Remove the variable xdpf and add the variable tx_buf. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20260205085742.2685134-15-wei.fang@nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent a2ae70c commit fee723a

1 file changed

Lines changed: 17 additions & 26 deletions

File tree

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,27 +1475,18 @@ fec_enet_hwtstamp(struct fec_enet_private *fep, unsigned ts,
14751475
hwtstamps->hwtstamp = ns_to_ktime(ns);
14761476
}
14771477

1478-
static void
1479-
fec_enet_tx_queue(struct net_device *ndev, u16 queue_id, int budget)
1478+
static void fec_enet_tx_queue(struct fec_enet_private *fep,
1479+
u16 queue, int budget)
14801480
{
1481-
struct fec_enet_private *fep;
1482-
struct xdp_frame *xdpf;
1483-
struct bufdesc *bdp;
1481+
struct netdev_queue *nq = netdev_get_tx_queue(fep->netdev, queue);
1482+
struct fec_enet_priv_tx_q *txq = fep->tx_queue[queue];
1483+
struct net_device *ndev = fep->netdev;
1484+
struct bufdesc *bdp = txq->dirty_tx;
1485+
int index, frame_len, entries_free;
1486+
struct fec_tx_buffer *tx_buf;
14841487
unsigned short status;
1485-
struct sk_buff *skb;
1486-
struct fec_enet_priv_tx_q *txq;
1487-
struct netdev_queue *nq;
1488-
int index = 0;
1489-
int entries_free;
1488+
struct sk_buff *skb;
14901489
struct page *page;
1491-
int frame_len;
1492-
1493-
fep = netdev_priv(ndev);
1494-
1495-
txq = fep->tx_queue[queue_id];
1496-
/* get next bdp of dirty_tx */
1497-
nq = netdev_get_tx_queue(ndev, queue_id);
1498-
bdp = txq->dirty_tx;
14991490

15001491
/* get next bdp of dirty_tx */
15011492
bdp = fec_enet_get_nextdesc(bdp, &txq->bd);
@@ -1508,9 +1499,10 @@ fec_enet_tx_queue(struct net_device *ndev, u16 queue_id, int budget)
15081499
break;
15091500

15101501
index = fec_enet_get_bd_index(bdp, &txq->bd);
1502+
tx_buf = &txq->tx_buf[index];
15111503
frame_len = fec16_to_cpu(bdp->cbd_datlen);
15121504

1513-
switch (txq->tx_buf[index].type) {
1505+
switch (tx_buf->type) {
15141506
case FEC_TXBUF_T_SKB:
15151507
if (bdp->cbd_bufaddr &&
15161508
!IS_TSO_HEADER(txq, fec32_to_cpu(bdp->cbd_bufaddr)))
@@ -1519,7 +1511,7 @@ fec_enet_tx_queue(struct net_device *ndev, u16 queue_id, int budget)
15191511
frame_len, DMA_TO_DEVICE);
15201512

15211513
bdp->cbd_bufaddr = cpu_to_fec32(0);
1522-
skb = txq->tx_buf[index].buf_p;
1514+
skb = tx_buf->buf_p;
15231515
if (!skb)
15241516
goto tx_buf_done;
15251517

@@ -1550,19 +1542,18 @@ fec_enet_tx_queue(struct net_device *ndev, u16 queue_id, int budget)
15501542
if (unlikely(!budget))
15511543
goto out;
15521544

1553-
xdpf = txq->tx_buf[index].buf_p;
15541545
dma_unmap_single(&fep->pdev->dev,
15551546
fec32_to_cpu(bdp->cbd_bufaddr),
15561547
frame_len, DMA_TO_DEVICE);
15571548
bdp->cbd_bufaddr = cpu_to_fec32(0);
1558-
xdp_return_frame_rx_napi(xdpf);
1549+
xdp_return_frame_rx_napi(tx_buf->buf_p);
15591550
break;
15601551
case FEC_TXBUF_T_XDP_TX:
15611552
if (unlikely(!budget))
15621553
goto out;
15631554

15641555
bdp->cbd_bufaddr = cpu_to_fec32(0);
1565-
page = txq->tx_buf[index].buf_p;
1556+
page = tx_buf->buf_p;
15661557
/* The dma_sync_size = 0 as XDP_TX has already synced
15671558
* DMA for_device
15681559
*/
@@ -1599,9 +1590,9 @@ fec_enet_tx_queue(struct net_device *ndev, u16 queue_id, int budget)
15991590
if (status & BD_ENET_TX_DEF)
16001591
ndev->stats.collisions++;
16011592

1602-
txq->tx_buf[index].buf_p = NULL;
1593+
tx_buf->buf_p = NULL;
16031594
/* restore default tx buffer type: FEC_TXBUF_T_SKB */
1604-
txq->tx_buf[index].type = FEC_TXBUF_T_SKB;
1595+
tx_buf->type = FEC_TXBUF_T_SKB;
16051596

16061597
tx_buf_done:
16071598
/* Make sure the update to bdp and tx_buf are performed
@@ -1637,7 +1628,7 @@ static void fec_enet_tx(struct net_device *ndev, int budget)
16371628

16381629
/* Make sure that AVB queues are processed first. */
16391630
for (i = fep->num_tx_queues - 1; i >= 0; i--)
1640-
fec_enet_tx_queue(ndev, i, budget);
1631+
fec_enet_tx_queue(fep, i, budget);
16411632
}
16421633

16431634
static int fec_enet_update_cbd(struct fec_enet_priv_rx_q *rxq,

0 commit comments

Comments
 (0)