diff mbox

[net-next,v3,05/10] net: sched: move TC_H_MAJ macro call into tcf_auto_prio

Message ID 20170516172802.1317-6-jiri@resnulli.us
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Jiri Pirko May 16, 2017, 5:27 p.m. UTC
From: Jiri Pirko <jiri@mellanox.com>

Call the helper from the function rather than to always adjust the
return value of the function.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 net/sched/cls_api.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Cong Wang May 16, 2017, 9:01 p.m. UTC | #1
On Tue, May 16, 2017 at 10:27 AM, Jiri Pirko <jiri@resnulli.us> wrote:
> From: Jiri Pirko <jiri@mellanox.com>
>
> Call the helper from the function rather than to always adjust the
> return value of the function.

And rename the function name to reflect this change?
Jiri Pirko May 16, 2017, 9:03 p.m. UTC | #2
Tue, May 16, 2017 at 11:01:52PM CEST, xiyou.wangcong@gmail.com wrote:
>On Tue, May 16, 2017 at 10:27 AM, Jiri Pirko <jiri@resnulli.us> wrote:
>> From: Jiri Pirko <jiri@mellanox.com>
>>
>> Call the helper from the function rather than to always adjust the
>> return value of the function.
>
>And rename the function name to reflect this change?

? What do you suggest?
Cong Wang May 16, 2017, 10:38 p.m. UTC | #3
On Tue, May 16, 2017 at 2:03 PM, Jiri Pirko <jiri@resnulli.us> wrote:
> Tue, May 16, 2017 at 11:01:52PM CEST, xiyou.wangcong@gmail.com wrote:
>>On Tue, May 16, 2017 at 10:27 AM, Jiri Pirko <jiri@resnulli.us> wrote:
>>> From: Jiri Pirko <jiri@mellanox.com>
>>>
>>> Call the helper from the function rather than to always adjust the
>>> return value of the function.
>>
>>And rename the function name to reflect this change?
>
> ? What do you suggest?

tcf_auto_major_prio()?
Jiri Pirko May 17, 2017, 5:47 a.m. UTC | #4
Wed, May 17, 2017 at 12:38:08AM CEST, xiyou.wangcong@gmail.com wrote:
>On Tue, May 16, 2017 at 2:03 PM, Jiri Pirko <jiri@resnulli.us> wrote:
>> Tue, May 16, 2017 at 11:01:52PM CEST, xiyou.wangcong@gmail.com wrote:
>>>On Tue, May 16, 2017 at 10:27 AM, Jiri Pirko <jiri@resnulli.us> wrote:
>>>> From: Jiri Pirko <jiri@mellanox.com>
>>>>
>>>> Call the helper from the function rather than to always adjust the
>>>> return value of the function.
>>>
>>>And rename the function name to reflect this change?
>>
>> ? What do you suggest?
>
>tcf_auto_major_prio()?

That makes no sense. prio is passed from user in upper 2 bytes (god
knows why but that is how it is). The helper returns prio, that's it.
Nothing major about it...
Jamal Hadi Salim May 17, 2017, 12:47 p.m. UTC | #5
On 17-05-17 01:47 AM, Jiri Pirko wrote:
> Wed, May 17, 2017 at 12:38:08AM CEST, xiyou.wangcong@gmail.com wrote:

[..]
>>
>> tcf_auto_major_prio()?
>
> That makes no sense. prio is passed from user in upper 2 bytes (god
> knows why but that is how it is).

I am not sure it is any god's decision ;-> Unless you think the creator
of this semantic is a god which in some circles is blasphemy ;->

16 bits for prio: 16 bits for proto - what is the problem?

cheers,
jamal
Jiri Pirko May 17, 2017, 12:53 p.m. UTC | #6
Wed, May 17, 2017 at 02:47:47PM CEST, jhs@mojatatu.com wrote:
>On 17-05-17 01:47 AM, Jiri Pirko wrote:
>> Wed, May 17, 2017 at 12:38:08AM CEST, xiyou.wangcong@gmail.com wrote:
>
>[..]
>> > 
>> > tcf_auto_major_prio()?
>> 
>> That makes no sense. prio is passed from user in upper 2 bytes (god
>> knows why but that is how it is).
>
>I am not sure it is any god's decision ;-> Unless you think the creator
>of this semantic is a god which in some circles is blasphemy ;->
>
>16 bits for prio: 16 bits for proto - what is the problem?

Should have been a struct, at least. But as you know, I always prefer
a Netlink attr :)
diff mbox

Patch

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 0e49e6e..72624fa 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -125,7 +125,7 @@  static inline u32 tcf_auto_prio(struct tcf_proto *tp)
 	if (tp)
 		first = tp->prio - 1;
 
-	return first;
+	return TC_H_MAJ(first);
 }
 
 static struct tcf_proto *tcf_proto_create(const char *kind, u32 protocol,
@@ -405,7 +405,7 @@  static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
 		}
 
 		if (prio_allocate)
-			prio = TC_H_MAJ(tcf_auto_prio(rtnl_dereference(*back)));
+			prio = tcf_auto_prio(rtnl_dereference(*back));
 
 		tp = tcf_proto_create(nla_data(tca[TCA_KIND]),
 				      protocol, prio, parent, q, block);