2024-03-05 05:24:59

by Ratheesh Kannoth

[permalink] [raw]
Subject: Re: [PATCH v1] ps3_gelic_net: Use napi routines for RX SKB

On 2024-03-01 at 13:50:11, Geoff Levand ([email protected]) wrote:
> + if (unlikely(!napi_buff))
> + return -ENOMEM;
>
> - descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size);
> - if (!descr->skb) {
> - descr->hw_regs.payload.dev_addr = 0; /* tell DMAC don't touch memory */
> + descr->skb = napi_build_skb(napi_buff, napi_buff_size);
> +
> + if (unlikely(!descr->skb)) {
> + skb_free_frag(napi_buff);
> return -ENOMEM;
> }
>
> - offset = ((unsigned long)descr->skb->data) &
> - (GELIC_NET_RXBUF_ALIGN - 1);
> - if (offset)
> - skb_reserve(descr->skb, GELIC_NET_RXBUF_ALIGN - offset);
> - /* io-mmu-map the skb */
> - cpu_addr = dma_map_single(ctodev(card), descr->skb->data,
> - GELIC_NET_MAX_FRAME, DMA_FROM_DEVICE);
> - descr->hw_regs.payload.dev_addr = cpu_to_be32(cpu_addr);
> - if (dma_mapping_error(ctodev(card), cpu_addr)) {
> - dev_kfree_skb_any(descr->skb);
> + cpu_addr = dma_map_single(dev, napi_buff, napi_buff_size,
> + DMA_FROM_DEVICE);
> +
> + if (dma_mapping_error(dev, cpu_addr)) {
> + skb_free_frag(napi_buff);
skb->head is freed; dont you need to free skb as well ?

> descr->skb = NULL;