From nobody@FreeBSD.org  Thu Mar 10 20:41:46 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id F0FB816A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 Mar 2005 20:41:45 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id BEEFC43D1F
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 Mar 2005 20:41:45 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j2AKfjKm058582
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 Mar 2005 20:41:45 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j2AKfjWn058581;
	Thu, 10 Mar 2005 20:41:45 GMT
	(envelope-from nobody)
Message-Id: <200503102041.j2AKfjWn058581@www.freebsd.org>
Date: Thu, 10 Mar 2005 20:41:45 GMT
From: Theo Schlossnagle <jesus@omniti.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: if_re under 5.3 doesn't support altq
X-Send-Pr-Version: www-2.3

>Number:         78681
>Category:       kern
>Synopsis:       [patch] if_re under 5.3 doesn't support altq
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    mlaier
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 10 20:50:02 GMT 2005
>Closed-Date:    Mon Mar 28 16:07:40 GMT 2005
>Last-Modified:  Mon Mar 28 16:07:40 GMT 2005
>Originator:     Theo Schlossnagle
>Release:        5.3-RELEASE-p5
>Organization:
OmniTI
>Environment:
FreeBSD ecbuild-16 5.3-RELEASE-p5 FreeBSD 5.3-RELEASE-p5 #12: Tue Feb 15 18:55:18 UTC 2005     root@pacifier:/usr/obj/usr/src/sys/GATE  i386
>Description:
Altq required ethernet drivers to use different macros for dequeueing and enqueueing pakcets.  if_re should use those.
>How-To-Repeat:
on a box with "re" interfaces, attempt to use altq in any fashion.
>Fix:
--- /usr/src/sys/dev/re/if_re.c.old     Tue Feb  1 21:37:26 2005
+++ /usr/src/sys/dev/re/if_re.c Tue Feb  1 22:20:04 2005
@@ -1203,7 +1203,9 @@
                ifp->if_baudrate = 1000000000;
        else
                ifp->if_baudrate = 100000000;
-       ifp->if_snd.ifq_maxlen = RL_IFQ_MAXLEN;
+       IFQ_SET_MAXLEN(&ifp->if_snd, RL_IFQ_MAXLEN);
+       ifp->if_snd.ifq_drv_maxlen = RL_IFQ_MAXLEN;
+       IFQ_SET_READY(&ifp->if_snd);
        ifp->if_capenable = ifp->if_capabilities;
 
        callout_handle_init(&sc->rl_stat_ch);
@@ -1786,7 +1788,7 @@
        re_rxeof(sc);
        re_txeof(sc);
 
-       if (ifp->if_snd.ifq_head != NULL)
+       if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
                re_start_locked(ifp);
 
        if (cmd == POLL_AND_CHECK_STATUS) { /* also check status register */
@@ -1870,7 +1872,7 @@
                }
        }
 
-       if (ifp->if_snd.ifq_head != NULL)
+       if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
                re_start_locked(ifp);
 
 done_locked:
@@ -2007,7 +2009,7 @@
 {
        struct rl_softc         *sc;
        struct mbuf             *m_head = NULL;
-       int                     idx;
+       int                     idx, queued = 0;
 
        sc = ifp->if_softc;
 
@@ -2016,7 +2018,7 @@
        idx = sc->rl_ldata.rl_tx_prodidx;
 
        while (sc->rl_ldata.rl_tx_mbuf[idx] == NULL) {
-               IF_DEQUEUE(&ifp->if_snd, m_head);
+               IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head);
                if (m_head == NULL)
                        break;
 

        if (re_encap(sc, &m_head, &idx)) {
-            IF_PREPEND(&ifp->if_snd, m_head);
+            IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
            ifp->if_flags |= IFF_OACTIVE;
            break;
        }
@@ -2031,25 +2033,27 @@
                 * to him.
                 */
                BPF_MTAP(ifp, m_head);
+
+               queued++;
        }
 
        /* Flush the TX descriptors */
+       if (queued) {
+               bus_dmamap_sync(sc->rl_ldata.rl_tx_list_tag,
+                       sc->rl_ldata.rl_tx_list_map,
+                       BUS_DMASYNC_PREWRITE|BUS_DMASYNC_PREREAD);
 
-       bus_dmamap_sync(sc->rl_ldata.rl_tx_list_tag,
-           sc->rl_ldata.rl_tx_list_map,
-           BUS_DMASYNC_PREWRITE|BUS_DMASYNC_PREREAD);
-
-       sc->rl_ldata.rl_tx_prodidx = idx;
+               sc->rl_ldata.rl_tx_prodidx = idx;
 
        /*
         * RealTek put the TX poll request register in a different
         * location on the 8169 gigE chip. I don't know why.
         */
 
-       if (sc->rl_type == RL_8169)
-               CSR_WRITE_2(sc, RL_GTXSTART, RL_TXSTART_START);
-       else
-               CSR_WRITE_2(sc, RL_TXSTART, RL_TXSTART_START);
+               if (sc->rl_type == RL_8169)
+                       CSR_WRITE_2(sc, RL_GTXSTART, RL_TXSTART_START);
+               else
+                       CSR_WRITE_2(sc, RL_TXSTART, RL_TXSTART_START);
 
        /*
         * Use the countdown timer for interrupt moderation.
@@ -2059,12 +2063,13 @@
         * interrupt. Each time we write to the TIMERCNT register,
         * the timer count is reset to 0.
         */
-       CSR_WRITE_4(sc, RL_TIMERCNT, 1);
+               CSR_WRITE_4(sc, RL_TIMERCNT, 1);
 
        /*
         * Set a timeout in case the chip goes out to lunch.
         */
-       ifp->if_timer = 5;
+               ifp->if_timer = 5;
+       }
 }
 
 static void

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->mlaier 
Responsible-Changed-By: simon 
Responsible-Changed-When: Thu Mar 10 21:03:24 GMT 2005 
Responsible-Changed-Why:  
ALTQ is normally mlaier's area. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=78681 
State-Changed-From-To: open->patched 
State-Changed-By: mlaier 
State-Changed-When: Sat Mar 12 17:36:01 GMT 2005 
State-Changed-Why:  
A slightly diffrent patch has been committed to HEAD.  MFC in two weeks as 
proper testing of these changes ir required. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=78681 
State-Changed-From-To: patched->closed 
State-Changed-By: mlaier 
State-Changed-When: Mon Mar 28 16:06:52 GMT 2005 
State-Changed-Why:  
MFCed, thanks.  Should be part of 5.4R 

http://www.freebsd.org/cgi/query-pr.cgi?pr=78681 
>Unformatted:
