Commit 8d2847d9 authored by Maxime Chevallier's avatar Maxime Chevallier Committed by David S. Miller

net: mvpp2: cls: Invalidate all C2 entries except the ones we use

C2 TCAM entries can be invalidated to avoid unwanted matches. Make sure
all entries are invalidated at init, then validate only the ones we use.
Signed-off-by: default avatarMaxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ff2f3cb6
...@@ -126,6 +126,8 @@ ...@@ -126,6 +126,8 @@
#define MVPP22_CLS_C2_TCAM_DATA4 0x1b20 #define MVPP22_CLS_C2_TCAM_DATA4 0x1b20
#define MVPP22_CLS_C2_LU_TYPE(lu) ((lu) & 0x3f) #define MVPP22_CLS_C2_LU_TYPE(lu) ((lu) & 0x3f)
#define MVPP22_CLS_C2_PORT_ID(port) ((port) << 8) #define MVPP22_CLS_C2_PORT_ID(port) ((port) << 8)
#define MVPP22_CLS_C2_TCAM_INV 0x1b24
#define MVPP22_CLS_C2_TCAM_INV_BIT BIT(31)
#define MVPP22_CLS_C2_HIT_CTR 0x1b50 #define MVPP22_CLS_C2_HIT_CTR 0x1b50
#define MVPP22_CLS_C2_ACT 0x1b60 #define MVPP22_CLS_C2_ACT 0x1b60
#define MVPP22_CLS_C2_ACT_RSS_EN(act) (((act) & 0x3) << 19) #define MVPP22_CLS_C2_ACT_RSS_EN(act) (((act) & 0x3) << 19)
......
...@@ -489,8 +489,16 @@ static void mvpp2_cls_flow_lkp_init(struct mvpp2 *priv, ...@@ -489,8 +489,16 @@ static void mvpp2_cls_flow_lkp_init(struct mvpp2 *priv,
static void mvpp2_cls_c2_write(struct mvpp2 *priv, static void mvpp2_cls_c2_write(struct mvpp2 *priv,
struct mvpp2_cls_c2_entry *c2) struct mvpp2_cls_c2_entry *c2)
{ {
u32 val;
mvpp2_write(priv, MVPP22_CLS_C2_TCAM_IDX, c2->index); mvpp2_write(priv, MVPP22_CLS_C2_TCAM_IDX, c2->index);
val = mvpp2_read(priv, MVPP22_CLS_C2_TCAM_INV);
if (c2->valid)
val &= ~MVPP22_CLS_C2_TCAM_INV_BIT;
else
val |= MVPP22_CLS_C2_TCAM_INV_BIT;
mvpp2_write(priv, MVPP22_CLS_C2_TCAM_INV, val);
mvpp2_write(priv, MVPP22_CLS_C2_ACT, c2->act); mvpp2_write(priv, MVPP22_CLS_C2_ACT, c2->act);
mvpp2_write(priv, MVPP22_CLS_C2_ATTR0, c2->attr[0]); mvpp2_write(priv, MVPP22_CLS_C2_ATTR0, c2->attr[0]);
...@@ -509,6 +517,7 @@ static void mvpp2_cls_c2_write(struct mvpp2 *priv, ...@@ -509,6 +517,7 @@ static void mvpp2_cls_c2_write(struct mvpp2 *priv,
void mvpp2_cls_c2_read(struct mvpp2 *priv, int index, void mvpp2_cls_c2_read(struct mvpp2 *priv, int index,
struct mvpp2_cls_c2_entry *c2) struct mvpp2_cls_c2_entry *c2)
{ {
u32 val;
mvpp2_write(priv, MVPP22_CLS_C2_TCAM_IDX, index); mvpp2_write(priv, MVPP22_CLS_C2_TCAM_IDX, index);
c2->index = index; c2->index = index;
...@@ -525,6 +534,9 @@ void mvpp2_cls_c2_read(struct mvpp2 *priv, int index, ...@@ -525,6 +534,9 @@ void mvpp2_cls_c2_read(struct mvpp2 *priv, int index,
c2->attr[1] = mvpp2_read(priv, MVPP22_CLS_C2_ATTR1); c2->attr[1] = mvpp2_read(priv, MVPP22_CLS_C2_ATTR1);
c2->attr[2] = mvpp2_read(priv, MVPP22_CLS_C2_ATTR2); c2->attr[2] = mvpp2_read(priv, MVPP22_CLS_C2_ATTR2);
c2->attr[3] = mvpp2_read(priv, MVPP22_CLS_C2_ATTR3); c2->attr[3] = mvpp2_read(priv, MVPP22_CLS_C2_ATTR3);
val = mvpp2_read(priv, MVPP22_CLS_C2_TCAM_INV);
c2->valid = !(val & MVPP22_CLS_C2_TCAM_INV_BIT);
} }
/* Initialize the flow table entries for the given flow */ /* Initialize the flow table entries for the given flow */
...@@ -807,6 +819,8 @@ static void mvpp2_port_c2_cls_init(struct mvpp2_port *port) ...@@ -807,6 +819,8 @@ static void mvpp2_port_c2_cls_init(struct mvpp2_port *port)
c2.attr[0] = MVPP22_CLS_C2_ATTR0_QHIGH(qh) | c2.attr[0] = MVPP22_CLS_C2_ATTR0_QHIGH(qh) |
MVPP22_CLS_C2_ATTR0_QLOW(ql); MVPP22_CLS_C2_ATTR0_QLOW(ql);
c2.valid = true;
mvpp2_cls_c2_write(port->priv, &c2); mvpp2_cls_c2_write(port->priv, &c2);
} }
...@@ -815,6 +829,7 @@ void mvpp2_cls_init(struct mvpp2 *priv) ...@@ -815,6 +829,7 @@ void mvpp2_cls_init(struct mvpp2 *priv)
{ {
struct mvpp2_cls_lookup_entry le; struct mvpp2_cls_lookup_entry le;
struct mvpp2_cls_flow_entry fe; struct mvpp2_cls_flow_entry fe;
struct mvpp2_cls_c2_entry c2;
int index; int index;
/* Enable classifier */ /* Enable classifier */
...@@ -838,6 +853,14 @@ void mvpp2_cls_init(struct mvpp2 *priv) ...@@ -838,6 +853,14 @@ void mvpp2_cls_init(struct mvpp2 *priv)
mvpp2_cls_lookup_write(priv, &le); mvpp2_cls_lookup_write(priv, &le);
} }
/* Clear C2 TCAM engine table */
memset(&c2, 0, sizeof(c2));
c2.valid = false;
for (index = 0; index < MVPP22_CLS_C2_N_ENTRIES; index++) {
c2.index = index;
mvpp2_cls_c2_write(priv, &c2);
}
mvpp2_cls_port_init_flows(priv); mvpp2_cls_port_init_flows(priv);
} }
......
...@@ -97,9 +97,14 @@ enum mvpp22_cls_c2_fwd_action { ...@@ -97,9 +97,14 @@ enum mvpp22_cls_c2_fwd_action {
struct mvpp2_cls_c2_entry { struct mvpp2_cls_c2_entry {
u32 index; u32 index;
/* TCAM lookup key */
u32 tcam[MVPP2_CLS_C2_TCAM_WORDS]; u32 tcam[MVPP2_CLS_C2_TCAM_WORDS];
/* Actions to perform upon TCAM match */
u32 act; u32 act;
/* Attributes relative to the actions to perform */
u32 attr[MVPP2_CLS_C2_ATTR_WORDS]; u32 attr[MVPP2_CLS_C2_ATTR_WORDS];
/* Entry validity */
u8 valid;
}; };
/* Classifier C2 engine entries */ /* Classifier C2 engine entries */
......
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