Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci/ixgbe Make jcl allocation per queue to reduce mu...



details:   https://anonhg.NetBSD.org/src/rev/4777b1bd8872
branches:  trunk
changeset: 365075:4777b1bd8872
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Tue Jul 31 09:19:34 2018 +0000

description:
Make jcl allocation per queue to reduce mutex spin. Tested by me and
knakahara.

diffstat:

 sys/dev/pci/ixgbe/ix_txrx.c      |  26 ++++++++++++++------------
 sys/dev/pci/ixgbe/ixgbe.h        |   9 ++++++---
 sys/dev/pci/ixgbe/ixgbe_netbsd.c |  16 ++++++++--------
 sys/dev/pci/ixgbe/ixgbe_osdep.h  |   3 +--
 4 files changed, 29 insertions(+), 25 deletions(-)

diffs (160 lines):

diff -r 9ad9be39b94b -r 4777b1bd8872 sys/dev/pci/ixgbe/ix_txrx.c
--- a/sys/dev/pci/ixgbe/ix_txrx.c       Tue Jul 31 07:00:48 2018 +0000
+++ b/sys/dev/pci/ixgbe/ix_txrx.c       Tue Jul 31 09:19:34 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.48 2018/06/26 06:48:01 msaitoh Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.49 2018/07/31 09:19:34 msaitoh Exp $ */
 
 /******************************************************************************
 
@@ -1343,7 +1343,7 @@
        while (j != limit) {
                rxbuf = &rxr->rx_buffers[i];
                if (rxbuf->buf == NULL) {
-                       mp = ixgbe_getjcl(&adapter->jcl_head, M_NOWAIT,
+                       mp = ixgbe_getjcl(&rxr->jcl_head, M_NOWAIT,
                            MT_DATA, M_PKTHDR, rxr->mbuf_sz);
                        if (mp == NULL) {
                                rxr->no_jmbuf.ev_count++;
@@ -1505,6 +1505,17 @@
        /* 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,
+           (2 * adapter->num_rx_desc), adapter->rx_mbuf_sz);
+
+       IXGBE_RX_LOCK(rxr);
+
        /* Now replenish the mbufs */
        for (int j = 0; j != rxr->num_desc; ++j) {
                struct mbuf *mp;
@@ -1534,7 +1545,7 @@
 #endif /* DEV_NETMAP */
 
                rxbuf->flags = 0;
-               rxbuf->buf = ixgbe_getjcl(&adapter->jcl_head, M_NOWAIT,
+               rxbuf->buf = ixgbe_getjcl(&rxr->jcl_head, M_NOWAIT,
                    MT_DATA, M_PKTHDR, adapter->rx_mbuf_sz);
                if (rxbuf->buf == NULL) {
                        error = ENOBUFS;
@@ -1611,15 +1622,6 @@
        struct rx_ring *rxr = adapter->rx_rings;
        int            j;
 
-       /*
-        * 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,
-           (2 * adapter->num_rx_desc) * adapter->num_queues,
-           adapter->rx_mbuf_sz);
-
        for (j = 0; j < adapter->num_queues; j++, rxr++)
                if (ixgbe_setup_receive_ring(rxr))
                        goto fail;
diff -r 9ad9be39b94b -r 4777b1bd8872 sys/dev/pci/ixgbe/ixgbe.h
--- a/sys/dev/pci/ixgbe/ixgbe.h Tue Jul 31 07:00:48 2018 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.h Tue Jul 31 09:19:34 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.h,v 1.50 2018/06/25 05:06:10 msaitoh Exp $ */
+/* $NetBSD: ixgbe.h,v 1.51 2018/07/31 09:19:34 msaitoh Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -417,6 +417,9 @@
 #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;
@@ -602,7 +605,6 @@
 
        struct sysctllog        *sysctllog;
        const struct sysctlnode *sysctltop;
-       ixgbe_extmem_head_t jcl_head;
 };
 
 /* Precision Time Sync (IEEE 1588) defines */
@@ -752,7 +754,8 @@
 const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *);
 
 /* For NetBSD */
-void ixgbe_jcl_reinit(struct adapter *, bus_dma_tag_t, int, size_t);
+void ixgbe_jcl_reinit(struct adapter *, bus_dma_tag_t, struct rx_ring *,
+    int, size_t);
 
 #include "ixgbe_bypass.h"
 #include "ixgbe_fdir.h"
diff -r 9ad9be39b94b -r 4777b1bd8872 sys/dev/pci/ixgbe/ixgbe_netbsd.c
--- a/sys/dev/pci/ixgbe/ixgbe_netbsd.c  Tue Jul 31 07:00:48 2018 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe_netbsd.c  Tue Jul 31 09:19:34 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_netbsd.c,v 1.7 2018/04/25 08:46:19 msaitoh Exp $ */
+/* $NetBSD: ixgbe_netbsd.c,v 1.8 2018/07/31 09:19:34 msaitoh Exp $ */
 /*
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -162,10 +162,10 @@
 }
 
 void
-ixgbe_jcl_reinit(struct adapter *adapter, bus_dma_tag_t dmat, int nbuf,
-    size_t size)
+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 = &adapter->jcl_head;
+       ixgbe_extmem_head_t *eh = &rxr->jcl_head;
        ixgbe_extmem_t *em;
        int i;
 
@@ -182,8 +182,8 @@
         *  Note that the num_rx_desc is currently fixed value. It's never
         * changed after device is attached.
         */
-       if ((adapter->osdep.last_rx_mbuf_sz == adapter->rx_mbuf_sz)
-           && (adapter->osdep.last_num_rx_desc == adapter->num_rx_desc))
+       if ((rxr->last_rx_mbuf_sz == rxr->mbuf_sz)
+           && (rxr->last_num_rx_desc == adapter->num_rx_desc))
                return;
 
        /* Free all dmamem */
@@ -205,8 +205,8 @@
        }
 
        /* Keep current parameters */
-       adapter->osdep.last_rx_mbuf_sz = adapter->rx_mbuf_sz;
-       adapter->osdep.last_num_rx_desc = adapter->num_rx_desc;
+       rxr->last_rx_mbuf_sz = adapter->rx_mbuf_sz;
+       rxr->last_num_rx_desc = adapter->num_rx_desc;
 }
 
 static void
diff -r 9ad9be39b94b -r 4777b1bd8872 sys/dev/pci/ixgbe/ixgbe_osdep.h
--- a/sys/dev/pci/ixgbe/ixgbe_osdep.h   Tue Jul 31 07:00:48 2018 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe_osdep.h   Tue Jul 31 09:19:34 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_osdep.h,v 1.22 2018/04/25 08:46:19 msaitoh Exp $ */
+/* $NetBSD: ixgbe_osdep.h,v 1.23 2018/07/31 09:19:34 msaitoh Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -208,7 +208,6 @@
        bus_size_t         mem_size;
        bus_dma_tag_t      dmat;
        u16                last_rx_mbuf_sz;
-       u32                last_num_rx_desc;
        pci_intr_handle_t  *intrs;
        int                nintrs;
        void               *ihs[IXG_MAX_NINTR];



Home | Main Index | Thread Index | Old Index