Date: Fri, 31 Oct 2003 08:31:11 -0800 (PST) From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 40978 for review Message-ID: <200310311631.h9VGVBHo083557@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=40978 Change 40978 by sam@sam_ebb on 2003/10/31 08:30:54 minor changes for forthcoming HAL update: verify the ABI checksum, print the mac, phy, and radio h/w revs at attach time (maybe should be under bootverbose) Affected files ... .. //depot/projects/netperf/sys/dev/ath/if_ath.c#29 edit Differences ... ==== //depot/projects/netperf/sys/dev/ath/if_ath.c#29 (text+ko) ==== @@ -174,6 +174,33 @@ #define DPRINTF2(X) #endif +/* + * Calculate a "checksum" that the driver can use to + * check for ABI compatibility. We just sum the offsets + * of all the function pointers which are assumed to + * start with ah_getRateTable and continue sequentially + * to the end of the structure. If a new method is added + * or moved this will be detected. This will not, however + * catch methods being moved around or some number added + * while an equal number are replaced, or arguments being + * changed, or lots of other things. + * + * This is stopgap. Improvements are welcome. + */ +static u_int32_t +ath_calcsum(void) +{ + u_int32_t sum = 0; + u_int32_t off; + + off = offsetof(struct ath_hal, ah_getRateTable); + while (off < sizeof(struct ath_hal)) { + sum += off; + off += sizeof(void (*)(void)); + } + return sum; +} + int ath_attach(u_int16_t devid, struct ath_softc *sc) { @@ -196,6 +223,23 @@ error = ENXIO; goto bad; } + if (ah->ah_checksum != ath_calcsum()) { + if_printf(ifp, "HAL ABI mismatch detected (%u != %u)\n", + ah->ah_checksum, ath_calcsum()); + error = ENXIO; + goto bad; + } + if_printf(ifp, "mac %d.%d phy %d.%d", + ah->ah_macVersion, ah->ah_macRev, + ah->ah_phyRev >> 4, ah->ah_phyRev & 0xf); + if (ah->ah_analog5GhzRev) + printf(" 5ghz radio %d.%d", + ah->ah_analog5GhzRev >> 4, ah->ah_analog5GhzRev & 0xf); + if (ah->ah_analog2GhzRev) + printf(" 2ghz radio %d.%d", + ah->ah_analog2GhzRev >> 4, ah->ah_analog2GhzRev & 0xf); + printf("\n"); + sc->sc_ah = ah; sc->sc_invalid = 0; /* ready to go, enable interrupt handling */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200310311631.h9VGVBHo083557>