git: 53236f905dbf - main - if_vtnet: improve dumping a kernel

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Mon, 18 Apr 2022 22:44:52 UTC
The branch main has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=53236f905dbf4f3d58b1d5eff5c9b14f100d0c5d

commit 53236f905dbf4f3d58b1d5eff5c9b14f100d0c5d
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2022-04-18 22:40:31 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2022-04-18 22:40:31 +0000

    if_vtnet: improve dumping a kernel
    
    Disable software LRO during kernel dumping, because having it enabled
    requires to be in a network epoch, which might or might not be the
    case depending on the code path resulting in the panic.
    
    Reviewed by:            markj
    MFC after:              3 days
    Sponsored by:           Netflix, Inc.
    Differential Revision:  https://reviews.freebsd.org/D34787
---
 sys/dev/virtio/network/if_vtnet.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c
index bb659b7b2ef5..d86dec6a141d 100644
--- a/sys/dev/virtio/network/if_vtnet.c
+++ b/sys/dev/virtio/network/if_vtnet.c
@@ -4404,8 +4404,27 @@ vtnet_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
 }
 
 static void
-vtnet_debugnet_event(struct ifnet *ifp __unused, enum debugnet_ev event __unused)
+vtnet_debugnet_event(struct ifnet *ifp, enum debugnet_ev event)
 {
+	struct vtnet_softc *sc;
+	static bool sw_lro_enabled = false;
+
+	/*
+	 * Disable software LRO, since it would require entering the network
+	 * epoch when calling vtnet_txq_eof() in vtnet_debugnet_poll().
+	 */
+	sc = if_getsoftc(ifp);
+	switch (event) {
+	case DEBUGNET_START:
+		sw_lro_enabled = (sc->vtnet_flags & VTNET_FLAG_SW_LRO) != 0;
+		if (sw_lro_enabled)
+			sc->vtnet_flags &= ~VTNET_FLAG_SW_LRO;
+		break;
+	case DEBUGNET_END:
+		if (sw_lro_enabled)
+			sc->vtnet_flags |= VTNET_FLAG_SW_LRO;
+		break;
+	}
 }
 
 static int