Re: [PATCH ref0] net: add Faraday FTMAC100 10/100 Ethernet driver

From: Po-Yu Chuang
Date: Thu Feb 24 2011 - 21:33:22 EST


Hi Eric,

On Fri, Feb 25, 2011 at 1:48 AM, Eric Dumazet <eric.dumazet@xxxxxxxxx> wrote:
> Le jeudi 24 fÃvrier 2011 Ã 18:39 +0100, Eric Dumazet a Ãcrit :
>> Le jeudi 24 fÃvrier 2011 Ã 17:29 +0800, Po-Yu Chuang a Ãcrit :
>> > From: Po-Yu Chuang <ratbert@xxxxxxxxxxxxxxxx>
>> > +
>> > +static bool ftmac100_rx_packet(struct ftmac100 *priv, int *processed)
>> > +{
>> > + Â struct net_device *netdev = priv->netdev;
>> > + Â struct ftmac100_rxdes *rxdes;
>> > + Â struct sk_buff *skb;
>> > + Â struct page *page;
>> > + Â dma_addr_t map;
>> > + Â int length;
>> > +
>> > + Â rxdes = ftmac100_rx_locate_first_segment(priv);
>> > + Â if (!rxdes)
>> > + Â Â Â Â Â return false;
>> > +
>> > + Â if (unlikely(ftmac100_rx_packet_error(priv, rxdes))) {
>> > + Â Â Â Â Â ftmac100_rx_drop_packet(priv);
>> > + Â Â Â Â Â return true;
>> > + Â }
>> > +
>> > + Â /*
>> > + Â Â* It is impossible to get multi-segment packets
>> > + Â Â* because we always provide big enough receive buffers.
>> > + Â Â*/
>> > + Â if (unlikely(!ftmac100_rxdes_last_segment(rxdes)))
>> > + Â Â Â Â Â BUG();
>> > +
>> > + Â /* start processing */
>> > + Â skb = netdev_alloc_skb_ip_align(netdev, ETH_HLEN);
>>
>> Oh I see... You should allocate a bigger head (say... 128 bytes)
>>
>> And copy in it up to 128 bytes of first part... this to avoid upper
>> stack to reallocate skb head (because IP/TCP processing need to get
>> their headers in skb head)
>
> Take a look at drivers/net/niu.c :
>
> #define RX_SKB_ALLOC_SIZE Â 128 + NET_IP_ALIGN
>
> static int niu_process_rx_pkt(...)
> {
> Â Â Â Â...
> Â Â Â Âskb = netdev_alloc_skb(np->dev, RX_SKB_ALLOC_SIZE);
> Â Â Â Â...
> Â Â Â Âwhile (1) {
> Â Â Â Â Â Â Â Â...
> Â Â Â Â Â Â Â Âniu_rx_skb_append(skb, page, off, append_size);
> Â Â Â Â}
> }

Oh I got it.

I will try this and redo the benchmarking.

Thanks,
Po-Yu Chuang
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/