]> git.itanic.dy.fi Git - linux-stable/commitdiff
net/mlx5e: Add ingress/egress indication for offloaded TC flows
authorOr Gerlitz <ogerlitz@mellanox.com>
Wed, 18 Apr 2018 10:45:11 +0000 (13:45 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 28 Jul 2018 05:57:14 +0000 (07:57 +0200)
[ Upstream commit 60bd4af814fec164c42bdd2efd7984b85d6b1e1e ]

When an e-switch TC rule is offloaded through the egdev (egress
device) mechanism, we treat this as egress, all other cases (NIC
and e-switch) are considred ingress.

This is preparation step that will allow us to  identify "wrong"
stat/del offload calls made by the TC core on egdev based flows and
ignore them.

Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Paul Blakey <paulb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h

index 30cad07be2b51a6c07a5489a0cf2a967f7bd22a4..065ff87f0bef798de42c037d6c5ad3503bd60dbb 100644 (file)
@@ -1092,9 +1092,6 @@ int mlx5e_ethtool_get_ts_info(struct mlx5e_priv *priv,
 int mlx5e_ethtool_flash_device(struct mlx5e_priv *priv,
                               struct ethtool_flash *flash);
 
-int mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
-                           void *cb_priv);
-
 /* mlx5e generic netdev management API */
 struct net_device*
 mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *profile,
index d3a1a2281e77b0ebe01c9e67d0b7fcc3428b9628..fdf40812a2a9a73ed98b399ed5817005a9f0f895 100644 (file)
@@ -3093,22 +3093,23 @@ static int mlx5e_setup_tc_mqprio(struct net_device *netdev,
 
 #ifdef CONFIG_MLX5_ESWITCH
 static int mlx5e_setup_tc_cls_flower(struct mlx5e_priv *priv,
-                                    struct tc_cls_flower_offload *cls_flower)
+                                    struct tc_cls_flower_offload *cls_flower,
+                                    int flags)
 {
        switch (cls_flower->command) {
        case TC_CLSFLOWER_REPLACE:
-               return mlx5e_configure_flower(priv, cls_flower);
+               return mlx5e_configure_flower(priv, cls_flower, flags);
        case TC_CLSFLOWER_DESTROY:
-               return mlx5e_delete_flower(priv, cls_flower);
+               return mlx5e_delete_flower(priv, cls_flower, flags);
        case TC_CLSFLOWER_STATS:
-               return mlx5e_stats_flower(priv, cls_flower);
+               return mlx5e_stats_flower(priv, cls_flower, flags);
        default:
                return -EOPNOTSUPP;
        }
 }
 
-int mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
-                           void *cb_priv)
+static int mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
+                                  void *cb_priv)
 {
        struct mlx5e_priv *priv = cb_priv;
 
@@ -3117,7 +3118,7 @@ int mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
 
        switch (type) {
        case TC_SETUP_CLSFLOWER:
-               return mlx5e_setup_tc_cls_flower(priv, type_data);
+               return mlx5e_setup_tc_cls_flower(priv, type_data, MLX5E_TC_INGRESS);
        default:
                return -EOPNOTSUPP;
        }
index 286565862341b54897402ae7f211203d1eabbd0d..c88eb80278dda184f4bca83572416be64bec9442 100644 (file)
@@ -723,15 +723,31 @@ static int mlx5e_rep_get_phys_port_name(struct net_device *dev,
 
 static int
 mlx5e_rep_setup_tc_cls_flower(struct mlx5e_priv *priv,
-                             struct tc_cls_flower_offload *cls_flower)
+                             struct tc_cls_flower_offload *cls_flower, int flags)
 {
        switch (cls_flower->command) {
        case TC_CLSFLOWER_REPLACE:
-               return mlx5e_configure_flower(priv, cls_flower);
+               return mlx5e_configure_flower(priv, cls_flower, flags);
        case TC_CLSFLOWER_DESTROY:
-               return mlx5e_delete_flower(priv, cls_flower);
+               return mlx5e_delete_flower(priv, cls_flower, flags);
        case TC_CLSFLOWER_STATS:
-               return mlx5e_stats_flower(priv, cls_flower);
+               return mlx5e_stats_flower(priv, cls_flower, flags);
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
+static int mlx5e_rep_setup_tc_cb_egdev(enum tc_setup_type type, void *type_data,
+                                      void *cb_priv)
+{
+       struct mlx5e_priv *priv = cb_priv;
+
+       if (!tc_cls_can_offload_and_chain0(priv->netdev, type_data))
+               return -EOPNOTSUPP;
+
+       switch (type) {
+       case TC_SETUP_CLSFLOWER:
+               return mlx5e_rep_setup_tc_cls_flower(priv, type_data, MLX5E_TC_EGRESS);
        default:
                return -EOPNOTSUPP;
        }
@@ -747,7 +763,7 @@ static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data,
 
        switch (type) {
        case TC_SETUP_CLSFLOWER:
-               return mlx5e_rep_setup_tc_cls_flower(priv, type_data);
+               return mlx5e_rep_setup_tc_cls_flower(priv, type_data, MLX5E_TC_INGRESS);
        default:
                return -EOPNOTSUPP;
        }
@@ -1111,7 +1127,7 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
 
        uplink_rpriv = mlx5_eswitch_get_uplink_priv(dev->priv.eswitch, REP_ETH);
        upriv = netdev_priv(uplink_rpriv->netdev);
-       err = tc_setup_cb_egdev_register(netdev, mlx5e_setup_tc_block_cb,
+       err = tc_setup_cb_egdev_register(netdev, mlx5e_rep_setup_tc_cb_egdev,
                                         upriv);
        if (err)
                goto err_neigh_cleanup;
@@ -1126,7 +1142,7 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
        return 0;
 
 err_egdev_cleanup:
-       tc_setup_cb_egdev_unregister(netdev, mlx5e_setup_tc_block_cb,
+       tc_setup_cb_egdev_unregister(netdev, mlx5e_rep_setup_tc_cb_egdev,
                                     upriv);
 
 err_neigh_cleanup:
@@ -1155,7 +1171,7 @@ mlx5e_vport_rep_unload(struct mlx5_eswitch_rep *rep)
        uplink_rpriv = mlx5_eswitch_get_uplink_priv(priv->mdev->priv.eswitch,
                                                    REP_ETH);
        upriv = netdev_priv(uplink_rpriv->netdev);
-       tc_setup_cb_egdev_unregister(netdev, mlx5e_setup_tc_block_cb,
+       tc_setup_cb_egdev_unregister(netdev, mlx5e_rep_setup_tc_cb_egdev,
                                     upriv);
        mlx5e_rep_neigh_cleanup(rpriv);
        mlx5e_detach_netdev(priv);
index b94276db3ce939225b282996ce0f382a2f36fa63..a1b0abc24ef5e4f1784e59c08fef1f609ff8e2a6 100644 (file)
@@ -61,12 +61,16 @@ struct mlx5_nic_flow_attr {
        struct mlx5_flow_table  *hairpin_ft;
 };
 
+#define MLX5E_TC_FLOW_BASE (MLX5E_TC_LAST_EXPORTED_BIT + 1)
+
 enum {
-       MLX5E_TC_FLOW_ESWITCH   = BIT(0),
-       MLX5E_TC_FLOW_NIC       = BIT(1),
-       MLX5E_TC_FLOW_OFFLOADED = BIT(2),
-       MLX5E_TC_FLOW_HAIRPIN   = BIT(3),
-       MLX5E_TC_FLOW_HAIRPIN_RSS = BIT(4),
+       MLX5E_TC_FLOW_INGRESS   = MLX5E_TC_INGRESS,
+       MLX5E_TC_FLOW_EGRESS    = MLX5E_TC_EGRESS,
+       MLX5E_TC_FLOW_ESWITCH   = BIT(MLX5E_TC_FLOW_BASE),
+       MLX5E_TC_FLOW_NIC       = BIT(MLX5E_TC_FLOW_BASE + 1),
+       MLX5E_TC_FLOW_OFFLOADED = BIT(MLX5E_TC_FLOW_BASE + 2),
+       MLX5E_TC_FLOW_HAIRPIN   = BIT(MLX5E_TC_FLOW_BASE + 3),
+       MLX5E_TC_FLOW_HAIRPIN_RSS = BIT(MLX5E_TC_FLOW_BASE + 4),
 };
 
 struct mlx5e_tc_flow {
@@ -2566,8 +2570,20 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
        return err;
 }
 
+static void get_flags(int flags, u8 *flow_flags)
+{
+       u8 __flow_flags = 0;
+
+       if (flags & MLX5E_TC_INGRESS)
+               __flow_flags |= MLX5E_TC_FLOW_INGRESS;
+       if (flags & MLX5E_TC_EGRESS)
+               __flow_flags |= MLX5E_TC_FLOW_EGRESS;
+
+       *flow_flags = __flow_flags;
+}
+
 int mlx5e_configure_flower(struct mlx5e_priv *priv,
-                          struct tc_cls_flower_offload *f)
+                          struct tc_cls_flower_offload *f, int flags)
 {
        struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
        struct mlx5e_tc_flow_parse_attr *parse_attr;
@@ -2576,11 +2592,13 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv,
        int attr_size, err = 0;
        u8 flow_flags = 0;
 
+       get_flags(flags, &flow_flags);
+
        if (esw && esw->mode == SRIOV_OFFLOADS) {
-               flow_flags = MLX5E_TC_FLOW_ESWITCH;
+               flow_flags |= MLX5E_TC_FLOW_ESWITCH;
                attr_size  = sizeof(struct mlx5_esw_flow_attr);
        } else {
-               flow_flags = MLX5E_TC_FLOW_NIC;
+               flow_flags |= MLX5E_TC_FLOW_NIC;
                attr_size  = sizeof(struct mlx5_nic_flow_attr);
        }
 
@@ -2639,7 +2657,7 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv,
 }
 
 int mlx5e_delete_flower(struct mlx5e_priv *priv,
-                       struct tc_cls_flower_offload *f)
+                       struct tc_cls_flower_offload *f, int flags)
 {
        struct mlx5e_tc_flow *flow;
        struct mlx5e_tc_table *tc = &priv->fs.tc;
@@ -2659,7 +2677,7 @@ int mlx5e_delete_flower(struct mlx5e_priv *priv,
 }
 
 int mlx5e_stats_flower(struct mlx5e_priv *priv,
-                      struct tc_cls_flower_offload *f)
+                      struct tc_cls_flower_offload *f, int flags)
 {
        struct mlx5e_tc_table *tc = &priv->fs.tc;
        struct mlx5e_tc_flow *flow;
index c14c263a739bddfc339744f99a0a5e5c117c19bd..2255345c2e1802bd9bf1055232d28403eef67754 100644 (file)
 #define MLX5E_TC_FLOW_ID_MASK 0x0000ffff
 
 #ifdef CONFIG_MLX5_ESWITCH
+
+enum {
+       MLX5E_TC_INGRESS = BIT(0),
+       MLX5E_TC_EGRESS  = BIT(1),
+       MLX5E_TC_LAST_EXPORTED_BIT = 1,
+};
+
 int mlx5e_tc_init(struct mlx5e_priv *priv);
 void mlx5e_tc_cleanup(struct mlx5e_priv *priv);
 
 int mlx5e_configure_flower(struct mlx5e_priv *priv,
-                          struct tc_cls_flower_offload *f);
+                          struct tc_cls_flower_offload *f, int flags);
 int mlx5e_delete_flower(struct mlx5e_priv *priv,
-                       struct tc_cls_flower_offload *f);
+                       struct tc_cls_flower_offload *f, int flags);
 
 int mlx5e_stats_flower(struct mlx5e_priv *priv,
-                      struct tc_cls_flower_offload *f);
+                      struct tc_cls_flower_offload *f, int flags);
 
 struct mlx5e_encap_entry;
 void mlx5e_tc_encap_flows_add(struct mlx5e_priv *priv,