Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Added sysctl nodes for the number of descriptors...



details:   https://anonhg.NetBSD.org/src/rev/b5e1102e6f85
branches:  trunk
changeset: 974402:b5e1102e6f85
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Fri Jul 31 09:25:42 2020 +0000

description:
Added sysctl nodes for the number of descriptors in ixl(4)

diffstat:

 sys/dev/pci/if_ixl.c |  65 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 63 insertions(+), 2 deletions(-)

diffs (121 lines):

diff -r 72609028331c -r b5e1102e6f85 sys/dev/pci/if_ixl.c
--- a/sys/dev/pci/if_ixl.c      Fri Jul 31 09:07:17 2020 +0000
+++ b/sys/dev/pci/if_ixl.c      Fri Jul 31 09:25:42 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ixl.c,v 1.69 2020/07/31 09:07:17 yamaguchi Exp $    */
+/*     $NetBSD: if_ixl.c,v 1.70 2020/07/31 09:25:42 yamaguchi Exp $    */
 
 /*
  * Copyright (c) 2013-2015, Intel Corporation
@@ -74,7 +74,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ixl.c,v 1.69 2020/07/31 09:07:17 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ixl.c,v 1.70 2020/07/31 09:25:42 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -84,6 +84,7 @@
 #include <sys/param.h>
 #include <sys/types.h>
 
+#include <sys/bitops.h>
 #include <sys/cpu.h>
 #include <sys/device.h>
 #include <sys/evcnt.h>
@@ -905,6 +906,7 @@
 static int     ixl_setup_sysctls(struct ixl_softc *);
 static void    ixl_teardown_sysctls(struct ixl_softc *);
 static int     ixl_sysctl_itr_handler(SYSCTLFN_PROTO);
+static int     ixl_sysctl_ndescs_handler(SYSCTLFN_PROTO);
 static int     ixl_queue_pairs_alloc(struct ixl_softc *);
 static void    ixl_queue_pairs_free(struct ixl_softc *);
 
@@ -1250,6 +1252,10 @@
 
        KASSERT(IXL_TXRX_PROCESS_UNLIMIT > sc->sc_rx_ring_ndescs);
        KASSERT(IXL_TXRX_PROCESS_UNLIMIT > sc->sc_tx_ring_ndescs);
+       KASSERT(sc->sc_rx_ring_ndescs ==
+           (1U << (fls32(sc->sc_rx_ring_ndescs) - 1)));
+       KASSERT(sc->sc_tx_ring_ndescs ==
+           (1U << (fls32(sc->sc_tx_ring_ndescs) - 1)));
 
        if (ixl_get_mac(sc) != 0) {
                /* error printed by ixl_get_mac */
@@ -6640,6 +6646,14 @@
                goto out;
 
        error = sysctl_createv(log, 0, &rxnode, NULL,
+           CTLFLAG_READWRITE, CTLTYPE_INT, "descriptor_num",
+           SYSCTL_DESCR("the number of rx descriptors"),
+           ixl_sysctl_ndescs_handler, 0,
+           (void *)sc, 0, CTL_CREATE, CTL_EOL);
+       if (error)
+               goto out;
+
+       error = sysctl_createv(log, 0, &rxnode, NULL,
            CTLFLAG_READWRITE, CTLTYPE_INT, "intr_process_limit",
            SYSCTL_DESCR("max number of Rx packets"
            " to process for interrupt processing"),
@@ -6671,6 +6685,14 @@
                goto out;
 
        error = sysctl_createv(log, 0, &txnode, NULL,
+           CTLFLAG_READWRITE, CTLTYPE_INT, "descriptor_num",
+           SYSCTL_DESCR("the number of tx descriptors"),
+           ixl_sysctl_ndescs_handler, 0,
+           (void *)sc, 0, CTL_CREATE, CTL_EOL);
+       if (error)
+               goto out;
+
+       error = sysctl_createv(log, 0, &txnode, NULL,
            CTLFLAG_READWRITE, CTLTYPE_INT, "intr_process_limit",
            SYSCTL_DESCR("max number of Tx packets"
            " to process for interrupt processing"),
@@ -6749,6 +6771,45 @@
        return 0;
 }
 
+static int
+ixl_sysctl_ndescs_handler(SYSCTLFN_ARGS)
+{
+       struct sysctlnode node = *rnode;
+       struct ixl_softc *sc = (struct ixl_softc *)node.sysctl_data;
+       struct ifnet *ifp = &sc->sc_ec.ec_if;
+       unsigned int *ndescs_ptr, ndescs, n;
+       int error;
+
+       if (ixl_sysctlnode_is_rx(&node)) {
+               ndescs_ptr = &sc->sc_rx_ring_ndescs;
+       } else {
+               ndescs_ptr = &sc->sc_tx_ring_ndescs;
+       }
+
+       ndescs = *ndescs_ptr;
+       node.sysctl_data = &ndescs;
+       node.sysctl_size = sizeof(ndescs);
+
+       error = sysctl_lookup(SYSCTLFN_CALL(&node));
+
+       if (error || newp == NULL)
+               return error;
+
+       if (ISSET(ifp->if_flags, IFF_RUNNING))
+               return EBUSY;
+
+       if (ndescs < 8 || 0xffff < ndescs)
+               return EINVAL;
+
+       n = 1U << (fls32(ndescs) - 1);
+       if (n != ndescs)
+               return EINVAL;
+
+       *ndescs_ptr = ndescs;
+
+       return 0;
+}
+
 static struct workqueue *
 ixl_workq_create(const char *name, pri_t prio, int ipl, int flags)
 {



Home | Main Index | Thread Index | Old Index