Source-Changes-HG archive

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

[src/trunk]: src Add support For I354(C2000 interna Ethernet controller):



details:   https://anonhg.NetBSD.org/src/rev/2e3ea9055532
branches:  trunk
changeset: 325571:2e3ea9055532
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Sun Dec 29 21:28:41 2013 +0000

description:
Add support For I354(C2000 interna Ethernet controller):
 - Add I354 support.
 - Fix SGMII+MDIO case. SGMII+I2C is not supported yet.
 - Not tested well.
 - Sprinkle "XXX" to check later.

diffstat:

 share/man/man4/wm.4    |    6 +-
 sys/dev/pci/if_wm.c    |  187 +++++++++++++++++++++++++++++++++++++++---------
 sys/dev/pci/if_wmreg.h |   11 ++-
 sys/dev/pci/if_wmvar.h |    3 +-
 4 files changed, 168 insertions(+), 39 deletions(-)

diffs (truncated from 528 to 300 lines):

diff -r 24c76678e809 -r 2e3ea9055532 share/man/man4/wm.4
--- a/share/man/man4/wm.4       Sun Dec 29 18:20:42 2013 +0000
+++ b/share/man/man4/wm.4       Sun Dec 29 21:28:41 2013 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: wm.4,v 1.28 2013/07/20 21:39:58 wiz Exp $
+.\"    $NetBSD: wm.4,v 1.29 2013/12/29 21:28:41 msaitoh Exp $
 .\"
 .\" Copyright 2002, 2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -33,7 +33,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd June 2, 2013
+.Dd December 30, 2013
 .Dt WM 4
 .Os
 .Sh NAME
@@ -142,6 +142,8 @@
 .It
 Intel I350 Ethernet (Copper, Fiber)
 .It
+Intel I354 (C2000 Internal) Ethernet (Copper, Fiber)
+.It
 Intel I210 Ethernet (Copper, Fiber)
 .It
 Intel I211 Ethernet
diff -r 24c76678e809 -r 2e3ea9055532 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Sun Dec 29 18:20:42 2013 +0000
+++ b/sys/dev/pci/if_wm.c       Sun Dec 29 21:28:41 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.264 2013/09/13 21:22:10 martin Exp $       */
+/*     $NetBSD: if_wm.c,v 1.265 2013/12/29 21:28:41 msaitoh Exp $      */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.264 2013/09/13 21:22:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.265 2013/12/29 21:28:41 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -543,11 +543,13 @@
 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 bool    wm_sgmii_uses_mdio(struct wm_softc *);
 static int     wm_sgmii_readreg(device_t, int, int);
 static void    wm_sgmii_writereg(device_t, int, int, int);
 
 static void    wm_gmii_statchg(struct ifnet *);
 
+static int     wm_get_phy_id_82575(struct wm_softc *);
 static void    wm_gmii_mediainit(struct wm_softc *, pci_product_id_t);
 static int     wm_gmii_mediachange(struct ifnet *);
 static void    wm_gmii_mediastatus(struct ifnet *, struct ifmediareq *);
@@ -1024,6 +1026,9 @@
          "I350 Gigabit Connection",
          WM_T_I350,            WMP_F_1000T },
 #endif
+       { PCI_VENDOR_INTEL,     PCI_PRODUCT_INTEL_C2000_SGMII,
+         "I354 Gigabit Connection",
+         WM_T_I354,            WMP_F_1000T },
        { PCI_VENDOR_INTEL,     PCI_PRODUCT_INTEL_I210_T1,
          "I210-T1 Ethernet Server Adapter",
          WM_T_I210,            WMP_F_1000T },
@@ -1210,8 +1215,8 @@
 
        if ((sc->sc_type == WM_T_82575) || (sc->sc_type == WM_T_82576)
            || (sc->sc_type == WM_T_82580) || (sc->sc_type == WM_T_82580ER)
-           || (sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I210)
-           || (sc->sc_type == WM_T_I211))
+           || (sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I354)
+           || (sc->sc_type == WM_T_I210) || (sc->sc_type == WM_T_I211))
                sc->sc_flags |= WM_F_NEWQUEUE;
 
        /* Set device properties (mactype) */
@@ -1326,7 +1331,7 @@
            || (sc->sc_type ==  WM_T_82571) || (sc->sc_type == WM_T_80003)
            || (sc->sc_type == WM_T_82575) || (sc->sc_type == WM_T_82576)
            || (sc->sc_type == WM_T_82580) || (sc->sc_type == WM_T_82580ER)
-           || (sc->sc_type == WM_T_I350))
+           || (sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I354))
                sc->sc_funcid = (CSR_READ(sc, WMREG_STATUS)
                    >> STATUS_FUNCID_SHIFT) & STATUS_FUNCID_MASK;
        else
@@ -1597,6 +1602,7 @@
        case WM_T_82580:
        case WM_T_82580ER:
        case WM_T_I350:
+       case WM_T_I354: /* XXXX ok? */
        case WM_T_80003:
                /* SPI */
                wm_set_spiaddrbits(sc);
@@ -1771,6 +1777,7 @@
        case WM_T_82580:
        case WM_T_82580ER:
        case WM_T_I350:
+       case WM_T_I354: /* XXX ok? */
        case WM_T_ICH8:
        case WM_T_ICH9:
        case WM_T_ICH10:
@@ -1897,20 +1904,30 @@
                case WM_T_82580:
                case WM_T_82580ER:
                case WM_T_I350:
+               case WM_T_I354:
                case WM_T_I210:
                case WM_T_I211:
                        reg = CSR_READ(sc, WMREG_CTRL_EXT);
                        switch (reg & CTRL_EXT_LINK_MODE_MASK) {
-                       case CTRL_EXT_LINK_MODE_SGMII:
-                               aprint_verbose_dev(sc->sc_dev, "SGMII\n");
-                               sc->sc_flags |= WM_F_SGMII;
+                       case CTRL_EXT_LINK_MODE_1000KX:
+                               aprint_verbose_dev(sc->sc_dev, "1000KX\n");
                                CSR_WRITE(sc, WMREG_CTRL_EXT,
                                    reg | CTRL_EXT_I2C_ENA);
-                               wm_gmii_mediainit(sc, wmp->wmp_product);
+                               panic("not supported yet\n");
                                break;
-                       case CTRL_EXT_LINK_MODE_1000KX:
+                       case CTRL_EXT_LINK_MODE_SGMII:
+                               if (wm_sgmii_uses_mdio(sc)) {
+                                       aprint_verbose_dev(sc->sc_dev,
+                                           "SGMII(MDIO)\n");
+                                       sc->sc_flags |= WM_F_SGMII;
+                                       wm_gmii_mediainit(sc,
+                                           wmp->wmp_product);
+                                       break;
+                               }
+                               aprint_verbose_dev(sc->sc_dev, "SGMII(I2C)\n");
+                               /*FALLTHROUGH*/
                        case CTRL_EXT_LINK_MODE_PCIE_SERDES:
-                               aprint_verbose_dev(sc->sc_dev, "1000KX or SERDES\n");
+                               aprint_verbose_dev(sc->sc_dev, "SERDES\n");
                                CSR_WRITE(sc, WMREG_CTRL_EXT,
                                    reg | CTRL_EXT_I2C_ENA);
                                panic("not supported yet\n");
@@ -1963,6 +1980,7 @@
        case WM_T_82580:
        case WM_T_82580ER:
        case WM_T_I350:
+       case WM_T_I354: /* XXXX ok? */
        case WM_T_I210:
        case WM_T_I211:
        case WM_T_80003:
@@ -3706,7 +3724,8 @@
                 * For an eratta, the RCTL_SECRC bit in RCTL register
                 * is always set in I350, so we don't trim it.
                 */
-               if ((sc->sc_type != WM_T_I350) && (sc->sc_type != WM_T_I210)
+               if ((sc->sc_type != WM_T_I350) && (sc->sc_type != WM_T_I354)
+                   && (sc->sc_type != WM_T_I210)
                    && (sc->sc_type != WM_T_I211)) {
                        if (m->m_len < ETHER_CRC_LEN) {
                                sc->sc_rxtail->m_len
@@ -3757,6 +3776,7 @@
                 * If VLANs are enabled, VLAN packets have been unwrapped
                 * for us.  Associate the tag with the packet.
                 */
+               /* XXXX should check for i350 and i354 */
                if ((status & WRX_ST_VP) != 0) {
                        VLAN_INPUT_TAG(ifp, m,
                            le16toh(vlantag),
@@ -4039,6 +4059,7 @@
        case WM_T_82572:
        case WM_T_82575:        /* XXX need special handing for jumbo frames */
        case WM_T_I350:
+       case WM_T_I354:
        case WM_T_80003:
                sc->sc_pba = PBA_32K;
                break;
@@ -4097,7 +4118,7 @@
 
        /* Set the completion timeout for interface */
        if ((sc->sc_type == WM_T_82575) || (sc->sc_type == WM_T_82576)
-           || (sc->sc_type == WM_T_I350))
+           || (sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I354))
                wm_set_pcie_completion_timeout(sc);
 
        /* Clear interrupt */
@@ -4210,6 +4231,7 @@
        case WM_T_82580ER:
        case WM_T_82583:
        case WM_T_I350:
+       case WM_T_I354:
        case WM_T_I210:
        case WM_T_I211:
        default:
@@ -4282,6 +4304,7 @@
        case WM_T_82580:
        case WM_T_82580ER:
        case WM_T_I350:
+       case WM_T_I354:
        case WM_T_I210:
        case WM_T_I211:
        case WM_T_80003:
@@ -4308,6 +4331,7 @@
        case WM_T_82580ER:
 #endif
        case WM_T_I350:
+       case WM_T_I354:
        case WM_T_ICH8:
        case WM_T_ICH9:
                if ((CSR_READ(sc, WMREG_EECD) & EECD_EE_PRES) == 0) {
@@ -4317,7 +4341,8 @@
                            || (sc->sc_type == WM_T_82576)
                            || (sc->sc_type == WM_T_82580)
                            || (sc->sc_type == WM_T_82580ER)
-                           || (sc->sc_type == WM_T_I350))
+                           || (sc->sc_type == WM_T_I350)
+                           || (sc->sc_type == WM_T_I354))
                                wm_reset_init_script_82575(sc);
                }
                break;
@@ -4326,7 +4351,7 @@
        }
 
        if ((sc->sc_type == WM_T_82580) || (sc->sc_type == WM_T_82580ER)
-           || (sc->sc_type == WM_T_I350)) {
+           || (sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I354)) {
                /* clear global device reset status bit */
                CSR_WRITE(sc, WMREG_STATUS, STATUS_DEV_RST_SET);
        }
@@ -4562,7 +4587,7 @@
         * Clear out the VLAN table -- we don't use it (yet).
         */
        CSR_WRITE(sc, WMREG_VET, 0);
-       if (sc->sc_type == WM_T_I350)
+       if ((sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I354))
                trynum = 10; /* Due to hw errata */
        else
                trynum = 1;
@@ -4761,7 +4786,8 @@
         * The I350 has a bug where it always strips the CRC whether
         * asked to or not. So ask for stripped CRC here and cope in rxeof
         */
-       if ((sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I210))
+       if ((sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I354)
+           || (sc->sc_type == WM_T_I210))
                sc->sc_rctl |= RCTL_SECRC;
 
        if (((sc->sc_ethercom.ec_capabilities & ETHERCAP_JUMBO_MTU) != 0)
@@ -4940,6 +4966,7 @@
        case WM_T_82580:
        case WM_T_82580ER:
        case WM_T_I350:
+       case WM_T_I354:
        case WM_T_I210:
        case WM_T_I211:
        case WM_T_80003:
@@ -5031,6 +5058,7 @@
        case WM_T_82580:
        case WM_T_82580ER:
        case WM_T_I350:
+       case WM_T_I354:
        case WM_T_I210:
        case WM_T_I211:
                if (sc->sc_type == WM_T_82571) {
@@ -5532,6 +5560,7 @@
        case WM_T_82580:
        case WM_T_82580ER:
        case WM_T_I350:
+       case WM_T_I354:
                switch (sc->sc_funcid) {
                case 0:
                        /* default value (== EEPROM_OFF_MACADDR) */
@@ -5773,7 +5802,7 @@
                size = WM_RAL_TABSIZE_82575;
        else if ((sc->sc_type == WM_T_82576) || (sc->sc_type == WM_T_82580))
                size = WM_RAL_TABSIZE_82576;
-       else if (sc->sc_type == WM_T_I350)
+       else if ((sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I354))
                size = WM_RAL_TABSIZE_I350;
        else
                size = WM_RAL_TABSIZE;
@@ -6155,6 +6184,7 @@
        case WM_T_82580:
        case WM_T_82580ER:
        case WM_T_I350:
+       case WM_T_I354:
        case WM_T_I210:
        case WM_T_I211:
        case WM_T_80003:
@@ -6229,6 +6259,7 @@
        case WM_T_82580:
        case WM_T_82580ER:
        case WM_T_I350:
+       case WM_T_I354:
        case WM_T_I210:
        case WM_T_I211:
        case WM_T_82583:
@@ -6280,6 +6311,7 @@
        case WM_T_82580:
        case WM_T_82580ER:
        case WM_T_I350:



Home | Main Index | Thread Index | Old Index