Skip to content

Commit c116c6e

Browse files
ogerlitzdavem330
authored andcommitted
net/mlx5: E-Switch, Add offloads table
Belongs to the NIC offloads name-space, and to be used as part of the SRIOV offloads logic to steer packets that hit the e-switch miss rule to the TIR of the relevant VF representor. Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent acbc200 commit c116c6e

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ enum {
155155
SRIOV_OFFLOADS
156156
};
157157

158+
struct mlx5_esw_offload {
159+
struct mlx5_flow_table *ft_offloads;
160+
};
161+
158162
struct mlx5_eswitch {
159163
struct mlx5_core_dev *dev;
160164
struct mlx5_l2_table l2_table;
@@ -169,6 +173,7 @@ struct mlx5_eswitch {
169173
*/
170174
struct mutex state_lock;
171175
struct esw_mc_addr *mc_promisc;
176+
struct mlx5_esw_offload offloads;
172177
int mode;
173178
};
174179

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,34 @@ void esw_destroy_offloads_fdb_table(struct mlx5_eswitch *esw)
212212

213213
mlx5_destroy_flow_table(esw->fdb_table.fdb);
214214
}
215+
216+
static int esw_create_offloads_table(struct mlx5_eswitch *esw)
217+
{
218+
struct mlx5_flow_namespace *ns;
219+
struct mlx5_flow_table *ft_offloads;
220+
struct mlx5_core_dev *dev = esw->dev;
221+
int err = 0;
222+
223+
ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_OFFLOADS);
224+
if (!ns) {
225+
esw_warn(esw->dev, "Failed to get offloads flow namespace\n");
226+
return -ENOMEM;
227+
}
228+
229+
ft_offloads = mlx5_create_flow_table(ns, 0, dev->priv.sriov.num_vfs + 2, 0);
230+
if (IS_ERR(ft_offloads)) {
231+
err = PTR_ERR(ft_offloads);
232+
esw_warn(esw->dev, "Failed to create offloads table, err %d\n", err);
233+
return err;
234+
}
235+
236+
esw->offloads.ft_offloads = ft_offloads;
237+
return 0;
238+
}
239+
240+
static void esw_destroy_offloads_table(struct mlx5_eswitch *esw)
241+
{
242+
struct mlx5_esw_offload *offloads = &esw->offloads;
243+
244+
mlx5_destroy_flow_table(offloads->ft_offloads);
245+
}

0 commit comments

Comments
 (0)