[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200310101334.GB2211@nanopsycho>
Date: Tue, 10 Mar 2020 11:13:34 +0100
From: Jiri Pirko <jiri@...nulli.us>
To: Jakub Kicinski <kuba@...nel.org>
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
Mon, Mar 09, 2020 at 08:17:22PM CET, kuba@...nel.org wrote:
>On Sat, 7 Mar 2020 07:59:48 +0100 Jiri Pirko wrote:
>> >> +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?
>>
>> No. I driver passes allowed_hw_stats_type != 0, means that allowed_hw_stats_type
>> should be checked against action_entry->hw_stats_type.
>
>Right, the "allowed_hw_stats_type &&" is fine.
>
>> With bitfield, this is a bit awkward, I didn't figure out to do it
>> better though.
>
>The bitfield passed from user space means any of the set bits, right?
>
>Condition would be better as:
>
>allowed_hw_stats_type && (allowed_hw_stats_type & entry->hw_stats_type)
>
>Otherwise passing more than one bit will not work well, no?
>
>Driver can pass IMMEDIATE | DELAYED, action has IMMEDIATE, your
Yeah, this is something that made more sense for non-bitfield. Basically
this is for simple driver which supports only one type. If the driver
supports more types (like mlxsw), it should not call this function.
>condition would reject it.. Same if driver has only one type and user
>space asks for any of a few.
>
>Drivers can't do a straight comparisons either, but:
>
>if (act->stats & TYPE1) {
> /* preferred stats type*/
>} else if (act->stats & TYPE2) {
> /* also supported, lower prio */
>} else if (act->Stats & TYPE3) {
> /* lowest prio */
>}
Powered by blists - more mailing lists