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 code to support API version 1.5. No fu...



details:   https://anonhg.NetBSD.org/src/rev/8b7cb7583ca6
branches:  trunk
changeset: 1029163:8b7cb7583ca6
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Fri Dec 24 05:11:04 2021 +0000

description:
Add code to support API version 1.5. No functional change.

  - This change adds almost all code to support API 1.5 except real negotiation
    and upgrade mailbox functions.
  - From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

diffstat:

 sys/dev/pci/ixgbe/if_sriov.c    |   26 +-
 sys/dev/pci/ixgbe/ixgbe.c       |    6 +-
 sys/dev/pci/ixgbe/ixgbe_82599.c |    8 +-
 sys/dev/pci/ixgbe/ixgbe_mbx.c   |  887 ++++++++++++++++++++++++++++-----------
 sys/dev/pci/ixgbe/ixgbe_mbx.h   |   54 +-
 sys/dev/pci/ixgbe/ixgbe_type.h  |   19 +-
 sys/dev/pci/ixgbe/ixgbe_vf.c    |   70 +-
 sys/dev/pci/ixgbe/ixgbe_x540.c  |    8 +-
 sys/dev/pci/ixgbe/ixv.c         |   10 +-
 9 files changed, 755 insertions(+), 333 deletions(-)

diffs (truncated from 1889 to 300 lines):

diff -r 1f4695b88dcc -r 8b7cb7583ca6 sys/dev/pci/ixgbe/if_sriov.c
--- a/sys/dev/pci/ixgbe/if_sriov.c      Fri Dec 24 05:05:57 2021 +0000
+++ b/sys/dev/pci/ixgbe/if_sriov.c      Fri Dec 24 05:11:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_sriov.c,v 1.16 2021/12/24 05:01:00 msaitoh Exp $ */
+/* $NetBSD: if_sriov.c,v 1.17 2021/12/24 05:11:04 msaitoh Exp $ */
 /******************************************************************************
 
   Copyright (c) 2001-2017, Intel Corporation
@@ -34,7 +34,7 @@
 /*$FreeBSD: head/sys/dev/ixgbe/if_sriov.c 327031 2017-12-20 18:15:06Z erj $*/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sriov.c,v 1.16 2021/12/24 05:01:00 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sriov.c,v 1.17 2021/12/24 05:11:04 msaitoh Exp $");
 
 #include "ixgbe.h"
 #include "ixgbe_sriov.h"
@@ -99,7 +99,7 @@
        if (vf->flags & IXGBE_VF_CTS)
                msg |= IXGBE_VT_MSGTYPE_CTS;
 
-       hw->mbx.ops.write(hw, &msg, 1, vf->pool);
+       hw->mbx.ops[vf->pool].write(hw, &msg, 1, vf->pool);
 }
 
 static inline void
@@ -594,7 +594,8 @@
 
        hw = &adapter->hw;
 
-       error = hw->mbx.ops.read(hw, msg, IXGBE_VFMAILBOX_SIZE, vf->pool);
+       error = hw->mbx.ops[vf->pool].read(hw, msg, IXGBE_VFMAILBOX_SIZE,
+           vf->pool);
 
        if (error != 0)
                return;
@@ -655,16 +656,17 @@
        for (i = 0; i < adapter->num_vfs; i++) {
                vf = &adapter->vfs[i];
 
-               if (vf->flags & IXGBE_VF_ACTIVE) {
-                       if (hw->mbx.ops.check_for_rst(hw, vf->pool) == 0)
-                               ixgbe_process_vf_reset(adapter, vf);
+               if ((vf->flags & IXGBE_VF_ACTIVE) == 0)
+                       continue;
+
+               if (hw->mbx.ops[vf->pool].check_for_rst(hw, vf->pool) == 0)
+                       ixgbe_process_vf_reset(adapter, vf);
 
-                       if (hw->mbx.ops.check_for_msg(hw, vf->pool) == 0)
-                               ixgbe_process_vf_msg(adapter, vf);
+               if (hw->mbx.ops[vf->pool].check_for_msg(hw, vf->pool) == 0)
+                       ixgbe_process_vf_msg(adapter, vf);
 
-                       if (hw->mbx.ops.check_for_ack(hw, vf->pool) == 0)
-                               ixgbe_process_vf_ack(adapter, vf);
-               }
+               if (hw->mbx.ops[vf->pool].check_for_ack(hw, vf->pool) == 0)
+                       ixgbe_process_vf_ack(adapter, vf);
        }
 } /* ixgbe_handle_mbx */
 
diff -r 1f4695b88dcc -r 8b7cb7583ca6 sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Fri Dec 24 05:05:57 2021 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Fri Dec 24 05:11:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.300 2021/12/16 10:48:49 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.301 2021/12/24 05:11:04 msaitoh Exp $ */
 
 /******************************************************************************
 
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.300 2021/12/16 10:48:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.301 2021/12/24 05:11:04 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -84,7 +84,7 @@
  * Driver version
  ************************************************************************/
 static const char ixgbe_driver_version[] = "4.0.1-k";
-/* XXX NetBSD: + 3.3.10 */
+/* XXX NetBSD: + 3.3.24 */
 
 /************************************************************************
  * PCI Device ID Table
diff -r 1f4695b88dcc -r 8b7cb7583ca6 sys/dev/pci/ixgbe/ixgbe_82599.c
--- a/sys/dev/pci/ixgbe/ixgbe_82599.c   Fri Dec 24 05:05:57 2021 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe_82599.c   Fri Dec 24 05:11:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_82599.c,v 1.28 2021/12/24 05:02:11 msaitoh Exp $ */
+/* $NetBSD: ixgbe_82599.c,v 1.29 2021/12/24 05:11:04 msaitoh Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -36,7 +36,7 @@
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_82599.c 331224 2018-03-19 20:55:05Z erj $*/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ixgbe_82599.c,v 1.28 2021/12/24 05:02:11 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_82599.c,v 1.29 2021/12/24 05:11:04 msaitoh Exp $");
 
 #include "ixgbe_type.h"
 #include "ixgbe_82599.h"
@@ -331,6 +331,7 @@
        struct ixgbe_phy_info *phy = &hw->phy;
        struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
        s32 ret_val;
+       u16 i;
 
        DEBUGFUNC("ixgbe_init_ops_82599");
 
@@ -392,7 +393,8 @@
        mac->arc_subsystem_valid = !!(IXGBE_READ_REG(hw, IXGBE_FWSM_BY_MAC(hw))
                                      & IXGBE_FWSM_MODE_MASK);
 
-       hw->mbx.ops.init_params = ixgbe_init_mbx_params_pf;
+       for (i = 0; i < 64; i++)
+               hw->mbx.ops[i].init_params = ixgbe_init_mbx_params_pf;
 
        /* EEPROM */
        eeprom->ops.read = ixgbe_read_eeprom_82599;
diff -r 1f4695b88dcc -r 8b7cb7583ca6 sys/dev/pci/ixgbe/ixgbe_mbx.c
--- a/sys/dev/pci/ixgbe/ixgbe_mbx.c     Fri Dec 24 05:05:57 2021 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe_mbx.c     Fri Dec 24 05:11:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_mbx.c,v 1.15 2021/12/24 05:03:37 msaitoh Exp $ */
+/* $NetBSD: ixgbe_mbx.c,v 1.16 2021/12/24 05:11:04 msaitoh Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -36,11 +36,14 @@
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_mbx.c 326022 2017-11-20 19:36:21Z pfg $*/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ixgbe_mbx.c,v 1.15 2021/12/24 05:03:37 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_mbx.c,v 1.16 2021/12/24 05:11:04 msaitoh Exp $");
 
 #include "ixgbe_type.h"
 #include "ixgbe_mbx.h"
 
+static s32 ixgbe_poll_for_msg(struct ixgbe_hw *hw, u16 mbx_id);
+static s32 ixgbe_poll_for_ack(struct ixgbe_hw *hw, u16 mbx_id);
+
 /**
  * ixgbe_read_mbx - Reads a message from the mailbox
  * @hw: pointer to the HW structure
@@ -53,42 +56,91 @@
 s32 ixgbe_read_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
 {
        struct ixgbe_mbx_info *mbx = &hw->mbx;
-       s32 ret_val = IXGBE_ERR_MBX;
 
        DEBUGFUNC("ixgbe_read_mbx");
 
        /* limit read to size of mailbox */
-       if (size > mbx->size)
+       if (size > mbx->size) {
+               ERROR_REPORT3(IXGBE_ERROR_ARGUMENT,
+                             "Invalid mailbox message size %u, changing to %u",
+                             size, mbx->size);
                size = mbx->size;
+       }
+
+       if (mbx->ops[mbx_id].read)
+               return mbx->ops[mbx_id].read(hw, msg, size, mbx_id);
+
+       return IXGBE_ERR_CONFIG;
+}
 
-       if (mbx->ops.read)
-               ret_val = mbx->ops.read(hw, msg, size, mbx_id);
+/**
+ * ixgbe_poll_mbx - Wait for message and read it from the mailbox
+ * @hw: pointer to the HW structure
+ * @msg: The message buffer
+ * @size: Length of buffer
+ * @mbx_id: id of mailbox to read
+ *
+ * returns SUCCESS if it successfully read message from buffer
+ **/
+s32 ixgbe_poll_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
+{
+       struct ixgbe_mbx_info *mbx = &hw->mbx;
+       s32 ret_val;
+
+       DEBUGFUNC("ixgbe_poll_mbx");
+
+       if (!mbx->ops[mbx_id].read || !mbx->ops[mbx_id].check_for_msg ||
+           !mbx->timeout)
+               return IXGBE_ERR_CONFIG;
+
+       /* limit read to size of mailbox */
+       if (size > mbx->size) {
+               ERROR_REPORT3(IXGBE_ERROR_ARGUMENT,
+                             "Invalid mailbox message size %u, changing to %u",
+                             size, mbx->size);
+               size = mbx->size;
+       }
+
+       ret_val = ixgbe_poll_for_msg(hw, mbx_id);
+       /* if ack received read message, otherwise we timed out */
+       if (!ret_val)
+               return mbx->ops[mbx_id].read(hw, msg, size, mbx_id);
 
        return ret_val;
 }
 
 /**
- * ixgbe_write_mbx - Write a message to the mailbox
+ * ixgbe_write_mbx - Write a message to the mailbox and wait for ACK
  * @hw: pointer to the HW structure
  * @msg: The message buffer
  * @size: Length of buffer
  * @mbx_id: id of mailbox to write
  *
- * returns SUCCESS if it successfully copied message into the buffer
+ * returns SUCCESS if it successfully copied message into the buffer and
+ * received an ACK to that message within specified period
  **/
 s32 ixgbe_write_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
 {
        struct ixgbe_mbx_info *mbx = &hw->mbx;
-       s32 ret_val = IXGBE_SUCCESS;
+       s32 ret_val = IXGBE_ERR_MBX;
 
        DEBUGFUNC("ixgbe_write_mbx");
 
+       /*
+        * exit if either we can't write, release
+        * or there is no timeout defined
+        */
+       if (!mbx->ops[mbx_id].write || !mbx->ops[mbx_id].check_for_ack ||
+           !mbx->ops[mbx_id].release || !mbx->timeout)
+               return IXGBE_ERR_CONFIG;
+
        if (size > mbx->size) {
-               ret_val = IXGBE_ERR_MBX;
+               ret_val = IXGBE_ERR_PARAM;
                ERROR_REPORT2(IXGBE_ERROR_ARGUMENT,
-                            "Invalid mailbox message size %d", size);
-       } else if (mbx->ops.write)
-               ret_val = mbx->ops.write(hw, msg, size, mbx_id);
+                            "Invalid mailbox message size %u", size);
+       } else {
+               ret_val = mbx->ops[mbx_id].write(hw, msg, size, mbx_id);
+       }
 
        return ret_val;
 }
@@ -103,12 +155,12 @@
 s32 ixgbe_check_for_msg(struct ixgbe_hw *hw, u16 mbx_id)
 {
        struct ixgbe_mbx_info *mbx = &hw->mbx;
-       s32 ret_val = IXGBE_ERR_MBX;
+       s32 ret_val = IXGBE_ERR_CONFIG;
 
        DEBUGFUNC("ixgbe_check_for_msg");
 
-       if (mbx->ops.check_for_msg)
-               ret_val = mbx->ops.check_for_msg(hw, mbx_id);
+       if (mbx->ops[mbx_id].check_for_msg)
+               ret_val = mbx->ops[mbx_id].check_for_msg(hw, mbx_id);
 
        return ret_val;
 }
@@ -123,12 +175,12 @@
 s32 ixgbe_check_for_ack(struct ixgbe_hw *hw, u16 mbx_id)
 {
        struct ixgbe_mbx_info *mbx = &hw->mbx;
-       s32 ret_val = IXGBE_ERR_MBX;
+       s32 ret_val = IXGBE_ERR_CONFIG;
 
        DEBUGFUNC("ixgbe_check_for_ack");
 
-       if (mbx->ops.check_for_ack)
-               ret_val = mbx->ops.check_for_ack(hw, mbx_id);
+       if (mbx->ops[mbx_id].check_for_ack)
+               ret_val = mbx->ops[mbx_id].check_for_ack(hw, mbx_id);
 
        return ret_val;
 }
@@ -143,12 +195,12 @@
 s32 ixgbe_check_for_rst(struct ixgbe_hw *hw, u16 mbx_id)
 {
        struct ixgbe_mbx_info *mbx = &hw->mbx;
-       s32 ret_val = IXGBE_ERR_MBX;
+       s32 ret_val = IXGBE_ERR_CONFIG;
 
        DEBUGFUNC("ixgbe_check_for_rst");
 
-       if (mbx->ops.check_for_rst)
-               ret_val = mbx->ops.check_for_rst(hw, mbx_id);
+       if (mbx->ops[mbx_id].check_for_rst)
+               ret_val = mbx->ops[mbx_id].check_for_rst(hw, mbx_id);
 



Home | Main Index | Thread Index | Old Index