All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch net-next] flow_offload: use flow_action_for_each in flow_action_mixed_hw_stats_types_check()
@ 2020-03-09 17:44 Jiri Pirko
  2020-03-09 18:07 ` Edward Cree
  2020-03-09 18:33 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 4+ messages in thread
From: Jiri Pirko @ 2020-03-09 17:44 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, pablo, ecree, mlxsw

Instead of manually iterating over entries, use flow_action_for_each
helper. Move the helper and wrap it to fit to 80 cols on the way.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 include/net/flow_offload.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 64807aa03cee..7b7bd9215156 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -256,6 +256,11 @@ static inline bool flow_offload_has_one_action(const struct flow_action *action)
 	return action->num_entries == 1;
 }
 
+#define flow_action_for_each(__i, __act, __actions)			\
+        for (__i = 0, __act = &(__actions)->entries[0];			\
+	     __i < (__actions)->num_entries;				\
+	     __act = &(__actions)->entries[++__i])
+
 static inline bool
 flow_action_mixed_hw_stats_types_check(const struct flow_action *action,
 				       struct netlink_ext_ack *extack)
@@ -267,7 +272,7 @@ flow_action_mixed_hw_stats_types_check(const struct flow_action *action,
 	if (flow_offload_has_one_action(action))
 		return true;
 
-	for (i = 0; i < action->num_entries; i++) {
+	flow_action_for_each(i, action_entry, action) {
 		action_entry = &action->entries[i];
 		if (i && action_entry->hw_stats_type != last_hw_stats_type) {
 			NL_SET_ERR_MSG_MOD(extack, "Mixing HW stats types for actions is not supported");
@@ -316,9 +321,6 @@ flow_action_basic_hw_stats_types_check(const struct flow_action *action,
 	return flow_action_hw_stats_types_check(action, extack, 0);
 }
 
-#define flow_action_for_each(__i, __act, __actions)			\
-        for (__i = 0, __act = &(__actions)->entries[0]; __i < (__actions)->num_entries; __act = &(__actions)->entries[++__i])
-
 struct flow_rule {
 	struct flow_match	match;
 	struct flow_action	action;
-- 
2.21.1


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

* Re: [patch net-next] flow_offload: use flow_action_for_each in flow_action_mixed_hw_stats_types_check()
  2020-03-09 17:44 [patch net-next] flow_offload: use flow_action_for_each in flow_action_mixed_hw_stats_types_check() Jiri Pirko
@ 2020-03-09 18:07 ` Edward Cree
  2020-03-09 18:33 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 4+ messages in thread
From: Edward Cree @ 2020-03-09 18:07 UTC (permalink / raw)
  To: Jiri Pirko, netdev; +Cc: davem, kuba, pablo, mlxsw

On 09/03/2020 17:44, Jiri Pirko wrote:
> Instead of manually iterating over entries, use flow_action_for_each
> helper. Move the helper and wrap it to fit to 80 cols on the way.
>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Edward Cree <ecree@solarflare.com>

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

* Re: [patch net-next] flow_offload: use flow_action_for_each in flow_action_mixed_hw_stats_types_check()
  2020-03-09 17:44 [patch net-next] flow_offload: use flow_action_for_each in flow_action_mixed_hw_stats_types_check() Jiri Pirko
  2020-03-09 18:07 ` Edward Cree
@ 2020-03-09 18:33 ` Pablo Neira Ayuso
  2020-03-10 10:03   ` Jiri Pirko
  1 sibling, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2020-03-09 18:33 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, kuba, ecree, mlxsw

On Mon, Mar 09, 2020 at 06:44:47PM +0100, Jiri Pirko wrote:
> Instead of manually iterating over entries, use flow_action_for_each
> helper. Move the helper and wrap it to fit to 80 cols on the way.
> 
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>  include/net/flow_offload.h | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
> index 64807aa03cee..7b7bd9215156 100644
> --- a/include/net/flow_offload.h
> +++ b/include/net/flow_offload.h
> @@ -256,6 +256,11 @@ static inline bool flow_offload_has_one_action(const struct flow_action *action)
>  	return action->num_entries == 1;
>  }
>  
> +#define flow_action_for_each(__i, __act, __actions)			\
> +        for (__i = 0, __act = &(__actions)->entries[0];			\
> +	     __i < (__actions)->num_entries;				\
> +	     __act = &(__actions)->entries[++__i])
> +
>  static inline bool
>  flow_action_mixed_hw_stats_types_check(const struct flow_action *action,
>  				       struct netlink_ext_ack *extack)
> @@ -267,7 +272,7 @@ flow_action_mixed_hw_stats_types_check(const struct flow_action *action,
>  	if (flow_offload_has_one_action(action))
>  		return true;
>  
> -	for (i = 0; i < action->num_entries; i++) {
> +	flow_action_for_each(i, action_entry, action) {
>  		action_entry = &action->entries[i];
                ^^^

action_entry is set twice, right? One from flow_action_for_each() and
again here. You can probably remove this line too.

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

* Re: [patch net-next] flow_offload: use flow_action_for_each in flow_action_mixed_hw_stats_types_check()
  2020-03-09 18:33 ` Pablo Neira Ayuso
@ 2020-03-10 10:03   ` Jiri Pirko
  0 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2020-03-10 10:03 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netdev, davem, kuba, ecree, mlxsw

Mon, Mar 09, 2020 at 07:33:25PM CET, pablo@netfilter.org wrote:
>On Mon, Mar 09, 2020 at 06:44:47PM +0100, Jiri Pirko wrote:
>> Instead of manually iterating over entries, use flow_action_for_each
>> helper. Move the helper and wrap it to fit to 80 cols on the way.
>> 
>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>> ---
>>  include/net/flow_offload.h | 10 ++++++----
>>  1 file changed, 6 insertions(+), 4 deletions(-)
>> 
>> diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
>> index 64807aa03cee..7b7bd9215156 100644
>> --- a/include/net/flow_offload.h
>> +++ b/include/net/flow_offload.h
>> @@ -256,6 +256,11 @@ static inline bool flow_offload_has_one_action(const struct flow_action *action)
>>  	return action->num_entries == 1;
>>  }
>>  
>> +#define flow_action_for_each(__i, __act, __actions)			\
>> +        for (__i = 0, __act = &(__actions)->entries[0];			\
>> +	     __i < (__actions)->num_entries;				\
>> +	     __act = &(__actions)->entries[++__i])
>> +
>>  static inline bool
>>  flow_action_mixed_hw_stats_types_check(const struct flow_action *action,
>>  				       struct netlink_ext_ack *extack)
>> @@ -267,7 +272,7 @@ flow_action_mixed_hw_stats_types_check(const struct flow_action *action,
>>  	if (flow_offload_has_one_action(action))
>>  		return true;
>>  
>> -	for (i = 0; i < action->num_entries; i++) {
>> +	flow_action_for_each(i, action_entry, action) {
>>  		action_entry = &action->entries[i];
>                ^^^
>
>action_entry is set twice, right? One from flow_action_for_each() and
>again here. You can probably remove this line too.

Correct. Will send v2


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

end of thread, other threads:[~2020-03-10 10:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-09 17:44 [patch net-next] flow_offload: use flow_action_for_each in flow_action_mixed_hw_stats_types_check() Jiri Pirko
2020-03-09 18:07 ` Edward Cree
2020-03-09 18:33 ` Pablo Neira Ayuso
2020-03-10 10:03   ` Jiri Pirko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.