PageRenderTime 26ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h

https://gitlab.com/pachecof/centos-stream-9
C Header | 283 lines | 231 code | 44 blank | 8 comment | 0 complexity | f4be407db8760901e2f5be061c4fa40f MD5 | raw file
  1. /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
  2. /* Copyright (c) 2018 Mellanox Technologies. */
  3. #ifndef __MLX5E_FLOW_STEER_H__
  4. #define __MLX5E_FLOW_STEER_H__
  5. #include "mod_hdr.h"
  6. enum {
  7. MLX5E_TC_FT_LEVEL = 0,
  8. MLX5E_TC_TTC_FT_LEVEL,
  9. };
  10. struct mlx5e_tc_table {
  11. /* Protects the dynamic assignment of the t parameter
  12. * which is the nic tc root table.
  13. */
  14. struct mutex t_lock;
  15. struct mlx5_flow_table *t;
  16. struct mlx5_fs_chains *chains;
  17. struct rhashtable ht;
  18. struct mod_hdr_tbl mod_hdr;
  19. struct mutex hairpin_tbl_lock; /* protects hairpin_tbl */
  20. DECLARE_HASHTABLE(hairpin_tbl, 8);
  21. struct notifier_block netdevice_nb;
  22. struct netdev_net_notifier netdevice_nn;
  23. struct mlx5_tc_ct_priv *ct;
  24. struct mapping_ctx *mapping;
  25. };
  26. struct mlx5e_flow_table {
  27. int num_groups;
  28. struct mlx5_flow_table *t;
  29. struct mlx5_flow_group **g;
  30. };
  31. struct mlx5e_l2_rule {
  32. u8 addr[ETH_ALEN + 2];
  33. struct mlx5_flow_handle *rule;
  34. };
  35. #define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE)
  36. struct mlx5e_promisc_table {
  37. struct mlx5e_flow_table ft;
  38. struct mlx5_flow_handle *rule;
  39. };
  40. /* Forward declaration and APIs to get private fields of vlan_table */
  41. struct mlx5e_vlan_table;
  42. unsigned long *mlx5e_vlan_get_active_svlans(struct mlx5e_vlan_table *vlan);
  43. struct mlx5_flow_table *mlx5e_vlan_get_flowtable(struct mlx5e_vlan_table *vlan);
  44. struct mlx5e_l2_table {
  45. struct mlx5e_flow_table ft;
  46. struct hlist_head netdev_uc[MLX5E_L2_ADDR_HASH_SIZE];
  47. struct hlist_head netdev_mc[MLX5E_L2_ADDR_HASH_SIZE];
  48. struct mlx5e_l2_rule broadcast;
  49. struct mlx5e_l2_rule allmulti;
  50. struct mlx5_flow_handle *trap_rule;
  51. bool broadcast_enabled;
  52. bool allmulti_enabled;
  53. bool promisc_enabled;
  54. };
  55. enum mlx5e_traffic_types {
  56. MLX5E_TT_IPV4_TCP,
  57. MLX5E_TT_IPV6_TCP,
  58. MLX5E_TT_IPV4_UDP,
  59. MLX5E_TT_IPV6_UDP,
  60. MLX5E_TT_IPV4_IPSEC_AH,
  61. MLX5E_TT_IPV6_IPSEC_AH,
  62. MLX5E_TT_IPV4_IPSEC_ESP,
  63. MLX5E_TT_IPV6_IPSEC_ESP,
  64. MLX5E_TT_IPV4,
  65. MLX5E_TT_IPV6,
  66. MLX5E_TT_ANY,
  67. MLX5E_NUM_TT,
  68. MLX5E_NUM_INDIR_TIRS = MLX5E_TT_ANY,
  69. };
  70. struct mlx5e_tirc_config {
  71. u8 l3_prot_type;
  72. u8 l4_prot_type;
  73. u32 rx_hash_fields;
  74. };
  75. #define MLX5_HASH_IP (MLX5_HASH_FIELD_SEL_SRC_IP |\
  76. MLX5_HASH_FIELD_SEL_DST_IP)
  77. #define MLX5_HASH_IP_L4PORTS (MLX5_HASH_FIELD_SEL_SRC_IP |\
  78. MLX5_HASH_FIELD_SEL_DST_IP |\
  79. MLX5_HASH_FIELD_SEL_L4_SPORT |\
  80. MLX5_HASH_FIELD_SEL_L4_DPORT)
  81. #define MLX5_HASH_IP_IPSEC_SPI (MLX5_HASH_FIELD_SEL_SRC_IP |\
  82. MLX5_HASH_FIELD_SEL_DST_IP |\
  83. MLX5_HASH_FIELD_SEL_IPSEC_SPI)
  84. enum mlx5e_tunnel_types {
  85. MLX5E_TT_IPV4_GRE,
  86. MLX5E_TT_IPV6_GRE,
  87. MLX5E_TT_IPV4_IPIP,
  88. MLX5E_TT_IPV6_IPIP,
  89. MLX5E_TT_IPV4_IPV6,
  90. MLX5E_TT_IPV6_IPV6,
  91. MLX5E_NUM_TUNNEL_TT,
  92. };
  93. bool mlx5e_tunnel_inner_ft_supported(struct mlx5_core_dev *mdev);
  94. struct mlx5e_ttc_rule {
  95. struct mlx5_flow_handle *rule;
  96. struct mlx5_flow_destination default_dest;
  97. };
  98. /* L3/L4 traffic type classifier */
  99. struct mlx5e_ttc_table {
  100. struct mlx5e_flow_table ft;
  101. struct mlx5e_ttc_rule rules[MLX5E_NUM_TT];
  102. struct mlx5_flow_handle *tunnel_rules[MLX5E_NUM_TUNNEL_TT];
  103. };
  104. /* NIC prio FTS */
  105. enum {
  106. MLX5E_PROMISC_FT_LEVEL,
  107. MLX5E_VLAN_FT_LEVEL,
  108. MLX5E_L2_FT_LEVEL,
  109. MLX5E_TTC_FT_LEVEL,
  110. MLX5E_INNER_TTC_FT_LEVEL,
  111. MLX5E_FS_TT_UDP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
  112. MLX5E_FS_TT_ANY_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
  113. #ifdef CONFIG_MLX5_EN_TLS
  114. MLX5E_ACCEL_FS_TCP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
  115. #endif
  116. #ifdef CONFIG_MLX5_EN_ARFS
  117. MLX5E_ARFS_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
  118. #endif
  119. #ifdef CONFIG_MLX5_EN_IPSEC
  120. MLX5E_ACCEL_FS_ESP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
  121. MLX5E_ACCEL_FS_ESP_FT_ERR_LEVEL,
  122. #endif
  123. };
  124. #define MLX5E_TTC_NUM_GROUPS 3
  125. #define MLX5E_TTC_GROUP1_SIZE (BIT(3) + MLX5E_NUM_TUNNEL_TT)
  126. #define MLX5E_TTC_GROUP2_SIZE BIT(1)
  127. #define MLX5E_TTC_GROUP3_SIZE BIT(0)
  128. #define MLX5E_TTC_TABLE_SIZE (MLX5E_TTC_GROUP1_SIZE +\
  129. MLX5E_TTC_GROUP2_SIZE +\
  130. MLX5E_TTC_GROUP3_SIZE)
  131. #define MLX5E_INNER_TTC_NUM_GROUPS 3
  132. #define MLX5E_INNER_TTC_GROUP1_SIZE BIT(3)
  133. #define MLX5E_INNER_TTC_GROUP2_SIZE BIT(1)
  134. #define MLX5E_INNER_TTC_GROUP3_SIZE BIT(0)
  135. #define MLX5E_INNER_TTC_TABLE_SIZE (MLX5E_INNER_TTC_GROUP1_SIZE +\
  136. MLX5E_INNER_TTC_GROUP2_SIZE +\
  137. MLX5E_INNER_TTC_GROUP3_SIZE)
  138. #ifdef CONFIG_MLX5_EN_RXNFC
  139. struct mlx5e_ethtool_table {
  140. struct mlx5_flow_table *ft;
  141. int num_rules;
  142. };
  143. #define ETHTOOL_NUM_L3_L4_FTS 7
  144. #define ETHTOOL_NUM_L2_FTS 4
  145. struct mlx5e_ethtool_steering {
  146. struct mlx5e_ethtool_table l3_l4_ft[ETHTOOL_NUM_L3_L4_FTS];
  147. struct mlx5e_ethtool_table l2_ft[ETHTOOL_NUM_L2_FTS];
  148. struct list_head rules;
  149. int tot_num_rules;
  150. };
  151. void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv);
  152. void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv);
  153. int mlx5e_ethtool_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd);
  154. int mlx5e_ethtool_get_rxnfc(struct net_device *dev,
  155. struct ethtool_rxnfc *info, u32 *rule_locs);
  156. #else
  157. static inline void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv) { }
  158. static inline void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv) { }
  159. static inline int mlx5e_ethtool_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
  160. { return -EOPNOTSUPP; }
  161. static inline int mlx5e_ethtool_get_rxnfc(struct net_device *dev,
  162. struct ethtool_rxnfc *info, u32 *rule_locs)
  163. { return -EOPNOTSUPP; }
  164. #endif /* CONFIG_MLX5_EN_RXNFC */
  165. #ifdef CONFIG_MLX5_EN_ARFS
  166. struct mlx5e_arfs_tables;
  167. int mlx5e_arfs_create_tables(struct mlx5e_priv *priv);
  168. void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv);
  169. int mlx5e_arfs_enable(struct mlx5e_priv *priv);
  170. int mlx5e_arfs_disable(struct mlx5e_priv *priv);
  171. int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
  172. u16 rxq_index, u32 flow_id);
  173. #else
  174. static inline int mlx5e_arfs_create_tables(struct mlx5e_priv *priv) { return 0; }
  175. static inline void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv) {}
  176. static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv) { return -EOPNOTSUPP; }
  177. static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv) { return -EOPNOTSUPP; }
  178. #endif
  179. #ifdef CONFIG_MLX5_EN_TLS
  180. struct mlx5e_accel_fs_tcp;
  181. #endif
  182. struct mlx5e_fs_udp;
  183. struct mlx5e_fs_any;
  184. struct mlx5e_ptp_fs;
  185. struct mlx5e_flow_steering {
  186. struct mlx5_flow_namespace *ns;
  187. struct mlx5_flow_namespace *egress_ns;
  188. #ifdef CONFIG_MLX5_EN_RXNFC
  189. struct mlx5e_ethtool_steering ethtool;
  190. #endif
  191. struct mlx5e_tc_table tc;
  192. struct mlx5e_promisc_table promisc;
  193. struct mlx5e_vlan_table *vlan;
  194. struct mlx5e_l2_table l2;
  195. struct mlx5e_ttc_table ttc;
  196. struct mlx5e_ttc_table inner_ttc;
  197. #ifdef CONFIG_MLX5_EN_ARFS
  198. struct mlx5e_arfs_tables *arfs;
  199. #endif
  200. #ifdef CONFIG_MLX5_EN_TLS
  201. struct mlx5e_accel_fs_tcp *accel_tcp;
  202. #endif
  203. struct mlx5e_fs_udp *udp;
  204. struct mlx5e_fs_any *any;
  205. struct mlx5e_ptp_fs *ptp_fs;
  206. };
  207. struct ttc_params {
  208. struct mlx5_flow_table_attr ft_attr;
  209. u32 any_tt_tirn;
  210. u32 indir_tirn[MLX5E_NUM_INDIR_TIRS];
  211. struct mlx5e_ttc_table *inner_ttc;
  212. };
  213. void mlx5e_set_ttc_basic_params(struct mlx5e_priv *priv, struct ttc_params *ttc_params);
  214. void mlx5e_set_ttc_ft_params(struct ttc_params *ttc_params);
  215. void mlx5e_set_inner_ttc_ft_params(struct ttc_params *ttc_params);
  216. int mlx5e_create_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params,
  217. struct mlx5e_ttc_table *ttc);
  218. void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv,
  219. struct mlx5e_ttc_table *ttc);
  220. int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params,
  221. struct mlx5e_ttc_table *ttc);
  222. void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv,
  223. struct mlx5e_ttc_table *ttc);
  224. void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
  225. int mlx5e_ttc_fwd_dest(struct mlx5e_priv *priv, enum mlx5e_traffic_types type,
  226. struct mlx5_flow_destination *new_dest);
  227. struct mlx5_flow_destination
  228. mlx5e_ttc_get_default_dest(struct mlx5e_priv *priv, enum mlx5e_traffic_types type);
  229. int mlx5e_ttc_fwd_default_dest(struct mlx5e_priv *priv, enum mlx5e_traffic_types type);
  230. void mlx5e_enable_cvlan_filter(struct mlx5e_priv *priv);
  231. void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv);
  232. int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
  233. void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);
  234. u8 mlx5e_get_proto_by_tunnel_type(enum mlx5e_tunnel_types tt);
  235. int mlx5e_add_vlan_trap(struct mlx5e_priv *priv, int trap_id, int tir_num);
  236. void mlx5e_remove_vlan_trap(struct mlx5e_priv *priv);
  237. int mlx5e_add_mac_trap(struct mlx5e_priv *priv, int trap_id, int tir_num);
  238. void mlx5e_remove_mac_trap(struct mlx5e_priv *priv);
  239. #endif /* __MLX5E_FLOW_STEER_H__ */