mlxsw: spectrum_flow: Promote binder-type dispatch to spectrum.c
authorPetr Machata <petrm@mellanox.com>
Fri, 10 Jul 2020 21:55:13 +0000 (00:55 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Jul 2020 00:22:22 +0000 (17:22 -0700)
Two RED qevents have been introduced recently. From the point of view of a
driver, qevents are simply blocks with unusual binder types. However they
need to be handled by different logic than ACL-like flows.

Thus rename mlxsw_sp_setup_tc_block() to mlxsw_sp_setup_tc_block_clsact()
and move the binder-type dispatch from there to spectrum.c into a new
function of the original name. The new dispatcher is easier to extend with
new binder types.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_flow.c

index 636dd09cbbbc622c91eb82f363736f3f94c02a91..2235c4bf330d08e4ba0592640c02f19c3e136455 100644 (file)
@@ -1329,6 +1329,19 @@ static int mlxsw_sp_port_kill_vid(struct net_device *dev,
        return 0;
 }
 
+static int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port,
+                                  struct flow_block_offload *f)
+{
+       switch (f->binder_type) {
+       case FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS:
+               return mlxsw_sp_setup_tc_block_clsact(mlxsw_sp_port, f, true);
+       case FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS:
+               return mlxsw_sp_setup_tc_block_clsact(mlxsw_sp_port, f, false);
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
 static int mlxsw_sp_setup_tc(struct net_device *dev, enum tc_setup_type type,
                             void *type_data)
 {
index 51047b1aa23a8e2aac5e62f29e3974cf3655e708..ee9a19f28b979d806ffe03f963152b8649dcc2d2 100644 (file)
@@ -767,8 +767,9 @@ mlxsw_sp_flow_block_is_mixed_bound(const struct mlxsw_sp_flow_block *block)
 struct mlxsw_sp_flow_block *mlxsw_sp_flow_block_create(struct mlxsw_sp *mlxsw_sp,
                                                       struct net *net);
 void mlxsw_sp_flow_block_destroy(struct mlxsw_sp_flow_block *block);
-int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port,
-                           struct flow_block_offload *f);
+int mlxsw_sp_setup_tc_block_clsact(struct mlxsw_sp_port *mlxsw_sp_port,
+                                  struct flow_block_offload *f,
+                                  bool ingress);
 
 /* spectrum_acl.c */
 struct mlxsw_sp_acl_ruleset;
index 421581a85cd6f5972f5426dd66d7b546eaeeae29..0456cda338082e9d41e2325c63dced3d1b53ca33 100644 (file)
@@ -277,18 +277,10 @@ static void mlxsw_sp_setup_tc_block_unbind(struct mlxsw_sp_port *mlxsw_sp_port,
        }
 }
 
-int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port,
-                           struct flow_block_offload *f)
+int mlxsw_sp_setup_tc_block_clsact(struct mlxsw_sp_port *mlxsw_sp_port,
+                                  struct flow_block_offload *f,
+                                  bool ingress)
 {
-       bool ingress;
-
-       if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
-               ingress = true;
-       else if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS)
-               ingress = false;
-       else
-               return -EOPNOTSUPP;
-
        f->driver_block_list = &mlxsw_sp_block_cb_list;
 
        switch (f->command) {