[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ALTQ/FreeBSD] Re: if_em



On Tue, Feb 10, 2004 at 05:52:59AM +0100, Arnaud Pignard wrote:
 > Hello,
 > 
 > i have install patch and seems server not crash. (with version of if_em.c 
 > did you patch?)
 > I haven't yet test if altqd shape correctly. Anyway altqstat work and altqd 
 > start.
 > 
 > In your patch you forgot one } for the for (;;) {
 > 
 > I have add one after :
 > ifp->if_timer = EM_TX_TIMEOUT;
 > 
 > is it the good place ?
 > 
 > Will report tomorrow if em patch working.
 > 
 > Thanks, Regards,
 > 

My apologies. The diff was wrong.
Here is updated one.(compilation tested on 5.2.1RC)

--- if_em.c.ORG	Mon Dec  8 01:53:50 2003
+++ if_em.c	Tue Feb 10 14:23:38 2004
@@ -609,18 +609,24 @@
         if (!adapter->link_active)
                 return;
 
-        while (ifp->if_snd.ifq_head != NULL) {
-
-                IF_DEQUEUE(&ifp->if_snd, m_head);
-                
-                if (m_head == NULL) break;
+	for (;;) {
+		IFQ_LOCK(&ifp->if_snd);
+		IFQ_POLL_NOLOCK(&ifp->if_snd, m_head);
+                if (m_head == NULL) {
+			IFQ_UNLOCK(&ifp->if_snd);
+			break;
+		}
                         
 		if (em_encap(adapter, m_head)) { 
+			IFQ_UNLOCK(&ifp->if_snd);
 			ifp->if_flags |= IFF_OACTIVE;
-			IF_PREPEND(&ifp->if_snd, m_head);
 			break;
                 }
 
+		/* now we are committed to transmit the packet */
+		IFQ_DEQUEUE_NOLOCK(&ifp->if_snd, m_head);
+		IFQ_UNLOCK(&ifp->if_snd);
+
 		/* Send a copy of the frame to the BPF listener */
 #if __FreeBSD_version < 500000
                 if (ifp->if_bpf)
@@ -902,7 +908,7 @@
                 em_clean_transmit_interrupts(adapter);
         }
 	
-        if (ifp->if_flags & IFF_RUNNING && ifp->if_snd.ifq_head != NULL)
+	if (ifp->if_flags & IFF_RUNNING && IFQ_IS_EMPTY(&ifp->if_snd) == 0)
                 em_start_locked(ifp);
 }
         
@@ -971,7 +977,7 @@
                 loop_cnt--;
         }
                  
-        if (ifp->if_flags & IFF_RUNNING && ifp->if_snd.ifq_head != NULL)
+	if (ifp->if_flags & IFF_RUNNING && IFQ_IS_EMPTY(&ifp->if_snd) == 0)
                 em_start_locked(ifp);
 
 	EM_UNLOCK(adapter);
@@ -1833,7 +1839,8 @@
 	ifp->if_ioctl = em_ioctl;
 	ifp->if_start = em_start;
 	ifp->if_watchdog = em_watchdog;
-	ifp->if_snd.ifq_maxlen = adapter->num_tx_desc - 1;
+	IFQ_SET_MAXLEN(&ifp->if_snd, adapter->num_tx_desc - 1);
+	IFQ_SET_READY(&ifp->if_snd);
 
 #if __FreeBSD_version < 500000
         ether_ifattach(ifp, ETHER_BPF_SUPPORTED);

Regards,
Pyun YongHyeon
-- 
Pyun YongHyeon <http://www.kr.freebsd.org/~yongari>
_________________________________________________________________
Send 'unsubscribe freebsd-altq' to listar@rofug.ro to unsubscribe