Skip to content

Commit ed11bb1

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: Add bypass operations for the flower classifier-action filter
Due to the immense variety of classification keys and actions available for tc-flower, as well as due to potentially very different DSA switch capabilities, it doesn't make a lot of sense for the DSA mid layer to even attempt to interpret these. So just pass them on to the underlying switch driver. DSA implements just the standard boilerplate for binding and unbinding flow blocks to ports, since nobody wants to deal with that. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8551cde commit ed11bb1

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

‎include/net/dsa.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,12 @@ struct dsa_switch_ops {
540540
/*
541541
* TC integration
542542
*/
543+
int (*cls_flower_add)(struct dsa_switch *ds, int port,
544+
struct flow_cls_offload *cls, bool ingress);
545+
int (*cls_flower_del)(struct dsa_switch *ds, int port,
546+
struct flow_cls_offload *cls, bool ingress);
547+
int (*cls_flower_stats)(struct dsa_switch *ds, int port,
548+
struct flow_cls_offload *cls, bool ingress);
543549
int (*port_mirror_add)(struct dsa_switch *ds, int port,
544550
struct dsa_mall_mirror_tc_entry *mirror,
545551
bool ingress);

‎net/dsa/slave.c‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,64 @@ static int dsa_slave_setup_tc_cls_matchall(struct net_device *dev,
946946
}
947947
}
948948

949+
static int dsa_slave_add_cls_flower(struct net_device *dev,
950+
struct flow_cls_offload *cls,
951+
bool ingress)
952+
{
953+
struct dsa_port *dp = dsa_slave_to_port(dev);
954+
struct dsa_switch *ds = dp->ds;
955+
int port = dp->index;
956+
957+
if (!ds->ops->cls_flower_add)
958+
return -EOPNOTSUPP;
959+
960+
return ds->ops->cls_flower_add(ds, port, cls, ingress);
961+
}
962+
963+
static int dsa_slave_del_cls_flower(struct net_device *dev,
964+
struct flow_cls_offload *cls,
965+
bool ingress)
966+
{
967+
struct dsa_port *dp = dsa_slave_to_port(dev);
968+
struct dsa_switch *ds = dp->ds;
969+
int port = dp->index;
970+
971+
if (!ds->ops->cls_flower_del)
972+
return -EOPNOTSUPP;
973+
974+
return ds->ops->cls_flower_del(ds, port, cls, ingress);
975+
}
976+
977+
static int dsa_slave_stats_cls_flower(struct net_device *dev,
978+
struct flow_cls_offload *cls,
979+
bool ingress)
980+
{
981+
struct dsa_port *dp = dsa_slave_to_port(dev);
982+
struct dsa_switch *ds = dp->ds;
983+
int port = dp->index;
984+
985+
if (!ds->ops->cls_flower_stats)
986+
return -EOPNOTSUPP;
987+
988+
return ds->ops->cls_flower_stats(ds, port, cls, ingress);
989+
}
990+
991+
static int dsa_slave_setup_tc_cls_flower(struct net_device *dev,
992+
struct flow_cls_offload *cls,
993+
bool ingress)
994+
{
995+
switch (cls->command) {
996+
case FLOW_CLS_REPLACE:
997+
return dsa_slave_add_cls_flower(dev, cls, ingress);
998+
case FLOW_CLS_DESTROY:
999+
return dsa_slave_del_cls_flower(dev, cls, ingress);
1000+
case FLOW_CLS_STATS:
1001+
return dsa_slave_stats_cls_flower(dev, cls, ingress);
1002+
default:
1003+
return -EOPNOTSUPP;
1004+
}
1005+
}
1006+
9491007
static int dsa_slave_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
9501008
void *cb_priv, bool ingress)
9511009
{
@@ -957,6 +1015,8 @@ static int dsa_slave_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
9571015
switch (type) {
9581016
case TC_SETUP_CLSMATCHALL:
9591017
return dsa_slave_setup_tc_cls_matchall(dev, type_data, ingress);
1018+
case TC_SETUP_CLSFLOWER:
1019+
return dsa_slave_setup_tc_cls_flower(dev, type_data, ingress);
9601020
default:
9611021
return -EOPNOTSUPP;
9621022
}

0 commit comments

Comments
 (0)