Skip to content

Commit a8d70a0

Browse files
Eli CohenSaeed Mahameed
authored andcommitted
net/mlx5: E-Switch, Disallow vlan/spoofcheck setup if not being esw manager
In smartnic env, if the host (PF) driver is not an e-switch manager, we are not allowed to apply eswitch ports setups such as vlan (VST), spoof-checks, min/max rate or state. Make sure we are eswitch manager when coming to issue these callbacks and err otherwise. Also fix the definition of ESW_ALLOWED to rely on eswitch_manager capability and on the vport_group_manger. Operations on the VF nic vport context, such as setting a mac or reading the vport counters are allowed to the PF in this scheme. The modify nic vport guid code was modified to omit checking the nic_vport_node_guid_modify eswitch capability. The reason for doing so is that modifying node guid requires vport group manager capability, and there's no need to check further capabilities. 1. set_vf_vlan - disallowed 2. set_vf_spoofchk - disallowed 3. set_vf_mac - allowed 4. get_vf_config - allowed 5. set_vf_trust - disallowed 6. set_vf_rate - disallowed 7. get_vf_stat - allowed 8. set_vf_link_state - disallowed Fixes: f942380 ('net/mlx5: E-Switch, Vport ingress/egress ACLs rules for spoofchk') Signed-off-by: Eli Cohen <eli@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com> Tested-by: Or Gerlitz <ogerlitz@mellanox.com>
1 parent aff2252 commit a8d70a0

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,17 +1594,15 @@ static void esw_disable_vport(struct mlx5_eswitch *esw, int vport_num)
15941594
}
15951595

15961596
/* Public E-Switch API */
1597-
#define ESW_ALLOWED(esw) ((esw) && MLX5_VPORT_MANAGER((esw)->dev))
1597+
#define ESW_ALLOWED(esw) ((esw) && MLX5_ESWITCH_MANAGER((esw)->dev))
1598+
15981599

15991600
int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
16001601
{
16011602
int err;
16021603
int i, enabled_events;
16031604

1604-
if (!ESW_ALLOWED(esw))
1605-
return 0;
1606-
1607-
if (!MLX5_ESWITCH_MANAGER(esw->dev) ||
1605+
if (!ESW_ALLOWED(esw) ||
16081606
!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, ft_support)) {
16091607
esw_warn(esw->dev, "E-Switch FDB is not supported, aborting ...\n");
16101608
return -EOPNOTSUPP;
@@ -1806,7 +1804,7 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
18061804
u64 node_guid;
18071805
int err = 0;
18081806

1809-
if (!ESW_ALLOWED(esw))
1807+
if (!MLX5_CAP_GEN(esw->dev, vport_group_manager))
18101808
return -EPERM;
18111809
if (!LEGAL_VPORT(esw, vport) || is_multicast_ether_addr(mac))
18121810
return -EINVAL;
@@ -1883,7 +1881,7 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
18831881
{
18841882
struct mlx5_vport *evport;
18851883

1886-
if (!ESW_ALLOWED(esw))
1884+
if (!MLX5_CAP_GEN(esw->dev, vport_group_manager))
18871885
return -EPERM;
18881886
if (!LEGAL_VPORT(esw, vport))
18891887
return -EINVAL;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,6 @@ int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
549549
return -EINVAL;
550550
if (!MLX5_CAP_GEN(mdev, vport_group_manager))
551551
return -EACCES;
552-
if (!MLX5_CAP_ESW(mdev, nic_vport_node_guid_modify))
553-
return -EOPNOTSUPP;
554552

555553
in = kvzalloc(inlen, GFP_KERNEL);
556554
if (!in)

0 commit comments

Comments
 (0)