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 Reduce bus_dmamap_sync() cost.



details:   https://anonhg.NetBSD.org/src/rev/074f3573caf8
branches:  trunk
changeset: 1023455:074f3573caf8
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Sep 08 09:09:47 2021 +0000

description:
Reduce bus_dmamap_sync() cost.

 - Don't sync whole descriptor ring but limited counts(rx_process_limit)
   descriptors.
 - Dont' sync every loop.

diffstat:

 sys/dev/pci/ixgbe/ix_txrx.c |  49 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 42 insertions(+), 7 deletions(-)

diffs (94 lines):

diff -r c6641862d21d -r 074f3573caf8 sys/dev/pci/ixgbe/ix_txrx.c
--- a/sys/dev/pci/ixgbe/ix_txrx.c       Wed Sep 08 08:46:28 2021 +0000
+++ b/sys/dev/pci/ixgbe/ix_txrx.c       Wed Sep 08 09:09:47 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.93 2021/09/08 08:46:28 msaitoh Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.94 2021/09/08 09:09:47 msaitoh Exp $ */
 
 /******************************************************************************
 
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.93 2021/09/08 08:46:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.94 2021/09/08 09:09:47 msaitoh Exp $");
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -1804,9 +1804,11 @@
        struct ixgbe_rx_buf     *rbuf, *nbuf;
        int                     i, nextp, processed = 0;
        u32                     staterr = 0;
-       u32                     loopcount = 0;
+       u32                     loopcount = 0, numdesc;
        u32                     limit = adapter->rx_process_limit;
        bool                    discard_multidesc = rxr->discard_multidesc;
+       bool                    wraparound = false;
+       unsigned int            syncremain;
 #ifdef RSS
        u16                     pkt_info;
 #endif
@@ -1823,6 +1825,24 @@
        }
 #endif /* DEV_NETMAP */
 
+       /* Sync the ring. The size is rx_process_limit or the first half */
+       if ((rxr->next_to_check + limit) <= rxr->num_desc) {
+               /* Non-wraparound */
+               numdesc = limit;
+               syncremain = 0;
+       } else {
+               /* Wraparound. Sync the first half. */
+               numdesc = rxr->num_desc - rxr->next_to_check;
+
+               /* Set the size of the last half */
+               syncremain = limit - numdesc;
+       }
+       bus_dmamap_sync(rxr->rxdma.dma_tag->dt_dmat,
+           rxr->rxdma.dma_map,
+           sizeof(union ixgbe_adv_rx_desc) * rxr->next_to_check,
+           sizeof(union ixgbe_adv_rx_desc) * numdesc,
+           BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+
        /*
         * 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
@@ -1839,9 +1859,22 @@
                bool        eop;
                bool        discard = false;
 
-               /* Sync the ring. */
-               ixgbe_dmamap_sync(rxr->rxdma.dma_tag, rxr->rxdma.dma_map,
-                   BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+               if (wraparound) {
+                       /* Sync the last half. */
+                       KASSERT(syncremain != 0);
+                       numdesc = syncremain;
+                       wraparound = false;
+               } else if (__predict_false(loopcount >= limit)) {
+                       KASSERT(discard_multidesc == true);
+                       numdesc = 1;
+               } else
+                       numdesc = 0;
+
+               if (numdesc != 0)
+                       bus_dmamap_sync(rxr->rxdma.dma_tag->dt_dmat,
+                           rxr->rxdma.dma_map, 0,
+                           sizeof(union ixgbe_adv_rx_desc) * numdesc,
+                           BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 
                cur = &rxr->rx_base[i];
                staterr = le32toh(cur->wb.upper.status_error);
@@ -2105,8 +2138,10 @@
                    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
                /* Advance our pointers to the next descriptor. */
-               if (++i == rxr->num_desc)
+               if (++i == rxr->num_desc) {
+                       wraparound = true;
                        i = 0;
+               }
                rxr->next_to_check = i;
 
                /* Now send to the stack or do LRO */



Home | Main Index | Thread Index | Old Index