net/mlx5e: Move flow steering declarations into en/fs.h
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / en / fs.h
index adc00ae7e9e9ae624fb372af08881fdc06353c70..bbf69e859b78c1322a9e218797114c9483a1a060 100644 (file)
@@ -4,12 +4,97 @@
 #ifndef __MLX5E_FLOW_STEER_H__
 #define __MLX5E_FLOW_STEER_H__
 
+enum {
+       MLX5E_TC_FT_LEVEL = 0,
+       MLX5E_TC_TTC_FT_LEVEL,
+};
+
+struct mlx5e_tc_table {
+       struct mlx5_flow_table          *t;
+
+       struct rhashtable               ht;
+
+       DECLARE_HASHTABLE(mod_hdr_tbl, 8);
+       DECLARE_HASHTABLE(hairpin_tbl, 8);
+};
+
 struct mlx5e_flow_table {
        int num_groups;
        struct mlx5_flow_table *t;
        struct mlx5_flow_group **g;
 };
 
+struct mlx5e_l2_rule {
+       u8  addr[ETH_ALEN + 2];
+       struct mlx5_flow_handle *rule;
+};
+
+#define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE)
+
+struct mlx5e_vlan_table {
+       struct mlx5e_flow_table         ft;
+       DECLARE_BITMAP(active_cvlans, VLAN_N_VID);
+       DECLARE_BITMAP(active_svlans, VLAN_N_VID);
+       struct mlx5_flow_handle *active_cvlans_rule[VLAN_N_VID];
+       struct mlx5_flow_handle *active_svlans_rule[VLAN_N_VID];
+       struct mlx5_flow_handle *untagged_rule;
+       struct mlx5_flow_handle *any_cvlan_rule;
+       struct mlx5_flow_handle *any_svlan_rule;
+       bool                    cvlan_filter_disabled;
+};
+
+struct mlx5e_l2_table {
+       struct mlx5e_flow_table    ft;
+       struct hlist_head          netdev_uc[MLX5E_L2_ADDR_HASH_SIZE];
+       struct hlist_head          netdev_mc[MLX5E_L2_ADDR_HASH_SIZE];
+       struct mlx5e_l2_rule       broadcast;
+       struct mlx5e_l2_rule       allmulti;
+       struct mlx5e_l2_rule       promisc;
+       bool                       broadcast_enabled;
+       bool                       allmulti_enabled;
+       bool                       promisc_enabled;
+};
+
+enum mlx5e_traffic_types {
+       MLX5E_TT_IPV4_TCP,
+       MLX5E_TT_IPV6_TCP,
+       MLX5E_TT_IPV4_UDP,
+       MLX5E_TT_IPV6_UDP,
+       MLX5E_TT_IPV4_IPSEC_AH,
+       MLX5E_TT_IPV6_IPSEC_AH,
+       MLX5E_TT_IPV4_IPSEC_ESP,
+       MLX5E_TT_IPV6_IPSEC_ESP,
+       MLX5E_TT_IPV4,
+       MLX5E_TT_IPV6,
+       MLX5E_TT_ANY,
+       MLX5E_NUM_TT,
+       MLX5E_NUM_INDIR_TIRS = MLX5E_TT_ANY,
+};
+
+enum mlx5e_tunnel_types {
+       MLX5E_TT_IPV4_GRE,
+       MLX5E_TT_IPV6_GRE,
+       MLX5E_NUM_TUNNEL_TT,
+};
+
+/* L3/L4 traffic type classifier */
+struct mlx5e_ttc_table {
+       struct mlx5e_flow_table  ft;
+       struct mlx5_flow_handle  *rules[MLX5E_NUM_TT];
+       struct mlx5_flow_handle  *tunnel_rules[MLX5E_NUM_TUNNEL_TT];
+};
+
+/* NIC prio FTS */
+enum {
+       MLX5E_VLAN_FT_LEVEL = 0,
+       MLX5E_L2_FT_LEVEL,
+       MLX5E_TTC_FT_LEVEL,
+       MLX5E_INNER_TTC_FT_LEVEL,
+#ifdef CONFIG_MLX5_EN_ARFS
+       MLX5E_ARFS_FT_LEVEL
+#endif
+};
+
 #ifdef CONFIG_MLX5_EN_RXNFC
 
 struct mlx5e_ethtool_table {
@@ -77,5 +162,49 @@ static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv) { return -EOPNOTSUP
 static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv) {        return -EOPNOTSUPP; }
 #endif
 
+struct mlx5e_flow_steering {
+       struct mlx5_flow_namespace      *ns;
+#ifdef CONFIG_MLX5_EN_RXNFC
+       struct mlx5e_ethtool_steering   ethtool;
+#endif
+       struct mlx5e_tc_table           tc;
+       struct mlx5e_vlan_table         vlan;
+       struct mlx5e_l2_table           l2;
+       struct mlx5e_ttc_table          ttc;
+       struct mlx5e_ttc_table          inner_ttc;
+#ifdef CONFIG_MLX5_EN_ARFS
+       struct mlx5e_arfs_tables        arfs;
+#endif
+};
+
+struct ttc_params {
+       struct mlx5_flow_table_attr ft_attr;
+       u32 any_tt_tirn;
+       u32 indir_tirn[MLX5E_NUM_INDIR_TIRS];
+       struct mlx5e_ttc_table *inner_ttc;
+};
+
+void mlx5e_set_ttc_basic_params(struct mlx5e_priv *priv, struct ttc_params *ttc_params);
+void mlx5e_set_ttc_ft_params(struct ttc_params *ttc_params);
+void mlx5e_set_inner_ttc_ft_params(struct ttc_params *ttc_params);
+
+int mlx5e_create_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params,
+                          struct mlx5e_ttc_table *ttc);
+void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv,
+                            struct mlx5e_ttc_table *ttc);
+
+int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params,
+                                struct mlx5e_ttc_table *ttc);
+void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv,
+                                  struct mlx5e_ttc_table *ttc);
+
+void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
+
+void mlx5e_enable_cvlan_filter(struct mlx5e_priv *priv);
+void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv);
+
+int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
+void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);
+
 #endif /* __MLX5E_FLOW_STEER_H__ */