Subject: kern/15982: smc91cxx driver doesn't work on ARM port.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <bsh@grotto.jp>
List: netbsd-bugs
Date: 03/20/2002 23:59:43
>Number:         15982
>Category:       kern
>Synopsis:       smc91cxx driver doesn't work on ARM port.
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 20 07:00:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Hiroyuki Bessho
>Release:        NetBSD 1.5ZA
>Organization:
	Genetec Corp., Shinjuku-ku, Tokyo.
>Environment:
System: NetBSD nekozame.a.grotto.jp 1.5ZA NetBSD 1.5ZA (NEKOZAME) #18: Thu Feb 7 03:46:21 JST 2002 bsh@nekozame.a.grotto.jp:/u0/work/current/i386/compile/NEKOZAME i386
smc91cxx.c:
     $NetBSD: smc91cxx.c,v 1.37 2001/11/13 13:14:44 lukem Exp $
>Description:
When an ethernet packet is copied from hardware to mbuf,  IP header 
in the packet needs to be aligned to 4-byte boundary for the packet
to be processed correctly by upper layer.

The other NIC drivers take care of it, but sm driver doesn't.
So sm driver doesn't work on CPUs that don't allow misaligned data access,
such as ARM.
>How-To-Repeat:
Run smc91cxx driver on ARM port.
>Fix:
A quick fix is attached.  with this patch, I could use sm driver on
NetBSD/evbarm.

The code is still wrong in that it assumes an mbuf cluster is always big 
enough to hold an ethernet packet, but it's an another story. (and true
for many ports)

*** smc91cxx.c	2001/11/21 03:19:31	1.1.1.8
--- smc91cxx.c	2002/03/20 14:27:58
***************
*** 1020,1025 ****
--- 1062,1075 ----
  	/*
  	 * Pull the packet off the interface.
  	 */
+ 	{
+ 	    /* align the ip header */
+ 	    caddr_t newdata
+ 		= (caddr_t) ALIGN(m->m_data + sizeof(struct ether_header))
+ 		- sizeof(struct ether_header);
+ 	    m->m_data = newdata;
+ 	}
+ 
  	eh = mtod(m, struct ether_header *);
  	data = mtod(m, u_int8_t *);
  	if (packetlen > 1)

>Release-Note:
>Audit-Trail:
>Unformatted: