Wed Jul 7 08:58:20 2021 UTC ()
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.
(msaitoh)
diff -r1.80 -r1.81 src/sys/dev/pci/ixgbe/ix_txrx.c
diff -r1.285 -r1.286 src/sys/dev/pci/ixgbe/ixgbe.c
diff -r1.75 -r1.76 src/sys/dev/pci/ixgbe/ixgbe.h
diff -r1.162 -r1.163 src/sys/dev/pci/ixgbe/ixv.c
--- src/sys/dev/pci/ixgbe/ix_txrx.c 2021/07/07 08:32:51 1.80
+++ src/sys/dev/pci/ixgbe/ix_txrx.c 2021/07/07 08:58:19 1.81
@@ -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 @@
* 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;
--- src/sys/dev/pci/ixgbe/ixgbe.c 2021/06/29 21:03:36 1.285
+++ src/sys/dev/pci/ixgbe/ixgbe.c 2021/07/07 08:58:19 1.286
@@ -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_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 @@
} 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 @@
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)
@@ -6172,6 +6183,31 @@
return 0;
} /* 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
--- src/sys/dev/pci/ixgbe/ixgbe.h 2021/03/09 10:03:18 1.75
+++ src/sys/dev/pci/ixgbe/ixgbe.h 2021/07/07 08:58:19 1.76
@@ -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 @@
u64 active_queues;
u32 num_rx_desc;
u32 rx_process_limit;
+ u32 rx_copy_len;
int num_jcl;
/* Multicast array memory */
--- src/sys/dev/pci/ixgbe/ixv.c 2021/06/16 00:21:18 1.162
+++ src/sys/dev/pci/ixgbe/ixv.c 2021/07/07 08:58:19 1.163
@@ -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_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 @@
} 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 @@
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,
@@ -2931,6 +2942,31 @@
return 0;
} /* 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