From owner-p4-projects@FreeBSD.ORG Fri Oct 31 08:31:13 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3BBE316A509; Fri, 31 Oct 2003 08:31:13 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 11CB816A501 for ; Fri, 31 Oct 2003 08:31:13 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4559743FA3 for ; Fri, 31 Oct 2003 08:31:12 -0800 (PST) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id h9VGVCXJ083561 for ; Fri, 31 Oct 2003 08:31:12 -0800 (PST) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id h9VGVBHo083557 for perforce@freebsd.org; Fri, 31 Oct 2003 08:31:11 -0800 (PST) (envelope-from sam@freebsd.org) Date: Fri, 31 Oct 2003 08:31:11 -0800 (PST) Message-Id: <200310311631.h9VGVBHo083557@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 40978 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Oct 2003 16:31:13 -0000 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 */