Module Name: src Committed By: msaitoh Date: Wed Jul 7 08:58:20 UTC 2021
Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixgbe.h ixv.c Log Message: Add new sysctl "rx_copy_len". ixgbe_rxeof() has an optimization "RX_COPY" to reduce costs of bus_dmamap_load_mbuf() and bus_dmamap_unload() by copying a mbuf cluster's memory to a newly allocated mbuf's MH_databuf[] and recycle the original map. The optimization is used when a length of a packet is smaller than a specific value. The value is calculated based on MHLEN. The size of MHLEN is architecture specific. It's 256 or 512. Make the threshold controllable by adding a new sysctl. To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.285 -r1.286 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pci/ixgbe/ixgbe.h cvs rdiff -u -r1.162 -r1.163 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.80 src/sys/dev/pci/ixgbe/ix_txrx.c:1.81 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.80 Wed Jul 7 08:32:51 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Wed Jul 7 08:58:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.80 2021/07/07 08:32:51 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.81 2021/07/07 08:58:19 msaitoh Exp $ */ /****************************************************************************** @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.80 2021/07/07 08:32:51 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.81 2021/07/07 08:58:19 msaitoh Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -1976,7 +1976,7 @@ ixgbe_rxeof(struct ix_queue *que) * is cache aligned into a new mbuf, and * leave the old mbuf+cluster for re-use. */ - if (eop && len <= IXGBE_RX_COPY_LEN) { + if (eop && len <= adapter->rx_copy_len) { sendmp = m_gethdr(M_NOWAIT, MT_DATA); if (sendmp != NULL) { sendmp->m_data += IXGBE_RX_COPY_ALIGN; Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.285 src/sys/dev/pci/ixgbe/ixgbe.c:1.286 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.285 Tue Jun 29 21:03:36 2021 +++ src/sys/dev/pci/ixgbe/ixgbe.c Wed Jul 7 08:58:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.285 2021/06/29 21:03:36 pgoyette Exp $ */ +/* $NetBSD: ixgbe.c,v 1.286 2021/07/07 08:58:19 msaitoh Exp $ */ /****************************************************************************** @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.285 2021/06/29 21:03:36 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.286 2021/07/07 08:58:19 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -259,6 +259,7 @@ static int ixgbe_sysctl_tdt_handler(SYSC static int ixgbe_sysctl_tdh_handler(SYSCTLFN_PROTO); 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_wol_enable(SYSCTLFN_PROTO); static int ixgbe_sysctl_wufc(SYSCTLFN_PROTO); @@ -986,6 +987,9 @@ ixgbe_attach(device_t parent, device_t d } else adapter->num_rx_desc = ixgbe_rxd; + /* Set default high limit of copying mbuf in rxeof */ + adapter->rx_copy_len = IXGBE_RX_COPY_LEN_MAX; + adapter->num_jcl = adapter->num_rx_desc * IXGBE_JCLNUM_MULTI; /* Allocate our TX/RX Queues */ @@ -3368,6 +3372,13 @@ ixgbe_add_device_sysctls(struct adapter aprint_error_dev(dev, "could not create sysctl\n"); if (sysctl_createv(log, 0, &rnode, &cnode, + CTLFLAG_READWRITE, CTLTYPE_INT, + "rx_copy_len", SYSCTL_DESCR("RX Copy Length"), + ixgbe_sysctl_rx_copy_len, 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_rx_desc", SYSCTL_DESCR("Number of rx descriptors"), NULL, 0, &adapter->num_rx_desc, 0, CTL_CREATE, CTL_EOL) != 0) @@ -6174,6 +6185,31 @@ ixgbe_sysctl_debug(SYSCTLFN_ARGS) } /* ixgbe_sysctl_debug */ /************************************************************************ + * ixgbe_sysctl_rx_copy_len + ************************************************************************/ +static int +ixgbe_sysctl_rx_copy_len(SYSCTLFN_ARGS) +{ + struct sysctlnode node = *rnode; + struct adapter *adapter = (struct adapter *)node.sysctl_data; + int error; + int result = adapter->rx_copy_len; + + node.sysctl_data = &result; + error = sysctl_lookup(SYSCTLFN_CALL(&node)); + + if (error || newp == NULL) + return error; + + if ((result < 0) || (result > IXGBE_RX_COPY_LEN_MAX)) + return EINVAL; + + adapter->rx_copy_len = result; + + return 0; +} /* ixgbe_sysctl_rx_copy_len */ + +/************************************************************************ * ixgbe_init_device_features ************************************************************************/ static void Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.75 src/sys/dev/pci/ixgbe/ixgbe.h:1.76 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.75 Tue Mar 9 10:03:18 2021 +++ src/sys/dev/pci/ixgbe/ixgbe.h Wed Jul 7 08:58:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.h,v 1.75 2021/03/09 10:03:18 msaitoh Exp $ */ +/* $NetBSD: ixgbe.h,v 1.76 2021/07/07 08:58:19 msaitoh Exp $ */ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause @@ -185,7 +185,7 @@ */ #define MPKTHSIZE (offsetof(struct _mbuf_dummy, m_pktdat)) #define IXGBE_RX_COPY_HDR_PADDED ((((MPKTHSIZE - 1) / 32) + 1) * 32) -#define IXGBE_RX_COPY_LEN (MSIZE - IXGBE_RX_COPY_HDR_PADDED) +#define IXGBE_RX_COPY_LEN_MAX (MSIZE - IXGBE_RX_COPY_HDR_PADDED) #define IXGBE_RX_COPY_ALIGN (IXGBE_RX_COPY_HDR_PADDED - MPKTHSIZE) /* Keep older OS drivers building... */ @@ -568,6 +568,7 @@ struct adapter { u64 active_queues; u32 num_rx_desc; u32 rx_process_limit; + u32 rx_copy_len; int num_jcl; /* Multicast array memory */ Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.162 src/sys/dev/pci/ixgbe/ixv.c:1.163 --- src/sys/dev/pci/ixgbe/ixv.c:1.162 Wed Jun 16 00:21:18 2021 +++ src/sys/dev/pci/ixgbe/ixv.c Wed Jul 7 08:58:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixv.c,v 1.162 2021/06/16 00:21:18 riastradh Exp $ */ +/* $NetBSD: ixv.c,v 1.163 2021/07/07 08:58:19 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.162 2021/06/16 00:21:18 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.163 2021/07/07 08:58:19 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -148,6 +148,7 @@ static int ixv_sysctl_rdh_handler(SYSCTL 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_rx_copy_len(SYSCTLFN_PROTO); /* The MSI-X Interrupt handlers */ static int ixv_msix_que(void *); @@ -516,6 +517,9 @@ ixv_attach(device_t parent, device_t dev } else adapter->num_rx_desc = ixv_rxd; + /* Set default high limit of copying mbuf in rxeof */ + adapter->rx_copy_len = IXGBE_RX_COPY_LEN_MAX; + adapter->num_jcl = adapter->num_rx_desc * IXGBE_JCLNUM_MULTI; /* Setup MSI-X */ @@ -2561,6 +2565,13 @@ ixv_add_device_sysctls(struct adapter *a aprint_error_dev(dev, "could not create sysctl\n"); if (sysctl_createv(log, 0, &rnode, &cnode, + CTLFLAG_READWRITE, CTLTYPE_INT, + "rx_copy_len", SYSCTL_DESCR("RX Copy Length"), + ixv_sysctl_rx_copy_len, 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_jcl_per_queue", SYSCTL_DESCR("Number of jumbo buffers per queue"), NULL, 0, &adapter->num_jcl, 0, CTL_CREATE, @@ -2933,6 +2944,31 @@ ixv_sysctl_debug(SYSCTLFN_ARGS) } /* ixv_sysctl_debug */ /************************************************************************ + * ixv_sysctl_rx_copy_len + ************************************************************************/ +static int +ixv_sysctl_rx_copy_len(SYSCTLFN_ARGS) +{ + struct sysctlnode node = *rnode; + struct adapter *adapter = (struct adapter *)node.sysctl_data; + int error; + int result = adapter->rx_copy_len; + + node.sysctl_data = &result; + error = sysctl_lookup(SYSCTLFN_CALL(&node)); + + if (error || newp == NULL) + return error; + + if ((result < 0) || (result > IXGBE_RX_COPY_LEN_MAX)) + return EINVAL; + + adapter->rx_copy_len = result; + + return 0; +} /* ixgbe_sysctl_rx_copy_len */ + +/************************************************************************ * ixv_init_device_features ************************************************************************/ static void