Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/dev/pci/ixgbe Pull up the following, requested by msa...



details:   https://anonhg.NetBSD.org/src/rev/40641f7cf2ae
branches:  netbsd-8
changeset: 450000:40641f7cf2ae
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Apr 01 12:35:38 2019 +0000

description:
Pull up the following, requested by msaitohin ticket #1225:

        sys/dev/pci/ixgbe/ixgbe.c               1.175-1.178
        sys/dev/pci/ixgbe/ixv.c                 1.110-1.111 via patch

- NetBSD currently uses traffic class 0 only. Other traffic classes
  aren't used yet. When IXGBE_TC_COUNTER_NUM is set to lower than
  IXGBE_DCB_MAX_TRAFFIC_CLASS (e.g. 1), other traffic classes' counters
  are not used. It means we don't generate evcnt for them and don't
  add the values in ixgbe_update_stats_counters().
- It's not required to calculate unused queues' statistics.
- Fix a bug that the VLAN HW tagging function is not correctly disabled
  when all vlan is detached.
- Fix a bug that VLAN HW tagging function is not correctly controlled
  on 82598.
- Control VLAN HW filter function correctly. Note that currently
  VLAN HW filter function doesn't work because NetBSD doesn't support
  it yet.
- Don't clear IXGBE_VLNCTRL_CFIEN bit When ETHERCAP_VLAN_HWFILTER is
  set. I think it's not required (and Linux doesn't do it). This change
  has no effect to NetBSD because ETHERCAP_VLAN_HWFILTER is not
  supported yet.

diffstat:

 sys/dev/pci/ixgbe/ixgbe.c      |  68 ++++++++++++++++++++++-------------------
 sys/dev/pci/ixgbe/ixgbe_type.h |  31 ++++++++++++++----
 sys/dev/pci/ixgbe/ixv.c        |  29 +++++++++++------
 3 files changed, 78 insertions(+), 50 deletions(-)

diffs (253 lines):

diff -r 296885d2d4a9 -r 40641f7cf2ae sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Fri Mar 29 19:59:40 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Mon Apr 01 12:35:38 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.28 2019/03/01 17:33:24 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.29 2019/04/01 12:35:38 martin Exp $ */
 
 /******************************************************************************
 
@@ -1558,8 +1558,8 @@
                }
        }
 
-       /* 8 registers */
-       for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+       /* 8 registers exist */
+       for (i = 0; i < IXGBE_TC_COUNTER_NUM; i++) {
                uint32_t mp;
 
                /* MPC */
@@ -1739,7 +1739,7 @@
 
        /* Max number of traffic class is 8 */
        KASSERT(IXGBE_DCB_MAX_TRAFFIC_CLASS == 8);
-       for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+       for (i = 0; i < IXGBE_TC_COUNTER_NUM; i++) {
                snprintf(adapter->tcs[i].evnamebuf,
                    sizeof(adapter->tcs[i].evnamebuf), "%s tc%d",
                    xname, i);
@@ -2038,7 +2038,7 @@
        adapter->msf_sicount.ev_count = 0;
        adapter->phy_sicount.ev_count = 0;
 
-       for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+       for (i = 0; i < IXGBE_TC_COUNTER_NUM; i++) {
                if (i < __arraycount(stats->mpc)) {
                        stats->mpc[i].ev_count = 0;
                        if (hw->mac.type == ixgbe_mac_82598EB)
@@ -2310,33 +2310,34 @@
        struct rx_ring  *rxr;
        int             i;
        u32             ctrl;
-
+       bool            hwtagging;
 
        /*
-        * We get here thru init_locked, meaning
-        * a soft reset, this has already cleared
-        * the VFTA and other state, so if there
-        * have been no vlan's registered do nothing.
+        *  This function is called from both if_init and ifflags_cb()
+        * on NetBSD.
         */
-       if (!VLAN_ATTACHED(&adapter->osdep.ec))
-               return;
+
+       /* Enable HW tagging only if any vlan is attached */
+       hwtagging = (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING)
+           && VLAN_ATTACHED(ec);
 
        /* Setup the queues for vlans */
-       if (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) {
-               for (i = 0; i < adapter->num_queues; i++) {
-                       rxr = &adapter->rx_rings[i];
-                       /* On 82599 the VLAN enable is per/queue in RXDCTL */
-                       if (hw->mac.type != ixgbe_mac_82598EB) {
-                               ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxr->me));
+       for (i = 0; i < adapter->num_queues; i++) {
+               rxr = &adapter->rx_rings[i];
+               /*
+                * On 82599 and later, the VLAN enable is per/queue in RXDCTL.
+                */
+               if (hw->mac.type != ixgbe_mac_82598EB) {
+                       ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxr->me));
+                       if (hwtagging)
                                ctrl |= IXGBE_RXDCTL_VME;
-                               IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxr->me), ctrl);
-                       }
-                       rxr->vtag_strip = TRUE;
+                       else
+                               ctrl &= ~IXGBE_RXDCTL_VME;
+                       IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxr->me), ctrl);
                }
-       }
-
-       if ((ec->ec_capenable & ETHERCAP_VLAN_HWFILTER) == 0)
-               return;
+               rxr->vtag_strip = hwtagging ? TRUE : FALSE;
+       }
+
        /*
         * A soft reset zero's out the VFTA, so
         * we need to repopulate it now.
@@ -2348,12 +2349,17 @@
 
        ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
        /* Enable the Filter Table if enabled */
-       if (ec->ec_capenable & ETHERCAP_VLAN_HWFILTER) {
-               ctrl &= ~IXGBE_VLNCTRL_CFIEN;
+       if (ec->ec_capenable & ETHERCAP_VLAN_HWFILTER)
                ctrl |= IXGBE_VLNCTRL_VFE;
-       }
-       if (hw->mac.type == ixgbe_mac_82598EB)
-               ctrl |= IXGBE_VLNCTRL_VME;
+       else
+               ctrl &= ~IXGBE_VLNCTRL_VFE;
+       /* VLAN hw tagging for 82598 */
+       if (hw->mac.type == ixgbe_mac_82598EB) {
+               if (hwtagging)
+                       ctrl |= IXGBE_VLNCTRL_VME;
+               else
+                       ctrl &= ~IXGBE_VLNCTRL_VME;
+       }
        IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
 } /* ixgbe_setup_vlan_hw_support */
 
@@ -3539,7 +3545,7 @@
        evcnt_detach(&adapter->msf_sicount);
        evcnt_detach(&adapter->phy_sicount);
 
-       for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+       for (i = 0; i < IXGBE_TC_COUNTER_NUM; i++) {
                if (i < __arraycount(stats->mpc)) {
                        evcnt_detach(&stats->mpc[i]);
                        if (hw->mac.type == ixgbe_mac_82598EB)
diff -r 296885d2d4a9 -r 40641f7cf2ae sys/dev/pci/ixgbe/ixgbe_type.h
--- a/sys/dev/pci/ixgbe/ixgbe_type.h    Fri Mar 29 19:59:40 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe_type.h    Mon Apr 01 12:35:38 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_type.h,v 1.22.2.7 2018/08/07 13:33:23 martin Exp $ */
+/* $NetBSD: ixgbe_type.h,v 1.22.2.8 2019/04/01 12:35:38 martin Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -3851,6 +3851,21 @@
        enum ixgbe_fc_mode requested_mode; /* FC mode requested by caller */
 };
 
+/*
+ * NetBSD currently uses traffic class 0 only. Other traffic classes aren't
+ * used yet. When IXGBE_TC_COUNTER_NUM is set to lower than
+ * IXGBE_DCB_MAX_TRAFFIC_CLASS (e.g. 1), other traffic classes' counters are
+ * not used. It means we don't generate evcnt for them and don't add the values
+ * in ixgbe_update_stats_counters().
+ */
+#if !defined(IXGBE_TC_COUNTER_NUM)
+#define IXGBE_TC_COUNTER_NUM IXGBE_DCB_MAX_TRAFFIC_CLASS
+#endif
+#if ((IXGBE_TC_COUNTER_NUM < 1)                                        \
+    || (IXGBE_TC_COUNTER_NUM > IXGBE_DCB_MAX_TRAFFIC_CLASS))
+#error Wrong IXGBE_TC_COUNTER_NUM value
+#endif
+
 /* Statistics counters collected by the MAC */
 struct ixgbe_hw_stats {
        char namebuf[32];
@@ -3865,7 +3880,7 @@
        struct evcnt mspdc;
        struct evcnt mbsdc;
        struct evcnt mpctotal;
-       struct evcnt mpc[8];
+       struct evcnt mpc[IXGBE_TC_COUNTER_NUM];
        struct evcnt mlfc;
        struct evcnt mrfc;
        struct evcnt rlec;
@@ -3873,10 +3888,10 @@
        struct evcnt lxonrxc;
        struct evcnt lxofftxc;
        struct evcnt lxoffrxc;
-       struct evcnt pxontxc[8];
-       struct evcnt pxonrxc[8];
-       struct evcnt pxofftxc[8];
-       struct evcnt pxoffrxc[8];
+       struct evcnt pxontxc[IXGBE_TC_COUNTER_NUM];
+       struct evcnt pxonrxc[IXGBE_TC_COUNTER_NUM];
+       struct evcnt pxofftxc[IXGBE_TC_COUNTER_NUM];
+       struct evcnt pxoffrxc[IXGBE_TC_COUNTER_NUM];
        struct evcnt prc64;
        struct evcnt prc127;
        struct evcnt prc255;
@@ -3889,7 +3904,7 @@
        struct evcnt gptc;
        struct evcnt gorc;
        struct evcnt gotc;
-       struct evcnt rnbc[8];
+       struct evcnt rnbc[IXGBE_TC_COUNTER_NUM];
        struct evcnt ruc;
        struct evcnt rfc;
        struct evcnt roc;
@@ -3914,7 +3929,7 @@
        struct evcnt qbrc[16];
        struct evcnt qbtc[16];
        struct evcnt qprdc[16];
-       struct evcnt pxon2offc[8];
+       struct evcnt pxon2offc[IXGBE_TC_COUNTER_NUM];
        u64 fdirustat_add;
        u64 fdirustat_remove;
        u64 fdirfstat_fadd;
diff -r 296885d2d4a9 -r 40641f7cf2ae sys/dev/pci/ixgbe/ixv.c
--- a/sys/dev/pci/ixgbe/ixv.c   Fri Mar 29 19:59:40 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixv.c   Mon Apr 01 12:35:38 2019 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.56.2.20 2019/03/01 17:33:24 martin Exp $*/
+/*$NetBSD: ixv.c,v 1.56.2.21 2019/04/01 12:35:38 martin Exp $*/
 
 /******************************************************************************
 
@@ -1973,28 +1973,35 @@
 static void
 ixv_setup_vlan_support(struct adapter *adapter)
 {
+       struct ethercom *ec = &adapter->osdep.ec;
        struct ixgbe_hw *hw = &adapter->hw;
+       struct rx_ring  *rxr;
        u32             ctrl, vid, vfta, retry;
+       bool            hwtagging;
 
        /*
-        * We get here thru init_locked, meaning
-        * a soft reset, this has already cleared
-        * the VFTA and other state, so if there
-        * have been no vlan's registered do nothing.
+        *  This function is called from both if_init and ifflags_cb()
+        * on NetBSD.
         */
-       if (!VLAN_ATTACHED(&adapter->osdep.ec))
-               return;
+
+       /* Enable HW tagging only if any vlan is attached */
+       hwtagging = (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING)
+           && VLAN_ATTACHED(ec);
 
        /* Enable the queues */
        for (int i = 0; i < adapter->num_queues; i++) {
-               ctrl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i));
-               ctrl |= IXGBE_RXDCTL_VME;
-               IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(i), ctrl);
+               rxr = &adapter->rx_rings[i];
+               ctrl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(rxr->me));
+               if (hwtagging)
+                       ctrl |= IXGBE_RXDCTL_VME;
+               else
+                       ctrl &= ~IXGBE_RXDCTL_VME;
+               IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(rxr->me), ctrl);
                /*
                 * Let Rx path know that it needs to store VLAN tag
                 * as part of extra mbuf info.
                 */
-               adapter->rx_rings[i].vtag_strip = TRUE;
+               rxr->vtag_strip = hwtagging ? TRUE : FALSE;
        }
 
        /*



Home | Main Index | Thread Index | Old Index