netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] sch_tbf: add TBF_BURST/TBF_PBURST attribute
@ 2013-12-13  9:41 Yang Yingliang
  2013-12-13  9:50 ` Duan Jiong
  2013-12-17  3:34 ` [PATCH resend " Yang Yingliang
  0 siblings, 2 replies; 9+ messages in thread
From: Yang Yingliang @ 2013-12-13  9:41 UTC (permalink / raw)
  To: davem, netdev; +Cc: eric.dumazet

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 },
+	[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;
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next] sch_tbf: add TBF_BURST/TBF_PBURST attribute
  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
  2013-12-16  2:11   ` Yang Yingliang
  2013-12-17  3:34 ` [PATCH resend " Yang Yingliang
  1 sibling, 1 reply; 9+ messages in thread
From: Duan Jiong @ 2013-12-13  9:50 UTC (permalink / raw)
  To: Yang Yingliang, davem, netdev; +Cc: eric.dumazet

于 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;
>  
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next] sch_tbf: add TBF_BURST/TBF_PBURST attribute
  2013-12-13  9:50 ` Duan Jiong
@ 2013-12-16  2:11   ` Yang Yingliang
  0 siblings, 0 replies; 9+ messages in thread
From: Yang Yingliang @ 2013-12-16  2:11 UTC (permalink / raw)
  To: Duan Jiong; +Cc: netdev

On 2013/12/13 17:50, Duan Jiong wrote:
> 于 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>
>> ---
[...]
>> 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
> 

OK, thanks!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH resend net-next] sch_tbf: add TBF_BURST/TBF_PBURST attribute
  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
@ 2013-12-17  3:34 ` Yang Yingliang
  2013-12-19 20:03   ` David Miller
  2013-12-19 20:15   ` Eric Dumazet
  1 sibling, 2 replies; 9+ messages in thread
From: Yang Yingliang @ 2013-12-17  3:34 UTC (permalink / raw)
  To: davem, netdev; +Cc: eric.dumazet

From: Yang Yingliang <yangyingliang@huawei.com>

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..ee84409 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 },
+	[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;
 
-- 1.8.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH resend net-next] sch_tbf: add TBF_BURST/TBF_PBURST attribute
  2013-12-17  3:34 ` [PATCH resend " Yang Yingliang
@ 2013-12-19 20:03   ` David Miller
  2013-12-19 20:15   ` Eric Dumazet
  1 sibling, 0 replies; 9+ messages in thread
From: David Miller @ 2013-12-19 20:03 UTC (permalink / raw)
  To: yangyingliang; +Cc: netdev, eric.dumazet

From: Yang Yingliang <yangyingliang@huawei.com>
Date: Tue, 17 Dec 2013 11:34:39 +0800

> From: Yang Yingliang <yangyingliang@huawei.com>
> 
> 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>

I really want to see some review of this change, thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH resend net-next] sch_tbf: add TBF_BURST/TBF_PBURST attribute
  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
  1 sibling, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2013-12-19 20:15 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: davem, netdev

On Tue, 2013-12-17 at 11:34 +0800, Yang Yingliang wrote:
> From: Yang Yingliang <yangyingliang@huawei.com>
> 
> 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..ee84409 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 },
> +	[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);
>  
         } else {
                ...
         }

>  	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));
                 } else {
                 }

>  	}
>  
>  	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;
>  

Otherwise, looks good.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 net-next] sch_tbf: add TBF_BURST/TBF_PBURST attribute
  2013-12-19 20:15   ` Eric Dumazet
@ 2013-12-20  1:24     ` Yang Yingliang
  2013-12-20  1:31       ` Eric Dumazet
  2013-12-26 18:54       ` David Miller
  0 siblings, 2 replies; 9+ messages in thread
From: Yang Yingliang @ 2013-12-20  1:24 UTC (permalink / raw)
  To: davem, netdev; +Cc: Eric Dumazet

From: Yang Yingliang <yangyingliang@huawei.com>

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>

---
Change note: 

v2 -> v3:
	add parentheses after "else"

v1 -> v2:
	remove an unnecessary tab
---
 include/uapi/linux/pkt_sched.h |  2 ++
 net/sched/sch_tbf.c            | 29 ++++++++++++++++++++++++-----
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
index 4566993..fe11920 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..fbba5b0 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 },
+	[TCA_TBF_PBURST] = { .type = NLA_U32 },
 };
 
 static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
@@ -358,7 +360,12 @@ 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])
@@ -366,12 +373,18 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
 		psched_ratecfg_precompute(&peak, &qopt->peakrate, prate64);
 		if (peak.rate_bytes_ps <= rate.rate_bytes_ps) {
 			pr_warn_ratelimited("sch_tbf: peakrate %llu is lower than or equals to rate %llu !\n",
-					    peak.rate_bytes_ps, rate.rate_bytes_ps);
+					peak.rate_bytes_ps, rate.rate_bytes_ps);
 			err = -EINVAL;
 			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 +404,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;
 
-- 1.8.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 net-next] sch_tbf: add TBF_BURST/TBF_PBURST attribute
  2013-12-20  1:24     ` [PATCH v3 " Yang Yingliang
@ 2013-12-20  1:31       ` Eric Dumazet
  2013-12-26 18:54       ` David Miller
  1 sibling, 0 replies; 9+ messages in thread
From: Eric Dumazet @ 2013-12-20  1:31 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: davem, netdev

On Fri, 2013-12-20 at 09:24 +0800, Yang Yingliang wrote:
> From: Yang Yingliang <yangyingliang@huawei.com>
> 
> 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>

Acked-by: Eric Dumazet <edumazet@google.com>

Thanks

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 net-next] sch_tbf: add TBF_BURST/TBF_PBURST attribute
  2013-12-20  1:24     ` [PATCH v3 " Yang Yingliang
  2013-12-20  1:31       ` Eric Dumazet
@ 2013-12-26 18:54       ` David Miller
  1 sibling, 0 replies; 9+ messages in thread
From: David Miller @ 2013-12-26 18:54 UTC (permalink / raw)
  To: yangyingliang; +Cc: netdev, eric.dumazet

From: Yang Yingliang <yangyingliang@huawei.com>
Date: Fri, 20 Dec 2013 09:24:47 +0800

> From: Yang Yingliang <yangyingliang@huawei.com>
> 
> 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>

Applied, thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-12-26 18:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).