Module Name:    src
Committed By:   martin
Date:           Wed Sep 15 16:30:51 UTC 2021

Modified Files:
        src/share/man/man4 [netbsd-9]: ixg.4 ixv.4
        src/sys/dev/pci [netbsd-9]: files.pci
        src/sys/dev/pci/ixgbe [netbsd-9]: if_bypass.c if_fdir.c if_sriov.c
            ix_txrx.c ixgbe.c ixgbe.h ixgbe_82598.c ixgbe_82599.c ixgbe_api.c
            ixgbe_bypass.h ixgbe_common.c ixgbe_dcb.c ixgbe_dcb.h
            ixgbe_dcb_82598.c ixgbe_dcb_82598.h ixgbe_dcb_82599.c
            ixgbe_dcb_82599.h ixgbe_fdir.h ixgbe_features.h ixgbe_mbx.c
            ixgbe_netbsd.c ixgbe_netbsd.h ixgbe_netmap.c ixgbe_netmap.h
            ixgbe_osdep.c ixgbe_osdep.h ixgbe_phy.c ixgbe_rss.h ixgbe_sriov.h
            ixgbe_type.h ixgbe_vf.c ixgbe_x540.c ixgbe_x540.h ixgbe_x550.c
            ixgbe_x550.h ixv.c

Log Message:
Pull up the following (via patch), requested by msaitoh in ticket #1346:

        sys/dev/pci/ixgbe/ixgbe.c                       1.252, 1.280-1.283, 
1.286-1.287, 1.289-1.290 via patch
        sys/dev/pci/ixgbe/ixgbe.h                       1.73, 1.76-1.80 via 
patch
        sys/dev/pci/ixgbe/ix_txrx.c                     1.68-1.93
        sys/dev/pci/ixgbe/ixv.c                         1.153, 1.157-1.161, 
1.163-1.166 via patch
        sys/dev/pci/ixgbe/if_bypass.c                   1.7-1.9
        sys/dev/pci/ixgbe/if_fdir.c                     1.4-1.5
        sys/dev/pci/ixgbe/if_sriov.c                    1.10-1.11
        sys/dev/pci/ixgbe/ixgbe_82598.c                 1.16
        sys/dev/pci/ixgbe/ixgbe_82599.c                 1.23
        sys/dev/pci/ixgbe/ixgbe_api.c                   1.25
        sys/dev/pci/ixgbe/ixgbe_bypass.h                1.2
        sys/dev/pci/ixgbe/ixgbe_common.c                1.30-1.33
        sys/dev/pci/ixgbe/ixgbe_dcb.c                   1.10-1.11
        sys/dev/pci/ixgbe/ixgbe_dcb.h                   1.7
        sys/dev/pci/ixgbe/ixgbe_dcb_82598.c             1.8-1.9
        sys/dev/pci/ixgbe/ixgbe_dcb_82598.h             1.7
        sys/dev/pci/ixgbe/ixgbe_dcb_82599.c             1.8-1.9
        sys/dev/pci/ixgbe/ixgbe_dcb_82599.h             1.7
        sys/dev/pci/ixgbe/ixgbe_fdir.h                  1.3
        sys/dev/pci/ixgbe/ixgbe_features.h              1.3
        sys/dev/pci/ixgbe/ixgbe_mbx.c                   1.12
        sys/dev/pci/ixgbe/ixgbe_netbsd.c                1.13, 1.16-1.17
        sys/dev/pci/ixgbe/ixgbe_netbsd.h                1.13-1.14
        sys/dev/pci/ixgbe/ixgbe_netmap.c                1.3-1.4
        sys/dev/pci/ixgbe/ixgbe_netmap.h                1.2
        sys/dev/pci/ixgbe/ixgbe_osdep.c                 1.7
        sys/dev/pci/ixgbe/ixgbe_osdep.h                 1.29-1.30
        sys/dev/pci/ixgbe/ixgbe_phy.c                   1.24
        sys/dev/pci/ixgbe/ixgbe_rss.h                   1.5
        sys/dev/pci/ixgbe/ixgbe_sriov.h                 1.4
        sys/dev/pci/ixgbe/ixgbe_type.h                  1.49
        sys/dev/pci/ixgbe/ixgbe_vf.c                    1.27
        sys/dev/pci/ixgbe/ixgbe_x540.c                  1.18-1.19
        sys/dev/pci/ixgbe/ixgbe_x540.h                  1.9
        sys/dev/pci/ixgbe/ixgbe_x550.c                  1.19-1.20
        sys/dev/pci/ixgbe/ixgbe_x550.h                  1.6
        sys/dev/pci/files.pci                           1.438
        share/man/man4/ixg.4                            1.15
        share/man/man4/ixv.4                            1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
  Before this commit, resource shortage was easily occurred because
  the total number of the clusters is small.
- Improve performance:
  - Use m_adj(ETHER_ALIGN) more.
  - Sprinkle __predict_false() in the RX path.
  - Don't pre-allocate a cluster for RXCOPY case to improve short
    packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
  DMA buffer. Also, when the buffer is already freed, do not call
  bus_dmamap_unload(9) (no resource leaks with this change). This
  change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
  ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
  on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
  address. At least, this change is required for macppc
  (sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
  panic.
- Save the discard_multidesc state to not to forget the state by
  exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
  packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
  change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.


To generate a diff of this commit:
cvs rdiff -u -r1.12.4.1 -r1.12.4.2 src/share/man/man4/ixg.4
cvs rdiff -u -r1.4.2.2 -r1.4.2.3 src/share/man/man4/ixv.4
cvs rdiff -u -r1.413.2.3 -r1.413.2.4 src/sys/dev/pci/files.pci
cvs rdiff -u -r1.4.8.2 -r1.4.8.3 src/sys/dev/pci/ixgbe/if_bypass.c \
    src/sys/dev/pci/ixgbe/ixgbe_osdep.c
cvs rdiff -u -r1.2 -r1.2.8.1 src/sys/dev/pci/ixgbe/if_fdir.c \
    src/sys/dev/pci/ixgbe/ixgbe_fdir.h
cvs rdiff -u -r1.6 -r1.6.2.1 src/sys/dev/pci/ixgbe/if_sriov.c
cvs rdiff -u -r1.54.2.5 -r1.54.2.6 src/sys/dev/pci/ixgbe/ix_txrx.c
cvs rdiff -u -r1.199.2.13 -r1.199.2.14 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.56.2.4 -r1.56.2.5 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.12.8.3 -r1.12.8.4 src/sys/dev/pci/ixgbe/ixgbe_82598.c
cvs rdiff -u -r1.21.4.1 -r1.21.4.2 src/sys/dev/pci/ixgbe/ixgbe_82599.c
cvs rdiff -u -r1.23.2.1 -r1.23.2.2 src/sys/dev/pci/ixgbe/ixgbe_api.c
cvs rdiff -u -r1.1 -r1.1.14.1 src/sys/dev/pci/ixgbe/ixgbe_bypass.h \
    src/sys/dev/pci/ixgbe/ixgbe_netmap.h
cvs rdiff -u -r1.25.2.3 -r1.25.2.4 src/sys/dev/pci/ixgbe/ixgbe_common.c
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/dev/pci/ixgbe/ixgbe_dcb.c
cvs rdiff -u -r1.6 -r1.6.8.1 src/sys/dev/pci/ixgbe/ixgbe_dcb.h \
    src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h \
    src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h
cvs rdiff -u -r1.7 -r1.7.8.1 src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.c \
    src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.c
cvs rdiff -u -r1.2 -r1.2.4.1 src/sys/dev/pci/ixgbe/ixgbe_features.h
cvs rdiff -u -r1.11 -r1.11.2.1 src/sys/dev/pci/ixgbe/ixgbe_mbx.c
cvs rdiff -u -r1.9.4.3 -r1.9.4.4 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c
cvs rdiff -u -r1.11.4.1 -r1.11.4.2 src/sys/dev/pci/ixgbe/ixgbe_netbsd.h
cvs rdiff -u -r1.2 -r1.2.2.1 src/sys/dev/pci/ixgbe/ixgbe_netmap.c
cvs rdiff -u -r1.23.6.3 -r1.23.6.4 src/sys/dev/pci/ixgbe/ixgbe_osdep.h
cvs rdiff -u -r1.18.4.3 -r1.18.4.4 src/sys/dev/pci/ixgbe/ixgbe_phy.c
cvs rdiff -u -r1.4 -r1.4.8.1 src/sys/dev/pci/ixgbe/ixgbe_rss.h
cvs rdiff -u -r1.3 -r1.3.8.1 src/sys/dev/pci/ixgbe/ixgbe_sriov.h
cvs rdiff -u -r1.41.2.2 -r1.41.2.3 src/sys/dev/pci/ixgbe/ixgbe_type.h
cvs rdiff -u -r1.18.2.3 -r1.18.2.4 src/sys/dev/pci/ixgbe/ixgbe_vf.c
cvs rdiff -u -r1.16.8.1 -r1.16.8.2 src/sys/dev/pci/ixgbe/ixgbe_x540.c
cvs rdiff -u -r1.8 -r1.8.8.1 src/sys/dev/pci/ixgbe/ixgbe_x540.h
cvs rdiff -u -r1.15.2.3 -r1.15.2.4 src/sys/dev/pci/ixgbe/ixgbe_x550.c
cvs rdiff -u -r1.5 -r1.5.4.1 src/sys/dev/pci/ixgbe/ixgbe_x550.h
cvs rdiff -u -r1.125.2.11 -r1.125.2.12 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/share/man/man4/ixg.4
diff -u src/share/man/man4/ixg.4:1.12.4.1 src/share/man/man4/ixg.4:1.12.4.2
--- src/share/man/man4/ixg.4:1.12.4.1	Thu Mar 11 16:00:24 2021
+++ src/share/man/man4/ixg.4	Wed Sep 15 16:30:51 2021
@@ -1,4 +1,4 @@
-.\" $NetBSD: ixg.4,v 1.12.4.1 2021/03/11 16:00:24 martin Exp $
+.\" $NetBSD: ixg.4,v 1.12.4.2 2021/09/15 16:30:51 martin Exp $
 .\"
 .\" Copyright (c) 2001-2008, Intel Corporation
 .\" All rights reserved.
@@ -33,7 +33,7 @@
 .\"
 .\" $FreeBSD: src/share/man/man4/ixgbe.4,v 1.3 2010/12/19 23:54:31 yongari Exp $
 .\"
-.Dd March 9, 2021
+.Dd August 25, 2021
 .Dt IXG 4
 .Os
 .Sh NAME
@@ -83,26 +83,6 @@ go to the Intel support website at:
 .\" with a supported adapter, email the specific information related to the
 .\" issue to
 .\" .Aq freebsd...@mailbox.intel.com .
-.Sh OPTIONS
-The
-.Nm
-driver doesn't use the common
-.Xr MCLGET 9
-interface and use the driver specific cluster allocation mechanism.
-If it's exhausted, the
-.Xr evcnt 9
-counter "ixgX qY Rx no jumbo mbuf" is incremented.
-If this is observed,
-the number can be changed by the following config parameter:
-.Bl -tag -width IXGBE_JCLNUM_MULTI -offset 3n
-.It Dv IXGBE_JCLNUM_MULTI
-The number of RX jumbo buffers (clusters) per queue is calculated by
-.Dv IXGBE_JCLNUM_MULTI
-* (number of rx descriptors).
-The total number of clusters per queue is available via the
-.Li hw.ixgN.num_jcl_per_queue
-.Xr sysctl 7 .
-.El
 .Sh SEE ALSO
 .Xr arp 4 ,
 .Xr ixv 4 ,

Index: src/share/man/man4/ixv.4
diff -u src/share/man/man4/ixv.4:1.4.2.2 src/share/man/man4/ixv.4:1.4.2.3
--- src/share/man/man4/ixv.4:1.4.2.2	Thu Mar 11 16:00:24 2021
+++ src/share/man/man4/ixv.4	Wed Sep 15 16:30:51 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ixv.4,v 1.4.2.2 2021/03/11 16:00:24 martin Exp $
+.\"	$NetBSD: ixv.4,v 1.4.2.3 2021/09/15 16:30:51 martin Exp $
 .\"
 .\" Copyright (c) 2018 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd March 9, 2021
+.Dd August 25, 2021
 .Dt IXV 4
 .Os
 .Sh NAME
@@ -43,26 +43,6 @@ newer chips support.
 It can be used on a
 .Nx
 guest that the host supports SR-IOV.
-.Sh OPTIONS
-The
-.Nm
-driver doesn't use the common
-.Xr MCLGET 9
-interface and use the driver specific cluster allocation mechanism.
-If it's exhausted, the
-.Xr evcnt 9
-counter "ixgX qY Rx no jumbo mbuf" is incremented.
-If this is observed,
-the number can be changed by the following config parameter:
-.Bl -tag -width IXGBE_JCLNUM_MULTI -offset 3n
-.It Dv IXGBE_JCLNUM_MULTI
-The number of RX jumbo buffers (clusters) per queue is calculated by
-.Dv IXGBE_JCLNUM_MULTI
-* (number of rx descriptors).
-The total number of clusters per queue is available with the
-.Li hw.ixgN.num_jcl_per_queue
-.Xr sysctl 7 .
-.El
 .Sh SEE ALSO
 .Xr arp 4 ,
 .Xr ixg 4 ,

Index: src/sys/dev/pci/files.pci
diff -u src/sys/dev/pci/files.pci:1.413.2.3 src/sys/dev/pci/files.pci:1.413.2.4
--- src/sys/dev/pci/files.pci:1.413.2.3	Thu Mar 11 16:00:24 2021
+++ src/sys/dev/pci/files.pci	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.413.2.3 2021/03/11 16:00:24 martin Exp $
+#	$NetBSD: files.pci,v 1.413.2.4 2021/09/15 16:30:50 martin Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -691,7 +691,6 @@ file	dev/pci/ixgbe/ixgbe_phy.c	ixg | ixv
 file	dev/pci/ixgbe/ixgbe_vf.c	ixg | ixv
 file	dev/pci/ixgbe/if_bypass.c	ixg | ixv
 file	dev/pci/ixgbe/if_fdir.c		ixg | ixv
-defparam opt_ixgbe.h	IXGBE_JCLNUM_MULTI
 
 # This appears to be the driver for virtual instances of i82599.
 device	ixv: ether, ifnet, arp, mii, mii_phy

Index: src/sys/dev/pci/ixgbe/if_bypass.c
diff -u src/sys/dev/pci/ixgbe/if_bypass.c:1.4.8.2 src/sys/dev/pci/ixgbe/if_bypass.c:1.4.8.3
--- src/sys/dev/pci/ixgbe/if_bypass.c:1.4.8.2	Wed Sep  2 12:34:55 2020
+++ src/sys/dev/pci/ixgbe/if_bypass.c	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: if_bypass.c,v 1.4.8.3 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
 
   Copyright (c) 2001-2017, Intel Corporation
@@ -32,6 +33,8 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/if_bypass.c 327031 2017-12-20 18:15:06Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: if_bypass.c,v 1.4.8.3 2021/09/15 16:30:50 martin Exp $");
 
 #include "ixgbe.h"
 
@@ -669,7 +672,7 @@ ixgbe_bp_log(SYSCTLFN_ARGS)
 		const char *action_str[] = {"ignore", "normal", "bypass",
 					    "isolate",};
 
-		/* verify vaild data  1 - 6 */
+		/* verify valid data  1 - 6 */
 		if (event < BYPASS_EVENT_MAIN_ON || event > BYPASS_EVENT_USR)
 			event = 0;
 
Index: src/sys/dev/pci/ixgbe/ixgbe_osdep.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_osdep.c:1.4.8.2 src/sys/dev/pci/ixgbe/ixgbe_osdep.c:1.4.8.3
--- src/sys/dev/pci/ixgbe/ixgbe_osdep.c:1.4.8.2	Sun Jan 26 11:03:17 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_osdep.c	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_osdep.c,v 1.4.8.2 2020/01/26 11:03:17 martin Exp $ */
+/* $NetBSD: ixgbe_osdep.c,v 1.4.8.3 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
 
@@ -34,6 +34,9 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_osdep.c 327031 2017-12-20 18:15:06Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_osdep.c,v 1.4.8.3 2021/09/15 16:30:50 martin Exp $");
+
 #include "ixgbe_osdep.h"
 #include "ixgbe.h"
 

Index: src/sys/dev/pci/ixgbe/if_fdir.c
diff -u src/sys/dev/pci/ixgbe/if_fdir.c:1.2 src/sys/dev/pci/ixgbe/if_fdir.c:1.2.8.1
--- src/sys/dev/pci/ixgbe/if_fdir.c:1.2	Wed Apr  4 08:13:07 2018
+++ src/sys/dev/pci/ixgbe/if_fdir.c	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: if_fdir.c,v 1.2.8.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
 
   Copyright (c) 2001-2017, Intel Corporation
@@ -32,6 +33,9 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/if_fdir.c 327031 2017-12-20 18:15:06Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: if_fdir.c,v 1.2.8.1 2021/09/15 16:30:50 martin Exp $");
+
 #include "ixgbe.h"
 
 #ifdef IXGBE_FDIR
Index: src/sys/dev/pci/ixgbe/ixgbe_fdir.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_fdir.h:1.2 src/sys/dev/pci/ixgbe/ixgbe_fdir.h:1.2.8.1
--- src/sys/dev/pci/ixgbe/ixgbe_fdir.h:1.2	Wed Apr  4 08:13:07 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_fdir.h	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_fdir.h,v 1.2.8.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
 
   Copyright (c) 2001-2017, Intel Corporation

Index: src/sys/dev/pci/ixgbe/if_sriov.c
diff -u src/sys/dev/pci/ixgbe/if_sriov.c:1.6 src/sys/dev/pci/ixgbe/if_sriov.c:1.6.2.1
--- src/sys/dev/pci/ixgbe/if_sriov.c:1.6	Thu Jun 27 05:55:40 2019
+++ src/sys/dev/pci/ixgbe/if_sriov.c	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: if_sriov.c,v 1.6.2.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
 
   Copyright (c) 2001-2017, Intel Corporation
@@ -32,6 +33,9 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/if_sriov.c 327031 2017-12-20 18:15:06Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: if_sriov.c,v 1.6.2.1 2021/09/15 16:30:50 martin Exp $");
+
 #include "ixgbe.h"
 #include "ixgbe_sriov.h"
 

Index: src/sys/dev/pci/ixgbe/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.54.2.5 src/sys/dev/pci/ixgbe/ix_txrx.c:1.54.2.6
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.54.2.5	Thu Mar 11 16:00:24 2021
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.54.2.5 2021/03/11 16:00:24 martin Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.54.2.6 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
 
@@ -63,6 +63,9 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.54.2.6 2021/09/15 16:30:50 martin Exp $");
+
 #include "opt_inet.h"
 #include "opt_inet6.h"
 
@@ -93,6 +96,10 @@ static bool ixgbe_rsc_enable = FALSE;
  */
 static int atr_sample_rate = 20;
 
+#define IXGBE_M_ADJ(adapter, rxr, mp)					\
+	if (adapter->max_frame_size <= (rxr->mbuf_sz - ETHER_ALIGN))	\
+		m_adj(mp, ETHER_ALIGN)
+
 /************************************************************************
  *  Local Function prototypes
  ************************************************************************/
@@ -202,7 +209,7 @@ ixgbe_mq_start(struct ifnet *ifp, struct
 {
 	struct adapter	*adapter = ifp->if_softc;
 	struct tx_ring	*txr;
-	int 		i;
+	int		i;
 #ifdef RSS
 	uint32_t bucket_id;
 #endif
@@ -482,6 +489,7 @@ retry:
 		return (error);
 	}
 
+#ifdef IXGBE_FDIR
 	/* Do the flow director magic */
 	if ((adapter->feat_en & IXGBE_FEATURE_FDIR) &&
 	    (txr->atr_sample) && (!adapter->fdir_reinit)) {
@@ -491,12 +499,13 @@ retry:
 			txr->atr_count = 0;
 		}
 	}
+#endif
 
 	olinfo_status |= IXGBE_ADVTXD_CC;
 	i = txr->next_avail_desc;
 	for (j = 0; j < map->dm_nsegs; j++) {
 		bus_size_t seglen;
-		bus_addr_t segaddr;
+		uint64_t segaddr;
 
 		txbuf = &txr->tx_buffers[i];
 		txd = &txr->tx_base[i];
@@ -1127,7 +1136,7 @@ ixgbe_txeof(struct tx_ring *txr)
 		 *   or the slot has the DD bit set.
 		 */
 		if (kring->nr_kflags < kring->nkr_num_slots &&
-		    txd[kring->nr_kflags].wb.status & IXGBE_TXD_STAT_DD) {
+		    le32toh(txd[kring->nr_kflags].wb.status) & IXGBE_TXD_STAT_DD) {
 			netmap_tx_irq(ifp, txr->me);
 		}
 		return false;
@@ -1152,7 +1161,7 @@ ixgbe_txeof(struct tx_ring *txr)
 		if (eop == NULL) /* No work */
 			break;
 
-		if ((eop->wb.status & IXGBE_TXD_STAT_DD) == 0)
+		if ((le32toh(eop->wb.status) & IXGBE_TXD_STAT_DD) == 0)
 			break;	/* I/O not complete */
 
 		if (buf->m_head) {
@@ -1328,7 +1337,7 @@ ixgbe_setup_hw_rsc(struct rx_ring *rxr)
  *      be recalled to try again.
  *
  *   XXX NetBSD TODO:
- *    - The ixgbe_rxeof() function always preallocates mbuf cluster (jcl),
+ *    - The ixgbe_rxeof() function always preallocates mbuf cluster,
  *      so the ixgbe_refresh_mbufs() function can be simplified.
  *
  ************************************************************************/
@@ -1338,30 +1347,27 @@ ixgbe_refresh_mbufs(struct rx_ring *rxr,
 	struct adapter      *adapter = rxr->adapter;
 	struct ixgbe_rx_buf *rxbuf;
 	struct mbuf         *mp;
-	int                 i, j, error;
+	int                 i, error;
 	bool                refreshed = false;
 
-	i = j = rxr->next_to_refresh;
-	/* Control the loop with one beyond */
-	if (++j == rxr->num_desc)
-		j = 0;
+	i = rxr->next_to_refresh;
+	/* next_to_refresh points to the previous one */
+	if (++i == rxr->num_desc)
+		i = 0;
 
-	while (j != limit) {
+	while (i != limit) {
 		rxbuf = &rxr->rx_buffers[i];
-		if (rxbuf->buf == NULL) {
-			mp = ixgbe_getjcl(&rxr->jcl_head, M_NOWAIT,
-			    MT_DATA, M_PKTHDR, rxr->mbuf_sz);
+		if (__predict_false(rxbuf->buf == NULL)) {
+			mp = ixgbe_getcl();
 			if (mp == NULL) {
-				rxr->no_jmbuf.ev_count++;
+				rxr->no_mbuf.ev_count++;
 				goto update;
 			}
-			if (adapter->max_frame_size <= (MCLBYTES - ETHER_ALIGN))
-				m_adj(mp, ETHER_ALIGN);
+			mp->m_pkthdr.len = mp->m_len = rxr->mbuf_sz;
+			IXGBE_M_ADJ(adapter, rxr, mp);
 		} else
 			mp = rxbuf->buf;
 
-		mp->m_pkthdr.len = mp->m_len = rxr->mbuf_sz;
-
 		/* If we're dealing with an mbuf that was copied rather
 		 * than replaced, there's no need to go through busdma.
 		 */
@@ -1370,7 +1376,7 @@ ixgbe_refresh_mbufs(struct rx_ring *rxr,
 			ixgbe_dmamap_unload(rxr->ptag, rxbuf->pmap);
 			error = bus_dmamap_load_mbuf(rxr->ptag->dt_dmat,
 			    rxbuf->pmap, mp, BUS_DMA_NOWAIT);
-			if (error != 0) {
+			if (__predict_false(error != 0)) {
 				device_printf(adapter->dev, "Refresh mbufs: "
 				    "payload dmamap load failure - %d\n",
 				    error);
@@ -1389,11 +1395,10 @@ ixgbe_refresh_mbufs(struct rx_ring *rxr,
 		}
 
 		refreshed = true;
-		/* Next is precalculated */
-		i = j;
+		/* next_to_refresh points to the previous one */
 		rxr->next_to_refresh = i;
-		if (++j == rxr->num_desc)
-			j = 0;
+		if (++i == rxr->num_desc)
+			i = 0;
 	}
 
 update:
@@ -1513,17 +1518,6 @@ ixgbe_setup_receive_ring(struct rx_ring 
 	/* Free current RX buffer structs and their mbufs */
 	ixgbe_free_receive_ring(rxr);
 
-	IXGBE_RX_UNLOCK(rxr);
-	/*
-	 * Now reinitialize our supply of jumbo mbufs.  The number
-	 * or size of jumbo mbufs may have changed.
-	 * Assume all of rxr->ptag are the same.
-	 */
-	ixgbe_jcl_reinit(adapter, rxr->ptag->dt_dmat, rxr,
-	    adapter->num_jcl, adapter->rx_mbuf_sz);
-
-	IXGBE_RX_LOCK(rxr);
-
 	/* Now replenish the mbufs */
 	for (int j = 0; j != rxr->num_desc; ++j) {
 		struct mbuf *mp;
@@ -1553,21 +1547,30 @@ ixgbe_setup_receive_ring(struct rx_ring 
 #endif /* DEV_NETMAP */
 
 		rxbuf->flags = 0;
-		rxbuf->buf = ixgbe_getjcl(&rxr->jcl_head, M_NOWAIT,
-		    MT_DATA, M_PKTHDR, adapter->rx_mbuf_sz);
+		rxbuf->buf = ixgbe_getcl();
 		if (rxbuf->buf == NULL) {
+			rxr->no_mbuf.ev_count++;
 			error = ENOBUFS;
 			goto fail;
 		}
 		mp = rxbuf->buf;
 		mp->m_pkthdr.len = mp->m_len = rxr->mbuf_sz;
+		IXGBE_M_ADJ(adapter, rxr, mp);
 		/* Get the memory mapping */
 		error = bus_dmamap_load_mbuf(rxr->ptag->dt_dmat, rxbuf->pmap,
 		    mp, BUS_DMA_NOWAIT);
-		if (error != 0)
-                        goto fail;
+		if (error != 0) {
+			/*
+			 * Clear this entry for later cleanup in
+			 * ixgbe_discard() which is called via
+			 * ixgbe_free_receive_ring().
+			 */
+			m_freem(mp);
+			rxbuf->buf = NULL;
+			goto fail;
+		}
 		bus_dmamap_sync(rxr->ptag->dt_dmat, rxbuf->pmap,
-		    0, adapter->rx_mbuf_sz, BUS_DMASYNC_PREREAD);
+		    0, mp->m_pkthdr.len, BUS_DMASYNC_PREREAD);
 		/* Update the descriptor and the cached value */
 		rxr->rx_base[j].read.pkt_addr =
 		    htole64(rxbuf->pmap->dm_segs[0].ds_addr);
@@ -1576,8 +1579,9 @@ ixgbe_setup_receive_ring(struct rx_ring 
 
 	/* Setup our descriptor indices */
 	rxr->next_to_check = 0;
-	rxr->next_to_refresh = 0;
+	rxr->next_to_refresh = adapter->num_rx_desc - 1; /* Fully allocated */
 	rxr->lro_enabled = FALSE;
+	rxr->discard_multidesc = false;
 	rxr->rx_copies.ev_count = 0;
 #if 0 /* NetBSD */
 	rxr->rx_bytes.ev_count = 0;
@@ -1699,9 +1703,6 @@ ixgbe_free_receive_buffers(struct rx_rin
 			}
 		}
 
-		/* NetBSD specific. See ixgbe_netbsd.c */
-		ixgbe_jcl_destroy(adapter, rxr);
-
 		if (rxr->rx_buffers != NULL) {
 			free(rxr->rx_buffers, M_DEVBUF);
 			rxr->rx_buffers = NULL;
@@ -1768,26 +1769,25 @@ ixgbe_rx_discard(struct rx_ring *rxr, in
 	rbuf = &rxr->rx_buffers[i];
 
 	/*
-	 * With advanced descriptors the writeback
-	 * clobbers the buffer addrs, so its easier
-	 * to just free the existing mbufs and take
-	 * the normal refresh path to get new buffers
-	 * and mapping.
+	 * With advanced descriptors the writeback clobbers the buffer addrs,
+	 * so its easier to just free the existing mbufs and take the normal
+	 * refresh path to get new buffers and mapping.
 	 */
 
 	if (rbuf->fmp != NULL) {/* Partial chain ? */
 		bus_dmamap_sync(rxr->ptag->dt_dmat, rbuf->pmap, 0,
 		    rbuf->buf->m_pkthdr.len, BUS_DMASYNC_POSTREAD);
+		ixgbe_dmamap_unload(rxr->ptag, rbuf->pmap);
 		m_freem(rbuf->fmp);
 		rbuf->fmp = NULL;
 		rbuf->buf = NULL; /* rbuf->buf is part of fmp's chain */
 	} else if (rbuf->buf) {
 		bus_dmamap_sync(rxr->ptag->dt_dmat, rbuf->pmap, 0,
 		    rbuf->buf->m_pkthdr.len, BUS_DMASYNC_POSTREAD);
+		ixgbe_dmamap_unload(rxr->ptag, rbuf->pmap);
 		m_free(rbuf->buf);
 		rbuf->buf = NULL;
 	}
-	ixgbe_dmamap_unload(rxr->ptag, rbuf->pmap);
 
 	rbuf->flags = 0;
 
@@ -1817,9 +1817,9 @@ ixgbe_rxeof(struct ix_queue *que)
 	struct ixgbe_rx_buf	*rbuf, *nbuf;
 	int			i, nextp, processed = 0;
 	u32			staterr = 0;
-	u32			count = 0;
+	u32			loopcount = 0;
 	u32			limit = adapter->rx_process_limit;
-	bool			discard_multidesc = false;
+	bool			discard_multidesc = rxr->discard_multidesc;
 #ifdef RSS
 	u16			pkt_info;
 #endif
@@ -1842,7 +1842,7 @@ ixgbe_rxeof(struct ix_queue *que)
 	 * layer.
 	 */
 	for (i = rxr->next_to_check;
-	     (count < limit) || (discard_multidesc == true);) {
+	     (loopcount < limit) || (discard_multidesc == true);) {
 
 		struct mbuf *sendmp, *mp;
 		struct mbuf *newmp;
@@ -1850,6 +1850,7 @@ ixgbe_rxeof(struct ix_queue *que)
 		u16         len;
 		u16         vtag = 0;
 		bool        eop;
+		bool        discard = false;
 
 		/* Sync the ring. */
 		ixgbe_dmamap_sync(rxr->rxdma.dma_tag, rxr->rxdma.dma_map,
@@ -1864,8 +1865,8 @@ ixgbe_rxeof(struct ix_queue *que)
 		if ((staterr & IXGBE_RXD_STAT_DD) == 0)
 			break;
 
-		count++;
-		sendmp = NULL;
+		loopcount++;
+		sendmp = newmp = NULL;
 		nbuf = NULL;
 		rsc = 0;
 		cur->wb.upper.status_error = 0;
@@ -1889,14 +1890,30 @@ ixgbe_rxeof(struct ix_queue *que)
 			goto next_desc;
 		}
 
-		/* pre-alloc new mbuf */
-		if (!discard_multidesc)
-			newmp = ixgbe_getjcl(&rxr->jcl_head, M_NOWAIT, MT_DATA,
-			    M_PKTHDR, rxr->mbuf_sz);
-		else
-			newmp = NULL;
-		if (newmp == NULL) {
-			rxr->no_jmbuf.ev_count++;
+		if (__predict_false(discard_multidesc))
+			discard = true;
+		else {
+			/* Pre-alloc new mbuf. */
+
+			if ((rbuf->fmp == NULL) &&
+			    eop && (len <= adapter->rx_copy_len)) {
+				/* For short packet. See below. */
+				sendmp = m_gethdr(M_NOWAIT, MT_DATA);
+				if (__predict_false(sendmp == NULL)) {
+					rxr->no_mbuf.ev_count++;
+					discard = true;
+				}
+			} else {
+				/* For long packet. */
+				newmp = ixgbe_getcl();
+				if (__predict_false(newmp == NULL)) {
+					rxr->no_mbuf.ev_count++;
+					discard = true;
+				}
+			}
+		}
+
+		if (__predict_false(discard)) {
 			/*
 			 * Descriptor initialization is already done by the
 			 * above code (cur->wb.upper.status_error = 0).
@@ -1958,46 +1975,60 @@ ixgbe_rxeof(struct ix_queue *que)
 		 * buffer struct and pass this along from one
 		 * descriptor to the next, until we get EOP.
 		 */
-		mp->m_len = len;
 		/*
 		 * See if there is a stored head
 		 * that determines what we are
 		 */
-		sendmp = rbuf->fmp;
-		if (sendmp != NULL) {  /* secondary frag */
+		if (rbuf->fmp != NULL) {
+			/* Secondary frag */
+			sendmp = rbuf->fmp;
+
+			/* Update new (used in future) mbuf */
+			newmp->m_pkthdr.len = newmp->m_len = rxr->mbuf_sz;
+			IXGBE_M_ADJ(adapter, rxr, newmp);
 			rbuf->buf = newmp;
 			rbuf->fmp = NULL;
+
+			/* For secondary frag */
+			mp->m_len = len;
 			mp->m_flags &= ~M_PKTHDR;
+
+			/* For sendmp */
 			sendmp->m_pkthdr.len += mp->m_len;
 		} else {
 			/*
-			 * Optimize.  This might be a small packet,
-			 * maybe just a TCP ACK.  Do a fast copy that
-			 * is cache aligned into a new mbuf, and
-			 * leave the old mbuf+cluster for re-use.
+			 * It's the first segment of a multi descriptor
+			 * packet or a single segment which contains a full
+			 * packet.
 			 */
-			if (eop && len <= IXGBE_RX_COPY_LEN) {
-				sendmp = m_gethdr(M_NOWAIT, MT_DATA);
-				if (sendmp != NULL) {
-					sendmp->m_data += IXGBE_RX_COPY_ALIGN;
-					ixgbe_bcopy(mp->m_data, sendmp->m_data,
-					    len);
-					sendmp->m_len = len;
-					rxr->rx_copies.ev_count++;
-					rbuf->flags |= IXGBE_RX_COPY;
 
-					m_freem(newmp);
-				}
-			}
-			if (sendmp == NULL) {
+			if (eop && (len <= adapter->rx_copy_len)) {
+				/*
+				 * Optimize.  This might be a small packet, may
+				 * be just a TCP ACK. Copy into a new mbuf, and
+				 * Leave the old mbuf+cluster for re-use.
+				 */
+				sendmp->m_data += ETHER_ALIGN;
+				memcpy(mtod(sendmp, void *),
+				    mtod(mp, void *), len);
+				rxr->rx_copies.ev_count++;
+				rbuf->flags |= IXGBE_RX_COPY;
+			} else {
+				/* Non short packet */
+
+				/* Update new (used in future) mbuf */
+				newmp->m_pkthdr.len = newmp->m_len
+				    = rxr->mbuf_sz;
+				IXGBE_M_ADJ(adapter, rxr, newmp);
 				rbuf->buf = newmp;
 				rbuf->fmp = NULL;
+
+				/* For sendmp */
 				sendmp = mp;
 			}
 
 			/* first desc of a non-ps chain */
-			sendmp->m_flags |= M_PKTHDR;
-			sendmp->m_pkthdr.len = mp->m_len;
+			sendmp->m_pkthdr.len = sendmp->m_len = len;
 		}
 		++processed;
 
@@ -2089,15 +2120,11 @@ next_desc:
 		/* Advance our pointers to the next descriptor. */
 		if (++i == rxr->num_desc)
 			i = 0;
+		rxr->next_to_check = i;
 
 		/* Now send to the stack or do LRO */
-		if (sendmp != NULL) {
-			rxr->next_to_check = i;
-			IXGBE_RX_UNLOCK(rxr);
+		if (sendmp != NULL)
 			ixgbe_rx_input(rxr, ifp, sendmp, ptype);
-			IXGBE_RX_LOCK(rxr);
-			i = rxr->next_to_check;
-		}
 
 		/* Every 8 descriptors we go to refresh mbufs */
 		if (processed == 8) {
@@ -2106,12 +2133,13 @@ next_desc:
 		}
 	}
 
+	/* Save the current status */
+	rxr->discard_multidesc = discard_multidesc;
+
 	/* Refresh any remaining buf structs */
 	if (ixgbe_rx_unrefreshed(rxr))
 		ixgbe_refresh_mbufs(rxr, i);
 
-	rxr->next_to_check = i;
-
 	IXGBE_RX_UNLOCK(rxr);
 
 #ifdef LRO
@@ -2212,7 +2240,7 @@ ixgbe_dma_malloc(struct adapter *adapter
 	}
 
 	r = bus_dmamem_map(dma->dma_tag->dt_dmat, &dma->dma_seg, rsegs,
-	    size, &dma->dma_vaddr, BUS_DMA_NOWAIT);
+	    size, &dma->dma_vaddr, BUS_DMA_NOWAIT | BUS_DMA_COHERENT);
 	if (r != 0) {
 		aprint_error_dev(dev, "%s: bus_dmamem_map failed; error %d\n",
 		    __func__, r);

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.13 src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.14
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.13	Thu Mar 11 16:00:24 2021
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.199.2.13 2021/03/11 16:00:24 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.199.2.14 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
 
@@ -63,11 +63,13 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.199.2.14 2021/09/15 16:30:50 martin Exp $");
+
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_net_mpsafe.h"
-#include "opt_ixgbe.h"
 #endif
 
 #include "ixgbe.h"
@@ -172,7 +174,7 @@ static int	ixgbe_ioctl(struct ifnet *, u
 static int	ixgbe_init(struct ifnet *);
 static void	ixgbe_init_locked(struct adapter *);
 static void	ixgbe_ifstop(struct ifnet *, int);
-static void	ixgbe_stop(void *);
+static void	ixgbe_stop_locked(void *);
 static void	ixgbe_init_device_features(struct adapter *);
 static void	ixgbe_check_fan_failure(struct adapter *, u32, bool);
 static void	ixgbe_add_media_types(struct adapter *);
@@ -246,12 +248,14 @@ static int	ixgbe_sysctl_power_state(SYSC
 static int	ixgbe_sysctl_print_rss_config(SYSCTLFN_PROTO);
 #endif
 static int	ixgbe_sysctl_next_to_check_handler(SYSCTLFN_PROTO);
+static int	ixgbe_sysctl_next_to_refresh_handler(SYSCTLFN_PROTO);
 static int	ixgbe_sysctl_rdh_handler(SYSCTLFN_PROTO);
 static int	ixgbe_sysctl_rdt_handler(SYSCTLFN_PROTO);
 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);
 
@@ -944,7 +948,8 @@ ixgbe_attach(device_t parent, device_t d
 	} else
 		adapter->num_rx_desc = ixgbe_rxd;
 
-	adapter->num_jcl = adapter->num_rx_desc * IXGBE_JCLNUM_MULTI;
+	/* Set default high limit of copying mbuf in rxeof */
+	adapter->rx_copy_len = IXGBE_RX_COPY_LEN_MAX;
 
 	/* Allocate our TX/RX Queues */
 	if (ixgbe_allocate_queues(adapter)) {
@@ -968,7 +973,8 @@ ixgbe_attach(device_t parent, device_t d
 		unsupported_sfp = true;
 		error = IXGBE_SUCCESS;
 	} else if (error) {
-		aprint_error_dev(dev, "Hardware initialization failed\n");
+		aprint_error_dev(dev,
+		    "Hardware initialization failed(error = %d)\n", error);
 		error = EIO;
 		goto err_late;
 	}
@@ -1210,7 +1216,7 @@ ixgbe_attach(device_t parent, device_t d
 
 	/* For Netmap */
 	adapter->init_locked = ixgbe_init_locked;
-	adapter->stop_locked = ixgbe_stop;
+	adapter->stop_locked = ixgbe_stop_locked;
 
 	if (adapter->feat_en & IXGBE_FEATURE_NETMAP)
 		ixgbe_netmap_attach(adapter);
@@ -1644,17 +1650,20 @@ ixgbe_update_stats_counters(struct adapt
 		stats->gorc.ev_count += IXGBE_READ_REG(hw, IXGBE_GORCL) +
 		    ((u64)IXGBE_READ_REG(hw, IXGBE_GORCH) << 32);
 		stats->gotc.ev_count += IXGBE_READ_REG(hw, IXGBE_GOTCL) +
-		    ((u64)IXGBE_READ_REG(hw, IXGBE_GOTCH) << 32) - total * ETHER_MIN_LEN;
+		    ((u64)IXGBE_READ_REG(hw, IXGBE_GOTCH) << 32)
+		    - total * ETHER_MIN_LEN;
 		stats->tor.ev_count += IXGBE_READ_REG(hw, IXGBE_TORL) +
 		    ((u64)IXGBE_READ_REG(hw, IXGBE_TORH) << 32);
 		stats->lxonrxc.ev_count += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT);
-		stats->lxoffrxc.ev_count += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
+		stats->lxoffrxc.ev_count
+		    += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
 	} else {
 		stats->lxonrxc.ev_count += IXGBE_READ_REG(hw, IXGBE_LXONRXC);
 		stats->lxoffrxc.ev_count += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
 		/* 82598 only has a counter in the high register */
 		stats->gorc.ev_count += IXGBE_READ_REG(hw, IXGBE_GORCH);
-		stats->gotc.ev_count += IXGBE_READ_REG(hw, IXGBE_GOTCH) - total * ETHER_MIN_LEN;
+		stats->gotc.ev_count += IXGBE_READ_REG(hw, IXGBE_GOTCH)
+		    - total * ETHER_MIN_LEN;
 		stats->tor.ev_count += IXGBE_READ_REG(hw, IXGBE_TORH);
 	}
 
@@ -1868,42 +1877,42 @@ ixgbe_add_hw_stats(struct adapter *adapt
 #endif
 
 		if (sysctl_createv(log, 0, &rnode, &cnode,
-		    CTLFLAG_READONLY,
-		    CTLTYPE_INT,
-		    "rxd_nxck", SYSCTL_DESCR("Receive Descriptor next to check"),
-			ixgbe_sysctl_next_to_check_handler, 0, (void *)rxr, 0,
+		    CTLFLAG_READONLY, CTLTYPE_INT, "rxd_nxck",
+		    SYSCTL_DESCR("Receive Descriptor next to check"),
+		    ixgbe_sysctl_next_to_check_handler, 0, (void *)rxr, 0,
 		    CTL_CREATE, CTL_EOL) != 0)
 			break;
 
 		if (sysctl_createv(log, 0, &rnode, &cnode,
-		    CTLFLAG_READONLY,
-		    CTLTYPE_INT,
-		    "rxd_head", SYSCTL_DESCR("Receive Descriptor Head"),
+		    CTLFLAG_READONLY, CTLTYPE_INT, "rxd_nxrf",
+		    SYSCTL_DESCR("Receive Descriptor next to refresh"),
+		    ixgbe_sysctl_next_to_refresh_handler, 0, (void *)rxr, 0,
+		    CTL_CREATE, CTL_EOL) != 0)
+			break;
+
+		if (sysctl_createv(log, 0, &rnode, &cnode,
+		    CTLFLAG_READONLY, CTLTYPE_INT, "rxd_head",
+		    SYSCTL_DESCR("Receive Descriptor Head"),
 		    ixgbe_sysctl_rdh_handler, 0, (void *)rxr, 0,
 		    CTL_CREATE, CTL_EOL) != 0)
 			break;
 
 		if (sysctl_createv(log, 0, &rnode, &cnode,
-		    CTLFLAG_READONLY,
-		    CTLTYPE_INT,
-		    "rxd_tail", SYSCTL_DESCR("Receive Descriptor Tail"),
+		    CTLFLAG_READONLY, CTLTYPE_INT, "rxd_tail",
+		    SYSCTL_DESCR("Receive Descriptor Tail"),
 		    ixgbe_sysctl_rdt_handler, 0, (void *)rxr, 0,
 		    CTL_CREATE, CTL_EOL) != 0)
 			break;
 
 		if (i < __arraycount(stats->qprc)) {
-			evcnt_attach_dynamic(&stats->qprc[i],
-			    EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
-			    "qprc");
-			evcnt_attach_dynamic(&stats->qptc[i],
-			    EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
-			    "qptc");
-			evcnt_attach_dynamic(&stats->qbrc[i],
-			    EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
-			    "qbrc");
-			evcnt_attach_dynamic(&stats->qbtc[i],
-			    EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
-			    "qbtc");
+			evcnt_attach_dynamic(&stats->qprc[i], EVCNT_TYPE_MISC,
+			    NULL, adapter->queues[i].evnamebuf, "qprc");
+			evcnt_attach_dynamic(&stats->qptc[i], EVCNT_TYPE_MISC,
+			    NULL, adapter->queues[i].evnamebuf, "qptc");
+			evcnt_attach_dynamic(&stats->qbrc[i], EVCNT_TYPE_MISC,
+			    NULL, adapter->queues[i].evnamebuf, "qbrc");
+			evcnt_attach_dynamic(&stats->qbtc[i], EVCNT_TYPE_MISC,
+			    NULL, adapter->queues[i].evnamebuf, "qbtc");
 			if (hw->mac.type >= ixgbe_mac_82599EB)
 				evcnt_attach_dynamic(&stats->qprdc[i],
 				    EVCNT_TYPE_MISC, NULL,
@@ -1911,13 +1920,15 @@ ixgbe_add_hw_stats(struct adapter *adapt
 		}
 
 		evcnt_attach_dynamic(&rxr->rx_packets, EVCNT_TYPE_MISC,
-		    NULL, adapter->queues[i].evnamebuf, "Queue Packets Received");
+		    NULL, adapter->queues[i].evnamebuf,
+		    "Queue Packets Received");
 		evcnt_attach_dynamic(&rxr->rx_bytes, EVCNT_TYPE_MISC,
-		    NULL, adapter->queues[i].evnamebuf, "Queue Bytes Received");
+		    NULL, adapter->queues[i].evnamebuf,
+		    "Queue Bytes Received");
 		evcnt_attach_dynamic(&rxr->rx_copies, EVCNT_TYPE_MISC,
 		    NULL, adapter->queues[i].evnamebuf, "Copied RX Frames");
-		evcnt_attach_dynamic(&rxr->no_jmbuf, EVCNT_TYPE_MISC,
-		    NULL, adapter->queues[i].evnamebuf, "Rx no jumbo mbuf");
+		evcnt_attach_dynamic(&rxr->no_mbuf, EVCNT_TYPE_MISC,
+		    NULL, adapter->queues[i].evnamebuf, "Rx no mbuf");
 		evcnt_attach_dynamic(&rxr->rx_discarded, EVCNT_TYPE_MISC,
 		    NULL, adapter->queues[i].evnamebuf, "Rx discarded");
 #ifdef LRO
@@ -2115,7 +2126,7 @@ ixgbe_clear_evcnt(struct adapter *adapte
 		rxr->rx_packets.ev_count = 0;
 		rxr->rx_bytes.ev_count = 0;
 		rxr->rx_copies.ev_count = 0;
-		rxr->no_jmbuf.ev_count = 0;
+		rxr->no_mbuf.ev_count = 0;
 		rxr->rx_discarded.ev_count = 0;
 	}
 	stats->ipcs.ev_count = 0;
@@ -2252,6 +2263,32 @@ ixgbe_sysctl_next_to_check_handler(SYSCT
 } /* ixgbe_sysctl_next_to_check_handler */
 
 /************************************************************************
+ * ixgbe_sysctl_next_to_refresh_handler - Receive Descriptor next to check
+ * handler function
+ *
+ *   Retrieves the next_to_refresh value
+ ************************************************************************/
+static int
+ixgbe_sysctl_next_to_refresh_handler(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node = *rnode;
+	struct rx_ring *rxr = (struct rx_ring *)node.sysctl_data;
+	struct adapter *adapter;
+	uint32_t val;
+
+	if (!rxr)
+		return (0);
+
+	adapter = rxr->adapter;
+	if (ixgbe_fw_recovery_mode_swflag(adapter))
+		return (EPERM);
+
+	val = rxr->next_to_refresh;
+	node.sysctl_data = &val;
+	return sysctl_lookup(SYSCTLFN_CALL(&node));
+} /* ixgbe_sysctl_next_to_refresh_handler */
+
+/************************************************************************
  * ixgbe_sysctl_rdh_handler - Receive Descriptor Head handler function
  *
  *   Retrieves the RDH value from the hardware
@@ -3136,8 +3173,11 @@ ixgbe_msix_link(void *arg)
 				retval = hw->phy.ops.check_overtemp(hw);
 				if (retval != IXGBE_ERR_OVERTEMP)
 					break;
-				device_printf(adapter->dev, "CRITICAL: OVER TEMP!! PHY IS SHUT DOWN!!\n");
-				device_printf(adapter->dev, "System shutdown required!\n");
+				device_printf(adapter->dev,
+				    "CRITICAL: OVER TEMP!! "
+				    "PHY IS SHUT DOWN!!\n");
+				device_printf(adapter->dev,
+				    "System shutdown required!\n");
 				break;
 			default:
 				if (!(eicr & IXGBE_EICR_TS))
@@ -3291,20 +3331,21 @@ ixgbe_add_device_sysctls(struct adapter 
 	if (sysctl_createv(log, 0, &rnode, &cnode,
 	    CTLFLAG_READWRITE, CTLTYPE_INT,
 	    "debug", SYSCTL_DESCR("Debug Info"),
-	    ixgbe_sysctl_debug, 0, (void *)adapter, 0, CTL_CREATE, CTL_EOL) != 0)
+	    ixgbe_sysctl_debug, 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)
+	    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_jcl_per_queue",
-	    SYSCTL_DESCR("Number of jumbo buffers per queue"),
-	    NULL, 0, &adapter->num_jcl, 0, CTL_CREATE,
-	    CTL_EOL) != 0)
+	    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)
 		aprint_error_dev(dev, "could not create sysctl\n");
 
 	if (sysctl_createv(log, 0, &rnode, &cnode,
@@ -3345,8 +3386,10 @@ ixgbe_add_device_sysctls(struct adapter 
 	 */
 	adapter->txrx_use_workqueue = ixgbe_txrx_workqueue;
 	if (sysctl_createv(log, 0, &rnode, &cnode, CTLFLAG_READWRITE,
-	    CTLTYPE_BOOL, "txrx_workqueue", SYSCTL_DESCR("Use workqueue for packet processing"),
-	    NULL, 0, &adapter->txrx_use_workqueue, 0, CTL_CREATE, CTL_EOL) != 0)
+	    CTLTYPE_BOOL, "txrx_workqueue",
+	    SYSCTL_DESCR("Use workqueue for packet processing"),
+	    NULL, 0, &adapter->txrx_use_workqueue, 0, CTL_CREATE,
+	    CTL_EOL) != 0)
 		aprint_error_dev(dev, "could not create sysctl\n");
 
 #ifdef IXGBE_DEBUG
@@ -3409,7 +3452,8 @@ ixgbe_add_device_sysctls(struct adapter 
 
 		if (sysctl_createv(log, 0, &phy_node, &cnode, CTLFLAG_READONLY,
 		    CTLTYPE_INT, "overtemp_occurred",
-		    SYSCTL_DESCR("External PHY High Temperature Event Occurred"),
+		    SYSCTL_DESCR(
+			    "External PHY High Temperature Event Occurred"),
 		    ixgbe_sysctl_phy_overtemp_occurred, 0, (void *)adapter, 0,
 		    CTL_CREATE, CTL_EOL) != 0)
 			aprint_error_dev(dev, "could not create sysctl\n");
@@ -3567,8 +3611,9 @@ ixgbe_detach(device_t dev, int flags)
 	}
 
 	/*
-	 * Stop the interface. ixgbe_setup_low_power_mode() calls ixgbe_stop(),
-	 * so it's not required to call ixgbe_stop() directly.
+	 * Stop the interface. ixgbe_setup_low_power_mode() calls
+	 * ixgbe_stop_locked(), so it's not required to call ixgbe_stop_locked()
+	 * directly.
 	 */
 	IXGBE_CORE_LOCK(adapter);
 	ixgbe_setup_low_power_mode(adapter);
@@ -3666,7 +3711,7 @@ ixgbe_detach(device_t dev, int flags)
 		evcnt_detach(&rxr->rx_packets);
 		evcnt_detach(&rxr->rx_bytes);
 		evcnt_detach(&rxr->rx_copies);
-		evcnt_detach(&rxr->no_jmbuf);
+		evcnt_detach(&rxr->no_mbuf);
 		evcnt_detach(&rxr->rx_discarded);
 	}
 	evcnt_detach(&stats->ipcs);
@@ -3752,7 +3797,7 @@ ixgbe_setup_low_power_mode(struct adapte
 	    hw->phy.ops.enter_lplu) {
 		/* X550EM baseT adapters need a special LPLU flow */
 		hw->phy.reset_disable = true;
-		ixgbe_stop(adapter);
+		ixgbe_stop_locked(adapter);
 		error = hw->phy.ops.enter_lplu(hw);
 		if (error)
 			device_printf(dev,
@@ -3760,7 +3805,7 @@ ixgbe_setup_low_power_mode(struct adapte
 		hw->phy.reset_disable = false;
 	} else {
 		/* Just stop for other adapters */
-		ixgbe_stop(adapter);
+		ixgbe_stop_locked(adapter);
 	}
 
 	if (!hw->wol_enabled) {
@@ -3909,7 +3954,7 @@ ixgbe_init_locked(struct adapter *adapte
 	u32		rxdctl, rxctrl;
 	u32		ctrl_ext;
 	bool		unsupported_sfp = false;
-	int		i, j, err;
+	int		i, j, error;
 
 	/* XXX check IFF_UP and IFF_RUNNING, power-saving state! */
 
@@ -3945,7 +3990,7 @@ ixgbe_init_locked(struct adapter *adapte
 	/* Prepare transmit descriptors and buffers */
 	if (ixgbe_setup_transmit_structures(adapter)) {
 		device_printf(dev, "Could not setup transmit structures\n");
-		ixgbe_stop(adapter);
+		ixgbe_stop_locked(adapter);
 		return;
 	}
 
@@ -3958,16 +4003,15 @@ ixgbe_init_locked(struct adapter *adapte
 	/* Setup Multicast table */
 	ixgbe_set_rxfilter(adapter);
 
-	/* Determine the correct mbuf pool, based on frame size */
-	if (adapter->max_frame_size <= MCLBYTES)
-		adapter->rx_mbuf_sz = MCLBYTES;
-	else
-		adapter->rx_mbuf_sz = MJUMPAGESIZE;
+	/* Use fixed buffer size, even for jumbo frames */
+	adapter->rx_mbuf_sz = MCLBYTES;
 
 	/* Prepare receive descriptors and buffers */
-	if (ixgbe_setup_receive_structures(adapter)) {
-		device_printf(dev, "Could not setup receive structures\n");
-		ixgbe_stop(adapter);
+	error = ixgbe_setup_receive_structures(adapter);
+	if (error) {
+		device_printf(dev,
+		    "Could not setup receive structures (err = %d)\n", error);
+		ixgbe_stop_locked(adapter);
 		return;
 	}
 
@@ -4089,8 +4133,8 @@ ixgbe_init_locked(struct adapter *adapte
 	 * need to be kick-started
 	 */
 	if (hw->phy.type == ixgbe_phy_none) {
-		err = hw->phy.ops.identify(hw);
-		if (err == IXGBE_ERR_SFP_NOT_SUPPORTED)
+		error = hw->phy.ops.identify(hw);
+		if (error == IXGBE_ERR_SFP_NOT_SUPPORTED)
 			unsupported_sfp = true;
 	} else if (hw->phy.type == ixgbe_phy_sfp_unsupported)
 		unsupported_sfp = true;
@@ -4566,7 +4610,7 @@ ixgbe_recovery_mode_timer(void *arg)
 			device_printf(adapter->dev, "Firmware recovery mode detected. Limiting functionality. Refer to the Intel(R) Ethernet Adapters and Devices User Guide for details on firmware recovery mode.\n");
 
 			if (hw->adapter_stopped == FALSE)
-				ixgbe_stop(adapter);
+				ixgbe_stop_locked(adapter);
 		}
 	} else
 		atomic_cas_uint(&adapter->recovery_mode, 1, 0);
@@ -4736,18 +4780,18 @@ ixgbe_ifstop(struct ifnet *ifp, int disa
 	struct adapter *adapter = ifp->if_softc;
 
 	IXGBE_CORE_LOCK(adapter);
-	ixgbe_stop(adapter);
+	ixgbe_stop_locked(adapter);
 	IXGBE_CORE_UNLOCK(adapter);
 }
 
 /************************************************************************
- * ixgbe_stop - Stop the hardware
+ * ixgbe_stop_locked - Stop the hardware
  *
  *   Disables all traffic on the adapter by issuing a
  *   global reset on the MAC and deallocates TX/RX buffers.
  ************************************************************************/
 static void
-ixgbe_stop(void *arg)
+ixgbe_stop_locked(void *arg)
 {
 	struct ifnet	*ifp;
 	struct adapter	*adapter = arg;
@@ -4757,7 +4801,7 @@ ixgbe_stop(void *arg)
 
 	KASSERT(mutex_owned(&adapter->core_mtx));
 
-	INIT_DEBUGOUT("ixgbe_stop: begin\n");
+	INIT_DEBUGOUT("ixgbe_stop_locked: begin\n");
 	ixgbe_disable_intr(adapter);
 	callout_stop(&adapter->timer);
 
@@ -4780,7 +4824,7 @@ ixgbe_stop(void *arg)
 	ixgbe_set_rar(&adapter->hw, 0, adapter->hw.mac.addr, 0, IXGBE_RAH_AV);
 
 	return;
-} /* ixgbe_stop */
+} /* ixgbe_stop_locked */
 
 /************************************************************************
  * ixgbe_update_link_status - Update OS on link state
@@ -5393,8 +5437,7 @@ ixgbe_set_advertise(struct adapter *adap
 	}
 
 	if (advertise < 0x0 || advertise > 0x3f) {
-		device_printf(dev,
-		    "Invalid advertised speed; valid modes are 0x0 through 0x3f\n");
+		device_printf(dev, "Invalid advertised speed; valid modes are 0x0 through 0x3f\n");
 		return (EINVAL);
 	}
 
@@ -6019,6 +6062,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
@@ -6379,7 +6447,8 @@ ixgbe_check_fan_failure(struct adapter *
 	    IXGBE_ESDP_SDP1;
 
 	if (reg & mask)
-		device_printf(adapter->dev, "\nCRITICAL: FAN FAILURE!! REPLACE IMMEDIATELY!!\n");
+		device_printf(adapter->dev,
+		    "\nCRITICAL: FAN FAILURE!! REPLACE IMMEDIATELY!!\n");
 } /* ixgbe_check_fan_failure */
 
 /************************************************************************
@@ -6520,7 +6589,8 @@ alloc_retry:
 		    softint_establish(SOFTINT_NET | IXGBE_SOFTINT_FLAGS,
 			ixgbe_deferred_mq_start, txr);
 
-		snprintf(wqname, sizeof(wqname), "%sdeferTx", device_xname(dev));
+		snprintf(wqname, sizeof(wqname), "%sdeferTx",
+		    device_xname(dev));
 		defertx_error = workqueue_create(&adapter->txr_wq, wqname,
 		    ixgbe_deferred_mq_start_work, adapter, IXGBE_WORKQUEUE_PRI,
 		    IPL_NET, IXGBE_WORKQUEUE_FLAGS);
@@ -6690,7 +6760,8 @@ ixgbe_allocate_msix(struct adapter *adap
 	    ixgbe_deferred_mq_start_work, adapter, IXGBE_WORKQUEUE_PRI, IPL_NET,
 	    IXGBE_WORKQUEUE_FLAGS);
 	if (error) {
-		aprint_error_dev(dev, "couldn't create workqueue for deferred Tx\n");
+		aprint_error_dev(dev,
+		    "couldn't create workqueue for deferred Tx\n");
 		goto err_out;
 	}
 	adapter->txr_wq_enqueued = percpu_alloc(sizeof(u_int));

Index: src/sys/dev/pci/ixgbe/ixgbe.h
diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.56.2.4 src/sys/dev/pci/ixgbe/ixgbe.h:1.56.2.5
--- src/sys/dev/pci/ixgbe/ixgbe.h:1.56.2.4	Thu Mar 11 16:00:24 2021
+++ src/sys/dev/pci/ixgbe/ixgbe.h	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.h,v 1.56.2.4 2021/03/11 16:00:24 martin Exp $ */
+/* $NetBSD: ixgbe.h,v 1.56.2.5 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -183,10 +183,7 @@
  * modern Intel CPUs, results in 40 bytes wasted and a significant drop
  * in observed efficiency of the optimization, 97.9% -> 81.8%.
  */
-#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_ALIGN       (IXGBE_RX_COPY_HDR_PADDED - MPKTHSIZE)
+#define IXGBE_RX_COPY_LEN_MAX     (MHLEN - ETHER_ALIGN)
 
 /* Keep older OS drivers building... */
 #if !defined(SYSCTL_ADD_UQUAD)
@@ -331,8 +328,8 @@ struct ix_queue {
 	struct evcnt     irqs;		/* Hardware interrupt */
 	struct evcnt     handleq;	/* software_interrupt */
 	struct evcnt     req;		/* deferred */
-	char             namebuf[32];
-	char             evnamebuf[32];
+	char             namebuf[32];	/* Name for sysctl */
+	char             evnamebuf[32];	/* Name for evcnt */
 
 	/* Lock for disabled_count and this queue's EIMS/EIMC bit */
 	kmutex_t         dc_mtx;
@@ -410,6 +407,7 @@ struct rx_ring {
 	bool			lro_enabled;
 	bool			hw_rsc;
 	bool			vtag_strip;
+	bool			discard_multidesc;
 	u16			next_to_refresh;
 	u16			next_to_check;
 	u16			num_desc;
@@ -419,9 +417,6 @@ struct rx_ring {
 #endif
 	struct ixgbe_rx_buf	*rx_buffers;
 	ixgbe_dma_tag_t		*ptag;
-	u16			last_rx_mbuf_sz;
-	u32			last_num_rx_desc;
-	ixgbe_extmem_head_t	jcl_head;
 
 	u64			bytes; /* Used for AIM calc */
 	u64			packets;
@@ -431,7 +426,7 @@ struct rx_ring {
 	struct evcnt		rx_packets;
 	struct evcnt		rx_bytes;
 	struct evcnt		rx_discarded;
-	struct evcnt		no_jmbuf;
+	struct evcnt		no_mbuf;
 	u64			rsc_num;
 
 	/* Flow Director */
@@ -560,7 +555,7 @@ struct adapter {
 	u64			active_queues;
 	u32			num_rx_desc;
 	u32			rx_process_limit;
-	int			num_jcl;
+	u32			rx_copy_len;
 
 	/* Multicast array memory */
 	struct ixgbe_mc_addr	*mta;
@@ -758,12 +753,8 @@ void ixgbe_free_receive_structures(struc
 bool ixgbe_txeof(struct tx_ring *);
 bool ixgbe_rxeof(struct ix_queue *);
 
-const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *);
-
 /* For NetBSD */
-void ixgbe_jcl_reinit(struct adapter *, bus_dma_tag_t, struct rx_ring *,
-    int, size_t);
-void ixgbe_jcl_destroy(struct adapter *,  struct rx_ring *);
+const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *);
 
 #include "ixgbe_bypass.h"
 #include "ixgbe_fdir.h"

Index: src/sys/dev/pci/ixgbe/ixgbe_82598.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_82598.c:1.12.8.3 src/sys/dev/pci/ixgbe/ixgbe_82598.c:1.12.8.4
--- src/sys/dev/pci/ixgbe/ixgbe_82598.c:1.12.8.3	Fri Jul 10 11:35:51 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_82598.c	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_82598.c,v 1.12.8.3 2020/07/10 11:35:51 martin Exp $ */
+/* $NetBSD: ixgbe_82598.c,v 1.12.8.4 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -35,6 +35,9 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_82598.c 331224 2018-03-19 20:55:05Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_82598.c,v 1.12.8.4 2021/09/15 16:30:50 martin Exp $");
+
 #include "ixgbe_type.h"
 #include "ixgbe_82598.h"
 #include "ixgbe_api.h"

Index: src/sys/dev/pci/ixgbe/ixgbe_82599.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_82599.c:1.21.4.1 src/sys/dev/pci/ixgbe/ixgbe_82599.c:1.21.4.2
--- src/sys/dev/pci/ixgbe/ixgbe_82599.c:1.21.4.1	Tue Jan 28 11:09:27 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_82599.c	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_82599.c,v 1.21.4.1 2020/01/28 11:09:27 martin Exp $ */
+/* $NetBSD: ixgbe_82599.c,v 1.21.4.2 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -35,6 +35,9 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_82599.c 331224 2018-03-19 20:55:05Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_82599.c,v 1.21.4.2 2021/09/15 16:30:50 martin Exp $");
+
 #include "ixgbe_type.h"
 #include "ixgbe_82599.h"
 #include "ixgbe_api.h"

Index: src/sys/dev/pci/ixgbe/ixgbe_api.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_api.c:1.23.2.1 src/sys/dev/pci/ixgbe/ixgbe_api.c:1.23.2.2
--- src/sys/dev/pci/ixgbe/ixgbe_api.c:1.23.2.1	Sun Jan 26 11:03:17 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_api.c	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_api.c,v 1.23.2.1 2020/01/26 11:03:17 martin Exp $ */
+/* $NetBSD: ixgbe_api.c,v 1.23.2.2 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -35,6 +35,9 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_api.c 331224 2018-03-19 20:55:05Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_api.c,v 1.23.2.2 2021/09/15 16:30:50 martin Exp $");
+
 #include "ixgbe_api.h"
 #include "ixgbe_common.h"
 

Index: src/sys/dev/pci/ixgbe/ixgbe_bypass.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_bypass.h:1.1 src/sys/dev/pci/ixgbe/ixgbe_bypass.h:1.1.14.1
--- src/sys/dev/pci/ixgbe/ixgbe_bypass.h:1.1	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_bypass.h	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_bypass.h,v 1.1.14.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
 
   Copyright (c) 2001-2017, Intel Corporation
Index: src/sys/dev/pci/ixgbe/ixgbe_netmap.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_netmap.h:1.1 src/sys/dev/pci/ixgbe/ixgbe_netmap.h:1.1.14.1
--- src/sys/dev/pci/ixgbe/ixgbe_netmap.h:1.1	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_netmap.h	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_netmap.h,v 1.1.14.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
 
   Copyright (c) 2001-2017, Intel Corporation

Index: src/sys/dev/pci/ixgbe/ixgbe_common.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_common.c:1.25.2.3 src/sys/dev/pci/ixgbe/ixgbe_common.c:1.25.2.4
--- src/sys/dev/pci/ixgbe/ixgbe_common.c:1.25.2.3	Wed Sep  2 12:34:55 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_common.c	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_common.c,v 1.25.2.3 2020/09/02 12:34:55 martin Exp $ */
+/* $NetBSD: ixgbe_common.c,v 1.25.2.4 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -35,6 +35,9 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_common.c 331224 2018-03-19 20:55:05Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_common.c,v 1.25.2.4 2021/09/15 16:30:50 martin Exp $");
+
 #include "ixgbe_common.h"
 #include "ixgbe_phy.h"
 #include "ixgbe_dcb.h"
@@ -1138,7 +1141,7 @@ s32 ixgbe_stop_adapter_generic(struct ix
 	 * This function is called in the state of both interrupt disabled
 	 * and interrupt enabled, e.g.
 	 * + interrupt disabled case:
-	 *   - ixgbe_stop()
+	 *   - ixgbe_stop_locked()
 	 *     - ixgbe_disable_intr() // interrupt disabled here
 	 *     - ixgbe_stop_adapter()
 	 *       - hw->mac.ops.stop_adapter()
@@ -5048,8 +5051,8 @@ s32 ixgbe_bypass_rw_generic(struct ixgbe
  * ixgbe_bypass_valid_rd_generic - Verify valid return from bit-bang.
  *
  * If we send a write we can't be sure it took until we can read back
- * that same register.  It can be a problem as some of the feilds may
- * for valid reasons change inbetween the time wrote the register and
+ * that same register.  It can be a problem as some of the fields may
+ * for valid reasons change in-between the time wrote the register and
  * we read it again to verify.  So this function check everything we
  * can check and then assumes it worked.
  *
@@ -5102,7 +5105,7 @@ bool ixgbe_bypass_valid_rd_generic(u32 i
 }
 
 /**
- *  ixgbe_bypass_set_generic - Set a bypass field in the FW CTRL Regiter.
+ *  ixgbe_bypass_set_generic - Set a bypass field in the FW CTRL Register.
  *
  *  @hw: pointer to hardware structure
  *  @cmd: The control word we are setting.
@@ -5148,7 +5151,7 @@ s32 ixgbe_bypass_set_generic(struct ixgb
 }
 
 /**
- *  ixgbe_bypass_rd_eep_generic - Read the bypass FW eeprom addres.
+ *  ixgbe_bypass_rd_eep_generic - Read the bypass FW eeprom address.
  *
  *  @hw: pointer to hardware structure
  *  @addr: The bypass eeprom address to read.

Index: src/sys/dev/pci/ixgbe/ixgbe_dcb.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_dcb.c:1.9 src/sys/dev/pci/ixgbe/ixgbe_dcb.c:1.9.4.1
--- src/sys/dev/pci/ixgbe/ixgbe_dcb.c:1.9	Mon Sep  3 16:29:33 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_dcb.c	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_dcb.c,v 1.9.4.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
 
@@ -33,6 +34,8 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_dcb.c 331224 2018-03-19 20:55:05Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_dcb.c,v 1.9.4.1 2021/09/15 16:30:50 martin Exp $");
 
 #include "ixgbe_type.h"
 #include "ixgbe_dcb.h"

Index: src/sys/dev/pci/ixgbe/ixgbe_dcb.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_dcb.h:1.6 src/sys/dev/pci/ixgbe/ixgbe_dcb.h:1.6.8.1
--- src/sys/dev/pci/ixgbe/ixgbe_dcb.h:1.6	Wed Apr  4 08:13:07 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_dcb.h	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_dcb.h,v 1.6.8.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
 
Index: src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h:1.6 src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h:1.6.8.1
--- src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h:1.6	Wed Apr  4 08:13:07 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,5 @@
+/* $NetBSD: ixgbe_dcb_82598.h,v 1.6.8.1 2021/09/15 16:30:50 martin Exp $ */
+
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
 
Index: src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h:1.6 src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h:1.6.8.1
--- src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h:1.6	Wed Apr  4 08:13:07 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_dcb_82599.h,v 1.6.8.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
 

Index: src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.c:1.7 src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.c:1.7.8.1
--- src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.c:1.7	Wed Apr  4 08:59:22 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.c	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_dcb_82598.c,v 1.7.8.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
 
@@ -33,6 +34,8 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_dcb_82598.c 331224 2018-03-19 20:55:05Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_dcb_82598.c,v 1.7.8.1 2021/09/15 16:30:50 martin Exp $");
 
 #include "ixgbe_type.h"
 #include "ixgbe_dcb.h"
Index: src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.c:1.7 src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.c:1.7.8.1
--- src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.c:1.7	Wed Apr  4 08:59:22 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.c	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_dcb_82599.c,v 1.7.8.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
 
@@ -33,6 +34,8 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_dcb_82599.c 331224 2018-03-19 20:55:05Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_dcb_82599.c,v 1.7.8.1 2021/09/15 16:30:50 martin Exp $");
 
 #include "ixgbe_type.h"
 #include "ixgbe_dcb.h"

Index: src/sys/dev/pci/ixgbe/ixgbe_features.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_features.h:1.2 src/sys/dev/pci/ixgbe/ixgbe_features.h:1.2.4.1
--- src/sys/dev/pci/ixgbe/ixgbe_features.h:1.2	Thu Dec  6 13:25:02 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_features.h	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_features.h,v 1.2.4.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
 
   Copyright (c) 2001-2017, Intel Corporation

Index: src/sys/dev/pci/ixgbe/ixgbe_mbx.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_mbx.c:1.11 src/sys/dev/pci/ixgbe/ixgbe_mbx.c:1.11.2.1
--- src/sys/dev/pci/ixgbe/ixgbe_mbx.c:1.11	Thu Jun 27 05:55:40 2019
+++ src/sys/dev/pci/ixgbe/ixgbe_mbx.c	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_mbx.c,v 1.11 2019/06/27 05:55:40 msaitoh Exp $ */
+/* $NetBSD: ixgbe_mbx.c,v 1.11.2.1 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -35,6 +35,9 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_mbx.c 326022 2017-11-20 19:36:21Z pfg $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_mbx.c,v 1.11.2.1 2021/09/15 16:30:50 martin Exp $");
+
 #include "ixgbe_type.h"
 #include "ixgbe_mbx.h"
 

Index: src/sys/dev/pci/ixgbe/ixgbe_netbsd.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.9.4.3 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.9.4.4
--- src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.9.4.3	Fri Jul 10 11:35:51 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_netbsd.c	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_netbsd.c,v 1.9.4.3 2020/07/10 11:35:51 martin Exp $ */
+/* $NetBSD: ixgbe_netbsd.c,v 1.9.4.4 2021/09/15 16:30:50 martin Exp $ */
 /*
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -27,6 +27,10 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_netbsd.c,v 1.9.4.4 2021/09/15 16:30:50 martin Exp $");
+
 #include <sys/param.h>
 
 #include <sys/atomic.h>
@@ -95,192 +99,19 @@ ixgbe_dmamap_create(ixgbe_dma_tag_t *dt,
 	    dt->dt_maxsegsize, dt->dt_boundary, flags, dmamp);
 }
 
-static void
-ixgbe_putext(ixgbe_extmem_t *em)
-{
-	ixgbe_extmem_head_t *eh = em->em_head;
-
-	mutex_enter(&eh->eh_mtx);
-
-	TAILQ_INSERT_HEAD(&eh->eh_freelist, em, em_link);
-
-	mutex_exit(&eh->eh_mtx);
-
-	return;
-}
-
-static ixgbe_extmem_t *
-ixgbe_getext(ixgbe_extmem_head_t *eh, size_t size)
-{
-	ixgbe_extmem_t *em;
-
-	mutex_enter(&eh->eh_mtx);
-
-	TAILQ_FOREACH(em, &eh->eh_freelist, em_link) {
-		if (em->em_size >= size)
-			break;
-	}
-
-	if (em != NULL)
-		TAILQ_REMOVE(&eh->eh_freelist, em, em_link);
-
-	mutex_exit(&eh->eh_mtx);
-
-	return em;
-}
-
-static ixgbe_extmem_t *
-ixgbe_newext(ixgbe_extmem_head_t *eh, bus_dma_tag_t dmat, size_t size)
-{
-	ixgbe_extmem_t *em;
-	int nseg, rc;
-
-	em = kmem_zalloc(sizeof(*em), KM_SLEEP);
-
-	rc = bus_dmamem_alloc(dmat, size, PAGE_SIZE, 0, &em->em_seg, 1, &nseg,
-	    BUS_DMA_WAITOK);
-
-	if (rc != 0)
-		goto post_zalloc_err;
-
-	rc = bus_dmamem_map(dmat, &em->em_seg, 1, size, &em->em_vaddr,
-	    BUS_DMA_WAITOK);
-
-	if (rc != 0)
-		goto post_dmamem_err;
-
-	em->em_dmat = dmat;
-	em->em_size = size;
-	em->em_head = eh;
-
-	return em;
-post_dmamem_err:
-	bus_dmamem_free(dmat, &em->em_seg, 1);
-post_zalloc_err:
-	kmem_free(em, sizeof(*em));
-	return NULL;
-}
-
-static void
-ixgbe_jcl_freeall(struct adapter *adapter, struct rx_ring *rxr)
-{
-	ixgbe_extmem_head_t *eh = &rxr->jcl_head;
-	ixgbe_extmem_t *em;
-	bus_dma_tag_t dmat = rxr->ptag->dt_dmat;
-
-	while ((em = ixgbe_getext(eh, 0)) != NULL) {
-		KASSERT(em->em_vaddr != NULL);
-		bus_dmamem_unmap(dmat, em->em_vaddr, em->em_size);
-		bus_dmamem_free(dmat, &em->em_seg, 1);
-		memset(em, 0, sizeof(*em));
-		kmem_free(em, sizeof(*em));
-	}
-}
 
-void
-ixgbe_jcl_reinit(struct adapter *adapter, bus_dma_tag_t dmat,
-    struct rx_ring *rxr, int nbuf, size_t size)
-{
-	ixgbe_extmem_head_t *eh = &rxr->jcl_head;
-	ixgbe_extmem_t *em;
-	int i;
-
-	if (!eh->eh_initialized) {
-		TAILQ_INIT(&eh->eh_freelist);
-		mutex_init(&eh->eh_mtx, MUTEX_DEFAULT, IPL_NET);
-		eh->eh_initialized = true;
-	}
-
-	/*
-	 *  Check previous parameters. If it's not required to reinit, just
-	 * return.
-	 *
-	 *  Note that the num_rx_desc is currently fixed value. It's never
-	 * changed after device is attached.
-	 */
-	if ((rxr->last_rx_mbuf_sz == rxr->mbuf_sz)
-	    && (rxr->last_num_rx_desc == adapter->num_rx_desc))
-		return;
-
-	/* Free all dmamem */
-	ixgbe_jcl_freeall(adapter, rxr);
-
-	for (i = 0; i < nbuf; i++) {
-		if ((em = ixgbe_newext(eh, dmat, size)) == NULL) {
-			device_printf(adapter->dev,
-			    "%s: only %d of %d jumbo buffers allocated\n",
-			    __func__, i, nbuf);
-			break;
-		}
-		ixgbe_putext(em);
-	}
-
-	/* Keep current parameters */
-	rxr->last_rx_mbuf_sz = adapter->rx_mbuf_sz;
-	rxr->last_num_rx_desc = adapter->num_rx_desc;
-}
-
-void
-ixgbe_jcl_destroy(struct adapter *adapter, struct rx_ring *rxr)
-{
-	ixgbe_extmem_head_t *eh = &rxr->jcl_head;
-
-	if (eh->eh_initialized) {
-		/* Free all dmamem */
-		ixgbe_jcl_freeall(adapter, rxr);
-
-		mutex_destroy(&eh->eh_mtx);
-		eh->eh_initialized = false;
-	}
-}
-
-
-static void
-ixgbe_jcl_free(struct mbuf *m, void *buf, size_t size, void *arg)
-{
-	ixgbe_extmem_t *em = arg;
-
-	KASSERT(em->em_size == size);
-
-	ixgbe_putext(em);
-	/* this is an abstraction violation, but it does not lead to a
-	 * double-free
-	 */
-	if (__predict_true(m != NULL)) {
-		KASSERT(m->m_type != MT_FREE);
-		m->m_type = MT_FREE;
-		pool_cache_put(mb_cache, m);
-	}
-}
-
-/* XXX need to wait for the system to finish with each jumbo mbuf and
- * free it before detaching the driver from the device.
- */
 struct mbuf *
-ixgbe_getjcl(ixgbe_extmem_head_t *eh, int nowait /* M_DONTWAIT */,
-    int type /* MT_DATA */, int flags /* M_PKTHDR */, size_t size)
+ixgbe_getcl(void)
 {
-	ixgbe_extmem_t *em;
 	struct mbuf *m;
 
-	if ((flags & M_PKTHDR) != 0)
-		m = m_gethdr(nowait, type);
-	else
-		m = m_get(nowait, type);
+	MGETHDR(m, M_DONTWAIT, MT_DATA);
 
 	if (m == NULL)
 		return NULL;
 
-	em = ixgbe_getext(eh, size);
-	if (em == NULL) {
-		m_freem(m);
-		return NULL;
-	}
-
-	MEXTADD(m, em->em_vaddr, em->em_size, M_DEVBUF, &ixgbe_jcl_free, em);
-
+	MCLGET(m, M_DONTWAIT);
 	if ((m->m_flags & M_EXT) == 0) {
-		ixgbe_putext(em);
 		m_freem(m);
 		return NULL;
 	}
@@ -303,15 +134,5 @@ ixgbe_pci_enable_busmaster(pci_chipset_t
 u_int
 atomic_load_acq_uint(volatile u_int *p)
 {
-	u_int rv;
-
-	rv = *p;
-	/*
-	 * XXX
-	 * membar_sync() is far more than we need on most CPUs;
-	 * we just don't have an MI load-acqure operation.
-	 */
-	membar_sync();
-
-	return rv;
+	return atomic_load_acquire(p);
 }

Index: src/sys/dev/pci/ixgbe/ixgbe_netbsd.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_netbsd.h:1.11.4.1 src/sys/dev/pci/ixgbe/ixgbe_netbsd.h:1.11.4.2
--- src/sys/dev/pci/ixgbe/ixgbe_netbsd.h:1.11.4.1	Thu Mar 11 16:00:24 2021
+++ src/sys/dev/pci/ixgbe/ixgbe_netbsd.h	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/*$NetBSD: ixgbe_netbsd.h,v 1.11.4.1 2021/03/11 16:00:24 martin Exp $*/
+/* $NetBSD: ixgbe_netbsd.h,v 1.11.4.2 2021/09/15 16:30:50 martin Exp $ */
 /*
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -40,20 +40,6 @@
 #define	MJUM16BYTES	(16 * 1024)
 #define	MJUMPAGESIZE	PAGE_SIZE
 
-/*
- * Number of jcl per queue is calculated by
- * adapter->num_rx_desc * IXGBE_JCLNUM_MULTI. The lower limit is 2.
- */
-#define	IXGBE_JCLNUM_MULTI_LOWLIM	2
-#define	IXGBE_JCLNUM_MULTI_DEFAULT	3
-#if !defined(IXGBE_JCLNUM_MULTI)
-# define IXGBE_JCLNUM_MULTI IXGBE_JCLNUM_MULTI_DEFAULT
-#else
-# if (IXGBE_JCLNUM_MULTI < IXGBE_JCLNUM_MULTI_LOWLIM)
-#  error IXGBE_JCLNUM_MULTI is too low.
-# endif
-#endif
-
 #define IFCAP_RXCSUM	\
 	(IFCAP_CSUM_IPv4_Rx|IFCAP_CSUM_TCPv4_Rx|IFCAP_CSUM_UDPv4_Rx|\
 	IFCAP_CSUM_TCPv6_Rx|IFCAP_CSUM_UDPv6_Rx)
@@ -76,35 +62,15 @@ struct ixgbe_dma_tag {
 
 typedef struct ixgbe_dma_tag ixgbe_dma_tag_t;
 
-struct ixgbe_extmem_head;
-typedef struct ixgbe_extmem_head ixgbe_extmem_head_t;
-
-struct ixgbe_extmem {
-	ixgbe_extmem_head_t		*em_head;
-	bus_dma_tag_t			em_dmat;
-	bus_size_t			em_size;
-	bus_dma_segment_t		em_seg;
-	void				*em_vaddr;
-	TAILQ_ENTRY(ixgbe_extmem)	em_link;
-};
-
-typedef struct ixgbe_extmem ixgbe_extmem_t;
-
-struct ixgbe_extmem_head {
-	TAILQ_HEAD(, ixgbe_extmem)	eh_freelist;
-	kmutex_t			eh_mtx;
-	bool				eh_initialized;
-};
-
-int ixgbe_dma_tag_create(bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t, int,
-    bus_size_t, int, ixgbe_dma_tag_t **);
+int ixgbe_dma_tag_create(bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t,
+    int, bus_size_t, int, ixgbe_dma_tag_t **);
 void ixgbe_dma_tag_destroy(ixgbe_dma_tag_t *);
 int ixgbe_dmamap_create(ixgbe_dma_tag_t *, int, bus_dmamap_t *);
 void ixgbe_dmamap_destroy(ixgbe_dma_tag_t *, bus_dmamap_t);
 void ixgbe_dmamap_sync(ixgbe_dma_tag_t *, bus_dmamap_t, int);
 void ixgbe_dmamap_unload(ixgbe_dma_tag_t *, bus_dmamap_t);
 
-struct mbuf *ixgbe_getjcl(ixgbe_extmem_head_t *, int, int, int, size_t);
+struct mbuf *ixgbe_getcl(void);
 void ixgbe_pci_enable_busmaster(pci_chipset_tag_t, pcitag_t);
 
 u_int atomic_load_acq_uint(volatile u_int *);

Index: src/sys/dev/pci/ixgbe/ixgbe_netmap.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_netmap.c:1.2 src/sys/dev/pci/ixgbe/ixgbe_netmap.c:1.2.2.1
--- src/sys/dev/pci/ixgbe/ixgbe_netmap.c:1.2	Thu Jun 27 05:55:40 2019
+++ src/sys/dev/pci/ixgbe/ixgbe_netmap.c	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_netmap.c,v 1.2.2.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
 
   Copyright (c) 2001-2017, Intel Corporation
@@ -69,6 +70,9 @@
  * it near the beginning of the standard driver.
  */
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_netmap.c,v 1.2.2.1 2021/09/15 16:30:50 martin Exp $");
+
 #ifdef DEV_NETMAP
 /*
  * Some drivers may need the following headers. Others

Index: src/sys/dev/pci/ixgbe/ixgbe_osdep.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.23.6.3 src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.23.6.4
--- src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.23.6.3	Fri Jul 10 11:35:51 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_osdep.h	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_osdep.h,v 1.23.6.3 2020/07/10 11:35:51 martin Exp $ */
+/* $NetBSD: ixgbe_osdep.h,v 1.23.6.4 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -167,25 +167,6 @@ void prefetch(void *x)
 #define prefetch(x)
 #endif
 
-/*
- * Optimized bcopy thanks to Luigi Rizzo's investigative work.  Assumes
- * non-overlapping regions and 32-byte padding on both src and dst.
- */
-static __inline int
-ixgbe_bcopy(void *restrict _src, void *restrict _dst, int l)
-{
-	uint64_t *src = _src;
-	uint64_t *dst = _dst;
-
-	for (; l > 0; l -= 32) {
-		*dst++ = *src++;
-		*dst++ = *src++;
-		*dst++ = *src++;
-		*dst++ = *src++;
-	}
-	return (0);
-}
-
 struct ixgbe_osdep
 {
 	struct ethercom    ec;
@@ -195,7 +176,6 @@ struct ixgbe_osdep
 	bus_space_handle_t mem_bus_space_handle;
 	bus_size_t         mem_size;
 	bus_dma_tag_t      dmat;
-	u16                last_rx_mbuf_sz;
 	pci_intr_handle_t  *intrs;
 	int		   nintrs;
 	void               *ihs[IXG_MAX_NINTR];

Index: src/sys/dev/pci/ixgbe/ixgbe_phy.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.18.4.3 src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.18.4.4
--- src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.18.4.3	Fri Jul 10 11:35:51 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_phy.c	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_phy.c,v 1.18.4.3 2020/07/10 11:35:51 martin Exp $ */
+/* $NetBSD: ixgbe_phy.c,v 1.18.4.4 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -35,6 +35,9 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_phy.c 331224 2018-03-19 20:55:05Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_phy.c,v 1.18.4.4 2021/09/15 16:30:50 martin Exp $");
+
 #include "ixgbe_api.h"
 #include "ixgbe_common.h"
 #include "ixgbe_phy.h"

Index: src/sys/dev/pci/ixgbe/ixgbe_rss.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_rss.h:1.4 src/sys/dev/pci/ixgbe/ixgbe_rss.h:1.4.8.1
--- src/sys/dev/pci/ixgbe/ixgbe_rss.h:1.4	Wed Apr  4 08:13:07 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_rss.h	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_rss.h,v 1.4.8.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
 
   Copyright (c) 2001-2017, Intel Corporation

Index: src/sys/dev/pci/ixgbe/ixgbe_sriov.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_sriov.h:1.3 src/sys/dev/pci/ixgbe/ixgbe_sriov.h:1.3.8.1
--- src/sys/dev/pci/ixgbe/ixgbe_sriov.h:1.3	Wed Apr  4 08:13:07 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_sriov.h	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_sriov.h,v 1.3.8.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
 
   Copyright (c) 2001-2017, Intel Corporation

Index: src/sys/dev/pci/ixgbe/ixgbe_type.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.41.2.2 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.41.2.3
--- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.41.2.2	Tue Jan 28 11:09:27 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_type.h	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_type.h,v 1.41.2.2 2020/01/28 11:09:27 martin Exp $ */
+/* $NetBSD: ixgbe_type.h,v 1.41.2.3 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -2773,7 +2773,7 @@ enum {
 #define IXGBE_RXDADV_ERR_FDIR_LEN	0x00100000 /* FDIR Length error */
 #define IXGBE_RXDADV_ERR_FDIR_DROP	0x00200000 /* FDIR Drop error */
 #define IXGBE_RXDADV_ERR_FDIR_COLL	0x00400000 /* FDIR Collision error */
-#define IXGBE_RXDADV_ERR_HBO	0x00800000 /*Header Buffer Overflow */
+#define IXGBE_RXDADV_ERR_HBO	0x00800000 /* Header Buffer Overflow */
 #define IXGBE_RXDADV_ERR_CE	0x01000000 /* CRC Error */
 #define IXGBE_RXDADV_ERR_LE	0x02000000 /* Length Error */
 #define IXGBE_RXDADV_ERR_PE	0x08000000 /* Packet Error */

Index: src/sys/dev/pci/ixgbe/ixgbe_vf.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.18.2.3 src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.18.2.4
--- src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.18.2.3	Thu Mar 11 16:00:24 2021
+++ src/sys/dev/pci/ixgbe/ixgbe_vf.c	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_vf.c,v 1.18.2.3 2021/03/11 16:00:24 martin Exp $ */
+/* $NetBSD: ixgbe_vf.c,v 1.18.2.4 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -35,6 +35,8 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_vf.c 331224 2018-03-19 20:55:05Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_vf.c,v 1.18.2.4 2021/09/15 16:30:50 martin Exp $");
 
 #include "ixgbe_api.h"
 #include "ixgbe_type.h"

Index: src/sys/dev/pci/ixgbe/ixgbe_x540.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.16.8.1 src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.16.8.2
--- src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.16.8.1	Thu Mar 11 16:00:24 2021
+++ src/sys/dev/pci/ixgbe/ixgbe_x540.c	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,5 @@
+/* $NetBSD: ixgbe_x540.c,v 1.16.8.2 2021/09/15 16:30:50 martin Exp $ */
+
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
 
@@ -33,6 +35,9 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_x540.c 331224 2018-03-19 20:55:05Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_x540.c,v 1.16.8.2 2021/09/15 16:30:50 martin Exp $");
+
 #include "ixgbe_x540.h"
 #include "ixgbe_type.h"
 #include "ixgbe_api.h"

Index: src/sys/dev/pci/ixgbe/ixgbe_x540.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_x540.h:1.8 src/sys/dev/pci/ixgbe/ixgbe_x540.h:1.8.8.1
--- src/sys/dev/pci/ixgbe/ixgbe_x540.h:1.8	Wed Apr  4 08:13:07 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_x540.h	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_x540.h,v 1.8.8.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
 

Index: src/sys/dev/pci/ixgbe/ixgbe_x550.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.15.2.3 src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.15.2.4
--- src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.15.2.3	Fri Jul 10 11:35:51 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_x550.c	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,5 @@
+/* $NetBSD: ixgbe_x550.c,v 1.15.2.4 2021/09/15 16:30:50 martin Exp $ */
+
 /******************************************************************************
 
   Copyright (c) 2001-2017, Intel Corporation
@@ -32,6 +34,9 @@
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_x550.c 331224 2018-03-19 20:55:05Z erj $*/
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_x550.c,v 1.15.2.4 2021/09/15 16:30:50 martin Exp $");
+
 #include "ixgbe_x550.h"
 #include "ixgbe_x540.h"
 #include "ixgbe_type.h"

Index: src/sys/dev/pci/ixgbe/ixgbe_x550.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_x550.h:1.5 src/sys/dev/pci/ixgbe/ixgbe_x550.h:1.5.4.1
--- src/sys/dev/pci/ixgbe/ixgbe_x550.h:1.5	Thu Dec  6 13:25:02 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_x550.h	Wed Sep 15 16:30:50 2021
@@ -1,3 +1,4 @@
+/* $NetBSD: ixgbe_x550.h,v 1.5.4.1 2021/09/15 16:30:50 martin Exp $ */
 /******************************************************************************
 
   Copyright (c) 2001-2017, Intel Corporation

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.125.2.11 src/sys/dev/pci/ixgbe/ixv.c:1.125.2.12
--- src/sys/dev/pci/ixgbe/ixv.c:1.125.2.11	Thu Mar 11 16:00:24 2021
+++ src/sys/dev/pci/ixgbe/ixv.c	Wed Sep 15 16:30:50 2021
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.125.2.11 2021/03/11 16:00:24 martin Exp $*/
+/* $NetBSD: ixv.c,v 1.125.2.12 2021/09/15 16:30:50 martin Exp $ */
 
 /******************************************************************************
 
@@ -34,11 +34,13 @@
 ******************************************************************************/
 /*$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.125.2.12 2021/09/15 16:30:50 martin Exp $");
+
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_net_mpsafe.h"
-#include "opt_ixgbe.h"
 #endif
 
 #include "ixgbe.h"
@@ -91,7 +93,7 @@ static int	ixv_ioctl(struct ifnet *, u_l
 static int	ixv_init(struct ifnet *);
 static void	ixv_init_locked(struct adapter *);
 static void	ixv_ifstop(struct ifnet *, int);
-static void	ixv_stop(void *);
+static void	ixv_stop_locked(void *);
 static void	ixv_init_device_features(struct adapter *);
 static void	ixv_media_status(struct ifnet *, struct ifmediareq *);
 static int	ixv_media_change(struct ifnet *);
@@ -139,10 +141,12 @@ static void	ixv_set_sysctl_value(struct 
 		    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);
 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 *);
@@ -325,7 +329,7 @@ ixv_attach(device_t parent, device_t dev
 	hw = &adapter->hw;
 
 	adapter->init_locked = ixv_init_locked;
-	adapter->stop_locked = ixv_stop;
+	adapter->stop_locked = ixv_stop_locked;
 
 	adapter->osdep.pc = pa->pa_pc;
 	adapter->osdep.tag = pa->pa_tag;
@@ -499,7 +503,8 @@ ixv_attach(device_t parent, device_t dev
 	} else
 		adapter->num_rx_desc = ixv_rxd;
 
-	adapter->num_jcl = adapter->num_rx_desc * IXGBE_JCLNUM_MULTI;
+	/* Set default high limit of copying mbuf in rxeof */
+	adapter->rx_copy_len = IXGBE_RX_COPY_LEN_MAX;
 
 	/* Setup MSI-X */
 	error = ixv_configure_interrupts(adapter);
@@ -651,7 +656,7 @@ ixv_detach(device_t dev, int flags)
 		evcnt_detach(&rxr->rx_packets);
 		evcnt_detach(&rxr->rx_bytes);
 		evcnt_detach(&rxr->rx_copies);
-		evcnt_detach(&rxr->no_jmbuf);
+		evcnt_detach(&rxr->no_mbuf);
 		evcnt_detach(&rxr->rx_discarded);
 	}
 	evcnt_detach(&stats->ipcs);
@@ -725,7 +730,7 @@ ixv_init_locked(struct adapter *adapter)
 	/* Prepare transmit descriptors and buffers */
 	if (ixgbe_setup_transmit_structures(adapter)) {
 		aprint_error_dev(dev, "Could not setup transmit structures\n");
-		ixv_stop(adapter);
+		ixv_stop_locked(adapter);
 		return;
 	}
 
@@ -742,19 +747,15 @@ ixv_init_locked(struct adapter *adapter)
 	/* Setup Multicast table */
 	ixv_set_rxfilter(adapter);
 
-	/*
-	 * Determine the correct mbuf pool
-	 * for doing jumbo/headersplit
-	 */
-	if (adapter->max_frame_size <= MCLBYTES)
-		adapter->rx_mbuf_sz = MCLBYTES;
-	else
-		adapter->rx_mbuf_sz = MJUMPAGESIZE;
+	/* Use fixed buffer size, even for jumbo frames */
+	adapter->rx_mbuf_sz = MCLBYTES;
 
 	/* Prepare receive descriptors and buffers */
-	if (ixgbe_setup_receive_structures(adapter)) {
-		device_printf(dev, "Could not setup receive structures\n");
-		ixv_stop(adapter);
+	error = ixgbe_setup_receive_structures(adapter);
+	if (error) {
+		device_printf(dev,
+		    "Could not setup receive structures (err = %d)\n", error);
+		ixv_stop_locked(adapter);
 		return;
 	}
 
@@ -1420,12 +1421,12 @@ ixv_ifstop(struct ifnet *ifp, int disabl
 	struct adapter *adapter = ifp->if_softc;
 
 	IXGBE_CORE_LOCK(adapter);
-	ixv_stop(adapter);
+	ixv_stop_locked(adapter);
 	IXGBE_CORE_UNLOCK(adapter);
 }
 
 static void
-ixv_stop(void *arg)
+ixv_stop_locked(void *arg)
 {
 	struct ifnet	*ifp;
 	struct adapter	*adapter = arg;
@@ -1435,7 +1436,7 @@ ixv_stop(void *arg)
 
 	KASSERT(mutex_owned(&adapter->core_mtx));
 
-	INIT_DEBUGOUT("ixv_stop: begin\n");
+	INIT_DEBUGOUT("ixv_stop_locked: begin\n");
 	ixv_disable_intr(adapter);
 
 	/* Tell the stack that the interface is no longer active */
@@ -1450,7 +1451,7 @@ ixv_stop(void *arg)
 	hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
 
 	return;
-} /* ixv_stop */
+} /* ixv_stop_locked */
 
 
 /************************************************************************
@@ -1970,6 +1971,32 @@ ixv_sysctl_next_to_check_handler(SYSCTLF
 } /* ixv_sysctl_next_to_check_handler */
 
 /************************************************************************
+ * ixv_sysctl_next_to_refresh_handler - Receive Descriptor next to refresh
+ * handler function
+ *
+ *   Retrieves the next_to_refresh value
+ ************************************************************************/
+static int
+ixv_sysctl_next_to_refresh_handler(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node = *rnode;
+	struct rx_ring *rxr = (struct rx_ring *)node.sysctl_data;
+	struct adapter *adapter;
+	uint32_t val;
+
+	if (!rxr)
+		return (0);
+
+	adapter = rxr->adapter;
+	if (ixgbe_fw_recovery_mode_swflag(adapter))
+		return (EPERM);
+
+	val = rxr->next_to_refresh;
+	node.sysctl_data = &val;
+	return sysctl_lookup(SYSCTLFN_CALL(&node));
+} /* ixv_sysctl_next_to_refresh_handler */
+
+/************************************************************************
  * ixv_sysctl_rdh_handler - Receive Descriptor Head handler function
  *
  *   Retrieves the RDH value from the hardware
@@ -2502,10 +2529,10 @@ ixv_add_device_sysctls(struct adapter *a
 		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,
-	    CTL_EOL) != 0)
+	    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,
@@ -2631,6 +2658,13 @@ ixv_add_stats_sysctls(struct adapter *ad
 			break;
 
 		if (sysctl_createv(log, 0, &rnode, &cnode,
+		    CTLFLAG_READONLY, CTLTYPE_INT, "rxd_nxrf",
+		    SYSCTL_DESCR("Receive Descriptor next to refresh"),
+		    ixv_sysctl_next_to_refresh_handler, 0, (void *)rxr, 0,
+		    CTL_CREATE, CTL_EOL) != 0)
+			break;
+
+		if (sysctl_createv(log, 0, &rnode, &cnode,
 		    CTLFLAG_READONLY,
 		    CTLTYPE_INT,
 		    "rxd_head", SYSCTL_DESCR("Receive Descriptor Head"),
@@ -2652,8 +2686,8 @@ ixv_add_stats_sysctls(struct adapter *ad
 		    NULL, adapter->queues[i].evnamebuf, "Queue Bytes Received");
 		evcnt_attach_dynamic(&rxr->rx_copies, EVCNT_TYPE_MISC,
 		    NULL, adapter->queues[i].evnamebuf, "Copied RX Frames");
-		evcnt_attach_dynamic(&rxr->no_jmbuf, EVCNT_TYPE_MISC,
-		    NULL, adapter->queues[i].evnamebuf, "Rx no jumbo mbuf");
+		evcnt_attach_dynamic(&rxr->no_mbuf, EVCNT_TYPE_MISC,
+		    NULL, adapter->queues[i].evnamebuf, "Rx no mbuf");
 		evcnt_attach_dynamic(&rxr->rx_discarded, EVCNT_TYPE_MISC,
 		    NULL, adapter->queues[i].evnamebuf, "Rx discarded");
 #ifdef LRO
@@ -2749,7 +2783,7 @@ ixv_clear_evcnt(struct adapter *adapter)
 		rxr->rx_packets.ev_count = 0;
 		rxr->rx_bytes.ev_count = 0;
 		rxr->rx_copies.ev_count = 0;
-		rxr->no_jmbuf.ev_count = 0;
+		rxr->no_mbuf.ev_count = 0;
 		rxr->rx_discarded.ev_count = 0;
 	}
 
@@ -2869,6 +2903,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
@@ -2924,7 +2983,7 @@ ixv_shutdown(device_t dev)
 {
 	struct adapter *adapter = device_private(dev);
 	IXGBE_CORE_LOCK(adapter);
-	ixv_stop(adapter);
+	ixv_stop_locked(adapter);
 	IXGBE_CORE_UNLOCK(adapter);
 
 	return (0);
@@ -3294,7 +3353,7 @@ ixv_allocate_msix(struct adapter *adapte
 	    IXGBE_WORKQUEUE_FLAGS);
 	if (error) {
 		aprint_error_dev(dev,
-		    "couldn't create workqueue\n");
+		    "couldn't create workqueue for Tx/Rx\n");
 	}
 
 	/* and Mailbox */

Reply via email to