From owner-svn-src-user@FreeBSD.ORG  Tue Jan 12 09:07:55 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 67D031065670;
	Tue, 12 Jan 2010 09:07:55 +0000 (UTC)
	(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 576418FC14;
	Tue, 12 Jan 2010 09:07:55 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0C97tQ3037222;
	Tue, 12 Jan 2010 09:07:55 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0C97tUe037219;
	Tue, 12 Jan 2010 09:07:55 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001120907.o0C97tUe037219@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Tue, 12 Jan 2010 09:07:55 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r202146 - user/luigi/ipfw3-head/sys/netinet/ipfw
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Tue, 12 Jan 2010 09:07:55 -0000

Author: luigi
Date: Tue Jan 12 09:07:55 2010
New Revision: 202146
URL: http://svn.freebsd.org/changeset/base/202146

Log:
  move the tagging out of the main function.
  add a flag for schedulers to indicate whether they can handle
  multiple queues or not.

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h	Tue Jan 12 09:06:36 2010	(r202145)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h	Tue Jan 12 09:07:55 2010	(r202146)
@@ -32,6 +32,7 @@
 #ifndef _DN_SCHED_H
 #define _DN_SCHED_H
 
+#define	DN_MULTIQUEUE	0x01
 /*
  * Descriptor for the scheduler.
  * Contains all function pointers for a given scheduler
@@ -39,7 +40,8 @@
  * in a global list of schedulers.
  */
 struct dn_sched {
-	int type;           /* the scheduler type */
+	uint32_t type;           /* the scheduler type */
+	uint32_t flags;	/* DN_MULTIQUEUE if supports multiple queues */
 	const char *name;   /* scheduler name */
 	int ref_count;      /* XXX number of instances in the system */
 

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Tue Jan 12 09:06:36 2010	(r202145)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c	Tue Jan 12 09:07:55 2010	(r202146)
@@ -739,6 +739,27 @@ ipdn_locate_flowset(int fs_nr)
 	return (fs);
 }
 
+static inline int
+tag_mbuf(struct mbuf *m, int dir, struct ip_fw_args *fwa)
+{
+	struct dn_pkt_tag *dt;
+	struct m_tag *mtag;
+
+	mtag = m_tag_get(PACKET_TAG_DUMMYNET,
+		    sizeof(*dt), M_NOWAIT | M_ZERO);
+	if (mtag == NULL)
+		return 1;		/* Cannot allocate packet header. */
+	m_tag_prepend(m, mtag);		/* Attach to mbuf chain. */
+	dt = (struct dn_pkt_tag *)(mtag + 1);
+	dt->rule = fwa->rule;
+	dt->rule.info &= IPFW_ONEPASS;	/* only keep this info */
+	dt->dn_dir = dir;
+	dt->ifp = fwa->oif;
+	/* dt->output tame is updated as we move through */
+	dt->output_time = curr_time;
+	return 0;
+}
+
 /*
  * dummynet hook for packets.
  * We use the argument to locate the flowset fs and the sched_set sch
@@ -762,6 +783,7 @@ dummynet_io(struct mbuf **m0, int dir, s
 		((fwa->rule.info & IPFW_IS_PIPE) ? DN_PIPEOFFSET : 0);
 	DUMMYNET_LOCK();
 	io_pkt++;
+	now = curr_time;
 	/* XXX locate_flowset could be optimised with a direct ref. */
 	fs = ipdn_locate_flowset(fs_id);
 	if (fs == NULL)
@@ -772,24 +794,13 @@ dummynet_io(struct mbuf **m0, int dir, s
 	si = find_sch_inst(fs->sched, &(fwa->f_id));
 	if (si == NULL)
 		goto dropit;
-
-	/* tag the mbuf */
-    {
-	struct dn_pkt_tag *dt;
-	struct m_tag *mtag;
-	mtag = m_tag_get(PACKET_TAG_DUMMYNET,
-		    sizeof(*dt), M_NOWAIT | M_ZERO);
-	if (mtag == NULL)
-		goto dropit;		/* Cannot allocate packet header. */
-	m_tag_prepend(m, mtag);		/* Attach to mbuf chain. */
-	dt = (struct dn_pkt_tag *)(mtag + 1);
-	dt->rule = fwa->rule;
-	dt->rule.info &= IPFW_ONEPASS;	/* only keep this info */
-	dt->dn_dir = dir;
-	dt->ifp = fwa->oif;
-	/* dt->output tame is updated as we move through */
-	dt->output_time = now = curr_time;
-    }
+	if (tag_mbuf(m, dir, fwa))
+		goto dropit;
+	/*
+	 * if the scheduler has a single queue (e.g. FIFO) then
+	 * call directly with NULL queue. Otherwise find a queue
+	 * and pass it.
+	 */
 	if (fs->kflags & DN_HAVE_MASK)
 		do_mask(&fs->fs.flow_mask, &(fwa->f_id));
 	if (fs->sched->fp->enqueue(si, fs, m, &(fwa->f_id))) {