From owner-freebsd-net@FreeBSD.ORG Fri Nov 29 17:24:16 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C6474DE4; Fri, 29 Nov 2013 17:24:16 +0000 (UTC) Received: from mail-n.franken.de (drew.ipv6.franken.de [IPv6:2001:638:a02:a001:20e:cff:fe4a:feaa]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 357C212F2; Fri, 29 Nov 2013 17:24:15 +0000 (UTC) Received: from [192.168.1.102] (p508F32E7.dip0.t-ipconnect.de [80.143.50.231]) (Authenticated sender: macmic) by mail-n.franken.de (Postfix) with ESMTP id E91891C0C0692; Fri, 29 Nov 2013 18:24:12 +0100 (CET) From: Michael Tuexen Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: A small fix for if_em.c, if_igb.c, if_ixgbe.c Date: Fri, 29 Nov 2013 18:24:12 +0100 Message-Id: <521B9C2A-EECC-4412-9F68-2235320EF324@lurchi.franken.de> To: "freebsd-net@freebsd.org list" Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) X-Mailer: Apple Mail (2.1510) Cc: Jack F Vogel X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Nov 2013 17:24:16 -0000 Dear all, ifnet(9) says regarding if_transmit(): Transmit a packet on an interface or queue it if the interface is in use. This function will return ENOBUFS if the devices software and hardware queues are both full. The drivers for em, igb and ixgbe might also return an error even in the case the packet was enqueued. The attached patches fix this issue. Any comments? Jack: What do you think? Would you prefer to commit the fix if you think it is acceptable? Best regards Michael [bsd5:~/head/sys/dev] tuexen% svn diff -x -p Index: e1000/if_em.c =================================================================== --- e1000/if_em.c (revision 258746) +++ e1000/if_em.c (working copy) @@ -930,7 +930,7 @@ em_mq_start_locked(struct ifnet *ifp, struct tx_ri /* Process the queue */ while ((next = drbr_peek(ifp, txr->br)) != NULL) { - if ((err = em_xmit(txr, &next)) != 0) { + if (em_xmit(txr, &next) != 0) { if (next == NULL) drbr_advance(ifp, txr->br); else @@ -957,7 +957,7 @@ em_mq_start_locked(struct ifnet *ifp, struct tx_ri em_txeof(txr); if (txr->tx_avail < EM_MAX_SCATTER) ifp->if_drv_flags |= IFF_DRV_OACTIVE; - return (err); + return (0); } /* Index: e1000/if_igb.c =================================================================== --- e1000/if_igb.c (revision 258746) +++ e1000/if_igb.c (working copy) @@ -192,7 +192,7 @@ static int igb_suspend(device_t); static int igb_resume(device_t); #ifndef IGB_LEGACY_TX static int igb_mq_start(struct ifnet *, struct mbuf *); -static int igb_mq_start_locked(struct ifnet *, struct tx_ring *); +static void igb_mq_start_locked(struct ifnet *, struct tx_ring *); static void igb_qflush(struct ifnet *); static void igb_deferred_mq_start(void *, int); #else @@ -989,31 +989,31 @@ igb_mq_start(struct ifnet *ifp, struct mbuf *m) if (err) return (err); if (IGB_TX_TRYLOCK(txr)) { - err = igb_mq_start_locked(ifp, txr); + igb_mq_start_locked(ifp, txr); IGB_TX_UNLOCK(txr); } else taskqueue_enqueue(que->tq, &txr->txq_task); - return (err); + return (0); } -static int +static void igb_mq_start_locked(struct ifnet *ifp, struct tx_ring *txr) { struct adapter *adapter = txr->adapter; struct mbuf *next; - int err = 0, enq = 0; + int enq = 0; IGB_TX_LOCK_ASSERT(txr); if (((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) || adapter->link_active == 0) - return (ENETDOWN); + return; /* Process the queue */ while ((next = drbr_peek(ifp, txr->br)) != NULL) { - if ((err = igb_xmit(txr, &next)) != 0) { + if (igb_xmit(txr, &next) != 0) { if (next == NULL) { /* It was freed, move forward */ drbr_advance(ifp, txr->br); @@ -1045,7 +1045,7 @@ igb_mq_start_locked(struct ifnet *ifp, struct tx_r igb_txeof(txr); if (txr->tx_avail <= IGB_MAX_SCATTER) txr->queue_status |= IGB_QUEUE_DEPLETED; - return (err); + return; } /* Index: ixgbe/ixgbe.c =================================================================== --- ixgbe/ixgbe.c (revision 258746) +++ ixgbe/ixgbe.c (working copy) @@ -107,7 +107,7 @@ static void ixgbe_start(struct ifnet *); static void ixgbe_start_locked(struct tx_ring *, struct ifnet *); #else /* ! IXGBE_LEGACY_TX */ static int ixgbe_mq_start(struct ifnet *, struct mbuf *); -static int ixgbe_mq_start_locked(struct ifnet *, struct tx_ring *); +static void ixgbe_mq_start_locked(struct ifnet *, struct tx_ring *); static void ixgbe_qflush(struct ifnet *); static void ixgbe_deferred_mq_start(void *, int); #endif /* IXGBE_LEGACY_TX */ @@ -831,35 +831,35 @@ ixgbe_mq_start(struct ifnet *ifp, struct mbuf *m) if (err) return (err); if (IXGBE_TX_TRYLOCK(txr)) { - err = ixgbe_mq_start_locked(ifp, txr); + ixgbe_mq_start_locked(ifp, txr); IXGBE_TX_UNLOCK(txr); } else taskqueue_enqueue(que->tq, &txr->txq_task); - return (err); + return (0); } -static int +static void ixgbe_mq_start_locked(struct ifnet *ifp, struct tx_ring *txr) { struct adapter *adapter = txr->adapter; struct mbuf *next; - int enqueued = 0, err = 0; + int enqueued = 0; if (((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) || adapter->link_active == 0) - return (ENETDOWN); + return; /* Process the queue */ #if __FreeBSD_version < 901504 next = drbr_dequeue(ifp, txr->br); while (next != NULL) { - if ((err = ixgbe_xmit(txr, &next)) != 0) { + if (ixgbe_xmit(txr, &next) != 0) { if (next != NULL) - err = drbr_enqueue(ifp, txr->br, next); + drbr_enqueue(ifp, txr->br, next); #else while ((next = drbr_peek(ifp, txr->br)) != NULL) { - if ((err = ixgbe_xmit(txr, &next)) != 0) { + if (ixgbe_xmit(txr, &next) != 0) { if (next == NULL) { drbr_advance(ifp, txr->br); } else { @@ -890,7 +890,7 @@ ixgbe_mq_start_locked(struct ifnet *ifp, struct tx if (txr->tx_avail < IXGBE_TX_CLEANUP_THRESHOLD) ixgbe_txeof(txr); - return (err); + return; } /*