Skip to content

Commit

Permalink
net: mscc: ocelot: only install TCAM entries into a specific lookup a…
Browse files Browse the repository at this point in the history
…nd PAG

We were installing TCAM rules with the LOOKUP field as unmasked, meaning
that all entries were matching on all lookups. Now that lookups are
exposed as individual chains, let's make the LOOKUP explicit when
offloading TCAM entries.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vladimir Oltean authored and David S. Miller committed Oct 2, 2020
1 parent 2f17c05 commit 226e9cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 6 additions & 4 deletions drivers/net/ethernet/mscc/ocelot_flower.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ static int ocelot_flower_parse_action(struct flow_cls_offload *f, bool ingress,
}
if (filter->block_id == VCAP_IS1 || filter->block_id == VCAP_IS2)
filter->lookup = ocelot_chain_to_lookup(chain);
if (filter->block_id == VCAP_IS2)
filter->pag = ocelot_chain_to_pag(chain);

filter->goto_target = -1;
filter->type = OCELOT_VCAP_FILTER_DUMMY;
Expand Down Expand Up @@ -205,9 +207,10 @@ static int ocelot_flower_parse_action(struct flow_cls_offload *f, bool ingress,
filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
break;
case FLOW_ACTION_POLICE:
if (filter->block_id != VCAP_IS2) {
if (filter->block_id != VCAP_IS2 ||
filter->lookup != 0) {
NL_SET_ERR_MSG_MOD(extack,
"Police action can only be offloaded to VCAP IS2");
"Police action can only be offloaded to VCAP IS2 lookup 0");
return -EOPNOTSUPP;
}
if (filter->goto_target != -1) {
Expand Down Expand Up @@ -259,8 +262,7 @@ static int ocelot_flower_parse_action(struct flow_cls_offload *f, bool ingress,
case FLOW_ACTION_GOTO:
filter->goto_target = a->chain_index;

if (filter->block_id == VCAP_IS1 &&
ocelot_chain_to_lookup(chain) == 2) {
if (filter->block_id == VCAP_IS1 && filter->lookup == 2) {
int pag = ocelot_chain_to_pag(filter->goto_target);

filter->action.pag_override_mask = 0xff;
Expand Down
6 changes: 5 additions & 1 deletion drivers/net/ethernet/mscc/ocelot_vcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,10 @@ static void is2_entry_set(struct ocelot *ocelot, int ix,

data.type = IS2_ACTION_TYPE_NORMAL;

vcap_key_set(vcap, &data, VCAP_IS2_HK_PAG, 0, 0);
vcap_key_set(vcap, &data, VCAP_IS2_HK_PAG, filter->pag, 0xff);
vcap_key_bit_set(vcap, &data, VCAP_IS2_HK_FIRST,
(filter->lookup == 0) ? OCELOT_VCAP_BIT_1 :
OCELOT_VCAP_BIT_0);
vcap_key_set(vcap, &data, VCAP_IS2_HK_IGR_PORT_MASK, 0,
~filter->ingress_port_mask);
vcap_key_bit_set(vcap, &data, VCAP_IS2_HK_FIRST, OCELOT_VCAP_BIT_ANY);
Expand Down Expand Up @@ -688,6 +691,7 @@ static void is1_entry_set(struct ocelot *ocelot, int ix,
if (filter->prio != 0)
data.tg |= data.tg_value;

vcap_key_set(vcap, &data, VCAP_IS1_HK_LOOKUP, filter->lookup, 0x3);
vcap_key_set(vcap, &data, VCAP_IS1_HK_IGR_PORT_MASK, 0,
~filter->ingress_port_mask);
vcap_key_bit_set(vcap, &data, VCAP_IS1_HK_L2_MC, filter->dmac_mc);
Expand Down

0 comments on commit 226e9cd

Please sign in to comment.