Module Name: src Committed By: msaitoh Date: Mon Sep 7 15:19:05 UTC 2015
Modified Files: src/sys/dev/pci: if_wm.c if_wmreg.h Log Message: - Check iNVM's image version and print it. - Update TODO. To generate a diff of this commit: cvs rdiff -u -r1.346 -r1.347 src/sys/dev/pci/if_wm.c cvs rdiff -u -r1.78 -r1.79 src/sys/dev/pci/if_wmreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.346 src/sys/dev/pci/if_wm.c:1.347 --- src/sys/dev/pci/if_wm.c:1.346 Mon Aug 17 06:16:03 2015 +++ src/sys/dev/pci/if_wm.c Mon Sep 7 15:19:05 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.346 2015/08/17 06:16:03 knakahara Exp $ */ +/* $NetBSD: if_wm.c,v 1.347 2015/09/07 15:19:05 msaitoh Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -74,14 +74,16 @@ * * - Check XXX'ed comments * - EEE (Energy Efficiency Ethernet) - * - MSI/MSI-X + * - Multi queue + * - Image Unique ID + * - LPLU other than PCH* * - Virtual Function * - Set LED correctly (based on contents in EEPROM) * - Rework how parameters are loaded from the EEPROM. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.346 2015/08/17 06:16:03 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.347 2015/09/07 15:19:05 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -723,6 +725,7 @@ static void wm_nvm_release(struct wm_sof static int wm_nvm_is_onboard_eeprom(struct wm_softc *); static int wm_nvm_get_flash_presence_i210(struct wm_softc *); static int wm_nvm_validate_checksum(struct wm_softc *); +static void wm_nvm_version_invm(struct wm_softc *); static void wm_nvm_version(struct wm_softc *); static int wm_nvm_read(struct wm_softc *, int, int, uint16_t *); @@ -9753,6 +9756,26 @@ wm_nvm_validate_checksum(struct wm_softc } static void +wm_nvm_version_invm(struct wm_softc *sc) +{ + uint32_t dword; + + /* + * Linux's code to decode version is very strange, so we don't + * obey that algorithm and just use word 61 as the document. + * Perhaps it's not perfect though... + * + * Example: + * + * Word61: 00800030 -> Version 0.6 (I211 spec update notes about 0.6) + */ + dword = CSR_READ(sc, WM_INVM_DATA_REG(61)); + dword = __SHIFTOUT(dword, INVM_VER_1); + sc->sc_nvm_ver_major = __SHIFTOUT(dword, INVM_MAJOR); + sc->sc_nvm_ver_minor = __SHIFTOUT(dword, INVM_MINOR); +} + +static void wm_nvm_version(struct wm_softc *sc) { uint16_t major, minor, build, patch; @@ -9796,12 +9819,12 @@ wm_nvm_version(struct wm_softc *sc) check_version = true; break; case WM_T_I211: - /* XXX wm_nvm_version_invm(sc); */ - return; + wm_nvm_version_invm(sc); + goto printver; case WM_T_I210: if (!wm_nvm_get_flash_presence_i210(sc)) { - /* XXX wm_nvm_version_invm(sc); */ - return; + wm_nvm_version_invm(sc); + goto printver; } /* FALLTHROUGH */ case WM_T_I350: @@ -9824,12 +9847,14 @@ wm_nvm_version(struct wm_softc *sc) /* Decimal */ minor = (minor / 16) * 10 + (minor % 16); + sc->sc_nvm_ver_major = major; + sc->sc_nvm_ver_minor = minor; - aprint_verbose(", version %d.%d", major, minor); +printver: + aprint_verbose(", version %d.%d", sc->sc_nvm_ver_major, + sc->sc_nvm_ver_minor); if (have_build) aprint_verbose(".%d", build); - sc->sc_nvm_ver_major = major; - sc->sc_nvm_ver_minor = minor; } if (check_optionrom) { wm_nvm_read(sc, NVM_OFF_COMB_VER_PTR, 1, &off); Index: src/sys/dev/pci/if_wmreg.h diff -u src/sys/dev/pci/if_wmreg.h:1.78 src/sys/dev/pci/if_wmreg.h:1.79 --- src/sys/dev/pci/if_wmreg.h:1.78 Sat Jun 13 15:47:58 2015 +++ src/sys/dev/pci/if_wmreg.h Mon Sep 7 15:19:05 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wmreg.h,v 1.78 2015/06/13 15:47:58 msaitoh Exp $ */ +/* $NetBSD: if_wmreg.h,v 1.79 2015/09/07 15:19:05 msaitoh Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -1114,6 +1114,13 @@ struct livengood_tcpip_ctxdesc { #define INVM_AUTOLOAD 0x0a #define INVM_PLL_WO_VAL 0x0010 +/* Version and Image Type field */ +#define INVM_VER_1 __BITS(12,3) +#define INVM_VER_2 __BITS(22,13) +#define INVM_IMGTYPE __BITS(28,23) +#define INVM_MINOR __BITS(3,0) +#define INVM_MAJOR __BITS(9,4) + /* Word definitions for ID LED Settings */ #define ID_LED_RESERVED_FFFF 0xFFFF