Skip to contentSkip to conversation

Expose ENCAP mode to mlx5_ib

PATCH In review Leon Romanovsky 6 participants 16 messages Jun 12, 2019 – Jun 17, 2019

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover Expose ENCAP mode to mlx5_ib

From: Leon Romanovsky <[email protected]>

Changelog v0->v1:
* Added patch to devlink to use declared enum for encap mode instead of u8
* Constify input argumetn to encap mode function
* fix encap variable type to be boolean

---------------------------------------------------------------------
Hi,

This is short series from Maor to expose and use enacap mode inside mlx5_ib.

Thanks

Leon Romanovsky (1):
net/mlx5: Declare more strictly devlink encap mode

Maor Gottlieb (3):
net/mlx5: Expose eswitch encap mode RDMA/mlx5: Consider eswitch encap mode RDMA/mlx5: Enable decap and packet reformat on FDB

 drivers/infiniband/hw/mlx5/main.c             | 25 ++++++++++++++-----
 .../net/ethernet/mellanox/mlx5/core/eswitch.c | 11 ++++++++
 .../net/ethernet/mellanox/mlx5/core/eswitch.h |  8 +++---
 .../mellanox/mlx5/core/eswitch_offloads.c     |  6 +++--
 include/linux/mlx5/eswitch.h                  | 12 +++++++++
 include/net/devlink.h                         |  6 +++--
 net/core/devlink.c                            |  6 +++--
 7 files changed, 59 insertions(+), 15 deletions(-)
#1 lore raw

PATCH 1/4 net/mlx5: Declare more strictly devlink encap mode

From: Leon Romanovsky <[email protected]>

Devlink has UAPI declaration for encap mode, so there is no need to be loose on the data get/set by drivers.

Update call sites to use enum devlink_eswitch_encap_mode instead of plain u8.

---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h         | 8 +++++---
 .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c    | 6 ++++--
 include/net/devlink.h                                     | 6 ++++--
 net/core/devlink.c                                        | 6 ++++--
 4 files changed, 17 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +5 -3
index ed3fad689ec9..e264dfc64a6e 100644
@@ -175,7 +175,7 @@ struct mlx5_esw_offload {
 	DECLARE_HASHTABLE(mod_hdr_tbl, 8);
 	u8 inline_mode;
 	u64 num_flows;
-	u8 encap;
+	enum devlink_eswitch_encap_mode encap;
 };
 
 /* E-Switch MC FDB table hash node */
@@ -356,9 +356,11 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode,
 					 struct netlink_ext_ack *extack);
 int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8 *mode);
 int mlx5_eswitch_inline_mode_get(struct mlx5_eswitch *esw, int nvfs, u8 *mode);
-int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap,
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode encap,
 					struct netlink_ext_ack *extack);
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8 *encap);
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode *encap);
 void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type);
 
 int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw,
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +4 -2
index e09ae27485ee..f1571163143d 100644
@@ -2137,7 +2137,8 @@ int mlx5_eswitch_inline_mode_get(struct mlx5_eswitch *esw, int nvfs, u8 *mode)
 	return 0;
 }
 
-int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap,
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode encap,
 					struct netlink_ext_ack *extack)
 {
 	struct mlx5_core_dev *dev = devlink_priv(devlink);
@@ -2186,7 +2187,8 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap,
 	return err;
 }
 
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8 *encap)
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode *encap)
 {
 	struct mlx5_core_dev *dev = devlink_priv(devlink);
 	struct mlx5_eswitch *esw = dev->priv.eswitch;
include/net/devlink.h +4 -2
index 1c4adfb4195a..7a34fc586def 100644
@@ -530,8 +530,10 @@ struct devlink_ops {
 	int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode);
 	int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode,
 				       struct netlink_ext_ack *extack);
-	int (*eswitch_encap_mode_get)(struct devlink *devlink, u8 *p_encap_mode);
-	int (*eswitch_encap_mode_set)(struct devlink *devlink, u8 encap_mode,
+	int (*eswitch_encap_mode_get)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode *p_encap_mode);
+	int (*eswitch_encap_mode_set)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode encap_mode,
 				      struct netlink_ext_ack *extack);
 	int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
 			struct netlink_ext_ack *extack);
net/core/devlink.c +4 -2
index d43bc52b8840..47ae69363b07 100644
@@ -1552,7 +1552,8 @@ static int devlink_nl_eswitch_fill(struct sk_buff *msg, struct devlink *devlink,
 				   u32 seq, int flags)
 {
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	void *hdr;
 	int err = 0;
 	u16 mode;
@@ -1628,7 +1629,8 @@ static int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb,
 {
 	struct devlink *devlink = info->user_ptr[0];
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	int err = 0;
 	u16 mode;
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

Hi Leon,

Quoted 11 lines

From: Leon Romanovsky <[email protected]>

Devlink has UAPI declaration for encap mode, so there is no need to be loose on the data get/set by drivers.

Update call sites to use enum devlink_eswitch_encap_mode instead of plain u8.

---

Kind regards,
Petr

Reviewed-by on v1 1/4
#3 lore raw

RE: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

In reply to Leon Romanovsky
Quoted 146 lines

-----Original Message-----
From: Leon Romanovsky <[email protected]>
Sent: Wednesday, June 12, 2019 5:50 PM
To: Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>
Cc: Leon Romanovsky <[email protected]>; RDMA mailing list <linux- [email protected]>; Maor Gottlieb <[email protected]>; Mark Bloch <[email protected]>; Parav Pandit <[email protected]>; Petr Vorel <[email protected]>; Saeed Mahameed <[email protected]>; linux- netdev <[email protected]>; Jiri Pirko <[email protected]>
Subject: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

From: Leon Romanovsky <[email protected]>

Devlink has UAPI declaration for encap mode, so there is no need to be loose on the data get/set by drivers.

Update call sites to use enum devlink_eswitch_encap_mode instead of plain u8.

---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h         | 8 +++++---
 .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c    | 6 ++++--
 include/net/devlink.h                                     | 6 ++++--
 net/core/devlink.c                                        | 6 ++++--
 4 files changed, 17 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -1
index ed3fad689ec9..e264dfc64a6e 100644
@@ -175,7 +175,7 @@ struct mlx5_esw_offload {
 	DECLARE_HASHTABLE(mod_hdr_tbl, 8);
 	u8 inline_mode;
 	u64 num_flows;
-	u8 encap;
+	enum devlink_eswitch_encap_mode encap;
 };
 
 /* E-Switch MC FDB table hash node */
@@ -356,9 +356,11 @@ int mlx5_devlink_eswitch_inline_mode_set(struct
 devlink *devlink, u8 mode,
 					 struct netlink_ext_ack *extack);
 int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8
 *mode);  int mlx5_eswitch_inline_mode_get(struct mlx5_eswitch *esw, int

nvfs, u8 *mode); -int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0 -1
 					struct netlink_ext_ack *extack);
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap);

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap);
void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8
rep_type);

int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, diff --git
a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index e09ae27485ee..f1571163143d 100644

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -1
@@ -2137,7 +2137,8 @@ int mlx5_eswitch_inline_mode_get(struct
 mlx5_eswitch *esw, int nvfs, u8 *mode)
 	return 0;
 }
 
-int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8
 encap,
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode
 encap,
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +1 -0
 					struct netlink_ext_ack *extack)
 {
 	struct mlx5_core_dev *dev = devlink_priv(devlink); @@ -2186,7
+2187,8 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink

*devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -1
 	return err;
 }
 
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap)

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap)
{

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -0
 	struct mlx5_core_dev *dev = devlink_priv(devlink);
 	struct mlx5_eswitch *esw = dev->priv.eswitch; diff --git

a/include/net/devlink.h b/include/net/devlink.h index 1c4adfb4195a..7a34fc586def 100644

include/net/devlink.h +0 -2
@@ -530,8 +530,10 @@ struct devlink_ops {
 	int (*eswitch_inline_mode_get)(struct devlink *devlink, u8
 *p_inline_mode);
 	int (*eswitch_inline_mode_set)(struct devlink *devlink, u8
 inline_mode,
 				       struct netlink_ext_ack *extack);
-	int (*eswitch_encap_mode_get)(struct devlink *devlink, u8
 *p_encap_mode);
-	int (*eswitch_encap_mode_set)(struct devlink *devlink, u8

encap_mode,

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_get)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

*p_encap_mode);

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_set)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

encap_mode,

include/net/devlink.h +0 -0
 				      struct netlink_ext_ack *extack);
 	int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
 			struct netlink_ext_ack *extack);
net/core/devlink.c index renamed from net/core/devlink.c +0 -0

d43bc52b8840..47ae69363b07 100644

net/core/devlink.c +2 -1
@@ -1552,7 +1552,8 @@ static int devlink_nl_eswitch_fill(struct sk_buff
 *msg, struct devlink *devlink,
 				   u32 seq, int flags)
 {
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	void *hdr;
 	int err = 0;
net/core/devlink.c +2 -2
 	u16 mode;
@@ -1628,7 +1629,8 @@ static int devlink_nl_cmd_eswitch_set_doit(struct
 sk_buff *skb,  {
 	struct devlink *devlink = info->user_ptr[0];
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	int err = 0;
 	u16 mode;
 
--
Quoted 1 line

2.20.1

Netdev follows reverse Christmas tree, but otherwise,

#4 lore raw

Re: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

Quoted 145 lines · Parav Pandit
Quoted 145 lines

-----Original Message-----
From: Leon Romanovsky <[email protected]>
Sent: Wednesday, June 12, 2019 5:50 PM
To: Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>
Cc: Leon Romanovsky <[email protected]>; RDMA mailing list <linux- [email protected]>; Maor Gottlieb <[email protected]>; Mark Bloch <[email protected]>; Parav Pandit <[email protected]>; Petr Vorel <[email protected]>; Saeed Mahameed <[email protected]>; linux- netdev <[email protected]>; Jiri Pirko <[email protected]>
Subject: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

From: Leon Romanovsky <[email protected]>

Devlink has UAPI declaration for encap mode, so there is no need to be loose on the data get/set by drivers.

Update call sites to use enum devlink_eswitch_encap_mode instead of plain u8.

---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h         | 8 +++++---
 .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c    | 6 ++++--
 include/net/devlink.h                                     | 6 ++++--
 net/core/devlink.c                                        | 6 ++++--
 4 files changed, 17 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -1
index ed3fad689ec9..e264dfc64a6e 100644
@@ -175,7 +175,7 @@ struct mlx5_esw_offload {
 	DECLARE_HASHTABLE(mod_hdr_tbl, 8);
 	u8 inline_mode;
 	u64 num_flows;
-	u8 encap;
+	enum devlink_eswitch_encap_mode encap;
 };
 
 /* E-Switch MC FDB table hash node */
@@ -356,9 +356,11 @@ int mlx5_devlink_eswitch_inline_mode_set(struct
 devlink *devlink, u8 mode,
 					 struct netlink_ext_ack *extack);
 int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8
 *mode);  int mlx5_eswitch_inline_mode_get(struct mlx5_eswitch *esw, int

nvfs, u8 *mode); -int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0 -1
 					struct netlink_ext_ack *extack);
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap);

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap);
void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8
rep_type);

int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, diff --git
a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index e09ae27485ee..f1571163143d 100644

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -1
@@ -2137,7 +2137,8 @@ int mlx5_eswitch_inline_mode_get(struct
 mlx5_eswitch *esw, int nvfs, u8 *mode)
 	return 0;
 }
 
-int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8
 encap,
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode
 encap,
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +1 -0
 					struct netlink_ext_ack *extack)
 {
 	struct mlx5_core_dev *dev = devlink_priv(devlink); @@ -2186,7
+2187,8 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink

*devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -1
 	return err;
 }
 
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap)

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap)
{

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -0
 	struct mlx5_core_dev *dev = devlink_priv(devlink);
 	struct mlx5_eswitch *esw = dev->priv.eswitch; diff --git

a/include/net/devlink.h b/include/net/devlink.h index 1c4adfb4195a..7a34fc586def 100644

include/net/devlink.h +0 -2
@@ -530,8 +530,10 @@ struct devlink_ops {
 	int (*eswitch_inline_mode_get)(struct devlink *devlink, u8
 *p_inline_mode);
 	int (*eswitch_inline_mode_set)(struct devlink *devlink, u8
 inline_mode,
 				       struct netlink_ext_ack *extack);
-	int (*eswitch_encap_mode_get)(struct devlink *devlink, u8
 *p_encap_mode);
-	int (*eswitch_encap_mode_set)(struct devlink *devlink, u8

encap_mode,

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_get)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

*p_encap_mode);

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_set)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

encap_mode,

include/net/devlink.h +0 -0
 				      struct netlink_ext_ack *extack);
 	int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
 			struct netlink_ext_ack *extack);
net/core/devlink.c index renamed from net/core/devlink.c +0 -0

d43bc52b8840..47ae69363b07 100644

net/core/devlink.c +2 -1
@@ -1552,7 +1552,8 @@ static int devlink_nl_eswitch_fill(struct sk_buff
 *msg, struct devlink *devlink,
 				   u32 seq, int flags)
 {
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	void *hdr;
 	int err = 0;
net/core/devlink.c +2 -1
 	u16 mode;
@@ -1628,7 +1629,8 @@ static int devlink_nl_cmd_eswitch_set_doit(struct
 sk_buff *skb,  {
 	struct devlink *devlink = info->user_ptr[0];
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	int err = 0;
 	u16 mode;
 
Quoted 4 lines
Quoted 2 lines

--
2.20.1

Netdev follows reverse Christmas tree, but otherwise,

It was before this patch, if Jiri is ok with that, I'll change this "const struct devlink_ops *ops = devlink->ops;" line while I'll apply this patchset to mlx5-net. If not, I'll leave it as is.

Quoted 1 line

Thanks

Quoted 1 line
maintainer Acked-by
#5 lore raw

Re: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

Quoted 146 lines · Thu, Jun 13, 2019 at 07:59:54AM CEST, [email protected] wrote:
Quoted 145 lines · Parav Pandit
Quoted 145 lines

-----Original Message-----
From: Leon Romanovsky <[email protected]>
Sent: Wednesday, June 12, 2019 5:50 PM
To: Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>
Cc: Leon Romanovsky <[email protected]>; RDMA mailing list <linux- [email protected]>; Maor Gottlieb <[email protected]>; Mark Bloch <[email protected]>; Parav Pandit <[email protected]>; Petr Vorel <[email protected]>; Saeed Mahameed <[email protected]>; linux- netdev <[email protected]>; Jiri Pirko <[email protected]>
Subject: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

From: Leon Romanovsky <[email protected]>

Devlink has UAPI declaration for encap mode, so there is no need to be loose on the data get/set by drivers.

Update call sites to use enum devlink_eswitch_encap_mode instead of plain u8.

---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h         | 8 +++++---
 .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c    | 6 ++++--
 include/net/devlink.h                                     | 6 ++++--
 net/core/devlink.c                                        | 6 ++++--
 4 files changed, 17 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -1
index ed3fad689ec9..e264dfc64a6e 100644
@@ -175,7 +175,7 @@ struct mlx5_esw_offload {
 	DECLARE_HASHTABLE(mod_hdr_tbl, 8);
 	u8 inline_mode;
 	u64 num_flows;
-	u8 encap;
+	enum devlink_eswitch_encap_mode encap;
 };
 
 /* E-Switch MC FDB table hash node */
@@ -356,9 +356,11 @@ int mlx5_devlink_eswitch_inline_mode_set(struct
 devlink *devlink, u8 mode,
 					 struct netlink_ext_ack *extack);
 int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8
 *mode);  int mlx5_eswitch_inline_mode_get(struct mlx5_eswitch *esw, int

nvfs, u8 *mode); -int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0 -1
 					struct netlink_ext_ack *extack);
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap);

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap);
void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8
rep_type);

int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, diff --git
a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index e09ae27485ee..f1571163143d 100644

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -1
@@ -2137,7 +2137,8 @@ int mlx5_eswitch_inline_mode_get(struct
 mlx5_eswitch *esw, int nvfs, u8 *mode)
 	return 0;
 }
 
-int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8
 encap,
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode
 encap,
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +1 -0
 					struct netlink_ext_ack *extack)
 {
 	struct mlx5_core_dev *dev = devlink_priv(devlink); @@ -2186,7
+2187,8 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink

*devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -1
 	return err;
 }
 
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap)

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap)
{

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -0
 	struct mlx5_core_dev *dev = devlink_priv(devlink);
 	struct mlx5_eswitch *esw = dev->priv.eswitch; diff --git

a/include/net/devlink.h b/include/net/devlink.h index 1c4adfb4195a..7a34fc586def 100644

include/net/devlink.h +0 -2
@@ -530,8 +530,10 @@ struct devlink_ops {
 	int (*eswitch_inline_mode_get)(struct devlink *devlink, u8
 *p_inline_mode);
 	int (*eswitch_inline_mode_set)(struct devlink *devlink, u8
 inline_mode,
 				       struct netlink_ext_ack *extack);
-	int (*eswitch_encap_mode_get)(struct devlink *devlink, u8
 *p_encap_mode);
-	int (*eswitch_encap_mode_set)(struct devlink *devlink, u8

encap_mode,

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_get)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

*p_encap_mode);

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_set)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

encap_mode,

include/net/devlink.h +0 -0
 				      struct netlink_ext_ack *extack);
 	int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
 			struct netlink_ext_ack *extack);
net/core/devlink.c index renamed from net/core/devlink.c +0 -0

d43bc52b8840..47ae69363b07 100644

net/core/devlink.c +2 -1
@@ -1552,7 +1552,8 @@ static int devlink_nl_eswitch_fill(struct sk_buff
 *msg, struct devlink *devlink,
 				   u32 seq, int flags)
 {
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	void *hdr;
 	int err = 0;
net/core/devlink.c +2 -1
 	u16 mode;
@@ -1628,7 +1629,8 @@ static int devlink_nl_cmd_eswitch_set_doit(struct
 sk_buff *skb,  {
 	struct devlink *devlink = info->user_ptr[0];
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	int err = 0;
 	u16 mode;
 
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

--
2.20.1

Netdev follows reverse Christmas tree, but otherwise,

It was before this patch, if Jiri is ok with that, I'll change this "const struct devlink_ops *ops = devlink->ops;" line while I'll apply this patchset to mlx5-net. If not, I'll leave it as is.

Change to what? I don't follow. The patch looks completely fine to me as it is.

Quoted 6 lines
Quoted 2 lines

Thanks

Quoted 1 line
#6 lore raw

Re: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

Quoted 152 lines · Jiri Pirko
Quoted 151 lines · Thu, Jun 13, 2019 at 07:59:54AM CEST, [email protected] wrote:
Quoted 149 lines · Parav Pandit
Quoted 146 lines

-----Original Message-----
From: Leon Romanovsky <[email protected]>
Sent: Wednesday, June 12, 2019 5:50 PM
To: Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>
Cc: Leon Romanovsky <[email protected]>; RDMA mailing list <linux- [email protected]>; Maor Gottlieb <[email protected]>; Mark Bloch <[email protected]>; Parav Pandit <[email protected]>; Petr Vorel <[email protected]>; Saeed Mahameed <[email protected]>; linux- netdev <[email protected]>; Jiri Pirko <[email protected]>
Subject: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

From: Leon Romanovsky <[email protected]>

Devlink has UAPI declaration for encap mode, so there is no need to be loose on the data get/set by drivers.

Update call sites to use enum devlink_eswitch_encap_mode instead of plain u8.

---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h         | 8 +++++---
 .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c    | 6 ++++--
 include/net/devlink.h                                     | 6 ++++--
 net/core/devlink.c                                        | 6 ++++--
 4 files changed, 17 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -1
index ed3fad689ec9..e264dfc64a6e 100644
@@ -175,7 +175,7 @@ struct mlx5_esw_offload {
 	DECLARE_HASHTABLE(mod_hdr_tbl, 8);
 	u8 inline_mode;
 	u64 num_flows;
-	u8 encap;
+	enum devlink_eswitch_encap_mode encap;
 };
 
 /* E-Switch MC FDB table hash node */
@@ -356,9 +356,11 @@ int mlx5_devlink_eswitch_inline_mode_set(struct
 devlink *devlink, u8 mode,
 					 struct netlink_ext_ack *extack);
 int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8
 *mode);  int mlx5_eswitch_inline_mode_get(struct mlx5_eswitch *esw, int

nvfs, u8 *mode); -int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0 -1
 					struct netlink_ext_ack *extack);
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap);

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap);
void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8
rep_type);

int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, diff --git
a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index e09ae27485ee..f1571163143d 100644

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -1
@@ -2137,7 +2137,8 @@ int mlx5_eswitch_inline_mode_get(struct
 mlx5_eswitch *esw, int nvfs, u8 *mode)
 	return 0;
 }
 
-int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8
 encap,
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode
 encap,
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +1 -0
 					struct netlink_ext_ack *extack)
 {
 	struct mlx5_core_dev *dev = devlink_priv(devlink); @@ -2186,7
+2187,8 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink

*devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -1
 	return err;
 }
 
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap)

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap)
{

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -0
 	struct mlx5_core_dev *dev = devlink_priv(devlink);
 	struct mlx5_eswitch *esw = dev->priv.eswitch; diff --git

a/include/net/devlink.h b/include/net/devlink.h index 1c4adfb4195a..7a34fc586def 100644

include/net/devlink.h +0 -2
@@ -530,8 +530,10 @@ struct devlink_ops {
 	int (*eswitch_inline_mode_get)(struct devlink *devlink, u8
 *p_inline_mode);
 	int (*eswitch_inline_mode_set)(struct devlink *devlink, u8
 inline_mode,
 				       struct netlink_ext_ack *extack);
-	int (*eswitch_encap_mode_get)(struct devlink *devlink, u8
 *p_encap_mode);
-	int (*eswitch_encap_mode_set)(struct devlink *devlink, u8

encap_mode,

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_get)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

*p_encap_mode);

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_set)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

encap_mode,

include/net/devlink.h +0 -0
 				      struct netlink_ext_ack *extack);
 	int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
 			struct netlink_ext_ack *extack);
net/core/devlink.c index renamed from net/core/devlink.c +0 -0

d43bc52b8840..47ae69363b07 100644

net/core/devlink.c +2 -1
@@ -1552,7 +1552,8 @@ static int devlink_nl_eswitch_fill(struct sk_buff
 *msg, struct devlink *devlink,
 				   u32 seq, int flags)
 {
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	void *hdr;
 	int err = 0;
net/core/devlink.c +2 -2
 	u16 mode;
@@ -1628,7 +1629,8 @@ static int devlink_nl_cmd_eswitch_set_doit(struct
 sk_buff *skb,  {
 	struct devlink *devlink = info->user_ptr[0];
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	int err = 0;
 	u16 mode;
 
--
Quoted 1 line

2.20.1

Netdev follows reverse Christmas tree, but otherwise,

Quoted 6 lines
Quoted 3 lines

It was before this patch, if Jiri is ok with that, I'll change this "const struct devlink_ops *ops = devlink->ops;" line while I'll apply this patchset to mlx5-net. If not, I'll leave it as is.

Change to what? I don't follow. The patch looks completely fine to me as it is.

Thanks Jiri,

Parav mentioned that two lines above my change were already not in Christmas tree format.

   struct devlink *devlink = info->user_ptr[0];
   const struct devlink_ops *ops = devlink->ops;

Thanks

Quoted 11 lines
Quoted 6 lines
Quoted 2 lines

Thanks

Quoted 1 line
maintainer
#7 lore raw

Re: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

Quoted 160 lines · Sun, Jun 16, 2019 at 12:15:07PM CEST, [email protected] wrote:
Quoted 152 lines · Jiri Pirko
Quoted 151 lines · Thu, Jun 13, 2019 at 07:59:54AM CEST, [email protected] wrote:
Quoted 149 lines · Parav Pandit
Quoted 146 lines

-----Original Message-----
From: Leon Romanovsky <[email protected]>
Sent: Wednesday, June 12, 2019 5:50 PM
To: Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>
Cc: Leon Romanovsky <[email protected]>; RDMA mailing list <linux- [email protected]>; Maor Gottlieb <[email protected]>; Mark Bloch <[email protected]>; Parav Pandit <[email protected]>; Petr Vorel <[email protected]>; Saeed Mahameed <[email protected]>; linux- netdev <[email protected]>; Jiri Pirko <[email protected]>
Subject: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

From: Leon Romanovsky <[email protected]>

Devlink has UAPI declaration for encap mode, so there is no need to be loose on the data get/set by drivers.

Update call sites to use enum devlink_eswitch_encap_mode instead of plain u8.

---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h         | 8 +++++---
 .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c    | 6 ++++--
 include/net/devlink.h                                     | 6 ++++--
 net/core/devlink.c                                        | 6 ++++--
 4 files changed, 17 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -1
index ed3fad689ec9..e264dfc64a6e 100644
@@ -175,7 +175,7 @@ struct mlx5_esw_offload {
 	DECLARE_HASHTABLE(mod_hdr_tbl, 8);
 	u8 inline_mode;
 	u64 num_flows;
-	u8 encap;
+	enum devlink_eswitch_encap_mode encap;
 };
 
 /* E-Switch MC FDB table hash node */
@@ -356,9 +356,11 @@ int mlx5_devlink_eswitch_inline_mode_set(struct
 devlink *devlink, u8 mode,
 					 struct netlink_ext_ack *extack);
 int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8
 *mode);  int mlx5_eswitch_inline_mode_get(struct mlx5_eswitch *esw, int

nvfs, u8 *mode); -int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0 -1
 					struct netlink_ext_ack *extack);
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap);

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap);
void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8
rep_type);

int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, diff --git
a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index e09ae27485ee..f1571163143d 100644

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -1
@@ -2137,7 +2137,8 @@ int mlx5_eswitch_inline_mode_get(struct
 mlx5_eswitch *esw, int nvfs, u8 *mode)
 	return 0;
 }
 
-int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8
 encap,
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode
 encap,
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +1 -0
 					struct netlink_ext_ack *extack)
 {
 	struct mlx5_core_dev *dev = devlink_priv(devlink); @@ -2186,7
+2187,8 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink

*devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -1
 	return err;
 }
 
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap)

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap)
{

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -0
 	struct mlx5_core_dev *dev = devlink_priv(devlink);
 	struct mlx5_eswitch *esw = dev->priv.eswitch; diff --git

a/include/net/devlink.h b/include/net/devlink.h index 1c4adfb4195a..7a34fc586def 100644

include/net/devlink.h +0 -2
@@ -530,8 +530,10 @@ struct devlink_ops {
 	int (*eswitch_inline_mode_get)(struct devlink *devlink, u8
 *p_inline_mode);
 	int (*eswitch_inline_mode_set)(struct devlink *devlink, u8
 inline_mode,
 				       struct netlink_ext_ack *extack);
-	int (*eswitch_encap_mode_get)(struct devlink *devlink, u8
 *p_encap_mode);
-	int (*eswitch_encap_mode_set)(struct devlink *devlink, u8

encap_mode,

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_get)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

*p_encap_mode);

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_set)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

encap_mode,

include/net/devlink.h +0 -0
 				      struct netlink_ext_ack *extack);
 	int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
 			struct netlink_ext_ack *extack);
net/core/devlink.c index renamed from net/core/devlink.c +0 -0

d43bc52b8840..47ae69363b07 100644

net/core/devlink.c +2 -1
@@ -1552,7 +1552,8 @@ static int devlink_nl_eswitch_fill(struct sk_buff
 *msg, struct devlink *devlink,
 				   u32 seq, int flags)
 {
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	void *hdr;
 	int err = 0;
net/core/devlink.c +2 -2
 	u16 mode;
@@ -1628,7 +1629,8 @@ static int devlink_nl_cmd_eswitch_set_doit(struct
 sk_buff *skb,  {
 	struct devlink *devlink = info->user_ptr[0];
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	int err = 0;
 	u16 mode;
 
--
Quoted 1 line

2.20.1

Netdev follows reverse Christmas tree, but otherwise,

Quoted 6 lines
Quoted 3 lines

It was before this patch, if Jiri is ok with that, I'll change this "const struct devlink_ops *ops = devlink->ops;" line while I'll apply this patchset to mlx5-net. If not, I'll leave it as is.

Change to what? I don't follow. The patch looks completely fine to me as it is.

Quoted 7 lines

Thanks Jiri,

Parav mentioned that two lines above my change were already not in Christmas tree format.

  struct devlink *devlink = info->user_ptr[0];
  const struct devlink_ops *ops = devlink->ops;

As there is a dependency between those 2 lines, I don't see how you can fix this.

Quoted 14 lines

Thanks

Quoted 11 lines
Quoted 6 lines
Quoted 2 lines

Thanks

Quoted 1 line
#8 lore raw

Re: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

Quoted 163 lines · Jiri Pirko
Quoted 162 lines · Sun, Jun 16, 2019 at 12:15:07PM CEST, [email protected] wrote:
Quoted 152 lines · Jiri Pirko
Quoted 151 lines · Thu, Jun 13, 2019 at 07:59:54AM CEST, [email protected] wrote:
Quoted 149 lines · Parav Pandit
Quoted 146 lines

-----Original Message-----
From: Leon Romanovsky <[email protected]>
Sent: Wednesday, June 12, 2019 5:50 PM
To: Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>
Cc: Leon Romanovsky <[email protected]>; RDMA mailing list <linux- [email protected]>; Maor Gottlieb <[email protected]>; Mark Bloch <[email protected]>; Parav Pandit <[email protected]>; Petr Vorel <[email protected]>; Saeed Mahameed <[email protected]>; linux- netdev <[email protected]>; Jiri Pirko <[email protected]>
Subject: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

From: Leon Romanovsky <[email protected]>

Devlink has UAPI declaration for encap mode, so there is no need to be loose on the data get/set by drivers.

Update call sites to use enum devlink_eswitch_encap_mode instead of plain u8.

---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h         | 8 +++++---
 .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c    | 6 ++++--
 include/net/devlink.h                                     | 6 ++++--
 net/core/devlink.c                                        | 6 ++++--
 4 files changed, 17 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -1
index ed3fad689ec9..e264dfc64a6e 100644
@@ -175,7 +175,7 @@ struct mlx5_esw_offload {
 	DECLARE_HASHTABLE(mod_hdr_tbl, 8);
 	u8 inline_mode;
 	u64 num_flows;
-	u8 encap;
+	enum devlink_eswitch_encap_mode encap;
 };
 
 /* E-Switch MC FDB table hash node */
@@ -356,9 +356,11 @@ int mlx5_devlink_eswitch_inline_mode_set(struct
 devlink *devlink, u8 mode,
 					 struct netlink_ext_ack *extack);
 int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8
 *mode);  int mlx5_eswitch_inline_mode_get(struct mlx5_eswitch *esw, int

nvfs, u8 *mode); -int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0 -1
 					struct netlink_ext_ack *extack);
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap);

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap);
void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8
rep_type);

int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, diff --git
a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index e09ae27485ee..f1571163143d 100644

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -1
@@ -2137,7 +2137,8 @@ int mlx5_eswitch_inline_mode_get(struct
 mlx5_eswitch *esw, int nvfs, u8 *mode)
 	return 0;
 }
 
-int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8
 encap,
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode
 encap,
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +1 -0
 					struct netlink_ext_ack *extack)
 {
 	struct mlx5_core_dev *dev = devlink_priv(devlink); @@ -2186,7
+2187,8 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink

*devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -1
 	return err;
 }
 
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap)

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap)
{

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -0
 	struct mlx5_core_dev *dev = devlink_priv(devlink);
 	struct mlx5_eswitch *esw = dev->priv.eswitch; diff --git

a/include/net/devlink.h b/include/net/devlink.h index 1c4adfb4195a..7a34fc586def 100644

include/net/devlink.h +0 -2
@@ -530,8 +530,10 @@ struct devlink_ops {
 	int (*eswitch_inline_mode_get)(struct devlink *devlink, u8
 *p_inline_mode);
 	int (*eswitch_inline_mode_set)(struct devlink *devlink, u8
 inline_mode,
 				       struct netlink_ext_ack *extack);
-	int (*eswitch_encap_mode_get)(struct devlink *devlink, u8
 *p_encap_mode);
-	int (*eswitch_encap_mode_set)(struct devlink *devlink, u8

encap_mode,

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_get)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

*p_encap_mode);

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_set)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

encap_mode,

include/net/devlink.h +0 -0
 				      struct netlink_ext_ack *extack);
 	int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
 			struct netlink_ext_ack *extack);
net/core/devlink.c index renamed from net/core/devlink.c +0 -0

d43bc52b8840..47ae69363b07 100644

net/core/devlink.c +2 -1
@@ -1552,7 +1552,8 @@ static int devlink_nl_eswitch_fill(struct sk_buff
 *msg, struct devlink *devlink,
 				   u32 seq, int flags)
 {
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	void *hdr;
 	int err = 0;
net/core/devlink.c +2 -2
 	u16 mode;
@@ -1628,7 +1629,8 @@ static int devlink_nl_cmd_eswitch_set_doit(struct
 sk_buff *skb,  {
 	struct devlink *devlink = info->user_ptr[0];
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	int err = 0;
 	u16 mode;
 
--
Quoted 1 line

2.20.1

Netdev follows reverse Christmas tree, but otherwise,

Quoted 6 lines
Quoted 3 lines

It was before this patch, if Jiri is ok with that, I'll change this "const struct devlink_ops *ops = devlink->ops;" line while I'll apply this patchset to mlx5-net. If not, I'll leave it as is.

Change to what? I don't follow. The patch looks completely fine to me as it is.

Thanks Jiri,

Quoted 8 lines
Quoted 5 lines

Parav mentioned that two lines above my change were already not in Christmas tree format.

  struct devlink *devlink = info->user_ptr[0];
  const struct devlink_ops *ops = devlink->ops;

As there is a dependency between those 2 lines, I don't see how you can fix this.

I don't want to do it, but this is possible solution:

	const struct devlink_ops *ops:
	struct devlink *devlink;
	..... extra declarations ....

	devlink = info->user_ptr[0];
	ops = devlink->ops;
	... rest of the code ...
Quoted 16 lines
Quoted 16 lines

Thanks

Quoted 11 lines
Quoted 6 lines
Quoted 2 lines

Thanks

Quoted 1 line
maintainer
#9 lore raw

Re: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

Quoted 175 lines · Sun, Jun 16, 2019 at 12:53:27PM CEST, [email protected] wrote:
Quoted 163 lines · Jiri Pirko
Quoted 162 lines · Sun, Jun 16, 2019 at 12:15:07PM CEST, [email protected] wrote:
Quoted 152 lines · Jiri Pirko
Quoted 151 lines · Thu, Jun 13, 2019 at 07:59:54AM CEST, [email protected] wrote:
Quoted 149 lines · Parav Pandit
Quoted 146 lines

-----Original Message-----
From: Leon Romanovsky <[email protected]>
Sent: Wednesday, June 12, 2019 5:50 PM
To: Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>
Cc: Leon Romanovsky <[email protected]>; RDMA mailing list <linux- [email protected]>; Maor Gottlieb <[email protected]>; Mark Bloch <[email protected]>; Parav Pandit <[email protected]>; Petr Vorel <[email protected]>; Saeed Mahameed <[email protected]>; linux- netdev <[email protected]>; Jiri Pirko <[email protected]>
Subject: [PATCH mlx5-next v1 1/4] net/mlx5: Declare more strictly devlink encap mode

From: Leon Romanovsky <[email protected]>

Devlink has UAPI declaration for encap mode, so there is no need to be loose on the data get/set by drivers.

Update call sites to use enum devlink_eswitch_encap_mode instead of plain u8.

---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h         | 8 +++++---
 .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c    | 6 ++++--
 include/net/devlink.h                                     | 6 ++++--
 net/core/devlink.c                                        | 6 ++++--
 4 files changed, 17 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -1
index ed3fad689ec9..e264dfc64a6e 100644
@@ -175,7 +175,7 @@ struct mlx5_esw_offload {
 	DECLARE_HASHTABLE(mod_hdr_tbl, 8);
 	u8 inline_mode;
 	u64 num_flows;
-	u8 encap;
+	enum devlink_eswitch_encap_mode encap;
 };
 
 /* E-Switch MC FDB table hash node */
@@ -356,9 +356,11 @@ int mlx5_devlink_eswitch_inline_mode_set(struct
 devlink *devlink, u8 mode,
 					 struct netlink_ext_ack *extack);
 int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8
 *mode);  int mlx5_eswitch_inline_mode_get(struct mlx5_eswitch *esw, int

nvfs, u8 *mode); -int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0 -1
 					struct netlink_ext_ack *extack);
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap);

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap);
void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8
rep_type);

int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, diff --git
a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index e09ae27485ee..f1571163143d 100644

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -1
@@ -2137,7 +2137,8 @@ int mlx5_eswitch_inline_mode_get(struct
 mlx5_eswitch *esw, int nvfs, u8 *mode)
 	return 0;
 }
 
-int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8
 encap,
+int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode
 encap,
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +1 -0
 					struct netlink_ext_ack *extack)
 {
 	struct mlx5_core_dev *dev = devlink_priv(devlink); @@ -2186,7
+2187,8 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink

*devlink, u8 encap,

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -1
 	return err;
 }
 
-int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, u8

*encap)

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
+int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+					enum devlink_eswitch_encap_mode

*encap)
{

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -0
 	struct mlx5_core_dev *dev = devlink_priv(devlink);
 	struct mlx5_eswitch *esw = dev->priv.eswitch; diff --git

a/include/net/devlink.h b/include/net/devlink.h index 1c4adfb4195a..7a34fc586def 100644

include/net/devlink.h +0 -2
@@ -530,8 +530,10 @@ struct devlink_ops {
 	int (*eswitch_inline_mode_get)(struct devlink *devlink, u8
 *p_inline_mode);
 	int (*eswitch_inline_mode_set)(struct devlink *devlink, u8
 inline_mode,
 				       struct netlink_ext_ack *extack);
-	int (*eswitch_encap_mode_get)(struct devlink *devlink, u8
 *p_encap_mode);
-	int (*eswitch_encap_mode_set)(struct devlink *devlink, u8

encap_mode,

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_get)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

*p_encap_mode);

include/net/devlink.h +2 -0
+	int (*eswitch_encap_mode_set)(struct devlink *devlink,
+				      enum devlink_eswitch_encap_mode

encap_mode,

include/net/devlink.h +0 -0
 				      struct netlink_ext_ack *extack);
 	int (*info_get)(struct devlink *devlink, struct devlink_info_req *req,
 			struct netlink_ext_ack *extack);
net/core/devlink.c index renamed from net/core/devlink.c +0 -0

d43bc52b8840..47ae69363b07 100644

net/core/devlink.c +2 -1
@@ -1552,7 +1552,8 @@ static int devlink_nl_eswitch_fill(struct sk_buff
 *msg, struct devlink *devlink,
 				   u32 seq, int flags)
 {
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	void *hdr;
 	int err = 0;
net/core/devlink.c +2 -2
 	u16 mode;
@@ -1628,7 +1629,8 @@ static int devlink_nl_cmd_eswitch_set_doit(struct
 sk_buff *skb,  {
 	struct devlink *devlink = info->user_ptr[0];
 	const struct devlink_ops *ops = devlink->ops;
-	u8 inline_mode, encap_mode;
+	enum devlink_eswitch_encap_mode encap_mode;
+	u8 inline_mode;
 	int err = 0;
 	u16 mode;
 
--
Quoted 1 line

2.20.1

Netdev follows reverse Christmas tree, but otherwise,

Quoted 6 lines
Quoted 3 lines

It was before this patch, if Jiri is ok with that, I'll change this "const struct devlink_ops *ops = devlink->ops;" line while I'll apply this patchset to mlx5-net. If not, I'll leave it as is.

Change to what? I don't follow. The patch looks completely fine to me as it is.

Thanks Jiri,

Quoted 8 lines
Quoted 5 lines

Parav mentioned that two lines above my change were already not in Christmas tree format.

  struct devlink *devlink = info->user_ptr[0];
  const struct devlink_ops *ops = devlink->ops;

As there is a dependency between those 2 lines, I don't see how you can fix this.

I don't want to do it, but this is possible solution:

Quoted 7 lines
	const struct devlink_ops *ops:
	struct devlink *devlink;
	..... extra declarations ....

	devlink = info->user_ptr[0];
	ops = devlink->ops;
	... rest of the code ...

Please don't.

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

Thanks

Quoted 11 lines
Quoted 6 lines
Quoted 2 lines

Thanks

Quoted 1 line
#10 lore raw

PATCH 2/4 net/mlx5: Expose eswitch encap mode

In reply to Leon Romanovsky

From: Maor Gottlieb <[email protected]>

Add API to get the current Eswitch encap mode. It will be used in downstream patches to check if flow table can be created with encap support or not.

---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 11 +++++++++++
 include/linux/mlx5/eswitch.h                      | 12 ++++++++++++
 2 files changed, 23 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +11 -0
index 9ea0ccfe5ef5..0c68d93bea79 100644
@@ -2452,6 +2452,17 @@ u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw)
 }
 EXPORT_SYMBOL_GPL(mlx5_eswitch_mode);
 
+enum devlink_eswitch_encap_mode
+mlx5_eswitch_get_encap_mode(const struct mlx5_core_dev *dev)
+{
+	struct mlx5_eswitch *esw;
+
+	esw = dev->priv.eswitch;
+	return ESW_ALLOWED(esw) ? esw->offloads.encap :
+		DEVLINK_ESWITCH_ENCAP_MODE_NONE;
+}
+EXPORT_SYMBOL(mlx5_eswitch_get_encap_mode);
+
 bool mlx5_esw_lag_prereq(struct mlx5_core_dev *dev0, struct mlx5_core_dev *dev1)
 {
 	if ((dev0->priv.eswitch->mode == SRIOV_NONE &&
include/linux/mlx5/eswitch.h +12 -0
index 0ca77dd1429c..f57c73e81267 100644
@@ -7,6 +7,7 @@
 #define _MLX5_ESWITCH_
 
 #include <linux/mlx5/driver.h>
+#include <net/devlink.h>
 
 #define MLX5_ESWITCH_MANAGER(mdev) MLX5_CAP_GEN(mdev, eswitch_manager)
 
@@ -60,4 +61,15 @@ u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw);
 struct mlx5_flow_handle *
 mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw,
 				    int vport, u32 sqn);
+
+#ifdef CONFIG_MLX5_ESWITCH
+enum devlink_eswitch_encap_mode
+mlx5_eswitch_get_encap_mode(const struct mlx5_core_dev *dev);
+#else  /* CONFIG_MLX5_ESWITCH */
+static inline enum devlink_eswitch_encap_mode
+mlx5_eswitch_get_encap_mode(const struct mlx5_core_dev *dev)
+{
+	return DEVLINK_ESWITCH_ENCAP_MODE_NONE;
+}
+#endif /* CONFIG_MLX5_ESWITCH */
 #endif
Reviewed-by on v1 2/4
#11 lore raw

RE: [PATCH mlx5-next v1 2/4] net/mlx5: Expose eswitch encap mode

Quoted 77 lines

-----Original Message-----
From: Leon Romanovsky <[email protected]>
Sent: Wednesday, June 12, 2019 5:50 PM
To: Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>
Cc: Leon Romanovsky <[email protected]>; RDMA mailing list <linux- [email protected]>; Maor Gottlieb <[email protected]>; Mark Bloch <[email protected]>; Parav Pandit <[email protected]>; Petr Vorel <[email protected]>; Saeed Mahameed <[email protected]>; linux- netdev <[email protected]>; Jiri Pirko <[email protected]>
Subject: [PATCH mlx5-next v1 2/4] net/mlx5: Expose eswitch encap mode

From: Maor Gottlieb <[email protected]>

Add API to get the current Eswitch encap mode.
It will be used in downstream patches to check if flow table can be created with encap support or not.

---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 11 +++++++++++
 include/linux/mlx5/eswitch.h                      | 12 ++++++++++++
 2 files changed, 23 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +10 -0
index 9ea0ccfe5ef5..0c68d93bea79 100644
@@ -2452,6 +2452,17 @@ u8 mlx5_eswitch_mode(struct mlx5_eswitch
 *esw)  }  EXPORT_SYMBOL_GPL(mlx5_eswitch_mode);
 
+enum devlink_eswitch_encap_mode
+mlx5_eswitch_get_encap_mode(const struct mlx5_core_dev *dev) {
+	struct mlx5_eswitch *esw;
+
+	esw = dev->priv.eswitch;
+	return ESW_ALLOWED(esw) ? esw->offloads.encap :
+		DEVLINK_ESWITCH_ENCAP_MODE_NONE;
+}
+EXPORT_SYMBOL(mlx5_eswitch_get_encap_mode);
+
 bool mlx5_esw_lag_prereq(struct mlx5_core_dev *dev0, struct
 mlx5_core_dev *dev1)  {
 	if ((dev0->priv.eswitch->mode == SRIOV_NONE && diff --git

a/include/linux/mlx5/eswitch.h b/include/linux/mlx5/eswitch.h index 0ca77dd1429c..f57c73e81267 100644

include/linux/mlx5/eswitch.h +1 -0
@@ -7,6 +7,7 @@
 #define _MLX5_ESWITCH_
 
 #include <linux/mlx5/driver.h>
+#include <net/devlink.h>
 
 #define MLX5_ESWITCH_MANAGER(mdev) MLX5_CAP_GEN(mdev,
 eswitch_manager)
@@ -60,4 +61,15 @@ u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw);

struct mlx5_flow_handle * mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw,

include/linux/mlx5/eswitch.h +5 -0
 				    int vport, u32 sqn);
+
+#ifdef CONFIG_MLX5_ESWITCH
+enum devlink_eswitch_encap_mode
+mlx5_eswitch_get_encap_mode(const struct mlx5_core_dev *dev); #else  /*
+CONFIG_MLX5_ESWITCH */ static inline enum

devlink_eswitch_encap_mode

include/linux/mlx5/eswitch.h +3 -1
+mlx5_eswitch_get_encap_mode(const struct mlx5_core_dev *dev) {
+	return DEVLINK_ESWITCH_ENCAP_MODE_NONE; } #endif /*
+CONFIG_MLX5_ESWITCH */
 #endif
--
Quoted 1 line

2.20.1

#12 lore raw

PATCH 3/4 RDMA/mlx5: Consider eswitch encap mode

In reply to Leon Romanovsky

From: Maor Gottlieb <[email protected]>

When flow steering is created, then the encap support should consider the eswitch encap mode. If the eswitch flow table (FDB) supports encap then it shouldn't be supported on NIC RX flow tables.

Fixes 4adda1122c490 ('RDMA/mlx5: Enable decap and packet reformat on flow tables')
---
 drivers/infiniband/hw/mlx5/main.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/infiniband/hw/mlx5/main.c +14 -6
index e832ac6c83a4..a6e2e0210ebb 100644
@@ -52,6 +52,7 @@
 #include <linux/mlx5/port.h>
 #include <linux/mlx5/vport.h>
 #include <linux/mlx5/fs.h>
+#include <linux/mlx5/eswitch.h>
 #include <linux/list.h>
 #include <rdma/ib_smi.h>
 #include <rdma/ib_umem.h>
@@ -3245,11 +3246,14 @@ static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev,
 	int max_table_size;
 	int num_entries;
 	int num_groups;
+	bool esw_encap;
 	u32 flags = 0;
 	int priority;
 
 	max_table_size = BIT(MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
 						       log_max_ft_size));
+	esw_encap = mlx5_eswitch_get_encap_mode(dev->mdev) !=
+		DEVLINK_ESWITCH_ENCAP_MODE_NONE;
 	if (flow_attr->type == IB_FLOW_ATTR_NORMAL) {
 		enum mlx5_flow_namespace_type fn_type;
 
@@ -3262,10 +3266,10 @@ static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev,
 		if (ft_type == MLX5_IB_FT_RX) {
 			fn_type = MLX5_FLOW_NAMESPACE_BYPASS;
 			prio = &dev->flow_db->prios[priority];
-			if (!dev->is_rep &&
+			if (!dev->is_rep && !esw_encap &&
 			    MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev, decap))
 				flags |= MLX5_FLOW_TABLE_TUNNEL_EN_DECAP;
-			if (!dev->is_rep &&
+			if (!dev->is_rep && !esw_encap &&
 			    MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
 					reformat_l3_tunnel_to_l2))
 				flags |= MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
@@ -3275,7 +3279,7 @@ static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev,
 							      log_max_ft_size));
 			fn_type = MLX5_FLOW_NAMESPACE_EGRESS;
 			prio = &dev->flow_db->egress_prios[priority];
-			if (!dev->is_rep &&
+			if (!dev->is_rep && !esw_encap &&
 			    MLX5_CAP_FLOWTABLE_NIC_TX(dev->mdev, reformat))
 				flags |= MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
 		}
@@ -3885,6 +3889,7 @@ _get_flow_table(struct mlx5_ib_dev *dev,
 	struct mlx5_flow_namespace *ns = NULL;
 	struct mlx5_ib_flow_prio *prio = NULL;
 	int max_table_size = 0;
+	bool esw_encap;
 	u32 flags = 0;
 	int priority;
 
@@ -3893,18 +3898,21 @@ _get_flow_table(struct mlx5_ib_dev *dev,
 	else
 		priority = ib_prio_to_core_prio(fs_matcher->priority, false);
 
+	esw_encap = mlx5_eswitch_get_encap_mode(dev->mdev) !=
+		DEVLINK_ESWITCH_ENCAP_MODE_NONE;
 	if (fs_matcher->ns_type == MLX5_FLOW_NAMESPACE_BYPASS) {
 		max_table_size = BIT(MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
 					log_max_ft_size));
-		if (MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev, decap))
+		if (MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev, decap) && !esw_encap)
 			flags |= MLX5_FLOW_TABLE_TUNNEL_EN_DECAP;
 		if (MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
-					      reformat_l3_tunnel_to_l2))
+					      reformat_l3_tunnel_to_l2) &&
+		    !esw_encap)
 			flags |= MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
 	} else if (fs_matcher->ns_type == MLX5_FLOW_NAMESPACE_EGRESS) {
 		max_table_size = BIT(
 			MLX5_CAP_FLOWTABLE_NIC_TX(dev->mdev, log_max_ft_size));
-		if (MLX5_CAP_FLOWTABLE_NIC_TX(dev->mdev, reformat))
+		if (MLX5_CAP_FLOWTABLE_NIC_TX(dev->mdev, reformat) && !esw_encap)
 			flags |= MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
 	} else if (fs_matcher->ns_type == MLX5_FLOW_NAMESPACE_FDB) {
 		max_table_size = BIT(
#13 lore raw

PATCH 4/4 RDMA/mlx5: Enable decap and packet reformat on FDB

In reply to Leon Romanovsky

From: Maor Gottlieb <[email protected]>

If FDB flow tables support decap operation, enable it on creation, This allows to perform decapsulation of tunnelled packets by steering rules. If FDB flow tables support reformat operation, enable it on creation as well.

---
 drivers/infiniband/hw/mlx5/main.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/infiniband/hw/mlx5/main.c +5 -0
index a6e2e0210ebb..33709fd93ab2 100644
@@ -3917,6 +3917,11 @@ _get_flow_table(struct mlx5_ib_dev *dev,
 	} else if (fs_matcher->ns_type == MLX5_FLOW_NAMESPACE_FDB) {
 		max_table_size = BIT(
 			MLX5_CAP_ESW_FLOWTABLE_FDB(dev->mdev, log_max_ft_size));
+		if (MLX5_CAP_ESW_FLOWTABLE_FDB(dev->mdev, decap) && esw_encap)
+			flags |= MLX5_FLOW_TABLE_TUNNEL_EN_DECAP;
+		if (MLX5_CAP_ESW_FLOWTABLE_FDB(dev->mdev, reformat_l3_tunnel_to_l2) &&
+		    esw_encap)
+			flags |= MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
 		priority = FDB_BYPASS_PATH;
 	}
#14 lore raw
In reply to Leon Romanovsky
Quoted 12 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

Changelog v0->v1:
* Added patch to devlink to use declared enum for encap mode instead of u8
* Constify input argumetn to encap mode function
* fix encap variable type to be boolean

---------------------------------------------------------------------
Hi,

This is short series from Maor to expose and use enacap mode inside mlx5_ib.

Quoted 7 lines

Thanks

Leon Romanovsky (1):
net/mlx5: Declare more strictly devlink encap mode

Maor Gottlieb (3):
net/mlx5: Expose eswitch encap mode

Those two applied to mlx5-next
82b11f071936 net/mlx5: Expose eswitch encap mode 98fdbea55037 net/mlx5: Declare more strictly devlink encap mode

Quoted 2 lines

RDMA/mlx5: Consider eswitch encap mode RDMA/mlx5: Enable decap and packet reformat on FDB

Doug, Jason

Can you please take those two patches in addition to latest mlx5-next?

Thanks

Quoted 13 lines
 drivers/infiniband/hw/mlx5/main.c             | 25 ++++++++++++++-----
 .../net/ethernet/mellanox/mlx5/core/eswitch.c | 11 ++++++++
 .../net/ethernet/mellanox/mlx5/core/eswitch.h |  8 +++---
 .../mellanox/mlx5/core/eswitch_offloads.c     |  6 +++--
 include/linux/mlx5/eswitch.h                  | 12 +++++++++
 include/net/devlink.h                         |  6 +++--
 net/core/devlink.c                            |  6 +++--
 7 files changed, 59 insertions(+), 15 deletions(-)

--
2.20.1

#15 lore raw
Quoted 28 lines · Leon Romanovsky
Quoted 15 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

Changelog v0->v1:
* Added patch to devlink to use declared enum for encap mode
instead of u8
* Constify input argumetn to encap mode function
* fix encap variable type to be boolean

-----------------------------------------------------------------
----
Hi,

This is short series from Maor to expose and use enacap mode inside mlx5_ib.

Quoted 7 lines

Thanks

Leon Romanovsky (1):
net/mlx5: Declare more strictly devlink encap mode

Maor Gottlieb (3):
net/mlx5: Expose eswitch encap mode

Those two applied to mlx5-next
82b11f071936 net/mlx5: Expose eswitch encap mode 98fdbea55037 net/mlx5: Declare more strictly devlink encap mode

Quoted 7 lines
Quoted 2 lines

RDMA/mlx5: Consider eswitch encap mode RDMA/mlx5: Enable decap and packet reformat on FDB

Doug, Jason

Can you please take those two patches in addition to latest mlx5- next?

Done, thanks.

Signature · 4 lines
Doug Ledford <[email protected]>
    GPG KeyID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57
2FDD