Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci - Fix RAL table's size of PCH2 and PCH_LPT.
details: https://anonhg.NetBSD.org/src/rev/e305b3411e24
branches: trunk
changeset: 342496:e305b3411e24
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Fri Dec 25 04:50:16 2015 +0000
description:
- Fix RAL table's size of PCH2 and PCH_LPT.
- PCH_LPT (and newer device) is required to check FWSM_WLOCK_MAC bit to
determine the range of the RAL.
- Fix typo in comment and modify comment by tnn@.
- Rename wm_check_reset_block() to wm_phy_resetisblocked() and make it returns
bool. No functional change.
diffstat:
sys/dev/pci/if_wm.c | 66 +++++++++++++++++++++++++++++++++----------------
sys/dev/pci/if_wmreg.h | 14 ++++++----
sys/dev/pci/if_wmvar.h | 8 +++---
3 files changed, 56 insertions(+), 32 deletions(-)
diffs (248 lines):
diff -r bb5c63eaaf3e -r e305b3411e24 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c Thu Dec 24 21:30:05 2015 +0000
+++ b/sys/dev/pci/if_wm.c Fri Dec 25 04:50:16 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wm.c,v 1.385 2015/12/22 02:17:21 knakahara Exp $ */
+/* $NetBSD: if_wm.c,v 1.386 2015/12/25 04:50:16 msaitoh Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.385 2015/12/22 02:17:21 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.386 2015/12/25 04:50:16 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -727,7 +727,7 @@
static int wm_check_mng_mode_generic(struct wm_softc *);
#endif
static int wm_enable_mng_pass_thru(struct wm_softc *);
-static int wm_check_reset_block(struct wm_softc *);
+static bool wm_phy_resetisblocked(struct wm_softc *);
static void wm_get_hw_control(struct wm_softc *);
static void wm_release_hw_control(struct wm_softc *);
static void wm_gate_hw_phy_config_ich8lan(struct wm_softc *, int);
@@ -3027,7 +3027,7 @@
struct ether_multistep step;
bus_addr_t mta_reg;
uint32_t hash, reg, bit;
- int i, size;
+ int i, size, max;
if (sc->sc_type >= WM_T_82544)
mta_reg = WMREG_CORDOVA_MTA;
@@ -3050,9 +3050,12 @@
if (sc->sc_type == WM_T_ICH8)
size = WM_RAL_TABSIZE_ICH8 -1;
else if ((sc->sc_type == WM_T_ICH9) || (sc->sc_type == WM_T_ICH10)
- || (sc->sc_type == WM_T_PCH) || (sc->sc_type == WM_T_PCH2)
- || (sc->sc_type == WM_T_PCH_LPT))
+ || (sc->sc_type == WM_T_PCH))
size = WM_RAL_TABSIZE_ICH8;
+ else if (sc->sc_type == WM_T_PCH2)
+ size = WM_RAL_TABSIZE_PCH2;
+ else if (sc->sc_type == WM_T_PCH_LPT)
+ size = WM_RAL_TABSIZE_PCH_LPT;
else if (sc->sc_type == WM_T_82575)
size = WM_RAL_TABSIZE_82575;
else if ((sc->sc_type == WM_T_82576) || (sc->sc_type == WM_T_82580))
@@ -3062,8 +3065,28 @@
else
size = WM_RAL_TABSIZE;
wm_set_ral(sc, CLLADDR(ifp->if_sadl), 0);
- for (i = 1; i < size; i++)
- wm_set_ral(sc, NULL, i);
+
+ if (sc->sc_type == WM_T_PCH_LPT) {
+ i = __SHIFTOUT(CSR_READ(sc, WMREG_FWSM), FWSM_WLOCK_MAC);
+ switch (i) {
+ case 0:
+ /* We can use all entries */
+ max = size;
+ break;
+ case 1:
+ /* Only RAR[0] */
+ max = 1;
+ break;
+ default:
+ /* available SHRA + RAR[0] */
+ max = i + 1;
+ }
+ } else
+ max = size;
+ for (i = 1; i < size; i++) {
+ if (i < max)
+ wm_set_ral(sc, NULL, i);
+ }
if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
|| (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH)
@@ -3727,7 +3750,7 @@
case WM_T_PCH2:
case WM_T_PCH_LPT:
reg = CSR_READ(sc, WMREG_CTRL) | CTRL_RST;
- if (wm_check_reset_block(sc) == 0) {
+ if (wm_phy_resetisblocked(sc) == false) {
/*
* Gate automatic PHY configuration by hardware on
* non-managed 82579
@@ -10971,8 +10994,8 @@
fwsm = CSR_READ(sc, WMREG_FWSM);
- if (((fwsm & FWSM_FW_VALID) != 0) &&
- (fwsm & FWSM_MODE_MASK) == (MNG_ICH_IAMT_MODE << FWSM_MODE_SHIFT))
+ if (((fwsm & FWSM_FW_VALID) != 0)
+ && (__SHIFTOUT(fwsm, FWSM_MODE) == MNG_ICH_IAMT_MODE))
return 1;
return 0;
@@ -10998,7 +11021,7 @@
fwsm = CSR_READ(sc, WMREG_FWSM);
- if ((fwsm & FWSM_MODE_MASK) == (MNG_IAMT_MODE << FWSM_MODE_SHIFT))
+ if (__SHIFTOUT(fwsm, FWSM_MODE) == MNG_IAMT_MODE)
return 1;
return 0;
@@ -11024,8 +11047,7 @@
fwsm = CSR_READ(sc, WMREG_FWSM);
factps = CSR_READ(sc, WMREG_FACTPS);
if (((factps & FACTPS_MNGCG) == 0)
- && ((fwsm & FWSM_MODE_MASK)
- == (MNG_ICH_IAMT_MODE << FWSM_MODE_SHIFT)))
+ && (__SHIFTOUT(fwsm, FWSM_MODE) == MNG_ICH_IAMT_MODE))
return 1;
} else if ((sc->sc_type == WM_T_82574) || (sc->sc_type == WM_T_82583)){
uint16_t data;
@@ -11045,8 +11067,8 @@
return 0;
}
-static int
-wm_check_reset_block(struct wm_softc *sc)
+static bool
+wm_phy_resetisblocked(struct wm_softc *sc)
{
bool blocked = false;
uint32_t reg;
@@ -11068,7 +11090,7 @@
}
blocked = false;
} while (blocked && (i++ < 10));
- return blocked ? 1 : 0;
+ return blocked;
break;
case WM_T_82571:
case WM_T_82572:
@@ -11078,16 +11100,16 @@
case WM_T_80003:
reg = CSR_READ(sc, WMREG_MANC);
if ((reg & MANC_BLK_PHY_RST_ON_IDE) != 0)
- return -1;
+ return true;
else
- return 0;
+ return false;
break;
default:
/* no problem */
break;
}
- return 0;
+ return false;
}
static void
@@ -11159,7 +11181,7 @@
fwsm = CSR_READ(sc, WMREG_FWSM);
if (((fwsm & FWSM_FW_VALID) == 0)
- && ((wm_check_reset_block(sc) == 0))) {
+ && ((wm_phy_resetisblocked(sc) == false))) {
sc->sc_ctrl |= CTRL_LANPHYPC_OVERRIDE;
sc->sc_ctrl &= ~CTRL_LANPHYPC_VALUE;
CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl);
@@ -11237,7 +11259,7 @@
case WM_T_82580:
case WM_T_I350:
case WM_T_I354:
- if ((CSR_READ(sc, WMREG_FWSM) & FWSM_MODE_MASK) != 0)
+ if ((CSR_READ(sc, WMREG_FWSM) & FWSM_MODE) != 0)
sc->sc_flags |= WM_F_ARC_SUBSYS_VALID;
sc->sc_flags |= WM_F_ASF_FIRMWARE_PRES;
break;
diff -r bb5c63eaaf3e -r e305b3411e24 sys/dev/pci/if_wmreg.h
--- a/sys/dev/pci/if_wmreg.h Thu Dec 24 21:30:05 2015 +0000
+++ b/sys/dev/pci/if_wmreg.h Fri Dec 25 04:50:16 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wmreg.h,v 1.87 2015/10/27 14:23:23 msaitoh Exp $ */
+/* $NetBSD: if_wmreg.h,v 1.88 2015/12/25 04:50:16 msaitoh Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -418,6 +418,8 @@
#define WM_RAL_TABSIZE 15 /* RAL size for old devices */
#define WM_RAL_TABSIZE_ICH8 7 /* RAL size for ICH* and PCH* */
+#define WM_RAL_TABSIZE_PCH2 5 /* RAL size for PCH2 */
+#define WM_RAL_TABSIZE_PCH_LPT 12 /* RAL size for PCH_LPT */
#define WM_RAL_TABSIZE_82575 16 /* RAL size for 82575 */
#define WM_RAL_TABSIZE_82576 24 /* RAL size for 82576 and 82580 */
#define WM_RAL_TABSIZE_I350 32 /* RAL size for I350 */
@@ -966,7 +968,7 @@
#define MANC_EN_MAC_ADDR_FILTER 0x00100000
#define MANC_EN_MNG2HOST 0x00200000
-#define WMREG_MANC2H 0x5860 /* Manaegment Control To Host - RW */
+#define WMREG_MANC2H 0x5860 /* Management Control To Host - RW */
#define MANC2H_PORT_623 (1 << 5)
#define MANC2H_PORT_624 (1 << 6)
@@ -998,12 +1000,12 @@
#define SWSM_DRV_LOAD 0x00000008 /* Driver Loaded Bit */
#define WMREG_FWSM 0x5b54 /* FW Semaphore */
-#define FWSM_MODE_MASK 0xe
-#define FWSM_MODE_SHIFT 0x1
+#define FWSM_MODE __BITS(1, 3)
#define MNG_ICH_IAMT_MODE 0x2 /* PT mode? */
#define MNG_IAMT_MODE 0x3
-#define FWSM_RSPCIPHY 0x00000040 /* Reset PHY on PCI reset */
-#define FWSM_FW_VALID 0x00008000 /* FW established a valid mode */
+#define FWSM_RSPCIPHY __BIT(6) /* Reset PHY on PCI reset */
+#define FWSM_WLOCK_MAC __BITS(7, 9) /* Reset PHY on PCI reset */
+#define FWSM_FW_VALID __BIT(15) /* FW established a valid mode */
#define WMREG_SWSM2 0x5b58 /* SW Semaphore 2 */
#define SWSM2_LOCK 0x00000002 /* Secondary driver semaphore bit */
diff -r bb5c63eaaf3e -r e305b3411e24 sys/dev/pci/if_wmvar.h
--- a/sys/dev/pci/if_wmvar.h Thu Dec 24 21:30:05 2015 +0000
+++ b/sys/dev/pci/if_wmvar.h Fri Dec 25 04:50:16 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wmvar.h,v 1.29 2015/06/06 04:39:12 msaitoh Exp $ */
+/* $NetBSD: if_wmvar.h,v 1.30 2015/12/25 04:50:16 msaitoh Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -143,12 +143,12 @@
WM_T_I210, /* I210 */
WM_T_I211, /* I211 */
WM_T_80003, /* i80003 */
- WM_T_ICH8, /* ICH8 LAN */
+ WM_T_ICH8, /* ICH8 (I/O Controller Hub) LAN */
WM_T_ICH9, /* ICH9 LAN */
WM_T_ICH10, /* ICH10 LAN */
- WM_T_PCH, /* PCH LAN */
+ WM_T_PCH, /* PCH (Platform Controller Hub) LAN */
WM_T_PCH2, /* PCH2 LAN */
- WM_T_PCH_LPT, /* PCH LPT LAN (I21[78]) */
+ WM_T_PCH_LPT, /* PCH "Lynx Point" LAN (I217, I218) */
} wm_chip_type;
typedef enum {
Home |
Main Index |
Thread Index |
Old Index