Module Name:    src
Committed By:   thorpej
Date:           Mon Aug 22 15:59:42 UTC 2022

Modified Files:
        src/sys/dev/pci: if_ale.c

Log Message:
ale_encap(): Fix error logic in previous change for when the defrag works,
but DMA mapping fails to use DMA resource shortage.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/pci/if_ale.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/dev/pci/if_ale.c
diff -u src/sys/dev/pci/if_ale.c:1.42 src/sys/dev/pci/if_ale.c:1.43
--- src/sys/dev/pci/if_ale.c:1.42	Mon Aug 22 15:43:49 2022
+++ src/sys/dev/pci/if_ale.c	Mon Aug 22 15:59:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ale.c,v 1.42 2022/08/22 15:43:49 thorpej Exp $	*/
+/*	$NetBSD: if_ale.c,v 1.43 2022/08/22 15:59:42 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2008, Pyun YongHyeon <yong...@freebsd.org>
@@ -32,7 +32,7 @@
 /* Driver for Atheros AR8121/AR8113/AR8114 PCIe Ethernet. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.42 2022/08/22 15:43:49 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.43 2022/08/22 15:59:42 thorpej Exp $");
 
 #include "vlan.h"
 
@@ -931,14 +931,19 @@ ale_encap(struct ale_softc *sc, struct m
 			KASSERT(m == mnew);
 			error = bus_dmamap_load_mbuf(sc->sc_dmat, map, mnew,
 			    BUS_DMA_NOWAIT);
+		} else {
+			/* Just drop if we can't defrag. */
+			error = EFBIG;
 		}
-		if (mnew == NULL || error == EFBIG) {
-			printf("%s: Tx packet consumes too many "
-			    "DMA segments, dropping...\n",
-			    device_xname(sc->sc_dev));
-			return EFBIG;
+		if (error) {
+			if (error == EFBIG) {
+				printf("%s: Tx packet consumes too many "
+				    "DMA segments, dropping...\n",
+				    device_xname(sc->sc_dev));
+			}
+			return error;
 		}
-	} else if (error != 0) {
+	} else if (error) {
 		return error;
 	}
 

Reply via email to