Commit 29e59fd4 authored by Yangbo Lu's avatar Yangbo Lu Committed by David S. Miller

net: mscc: ocelot: make ocelot_ace_rule support multiple ports

The ocelot_ace_rule is port specific now. Make it flexible to
be able to support multiple ports too.
Signed-off-by: default avatarYangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: default avatarAllan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d6584892
...@@ -352,7 +352,7 @@ static void is2_entry_set(struct ocelot *ocelot, int ix, ...@@ -352,7 +352,7 @@ static void is2_entry_set(struct ocelot *ocelot, int ix,
data.type = IS2_ACTION_TYPE_NORMAL; data.type = IS2_ACTION_TYPE_NORMAL;
VCAP_KEY_ANY_SET(PAG); VCAP_KEY_ANY_SET(PAG);
VCAP_KEY_SET(IGR_PORT_MASK, 0, ~BIT(ace->chip_port)); VCAP_KEY_SET(IGR_PORT_MASK, 0, ~ace->ingress_port_mask);
VCAP_KEY_BIT_SET(FIRST, OCELOT_VCAP_BIT_1); VCAP_KEY_BIT_SET(FIRST, OCELOT_VCAP_BIT_1);
VCAP_KEY_BIT_SET(HOST_MATCH, OCELOT_VCAP_BIT_ANY); VCAP_KEY_BIT_SET(HOST_MATCH, OCELOT_VCAP_BIT_ANY);
VCAP_KEY_BIT_SET(L2_MC, ace->dmac_mc); VCAP_KEY_BIT_SET(L2_MC, ace->dmac_mc);
...@@ -576,7 +576,7 @@ static void is2_entry_set(struct ocelot *ocelot, int ix, ...@@ -576,7 +576,7 @@ static void is2_entry_set(struct ocelot *ocelot, int ix,
static void is2_entry_get(struct ocelot_ace_rule *rule, int ix) static void is2_entry_get(struct ocelot_ace_rule *rule, int ix)
{ {
struct ocelot *op = rule->port->ocelot; struct ocelot *op = rule->ocelot;
struct vcap_data data; struct vcap_data data;
int row = (ix / 2); int row = (ix / 2);
u32 cnt; u32 cnt;
...@@ -655,11 +655,11 @@ int ocelot_ace_rule_offload_add(struct ocelot_ace_rule *rule) ...@@ -655,11 +655,11 @@ int ocelot_ace_rule_offload_add(struct ocelot_ace_rule *rule)
/* Move down the rules to make place for the new rule */ /* Move down the rules to make place for the new rule */
for (i = acl_block->count - 1; i > index; i--) { for (i = acl_block->count - 1; i > index; i--) {
ace = ocelot_ace_rule_get_rule_index(acl_block, i); ace = ocelot_ace_rule_get_rule_index(acl_block, i);
is2_entry_set(rule->port->ocelot, i, ace); is2_entry_set(rule->ocelot, i, ace);
} }
/* Now insert the new rule */ /* Now insert the new rule */
is2_entry_set(rule->port->ocelot, index, rule); is2_entry_set(rule->ocelot, index, rule);
return 0; return 0;
} }
...@@ -697,11 +697,11 @@ int ocelot_ace_rule_offload_del(struct ocelot_ace_rule *rule) ...@@ -697,11 +697,11 @@ int ocelot_ace_rule_offload_del(struct ocelot_ace_rule *rule)
/* Move up all the blocks over the deleted rule */ /* Move up all the blocks over the deleted rule */
for (i = index; i < acl_block->count; i++) { for (i = index; i < acl_block->count; i++) {
ace = ocelot_ace_rule_get_rule_index(acl_block, i); ace = ocelot_ace_rule_get_rule_index(acl_block, i);
is2_entry_set(rule->port->ocelot, i, ace); is2_entry_set(rule->ocelot, i, ace);
} }
/* Now delete the last rule, because it is duplicated */ /* Now delete the last rule, because it is duplicated */
is2_entry_set(rule->port->ocelot, acl_block->count, &del_ace); is2_entry_set(rule->ocelot, acl_block->count, &del_ace);
return 0; return 0;
} }
...@@ -717,7 +717,7 @@ int ocelot_ace_rule_stats_update(struct ocelot_ace_rule *rule) ...@@ -717,7 +717,7 @@ int ocelot_ace_rule_stats_update(struct ocelot_ace_rule *rule)
/* After we get the result we need to clear the counters */ /* After we get the result we need to clear the counters */
tmp = ocelot_ace_rule_get_rule_index(acl_block, index); tmp = ocelot_ace_rule_get_rule_index(acl_block, index);
tmp->stats.pkts = 0; tmp->stats.pkts = 0;
is2_entry_set(rule->port->ocelot, index, tmp); is2_entry_set(rule->ocelot, index, tmp);
return 0; return 0;
} }
......
...@@ -186,14 +186,14 @@ struct ocelot_ace_stats { ...@@ -186,14 +186,14 @@ struct ocelot_ace_stats {
struct ocelot_ace_rule { struct ocelot_ace_rule {
struct list_head list; struct list_head list;
struct ocelot_port *port; struct ocelot *ocelot;
u16 prio; u16 prio;
u32 id; u32 id;
enum ocelot_ace_action action; enum ocelot_ace_action action;
struct ocelot_ace_stats stats; struct ocelot_ace_stats stats;
int chip_port; u16 ingress_port_mask;
enum ocelot_vcap_bit dmac_mc; enum ocelot_vcap_bit dmac_mc;
enum ocelot_vcap_bit dmac_bc; enum ocelot_vcap_bit dmac_bc;
......
...@@ -177,8 +177,8 @@ struct ocelot_ace_rule *ocelot_ace_rule_create(struct flow_cls_offload *f, ...@@ -177,8 +177,8 @@ struct ocelot_ace_rule *ocelot_ace_rule_create(struct flow_cls_offload *f,
if (!rule) if (!rule)
return NULL; return NULL;
rule->port = &block->priv->port; rule->ocelot = block->priv->port.ocelot;
rule->chip_port = block->priv->chip_port; rule->ingress_port_mask = BIT(block->priv->chip_port);
return rule; return rule;
} }
...@@ -213,7 +213,7 @@ static int ocelot_flower_destroy(struct flow_cls_offload *f, ...@@ -213,7 +213,7 @@ static int ocelot_flower_destroy(struct flow_cls_offload *f,
int ret; int ret;
rule.prio = f->common.prio; rule.prio = f->common.prio;
rule.port = &port_block->priv->port; rule.ocelot = port_block->priv->port.ocelot;
rule.id = f->cookie; rule.id = f->cookie;
ret = ocelot_ace_rule_offload_del(&rule); ret = ocelot_ace_rule_offload_del(&rule);
...@@ -231,7 +231,7 @@ static int ocelot_flower_stats_update(struct flow_cls_offload *f, ...@@ -231,7 +231,7 @@ static int ocelot_flower_stats_update(struct flow_cls_offload *f,
int ret; int ret;
rule.prio = f->common.prio; rule.prio = f->common.prio;
rule.port = &port_block->priv->port; rule.ocelot = port_block->priv->port.ocelot;
rule.id = f->cookie; rule.id = f->cookie;
ret = ocelot_ace_rule_stats_update(&rule); ret = ocelot_ace_rule_stats_update(&rule);
if (ret) if (ret)
......
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