[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200306112851.2dc630e7@kicinski-fedora-PC1C0HJN>
Date: Fri, 6 Mar 2020 11:28:51 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Jiri Pirko <jiri@...nulli.us>
Cc: netdev@...r.kernel.org, davem@...emloft.net, saeedm@...lanox.com,
leon@...nel.org, michael.chan@...adcom.com, vishal@...lsio.com,
jeffrey.t.kirsher@...el.com, idosch@...lanox.com,
aelior@...vell.com, peppe.cavallaro@...com,
alexandre.torgue@...com, jhs@...atatu.com,
xiyou.wangcong@...il.com, pablo@...filter.org,
ecree@...arflare.com, mlxsw@...lanox.com
Subject: Re: [patch net-next v3 03/10] flow_offload: check for basic action
hw stats type
On Fri, 6 Mar 2020 14:28:49 +0100 Jiri Pirko wrote:
> @@ -251,6 +252,66 @@ static inline bool flow_offload_has_one_action(const struct flow_action *action)
> return action->num_entries == 1;
> }
>
> +static inline bool
> +flow_action_mixed_hw_stats_types_check(const struct flow_action *action,
> + struct netlink_ext_ack *extack)
> +{
> + const struct flow_action_entry *action_entry;
> + u8 uninitialized_var(last_hw_stats_type);
Perhaps just initialize before the loop to action 0 and start loop
from 1?
> + int i;
> +
> + if (flow_offload_has_one_action(action))
> + return true;
> +
> + for (i = 0; i < action->num_entries; i++) {
> + action_entry = &action->entries[0];
s/0/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");
> + return false;
> + }
> + last_hw_stats_type = action_entry->hw_stats_type;
> + }
> + return true;
> +}
> +
> +static inline const struct flow_action_entry *
> +flow_action_first_entry_get(const struct flow_action *action)
> +{
> + WARN_ON(!flow_action_has_entries(action));
> + return &action->entries[0];
> +}
> +
> +static inline bool
> +flow_action_hw_stats_types_check(const struct flow_action *action,
> + struct netlink_ext_ack *extack,
> + u8 allowed_hw_stats_type)
> +{
> + const struct flow_action_entry *action_entry;
> +
> + if (!flow_action_has_entries(action))
> + return true;
> + if (!flow_action_mixed_hw_stats_types_check(action, extack))
> + return false;
> + action_entry = flow_action_first_entry_get(action);
> + if (!allowed_hw_stats_type &&
> + action_entry->hw_stats_type != FLOW_ACTION_HW_STATS_TYPE_ANY) {
> + NL_SET_ERR_MSG_MOD(extack, "Driver supports only default HW stats type \"any\"");
> + return false;
> + } else if (allowed_hw_stats_type &&
> + action_entry->hw_stats_type != allowed_hw_stats_type) {
Should this be an logical 'and' if we're doing it the bitfield way?
> + NL_SET_ERR_MSG_MOD(extack, "Driver does not support selected HW stats type");
> + return false;
> + }
> + return true;
> +}
Powered by blists - more mailing lists