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 Limit {tx,rx}_process_limit sysctl values ...



details:   https://anonhg.NetBSD.org/src/rev/ba4104815d36
branches:  trunk
changeset: 365790:ba4104815d36
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Apr 25 07:54:42 2022 +0000

description:
Limit {tx,rx}_process_limit sysctl values from 1 to num_{tx,rx}_desc.

diffstat:

 sys/dev/pci/ixgbe/ixgbe.c |  118 +++++++++++++++++++++++++++++----------------
 sys/dev/pci/ixgbe/ixv.c   |  115 ++++++++++++++++++++++++++++++--------------
 2 files changed, 153 insertions(+), 80 deletions(-)

diffs (truncated from 359 to 300 lines):

diff -r 59cc418a3db7 -r ba4104815d36 sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Mon Apr 25 07:51:12 2022 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Mon Apr 25 07:54:42 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.312 2022/03/10 04:14:34 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.313 2022/04/25 07:54:42 msaitoh Exp $ */
 
 /******************************************************************************
 
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.312 2022/03/10 04:14:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.313 2022/04/25 07:54:42 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -238,8 +238,6 @@
 static int     ixgbe_get_default_advertise(struct adapter *);
 
 /* Sysctl handlers */
-static void    ixgbe_set_sysctl_value(struct adapter *, const char *,
-                    const char *, int *, int);
 static int     ixgbe_sysctl_flowcntl(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_advertise(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_interrupt_rate_handler(SYSCTLFN_PROTO);
@@ -259,6 +257,8 @@
 static int     ixgbe_sysctl_eee_state(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_debug(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_rx_copy_len(SYSCTLFN_PROTO);
+static int     ixgbe_sysctl_tx_process_limit(SYSCTLFN_PROTO);
+static int     ixgbe_sysctl_rx_process_limit(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_wol_enable(SYSCTLFN_PROTO);
 static int     ixgbe_sysctl_wufc(SYSCTLFN_PROTO);
 
@@ -963,15 +963,6 @@
        /* Set an initial default flow control value */
        hw->fc.requested_mode = ixgbe_flow_control;
 
-       /* Sysctls for limiting the amount of work done in the taskqueues */
-       ixgbe_set_sysctl_value(adapter, "rx_processing_limit",
-           "max number of rx packets to process",
-           &adapter->rx_process_limit, ixgbe_rx_process_limit);
-
-       ixgbe_set_sysctl_value(adapter, "tx_processing_limit",
-           "max number of tx packets to process",
-           &adapter->tx_process_limit, ixgbe_tx_process_limit);
-
        /* Do descriptor calc and sanity checks */
        if (((ixgbe_txd * sizeof(union ixgbe_adv_tx_desc)) % DBA_ALIGN) != 0 ||
            ixgbe_txd < MIN_TXD || ixgbe_txd > MAX_TXD) {
@@ -987,6 +978,14 @@
        } else
                adapter->num_rx_desc = ixgbe_rxd;
 
+       /* Sysctls for limiting the amount of work done in the taskqueues */
+       adapter->rx_process_limit
+           = (ixgbe_rx_process_limit <= adapter->num_rx_desc)
+           ? ixgbe_rx_process_limit : adapter->num_rx_desc;
+       adapter->tx_process_limit
+           = (ixgbe_tx_process_limit <= adapter->num_tx_desc)
+           ? ixgbe_tx_process_limit : adapter->num_tx_desc;
+
        /* Set default high limit of copying mbuf in rxeof */
        adapter->rx_copy_len = IXGBE_RX_COPY_LEN_MAX;
 
@@ -3436,6 +3435,20 @@
                aprint_error_dev(dev, "could not create sysctl\n");
 
        if (sysctl_createv(log, 0, &rnode, &cnode,
+           CTLFLAG_READWRITE, CTLTYPE_INT, "rx_process_limit",
+           SYSCTL_DESCR("max number of RX packets to process"),
+           ixgbe_sysctl_rx_process_limit, 0, (void *)adapter, 0, CTL_CREATE,
+           CTL_EOL) != 0)
+               aprint_error_dev(dev, "could not create sysctl\n");
+
+       if (sysctl_createv(log, 0, &rnode, &cnode,
+           CTLFLAG_READWRITE, CTLTYPE_INT, "tx_process_limit",
+           SYSCTL_DESCR("max number of TX packets to process"),
+           ixgbe_sysctl_tx_process_limit, 0, (void *)adapter, 0, CTL_CREATE,
+           CTL_EOL) != 0)
+               aprint_error_dev(dev, "could not create sysctl\n");
+
+       if (sysctl_createv(log, 0, &rnode, &cnode,
            CTLFLAG_READONLY, CTLTYPE_INT,
            "num_queues", SYSCTL_DESCR("Number of queues"),
            NULL, 0, &adapter->num_queues, 0, CTL_CREATE, CTL_EOL) != 0)
@@ -5381,35 +5394,6 @@
 } /* ixgbe_free_pci_resources */
 
 /************************************************************************
- * ixgbe_set_sysctl_value
- ************************************************************************/
-static void
-ixgbe_set_sysctl_value(struct adapter *adapter, const char *name,
-    const char *description, int *limit, int value)
-{
-       device_t dev =  adapter->dev;
-       struct sysctllog **log;
-       const struct sysctlnode *rnode, *cnode;
-
-       /*
-        * It's not required to check recovery mode because this function never
-        * touches hardware.
-        */
-
-       log = &adapter->sysctllog;
-       if ((rnode = ixgbe_sysctl_instance(adapter)) == NULL) {
-               aprint_error_dev(dev, "could not create sysctl root\n");
-               return;
-       }
-       if (sysctl_createv(log, 0, &rnode, &cnode,
-           CTLFLAG_READWRITE, CTLTYPE_INT,
-           name, SYSCTL_DESCR(description),
-               NULL, 0, limit, 0, CTL_CREATE, CTL_EOL) != 0)
-               aprint_error_dev(dev, "could not create sysctl\n");
-       *limit = value;
-} /* ixgbe_set_sysctl_value */
-
-/************************************************************************
  * ixgbe_sysctl_flowcntl
  *
  *   SYSCTL wrapper around setting Flow Control
@@ -6248,6 +6232,56 @@
 } /* ixgbe_sysctl_rx_copy_len */
 
 /************************************************************************
+ * ixgbe_sysctl_tx_process_limit
+ ************************************************************************/
+static int
+ixgbe_sysctl_tx_process_limit(SYSCTLFN_ARGS)
+{
+       struct sysctlnode node = *rnode;
+       struct adapter *adapter = (struct adapter *)node.sysctl_data;
+       int error;
+       int result = adapter->tx_process_limit;
+
+       node.sysctl_data = &result;
+       error = sysctl_lookup(SYSCTLFN_CALL(&node));
+
+       if (error || newp == NULL)
+               return error;
+
+       if ((result <= 0) || (result > adapter->num_tx_desc))
+               return EINVAL;
+
+       adapter->tx_process_limit = result;
+
+       return 0;
+} /* ixgbe_sysctl_tx_process_limit */
+
+/************************************************************************
+ * ixgbe_sysctl_rx_process_limit
+ ************************************************************************/
+static int
+ixgbe_sysctl_rx_process_limit(SYSCTLFN_ARGS)
+{
+       struct sysctlnode node = *rnode;
+       struct adapter *adapter = (struct adapter *)node.sysctl_data;
+       int error;
+       int result = adapter->rx_process_limit;
+
+       node.sysctl_data = &result;
+       error = sysctl_lookup(SYSCTLFN_CALL(&node));
+
+       if (error || newp == NULL)
+               return error;
+
+       if ((result <= 0) || (result > adapter->num_rx_desc))
+               return EINVAL;
+
+       adapter->rx_process_limit = result;
+
+       return 0;
+} /* ixgbe_sysctl_rx_process_limit */
+
+/************************************************************************
  * ixgbe_init_device_features
  ************************************************************************/
 static void
diff -r 59cc418a3db7 -r ba4104815d36 sys/dev/pci/ixgbe/ixv.c
--- a/sys/dev/pci/ixgbe/ixv.c   Mon Apr 25 07:51:12 2022 +0000
+++ b/sys/dev/pci/ixgbe/ixv.c   Mon Apr 25 07:54:42 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixv.c,v 1.178 2022/01/25 01:56:22 msaitoh Exp $ */
+/* $NetBSD: ixv.c,v 1.179 2022/04/25 07:54:42 msaitoh Exp $ */
 
 /******************************************************************************
 
@@ -35,7 +35,7 @@
 /*$FreeBSD: head/sys/dev/ixgbe/if_ixv.c 331224 2018-03-19 20:55:05Z erj $*/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.178 2022/01/25 01:56:22 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.179 2022/04/25 07:54:42 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -137,8 +137,6 @@
 static void    ixv_clear_evcnt(struct adapter *);
 
 /* Sysctl handlers */
-static void    ixv_set_sysctl_value(struct adapter *, const char *,
-                   const char *, int *, int);
 static int     ixv_sysctl_interrupt_rate_handler(SYSCTLFN_PROTO);
 static int     ixv_sysctl_next_to_check_handler(SYSCTLFN_PROTO);
 static int     ixv_sysctl_next_to_refresh_handler(SYSCTLFN_PROTO);
@@ -146,6 +144,8 @@
 static int     ixv_sysctl_rdt_handler(SYSCTLFN_PROTO);
 static int     ixv_sysctl_tdt_handler(SYSCTLFN_PROTO);
 static int     ixv_sysctl_tdh_handler(SYSCTLFN_PROTO);
+static int     ixv_sysctl_tx_process_limit(SYSCTLFN_PROTO);
+static int     ixv_sysctl_rx_process_limit(SYSCTLFN_PROTO);
 static int     ixv_sysctl_rx_copy_len(SYSCTLFN_PROTO);
 
 /* The MSI-X Interrupt handlers */
@@ -498,15 +498,6 @@
        /* Register for VLAN events */
        ether_set_vlan_cb(&adapter->osdep.ec, ixv_vlan_cb);
 
-       /* Sysctls for limiting the amount of work done in the taskqueues */
-       ixv_set_sysctl_value(adapter, "rx_processing_limit",
-           "max number of rx packets to process",
-           &adapter->rx_process_limit, ixv_rx_process_limit);
-
-       ixv_set_sysctl_value(adapter, "tx_processing_limit",
-           "max number of tx packets to process",
-           &adapter->tx_process_limit, ixv_tx_process_limit);
-
        /* Do descriptor calc and sanity checks */
        if (((ixv_txd * sizeof(union ixgbe_adv_tx_desc)) % DBA_ALIGN) != 0 ||
            ixv_txd < MIN_TXD || ixv_txd > MAX_TXD) {
@@ -522,6 +513,14 @@
        } else
                adapter->num_rx_desc = ixv_rxd;
 
+       /* Sysctls for limiting the amount of work done in the taskqueues */
+       adapter->rx_process_limit
+           = (ixv_rx_process_limit <= adapter->num_rx_desc)
+           ? ixv_rx_process_limit : adapter->num_rx_desc;
+       adapter->tx_process_limit
+           = (ixv_tx_process_limit <= adapter->num_tx_desc)
+           ? ixv_tx_process_limit : adapter->num_tx_desc;
+
        /* Set default high limit of copying mbuf in rxeof */
        adapter->rx_copy_len = IXGBE_RX_COPY_LEN_MAX;
 
@@ -2564,6 +2563,20 @@
                aprint_error_dev(dev, "could not create sysctl\n");
 
        if (sysctl_createv(log, 0, &rnode, &cnode,
+           CTLFLAG_READWRITE, CTLTYPE_INT, "rx_process_limit",
+           SYSCTL_DESCR("max number of RX packets to process"),
+           ixv_sysctl_rx_process_limit, 0, (void *)adapter, 0, CTL_CREATE,
+           CTL_EOL) != 0)
+               aprint_error_dev(dev, "could not create sysctl\n");
+
+       if (sysctl_createv(log, 0, &rnode, &cnode,
+           CTLFLAG_READWRITE, CTLTYPE_INT, "tx_process_limit",
+           SYSCTL_DESCR("max number of TX packets to process"),
+           ixv_sysctl_tx_process_limit, 0, (void *)adapter, 0, CTL_CREATE,
+           CTL_EOL) != 0)
+               aprint_error_dev(dev, "could not create sysctl\n");
+
+       if (sysctl_createv(log, 0, &rnode, &cnode,
            CTLFLAG_READWRITE, CTLTYPE_BOOL, "enable_aim",
            SYSCTL_DESCR("Interrupt Moderation"),
            NULL, 0, &adapter->enable_aim, 0, CTL_CREATE, CTL_EOL) != 0)
@@ -2845,30 +2858,6 @@
 
 } /* ixv_clear_evcnt */
 
-/************************************************************************
- * ixv_set_sysctl_value
- ************************************************************************/
-static void
-ixv_set_sysctl_value(struct adapter *adapter, const char *name,
-       const char *description, int *limit, int value)
-{
-       device_t dev =  adapter->dev;
-       struct sysctllog **log;
-       const struct sysctlnode *rnode, *cnode;
-
-       log = &adapter->sysctllog;
-       if ((rnode = ixv_sysctl_instance(adapter)) == NULL) {
-               aprint_error_dev(dev, "could not create sysctl root\n");
-               return;
-       }
-       if (sysctl_createv(log, 0, &rnode, &cnode,
-           CTLFLAG_READWRITE, CTLTYPE_INT,
-           name, SYSCTL_DESCR(description),
-           NULL, 0, limit, 0, CTL_CREATE, CTL_EOL) != 0)
-               aprint_error_dev(dev, "could not create sysctl\n");
-       *limit = value;
-} /* ixv_set_sysctl_value */
-
 #define PRINTQS(adapter, regname)                                      \
        do {                                                            \
                struct ixgbe_hw *_hw = &(adapter)->hw;                  \



Home | Main Index | Thread Index | Old Index