Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci/ixgbe ADD SFP+ MOD_ABS inversion quirk.



details:   https://anonhg.NetBSD.org/src/rev/105ceb39583b
branches:  trunk
changeset: 937792:105ceb39583b
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Aug 27 00:07:56 2020 +0000

description:
ADD SFP+ MOD_ABS inversion quirk.

 On X550 EM, GPIO(SDP) and SFP+'s MOD_ABS is directly connected. It has
no inverter. GIGABYTE MA10-ST0 has a inverter, so add new quirk for it.

diffstat:

 sys/dev/pci/ixgbe/ixgbe.c |  38 +++++++++++++++++++++++++++++++++-----
 sys/dev/pci/ixgbe/ixgbe.h |   7 ++++++-
 2 files changed, 39 insertions(+), 6 deletions(-)

diffs (117 lines):

diff -r 8226f808d04e -r 105ceb39583b sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Wed Aug 26 23:08:29 2020 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Thu Aug 27 00:07:56 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.244 2020/08/24 19:03:27 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.245 2020/08/27 00:07:56 msaitoh Exp $ */
 
 /******************************************************************************
 
@@ -159,6 +159,7 @@
  * Function prototypes
  ************************************************************************/
 static int     ixgbe_probe(device_t, cfdata_t, void *);
+static void    ixgbe_quirks(struct adapter *);
 static void    ixgbe_attach(device_t, device_t, void *);
 static int     ixgbe_detach(device_t, int);
 #if 0
@@ -257,7 +258,7 @@
 static int     ixgbe_sysctl_wufc(SYSCTLFN_PROTO);
 
 /* Support for pluggable optic modules */
-static bool    ixgbe_sfp_cage_full(struct ixgbe_hw *);
+static bool    ixgbe_sfp_cage_full(struct adapter *);
 
 /* Legacy (single vector) interrupt handler */
 static int     ixgbe_legacy_irq(void *);
@@ -763,6 +764,26 @@
        return;
 } /* ixgbe_initialize_transmit_units */
 
+static void
+ixgbe_quirks(struct adapter *adapter)
+{
+       device_t dev = adapter->dev;
+       const char *vendor, *product;
+
+       /* Quirk for inverted logic of SFP+'s MOD_ABS */
+       vendor = pmf_get_platform("system-vendor");
+       product = pmf_get_platform("system-product");
+
+       if ((vendor == NULL) || (product == NULL))
+               return;
+
+       if ((strcmp(vendor, "GIGABYTE") == 0) &&
+           (strcmp(product, "MA10-ST0") == 0)) {
+               aprint_verbose_dev(dev, "Enable SFP+ MOD_ABS inverse quirk\n");
+               adapter->quirks |= IXGBE_QUIRK_MOD_ABS_INVERT;
+       }
+}
+
 /************************************************************************
  * ixgbe_attach - Device initialization routine
  *
@@ -810,6 +831,9 @@
        aprint_normal(": %s, Version - %s\n",
            ixgbe_strings[ent->index], ixgbe_driver_version);
 
+       /* Set quirk flags */
+       ixgbe_quirks(adapter);
+
        /* Core Lock Init */
        IXGBE_CORE_LOCK_INIT(adapter, device_xname(dev));
 
@@ -4620,8 +4644,9 @@
  *   Determine if a port had optics inserted.
  ************************************************************************/
 static bool
-ixgbe_sfp_cage_full(struct ixgbe_hw *hw)
+ixgbe_sfp_cage_full(struct adapter *adapter)
 {
+       struct ixgbe_hw *hw = &adapter->hw;
        uint32_t mask;
        int rv;
 
@@ -4631,9 +4656,12 @@
                mask = IXGBE_ESDP_SDP2;
 
        rv = IXGBE_READ_REG(hw, IXGBE_ESDP) & mask;
+       if ((adapter->quirks & IXGBE_QUIRK_MOD_ABS_INVERT) != 0)
+               rv = !rv;
+
        if (hw->mac.type == ixgbe_mac_X550EM_a) {
-               /* It seems X550EM_a's SDP0 is inverted than others... */
-               return (rv == 0);
+               /* X550EM_a's SDP0 is inverted than others. */
+               return !rv;
        }
 
        return rv;
diff -r 8226f808d04e -r 105ceb39583b sys/dev/pci/ixgbe/ixgbe.h
--- a/sys/dev/pci/ixgbe/ixgbe.h Wed Aug 26 23:08:29 2020 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.h Thu Aug 27 00:07:56 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.h,v 1.69 2020/08/17 07:59:06 msaitoh Exp $ */
+/* $NetBSD: ixgbe.h,v 1.70 2020/08/27 00:07:56 msaitoh Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -623,6 +623,9 @@
        u32                     feat_cap;
        u32                     feat_en;
 
+       /* Quirks */
+       u32                     quirks;
+
        /* Traffic classes */
        struct ixgbe_tc tcs[IXGBE_DCB_MAX_TRAFFIC_CLASS];
 
@@ -770,6 +773,8 @@
 #define IXGBE_REQUEST_TASK_LSC         0x20
 #define IXGBE_REQUEST_TASK_NEED_ACKINTR        0x80
 
+#define IXGBE_QUIRK_MOD_ABS_INVERT     __BIT(0)
+
 /* For NetBSD */
 const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *);
 void ixgbe_jcl_reinit(struct adapter *, bus_dma_tag_t, struct rx_ring *,



Home | Main Index | Thread Index | Old Index