LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 03-12-2009, 06:27 PM   #1
AustinMarton
Member
 
Registered: May 2007
Location: New Zealand
Distribution: Fedora at home, Ubuntu 10.04 at work
Posts: 88

Rep: Reputation: 16
Question Ethernet driver - kernel crashes after passing a few Ethernet frames to upper layers


Hi there, I am _still_ working on an uClinux Ethernet driver on the NiosII on a Cyclone2. It is similar to the DM9000 driver.

I have finally got the receive function working correctly, but it seems to have an intermittent problem, after receiving a number of frames successfully, the kernel crashes.

If I remove "netif_rx(skb)" the error does not occur. Are the upper layers not handling my frames properly? Are my frames some how malformed and therefore creating a problem when the reach the higher layers of the TCP/IP stack?

In the last few trials I did, when it crashes it happens after 3, 20, 143, 14, 2, 10 packets were received. I then get the error:
Quote:
Bad page state in process 'swapper'
page:48be64e2 flags:0x41fd0000 mapping:00000000 mapcount:12477673 count:0
Trying to fix it up, but a reboot is needed
Backtrace:
Stack from 009bfe6c:<0>
<0> 00000001<0> 00840c90<0> 41fd0000<0> 00000000<0> 00be64e9<0> 00000000<0> 48be64e2<0> 00843a18<0>
<0> 00000400<0> 00c25000<0> 009af7b4<0> 00ed7a00<0> 48be64e2<0> 00843ae0<0> 00847280<0> 00000305<0>
<0> 009093e8<0> 00ed7a00<0> 009af79c<0> 009091ac<0> 00ed7a00<0> 009091cc<0> 00ed7a00<0> 009092ac<0>
<0> 00912e10<0> 009b6594<0> 009af780<0> 00000040<0> ffffe282<0> 009af768<0> 00000001<0> 009af768<0>
<0> 00912ed4<0> 009b6594<0> ffffe282<0> 009af774<0> 009af788<0> 0000012c<0> 00000000<0> 00000040<0>
<0> 009af780<0> 009130b8<0> deadbeef<0> deadbeef<0> 009ab3e8<0> 0000000a<0> 00000001<0> 009b7810<0>
Call Trace:<0>
<0> [<00815dd8>]<0> [<00815ebc>]<0> [<008161b8>]<0> [<008014a4>]<0>
<0> [<008009cc>]<0> [<00801bf4>]<0> [<00801bfc>]<0> [<009872ac>]<0>
<0> [<008000a4>]<0>
Bad page state in process 'swapper'
page:98bb0681 flags:0x00000018 mapping:00cc8408 mapcount:0 count:0
Trying to fix it up, but a reboot is needed
Backtrace:
Stack from 009bfe6c:<0>
<0> 00000001<0> 00840c90<0> 00000018<0> 00cc8408<0> 00000000<0> 00000000<0> 98bb0681<0> 00843a18<0>
<0> 00000400<0> 00c25000<0> 009af7b4<0> 00ed7a00<0> 98bb0681<0> 00843ae0<0> 00847280<0> 00000382<0>
<0> 009093e8<0> 00ed7a00<0> 009af79c<0> 009091ac<0> 00ed7a00<0> 009091cc<0> 00ed7a00<0> 009092ac<0>
<0> 00912e10<0> 009b6594<0> 009af780<0> 00000040<0> ffffe282<0> 009af768<0> 00000001<0> 009af768<0>
<0> 00912ed4<0> 009b6594<0> ffffe282<0> 009af774<0> 009af788<0> 0000012c<0> 00000000<0> 00000040
This is the basic code for my receive function with the hardware specific code removed.
Code:
void hw_rx2(struct net_device *dev)
{
	struct sk_buff *skb;
	uint8_t *rdptr;
      ...

	/* Recieve frame header */
      ...

	if ((skb = dev_alloc_skb(rxLen+2)) == NULL)	{
		printk("Cannot allocate socket buffer\n");
		goto ERROR;
	}
	skb_reserve(skb, 2);
	rdptr = (uint8_t *) skb_put(skb, rxLen+2);
	
	/* Recieve Ethernet frame */
	while (1) { /* break based on frame length, will always be in valid range */

		for (i=0;i<4;i++)	{ /* Read 8 bytes of Ethernet frame. */	

			/* READ WORD */
                        rxWord = ...

			count++;
			if (count > rxLen) { /* if at end of frame */
					goto FCS;
			}
			else	{
				memcpy(rdptr, &rxWord, 16);   /* copy 2 bytes to socket buffer */
				rdptr += 2;	/* increment pointer by 2 bytes */
			}
		}
		while (/* Poll status register until data ready to read */)
	} 

FCS:
	/* READ FRAME CHECK SEQUENCE */
      ...

	skb->csum = FCS1 + FCS2;
	dev->stats.rx_bytes += rxLen;	

	/* pass to upper layer */
	skb->protocol = eth_type_trans(skb, dev); 
	netif_rx(skb);
	dev->stats.rx_packets++;	

DONE:
	/* Write to CMD_STATUS_REG to indicate the end of the frame. */
      ...
	return;
}
Any ideas?

Cheers,
Austin.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PCMCIA ethernet driver loaded --now what? How do I access ethernet? KWTm Linux - Hardware 3 07-10-2006 01:07 PM
kernel 2.6.7 nvidia ethernet driver Da_Necromancer Linux - Software 15 10-10-2004 01:09 PM
When I try to make my ethernet driver under kernel 2.6.8.1 .. error. em0ng Linux - Software 0 09-26-2004 05:59 AM
ethernet to ethernet frames alaios Linux - Networking 0 08-28-2004 04:32 PM
How to install driver Ethernet card in Linux kernel 2.4.10 truong van lich Linux - Software 1 07-29-2003 02:57 AM


All times are GMT -5. The time now is 12:45 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration