[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

macppc, src/sys/dev/pci/if_de.c Endian problem



>Submitter-Id:	net
>Originator: 	
>Organization:
	Fujiwara Family at Nagazu	
	
>Confidential:	no
>Synopsis:	macppc, src/sys/dev/pci/if_de.c Endian problem
>Severity:	serious
>Priority:	medium
>Category:	port-macppc
>Class:		sw-bug
>Release:	NetBSD-current source 1999/02/20
>Environment:
	
System: NetBSD harry 1.3I NetBSD 1.3I (DE) #3: Sun Feb 21 23:14:05 JST 1999 root@harry:/usr/src/sys/arch/macppc/compile/DE macppc
         PowerMac clone, actually StarMax 3000/240

>Description:
	
	(1) GENERIC kernel does not have de device activated. (It may be OK)
        (2) My Ethernet/pci card is Sonic made, using DEC 21041 chip. 
            Once de device enabled at config for macppc, endian problem arises.
            No network activities go well, no response at all for network.
        (2-a) I also have found typo at src/sys/dev/pci/if_devar.h  arround line
            1069.
            TULUP_RESTORESPL
               |
               v
            TULIP_RESTORESPL
        (3) ifconfig looks OK, but actually nothing works.
-------------------
root@harry  22:27:38/990221(~)# ifconfig -a
de0: flags=8c63<UP,BROADCAST,NOTRAILERS,RUNNING,OACTIVE,SIMPLEX,MULTICAST> mtu 1500
        address: 00:40:10:09:77:f1
        media: Ethernet autoselect (10baseT)
        status: active
        inet 210.145.40.xxx netmask 0xfffffff0 broadcast 210.145.40.xxx
lo0: flags=8009<UP,LOOPBACK,MULTICAST> mtu 32976
        inet 127.0.0.1 netmask 0xff000000 
ppp0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
ppp1: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
sl0: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 296
sl1: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 296
tun0: flags=10<POINTOPOINT> mtu 1500
tun1: flags=10<POINTOPOINT> mtu 1500
tun2: flags=10<POINTOPOINT> mtu 1500
tun3: flags=10<POINTOPOINT> mtu 1500
-------------------

        (4) at booting it pauses at ypbind starting, and Control-C get 
            proceed further, amd starting needs to timeout to proceed. 
        (5) for ping,
	root@harry  22:28:16/990221(~)# ping 210.145.40.yyy
	PING 210.145.40.yyy (210.145.40.yyy): 56 data bytes
	ping: sendto: Host is down
	..... (repeat)...
	ping: sendto: Host is down
	^C
	----210.145.40.yyy PING Statistics----
	10 packets transmitted, 0 packets received, 100.0% packet loss

>How-To-Repeat:
	
	Get following line in GENERIC, and use DEC card.
	de* at pci? dev ? function ?        # DEC 21x4x-based Ethernet
>Fix:

	
        Use following patch,

--- src/sys/dev/pci/if_de.c.orig	Tue Nov 10 21:18:11 1998
+++ src/sys/dev/pci/if_de.c	Sun Feb 21 22:40:07 1999
@@ -3094,7 +3094,11 @@
 	while (enm != NULL) {
 		if (bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) == 0) {
 		    hash = tulip_mchash(enm->enm_addrlo);
+#if BYTE_ORDER == BIG_ENDIAN
+		    sp[hash >> 4] |= (1 << (hash & 0xF)) << 16;
+#else
 		    sp[hash >> 4] |= 1 << (hash & 0xF);
+#endif
 		} else {
 		    sc->tulip_flags |= TULIP_ALLMULTI;
 		    sc->tulip_flags &= ~(TULIP_WANTHASHONLY|TULIP_WANTHASHPERFECT);
@@ -3108,14 +3112,28 @@
 	 */
 	if ((sc->tulip_flags & TULIP_ALLMULTI) == 0) {
 	    hash = tulip_mchash(etherbroadcastaddr);
+#if BYTE_ORDER == BIG_ENDIAN
+	    sp[hash >> 4] |= (1 << (hash & 0xF)) << 16;
+#else
 	    sp[hash >> 4] |= 1 << (hash & 0xF);
+#endif
 	    if (sc->tulip_flags & TULIP_WANTHASHONLY) {
 		hash = tulip_mchash(sc->tulip_enaddr);
+#if BYTE_ORDER == BIG_ENDIAN
+		sp[hash >> 4] |= (1 << (hash & 0xF)) << 16;
+#else
 		sp[hash >> 4] |= 1 << (hash & 0xF);
+#endif
 	    } else {
+#if BYTE_ORDER == BIG_ENDIAN
+		sp[39] = ((u_int16_t *) sc->tulip_enaddr)[0] << 16;
+		sp[40] = ((u_int16_t *) sc->tulip_enaddr)[1] << 16;
+		sp[41] = ((u_int16_t *) sc->tulip_enaddr)[2] << 16;
+#else
 		sp[39] = ((u_int16_t *) sc->tulip_enaddr)[0]; 
 		sp[40] = ((u_int16_t *) sc->tulip_enaddr)[1]; 
 		sp[41] = ((u_int16_t *) sc->tulip_enaddr)[2];
+#endif
 	    }
 	}
     }
@@ -3129,9 +3147,15 @@
 	    ETHER_FIRST_MULTI(step, TULIP_ETHERCOM(sc), enm);
 	    for (; enm != NULL; idx++) {
 		if (bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) == 0) {
+#if BYTE_ORDER == BIG_ENDIAN
+		    *sp++ = ((u_int16_t *) enm->enm_addrlo)[0] << 16;
+		    *sp++ = ((u_int16_t *) enm->enm_addrlo)[1] << 16;
+		    *sp++ = ((u_int16_t *) enm->enm_addrlo)[2] << 16;
+#else
 		    *sp++ = ((u_int16_t *) enm->enm_addrlo)[0]; 
 		    *sp++ = ((u_int16_t *) enm->enm_addrlo)[1]; 
 		    *sp++ = ((u_int16_t *) enm->enm_addrlo)[2];
+#endif
 		} else {
 		    sc->tulip_flags |= TULIP_ALLMULTI;
 		    break;
@@ -3142,17 +3166,29 @@
 	     * Add the broadcast address.
 	     */
 	    idx++;
+#if BYTE_ORDER == BIG_ENDIAN
+	    *sp++ = 0xFFFF << 16;
+	    *sp++ = 0xFFFF << 16;
+	    *sp++ = 0xFFFF << 16;
+#else
 	    *sp++ = 0xFFFF;
 	    *sp++ = 0xFFFF;
 	    *sp++ = 0xFFFF;
+#endif
 	}
 	/*
 	 * Pad the rest with our hardware address
 	 */
 	for (; idx < 16; idx++) {
+#if BYTE_ORDER == BIG_ENDIAN
+	    *sp++ = ((u_int16_t *) sc->tulip_enaddr)[0] << 16;
+	    *sp++ = ((u_int16_t *) sc->tulip_enaddr)[1] << 16;
+	    *sp++ = ((u_int16_t *) sc->tulip_enaddr)[2] << 16;
+#else
 	    *sp++ = ((u_int16_t *) sc->tulip_enaddr)[0]; 
 	    *sp++ = ((u_int16_t *) sc->tulip_enaddr)[1]; 
 	    *sp++ = ((u_int16_t *) sc->tulip_enaddr)[2];
+#endif
 	}
     }
 #if defined(IFF_ALLMULTI)
@@ -3202,11 +3238,19 @@
 #else
     TULIP_CSR_WRITE(sc, csr_rxlist, TULIP_KVATOPHYS(sc, &sc->tulip_rxinfo.ri_first[0]));
 #endif
+#ifdef macppc	/* XXX only macppc? */
+    TULIP_CSR_WRITE(sc, csr_busmode,
+		    (1 << (TULIP_BURSTSIZE(sc->tulip_unit) + 8))
+		    |TULIP_BUSMODE_CACHE_ALIGN8
+		    |TULIP_BUSMODE_READMULTIPLE
+		    |TULIP_BUSMODE_DESC_BIGENDIAN);
+#else
     TULIP_CSR_WRITE(sc, csr_busmode,
 		    (1 << (TULIP_BURSTSIZE(sc->tulip_unit) + 8))
 		    |TULIP_BUSMODE_CACHE_ALIGN8
 		    |TULIP_BUSMODE_READMULTIPLE
 		    |(BYTE_ORDER != LITTLE_ENDIAN ? TULIP_BUSMODE_BIGENDIAN : 0));
+#endif
 
     sc->tulip_txtimer = 0;
     sc->tulip_txq.ifq_maxlen = TULIP_TXDESCS;
@@ -3823,7 +3867,11 @@
     const char * const *msgp = tulip_status_bits;
     const char *sep;
     u_int32_t mask;
+#ifdef macppc
+    const char thrsh[] = "72|128\0\0\0" "00096|256\0\0\0" "000128|512\0\0" "000160|1024";
+#else
     const char thrsh[] = "72|128\0\0\0" "96|256\0\0\0" "128|512\0\0" "160|1024";
+#endif
 
     csr &= (1 << (sizeof(tulip_status_bits)/sizeof(tulip_status_bits[0]))) - 1;
     printf(TULIP_PRINTF_FMT ": abnormal interrupt:", TULIP_PRINTF_ARGS);
--- src/sys/dev/pci/if_devar.h-ooo	Sun Feb 21 22:46:21 1999
+++ src/sys/dev/pci/if_devar.h	Sun Feb 21 22:45:22 1999
@@ -1060,7 +1060,7 @@
 #ifndef TULIP_RAISESOFTSPL
 #define	TULIP_RAISESOFTSPL()		splnet()
 #endif
-#ifndef TULUP_RESTORESPL
+#ifndef TULIP_RESTORESPL
 #define	TULIP_RESTORESPL(s)		splx(s)
 #endif