diff -ur pci.orig/if_de.c pci/if_de.c --- pci.orig/if_de.c Mon Aug 30 01:31:35 1999 +++ pci/if_de.c Sun Jan 23 21:03:23 2000 @@ -177,7 +177,22 @@ #define TULIP_DEBUG #endif -#if 0 +#if 1 +/* + * This turns on very very verbose debugging print. + */ +#define TULIP_DEBUG_VERBOSE 1 +#endif + +#if 1 +/* + * This turns on manual setting media is allways allowed. + * And when media type is MII, write 0x00000000 to CSR13 and CSR14. + */ +#define TULIP_FORCE_MII_MEDIA_SET 1 +#endif + +#if 1 #define TULIP_PERFSTATS #endif @@ -215,6 +230,11 @@ static void tulip_ifmedia_status(struct ifnet * const ifp, struct ifmediareq *req); #endif /* static void tulip_21140_map_media(tulip_softc_t *sc); */ +#ifdef TULIP_DEBUG_VERBOSE +#define TULIP_DEBUG_VERBOSE_PRINTF(x) printf##x +#else +#define TULIP_DEBUG_VERBOSE_PRINTF(x) +#endif static void tulip_timeout_callback( @@ -322,6 +342,7 @@ if (mi == NULL) return; + TULIP_DEBUG_VERBOSE_PRINTF((TULIP_PRINTF_FMT ": tulip_media_set: setting media to %s. media_type is %s.\n", TULIP_PRINTF_ARGS, tulip_mediums[media], tulip_mediainfo_string[mi->mi_type] )); /* * If we are switching media, make sure we don't think there's * any stale RX activity @@ -364,8 +385,14 @@ } TULIP_CSR_WRITE(sc, csr_sia_general, mi->mi_gpcontrol); TULIP_CSR_WRITE(sc, csr_sia_general, mi->mi_gpdata); + +#ifdef TULIP_FORCE_MII_MEDIA_SET + } else if (mi->mi_type == TULIP_MEDIAINFO_MII ) { +#else /* original code */ } else if (mi->mi_type == TULIP_MEDIAINFO_MII && sc->tulip_probe_state != TULIP_PROBE_INACTIVE) { +#endif /* TULIP_FORCE_MII_MEDIA_SET */ + int idx; if (sc->tulip_features & TULIP_HAVE_SIAGP) { const u_int8_t *dp; @@ -380,6 +407,22 @@ DELAY(10); TULIP_CSR_WRITE(sc, csr_sia_general, (dp[0] + 256 * dp[1]) << 16); } +#ifdef TULIP_FORCE_MII_MEDIA_SET + if ( mi->mi_reset_length == 0 && mi->mi_gpr_length == 0 ) { + TULIP_DEBUG_VERBOSE_PRINTF((TULIP_PRINTF_FMT ": tulip_media_set: Okey. Now tring to reset 21143\n", TULIP_PRINTF_ARGS )); + DELAY(50); + TULIP_CSR_WRITE(sc, csr_sia_general, 0); + TULIP_DEBUG_VERBOSE_PRINTF((TULIP_PRINTF_FMT ": tulip_media_set: TULIP_CSR_WRITE(CSR15, %08x)\n", TULIP_PRINTF_ARGS, 0 )); + DELAY(50); + TULIP_CSR_WRITE(sc, csr_sia_tx_rx, 0); + TULIP_DEBUG_VERBOSE_PRINTF((TULIP_PRINTF_FMT ": tulip_media_set: TULIP_CSR_WRITE(CSR14, %08x)\n", TULIP_PRINTF_ARGS, 0 )); + DELAY(50); + TULIP_CSR_WRITE(sc, csr_sia_connectivity, 0); + TULIP_DEBUG_VERBOSE_PRINTF((TULIP_PRINTF_FMT ": tulip_media_set: TULIP_CSR_WRITE(CSR13, %08x)\n", TULIP_PRINTF_ARGS, 0 )); + } else { + TULIP_DEBUG_VERBOSE_PRINTF((TULIP_PRINTF_FMT ": tulip_media_set: Humm. There is some reset data in ROM. Skipping force reset sequence.\n", TULIP_PRINTF_ARGS )); + } +#endif /* TULIP_FORCE_MII_MEDIA_SET */ } else { for (idx = 0; idx < mi->mi_reset_length; idx++) { DELAY(10); @@ -451,12 +494,21 @@ sc->tulip_flags &= ~(TULIP_TXPROBE_ACTIVE|TULIP_TRYNWAY); if (sc->tulip_flags & TULIP_INRESET) { tulip_media_set(sc, sc->tulip_media); - } else if (sc->tulip_probe_media != sc->tulip_media) { + } + /* + * Condition check was removed. When probed media with + * autonegotiation is not correct, I want to setup media type with + * ifconfig command manually. + */ +#ifndef TULIP_FORCE_MII_MEDIA_SET + else if (sc->tulip_probe_media != sc->tulip_media) { /* * No reason to change media if we have the right media. */ + TULIP_DEBUG_VERBOSE_PRINTF((TULIP_PRINTF_FMT ": tulip_linkup: No reason to change media if we have the right media. I will not change media.\n", TULIP_PRINTF_ARGS)); tulip_reset(sc); } +#endif /* not TULIP_FORCE_MI_MEDIA_SET */ tulip_init(sc); } @@ -1485,6 +1537,7 @@ loudprintf(TULIP_PRINTF_FMT "(phy%d): autonegotiation complete: 0x%04x\n", TULIP_PRINTF_ARGS, phyaddr, data); #endif + TULIP_DEBUG_VERBOSE_PRINTF((TULIP_PRINTF_FMT ": autonegotiation compelete!!! data:%08x\n", TULIP_PRINTF_ARGS, data)); data = (data << 6) & status; if (!tulip_mii_map_abilities(sc, data)) sc->tulip_flags &= ~TULIP_DIDNWAY; @@ -2083,9 +2136,14 @@ } #define tulip_mchash(mca) (tulip_crc32(mca, 6) & 0x1FF) -#define tulip_srom_crcok(databuf) ( \ +#define tulip_srom_crcok(databuf) \ + (tulip_srom_crcok128(databuf) || tulip_srom_crcok96(databuf)) +#define tulip_srom_crcok128(databuf) ( \ ((tulip_crc32(databuf, 126) & 0xFFFFU) ^ 0xFFFFU) == \ ((databuf)[126] | ((databuf)[127] << 8))) +#define tulip_srom_crcok96(databuf) ( \ + ((tulip_crc32(databuf, 94) & 0xFFFFU) ^ 0xFFFFU) == \ + ((databuf)[94] | ((databuf)[95] << 8))) static unsigned tulip_crc32( diff -ur pci.orig/if_devar.h pci/if_devar.h --- pci.orig/if_devar.h Mon Aug 30 01:31:36 1999 +++ pci/if_devar.h Sun Jan 9 02:22:23 2000 @@ -269,6 +269,17 @@ #define TULIP_SROM_ATTR_POWERUP 0x0800 #define TULIP_SROM_ATTR_NOLINKPASS 0x1000 +#ifdef TULIP_DEBUG_VERBOSE +static char *tulip_mediainfo_string[] = { + "TULIP_MEDIAINFO_NONE", + "TULIP_MEDIAINFO_SIA", + "TULIP_MEDIAINFO_GPR", + "TULIP_MEDIAINFO_MII", + "TULIP_MEDIAINFO_RESET", + "TULIP_MEDIAINFO_SYM" +}; +#endif + typedef struct { enum { TULIP_MEDIAINFO_NONE,