Skip to content

Commit bc609f9

Browse files
WeiFang-NXPPaolo Abeni
authored andcommitted
net: fec: improve fec_enet_rx_queue()
This patch has made the following adjustments to fec_enet_rx_queue(). 1. The function parameters are modified to maintain the same style as subsequently added XDP-related interfaces. 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. Replace variable cbd_bufaddr with dma. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20260205085742.2685134-6-wei.fang@nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 54a6e86 commit bc609f9

1 file changed

Lines changed: 15 additions & 20 deletions

File tree

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,26 +1840,25 @@ static struct sk_buff *fec_build_skb(struct fec_enet_private *fep,
18401840
* not been given to the system, we just set the empty indicator,
18411841
* effectively tossing the packet.
18421842
*/
1843-
static int
1844-
fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
1843+
static int fec_enet_rx_queue(struct fec_enet_private *fep,
1844+
u16 queue, int budget)
18451845
{
1846-
struct fec_enet_private *fep = netdev_priv(ndev);
1847-
struct fec_enet_priv_rx_q *rxq;
1848-
struct bufdesc *bdp;
1849-
unsigned short status;
1850-
struct sk_buff *skb;
1851-
ushort pkt_len;
1852-
int pkt_received = 0;
1853-
int index = 0;
1854-
bool need_swap = fep->quirks & FEC_QUIRK_SWAP_FRAME;
18551846
u32 data_start = FEC_ENET_XDP_HEADROOM + fep->rx_shift;
1847+
struct fec_enet_priv_rx_q *rxq = fep->rx_queue[queue];
18561848
struct bpf_prog *xdp_prog = READ_ONCE(fep->xdp_prog);
1849+
bool need_swap = fep->quirks & FEC_QUIRK_SWAP_FRAME;
18571850
u32 ret, xdp_result = FEC_ENET_XDP_PASS;
1851+
struct net_device *ndev = fep->netdev;
1852+
struct bufdesc *bdp = rxq->bd.cur;
18581853
u32 sub_len = 4 + fep->rx_shift;
18591854
int cpu = smp_processor_id();
1855+
int pkt_received = 0;
1856+
u16 status, pkt_len;
1857+
struct sk_buff *skb;
18601858
struct xdp_buff xdp;
18611859
struct page *page;
1862-
__fec32 cbd_bufaddr;
1860+
dma_addr_t dma;
1861+
int index;
18631862

18641863
#if defined(CONFIG_COLDFIRE) && !defined(CONFIG_COLDFIRE_COHERENT_DMA)
18651864
/*
@@ -1868,12 +1867,10 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
18681867
*/
18691868
flush_cache_all();
18701869
#endif
1871-
rxq = fep->rx_queue[queue_id];
18721870

18731871
/* First, grab all of the stats for the incoming packet.
18741872
* These get messed up if we get called due to a busy condition.
18751873
*/
1876-
bdp = rxq->bd.cur;
18771874
xdp_init_buff(&xdp, PAGE_SIZE << fep->pagepool_order, &rxq->xdp_rxq);
18781875

18791876
while (!((status = fec16_to_cpu(bdp->cbd_sc)) & BD_ENET_RX_EMPTY)) {
@@ -1882,7 +1879,7 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
18821879
break;
18831880
pkt_received++;
18841881

1885-
writel(FEC_ENET_RXF_GET(queue_id), fep->hwp + FEC_IEVENT);
1882+
writel(FEC_ENET_RXF_GET(queue), fep->hwp + FEC_IEVENT);
18861883

18871884
/* Check for errors. */
18881885
status ^= BD_ENET_RX_LAST;
@@ -1896,15 +1893,13 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
18961893

18971894
index = fec_enet_get_bd_index(bdp, &rxq->bd);
18981895
page = rxq->rx_buf[index];
1899-
cbd_bufaddr = bdp->cbd_bufaddr;
1896+
dma = fec32_to_cpu(bdp->cbd_bufaddr);
19001897
if (fec_enet_update_cbd(rxq, bdp, index)) {
19011898
ndev->stats.rx_dropped++;
19021899
goto rx_processing_done;
19031900
}
19041901

1905-
dma_sync_single_for_cpu(&fep->pdev->dev,
1906-
fec32_to_cpu(cbd_bufaddr),
1907-
pkt_len,
1902+
dma_sync_single_for_cpu(&fep->pdev->dev, dma, pkt_len,
19081903
DMA_FROM_DEVICE);
19091904
prefetch(page_address(page));
19101905

@@ -1980,7 +1975,7 @@ static int fec_enet_rx(struct net_device *ndev, int budget)
19801975

19811976
/* Make sure that AVB queues are processed first. */
19821977
for (i = fep->num_rx_queues - 1; i >= 0; i--)
1983-
done += fec_enet_rx_queue(ndev, i, budget - done);
1978+
done += fec_enet_rx_queue(fep, i, budget - done);
19841979

19851980
return done;
19861981
}

0 commit comments

Comments
 (0)