File Index
Files and directories
Sign in
FILE

fs.h

File preview with syntax highlighting.

linux-6.19.14/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h C
  1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
  2/* Copyright (c) 2018 Mellanox Technologies. */
  3
  4#ifndef __MLX5E_FLOW_STEER_H__
  5#define __MLX5E_FLOW_STEER_H__
  6
  7#include "mod_hdr.h"
  8#include "lib/fs_ttc.h"
  9
 10struct mlx5e_post_act;
 11struct mlx5e_tc_table;
 12
 13enum {
 14	MLX5E_TC_FT_LEVEL = 0,
 15	MLX5E_TC_TTC_FT_LEVEL,
 16	MLX5E_TC_MISS_LEVEL,
 17};
 18
 19enum {
 20	MLX5E_TC_PRIO = 0,
 21	MLX5E_PROMISC_PRIO,
 22	MLX5E_NIC_PRIO,
 23};
 24
 25struct mlx5e_flow_table {
 26	int num_groups;
 27	struct mlx5_flow_table *t;
 28	struct mlx5_flow_group **g;
 29};
 30
 31struct mlx5e_l2_rule {
 32	u8  addr[ETH_ALEN + 2];
 33	struct mlx5_flow_handle *rule;
 34};
 35
 36#define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE)
 37
 38struct mlx5e_promisc_table {
 39	struct mlx5e_flow_table	ft;
 40	struct mlx5_flow_handle	*rule;
 41};
 42
 43/* Forward declaration and APIs to get private fields of vlan_table */
 44struct mlx5e_vlan_table;
 45unsigned long *mlx5e_vlan_get_active_svlans(struct mlx5e_vlan_table *vlan);
 46struct mlx5_flow_table *mlx5e_vlan_get_flowtable(struct mlx5e_vlan_table *vlan);
 47
 48struct mlx5e_l2_table {
 49	struct mlx5e_flow_table    ft;
 50	struct hlist_head          netdev_uc[MLX5E_L2_ADDR_HASH_SIZE];
 51	struct hlist_head          netdev_mc[MLX5E_L2_ADDR_HASH_SIZE];
 52	struct mlx5e_l2_rule	   broadcast;
 53	struct mlx5e_l2_rule	   allmulti;
 54	struct mlx5_flow_handle    *trap_rule;
 55	bool                       broadcast_enabled;
 56	bool                       allmulti_enabled;
 57	bool                       promisc_enabled;
 58};
 59
 60#define MLX5E_NUM_INDIR_TIRS (MLX5_NUM_INDIR_TIRS)
 61
 62#define MLX5_HASH_IP		(MLX5_HASH_FIELD_SEL_SRC_IP   |\
 63				 MLX5_HASH_FIELD_SEL_DST_IP)
 64#define MLX5_HASH_IP_L4PORTS	(MLX5_HASH_FIELD_SEL_SRC_IP   |\
 65				 MLX5_HASH_FIELD_SEL_DST_IP   |\
 66				 MLX5_HASH_FIELD_SEL_L4_SPORT |\
 67				 MLX5_HASH_FIELD_SEL_L4_DPORT)
 68#define MLX5_HASH_IP_IPSEC_SPI	(MLX5_HASH_FIELD_SEL_SRC_IP   |\
 69				 MLX5_HASH_FIELD_SEL_DST_IP   |\
 70				 MLX5_HASH_FIELD_SEL_IPSEC_SPI)
 71
 72/* NIC promisc FT level */
 73enum {
 74	MLX5E_PROMISC_FT_LEVEL,
 75};
 76
 77/* NIC prio FTS */
 78enum {
 79	MLX5E_VLAN_FT_LEVEL,
 80	MLX5E_L2_FT_LEVEL,
 81	MLX5E_TTC_FT_LEVEL,
 82	MLX5E_INNER_TTC_FT_LEVEL,
 83	MLX5E_FS_TT_UDP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
 84	MLX5E_FS_TT_ANY_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
 85#ifdef CONFIG_MLX5_EN_TLS
 86	MLX5E_ACCEL_FS_TCP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
 87#endif
 88#ifdef CONFIG_MLX5_EN_ARFS
 89	MLX5E_ARFS_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
 90#endif
 91#if defined(CONFIG_MLX5_EN_IPSEC) || defined(CONFIG_MLX5_EN_PSP)
 92	MLX5E_ACCEL_FS_ESP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
 93	MLX5E_ACCEL_FS_ESP_FT_ERR_LEVEL,
 94	MLX5E_ACCEL_FS_POL_FT_LEVEL,
 95	MLX5E_ACCEL_FS_POL_MISS_FT_LEVEL,
 96	MLX5E_ACCEL_FS_ESP_FT_ROCE_LEVEL,
 97#endif
 98};
 99
100struct mlx5e_flow_steering;
101struct mlx5e_rx_res;
102
103#ifdef CONFIG_MLX5_EN_ARFS
104struct mlx5e_arfs_tables;
105
106int mlx5e_arfs_create_tables(struct mlx5e_flow_steering *fs,
107			     struct mlx5e_rx_res *rx_res, bool ntuple);
108void mlx5e_arfs_destroy_tables(struct mlx5e_flow_steering *fs, bool ntuple);
109int mlx5e_arfs_enable(struct mlx5e_flow_steering *fs);
110int mlx5e_arfs_disable(struct mlx5e_flow_steering *fs);
111int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
112			u16 rxq_index, u32 flow_id);
113#else
114static inline int mlx5e_arfs_create_tables(struct mlx5e_flow_steering *fs,
115					   struct mlx5e_rx_res *rx_res, bool ntuple)
116{ return 0; }
117static inline void mlx5e_arfs_destroy_tables(struct mlx5e_flow_steering *fs, bool ntuple) {}
118static inline int mlx5e_arfs_enable(struct mlx5e_flow_steering *fs)
119{ return -EOPNOTSUPP; }
120static inline int mlx5e_arfs_disable(struct mlx5e_flow_steering *fs)
121{ return -EOPNOTSUPP; }
122#endif
123
124#ifdef CONFIG_MLX5_EN_TLS
125struct mlx5e_accel_fs_tcp;
126#endif
127
128struct mlx5e_profile;
129struct mlx5e_fs_udp;
130struct mlx5e_fs_any;
131struct mlx5e_ptp_fs;
132
133void mlx5e_set_ttc_params(struct mlx5e_flow_steering *fs,
134			  struct mlx5e_rx_res *rx_res,
135			  struct ttc_params *ttc_params, bool tunnel,
136			  bool ipsec_rss);
137
138void mlx5e_destroy_ttc_table(struct mlx5e_flow_steering *fs);
139int mlx5e_create_ttc_table(struct mlx5e_flow_steering  *fs,
140			   struct mlx5e_rx_res *rx_res);
141
142void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
143
144void mlx5e_enable_cvlan_filter(struct mlx5e_flow_steering *fs, bool promisc);
145void mlx5e_disable_cvlan_filter(struct mlx5e_flow_steering *fs, bool promisc);
146
147int mlx5e_create_flow_steering(struct mlx5e_flow_steering *fs,
148			       struct mlx5e_rx_res *rx_res,
149			       const struct mlx5e_profile *profile,
150			       struct net_device *netdev);
151void mlx5e_destroy_flow_steering(struct mlx5e_flow_steering *fs, bool ntuple,
152				 const struct mlx5e_profile *profile);
153
154struct mlx5e_flow_steering *mlx5e_fs_init(const struct mlx5e_profile *profile,
155					  struct mlx5_core_dev *mdev,
156					  bool state_destroy,
157					  struct dentry *dfs_root);
158void mlx5e_fs_cleanup(struct mlx5e_flow_steering *fs);
159struct mlx5e_vlan_table *mlx5e_fs_get_vlan(struct mlx5e_flow_steering *fs);
160struct mlx5e_tc_table *mlx5e_fs_get_tc(struct mlx5e_flow_steering *fs);
161struct mlx5e_l2_table *mlx5e_fs_get_l2(struct mlx5e_flow_steering *fs);
162struct mlx5_flow_namespace *mlx5e_fs_get_ns(struct mlx5e_flow_steering *fs, bool egress);
163void mlx5e_fs_set_ns(struct mlx5e_flow_steering *fs, struct mlx5_flow_namespace *ns, bool egress);
164
165static inline bool mlx5e_fs_has_arfs(struct net_device *netdev)
166{
167	return IS_ENABLED(CONFIG_MLX5_EN_ARFS) &&
168		netdev->hw_features & NETIF_F_NTUPLE;
169}
170
171static inline bool mlx5e_fs_want_arfs(struct net_device *netdev)
172{
173	return IS_ENABLED(CONFIG_MLX5_EN_ARFS) &&
174		netdev->features & NETIF_F_NTUPLE;
175}
176
177#ifdef CONFIG_MLX5_EN_RXNFC
178struct mlx5e_ethtool_steering *mlx5e_fs_get_ethtool(struct mlx5e_flow_steering *fs);
179#endif
180struct mlx5_ttc_table *mlx5e_fs_get_ttc(struct mlx5e_flow_steering *fs, bool inner);
181void mlx5e_fs_set_ttc(struct mlx5e_flow_steering *fs, struct mlx5_ttc_table *ttc, bool inner);
182#ifdef CONFIG_MLX5_EN_ARFS
183struct mlx5e_arfs_tables *mlx5e_fs_get_arfs(struct mlx5e_flow_steering *fs);
184void mlx5e_fs_set_arfs(struct mlx5e_flow_steering *fs, struct mlx5e_arfs_tables *arfs);
185#endif
186struct mlx5e_ptp_fs *mlx5e_fs_get_ptp(struct mlx5e_flow_steering *fs);
187void mlx5e_fs_set_ptp(struct mlx5e_flow_steering *fs, struct mlx5e_ptp_fs *ptp_fs);
188struct mlx5e_fs_any *mlx5e_fs_get_any(struct mlx5e_flow_steering *fs);
189void mlx5e_fs_set_any(struct mlx5e_flow_steering *fs, struct mlx5e_fs_any *any);
190struct mlx5e_fs_udp *mlx5e_fs_get_udp(struct mlx5e_flow_steering *fs);
191void mlx5e_fs_set_udp(struct mlx5e_flow_steering *fs, struct mlx5e_fs_udp *udp);
192#ifdef CONFIG_MLX5_EN_TLS
193struct mlx5e_accel_fs_tcp *mlx5e_fs_get_accel_tcp(struct mlx5e_flow_steering *fs);
194void mlx5e_fs_set_accel_tcp(struct mlx5e_flow_steering *fs, struct mlx5e_accel_fs_tcp *accel_tcp);
195#endif
196void mlx5e_fs_set_state_destroy(struct mlx5e_flow_steering *fs, bool state_destroy);
197void mlx5e_fs_set_vlan_strip_disable(struct mlx5e_flow_steering *fs, bool vlan_strip_disable);
198
199struct mlx5_core_dev *mlx5e_fs_get_mdev(struct mlx5e_flow_steering *fs);
200int mlx5e_add_vlan_trap(struct mlx5e_flow_steering *fs, int  trap_id, int tir_num);
201void mlx5e_remove_vlan_trap(struct mlx5e_flow_steering *fs);
202int mlx5e_add_mac_trap(struct mlx5e_flow_steering *fs, int  trap_id, int tir_num);
203void mlx5e_remove_mac_trap(struct mlx5e_flow_steering *fs);
204void mlx5e_fs_set_rx_mode_work(struct mlx5e_flow_steering *fs, struct net_device *netdev);
205int mlx5e_fs_vlan_rx_add_vid(struct mlx5e_flow_steering *fs,
206			     struct net_device *netdev,
207			     __be16 proto, u16 vid);
208int mlx5e_fs_vlan_rx_kill_vid(struct mlx5e_flow_steering *fs,
209			      struct net_device *netdev,
210			      __be16 proto, u16 vid);
211void mlx5e_fs_init_l2_addr(struct mlx5e_flow_steering *fs, struct net_device *netdev);
212
213struct dentry *mlx5e_fs_get_debugfs_root(struct mlx5e_flow_steering *fs);
214
215#define fs_err(fs, fmt, ...) \
216	mlx5_core_err(mlx5e_fs_get_mdev(fs), fmt, ##__VA_ARGS__)
217
218#define fs_dbg(fs, fmt, ...) \
219	mlx5_core_dbg(mlx5e_fs_get_mdev(fs), fmt, ##__VA_ARGS__)
220
221#define fs_warn(fs, fmt, ...) \
222	mlx5_core_warn(mlx5e_fs_get_mdev(fs), fmt, ##__VA_ARGS__)
223
224#define fs_warn_once(fs, fmt, ...) \
225	mlx5_core_warn_once(mlx5e_fs_get_mdev(fs), fmt, ##__VA_ARGS__)
226
227#endif /* __MLX5E_FLOW_STEER_H__ */
228
~/ Read-only file preview.