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 following revision(s) (requeste...



details:   https://anonhg.NetBSD.org/src/rev/199ed00f028a
branches:  netbsd-8
changeset: 434796:199ed00f028a
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Mar 30 12:07:34 2018 +0000

description:
Pull up following revision(s) (requested by msaitoh in ticket #673):

        sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
        sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
        sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
        sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
        sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
        sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
        sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
        sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
        sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
        sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
        sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
        sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
        sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
        sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
        sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
        sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
        sys/dev/pci/ixgbe/ixv.c: revision 1.88
        sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
        sys/dev/pci/ixgbe/ixv.c: revision 1.89
        sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
        sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
        sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter  stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
  and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
  NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
  X550 and newer on some environment. X550 changed FWSM bit definition.
  See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
  not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
  function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
  C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
    - ixgbe_media_status()
    - ixgbe_local_timer1()
    - ixgbe_stop()
    - ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
    - ixv_media_status()
    - ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.

diffstat:

 sys/dev/pci/ixgbe/if_bypass.c    |   86 ++++++++++++------------
 sys/dev/pci/ixgbe/if_sriov.c     |   36 +++++-----
 sys/dev/pci/ixgbe/ix_txrx.c      |   34 +++++-----
 sys/dev/pci/ixgbe/ixgbe.c        |   54 +++++++++++-----
 sys/dev/pci/ixgbe/ixgbe.h        |   16 ++--
 sys/dev/pci/ixgbe/ixgbe_common.c |  131 +++++++++++++++++++++++++++++++++++---
 sys/dev/pci/ixgbe/ixgbe_common.h |    7 +-
 sys/dev/pci/ixgbe/ixgbe_osdep.c  |   42 ++++++------
 sys/dev/pci/ixgbe/ixgbe_osdep.h  |   42 ++++++------
 sys/dev/pci/ixgbe/ixgbe_phy.c    |   17 ++--
 sys/dev/pci/ixgbe/ixgbe_sriov.h  |    3 +-
 sys/dev/pci/ixgbe/ixgbe_type.h   |   45 ++++++++++++-
 sys/dev/pci/ixgbe/ixgbe_vf.h     |   42 ++++++------
 sys/dev/pci/ixgbe/ixgbe_x540.c   |    3 +
 sys/dev/pci/ixgbe/ixgbe_x550.c   |   21 +++--
 sys/dev/pci/ixgbe/ixv.c          |   46 ++++++------
 16 files changed, 404 insertions(+), 221 deletions(-)

diffs (truncated from 1383 to 300 lines):

diff -r b9a500df3d47 -r 199ed00f028a sys/dev/pci/ixgbe/if_bypass.c
--- a/sys/dev/pci/ixgbe/if_bypass.c     Fri Mar 30 12:01:30 2018 +0000
+++ b/sys/dev/pci/ixgbe/if_bypass.c     Fri Mar 30 12:07:34 2018 +0000
@@ -474,45 +474,45 @@
 
        mask = BYPASS_WDT_ENABLE_M;
        switch (timeout) {
-               case 0: /* disables the timer */
-                       break;
-               case 1:
-                       arg = BYPASS_WDT_1_5 << BYPASS_WDT_TIME_SHIFT;
-                       arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-                       mask |= BYPASS_WDT_VALUE_M;
-                       break;
-               case 2:
-                       arg = BYPASS_WDT_2 << BYPASS_WDT_TIME_SHIFT;
-                       arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-                       mask |= BYPASS_WDT_VALUE_M;
-                       break;
-               case 3:
-                       arg = BYPASS_WDT_3 << BYPASS_WDT_TIME_SHIFT;
-                       arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-                       mask |= BYPASS_WDT_VALUE_M;
-                       break;
-               case 4:
-                       arg = BYPASS_WDT_4 << BYPASS_WDT_TIME_SHIFT;
-                       arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-                       mask |= BYPASS_WDT_VALUE_M;
-                       break;
-               case 8:
-                       arg = BYPASS_WDT_8 << BYPASS_WDT_TIME_SHIFT;
-                       arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-                       mask |= BYPASS_WDT_VALUE_M;
-                       break;
-               case 16:
-                       arg = BYPASS_WDT_16 << BYPASS_WDT_TIME_SHIFT;
-                       arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-                       mask |= BYPASS_WDT_VALUE_M;
-                       break;
-               case 32:
-                       arg = BYPASS_WDT_32 << BYPASS_WDT_TIME_SHIFT;
-                       arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-                       mask |= BYPASS_WDT_VALUE_M;
-                       break;
-               default:
-                       return (EINVAL);
+       case 0: /* disables the timer */
+               break;
+       case 1:
+               arg = BYPASS_WDT_1_5 << BYPASS_WDT_TIME_SHIFT;
+               arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
+               mask |= BYPASS_WDT_VALUE_M;
+               break;
+       case 2:
+               arg = BYPASS_WDT_2 << BYPASS_WDT_TIME_SHIFT;
+               arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
+               mask |= BYPASS_WDT_VALUE_M;
+               break;
+       case 3:
+               arg = BYPASS_WDT_3 << BYPASS_WDT_TIME_SHIFT;
+               arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
+               mask |= BYPASS_WDT_VALUE_M;
+               break;
+       case 4:
+               arg = BYPASS_WDT_4 << BYPASS_WDT_TIME_SHIFT;
+               arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
+               mask |= BYPASS_WDT_VALUE_M;
+               break;
+       case 8:
+               arg = BYPASS_WDT_8 << BYPASS_WDT_TIME_SHIFT;
+               arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
+               mask |= BYPASS_WDT_VALUE_M;
+               break;
+       case 16:
+               arg = BYPASS_WDT_16 << BYPASS_WDT_TIME_SHIFT;
+               arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
+               mask |= BYPASS_WDT_VALUE_M;
+               break;
+       case 32:
+               arg = BYPASS_WDT_32 << BYPASS_WDT_TIME_SHIFT;
+               arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
+               mask |= BYPASS_WDT_VALUE_M;
+               break;
+       default:
+               return (EINVAL);
        }
        /* Set the new watchdog */
        ixgbe_bypass_mutex_enter(adapter);
@@ -635,7 +635,7 @@
                            &data);
                        ixgbe_bypass_mutex_clear(adapter);
                        if (error)
-                               return (-EINVAL);
+                               return (EINVAL);
                        eeprom[count].logs += data << (8 * i);
                }
 
@@ -644,7 +644,7 @@
                    log_off + i, &eeprom[count].actions);
                ixgbe_bypass_mutex_clear(adapter);
                if (error)
-                       return (-EINVAL);
+                       return (EINVAL);
 
                /* Quit if not a unread log */
                if (!(eeprom[count].logs & BYPASS_LOG_CLEAR_M))
@@ -717,7 +717,7 @@
                ixgbe_bypass_mutex_clear(adapter);
 
                if (error)
-                       return (-EINVAL);
+                       return (EINVAL);
        }
 
        status = 0; /* reset */
@@ -731,7 +731,7 @@
        status = 0; /* reset */
        while (atomic_cas_uint(&adapter->bypass.log, 1, 0) == 0)
                usec_delay(3000);
-       return (-EINVAL);
+       return (EINVAL);
 } /* ixgbe_bp_log */
 
 /************************************************************************
diff -r b9a500df3d47 -r 199ed00f028a sys/dev/pci/ixgbe/if_sriov.c
--- a/sys/dev/pci/ixgbe/if_sriov.c      Fri Mar 30 12:01:30 2018 +0000
+++ b/sys/dev/pci/ixgbe/if_sriov.c      Fri Mar 30 12:07:34 2018 +0000
@@ -33,6 +33,7 @@
 /*$FreeBSD: head/sys/dev/ixgbe/if_sriov.c 320688 2017-07-05 17:27:03Z erj $*/
 
 #include "ixgbe.h"
+#include "ixgbe_sriov.h"
 
 #ifdef PCI_IOV
 
@@ -89,26 +90,26 @@
 
 /* Support functions for SR-IOV/VF management */
 static inline void
-ixgbe_send_vf_msg(struct adapter *adapter, struct ixgbe_vf *vf, u32 msg)
+ixgbe_send_vf_msg(struct ixgbe_hw *hw, struct ixgbe_vf *vf, u32 msg)
 {
        if (vf->flags & IXGBE_VF_CTS)
                msg |= IXGBE_VT_MSGTYPE_CTS;
 
-       adapter->hw.mbx.ops.write(&adapter->hw, &msg, 1, vf->pool);
+       hw->mbx.ops.write(hw, &msg, 1, vf->pool);
 }
 
 static inline void
 ixgbe_send_vf_ack(struct adapter *adapter, struct ixgbe_vf *vf, u32 msg)
 {
        msg &= IXGBE_VT_MSG_MASK;
-       ixgbe_send_vf_msg(adapter, vf, msg | IXGBE_VT_MSGTYPE_ACK);
+       ixgbe_send_vf_msg(&adapter->hw, vf, msg | IXGBE_VT_MSGTYPE_ACK);
 }
 
 static inline void
 ixgbe_send_vf_nack(struct adapter *adapter, struct ixgbe_vf *vf, u32 msg)
 {
        msg &= IXGBE_VT_MSG_MASK;
-       ixgbe_send_vf_msg(adapter, vf, msg | IXGBE_VT_MSGTYPE_NACK);
+       ixgbe_send_vf_msg(&adapter->hw, vf, msg | IXGBE_VT_MSGTYPE_NACK);
 }
 
 static inline void
@@ -204,7 +205,7 @@
        for (int i = 0; i < adapter->num_vfs; i++) {
                vf = &adapter->vfs[i];
                if (vf->flags & IXGBE_VF_ACTIVE)
-                       ixgbe_send_vf_msg(adapter, vf, IXGBE_PF_CONTROL_MSG);
+                       ixgbe_send_vf_msg(&adapter->hw, vf, IXGBE_PF_CONTROL_MSG);
        }
 } /* ixgbe_ping_all_vfs */
 
@@ -233,7 +234,7 @@
 
        if (tag == 0) {
                /* Accept non-vlan tagged traffic. */
-               //vmolr |= IXGBE_VMOLR_AUPE;
+               vmolr |= IXGBE_VMOLR_AUPE;
 
                /* Allow VM to tag outgoing traffic; no default tag. */
                vmvir = 0;
@@ -292,7 +293,6 @@
                        return (TRUE);
 
                return (FALSE);
-
        }
 } /* ixgbe_vf_frame_size_compatible */
 
@@ -366,7 +366,7 @@
 
        vf->flags |= IXGBE_VF_CTS;
 
-       resp[0] = IXGBE_VF_RESET | ack | IXGBE_VT_MSGTYPE_CTS;
+       resp[0] = IXGBE_VF_RESET | ack;
        bcopy(vf->ether_addr, &resp[1], ETHER_ADDR_LEN);
        resp[3] = hw->mac.mc_filter_type;
        hw->mbx.ops.write(hw, resp, IXGBE_VF_PERMADDR_MSG_LEN, vf->pool);
@@ -451,7 +451,7 @@
        }
 
        /* It is illegal to enable vlan tag 0. */
-       if (tag == 0 && enable != 0){
+       if (tag == 0 && enable != 0) {
                ixgbe_send_vf_nack(adapter, vf, msg[0]);
                return;
        }
@@ -578,8 +578,8 @@
        if (error != 0)
                return;
 
-       CTR3(KTR_MALLOC, "%s: received msg %x from %d",
-           adapter->ifp->if_xname, msg[0], vf->pool);
+       CTR3(KTR_MALLOC, "%s: received msg %x from %d", adapter->ifp->if_xname,
+           msg[0], vf->pool);
        if (msg[0] == IXGBE_VF_RESET) {
                ixgbe_vf_reset_msg(adapter, vf, msg);
                return;
@@ -622,12 +622,11 @@
 void
 ixgbe_handle_mbx(void *context, int pending)
 {
-       struct adapter *adapter;
+       struct adapter *adapter = context;
        struct ixgbe_hw *hw;
        struct ixgbe_vf *vf;
        int i;
 
-       adapter = context;
        hw = &adapter->hw;
 
        IXGBE_CORE_LOCK(adapter);
@@ -694,19 +693,22 @@
        }
 
        adapter->num_vfs = num_vfs;
+
+       /* set the SRIOV flag now as it's needed
+        * by ixgbe_init_locked() */
+       adapter->feat_en |= IXGBE_FEATURE_SRIOV;
        adapter->init_locked(adapter);
-       adapter->feat_en |= IXGBE_FEATURE_SRIOV;
 
        IXGBE_CORE_UNLOCK(adapter);
 
-       return retval;
+       return (retval);
 
 err_init_iov:
        adapter->num_vfs = 0;
        adapter->pool = 0;
        adapter->iov_mode = IXGBE_NO_VM;
 
-       return retval;
+       return (retval);
 } /* ixgbe_init_iov */
 
 void
@@ -773,7 +775,7 @@
        ixgbe_vf_enable_transmit(adapter, vf);
        ixgbe_vf_enable_receive(adapter, vf);
 
-       ixgbe_send_vf_msg(adapter, vf, IXGBE_PF_CONTROL_MSG);
+       ixgbe_send_vf_msg(&adapter->hw, vf, IXGBE_PF_CONTROL_MSG);
 } /* ixgbe_init_vf */
 
 void
diff -r b9a500df3d47 -r 199ed00f028a sys/dev/pci/ixgbe/ix_txrx.c
--- a/sys/dev/pci/ixgbe/ix_txrx.c       Fri Mar 30 12:01:30 2018 +0000
+++ b/sys/dev/pci/ixgbe/ix_txrx.c       Fri Mar 30 12:07:34 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.24.2.7 2018/03/13 14:59:06 martin Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.24.2.8 2018/03/30 12:07:34 martin Exp $ */
 
 /******************************************************************************
 
@@ -865,23 +865,23 @@
 
        /* No support for offloads for non-L4 next headers */
        switch (ipproto) {
-               case IPPROTO_TCP:
-                       if (mp->m_pkthdr.csum_flags &
-                           (M_CSUM_TCPv4 | M_CSUM_TCPv6))
-                               type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_L4T_TCP;
-                       else
-                               offload = false;
-                       break;
-               case IPPROTO_UDP:
-                       if (mp->m_pkthdr.csum_flags &
-                           (M_CSUM_UDPv4 | M_CSUM_UDPv6))
-                               type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_L4T_UDP;
-                       else
-                               offload = false;
-                       break;
-               default:
+       case IPPROTO_TCP:
+               if (mp->m_pkthdr.csum_flags &



Home | Main Index | Thread Index | Old Index