Skip to content

Commit 1cd5ea4

Browse files
committed
Merge tag 'mlx5-updates-2022-08-22' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
mlx5-updates-2022-08-22 Roi Dayan Says: =============== Add support for SF tunnel offload Mlx5 driver only supports VF tunnel offload. To add support for SF tunnel offload the driver needs to: 1. Add send-to-vport metadata matching rules like done for VFs. 2. Set an indirect table for SF vport, same as VF vport. info smaller sub functions for better maintainability. rules from esw init phase to representor load phase. SFs could be created after esw initialized and thus the send-to-vport meta rules would not be created for those SFs. By moving the creation of the rules to representor load phase we ensure creating the rules also for SFs created later. =============== Lama Kayal Says: ================ Make flow steering API loosely coupled from mlx5e_priv, in a manner to introduce more readable and maintainable modules. Make TC's private, let mlx5e_flow_steering struct be dynamically allocated, and introduce its API to maintain the code via setters and getters instead of publicly exposing it. Introduce flow steering debug macros to provide an elegant finish to the decoupled flow steering API, where errors related to flow steering shall be reported via them. All flow steering related files will drop any coupling to mlx5e_priv, instead they will get the relevant members as input. Among these, fs_tt_redirect, fs_tc, and arfs. ================
2 parents fef5de7 + 72e0bcd commit 1cd5ea4

29 files changed

+1246
-765
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -856,11 +856,6 @@ enum {
856856
MLX5E_STATE_XDP_ACTIVE,
857857
};
858858

859-
enum {
860-
MLX5E_TC_PRIO = 0,
861-
MLX5E_NIC_PRIO
862-
};
863-
864859
struct mlx5e_modify_sq_param {
865860
int curr_state;
866861
int next_state;

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

Lines changed: 80 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@
88
#include "lib/fs_ttc.h"
99

1010
struct mlx5e_post_act;
11+
struct mlx5e_tc_table;
1112

1213
enum {
1314
MLX5E_TC_FT_LEVEL = 0,
1415
MLX5E_TC_TTC_FT_LEVEL,
1516
MLX5E_TC_MISS_LEVEL,
1617
};
1718

19+
enum {
20+
MLX5E_TC_PRIO = 0,
21+
MLX5E_NIC_PRIO
22+
};
23+
1824
struct mlx5e_flow_table {
1925
int num_groups;
2026
struct mlx5_flow_table *t;
@@ -83,54 +89,28 @@ enum {
8389
#endif
8490
};
8591

86-
struct mlx5e_priv;
87-
88-
#ifdef CONFIG_MLX5_EN_RXNFC
89-
90-
struct mlx5e_ethtool_table {
91-
struct mlx5_flow_table *ft;
92-
int num_rules;
93-
};
94-
95-
#define ETHTOOL_NUM_L3_L4_FTS 7
96-
#define ETHTOOL_NUM_L2_FTS 4
97-
98-
struct mlx5e_ethtool_steering {
99-
struct mlx5e_ethtool_table l3_l4_ft[ETHTOOL_NUM_L3_L4_FTS];
100-
struct mlx5e_ethtool_table l2_ft[ETHTOOL_NUM_L2_FTS];
101-
struct list_head rules;
102-
int tot_num_rules;
103-
};
104-
105-
void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv);
106-
void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv);
107-
int mlx5e_ethtool_set_rxnfc(struct mlx5e_priv *priv, struct ethtool_rxnfc *cmd);
108-
int mlx5e_ethtool_get_rxnfc(struct mlx5e_priv *priv,
109-
struct ethtool_rxnfc *info, u32 *rule_locs);
110-
#else
111-
static inline void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv) { }
112-
static inline void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv) { }
113-
static inline int mlx5e_ethtool_set_rxnfc(struct mlx5e_priv *priv, struct ethtool_rxnfc *cmd)
114-
{ return -EOPNOTSUPP; }
115-
static inline int mlx5e_ethtool_get_rxnfc(struct mlx5e_priv *priv,
116-
struct ethtool_rxnfc *info, u32 *rule_locs)
117-
{ return -EOPNOTSUPP; }
118-
#endif /* CONFIG_MLX5_EN_RXNFC */
92+
struct mlx5e_flow_steering;
93+
struct mlx5e_rx_res;
11994

12095
#ifdef CONFIG_MLX5_EN_ARFS
12196
struct mlx5e_arfs_tables;
12297

123-
int mlx5e_arfs_create_tables(struct mlx5e_priv *priv);
124-
void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv);
125-
int mlx5e_arfs_enable(struct mlx5e_priv *priv);
126-
int mlx5e_arfs_disable(struct mlx5e_priv *priv);
98+
int mlx5e_arfs_create_tables(struct mlx5e_flow_steering *fs,
99+
struct mlx5e_rx_res *rx_res, bool ntuple);
100+
void mlx5e_arfs_destroy_tables(struct mlx5e_flow_steering *fs, bool ntuple);
101+
int mlx5e_arfs_enable(struct mlx5e_flow_steering *fs);
102+
int mlx5e_arfs_disable(struct mlx5e_flow_steering *fs);
127103
int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
128104
u16 rxq_index, u32 flow_id);
129105
#else
130-
static inline int mlx5e_arfs_create_tables(struct mlx5e_priv *priv) { return 0; }
131-
static inline void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv) {}
132-
static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv) { return -EOPNOTSUPP; }
133-
static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv) { return -EOPNOTSUPP; }
106+
static inline int mlx5e_arfs_create_tables(struct mlx5e_flow_steering *fs,
107+
struct mlx5e_rx_res *rx_res, bool ntuple)
108+
{ return 0; }
109+
static inline void mlx5e_arfs_destroy_tables(struct mlx5e_flow_steering *fs, bool ntuple) {}
110+
static inline int mlx5e_arfs_enable(struct mlx5e_flow_steering *fs)
111+
{ return -EOPNOTSUPP; }
112+
static inline int mlx5e_arfs_disable(struct mlx5e_flow_steering *fs)
113+
{ return -EOPNOTSUPP; }
134114
#endif
135115

136116
#ifdef CONFIG_MLX5_EN_TLS
@@ -142,54 +122,63 @@ struct mlx5e_fs_udp;
142122
struct mlx5e_fs_any;
143123
struct mlx5e_ptp_fs;
144124

145-
struct mlx5e_flow_steering {
146-
bool state_destroy;
147-
bool vlan_strip_disable;
148-
struct mlx5_core_dev *mdev;
149-
struct mlx5_flow_namespace *ns;
150-
#ifdef CONFIG_MLX5_EN_RXNFC
151-
struct mlx5e_ethtool_steering ethtool;
152-
#endif
153-
struct mlx5e_tc_table *tc;
154-
struct mlx5e_promisc_table promisc;
155-
struct mlx5e_vlan_table *vlan;
156-
struct mlx5e_l2_table l2;
157-
struct mlx5_ttc_table *ttc;
158-
struct mlx5_ttc_table *inner_ttc;
159-
#ifdef CONFIG_MLX5_EN_ARFS
160-
struct mlx5e_arfs_tables *arfs;
161-
#endif
162-
#ifdef CONFIG_MLX5_EN_TLS
163-
struct mlx5e_accel_fs_tcp *accel_tcp;
164-
#endif
165-
struct mlx5e_fs_udp *udp;
166-
struct mlx5e_fs_any *any;
167-
struct mlx5e_ptp_fs *ptp_fs;
168-
};
169-
170-
void mlx5e_set_ttc_params(struct mlx5e_priv *priv,
125+
void mlx5e_set_ttc_params(struct mlx5e_flow_steering *fs,
126+
struct mlx5e_rx_res *rx_res,
171127
struct ttc_params *ttc_params, bool tunnel);
172128

173-
void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv);
174-
int mlx5e_create_ttc_table(struct mlx5e_priv *priv);
129+
void mlx5e_destroy_ttc_table(struct mlx5e_flow_steering *fs);
130+
int mlx5e_create_ttc_table(struct mlx5e_flow_steering *fs,
131+
struct mlx5e_rx_res *rx_res);
175132

176133
void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
177134

178-
void mlx5e_enable_cvlan_filter(struct mlx5e_priv *priv);
179-
void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv);
135+
void mlx5e_enable_cvlan_filter(struct mlx5e_flow_steering *fs, bool promisc);
136+
void mlx5e_disable_cvlan_filter(struct mlx5e_flow_steering *fs, bool promisc);
180137

181-
int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
182-
void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);
138+
int mlx5e_create_flow_steering(struct mlx5e_flow_steering *fs,
139+
struct mlx5e_rx_res *rx_res,
140+
const struct mlx5e_profile *profile,
141+
struct net_device *netdev);
142+
void mlx5e_destroy_flow_steering(struct mlx5e_flow_steering *fs, bool ntuple,
143+
const struct mlx5e_profile *profile);
183144

184145
struct mlx5e_flow_steering *mlx5e_fs_init(const struct mlx5e_profile *profile,
185146
struct mlx5_core_dev *mdev,
186147
bool state_destroy);
187148
void mlx5e_fs_cleanup(struct mlx5e_flow_steering *fs);
188-
189-
int mlx5e_add_vlan_trap(struct mlx5e_priv *priv, int trap_id, int tir_num);
190-
void mlx5e_remove_vlan_trap(struct mlx5e_priv *priv);
191-
int mlx5e_add_mac_trap(struct mlx5e_priv *priv, int trap_id, int tir_num);
192-
void mlx5e_remove_mac_trap(struct mlx5e_priv *priv);
149+
struct mlx5e_vlan_table *mlx5e_fs_get_vlan(struct mlx5e_flow_steering *fs);
150+
void mlx5e_fs_set_tc(struct mlx5e_flow_steering *fs, struct mlx5e_tc_table *tc);
151+
struct mlx5e_tc_table *mlx5e_fs_get_tc(struct mlx5e_flow_steering *fs);
152+
struct mlx5e_l2_table *mlx5e_fs_get_l2(struct mlx5e_flow_steering *fs);
153+
struct mlx5_flow_namespace *mlx5e_fs_get_ns(struct mlx5e_flow_steering *fs, bool egress);
154+
void mlx5e_fs_set_ns(struct mlx5e_flow_steering *fs, struct mlx5_flow_namespace *ns, bool egress);
155+
#ifdef CONFIG_MLX5_EN_RXNFC
156+
struct mlx5e_ethtool_steering *mlx5e_fs_get_ethtool(struct mlx5e_flow_steering *fs);
157+
#endif
158+
struct mlx5_ttc_table *mlx5e_fs_get_ttc(struct mlx5e_flow_steering *fs, bool inner);
159+
void mlx5e_fs_set_ttc(struct mlx5e_flow_steering *fs, struct mlx5_ttc_table *ttc, bool inner);
160+
#ifdef CONFIG_MLX5_EN_ARFS
161+
struct mlx5e_arfs_tables *mlx5e_fs_get_arfs(struct mlx5e_flow_steering *fs);
162+
void mlx5e_fs_set_arfs(struct mlx5e_flow_steering *fs, struct mlx5e_arfs_tables *arfs);
163+
#endif
164+
struct mlx5e_ptp_fs *mlx5e_fs_get_ptp(struct mlx5e_flow_steering *fs);
165+
void mlx5e_fs_set_ptp(struct mlx5e_flow_steering *fs, struct mlx5e_ptp_fs *ptp_fs);
166+
struct mlx5e_fs_any *mlx5e_fs_get_any(struct mlx5e_flow_steering *fs);
167+
void mlx5e_fs_set_any(struct mlx5e_flow_steering *fs, struct mlx5e_fs_any *any);
168+
struct mlx5e_fs_udp *mlx5e_fs_get_udp(struct mlx5e_flow_steering *fs);
169+
void mlx5e_fs_set_udp(struct mlx5e_flow_steering *fs, struct mlx5e_fs_udp *udp);
170+
#ifdef CONFIG_MLX5_EN_TLS
171+
struct mlx5e_accel_fs_tcp *mlx5e_fs_get_accel_tcp(struct mlx5e_flow_steering *fs);
172+
void mlx5e_fs_set_accel_tcp(struct mlx5e_flow_steering *fs, struct mlx5e_accel_fs_tcp *accel_tcp);
173+
#endif
174+
void mlx5e_fs_set_state_destroy(struct mlx5e_flow_steering *fs, bool state_destroy);
175+
void mlx5e_fs_set_vlan_strip_disable(struct mlx5e_flow_steering *fs, bool vlan_strip_disable);
176+
177+
struct mlx5_core_dev *mlx5e_fs_get_mdev(struct mlx5e_flow_steering *fs);
178+
int mlx5e_add_vlan_trap(struct mlx5e_flow_steering *fs, int trap_id, int tir_num);
179+
void mlx5e_remove_vlan_trap(struct mlx5e_flow_steering *fs);
180+
int mlx5e_add_mac_trap(struct mlx5e_flow_steering *fs, int trap_id, int tir_num);
181+
void mlx5e_remove_mac_trap(struct mlx5e_flow_steering *fs);
193182
void mlx5e_fs_set_rx_mode_work(struct mlx5e_flow_steering *fs, struct net_device *netdev);
194183
int mlx5e_fs_vlan_rx_add_vid(struct mlx5e_flow_steering *fs,
195184
struct net_device *netdev,
@@ -198,5 +187,18 @@ int mlx5e_fs_vlan_rx_kill_vid(struct mlx5e_flow_steering *fs,
198187
struct net_device *netdev,
199188
__be16 proto, u16 vid);
200189
void mlx5e_fs_init_l2_addr(struct mlx5e_flow_steering *fs, struct net_device *netdev);
190+
191+
#define fs_err(fs, fmt, ...) \
192+
mlx5_core_err(mlx5e_fs_get_mdev(fs), fmt, ##__VA_ARGS__)
193+
194+
#define fs_dbg(fs, fmt, ...) \
195+
mlx5_core_dbg(mlx5e_fs_get_mdev(fs), fmt, ##__VA_ARGS__)
196+
197+
#define fs_warn(fs, fmt, ...) \
198+
mlx5_core_warn(mlx5e_fs_get_mdev(fs), fmt, ##__VA_ARGS__)
199+
200+
#define fs_warn_once(fs, fmt, ...) \
201+
mlx5_core_warn_once(mlx5e_fs_get_mdev(fs), fmt, ##__VA_ARGS__)
202+
201203
#endif /* __MLX5E_FLOW_STEER_H__ */
202204

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2+
/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. */
3+
4+
#ifndef __MLX5E_FS_ETHTOOL_H__
5+
#define __MLX5E_FS_ETHTOOL_H__
6+
7+
struct mlx5e_priv;
8+
struct mlx5e_ethtool_steering;
9+
#ifdef CONFIG_MLX5_EN_RXNFC
10+
int mlx5e_ethtool_alloc(struct mlx5e_ethtool_steering **ethtool);
11+
void mlx5e_ethtool_free(struct mlx5e_ethtool_steering *ethtool);
12+
void mlx5e_ethtool_init_steering(struct mlx5e_flow_steering *fs);
13+
void mlx5e_ethtool_cleanup_steering(struct mlx5e_flow_steering *fs);
14+
int mlx5e_ethtool_set_rxnfc(struct mlx5e_priv *priv, struct ethtool_rxnfc *cmd);
15+
int mlx5e_ethtool_get_rxnfc(struct mlx5e_priv *priv,
16+
struct ethtool_rxnfc *info, u32 *rule_locs);
17+
#else
18+
static inline int mlx5e_ethtool_alloc(struct mlx5e_ethtool_steering **ethtool)
19+
{ return 0; }
20+
static inline void mlx5e_ethtool_free(struct mlx5e_ethtool_steering *ethtool) { }
21+
static inline void mlx5e_ethtool_init_steering(struct mlx5e_flow_steering *fs) { }
22+
static inline void mlx5e_ethtool_cleanup_steering(struct mlx5e_flow_steering *fs) { }
23+
static inline int mlx5e_ethtool_set_rxnfc(struct mlx5e_priv *priv, struct ethtool_rxnfc *cmd)
24+
{ return -EOPNOTSUPP; }
25+
static inline int mlx5e_ethtool_get_rxnfc(struct mlx5e_priv *priv,
26+
struct ethtool_rxnfc *info, u32 *rule_locs)
27+
{ return -EOPNOTSUPP; }
28+
#endif
29+
#endif

0 commit comments

Comments
 (0)