public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Duan Jiong <duanj.fnst@cn•fujitsu.com>
To: Yang Yingliang <yangyingliang@huawei•com>,
	davem@davemloft•net, netdev@vger•kernel.org
Cc: eric.dumazet@gmail•com
Subject: Re: [PATCH net-next] sch_tbf: add TBF_BURST/TBF_PBURST attribute
Date: Fri, 13 Dec 2013 17:50:31 +0800	[thread overview]
Message-ID: <52AAD867.5030305@cn.fujitsu.com> (raw)
In-Reply-To: <1386927716-7896-1-git-send-email-yangyingliang@huawei.com>

于 2013年12月13日 17:41, Yang Yingliang 写道:
> When we set burst to 1514 with low rate in userspace,
> the kernel get a value of burst that less than 1514,
> which doesn't work.
> 
> Because it may make some loss when transform burst
> to buffer in userspace. This makes burst lose some
> bytes, when the kernel transform the buffer back to
> burst.
> 
> This patch adds two new attributes to support sending
> burst/mtu to kernel directly to avoid the loss.
> 
> Signed-off-by: Yang Yingliang <yangyingliang@huawei•com>
> ---
>  include/uapi/linux/pkt_sched.h |  2 ++
>  net/sched/sch_tbf.c            | 25 +++++++++++++++++++++----
>  2 files changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
> index a806687..fd8e17e 100644
> --- a/include/uapi/linux/pkt_sched.h
> +++ b/include/uapi/linux/pkt_sched.h
> @@ -173,6 +173,8 @@ enum {
>  	TCA_TBF_PTAB,
>  	TCA_TBF_RATE64,
>  	TCA_TBF_PRATE64,
> +	TCA_TBF_BURST,
> +	TCA_TBF_PBURST,
>  	__TCA_TBF_MAX,
>  };
>  
> diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
> index 887e672..a746049 100644
> --- a/net/sched/sch_tbf.c
> +++ b/net/sched/sch_tbf.c
> @@ -307,6 +307,8 @@ static const struct nla_policy tbf_policy[TCA_TBF_MAX + 1] = {
>  	[TCA_TBF_PTAB]	= { .type = NLA_BINARY, .len = TC_RTAB_SIZE },
>  	[TCA_TBF_RATE64]	= { .type = NLA_U64 },
>  	[TCA_TBF_PRATE64]	= { .type = NLA_U64 },
> +	[TCA_TBF_BURST]		= { .type = NLA_U32 },

This place should remove one tab.

Thanks,
  Duan

> +	[TCA_TBF_PBURST]	= { .type = NLA_U32 },
>  };
>  
>  static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
> @@ -358,7 +360,11 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
>  		rate64 = nla_get_u64(tb[TCA_TBF_RATE64]);
>  	psched_ratecfg_precompute(&rate, &qopt->rate, rate64);
>  
> -	max_size = min_t(u64, psched_ns_t2l(&rate, buffer), ~0U);
> +	if (tb[TCA_TBF_BURST]) {
> +		max_size = nla_get_u32(tb[TCA_TBF_BURST]);
> +		buffer = psched_l2t_ns(&rate, max_size);
> +	} else
> +		max_size = min_t(u64, psched_ns_t2l(&rate, buffer), ~0U);
>  
>  	if (qopt->peakrate.rate) {
>  		if (tb[TCA_TBF_PRATE64])
> @@ -371,7 +377,12 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
>  			goto done;
>  		}
>  
> -		max_size = min_t(u64, max_size, psched_ns_t2l(&peak, mtu));
> +		if (tb[TCA_TBF_PBURST]) {
> +			u32 pburst = nla_get_u32(tb[TCA_TBF_PBURST]);
> +			max_size = min_t(u32, max_size, pburst);
> +			mtu = psched_l2t_ns(&peak, pburst);
> +		} else
> +			max_size = min_t(u64, max_size, psched_ns_t2l(&peak, mtu));
>  	}
>  
>  	if (max_size < psched_mtu(qdisc_dev(sch)))
> @@ -391,9 +402,15 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
>  		q->qdisc = child;
>  	}
>  	q->limit = qopt->limit;
> -	q->mtu = PSCHED_TICKS2NS(qopt->mtu);
> +	if (tb[TCA_TBF_PBURST])
> +		q->mtu = mtu;
> +	else
> +		q->mtu = PSCHED_TICKS2NS(qopt->mtu);
>  	q->max_size = max_size;
> -	q->buffer = PSCHED_TICKS2NS(qopt->buffer);
> +	if (tb[TCA_TBF_BURST])
> +		q->buffer = buffer;
> +	else
> +		q->buffer = PSCHED_TICKS2NS(qopt->buffer);
>  	q->tokens = q->buffer;
>  	q->ptokens = q->mtu;
>  
> 

  reply	other threads:[~2013-12-13  9:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-13  9:41 [PATCH net-next] sch_tbf: add TBF_BURST/TBF_PBURST attribute Yang Yingliang
2013-12-13  9:50 ` Duan Jiong [this message]
2013-12-16  2:11   ` Yang Yingliang
2013-12-17  3:34 ` [PATCH resend " Yang Yingliang
2013-12-19 20:03   ` David Miller
2013-12-19 20:15   ` Eric Dumazet
2013-12-20  1:24     ` [PATCH v3 " Yang Yingliang
2013-12-20  1:31       ` Eric Dumazet
2013-12-26 18:54       ` David Miller

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=52AAD867.5030305@cn.fujitsu.com \
    --to=duanj.fnst@cn$(echo .)fujitsu.com \
    --cc=davem@davemloft$(echo .)net \
    --cc=eric.dumazet@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=yangyingliang@huawei$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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