[PATCH net-next v3 5/7] net: axienet: implement NAPI and GRO receive
Robert Hancock
robert.hancock at calian.com
Tue Mar 8 13:13:44 PST 2022
On Mon, 2022-03-07 at 08:53 +0200, Julian Wiedmann wrote:
> On 05.03.22 04:24, Robert Hancock wrote:
> > Implement NAPI and GRO receive. In addition to better performance, this
> > also avoids handling RX packets in hard IRQ context, which reduces the
> > IRQ latency impact to other devices.
> >
> > Signed-off-by: Robert Hancock <robert.hancock at calian.com>
> > ---
> > drivers/net/ethernet/xilinx/xilinx_axienet.h | 6 ++
> > .../net/ethernet/xilinx/xilinx_axienet_main.c | 81 ++++++++++++-------
> > 2 files changed, 59 insertions(+), 28 deletions(-)
> >
>
> [...]
>
> > -static void axienet_recv(struct net_device *ndev)
> > +static int axienet_poll(struct napi_struct *napi, int budget)
> > {
> > u32 length;
> > u32 csumstatus;
> > u32 size = 0;
> > - u32 packets = 0;
> > + int packets = 0;
> > dma_addr_t tail_p = 0;
> > - struct axienet_local *lp = netdev_priv(ndev);
> > - struct sk_buff *skb, *new_skb;
> > struct axidma_bd *cur_p;
> > + struct sk_buff *skb, *new_skb;
> > + struct axienet_local *lp = container_of(napi, struct axienet_local,
> > napi);
> >
> > cur_p = &lp->rx_bd_v[lp->rx_bd_ci];
> >
> > - while ((cur_p->status & XAXIDMA_BD_STS_COMPLETE_MASK)) {
> > + while (packets < budget && (cur_p->status &
> > XAXIDMA_BD_STS_COMPLETE_MASK)) {
> > dma_addr_t phys;
> >
> > /* Ensure we see complete descriptor update */
> > @@ -918,7 +916,7 @@ static void axienet_recv(struct net_device *ndev)
> > DMA_FROM_DEVICE);
> >
> > skb_put(skb, length);
> > - skb->protocol = eth_type_trans(skb, ndev);
> > + skb->protocol = eth_type_trans(skb, lp->ndev);
> > /*skb_checksum_none_assert(skb);*/
> > skb->ip_summed = CHECKSUM_NONE;
> >
> > @@ -937,13 +935,13 @@ static void axienet_recv(struct net_device *ndev)
> > skb->ip_summed = CHECKSUM_COMPLETE;
> > }
> >
> > - netif_rx(skb);
> > + napi_gro_receive(napi, skb);
> >
> > size += length;
> > packets++;
> > }
> >
> > - new_skb = netdev_alloc_skb_ip_align(ndev, lp->max_frm_size);
> > + new_skb = netdev_alloc_skb_ip_align(lp->ndev, lp-
> > >max_frm_size);
> > if (!new_skb)
> > break;
> >
>
> Here you should be able to use napi_alloc_skb() now instead.
Thanks - this patch set was merged to net-next already, but I just submitted a
follow-on patch to add in this change.
--
Robert Hancock
Senior Hardware Designer, Calian Advanced Technologies
www.calian.com
More information about the linux-arm-kernel
mailing list