Module Name:    src
Committed By:   jdolecek
Date:           Sun Apr 26 13:09:53 UTC 2020

Modified Files:
        src/sys/arch/xen/xen: xennetback_xenbus.c

Log Message:
bump send queue to 2*NET_TX_RING_SIZE to make it less likely packets
are dropped on load

m_defrag() short packets before calling bus_dmamap_load_mbuf() -
if it's fragmented load_mbuf would fail anyway, and even with
eventual feature-sg support it's way faster to pass the short packet
in single fragment


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/arch/xen/xen/xennetback_xenbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/xennetback_xenbus.c
diff -u src/sys/arch/xen/xen/xennetback_xenbus.c:1.97 src/sys/arch/xen/xen/xennetback_xenbus.c:1.98
--- src/sys/arch/xen/xen/xennetback_xenbus.c:1.97	Sat Apr 25 11:33:28 2020
+++ src/sys/arch/xen/xen/xennetback_xenbus.c	Sun Apr 26 13:09:52 2020
@@ -1,4 +1,4 @@
-/*      $NetBSD: xennetback_xenbus.c,v 1.97 2020/04/25 11:33:28 jdolecek Exp $      */
+/*      $NetBSD: xennetback_xenbus.c,v 1.98 2020/04/26 13:09:52 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.97 2020/04/25 11:33:28 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.98 2020/04/26 13:09:52 jdolecek Exp $");
 
 #include "opt_xen.h"
 
@@ -269,6 +269,7 @@ xennetback_xenbus_create(struct xenbus_d
 	ifp->if_init = xennetback_ifinit;
 	ifp->if_stop = xennetback_ifstop;
 	ifp->if_timer = 0;
+	IFQ_SET_MAXLEN(&ifp->if_snd, uimax(2 * NET_TX_RING_SIZE, IFQ_MAXLEN));
 	IFQ_SET_READY(&ifp->if_snd);
 	if_attach(ifp);
 	if_deferred_start_init(ifp, NULL);
@@ -912,6 +913,15 @@ xennetback_ifsoftstart_copy(struct xnetb
 
 			xst = &xneti->xni_xstate[i];
 
+			/*
+			 * For short packets it's always way faster passing
+			 * single defragmented packet, even with feature-sg.
+			 * Try to defragment first if the result is likely
+			 * to fit into a single mbuf.
+			 */
+			if (m->m_pkthdr.len < MCLBYTES && m->m_next)
+				(void)m_defrag(m, M_DONTWAIT);
+
 			if (bus_dmamap_load_mbuf(
 			    xneti->xni_xbusd->xbusd_dmat,
 			    xst->xs_dmamap, m, BUS_DMA_NOWAIT) != 0) {

Reply via email to