Module Name:    src
Committed By:   msaitoh
Date:           Wed Dec 11 09:48:16 UTC 2019

Modified Files:
        src/sys/dev/pci: if_wm.c if_wmreg.h

Log Message:
- Set CTRL_ILOS(Invert loss of signal) bit correctly on 82580 port 1, 2, 3 and
  newer chips. This change fixes a bug that some fiber, serdes or SFP devices
  don't detect the link status correctly.
  XXX We should check for other NVM reads if they have the same problem. One of
  the solution to avoid this type of bug is to check the register layout
  in wm_nvm_read().
- Use __BIT()
- Add comment


To generate a diff of this commit:
cvs rdiff -u -r1.653 -r1.654 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.116 -r1.117 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.653 src/sys/dev/pci/if_wm.c:1.654
--- src/sys/dev/pci/if_wm.c:1.653	Wed Dec 11 09:27:46 2019
+++ src/sys/dev/pci/if_wm.c	Wed Dec 11 09:48:16 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.653 2019/12/11 09:27:46 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.654 2019/12/11 09:48:16 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.653 2019/12/11 09:27:46 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.654 2019/12/11 09:48:16 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2656,10 +2656,11 @@ alloc_retry:
 		}
 	}
 
-	/* XXX For other than 82580? */
-	if (sc->sc_type == WM_T_82580) {
-		wm_nvm_read(sc, NVM_OFF_CFG3_PORTA, 1, &nvmword);
-		if (nvmword & __BIT(13))
+	if ((sc->sc_type >= WM_T_82580) && (sc->sc_type <= WM_T_I211)) {
+		wm_nvm_read(sc,
+		    NVM_OFF_LAN_FUNC_82580(sc->sc_funcid) + NVM_OFF_CFG3_PORTA,
+		    1, &nvmword);
+		if (nvmword & NVM_CFG3_ILOS)
 			sc->sc_ctrl |= CTRL_ILOS;
 	}
 

Index: src/sys/dev/pci/if_wmreg.h
diff -u src/sys/dev/pci/if_wmreg.h:1.116 src/sys/dev/pci/if_wmreg.h:1.117
--- src/sys/dev/pci/if_wmreg.h:1.116	Wed Dec 11 09:12:29 2019
+++ src/sys/dev/pci/if_wmreg.h	Wed Dec 11 09:48:16 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmreg.h,v 1.116 2019/12/11 09:12:29 msaitoh Exp $	*/
+/*	$NetBSD: if_wmreg.h,v 1.117 2019/12/11 09:48:16 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -1487,9 +1487,10 @@ struct livengood_tcpip_ctxdesc {
 
 #define NVM_3GIO_3_ASPM_MASK	(0x3 << 2)	/* Active State PM Support */
 
-#define NVM_CFG3_APME		(1U << 10)	
-#define NVM_CFG3_PORTA_EXT_MDIO	(1U << 2)	/* External MDIO Interface */
-#define NVM_CFG3_PORTA_COM_MDIO	(1U << 3)	/* MDIO Interface is shared */
+#define NVM_CFG3_PORTA_EXT_MDIO	__BIT(2)	/* External MDIO Interface */
+#define NVM_CFG3_PORTA_COM_MDIO	__BIT(3)	/* MDIO Interface is shared */
+#define NVM_CFG3_APME		__BIT(10)	/* APM Enable */
+#define NVM_CFG3_ILOS		__BIT(13)	/* Invert loss of signal */
 
 #define	NVM_OFF_MACADDR_82571(x)	(3 * (x))
 

Reply via email to