* Kernel freeze when writing e1000 driver
@ 2013-02-26 16:19 Phani Vadrevu
2013-02-26 16:49 ` Jonathan Neuschäfer
2013-02-26 17:01 ` Valdis.Kletnieks at vt.edu
0 siblings, 2 replies; 3+ messages in thread
From: Phani Vadrevu @ 2013-02-26 16:19 UTC (permalink / raw)
To: kernelnewbies
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);
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Kernel freeze when writing e1000 driver
2013-02-26 16:19 Kernel freeze when writing e1000 driver Phani Vadrevu
@ 2013-02-26 16:49 ` Jonathan Neuschäfer
2013-02-26 17:01 ` Valdis.Kletnieks at vt.edu
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Neuschäfer @ 2013-02-26 16:49 UTC (permalink / raw)
To: kernelnewbies
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Kernel freeze when writing e1000 driver
2013-02-26 16:19 Kernel freeze when writing e1000 driver Phani Vadrevu
2013-02-26 16:49 ` Jonathan Neuschäfer
@ 2013-02-26 17:01 ` Valdis.Kletnieks at vt.edu
1 sibling, 0 replies; 3+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2013-02-26 17:01 UTC (permalink / raw)
To: kernelnewbies
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130226/d590311a/attachment.bin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-02-26 17:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-26 16:19 Kernel freeze when writing e1000 driver Phani Vadrevu
2013-02-26 16:49 ` Jonathan Neuschäfer
2013-02-26 17:01 ` Valdis.Kletnieks at vt.edu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).