From: Stanislaw Gruszka
Sent: 30 July 2019 10:36
...
len = pkt_stat.pkt_len + pkt_offset;
skb = dev_alloc_skb(len);
if (WARN_ONCE(!skb, "rx routine starvation\n")) goto next_rp;
/* put the DMA data including rx_desc from phy to new skb */
skb_put_data(new, skb->data, new_len);
skb_put_data(skb, rx_desc, len);
Coping big packets it quite inefficient. What drivers usually do is copy only for small packets and for big ones allocate new rx buf (drop packet alloc if fail) and pas old buf to network stack via skb_add_rx_frag(). See iwlmvm as example.
If you have to do iommu setup/teardown then the breakeven point for (not) copying may be surprisingly large. You do need to do the measurements on a range of hardware. Coping is also likely to affect the L1 cache - unless you can copy quickly without polluting the cache.
It is all 'swings and roundabouts'.
David
- Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)