Port isolation takes after REDIR judgment, but software delivers such frames. Either route such rules to the software, or reject offloading. Fixes: 8eb9e7520b17 ("net: dsa: yt921x: Add ACL support") Signed-off-by: David Yang --- drivers/net/dsa/motorcomm/tc.c | 33 +++++++++++++++++++++++++++++++-- drivers/net/dsa/motorcomm/tc.h | 6 +++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/motorcomm/tc.c b/drivers/net/dsa/motorcomm/tc.c index e3f057ed580f..b7fe867da088 100644 --- a/drivers/net/dsa/motorcomm/tc.c +++ b/drivers/net/dsa/motorcomm/tc.c @@ -1030,6 +1030,7 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext, const struct flow_rule *rule = flow_cls_offload_flow_rule(cls); const struct flow_action *flow_action = &rule->action; struct netlink_ext_ack *extack = cls->common.extack; + struct yt921x_port *pp = &priv->ports[port]; const struct flow_action_entry *act; u32 *action = ruleext->r.action; bool seen_priority = false; @@ -1041,6 +1042,8 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext, int res; memset(action, 0, 3 * sizeof(*action)); + ruleext->r.sw_assisting = false; + flow_action_for_each(i, act, flow_action) { /* The flow action entry carries no mirred control, so there * is no way to tell whether software would continue past a @@ -1072,6 +1075,20 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext, goto fallback; } + /* Port isolation takes after REDIR judgment, but + * software delivers such frames. + */ + if (pp->isolation_mask & BIT(to_dp->index)) { + if (cls->common.skip_sw) { + if (to_dp->index == port) + reason = "Redirect to self, which is not hairpinning"; + else + reason = "Redirect target isolated, or not in the same bridge"; + goto fallback; + } + ruleext->r.sw_assisting = true; + } + action[2] |= YT921X_ACL_ACTc_FWD_EN | YT921X_ACL_ACTc_FWD_REDIR | YT921X_ACL_ACTc_FWD_REDIR_DPORTn(to_dp->index); @@ -1301,8 +1318,19 @@ yt921x_acl_commit(struct yt921x_priv *priv, unsigned int entid, u8 entsmask) aclrule = aclblk->rules[binid]; /* Write actions */ - res = yt921x_reg96_write(priv, YT921X_ACLn_ACT(entid), - aclrule ? aclrule->action : zeros); + if (!aclrule || !aclrule->sw_assisting) { + res = yt921x_reg96_write(priv, YT921X_ACLn_ACT(entid), + aclrule ? aclrule->action : zeros); + } else { + u32 action[3]; + + memcpy(action, aclrule->action, sizeof(action)); + action[2] &= ~YT921X_ACL_ACTc_FWD_REDIR_DPORTS_M & + ~YT921X_ACL_ACTc_FWD_M; + action[2] |= YT921X_ACL_ACTc_FWD_EN | YT921X_ACL_ACTc_FWD_TRAP; + + res = yt921x_reg96_write(priv, YT921X_ACLn_ACT(entid), action); + } if (res) return res; @@ -1502,6 +1530,7 @@ yt921x_acl_add(struct yt921x_priv *priv, ~YT921X_ACL_ACTc_FWD_M; aclrule->action[2] |= YT921X_ACL_ACTc_FWD_EN | YT921X_ACL_ACTc_FWD_TRAP; + aclrule->sw_assisting = false; } if (meterid < YT921X_METER_NUM) aclrule->action[0] |= YT921X_ACL_ACTa_METER_ID(meterid); diff --git a/drivers/net/dsa/motorcomm/tc.h b/drivers/net/dsa/motorcomm/tc.h index cc53f148d690..81c29a8eec5a 100644 --- a/drivers/net/dsa/motorcomm/tc.h +++ b/drivers/net/dsa/motorcomm/tc.h @@ -349,7 +349,11 @@ struct yt921x_acl_rule { enum tc_setup_type type; u32 action[3]; - bool sw_assisted; + bool sw_assisted:1; + /* not a TRAP rule, but installed as trapped as some conditions are not + * met + */ + bool sw_assisting:1; u8 mask; struct yt921x_acl_entry entries[YT921X_ACL_ENT_PER_BLK]; -- 2.53.0