diff options
| author | msaitoh <msaitoh@NetBSD.org> | 2021-07-07 08:58:19 +0000 |
|---|---|---|
| committer | msaitoh <msaitoh@NetBSD.org> | 2021-07-07 08:58:19 +0000 |
| commit | b6b5e90cb8de0d7e820a4e37368f9cc3e4dd54b0 (patch) | |
| tree | 108bf863d738601d4abb2a66366ad6b85b63a8fb | |
| parent | d7c9e19c460b9687491ade881624bfeaa4af0bb1 (diff) | |
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.
| -rw-r--r-- | sys/dev/pci/ixgbe/ix_txrx.c | 6 | ||||
| -rw-r--r-- | sys/dev/pci/ixgbe/ixgbe.c | 40 | ||||
| -rw-r--r-- | sys/dev/pci/ixgbe/ixgbe.h | 5 | ||||
| -rw-r--r-- | sys/dev/pci/ixgbe/ixv.c | 40 |
4 files changed, 82 insertions, 9 deletions
diff --git a/sys/dev/pci/ixgbe/ix_txrx.c b/sys/dev/pci/ixgbe/ix_txrx.c index 261019c9fa6..8a51e941064 100644 --- a/sys/dev/pci/ixgbe/ix_txrx.c +++ b/sys/dev/pci/ixgbe/ix_txrx.c @@ -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; diff --git a/sys/dev/pci/ixgbe/ixgbe.c b/sys/dev/pci/ixgbe/ixgbe.c index 6b54cd06f3f..76b4eca70e2 100644 --- a/sys/dev/pci/ixgbe/ixgbe.c +++ b/sys/dev/pci/ixgbe/ixgbe.c @@ -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(SYSCTLFN_PROTO); 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 dev, void *aux) } 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 *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 diff --git a/sys/dev/pci/ixgbe/ixgbe.h b/sys/dev/pci/ixgbe/ixgbe.h index 1a848eb607e..730bb445d6b 100644 --- a/sys/dev/pci/ixgbe/ixgbe.h +++ b/sys/dev/pci/ixgbe/ixgbe.h @@ -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 */ diff --git a/sys/dev/pci/ixgbe/ixv.c b/sys/dev/pci/ixgbe/ixv.c index 4a6b42df1b7..3c8823a6473 100644 --- a/sys/dev/pci/ixgbe/ixv.c +++ b/sys/dev/pci/ixgbe/ixv.c @@ -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(SYSCTLFN_PROTO); 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, void *aux) } 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 *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"), + 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 |
