0001
0002
0003
0004 #ifndef __MLX5E_FLOW_STEER_H__
0005 #define __MLX5E_FLOW_STEER_H__
0006
0007 #include "mod_hdr.h"
0008 #include "lib/fs_ttc.h"
0009
0010 struct mlx5e_post_act;
0011
0012 enum {
0013 MLX5E_TC_FT_LEVEL = 0,
0014 MLX5E_TC_TTC_FT_LEVEL,
0015 MLX5E_TC_MISS_LEVEL,
0016 };
0017
0018 struct mlx5e_flow_table {
0019 int num_groups;
0020 struct mlx5_flow_table *t;
0021 struct mlx5_flow_group **g;
0022 };
0023
0024 struct mlx5e_l2_rule {
0025 u8 addr[ETH_ALEN + 2];
0026 struct mlx5_flow_handle *rule;
0027 };
0028
0029 #define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE)
0030
0031 struct mlx5e_promisc_table {
0032 struct mlx5e_flow_table ft;
0033 struct mlx5_flow_handle *rule;
0034 };
0035
0036
0037 struct mlx5e_vlan_table;
0038 unsigned long *mlx5e_vlan_get_active_svlans(struct mlx5e_vlan_table *vlan);
0039 struct mlx5_flow_table *mlx5e_vlan_get_flowtable(struct mlx5e_vlan_table *vlan);
0040
0041 struct mlx5e_l2_table {
0042 struct mlx5e_flow_table ft;
0043 struct hlist_head netdev_uc[MLX5E_L2_ADDR_HASH_SIZE];
0044 struct hlist_head netdev_mc[MLX5E_L2_ADDR_HASH_SIZE];
0045 struct mlx5e_l2_rule broadcast;
0046 struct mlx5e_l2_rule allmulti;
0047 struct mlx5_flow_handle *trap_rule;
0048 bool broadcast_enabled;
0049 bool allmulti_enabled;
0050 bool promisc_enabled;
0051 };
0052
0053 #define MLX5E_NUM_INDIR_TIRS (MLX5_NUM_TT - 1)
0054
0055 #define MLX5_HASH_IP (MLX5_HASH_FIELD_SEL_SRC_IP |\
0056 MLX5_HASH_FIELD_SEL_DST_IP)
0057 #define MLX5_HASH_IP_L4PORTS (MLX5_HASH_FIELD_SEL_SRC_IP |\
0058 MLX5_HASH_FIELD_SEL_DST_IP |\
0059 MLX5_HASH_FIELD_SEL_L4_SPORT |\
0060 MLX5_HASH_FIELD_SEL_L4_DPORT)
0061 #define MLX5_HASH_IP_IPSEC_SPI (MLX5_HASH_FIELD_SEL_SRC_IP |\
0062 MLX5_HASH_FIELD_SEL_DST_IP |\
0063 MLX5_HASH_FIELD_SEL_IPSEC_SPI)
0064
0065
0066 enum {
0067 MLX5E_PROMISC_FT_LEVEL,
0068 MLX5E_VLAN_FT_LEVEL,
0069 MLX5E_L2_FT_LEVEL,
0070 MLX5E_TTC_FT_LEVEL,
0071 MLX5E_INNER_TTC_FT_LEVEL,
0072 MLX5E_FS_TT_UDP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
0073 MLX5E_FS_TT_ANY_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
0074 #ifdef CONFIG_MLX5_EN_TLS
0075 MLX5E_ACCEL_FS_TCP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
0076 #endif
0077 #ifdef CONFIG_MLX5_EN_ARFS
0078 MLX5E_ARFS_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
0079 #endif
0080 #ifdef CONFIG_MLX5_EN_IPSEC
0081 MLX5E_ACCEL_FS_ESP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
0082 MLX5E_ACCEL_FS_ESP_FT_ERR_LEVEL,
0083 #endif
0084 };
0085
0086 struct mlx5e_priv;
0087
0088 #ifdef CONFIG_MLX5_EN_RXNFC
0089
0090 struct mlx5e_ethtool_table {
0091 struct mlx5_flow_table *ft;
0092 int num_rules;
0093 };
0094
0095 #define ETHTOOL_NUM_L3_L4_FTS 7
0096 #define ETHTOOL_NUM_L2_FTS 4
0097
0098 struct mlx5e_ethtool_steering {
0099 struct mlx5e_ethtool_table l3_l4_ft[ETHTOOL_NUM_L3_L4_FTS];
0100 struct mlx5e_ethtool_table l2_ft[ETHTOOL_NUM_L2_FTS];
0101 struct list_head rules;
0102 int tot_num_rules;
0103 };
0104
0105 void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv);
0106 void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv);
0107 int mlx5e_ethtool_set_rxnfc(struct mlx5e_priv *priv, struct ethtool_rxnfc *cmd);
0108 int mlx5e_ethtool_get_rxnfc(struct mlx5e_priv *priv,
0109 struct ethtool_rxnfc *info, u32 *rule_locs);
0110 #else
0111 static inline void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv) { }
0112 static inline void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv) { }
0113 static inline int mlx5e_ethtool_set_rxnfc(struct mlx5e_priv *priv, struct ethtool_rxnfc *cmd)
0114 { return -EOPNOTSUPP; }
0115 static inline int mlx5e_ethtool_get_rxnfc(struct mlx5e_priv *priv,
0116 struct ethtool_rxnfc *info, u32 *rule_locs)
0117 { return -EOPNOTSUPP; }
0118 #endif
0119
0120 #ifdef CONFIG_MLX5_EN_ARFS
0121 struct mlx5e_arfs_tables;
0122
0123 int mlx5e_arfs_create_tables(struct mlx5e_priv *priv);
0124 void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv);
0125 int mlx5e_arfs_enable(struct mlx5e_priv *priv);
0126 int mlx5e_arfs_disable(struct mlx5e_priv *priv);
0127 int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
0128 u16 rxq_index, u32 flow_id);
0129 #else
0130 static inline int mlx5e_arfs_create_tables(struct mlx5e_priv *priv) { return 0; }
0131 static inline void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv) {}
0132 static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv) { return -EOPNOTSUPP; }
0133 static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv) { return -EOPNOTSUPP; }
0134 #endif
0135
0136 #ifdef CONFIG_MLX5_EN_TLS
0137 struct mlx5e_accel_fs_tcp;
0138 #endif
0139
0140 struct mlx5e_profile;
0141 struct mlx5e_fs_udp;
0142 struct mlx5e_fs_any;
0143 struct mlx5e_ptp_fs;
0144
0145 struct mlx5e_flow_steering {
0146 bool state_destroy;
0147 bool vlan_strip_disable;
0148 struct mlx5_core_dev *mdev;
0149 struct mlx5_flow_namespace *ns;
0150 #ifdef CONFIG_MLX5_EN_RXNFC
0151 struct mlx5e_ethtool_steering ethtool;
0152 #endif
0153 struct mlx5e_tc_table *tc;
0154 struct mlx5e_promisc_table promisc;
0155 struct mlx5e_vlan_table *vlan;
0156 struct mlx5e_l2_table l2;
0157 struct mlx5_ttc_table *ttc;
0158 struct mlx5_ttc_table *inner_ttc;
0159 #ifdef CONFIG_MLX5_EN_ARFS
0160 struct mlx5e_arfs_tables *arfs;
0161 #endif
0162 #ifdef CONFIG_MLX5_EN_TLS
0163 struct mlx5e_accel_fs_tcp *accel_tcp;
0164 #endif
0165 struct mlx5e_fs_udp *udp;
0166 struct mlx5e_fs_any *any;
0167 struct mlx5e_ptp_fs *ptp_fs;
0168 };
0169
0170 void mlx5e_set_ttc_params(struct mlx5e_priv *priv,
0171 struct ttc_params *ttc_params, bool tunnel);
0172
0173 void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv);
0174 int mlx5e_create_ttc_table(struct mlx5e_priv *priv);
0175
0176 void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
0177
0178 void mlx5e_enable_cvlan_filter(struct mlx5e_priv *priv);
0179 void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv);
0180
0181 int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
0182 void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);
0183
0184 struct mlx5e_flow_steering *mlx5e_fs_init(const struct mlx5e_profile *profile,
0185 struct mlx5_core_dev *mdev,
0186 bool state_destroy);
0187 void mlx5e_fs_cleanup(struct mlx5e_flow_steering *fs);
0188
0189 int mlx5e_add_vlan_trap(struct mlx5e_priv *priv, int trap_id, int tir_num);
0190 void mlx5e_remove_vlan_trap(struct mlx5e_priv *priv);
0191 int mlx5e_add_mac_trap(struct mlx5e_priv *priv, int trap_id, int tir_num);
0192 void mlx5e_remove_mac_trap(struct mlx5e_priv *priv);
0193 void mlx5e_fs_set_rx_mode_work(struct mlx5e_flow_steering *fs, struct net_device *netdev);
0194 int mlx5e_fs_vlan_rx_add_vid(struct mlx5e_flow_steering *fs,
0195 struct net_device *netdev,
0196 __be16 proto, u16 vid);
0197 int mlx5e_fs_vlan_rx_kill_vid(struct mlx5e_flow_steering *fs,
0198 struct net_device *netdev,
0199 __be16 proto, u16 vid);
0200 void mlx5e_fs_init_l2_addr(struct mlx5e_flow_steering *fs, struct net_device *netdev);
0201 #endif
0202