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

net: mvpp2: cls: Allow dropping packets with classification offload

This commit introduces support for the "Drop" action in classification
offload. This corresponds to the "-1" action with ethtool -N.

This is achieved using the color marking actions available in the C2
engine, which associate a color to a packet. These colors can be either
Green, Yellow or Red, Red meaning that the packet should be dropped.

Green and Yellow colors are interpreted by the Policer, which isn't
supported yet.

This method of dropping using the Classifier is different than the
already existing early-drop features, such as VLAN filtering and MAC
UC/MC filtering, which are performed during the Parsing step, and
therefore take precedence over classification actions.
Signed-off-by: default avatarMaxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 90b509b3
...@@ -136,6 +136,7 @@ ...@@ -136,6 +136,7 @@
#define MVPP22_CLS_C2_ACT_FWD(act) (((act) & 0x7) << 13) #define MVPP22_CLS_C2_ACT_FWD(act) (((act) & 0x7) << 13)
#define MVPP22_CLS_C2_ACT_QHIGH(act) (((act) & 0x3) << 11) #define MVPP22_CLS_C2_ACT_QHIGH(act) (((act) & 0x3) << 11)
#define MVPP22_CLS_C2_ACT_QLOW(act) (((act) & 0x3) << 9) #define MVPP22_CLS_C2_ACT_QLOW(act) (((act) & 0x3) << 9)
#define MVPP22_CLS_C2_ACT_COLOR(act) ((act) & 0x7)
#define MVPP22_CLS_C2_ATTR0 0x1b64 #define MVPP22_CLS_C2_ATTR0 0x1b64
#define MVPP22_CLS_C2_ATTR0_QHIGH(qh) (((qh) & 0x1f) << 24) #define MVPP22_CLS_C2_ATTR0_QHIGH(qh) (((qh) & 0x1f) << 24)
#define MVPP22_CLS_C2_ATTR0_QHIGH_MASK 0x1f #define MVPP22_CLS_C2_ATTR0_QHIGH_MASK 0x1f
......
...@@ -1057,17 +1057,28 @@ static int mvpp2_port_c2_tcam_rule_add(struct mvpp2_port *port, ...@@ -1057,17 +1057,28 @@ static int mvpp2_port_c2_tcam_rule_add(struct mvpp2_port *port,
c2.tcam[4] |= MVPP22_CLS_C2_TCAM_EN(MVPP22_CLS_C2_LU_TYPE(MVPP2_CLS_LU_TYPE_MASK)); c2.tcam[4] |= MVPP22_CLS_C2_TCAM_EN(MVPP22_CLS_C2_LU_TYPE(MVPP2_CLS_LU_TYPE_MASK));
c2.tcam[4] |= MVPP22_CLS_C2_LU_TYPE(rule->loc); c2.tcam[4] |= MVPP22_CLS_C2_LU_TYPE(rule->loc);
/* Mark packet as "forwarded to software", needed for RSS */ if (act->id == FLOW_ACTION_DROP) {
c2.act |= MVPP22_CLS_C2_ACT_FWD(MVPP22_C2_FWD_SW_LOCK); c2.act = MVPP22_CLS_C2_ACT_COLOR(MVPP22_C2_COL_RED_LOCK);
} else {
/* We want to keep the default color derived from the Header
* Parser drop entries, for VLAN and MAC filtering. This will
* assign a default color of Green or Red, and we want matches
* with a non-drop action to keep that color.
*/
c2.act = MVPP22_CLS_C2_ACT_COLOR(MVPP22_C2_COL_NO_UPD_LOCK);
c2.act |= MVPP22_CLS_C2_ACT_QHIGH(MVPP22_C2_UPD_LOCK) | /* Mark packet as "forwarded to software", needed for RSS */
MVPP22_CLS_C2_ACT_QLOW(MVPP22_C2_UPD_LOCK); c2.act |= MVPP22_CLS_C2_ACT_FWD(MVPP22_C2_FWD_SW_LOCK);
qh = ((act->queue.index + port->first_rxq) >> 3) & MVPP22_CLS_C2_ATTR0_QHIGH_MASK; c2.act |= MVPP22_CLS_C2_ACT_QHIGH(MVPP22_C2_UPD_LOCK) |
ql = (act->queue.index + port->first_rxq) & MVPP22_CLS_C2_ATTR0_QLOW_MASK; MVPP22_CLS_C2_ACT_QLOW(MVPP22_C2_UPD_LOCK);
c2.attr[0] = MVPP22_CLS_C2_ATTR0_QHIGH(qh) | qh = ((act->queue.index + port->first_rxq) >> 3) & MVPP22_CLS_C2_ATTR0_QHIGH_MASK;
MVPP22_CLS_C2_ATTR0_QLOW(ql); ql = (act->queue.index + port->first_rxq) & MVPP22_CLS_C2_ATTR0_QLOW_MASK;
c2.attr[0] = MVPP22_CLS_C2_ATTR0_QHIGH(qh) |
MVPP22_CLS_C2_ATTR0_QLOW(ql);
}
c2.valid = true; c2.valid = true;
...@@ -1183,7 +1194,7 @@ static int mvpp2_cls_rfs_parse_rule(struct mvpp2_rfs_rule *rule) ...@@ -1183,7 +1194,7 @@ static int mvpp2_cls_rfs_parse_rule(struct mvpp2_rfs_rule *rule)
struct flow_action_entry *act; struct flow_action_entry *act;
act = &flow->action.entries[0]; act = &flow->action.entries[0];
if (act->id != FLOW_ACTION_QUEUE) if (act->id != FLOW_ACTION_QUEUE && act->id != FLOW_ACTION_DROP)
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* For now, only use the C2 engine which has a HEK size limited to 64 /* For now, only use the C2 engine which has a HEK size limited to 64
......
...@@ -92,6 +92,17 @@ enum mvpp22_cls_c2_fwd_action { ...@@ -92,6 +92,17 @@ enum mvpp22_cls_c2_fwd_action {
MVPP22_C2_FWD_HW_LOW_LAT_LOCK, MVPP22_C2_FWD_HW_LOW_LAT_LOCK,
}; };
enum mvpp22_cls_c2_color_action {
MVPP22_C2_COL_NO_UPD = 0,
MVPP22_C2_COL_NO_UPD_LOCK,
MVPP22_C2_COL_GREEN,
MVPP22_C2_COL_GREEN_LOCK,
MVPP22_C2_COL_YELLOW,
MVPP22_C2_COL_YELLOW_LOCK,
MVPP22_C2_COL_RED, /* Drop */
MVPP22_C2_COL_RED_LOCK, /* Drop */
};
#define MVPP2_CLS_C2_TCAM_WORDS 5 #define MVPP2_CLS_C2_TCAM_WORDS 5
#define MVPP2_CLS_C2_ATTR_WORDS 5 #define MVPP2_CLS_C2_ATTR_WORDS 5
......
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