Kernel freeze when writing e1000 driver
Hi list, I am writing a network driver for the e1000 card. While doing the receive part, I saw that the kernel freezes whenever it reaches the netif_rx(skb) call. I was able to reproduce the same error when using a bare bones driver where I hard codde the skb data. Please see the code of that test function below. The data is that of a TCP packet (with IP and Ethernet headers). When I load the driver into a Virtual Machine, I see the VM process taking above 100% CPU in the host machine. The OS does not respond to input after this. If I comment out the netif_rx line it seems to be working fine. Thanks, Phani static void test_skb(void){ unsigned char t[] = {0x52,0x54,0x00,0x12,0x34,0x56,0x52,0x55,0x0a,0x00,0x02,0x02,0x08,0x00,0x45,0x00,0x00,0x2c,0x00,0x1c,0x00,0x00,0x40,0x06,0x62,0xa0,0x0a,0x00,0x02,0x02,0x0a,0x00,0x02,0x0f,0xc6,0x1a,0x1e,0xdb,0x4c,0x81,0x18,0x01,0x00,0x00,0x00,0x00,0x60,0x02,0x22,0x38,0x14,0x66,0x00,0x00,0x02,0x04,0x05,0xb4}; int len = 58; struct sk_buff *skb; skb = dev_alloc_skb (len + 2); if (skb) { printk("Allocated skb buffer\n"); memcpy(skb_put(skb, len), t, len); printk("step1\n"); //skb_put(skb, len); //skb->dev = dev; printk("step2\n"); //skb->protocol = eth_type_trans(skb, dev); skb->protocol = ETH_P_IP; printk("step3\n"); skb->ip_summed = CHECKSUM_UNNECESSARY; printk("step4\n"); //netif_rx (skb); printk("step5\n"); } printk(KERN_INFO"All Done"); if(skb){ dev_kfree_skb(skb); } }
On Tue, Feb 26, 2013 at 11:19:18AM -0500, Phani Vadrevu wrote:
unsigned char t[] = {0x52,0x54,0x00,0x12,0x34,0x56,0x52,0x55,0x0a,0x00,0x02,0x02,0x08,0x00,0x45,0x00,0x00,0x2c,0x00,0x1c,0x00,0x00,0x40,0x06,0x62,0xa0,0x0a,0x00,0x02,0x02,0x0a,0x00,0x02,0x0f,0xc6,0x1a,0x1e,0xdb,0x4c,0x81,0x18,0x01,0x00,0x00,0x00,0x00,0x60,0x02,0x22,0x38,0x14,0x66,0x00,0x00,0x02,0x04,0x05,0xb4}; int len = 58;
Although it won't solve the problem at hand, I suggest using "sizeof" here. Thanks, Jonathan Neuschäfer
On Tue, 26 Feb 2013 11:19:18 -0500, Phani Vadrevu said:
I am writing a network driver for the e1000 card. While doing the receive part, I saw that the kernel freezes whenever it reaches the netif_rx(skb) call. I was able to reproduce the same error when using a bare bones driver where I hard codde the skb data.
There's a known-working driver in the kernel source tree for this device already. Start by looking at what data it's placed in the skb when it calls that routine, and how it differs from what you filled in. For bonus points - lose the 'unsigned char t[]' array and replace it with a bunch of explicit 'skb->foo = bar' statements. In particular, that assures that you haven't missed a 0x15 27 bytes into the array, or failed to allow alignment padding bytes.
participants (3)
-
Jonathan Neuschäfer -
Phani Vadrevu -
Valdis.Kletnieks@vt.edu