Skip to content

Commit a16fa28

Browse files
jpirkodavem330
authored andcommitted
flow_offload: restrict driver to pass one allowed bit to flow_action_hw_stats_types_check()
The intention of this helper was to allow driver to specify one type that it supports, so not only "any" value would pass. So make the API more strict and allow driver to pass only 1 bit that is going to be checked. Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 42d5fe5 commit a16fa28

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,7 +2879,7 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv,
28792879
return -EINVAL;
28802880

28812881
if (!flow_action_hw_stats_types_check(flow_action, extack,
2882-
FLOW_ACTION_HW_STATS_TYPE_DELAYED))
2882+
FLOW_ACTION_HW_STATS_TYPE_DELAYED_BIT))
28832883
return -EOPNOTSUPP;
28842884

28852885
attr->flow_tag = MLX5_FS_DEFAULT_FLOW_TAG;
@@ -3374,7 +3374,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
33743374
return -EINVAL;
33753375

33763376
if (!flow_action_hw_stats_types_check(flow_action, extack,
3377-
FLOW_ACTION_HW_STATS_TYPE_DELAYED))
3377+
FLOW_ACTION_HW_STATS_TYPE_DELAYED_BIT))
33783378
return -EOPNOTSUPP;
33793379

33803380
flow_action_for_each(i, act, flow_action) {

include/net/flow_offload.h

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,10 @@ flow_action_first_entry_get(const struct flow_action *action)
300300
}
301301

302302
static inline bool
303-
flow_action_hw_stats_types_check(const struct flow_action *action,
304-
struct netlink_ext_ack *extack,
305-
u8 allowed_hw_stats_type)
303+
__flow_action_hw_stats_types_check(const struct flow_action *action,
304+
struct netlink_ext_ack *extack,
305+
bool check_allow_bit,
306+
enum flow_action_hw_stats_type_bit allow_bit)
306307
{
307308
const struct flow_action_entry *action_entry;
308309

@@ -311,23 +312,32 @@ flow_action_hw_stats_types_check(const struct flow_action *action,
311312
if (!flow_action_mixed_hw_stats_types_check(action, extack))
312313
return false;
313314
action_entry = flow_action_first_entry_get(action);
314-
if (allowed_hw_stats_type == 0 &&
315+
if (!check_allow_bit &&
315316
action_entry->hw_stats_type != FLOW_ACTION_HW_STATS_TYPE_ANY) {
316317
NL_SET_ERR_MSG_MOD(extack, "Driver supports only default HW stats type \"any\"");
317318
return false;
318-
} else if (allowed_hw_stats_type != 0 &&
319-
!(action_entry->hw_stats_type & allowed_hw_stats_type)) {
319+
} else if (check_allow_bit &&
320+
!(action_entry->hw_stats_type & BIT(allow_bit))) {
320321
NL_SET_ERR_MSG_MOD(extack, "Driver does not support selected HW stats type");
321322
return false;
322323
}
323324
return true;
324325
}
325326

327+
static inline bool
328+
flow_action_hw_stats_types_check(const struct flow_action *action,
329+
struct netlink_ext_ack *extack,
330+
enum flow_action_hw_stats_type_bit allow_bit)
331+
{
332+
return __flow_action_hw_stats_types_check(action, extack,
333+
true, allow_bit);
334+
}
335+
326336
static inline bool
327337
flow_action_basic_hw_stats_types_check(const struct flow_action *action,
328338
struct netlink_ext_ack *extack)
329339
{
330-
return flow_action_hw_stats_types_check(action, extack, 0);
340+
return __flow_action_hw_stats_types_check(action, extack, false, 0);
331341
}
332342

333343
struct flow_rule {

0 commit comments

Comments
 (0)