Commit 748da30b authored by Vu Pham's avatar Vu Pham Committed by Saeed Mahameed

net/mlx5: E-switch, Offloads shift ACL programming during enable/disable vport

Currently legacy mode enables ACL while enabling vport, while offloads
mode enable ACL when moving to offloads mode.

Bring consistency to both modes by enabling/disabling ACL when
enabling/disabling a vport.

It also eliminates creating ingress ACL table on unused ECPF vport in
offloads mode.
Signed-off-by: default avatarVu Pham <vuhuong@mellanox.com>
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 89a0f1fb
...@@ -1722,8 +1722,8 @@ static int esw_vport_setup_acl(struct mlx5_eswitch *esw, ...@@ -1722,8 +1722,8 @@ static int esw_vport_setup_acl(struct mlx5_eswitch *esw,
{ {
if (esw->mode == MLX5_ESWITCH_LEGACY) if (esw->mode == MLX5_ESWITCH_LEGACY)
return esw_vport_create_legacy_acl_tables(esw, vport); return esw_vport_create_legacy_acl_tables(esw, vport);
else
return 0; return esw_vport_create_offloads_acl_tables(esw, vport);
} }
static void esw_vport_destroy_legacy_acl_tables(struct mlx5_eswitch *esw, static void esw_vport_destroy_legacy_acl_tables(struct mlx5_eswitch *esw,
...@@ -1747,6 +1747,8 @@ static void esw_vport_cleanup_acl(struct mlx5_eswitch *esw, ...@@ -1747,6 +1747,8 @@ static void esw_vport_cleanup_acl(struct mlx5_eswitch *esw,
{ {
if (esw->mode == MLX5_ESWITCH_LEGACY) if (esw->mode == MLX5_ESWITCH_LEGACY)
esw_vport_destroy_legacy_acl_tables(esw, vport); esw_vport_destroy_legacy_acl_tables(esw, vport);
else
esw_vport_destroy_offloads_acl_tables(esw, vport);
} }
static int esw_enable_vport(struct mlx5_eswitch *esw, struct mlx5_vport *vport, static int esw_enable_vport(struct mlx5_eswitch *esw, struct mlx5_vport *vport,
......
...@@ -614,6 +614,13 @@ mlx5_eswitch_enable_pf_vf_vports(struct mlx5_eswitch *esw, ...@@ -614,6 +614,13 @@ mlx5_eswitch_enable_pf_vf_vports(struct mlx5_eswitch *esw,
enum mlx5_eswitch_vport_event enabled_events); enum mlx5_eswitch_vport_event enabled_events);
void mlx5_eswitch_disable_pf_vf_vports(struct mlx5_eswitch *esw); void mlx5_eswitch_disable_pf_vf_vports(struct mlx5_eswitch *esw);
int
esw_vport_create_offloads_acl_tables(struct mlx5_eswitch *esw,
struct mlx5_vport *vport);
void
esw_vport_destroy_offloads_acl_tables(struct mlx5_eswitch *esw,
struct mlx5_vport *vport);
#else /* CONFIG_MLX5_ESWITCH */ #else /* CONFIG_MLX5_ESWITCH */
/* eswitch API stubs */ /* eswitch API stubs */
static inline int mlx5_eswitch_init(struct mlx5_core_dev *dev) { return 0; } static inline int mlx5_eswitch_init(struct mlx5_core_dev *dev) { return 0; }
......
...@@ -1950,7 +1950,7 @@ esw_check_vport_match_metadata_supported(const struct mlx5_eswitch *esw) ...@@ -1950,7 +1950,7 @@ esw_check_vport_match_metadata_supported(const struct mlx5_eswitch *esw)
return true; return true;
} }
static int int
esw_vport_create_offloads_acl_tables(struct mlx5_eswitch *esw, esw_vport_create_offloads_acl_tables(struct mlx5_eswitch *esw,
struct mlx5_vport *vport) struct mlx5_vport *vport)
{ {
...@@ -1968,7 +1968,7 @@ esw_vport_create_offloads_acl_tables(struct mlx5_eswitch *esw, ...@@ -1968,7 +1968,7 @@ esw_vport_create_offloads_acl_tables(struct mlx5_eswitch *esw,
return err; return err;
} }
static void void
esw_vport_destroy_offloads_acl_tables(struct mlx5_eswitch *esw, esw_vport_destroy_offloads_acl_tables(struct mlx5_eswitch *esw,
struct mlx5_vport *vport) struct mlx5_vport *vport)
{ {
...@@ -1976,43 +1976,27 @@ esw_vport_destroy_offloads_acl_tables(struct mlx5_eswitch *esw, ...@@ -1976,43 +1976,27 @@ esw_vport_destroy_offloads_acl_tables(struct mlx5_eswitch *esw,
esw_vport_disable_ingress_acl(esw, vport); esw_vport_disable_ingress_acl(esw, vport);
} }
static int esw_create_offloads_acl_tables(struct mlx5_eswitch *esw) static int esw_create_uplink_offloads_acl_tables(struct mlx5_eswitch *esw)
{ {
struct mlx5_vport *vport; struct mlx5_vport *vport;
int i, j;
int err; int err;
if (esw_check_vport_match_metadata_supported(esw)) if (esw_check_vport_match_metadata_supported(esw))
esw->flags |= MLX5_ESWITCH_VPORT_MATCH_METADATA; esw->flags |= MLX5_ESWITCH_VPORT_MATCH_METADATA;
mlx5_esw_for_all_vports(esw, i, vport) { vport = mlx5_eswitch_get_vport(esw, MLX5_VPORT_UPLINK);
err = esw_vport_create_offloads_acl_tables(esw, vport); err = esw_vport_create_offloads_acl_tables(esw, vport);
if (err) if (err)
goto err_acl_table; esw->flags &= ~MLX5_ESWITCH_VPORT_MATCH_METADATA;
}
if (mlx5_eswitch_vport_match_metadata_enabled(esw))
esw_info(esw->dev, "Use metadata reg_c as source vport to match\n");
return 0;
err_acl_table:
for (j = MLX5_VPORT_PF; j < i; j++) {
vport = &esw->vports[j];
esw_vport_destroy_offloads_acl_tables(esw, vport);
}
return err; return err;
} }
static void esw_destroy_offloads_acl_tables(struct mlx5_eswitch *esw) static void esw_destroy_uplink_offloads_acl_tables(struct mlx5_eswitch *esw)
{ {
struct mlx5_vport *vport; struct mlx5_vport *vport;
int i;
mlx5_esw_for_all_vports(esw, i, vport)
esw_vport_destroy_offloads_acl_tables(esw, vport);
vport = mlx5_eswitch_get_vport(esw, MLX5_VPORT_UPLINK);
esw_vport_destroy_offloads_acl_tables(esw, vport);
esw->flags &= ~MLX5_ESWITCH_VPORT_MATCH_METADATA; esw->flags &= ~MLX5_ESWITCH_VPORT_MATCH_METADATA;
} }
...@@ -2030,7 +2014,7 @@ static int esw_offloads_steering_init(struct mlx5_eswitch *esw) ...@@ -2030,7 +2014,7 @@ static int esw_offloads_steering_init(struct mlx5_eswitch *esw)
memset(&esw->fdb_table.offloads, 0, sizeof(struct offloads_fdb)); memset(&esw->fdb_table.offloads, 0, sizeof(struct offloads_fdb));
mutex_init(&esw->fdb_table.offloads.fdb_prio_lock); mutex_init(&esw->fdb_table.offloads.fdb_prio_lock);
err = esw_create_offloads_acl_tables(esw); err = esw_create_uplink_offloads_acl_tables(esw);
if (err) if (err)
return err; return err;
...@@ -2055,7 +2039,7 @@ static int esw_offloads_steering_init(struct mlx5_eswitch *esw) ...@@ -2055,7 +2039,7 @@ static int esw_offloads_steering_init(struct mlx5_eswitch *esw)
esw_destroy_offloads_fdb_tables(esw); esw_destroy_offloads_fdb_tables(esw);
create_fdb_err: create_fdb_err:
esw_destroy_offloads_acl_tables(esw); esw_destroy_uplink_offloads_acl_tables(esw);
return err; return err;
} }
...@@ -2065,7 +2049,7 @@ static void esw_offloads_steering_cleanup(struct mlx5_eswitch *esw) ...@@ -2065,7 +2049,7 @@ static void esw_offloads_steering_cleanup(struct mlx5_eswitch *esw)
esw_destroy_vport_rx_group(esw); esw_destroy_vport_rx_group(esw);
esw_destroy_offloads_table(esw); esw_destroy_offloads_table(esw);
esw_destroy_offloads_fdb_tables(esw); esw_destroy_offloads_fdb_tables(esw);
esw_destroy_offloads_acl_tables(esw); esw_destroy_uplink_offloads_acl_tables(esw);
} }
static void static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment