NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/47542: PHY access method for 82580(I340) and I350 (wm(4)) is incorrect.



>   All 4 interfaces used in an agr(4). This is a file server, and I didn't
>   notice any networking issue ...
>   
>   --
>   Manuel Bouyer <bouyer%antioche.eu.org@localhost>
>        NetBSD: 26 ans d'experience feront toujours la difference
>   --

 You're lucky :-)

The smallest patch:

Index: if_wm.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_wm.c,v
retrieving revision 1.242
diff -u -r1.242 if_wm.c
--- if_wm.c     7 Feb 2013 15:38:42 -0000       1.242
+++ if_wm.c     8 Feb 2013 10:46:41 -0000
@@ -543,6 +543,8 @@
 static void    wm_gmii_bm_writereg(device_t, int, int, int);
 static int     wm_gmii_hv_readreg(device_t, int, int);
 static void    wm_gmii_hv_writereg(device_t, int, int, int);
+static int     wm_gmii_82580_readreg(device_t, int, int);
+static void    wm_gmii_82580_writereg(device_t, int, int, int);
 static int     wm_sgmii_readreg(device_t, int, int);
 static void    wm_sgmii_writereg(device_t, int, int, int);
 
@@ -6315,6 +6317,10 @@
                } else if (sc->sc_type >= WM_T_80003) {
                        sc->sc_mii.mii_readreg = wm_gmii_i80003_readreg;
                        sc->sc_mii.mii_writereg = wm_gmii_i80003_writereg;
+               } else if (sc->sc_type >= WM_T_82580) {
+                       sc->sc_phytype = WMPHY_82580;
+                       sc->sc_mii.mii_readreg = wm_gmii_82580_readreg;
+                       sc->sc_mii.mii_writereg = wm_gmii_82580_writereg;
                } else if (sc->sc_type >= WM_T_82544) {
                        sc->sc_mii.mii_readreg = wm_gmii_i82544_readreg;
                        sc->sc_mii.mii_writereg = wm_gmii_i82544_writereg;
@@ -7018,6 +7024,58 @@
 }
 
 /*
+ * wm_gmii_82580_readreg:      [mii interface function]
+ *
+ *     Read a PHY register on the 82580 and I350.
+ * This could be handled by the PHY layer if we didn't have to lock the
+ * ressource ...
+ */
+static int
+wm_gmii_82580_readreg(device_t self, int phy, int reg)
+{
+       struct wm_softc *sc = device_private(self);
+       int sem;
+       int rv;
+
+       sem = swfwphysem[sc->sc_funcid];
+       if (wm_get_swfw_semaphore(sc, sem)) {
+               aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
+                   __func__);
+               return 0;
+       }
+
+       rv = wm_gmii_i82544_readreg(self, phy, reg);
+
+       wm_put_swfw_semaphore(sc, sem);
+       return rv;
+}
+
+/*
+ * wm_gmii_82580_writereg:     [mii interface function]
+ *
+ *     Write a PHY register on the 82580 and I350.
+ * This could be handled by the PHY layer if we didn't have to lock the
+ * ressource ...
+ */
+static void
+wm_gmii_82580_writereg(device_t self, int phy, int reg, int val)
+{
+       struct wm_softc *sc = device_private(self);
+       int sem;
+
+       sem = swfwphysem[sc->sc_funcid];
+       if (wm_get_swfw_semaphore(sc, sem)) {
+               aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
+                   __func__);
+               return;
+       }
+
+       wm_gmii_i82544_writereg(self, phy, reg, val);
+
+       wm_put_swfw_semaphore(sc, sem);
+}
+
+/*
  * wm_gmii_statchg:    [mii interface function]
  *
  *     Callback from MII layer when media changes.
Index: if_wmvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_wmvar.h,v
retrieving revision 1.13
diff -u -r1.13 if_wmvar.h
--- if_wmvar.h  25 May 2012 23:37:38 -0000      1.13
+++ if_wmvar.h  8 Feb 2013 10:46:41 -0000
@@ -140,7 +140,8 @@
        WMPHY_BM,
        WMPHY_82577,
        WMPHY_82578,
-       WMPHY_82579
+       WMPHY_82579,
+       WMPHY_82580
 } wm_phy_type;
 
 


-- 
-----------------------------------------------
                SAITOH Masanobu (msaitoh%execsw.org@localhost
                                 msaitoh%netbsd.org@localhost)


Home | Main Index | Thread Index | Old Index