netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: davem@davemloft.net
Cc: netdev@oss.sgi.com
Subject: [PATCH 6/7] [PKT_SCHED]: Cleanup pfifo_fast qdisc and remove unnecessary code
Date: Tue, 07 Jun 2005 16:08:48 +0200	[thread overview]
Message-ID: <20050607140901.469224000@axs> (raw)
In-Reply-To: 20050607140842.778143000@axs

[-- Attachment #1: sch_pfifo_fast_cleanup --]
[-- Type: text/plain, Size: 3141 bytes --]

Removes the skb trimming code which is not needed since we never
touch the skb upon failure. Removes unnecessary initializers,
and simplifies the code a bit.

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.13/net/sched/sch_generic.c
===================================================================
--- net-2.6.13.orig/net/sched/sch_generic.c
+++ net-2.6.13/net/sched/sch_generic.c
@@ -311,6 +311,8 @@ static const u8 prio2band[TC_PRIO_MAX+1]
    generic prio+fifo combination.
  */
 
+#define PFIFO_FAST_BANDS 3
+
 static inline struct sk_buff_head *prio2list(struct sk_buff *skb,
 					     struct Qdisc *qdisc)
 {
@@ -318,8 +320,7 @@ static inline struct sk_buff_head *prio2
 	return list + prio2band[skb->priority & TC_PRIO_MAX];
 }
 
-static int
-pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc* qdisc)
+static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc* qdisc)
 {
 	struct sk_buff_head *list = prio2list(skb, qdisc);
 
@@ -331,36 +332,34 @@ pfifo_fast_enqueue(struct sk_buff *skb, 
 	return qdisc_drop(skb, qdisc);
 }
 
-static struct sk_buff *
-pfifo_fast_dequeue(struct Qdisc* qdisc)
+static struct sk_buff *pfifo_fast_dequeue(struct Qdisc* qdisc)
 {
 	int prio;
 	struct sk_buff_head *list = qdisc_priv(qdisc);
 
-	for (prio = 0; prio < 3; prio++, list++) {
+	for (prio = 0; prio < PFIFO_FAST_BANDS; prio++, list++) {
 		struct sk_buff *skb = __qdisc_dequeue_head(qdisc, list);
 		if (skb) {
 			qdisc->q.qlen--;
 			return skb;
 		}
 	}
+
 	return NULL;
 }
 
-static int
-pfifo_fast_requeue(struct sk_buff *skb, struct Qdisc* qdisc)
+static int pfifo_fast_requeue(struct sk_buff *skb, struct Qdisc* qdisc)
 {
 	qdisc->q.qlen++;
 	return __qdisc_requeue(skb, qdisc, prio2list(skb, qdisc));
 }
 
-static void
-pfifo_fast_reset(struct Qdisc* qdisc)
+static void pfifo_fast_reset(struct Qdisc* qdisc)
 {
 	int prio;
 	struct sk_buff_head *list = qdisc_priv(qdisc);
 
-	for (prio=0; prio < 3; prio++)
+	for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
 		__qdisc_reset_queue(qdisc, list + prio);
 
 	qdisc->qstats.backlog = 0;
@@ -369,35 +368,30 @@ pfifo_fast_reset(struct Qdisc* qdisc)
 
 static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
 {
-	unsigned char	 *b = skb->tail;
-	struct tc_prio_qopt opt;
+	struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
 
-	opt.bands = 3; 
 	memcpy(&opt.priomap, prio2band, TC_PRIO_MAX+1);
 	RTA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
 	return skb->len;
 
 rtattr_failure:
-	skb_trim(skb, b - skb->data);
 	return -1;
 }
 
 static int pfifo_fast_init(struct Qdisc *qdisc, struct rtattr *opt)
 {
-	int i;
+	int prio;
 	struct sk_buff_head *list = qdisc_priv(qdisc);
 
-	for (i=0; i<3; i++)
-		skb_queue_head_init(list+i);
+	for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
+		skb_queue_head_init(list + prio);
 
 	return 0;
 }
 
 static struct Qdisc_ops pfifo_fast_ops = {
-	.next		=	NULL,
-	.cl_ops		=	NULL,
 	.id		=	"pfifo_fast",
-	.priv_size	=	3 * sizeof(struct sk_buff_head),
+	.priv_size	=	PFIFO_FAST_BANDS * sizeof(struct sk_buff_head),
 	.enqueue	=	pfifo_fast_enqueue,
 	.dequeue	=	pfifo_fast_dequeue,
 	.requeue	=	pfifo_fast_requeue,

       reply	other threads:[~2005-06-07 14:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20050607140842.778143000@axs>
2005-06-07 14:08 ` Thomas Graf [this message]
2005-06-07 14:08 ` [PATCH 7/7] [PKT_SCHED]: noop/noqueue qdisc style cleanups Thomas Graf
2005-06-07 21:36   ` netdev munching messages again? Thomas Graf
2005-06-07 21:42     ` David S. Miller
2005-06-08 13:29       ` Thomas Graf
2005-06-08 13:44         ` jamal
2005-06-08 16:04           ` Ralf Baechle
2005-06-08 16:13             ` Thomas Graf
2005-06-08 17:28               ` Ralf Baechle
2005-06-08 20:00                 ` Thomas Graf
2005-06-08 20:10                   ` David S. Miller
2005-06-08 20:30                     ` randy_dunlap
     [not found]                       ` <42A77446.3030102@us.ibm.com>
2005-06-08 22:46                         ` netdev moved to vger; please subscribe David S. Miller
2005-06-09 13:27                     ` [PATCH] Re: netdev munching messages again? Ralf Baechle
2005-06-09 16:18                       ` Ralf Baechle
     [not found]                   ` <20050609122325.GE4927@linux-mips.org>
2005-06-09 12:43                     ` jamal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050607140901.469224000@axs \
    --to=tgraf@suug.ch \
    --cc=davem@davemloft.net \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).