Source-Changes-HG archive

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

[src/netbsd-9]: src Pull up the following (all via patch) requested by msaito...



details:   https://anonhg.NetBSD.org/src/rev/fa8dad926eea
branches:  netbsd-9
changeset: 953511:fa8dad926eea
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Mar 11 16:00:24 2021 +0000

description:
Pull up the following (all via patch) requested by msaitoh in ticket #1231:

        sys/dev/pci/ixgbe/ixgbe.c                       1.259, 1.278-1.279
        sys/dev/pci/ixgbe/ixgbe.h                       1.75
        sys/dev/pci/ixgbe/ixgbe_netbsd.h                1.12
        sys/dev/pci/ixgbe/ixgbe_vf.c                    1.24-1.26
        sys/dev/pci/ixgbe/ixgbe_x550.c                  1.17
        sys/dev/pci/ixgbe/ixv.c                         1.155-1.156
        sys/dev/pci/ixgbe/ix_txrx.c                     1.64-67
        sys/dev/pci/files.pci                           1.436
        share/man/man4/ixg.4                            1.13-1.14
        share/man/man4/ixv.4                            1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
  exhausted.
- Modify some parameters to reduce packet dropping. See also the
  manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
  reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
  it more understandable.
- Fix a bug that some advertise speeds can't be set with
  hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
  message, too.
- Fix typo in comment or debug message.

diffstat:

 share/man/man4/ixg.4             |  24 ++++++++++++++-
 share/man/man4/ixv.4             |  24 ++++++++++++++-
 sys/dev/pci/files.pci            |   3 +-
 sys/dev/pci/ixgbe/ix_txrx.c      |  62 +++++++++++++++++++++++++++++++++++----
 sys/dev/pci/ixgbe/ixgbe.c        |  18 +++++++++--
 sys/dev/pci/ixgbe/ixgbe.h        |   5 +-
 sys/dev/pci/ixgbe/ixgbe_netbsd.h |  16 +++++++++-
 sys/dev/pci/ixgbe/ixgbe_vf.c     |   9 +++--
 sys/dev/pci/ixgbe/ixgbe_x540.c   |   2 +-
 sys/dev/pci/ixgbe/ixv.c          |  14 +++++++-
 10 files changed, 151 insertions(+), 26 deletions(-)

diffs (truncated from 454 to 300 lines):

diff -r 37e5852eb91e -r fa8dad926eea share/man/man4/ixg.4
--- a/share/man/man4/ixg.4      Tue Mar 09 16:02:45 2021 +0000
+++ b/share/man/man4/ixg.4      Thu Mar 11 16:00:24 2021 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: ixg.4,v 1.12 2018/05/09 08:01:16 wiz Exp $
+.\" $NetBSD: ixg.4,v 1.12.4.1 2021/03/11 16:00:24 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 May 9, 2018
+.Dd March 9, 2021
 .Dt IXG 4
 .Os
 .Sh NAME
@@ -83,6 +83,26 @@
 .\" with a supported adapter, email the specific information related to the
 .\" issue to
 .\" .Aq freebsdnic%mailbox.intel.com@localhost .
+.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 ,
diff -r 37e5852eb91e -r fa8dad926eea share/man/man4/ixv.4
--- a/share/man/man4/ixv.4      Tue Mar 09 16:02:45 2021 +0000
+++ b/share/man/man4/ixv.4      Thu Mar 11 16:00:24 2021 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ixv.4,v 1.4.2.1 2019/09/26 19:07:23 martin Exp $
+.\"    $NetBSD: ixv.4,v 1.4.2.2 2021/03/11 16:00:24 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 September 5, 2019
+.Dd March 9, 2021
 .Dt IXV 4
 .Os
 .Sh NAME
@@ -43,6 +43,26 @@
 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 ,
diff -r 37e5852eb91e -r fa8dad926eea sys/dev/pci/files.pci
--- a/sys/dev/pci/files.pci     Tue Mar 09 16:02:45 2021 +0000
+++ b/sys/dev/pci/files.pci     Thu Mar 11 16:00:24 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.pci,v 1.413.2.2 2020/07/07 10:29:05 martin Exp $
+#      $NetBSD: files.pci,v 1.413.2.3 2021/03/11 16:00:24 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,6 +691,7 @@
 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
diff -r 37e5852eb91e -r fa8dad926eea sys/dev/pci/ixgbe/ix_txrx.c
--- a/sys/dev/pci/ixgbe/ix_txrx.c       Tue Mar 09 16:02:45 2021 +0000
+++ b/sys/dev/pci/ixgbe/ix_txrx.c       Thu Mar 11 16:00:24 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.54.2.4 2020/07/10 11:35:51 martin Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.54.2.5 2021/03/11 16:00:24 martin Exp $ */
 
 /******************************************************************************
 
@@ -1326,6 +1326,11 @@
  *      exhaustion are unnecessary, if an mbuf cannot be obtained
  *      it just returns, keeping its placeholder, thus it can simply
  *      be recalled to try again.
+ *
+ *   XXX NetBSD TODO:
+ *    - The ixgbe_rxeof() function always preallocates mbuf cluster (jcl),
+ *      so the ixgbe_refresh_mbufs() function can be simplified.
+ *
  ************************************************************************/
 static void
 ixgbe_refresh_mbufs(struct rx_ring *rxr, int limit)
@@ -1515,7 +1520,7 @@
         * 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);
+           adapter->num_jcl, adapter->rx_mbuf_sz);
 
        IXGBE_RX_LOCK(rxr);
 
@@ -1812,7 +1817,9 @@
        struct ixgbe_rx_buf     *rbuf, *nbuf;
        int                     i, nextp, processed = 0;
        u32                     staterr = 0;
-       u32                     count = adapter->rx_process_limit;
+       u32                     count = 0;
+       u32                     limit = adapter->rx_process_limit;
+       bool                    discard_multidesc = false;
 #ifdef RSS
        u16                     pkt_info;
 #endif
@@ -1829,8 +1836,16 @@
        }
 #endif /* DEV_NETMAP */
 
-       for (i = rxr->next_to_check; count != 0;) {
+       /*
+        * The max number of loop is rx_process_limit. If discard_multidesc is
+        * true, continue processing to not to send broken packet to the upper
+        * layer.
+        */
+       for (i = rxr->next_to_check;
+            (count < limit) || (discard_multidesc == true);) {
+
                struct mbuf *sendmp, *mp;
+               struct mbuf *newmp;
                u32         rsc, ptype;
                u16         len;
                u16         vtag = 0;
@@ -1849,7 +1864,7 @@
                if ((staterr & IXGBE_RXD_STAT_DD) == 0)
                        break;
 
-               count--;
+               count++;
                sendmp = NULL;
                nbuf = NULL;
                rsc = 0;
@@ -1870,9 +1885,38 @@
 #endif
                        rxr->rx_discarded.ev_count++;
                        ixgbe_rx_discard(rxr, i);
+                       discard_multidesc = false;
                        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++;
+                       /*
+                        * Descriptor initialization is already done by the
+                        * above code (cur->wb.upper.status_error = 0).
+                        * So, we can reuse current rbuf->buf for new packet.
+                        *
+                        * Rewrite the buffer addr, see comment in
+                        * ixgbe_rx_discard().
+                        */
+                       cur->read.pkt_addr = rbuf->addr;
+                       m_freem(rbuf->fmp);
+                       rbuf->fmp = NULL;
+                       if (!eop) {
+                               /* Discard the entire packet. */
+                               discard_multidesc = true;
+                       } else
+                               discard_multidesc = false;
+                       goto next_desc;
+               }
+               discard_multidesc = false;
+
                bus_dmamap_sync(rxr->ptag->dt_dmat, rbuf->pmap, 0,
                    rbuf->buf->m_pkthdr.len, BUS_DMASYNC_POSTREAD);
 
@@ -1921,7 +1965,8 @@
                 */
                sendmp = rbuf->fmp;
                if (sendmp != NULL) {  /* secondary frag */
-                       rbuf->buf = rbuf->fmp = NULL;
+                       rbuf->buf = newmp;
+                       rbuf->fmp = NULL;
                        mp->m_flags &= ~M_PKTHDR;
                        sendmp->m_pkthdr.len += mp->m_len;
                } else {
@@ -1940,10 +1985,13 @@
                                        sendmp->m_len = len;
                                        rxr->rx_copies.ev_count++;
                                        rbuf->flags |= IXGBE_RX_COPY;
+
+                                       m_freem(newmp);
                                }
                        }
                        if (sendmp == NULL) {
-                               rbuf->buf = rbuf->fmp = NULL;
+                               rbuf->buf = newmp;
+                               rbuf->fmp = NULL;
                                sendmp = mp;
                        }
 
diff -r 37e5852eb91e -r fa8dad926eea sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Tue Mar 09 16:02:45 2021 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Thu Mar 11 16:00:24 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.199.2.12 2020/09/02 12:34:55 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.199.2.13 2021/03/11 16:00:24 martin Exp $ */
 
 /******************************************************************************
 
@@ -67,6 +67,7 @@
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_net_mpsafe.h"
+#include "opt_ixgbe.h"
 #endif
 
 #include "ixgbe.h"
@@ -943,6 +944,8 @@
        } else
                adapter->num_rx_desc = ixgbe_rxd;
 
+       adapter->num_jcl = adapter->num_rx_desc * IXGBE_JCLNUM_MULTI;
+
        /* Allocate our TX/RX Queues */
        if (ixgbe_allocate_queues(adapter)) {
                error = ENOMEM;
@@ -1854,7 +1857,7 @@
                    NULL, adapter->queues[i].evnamebuf, "TSO");
                evcnt_attach_dynamic(&txr->no_desc_avail, EVCNT_TYPE_MISC,
                    NULL, adapter->queues[i].evnamebuf,
-                   "Queue No Descriptor Available");
+                   "TX Queue No Descriptor Available");
                evcnt_attach_dynamic(&txr->total_packets, EVCNT_TYPE_MISC,
                    NULL, adapter->queues[i].evnamebuf,
                    "Queue Packets Transmitted");
@@ -3298,6 +3301,13 @@
                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)
+               aprint_error_dev(dev, "could not create sysctl\n");
+
+       if (sysctl_createv(log, 0, &rnode, &cnode,
            CTLFLAG_READONLY, CTLTYPE_INT,
            "num_queues", SYSCTL_DESCR("Number of queues"),
            NULL, 0, &adapter->num_queues, 0, CTL_CREATE, CTL_EOL) != 0)
@@ -5382,9 +5392,9 @@
                return (EINVAL);
        }
 
-       if (advertise < 0x0 || advertise > 0x2f) {
+       if (advertise < 0x0 || advertise > 0x3f) {
                device_printf(dev,
-                   "Invalid advertised speed; valid modes are 0x0 through 0x7\n");
+                   "Invalid advertised speed; valid modes are 0x0 through 0x3f\n");
                return (EINVAL);
        }
 



Home | Main Index | Thread Index | Old Index