Skip to contentSkip to conversation

hi , question function of net_rx(struct net_device *dev)

DISCUSSION lx 2 participants 2 messages Jul 18, 2014

lore
Share & tools
lore

lx

author
#0 lore raw

hi :
the source code of net_rx(struct net_device *dev) is:
http://lxr.oss.org.cn/source/drivers/net/ethernet/cirrus/cs89x0.c#L670

I can't understand codes about malloc buffer.
##########################################

684         /* Malloc up new buffer. */
685         skb = netdev_alloc_skb(dev, length + 2);
686         if (skb == NULL) {

687 dev->stats.rx_dropped++;
688 return;
689 }
690 skb_reserve(skb, 2); /* longword align L3 header */
##########################################

How to explain 'length + 2' in line of 685? Why add 2 ?

Thank you.

#1 lore raw
Quoted 9 lines · lx

hi :
the source code of net_rx(struct net_device *dev) is:
http://lxr.oss.org.cn/source/drivers/net/ethernet/cirrus/cs89x0.c#L670

I can't understand codes about malloc buffer.
##########################################

684         /* Malloc up new buffer. */
685         skb = netdev_alloc_skb(dev, length + 2);
686         if (skb == NULL) {
Quoted 7 lines

687 dev->stats.rx_dropped++;
688 return;
689 }
690 skb_reserve(skb, 2); /* longword align L3 header */
##########################################

How to explain 'length + 2' in line of 685? Why add 2 ?

That's why it's explained on the line 690.
http://lwn.net/Articles/89597/

Quoted 8 lines

Thank you.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Signature · 2 lines
Regards,
Denis