Sat Aug 20 19:04:07 2022 UTC ()
gfe_ifstart(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".


(thorpej)
diff -r1.59 -r1.60 src/sys/dev/marvell/if_gfe.c

cvs diff -r1.59 -r1.60 src/sys/dev/marvell/if_gfe.c (expand / switch to unified diff)

--- src/sys/dev/marvell/if_gfe.c 2021/08/07 16:19:13 1.59
+++ src/sys/dev/marvell/if_gfe.c 2022/08/20 19:04:07 1.60
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_gfe.c,v 1.59 2021/08/07 16:19:13 thorpej Exp $ */ 1/* $NetBSD: if_gfe.c,v 1.60 2022/08/20 19:04:07 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc. 4 * Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -32,27 +32,27 @@ @@ -32,27 +32,27 @@
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE. 37 * POSSIBILITY OF SUCH DAMAGE.
38 */ 38 */
39 39
40/* 40/*
41 * if_gfe.c -- GT ethernet MAC driver 41 * if_gfe.c -- GT ethernet MAC driver
42 */ 42 */
43 43
44#include <sys/cdefs.h> 44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD: if_gfe.c,v 1.59 2021/08/07 16:19:13 thorpej Exp $"); 45__KERNEL_RCSID(0, "$NetBSD: if_gfe.c,v 1.60 2022/08/20 19:04:07 thorpej Exp $");
46 46
47#include "opt_inet.h" 47#include "opt_inet.h"
48 48
49#include <sys/param.h> 49#include <sys/param.h>
50#include <sys/bus.h> 50#include <sys/bus.h>
51#include <sys/callout.h> 51#include <sys/callout.h>
52#include <sys/device.h> 52#include <sys/device.h>
53#include <sys/errno.h> 53#include <sys/errno.h>
54#include <sys/ioctl.h> 54#include <sys/ioctl.h>
55#include <sys/mbuf.h> 55#include <sys/mbuf.h>
56#include <sys/mutex.h> 56#include <sys/mutex.h>
57#include <sys/socket.h> 57#include <sys/socket.h>
58 58
@@ -681,54 +681,55 @@ void @@ -681,54 +681,55 @@ void
681gfe_ifstart(struct ifnet *ifp) 681gfe_ifstart(struct ifnet *ifp)
682{ 682{
683 struct gfe_softc * const sc = ifp->if_softc; 683 struct gfe_softc * const sc = ifp->if_softc;
684 struct mbuf *m; 684 struct mbuf *m;
685 685
686 GE_FUNC_ENTER(sc, "gfe_ifstart"); 686 GE_FUNC_ENTER(sc, "gfe_ifstart");
687 687
688 if ((ifp->if_flags & IFF_RUNNING) == 0) { 688 if ((ifp->if_flags & IFF_RUNNING) == 0) {
689 GE_FUNC_EXIT(sc, "$"); 689 GE_FUNC_EXIT(sc, "$");
690 return; 690 return;
691 } 691 }
692 692
693 for (;;) { 693 for (;;) {
694 IF_DEQUEUE(&ifp->if_snd, m); 694 IF_POLL(&ifp->if_snd, m);
695 if (m == NULL) { 695 if (m == NULL) {
696 ifp->if_flags &= ~IFF_OACTIVE; 696 ifp->if_flags &= ~IFF_OACTIVE;
697 GE_FUNC_EXIT(sc, ""); 697 GE_FUNC_EXIT(sc, "");
698 return; 698 return;
699 } 699 }
700 700
701 /* 701 /*
702 * No space in the pending queue? try later. 702 * No space in the pending queue? try later.
703 */ 703 */
704 if (IF_QFULL(&sc->sc_txq[GE_TXPRIO_HI].txq_pendq)) 704 if (IF_QFULL(&sc->sc_txq[GE_TXPRIO_HI].txq_pendq))
705 break; 705 break;
706 706
 707 IF_DEQUEUE(&ifp->if_snd, m);
 708
707 /* 709 /*
708 * Try to enqueue a mbuf to the device. If that fails, we 710 * Try to enqueue a mbuf to the device. If that fails, we
709 * can always try to map the next mbuf. 711 * can always try to map the next mbuf.
710 */ 712 */
711 IF_ENQUEUE(&sc->sc_txq[GE_TXPRIO_HI].txq_pendq, m); 713 IF_ENQUEUE(&sc->sc_txq[GE_TXPRIO_HI].txq_pendq, m);
712 GE_DPRINTF(sc, (">")); 714 GE_DPRINTF(sc, (">"));
713#ifndef GE_NOTX 715#ifndef GE_NOTX
714 (void) gfe_tx_enqueue(sc, GE_TXPRIO_HI); 716 (void) gfe_tx_enqueue(sc, GE_TXPRIO_HI);
715#endif 717#endif
716 } 718 }
717 719
718 /* 720 /*
719 * Attempt to queue the mbuf for send failed. 721 * Attempt to queue the mbuf for send failed.
720 */ 722 */
721 IF_PREPEND(&ifp->if_snd, m); 
722 ifp->if_flags |= IFF_OACTIVE; 723 ifp->if_flags |= IFF_OACTIVE;
723 GE_FUNC_EXIT(sc, "%%"); 724 GE_FUNC_EXIT(sc, "%%");
724} 725}
725 726
726void 727void
727gfe_ifwatchdog(struct ifnet *ifp) 728gfe_ifwatchdog(struct ifnet *ifp)
728{ 729{
729 struct gfe_softc * const sc = ifp->if_softc; 730 struct gfe_softc * const sc = ifp->if_softc;
730 struct gfe_txqueue * const txq = &sc->sc_txq[GE_TXPRIO_HI]; 731 struct gfe_txqueue * const txq = &sc->sc_txq[GE_TXPRIO_HI];
731 732
732 GE_FUNC_ENTER(sc, "gfe_ifwatchdog"); 733 GE_FUNC_ENTER(sc, "gfe_ifwatchdog");
733 aprint_error_dev(sc->sc_dev, "device timeout"); 734 aprint_error_dev(sc->sc_dev, "device timeout");
734 if (ifp->if_flags & IFF_RUNNING) { 735 if (ifp->if_flags & IFF_RUNNING) {