You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
4.4 KiB
140 lines
4.4 KiB
From 9558c167e7bcfe7b5ef5a688054f274e2083c0ce Mon Sep 17 00:00:00 2001
|
|
From: Alaa Hleihel <ahleihel@redhat.com>
|
|
Date: Tue, 19 May 2020 07:49:32 -0400
|
|
Subject: [PATCH 269/312] [netdrv] net/mlx5: Split eswitch mode check to
|
|
different helper function
|
|
|
|
Message-id: <20200519074934.6303-62-ahleihel@redhat.com>
|
|
Patchwork-id: 310565
|
|
Patchwork-instance: patchwork
|
|
O-Subject: [RHEL8.3 BZ 1663246 61/63] net/mlx5: Split eswitch mode check to different helper function
|
|
Bugzilla: 1835595 1663246
|
|
RH-Acked-by: Marcelo Leitner <mleitner@redhat.com>
|
|
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
|
|
RH-Acked-by: John Linville <linville@redhat.com>
|
|
RH-Acked-by: Ivan Vecera <ivecera@redhat.com>
|
|
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
|
|
RH-Acked-by: Kamal Heib <kheib@redhat.com>
|
|
|
|
Bugzilla: http://bugzilla.redhat.com/1835595
|
|
Bugzilla: http://bugzilla.redhat.com/1663246
|
|
Upstream: v5.7-rc1
|
|
|
|
commit ae24432cbc2b2d7f5a8d636194422604b0b4c4f7
|
|
Author: Parav Pandit <parav@mellanox.com>
|
|
Date: Sat Dec 14 04:09:04 2019 -0600
|
|
|
|
net/mlx5: Split eswitch mode check to different helper function
|
|
|
|
In order to check eswitch state under a lock, prepare code to split
|
|
capability check and eswitch state check into two helper functions.
|
|
|
|
Reviewed-by: Roi Dayan <roid@mellanox.com>
|
|
Reviewed-by: Bodong Wang <bodong@mellanox.com>
|
|
Reviewed-by: Mark Bloch <markb@mellanox.com>
|
|
Signed-off-by: Parav Pandit <parav@mellanox.com>
|
|
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
|
|
|
|
Signed-off-by: Alaa Hleihel <ahleihel@redhat.com>
|
|
Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
|
|
---
|
|
.../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 37 +++++++++++++++++++---
|
|
1 file changed, 33 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
|
|
index 96a6eaf84a50..1b74a6f35df9 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
|
|
@@ -2582,13 +2582,18 @@ static int mlx5_eswitch_check(const struct mlx5_core_dev *dev)
|
|
if(!MLX5_ESWITCH_MANAGER(dev))
|
|
return -EPERM;
|
|
|
|
- if (dev->priv.eswitch->mode == MLX5_ESWITCH_NONE &&
|
|
- !mlx5_core_is_ecpf_esw_manager(dev))
|
|
- return -EOPNOTSUPP;
|
|
-
|
|
return 0;
|
|
}
|
|
|
|
+static int eswitch_devlink_esw_mode_check(const struct mlx5_eswitch *esw)
|
|
+{
|
|
+ /* devlink commands in NONE eswitch mode are currently supported only
|
|
+ * on ECPF.
|
|
+ */
|
|
+ return (esw->mode == MLX5_ESWITCH_NONE &&
|
|
+ !mlx5_core_is_ecpf_esw_manager(esw->dev)) ? -EOPNOTSUPP : 0;
|
|
+}
|
|
+
|
|
int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
|
|
struct netlink_ext_ack *extack)
|
|
{
|
|
@@ -2600,6 +2605,10 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
|
|
if (err)
|
|
return err;
|
|
|
|
+ err = eswitch_devlink_esw_mode_check(dev->priv.eswitch);
|
|
+ if (err)
|
|
+ return err;
|
|
+
|
|
cur_mlx5_mode = dev->priv.eswitch->mode;
|
|
|
|
if (esw_mode_from_devlink(mode, &mlx5_mode))
|
|
@@ -2625,6 +2634,10 @@ int mlx5_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
|
|
if (err)
|
|
return err;
|
|
|
|
+ err = eswitch_devlink_esw_mode_check(dev->priv.eswitch);
|
|
+ if (err)
|
|
+ return err;
|
|
+
|
|
return esw_mode_to_devlink(dev->priv.eswitch->mode, mode);
|
|
}
|
|
|
|
@@ -2640,6 +2653,10 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode,
|
|
if (err)
|
|
return err;
|
|
|
|
+ err = eswitch_devlink_esw_mode_check(esw);
|
|
+ if (err)
|
|
+ return err;
|
|
+
|
|
switch (MLX5_CAP_ETH(dev, wqe_inline_mode)) {
|
|
case MLX5_CAP_INLINE_MODE_NOT_REQUIRED:
|
|
if (mode == DEVLINK_ESWITCH_INLINE_MODE_NONE)
|
|
@@ -2694,6 +2711,10 @@ int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8 *mode)
|
|
if (err)
|
|
return err;
|
|
|
|
+ err = eswitch_devlink_esw_mode_check(esw);
|
|
+ if (err)
|
|
+ return err;
|
|
+
|
|
return esw_inline_mode_to_devlink(esw->offloads.inline_mode, mode);
|
|
}
|
|
|
|
@@ -2746,6 +2767,10 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
|
|
if (err)
|
|
return err;
|
|
|
|
+ err = eswitch_devlink_esw_mode_check(esw);
|
|
+ if (err)
|
|
+ return err;
|
|
+
|
|
if (encap != DEVLINK_ESWITCH_ENCAP_MODE_NONE &&
|
|
(!MLX5_CAP_ESW_FLOWTABLE_FDB(dev, reformat) ||
|
|
!MLX5_CAP_ESW_FLOWTABLE_FDB(dev, decap)))
|
|
@@ -2795,6 +2820,10 @@ int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
|
|
if (err)
|
|
return err;
|
|
|
|
+ err = eswitch_devlink_esw_mode_check(esw);
|
|
+ if (err)
|
|
+ return err;
|
|
+
|
|
*encap = esw->offloads.encap;
|
|
return 0;
|
|
}
|
|
--
|
|
2.13.6
|
|
|