netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH RFC 3/3] net_sched: Add size table for qdiscs
Date: Thu, 17 Jul 2008 12:30:48 +0200	[thread overview]
Message-ID: <487F1F58.3040701@trash.net> (raw)
In-Reply-To: <20080717100938.3327.45121.stgit@fate.lan>

Jussi Kivilinna wrote:
> diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
> index dbb7ac3..eae53bf 100644
> --- a/include/linux/pkt_sched.h
> +++ b/include/linux/pkt_sched.h
> @@ -85,6 +85,27 @@ struct tc_ratespec
>  
>  #define TC_RTAB_SIZE	1024
>  
> +struct tc_sizespec {
> +	unsigned char	cell_log;
> +	unsigned char	size_log;
> +	short		cell_align;
> +	int		overhead;
> +	unsigned	linklayer;
> +	unsigned	mpu;
> +	unsigned	mtu;
> +};

Please use "unsigned int".

> +
> +#define TC_STAB_DATA_SIZE 1024
> +
> +enum {
> +	TCA_STAB_UNSPEC,
> +	TCA_STAB_BASE,
> +	TCA_STAB_DATA,
> +	__TCA_STAB_MAX
> +};

Since you already split the STAB into a base and a data
structure, wouldn't it make sense to have the data size
dynamic for user-defined granularity?

> +static LIST_HEAD(qdisc_stab_list);
> +
> +static const struct nla_policy stab_policy[TCA_STAB_MAX + 1] = {
> +	[TCA_STAB_BASE]	= { .len = sizeof(struct tc_sizespec) },
> +	[TCA_STAB_DATA] = { .type = NLA_BINARY, .len = TC_STAB_DATA_SIZE },
> +};
> +
> +static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt, int *err)
> +{
> +	struct nlattr *tb[TCA_STAB_MAX + 1];
> +	struct qdisc_size_table *stab;
> +	struct tc_sizespec *s;
> +	u16 *tab;
> +
> +	*err = nla_parse_nested(tb, TCA_STAB_MAX, opt, stab_policy);
> +	if (*err < 0)
> +		return NULL;

ERR_PTR is cleaner than pointer return values IMO.

> diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
> index bc9d6af..f75ba82 100644
> --- a/net/sched/sch_netem.c
> +++ b/net/sched/sch_netem.c
> @@ -84,7 +84,7 @@ struct netem_skb_cb {
>  
>  static inline struct netem_skb_cb *netem_skb_cb(struct sk_buff *skb)
>  {
> -	return (struct netem_skb_cb *)skb->cb;
> +	return (struct netem_skb_cb *)qdisc_skb_cb(skb)->data;
>  }

A BUILD_BUG_ON to make sure the skb->cb size is not exceeded would
be good to have.

>  /* init_crandom - initialize correlated random number generator
> @@ -189,6 +189,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
>  		u32 dupsave = q->duplicate; /* prevent duplicating a dup... */
>  		q->duplicate = 0;
>  
> +		qdisc_root_init_tx_len(skb2, rootq);
>  		qdisc_enqueue(skb2, rootq);

How about adding qdisc_enqueue_root() to perform both these steps
(its similar to net/core/dev.c).

> diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
> index 1e3d52e..862c0e3 100644
> --- a/net/sched/sch_tbf.c
> +++ b/net/sched/sch_tbf.c
> @@ -123,9 +123,9 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc* sch)
>  	struct tbf_sched_data *q = qdisc_priv(sch);
>  	int ret;
>  
> -	/* qdisc_tx_len() before qdisc_enqueue() wrapper, might return different
> -	 * length than after wrapper. Should recalculate tx_len here if q->qdisc
> -	 * has size table? */
> +	if (q->qdisc->stab)
> +		qdisc_calculate_tx_len(skb, q->qdisc->stab);
> +

I don't think this will help, the inner qdisc might again have
an inner qdisc that increases the size. So this probably needs
to be handled during dequeue.

>  	if (qdisc_tx_len(skb) > q->max_size) {
>  		sch->qstats.drops++;
>  #ifdef CONFIG_NET_CLS_ACT
> 


  reply	other threads:[~2008-07-17 10:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-17 10:09 [PATCH RFC 0/3] Add generic size table for qdiscs Jussi Kivilinna
2008-07-17 10:09 ` [PATCH RFC 1/3] net_sched: Add qdisc_enqueue wrapper Jussi Kivilinna
2008-07-17 10:10   ` Patrick McHardy
2008-07-17 10:09 ` [PATCH RFC 2/3] net_sched: Add accessor function for packet length for qdiscs Jussi Kivilinna
2008-07-17 10:11   ` Patrick McHardy
2008-07-17 11:33     ` Jussi Kivilinna
2008-07-17 10:09 ` [PATCH RFC 3/3] net_sched: Add size table " Jussi Kivilinna
2008-07-17 10:30   ` Patrick McHardy [this message]
2008-07-17 18:02     ` Jussi Kivilinna
2008-07-21 13:00       ` Patrick McHardy
2008-07-21 13:03         ` Jussi Kivilinna

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=487F1F58.3040701@trash.net \
    --to=kaber@trash.net \
    --cc=jussi.kivilinna@mbnet.fi \
    --cc=netdev@vger.kernel.org \
    /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).