Commit e8bd7025 authored by Volodymyr Mytnyk's avatar Volodymyr Mytnyk Committed by Jakub Kicinski

prestera: acl: add action hw_stats support

Currently, when user adds a tc action and the action gets offloaded,
the user expects the HW stats to be counted also. This limits the
amount of supported offloaded filters, as HW counter resources may
be quite limited. Without counter assigned, the HW is capable to
carry much more filters.

To resolve the issue above, the following types of HW stats are
offloaded and supported by the driver:

any       - current default, user does not care about the type.
delayed   - polled from HW periodically.
disabled  - no HW stats needed.
immediate - not supported.

Example:
  tc filter add dev PORT ingress proto ip flower skip_sw ip_proto 0x11 \
    action drop
  tc filter add dev PORT ingress proto ip flower skip_sw ip_proto 0x12 \
    action drop hw_stats disabled
  tc filter add dev sw1p1 ingress proto ip flower skip_sw ip_proto 0x14 \
    action drop hw_stats delayed
Signed-off-by: default avatarVolodymyr Mytnyk <vmytnyk@marvell.com>
Link: https://lore.kernel.org/r/1649164814-18731-1-git-send-email-volodymyr.mytnyk@plvision.euSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 51454ea4
...@@ -421,13 +421,6 @@ int prestera_acl_rule_add(struct prestera_switch *sw, ...@@ -421,13 +421,6 @@ int prestera_acl_rule_add(struct prestera_switch *sw,
rule->re_arg.vtcam_id = ruleset->vtcam_id; rule->re_arg.vtcam_id = ruleset->vtcam_id;
rule->re_key.prio = rule->priority; rule->re_key.prio = rule->priority;
/* setup counter */
rule->re_arg.count.valid = true;
err = prestera_acl_chain_to_client(ruleset->ht_key.chain_index,
&rule->re_arg.count.client);
if (err)
goto err_rule_add;
rule->re = prestera_acl_rule_entry_find(sw->acl, &rule->re_key); rule->re = prestera_acl_rule_entry_find(sw->acl, &rule->re_key);
err = WARN_ON(rule->re) ? -EEXIST : 0; err = WARN_ON(rule->re) ? -EEXIST : 0;
if (err) if (err)
......
...@@ -70,6 +70,24 @@ static int prestera_flower_parse_actions(struct prestera_flow_block *block, ...@@ -70,6 +70,24 @@ static int prestera_flower_parse_actions(struct prestera_flow_block *block,
if (!flow_action_has_entries(flow_action)) if (!flow_action_has_entries(flow_action))
return 0; return 0;
if (!flow_action_mixed_hw_stats_check(flow_action, extack))
return -EOPNOTSUPP;
act = flow_action_first_entry_get(flow_action);
if (act->hw_stats & FLOW_ACTION_HW_STATS_DISABLED) {
/* Nothing to do */
} else if (act->hw_stats & FLOW_ACTION_HW_STATS_DELAYED) {
/* setup counter first */
rule->re_arg.count.valid = true;
err = prestera_acl_chain_to_client(chain_index,
&rule->re_arg.count.client);
if (err)
return err;
} else {
NL_SET_ERR_MSG_MOD(extack, "Unsupported action HW stats type");
return -EOPNOTSUPP;
}
flow_action_for_each(i, act, flow_action) { flow_action_for_each(i, act, flow_action) {
switch (act->id) { switch (act->id) {
case FLOW_ACTION_ACCEPT: case FLOW_ACTION_ACCEPT:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment