Ethernet device driver hardware rx- am I doing the right thing with my socket buffer?
Hi there,
I am working on an Ethernet device driver for uClinux, currently I am not sure about the hardware receive function, this is what I do: define a socket buffer: Code:
struct sk_buff *skb; if all okay, allocate memory for the skb: Code:
if (goodPacket && ((skb = dev_alloc_skb(rxLen+x)) != NULL)) { ... Code:
skb_reserve(skb, 2); Code:
rdptr = (uint8_t *) skb_put(skb, rxLen+x); Code:
memcpy(rdptr, &rxWord, 16); /* copy 2 bytes to socket buffer */ Code:
skb->dev = dev; Code:
ret = netif_rx(skb); Does this look correct? I do not know what to put for the offset to add to rxLen ("x"). If I put zero I get Code:
skb_over_panic: text:fb00005e len:240 put:240 head:00bd6000 data:00bd6012 tail:0xbd6102 end:0xbd6100 dev:eth0 netif_rx is returning 0 which indicates success, but I don't see the packet count increase in ifconfig. |
x=2. That's the same 2 you add to skb_reserve. Explanation: IP packet in the stack must be aligned. It doesn't match the 'raw' Ethernet packet you have. It means that you need to reserve 2 octets more and copy the data in such a way that the IP packet is formed as it should be.
|
All times are GMT -5. The time now is 07:23 AM. |