netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12
@ 2019-11-13 22:41 Saeed Mahameed
  2019-11-13 22:41 ` [net-next V2 1/7] net/mlx5: DR, Fix matcher builders select check Saeed Mahameed
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Saeed Mahameed @ 2019-11-13 22:41 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Pablo Neira Ayuso, Saeed Mahameed

Hi Dave,

This series adds misc updates to mlx5 driver,
For more information please see tag log below.

Highlights:
1) Devlink reload support
2) TC Flowtable offloads 

Please pull and let me know if there is any problem.
Please note that the series starts with a merge of mlx5-next branch,
to resolve and avoid dependency with rdma tree.

v1->v2:
- dropped the 2 patches dealing with sriov vlan trunks, as it was nacked.
- merged the flowtables offloads low level infrastructure into mlx5-next
  and updated the mlx5-next merge commit.
- added mlx5 TC flowtables offload support patch on top of this series.

Thanks,
Saeed.

---
The following changes since commit c94ef13b04e2382c8fcb876705ea505bff9fb714:

  Merge branch 'mlx5-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux (2019-11-13 14:24:58 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2019-11-12

for you to fetch changes up to 84179981317fb4fb3e9df5acd42ea33cf6037793:

  net/mlx5: TC: Offload flow table rules (2019-11-13 14:25:04 -0800)

----------------------------------------------------------------
mlx5-updates-2019-11-12

1) Merge mlx5-next for devlink reload and flowtable offloads dependencies
2) Devlink reload support
3) TC Flowtable offloads
4) Misc cleanup

----------------------------------------------------------------
Alex Vesker (1):
      net/mlx5: DR, Fix matcher builders select check

Eli Cohen (2):
      net/mlx5: Remove redundant NULL initializations
      net/mlx5e: Fix error flow cleanup in mlx5e_tc_tun_create_header_ipv4/6

Michael Guralnik (2):
      net/mlx5e: Set netdev name space on creation
      net/mlx5: Add devlink reload

Parav Pandit (1):
      net/mlx5: Read num_vfs before disabling SR-IOV

Paul Blakey (1):
      net/mlx5: TC: Offload flow table rules

 drivers/net/ethernet/mellanox/mlx5/core/devlink.c  | 20 +++++++++
 .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c    | 26 +++++++-----
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |  2 +
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c   | 47 ++++++++++++++++++++--
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c    | 28 ++++++++++++-
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.h    |  3 +-
 drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h |  5 +++
 drivers/net/ethernet/mellanox/mlx5/core/main.c     |  4 +-
 .../net/ethernet/mellanox/mlx5/core/mlx5_core.h    |  3 ++
 drivers/net/ethernet/mellanox/mlx5/core/sriov.c    | 11 ++---
 .../mellanox/mlx5/core/steering/dr_matcher.c       |  2 +-
 11 files changed, 128 insertions(+), 23 deletions(-)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [net-next V2 1/7] net/mlx5: DR, Fix matcher builders select check
  2019-11-13 22:41 [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12 Saeed Mahameed
@ 2019-11-13 22:41 ` Saeed Mahameed
  2019-11-13 22:41 ` [net-next V2 2/7] net/mlx5: Read num_vfs before disabling SR-IOV Saeed Mahameed
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Saeed Mahameed @ 2019-11-13 22:41 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Pablo Neira Ayuso, Alex Vesker, Saeed Mahameed

From: Alex Vesker <valex@mellanox.com>

When selecting a matcher ste_builder_arr will always be evaluated
as true, instead check if num_of_builders is set for validity.

Fixes: 667f264676c7 ("net/mlx5: DR, Support IPv4 and IPv6 mixed matcher")
Signed-off-by: Alex Vesker <valex@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_matcher.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_matcher.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_matcher.c
index 5db947df8763..c6548980daf0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_matcher.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_matcher.c
@@ -154,7 +154,7 @@ int mlx5dr_matcher_select_builders(struct mlx5dr_matcher *matcher,
 	nic_matcher->num_of_builders =
 		nic_matcher->num_of_builders_arr[outer_ipv][inner_ipv];
 
-	if (!nic_matcher->ste_builder) {
+	if (!nic_matcher->num_of_builders) {
 		mlx5dr_dbg(matcher->tbl->dmn,
 			   "Rule not supported on this matcher due to IP related fields\n");
 		return -EINVAL;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [net-next V2 2/7] net/mlx5: Read num_vfs before disabling SR-IOV
  2019-11-13 22:41 [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12 Saeed Mahameed
  2019-11-13 22:41 ` [net-next V2 1/7] net/mlx5: DR, Fix matcher builders select check Saeed Mahameed
@ 2019-11-13 22:41 ` Saeed Mahameed
  2019-11-13 22:41 ` [net-next V2 3/7] net/mlx5: Remove redundant NULL initializations Saeed Mahameed
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Saeed Mahameed @ 2019-11-13 22:41 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Pablo Neira Ayuso, Parav Pandit, Daniel Jurgens, Saeed Mahameed

From: Parav Pandit <parav@mellanox.com>

mlx5_device_disable_sriov() currently reads num_vfs from the PCI core.
However when mlx5_device_disable_sriov() is executed, SR-IOV is
already disabled at the PCI level.
Due to this disable_hca() cleanup is not done during SR-IOV disable
flow.

mlx5_sriov_disable()
  pci_enable_sriov()
  mlx5_device_disable_sriov() <- num_vfs is zero here.

When SR-IOV enablement fails during mlx5_sriov_enable(), HCA's are left
in enabled stage because mlx5_device_disable_sriov() relies on num_vfs
from PCI core.

mlx5_sriov_enable()
  mlx5_device_enable_sriov()
  pci_enable_sriov() <- Fails

Hence, to overcome above issues,
(a) Read num_vfs before disabling SR-IOV and use it.
(b) Use num_vfs given when enabling sriov in error unwinding path.

Fixes: d886aba677a0 ("net/mlx5: Reduce dependency on enabled_vfs counter and num_vfs")
Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Daniel Jurgens <danielj@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/sriov.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sriov.c b/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
index f641f1336402..03f037811f1d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
@@ -108,10 +108,10 @@ static int mlx5_device_enable_sriov(struct mlx5_core_dev *dev, int num_vfs)
 	return 0;
 }
 
-static void mlx5_device_disable_sriov(struct mlx5_core_dev *dev, bool clear_vf)
+static void
+mlx5_device_disable_sriov(struct mlx5_core_dev *dev, int num_vfs, bool clear_vf)
 {
 	struct mlx5_core_sriov *sriov = &dev->priv.sriov;
-	int num_vfs = pci_num_vf(dev->pdev);
 	int err;
 	int vf;
 
@@ -147,7 +147,7 @@ static int mlx5_sriov_enable(struct pci_dev *pdev, int num_vfs)
 	err = pci_enable_sriov(pdev, num_vfs);
 	if (err) {
 		mlx5_core_warn(dev, "pci_enable_sriov failed : %d\n", err);
-		mlx5_device_disable_sriov(dev, true);
+		mlx5_device_disable_sriov(dev, num_vfs, true);
 	}
 	return err;
 }
@@ -155,9 +155,10 @@ static int mlx5_sriov_enable(struct pci_dev *pdev, int num_vfs)
 static void mlx5_sriov_disable(struct pci_dev *pdev)
 {
 	struct mlx5_core_dev *dev  = pci_get_drvdata(pdev);
+	int num_vfs = pci_num_vf(dev->pdev);
 
 	pci_disable_sriov(pdev);
-	mlx5_device_disable_sriov(dev, true);
+	mlx5_device_disable_sriov(dev, num_vfs, true);
 }
 
 int mlx5_core_sriov_configure(struct pci_dev *pdev, int num_vfs)
@@ -192,7 +193,7 @@ void mlx5_sriov_detach(struct mlx5_core_dev *dev)
 	if (!mlx5_core_is_pf(dev))
 		return;
 
-	mlx5_device_disable_sriov(dev, false);
+	mlx5_device_disable_sriov(dev, pci_num_vf(dev->pdev), false);
 }
 
 static u16 mlx5_get_max_vfs(struct mlx5_core_dev *dev)
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [net-next V2 3/7] net/mlx5: Remove redundant NULL initializations
  2019-11-13 22:41 [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12 Saeed Mahameed
  2019-11-13 22:41 ` [net-next V2 1/7] net/mlx5: DR, Fix matcher builders select check Saeed Mahameed
  2019-11-13 22:41 ` [net-next V2 2/7] net/mlx5: Read num_vfs before disabling SR-IOV Saeed Mahameed
@ 2019-11-13 22:41 ` Saeed Mahameed
  2019-11-13 22:41 ` [net-next V2 4/7] net/mlx5e: Fix error flow cleanup in mlx5e_tc_tun_create_header_ipv4/6 Saeed Mahameed
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Saeed Mahameed @ 2019-11-13 22:41 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Pablo Neira Ayuso, Eli Cohen, Vlad Buslov, Roi Dayan,
	Saeed Mahameed

From: Eli Cohen <eli@mellanox.com>

Neighbour initializations to NULL are not necessary as the pointers are
not used if an error is returned, and if success returned, pointers are
initialized.

Signed-off-by: Eli Cohen <eli@mellanox.com>
Reviewed-by: Vlad Buslov <vladbu@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
index 13af72556987..4f78efeb6ee8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
@@ -77,8 +77,8 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv,
 				   struct neighbour **out_n,
 				   u8 *out_ttl)
 {
+	struct neighbour *n;
 	struct rtable *rt;
-	struct neighbour *n = NULL;
 
 #if IS_ENABLED(CONFIG_INET)
 	struct mlx5_core_dev *mdev = priv->mdev;
@@ -138,8 +138,8 @@ static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv,
 				   struct neighbour **out_n,
 				   u8 *out_ttl)
 {
-	struct neighbour *n = NULL;
 	struct dst_entry *dst;
+	struct neighbour *n;
 
 #if IS_ENABLED(CONFIG_INET) && IS_ENABLED(CONFIG_IPV6)
 	int ret;
@@ -212,8 +212,8 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,
 	int max_encap_size = MLX5_CAP_ESW(priv->mdev, max_encap_header_size);
 	const struct ip_tunnel_key *tun_key = &e->tun_info->key;
 	struct net_device *out_dev, *route_dev;
-	struct neighbour *n = NULL;
 	struct flowi4 fl4 = {};
+	struct neighbour *n;
 	int ipv4_encap_size;
 	char *encap_header;
 	u8 nud_state, ttl;
@@ -328,9 +328,9 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,
 	int max_encap_size = MLX5_CAP_ESW(priv->mdev, max_encap_header_size);
 	const struct ip_tunnel_key *tun_key = &e->tun_info->key;
 	struct net_device *out_dev, *route_dev;
-	struct neighbour *n = NULL;
 	struct flowi6 fl6 = {};
 	struct ipv6hdr *ip6h;
+	struct neighbour *n;
 	int ipv6_encap_size;
 	char *encap_header;
 	u8 nud_state, ttl;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [net-next V2 4/7] net/mlx5e: Fix error flow cleanup in mlx5e_tc_tun_create_header_ipv4/6
  2019-11-13 22:41 [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12 Saeed Mahameed
                   ` (2 preceding siblings ...)
  2019-11-13 22:41 ` [net-next V2 3/7] net/mlx5: Remove redundant NULL initializations Saeed Mahameed
@ 2019-11-13 22:41 ` Saeed Mahameed
  2019-11-13 22:41 ` [net-next V2 5/7] net/mlx5e: Set netdev name space on creation Saeed Mahameed
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Saeed Mahameed @ 2019-11-13 22:41 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Pablo Neira Ayuso, Eli Cohen, Roi Dayan, Vlad Buslov,
	Saeed Mahameed

From: Eli Cohen <eli@mellanox.com>

Be sure to release the neighbour in case of failures after successful
route lookup.

Signed-off-by: Eli Cohen <eli@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../ethernet/mellanox/mlx5/core/en/tc_tun.c    | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
index 4f78efeb6ee8..5316cedd78bf 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
@@ -239,12 +239,15 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,
 	if (max_encap_size < ipv4_encap_size) {
 		mlx5_core_warn(priv->mdev, "encap size %d too big, max supported is %d\n",
 			       ipv4_encap_size, max_encap_size);
-		return -EOPNOTSUPP;
+		err = -EOPNOTSUPP;
+		goto out;
 	}
 
 	encap_header = kzalloc(ipv4_encap_size, GFP_KERNEL);
-	if (!encap_header)
-		return -ENOMEM;
+	if (!encap_header) {
+		err = -ENOMEM;
+		goto out;
+	}
 
 	/* used by mlx5e_detach_encap to lookup a neigh hash table
 	 * entry in the neigh hash table when a user deletes a rule
@@ -355,12 +358,15 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,
 	if (max_encap_size < ipv6_encap_size) {
 		mlx5_core_warn(priv->mdev, "encap size %d too big, max supported is %d\n",
 			       ipv6_encap_size, max_encap_size);
-		return -EOPNOTSUPP;
+		err = -EOPNOTSUPP;
+		goto out;
 	}
 
 	encap_header = kzalloc(ipv6_encap_size, GFP_KERNEL);
-	if (!encap_header)
-		return -ENOMEM;
+	if (!encap_header) {
+		err = -ENOMEM;
+		goto out;
+	}
 
 	/* used by mlx5e_detach_encap to lookup a neigh hash table
 	 * entry in the neigh hash table when a user deletes a rule
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [net-next V2 5/7] net/mlx5e: Set netdev name space on creation
  2019-11-13 22:41 [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12 Saeed Mahameed
                   ` (3 preceding siblings ...)
  2019-11-13 22:41 ` [net-next V2 4/7] net/mlx5e: Fix error flow cleanup in mlx5e_tc_tun_create_header_ipv4/6 Saeed Mahameed
@ 2019-11-13 22:41 ` Saeed Mahameed
  2019-11-13 22:41 ` [net-next V2 6/7] net/mlx5: Add devlink reload Saeed Mahameed
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Saeed Mahameed @ 2019-11-13 22:41 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Pablo Neira Ayuso, Michael Guralnik, Jiri Pirko, Saeed Mahameed

From: Michael Guralnik <michaelgur@mellanox.com>

Use devlink instance name space to set the netdev net namespace.

Preparation patch for devlink reload implementation.

Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  | 2 ++
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c   | 2 ++
 drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h | 5 +++++
 3 files changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 772bfdbdeb9c..06a592fb62bf 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -63,6 +63,7 @@
 #include "en/xsk/rx.h"
 #include "en/xsk/tx.h"
 #include "en/hv_vhca_stats.h"
+#include "lib/mlx5.h"
 
 
 bool mlx5e_check_fragmented_striding_rq_cap(struct mlx5_core_dev *mdev)
@@ -5427,6 +5428,7 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
 		return NULL;
 	}
 
+	dev_net_set(netdev, mlx5_core_net(mdev));
 	priv = netdev_priv(netdev);
 
 	err = mlx5e_attach(mdev, priv);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index cd9bb7c7b341..c7f98f1fd9b1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -47,6 +47,7 @@
 #include "en/tc_tun.h"
 #include "fs_core.h"
 #include "lib/port_tun.h"
+#include "lib/mlx5.h"
 #define CREATE_TRACE_POINTS
 #include "diag/en_rep_tracepoint.h"
 
@@ -1877,6 +1878,7 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
 		return -EINVAL;
 	}
 
+	dev_net_set(netdev, mlx5_core_net(dev));
 	rpriv->netdev = netdev;
 	rep->rep_data[REP_ETH].priv = rpriv;
 	INIT_LIST_HEAD(&rpriv->vport_sqs_list);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h b/drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h
index b99d469e4e64..249539247e2e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h
@@ -84,4 +84,9 @@ int mlx5_create_encryption_key(struct mlx5_core_dev *mdev,
 			       void *key, u32 sz_bytes, u32 *p_key_id);
 void mlx5_destroy_encryption_key(struct mlx5_core_dev *mdev, u32 key_id);
 
+static inline struct net *mlx5_core_net(struct mlx5_core_dev *dev)
+{
+	return devlink_net(priv_to_devlink(dev));
+}
+
 #endif
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [net-next V2 6/7] net/mlx5: Add devlink reload
  2019-11-13 22:41 [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12 Saeed Mahameed
                   ` (4 preceding siblings ...)
  2019-11-13 22:41 ` [net-next V2 5/7] net/mlx5e: Set netdev name space on creation Saeed Mahameed
@ 2019-11-13 22:41 ` Saeed Mahameed
  2019-11-13 22:41 ` [net-next V2 7/7] net/mlx5: TC: Offload flow table rules Saeed Mahameed
  2019-11-15  2:02 ` [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12 David Miller
  7 siblings, 0 replies; 9+ messages in thread
From: Saeed Mahameed @ 2019-11-13 22:41 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Pablo Neira Ayuso, Michael Guralnik, Jiri Pirko, Saeed Mahameed

From: Michael Guralnik <michaelgur@mellanox.com>

Implement devlink reload for mlx5.

Usage example:
devlink dev reload pci/0000:06:00.0

Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../net/ethernet/mellanox/mlx5/core/devlink.c | 20 +++++++++++++++++++
 .../net/ethernet/mellanox/mlx5/core/main.c    |  4 ++--
 .../ethernet/mellanox/mlx5/core/mlx5_core.h   |  3 +++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
index b2c26388edb1..ac108f1e5bd6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
@@ -85,6 +85,22 @@ mlx5_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
 	return 0;
 }
 
+static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,
+				    struct netlink_ext_ack *extack)
+{
+	struct mlx5_core_dev *dev = devlink_priv(devlink);
+
+	return mlx5_unload_one(dev, false);
+}
+
+static int mlx5_devlink_reload_up(struct devlink *devlink,
+				  struct netlink_ext_ack *extack)
+{
+	struct mlx5_core_dev *dev = devlink_priv(devlink);
+
+	return mlx5_load_one(dev, false);
+}
+
 static const struct devlink_ops mlx5_devlink_ops = {
 #ifdef CONFIG_MLX5_ESWITCH
 	.eswitch_mode_set = mlx5_devlink_eswitch_mode_set,
@@ -96,6 +112,8 @@ static const struct devlink_ops mlx5_devlink_ops = {
 #endif
 	.flash_update = mlx5_devlink_flash_update,
 	.info_get = mlx5_devlink_info_get,
+	.reload_down = mlx5_devlink_reload_down,
+	.reload_up = mlx5_devlink_reload_up,
 };
 
 struct devlink *mlx5_devlink_alloc(void)
@@ -235,6 +253,7 @@ int mlx5_devlink_register(struct devlink *devlink, struct device *dev)
 		goto params_reg_err;
 	mlx5_devlink_set_params_init_values(devlink);
 	devlink_params_publish(devlink);
+	devlink_reload_enable(devlink);
 	return 0;
 
 params_reg_err:
@@ -244,6 +263,7 @@ int mlx5_devlink_register(struct devlink *devlink, struct device *dev)
 
 void mlx5_devlink_unregister(struct devlink *devlink)
 {
+	devlink_reload_disable(devlink);
 	devlink_params_unregister(devlink, mlx5_devlink_params,
 				  ARRAY_SIZE(mlx5_devlink_params));
 	devlink_unregister(devlink);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index c9a091d3226c..31fbfd6e8bb9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -1168,7 +1168,7 @@ static void mlx5_unload(struct mlx5_core_dev *dev)
 	mlx5_put_uars_page(dev, dev->priv.uar);
 }
 
-static int mlx5_load_one(struct mlx5_core_dev *dev, bool boot)
+int mlx5_load_one(struct mlx5_core_dev *dev, bool boot)
 {
 	int err = 0;
 
@@ -1226,7 +1226,7 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, bool boot)
 	return err;
 }
 
-static int mlx5_unload_one(struct mlx5_core_dev *dev, bool cleanup)
+int mlx5_unload_one(struct mlx5_core_dev *dev, bool cleanup)
 {
 	if (cleanup) {
 		mlx5_unregister_device(dev);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index b100489dc85c..da67b28d6e23 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -243,4 +243,7 @@ enum {
 
 u8 mlx5_get_nic_state(struct mlx5_core_dev *dev);
 void mlx5_set_nic_state(struct mlx5_core_dev *dev, u8 state);
+
+int mlx5_unload_one(struct mlx5_core_dev *dev, bool cleanup);
+int mlx5_load_one(struct mlx5_core_dev *dev, bool boot);
 #endif /* __MLX5_CORE_H__ */
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [net-next V2 7/7] net/mlx5: TC: Offload flow table rules
  2019-11-13 22:41 [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12 Saeed Mahameed
                   ` (5 preceding siblings ...)
  2019-11-13 22:41 ` [net-next V2 6/7] net/mlx5: Add devlink reload Saeed Mahameed
@ 2019-11-13 22:41 ` Saeed Mahameed
  2019-11-15  2:02 ` [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12 David Miller
  7 siblings, 0 replies; 9+ messages in thread
From: Saeed Mahameed @ 2019-11-13 22:41 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Pablo Neira Ayuso, Paul Blakey, Mark Bloch, Saeed Mahameed

From: Paul Blakey <paulb@mellanox.com>

Since both tc rules and flow table rules are of the same format,
we can re-use tc parsing for that, and move the flow table rules
to their steering domain - In this case, the next chain after
max tc chain.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Mark Bloch <markb@mellanox.com>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../net/ethernet/mellanox/mlx5/core/en_rep.c  | 45 +++++++++++++++++--
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   | 28 +++++++++++-
 .../net/ethernet/mellanox/mlx5/core/en_tc.h   |  3 +-
 3 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index c7f98f1fd9b1..f175cb24bb67 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -1244,21 +1244,60 @@ static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data,
 	}
 }
 
-static LIST_HEAD(mlx5e_rep_block_cb_list);
+static int mlx5e_rep_setup_ft_cb(enum tc_setup_type type, void *type_data,
+				 void *cb_priv)
+{
+	struct flow_cls_offload *f = type_data;
+	struct flow_cls_offload cls_flower;
+	struct mlx5e_priv *priv = cb_priv;
+	struct mlx5_eswitch *esw;
+	unsigned long flags;
+	int err;
+
+	flags = MLX5_TC_FLAG(INGRESS) |
+		MLX5_TC_FLAG(ESW_OFFLOAD) |
+		MLX5_TC_FLAG(FT_OFFLOAD);
+	esw = priv->mdev->priv.eswitch;
 
+	switch (type) {
+	case TC_SETUP_CLSFLOWER:
+		if (!mlx5_eswitch_prios_supported(esw) || f->common.chain_index)
+			return -EOPNOTSUPP;
+
+		/* Re-use tc offload path by moving the ft flow to the
+		 * reserved ft chain.
+		 */
+		memcpy(&cls_flower, f, sizeof(*f));
+		cls_flower.common.chain_index = FDB_FT_CHAIN;
+		err = mlx5e_rep_setup_tc_cls_flower(priv, &cls_flower, flags);
+		memcpy(&f->stats, &cls_flower.stats, sizeof(f->stats));
+		return err;
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+static LIST_HEAD(mlx5e_rep_block_tc_cb_list);
+static LIST_HEAD(mlx5e_rep_block_ft_cb_list);
 static int mlx5e_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
 			      void *type_data)
 {
 	struct mlx5e_priv *priv = netdev_priv(dev);
 	struct flow_block_offload *f = type_data;
 
+	f->unlocked_driver_cb = true;
+
 	switch (type) {
 	case TC_SETUP_BLOCK:
-		f->unlocked_driver_cb = true;
 		return flow_block_cb_setup_simple(type_data,
-						  &mlx5e_rep_block_cb_list,
+						  &mlx5e_rep_block_tc_cb_list,
 						  mlx5e_rep_setup_tc_cb,
 						  priv, priv, true);
+	case TC_SETUP_FT:
+		return flow_block_cb_setup_simple(type_data,
+						  &mlx5e_rep_block_ft_cb_list,
+						  mlx5e_rep_setup_ft_cb,
+						  priv, priv, true);
 	default:
 		return -EOPNOTSUPP;
 	}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 0c1022cda128..3a707d788022 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -74,6 +74,7 @@ enum {
 	MLX5E_TC_FLOW_FLAG_INGRESS	= MLX5E_TC_FLAG_INGRESS_BIT,
 	MLX5E_TC_FLOW_FLAG_EGRESS	= MLX5E_TC_FLAG_EGRESS_BIT,
 	MLX5E_TC_FLOW_FLAG_ESWITCH	= MLX5E_TC_FLAG_ESW_OFFLOAD_BIT,
+	MLX5E_TC_FLOW_FLAG_FT		= MLX5E_TC_FLAG_FT_OFFLOAD_BIT,
 	MLX5E_TC_FLOW_FLAG_NIC		= MLX5E_TC_FLAG_NIC_OFFLOAD_BIT,
 	MLX5E_TC_FLOW_FLAG_OFFLOADED	= MLX5E_TC_FLOW_BASE,
 	MLX5E_TC_FLOW_FLAG_HAIRPIN	= MLX5E_TC_FLOW_BASE + 1,
@@ -276,6 +277,11 @@ static bool mlx5e_is_eswitch_flow(struct mlx5e_tc_flow *flow)
 	return flow_flag_test(flow, ESWITCH);
 }
 
+static bool mlx5e_is_ft_flow(struct mlx5e_tc_flow *flow)
+{
+	return flow_flag_test(flow, FT);
+}
+
 static bool mlx5e_is_offloaded_flow(struct mlx5e_tc_flow *flow)
 {
 	return flow_flag_test(flow, OFFLOADED);
@@ -1168,7 +1174,12 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
 		return -EOPNOTSUPP;
 	}
 
-	if (attr->chain > max_chain) {
+	/* We check chain range only for tc flows.
+	 * For ft flows, we checked attr->chain was originally 0 and set it to
+	 * FDB_FT_CHAIN which is outside tc range.
+	 * See mlx5e_rep_setup_ft_cb().
+	 */
+	if (!mlx5e_is_ft_flow(flow) && attr->chain > max_chain) {
 		NL_SET_ERR_MSG(extack, "Requested chain is out of supported range");
 		return -EOPNOTSUPP;
 	}
@@ -3217,6 +3228,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
 	struct mlx5e_tc_flow_parse_attr *parse_attr = attr->parse_attr;
 	struct mlx5e_rep_priv *rpriv = priv->ppriv;
 	const struct ip_tunnel_info *info = NULL;
+	bool ft_flow = mlx5e_is_ft_flow(flow);
 	const struct flow_action_entry *act;
 	bool encap = false;
 	u32 action = 0;
@@ -3261,6 +3273,14 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
 				return -EINVAL;
 			}
 
+			if (ft_flow && out_dev == priv->netdev) {
+				/* Ignore forward to self rules generated
+				 * by adding both mlx5 devs to the flow table
+				 * block on a normal nft offload setup.
+				 */
+				return -EOPNOTSUPP;
+			}
+
 			if (attr->out_count >= MLX5_MAX_FLOW_FWD_VPORTS) {
 				NL_SET_ERR_MSG_MOD(extack,
 						   "can't support more output ports, can't offload forwarding");
@@ -3385,6 +3405,10 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
 			u32 dest_chain = act->chain_index;
 			u32 max_chain = mlx5_eswitch_get_chain_range(esw);
 
+			if (ft_flow) {
+				NL_SET_ERR_MSG_MOD(extack, "Goto action is not supported");
+				return -EOPNOTSUPP;
+			}
 			if (dest_chain <= attr->chain) {
 				NL_SET_ERR_MSG(extack, "Goto earlier chain isn't supported");
 				return -EOPNOTSUPP;
@@ -3475,6 +3499,8 @@ static void get_flags(int flags, unsigned long *flow_flags)
 		__flow_flags |= BIT(MLX5E_TC_FLOW_FLAG_ESWITCH);
 	if (flags & MLX5_TC_FLAG(NIC_OFFLOAD))
 		__flow_flags |= BIT(MLX5E_TC_FLOW_FLAG_NIC);
+	if (flags & MLX5_TC_FLAG(FT_OFFLOAD))
+		__flow_flags |= BIT(MLX5E_TC_FLOW_FLAG_FT);
 
 	*flow_flags = __flow_flags;
 }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
index 924c6ef86a14..262cdb7b69b1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
@@ -44,7 +44,8 @@ enum {
 	MLX5E_TC_FLAG_EGRESS_BIT,
 	MLX5E_TC_FLAG_NIC_OFFLOAD_BIT,
 	MLX5E_TC_FLAG_ESW_OFFLOAD_BIT,
-	MLX5E_TC_FLAG_LAST_EXPORTED_BIT = MLX5E_TC_FLAG_ESW_OFFLOAD_BIT,
+	MLX5E_TC_FLAG_FT_OFFLOAD_BIT,
+	MLX5E_TC_FLAG_LAST_EXPORTED_BIT = MLX5E_TC_FLAG_FT_OFFLOAD_BIT,
 };
 
 #define MLX5_TC_FLAG(flag) BIT(MLX5E_TC_FLAG_##flag##_BIT)
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12
  2019-11-13 22:41 [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12 Saeed Mahameed
                   ` (6 preceding siblings ...)
  2019-11-13 22:41 ` [net-next V2 7/7] net/mlx5: TC: Offload flow table rules Saeed Mahameed
@ 2019-11-15  2:02 ` David Miller
  7 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2019-11-15  2:02 UTC (permalink / raw)
  To: saeedm; +Cc: netdev, pablo

From: Saeed Mahameed <saeedm@mellanox.com>
Date: Wed, 13 Nov 2019 22:41:29 +0000

> This series adds misc updates to mlx5 driver,
> For more information please see tag log below.
> 
> Highlights:
> 1) Devlink reload support
> 2) TC Flowtable offloads 
> 
> Please pull and let me know if there is any problem.
> Please note that the series starts with a merge of mlx5-next branch,
> to resolve and avoid dependency with rdma tree.
> 
> v1->v2:
> - dropped the 2 patches dealing with sriov vlan trunks, as it was nacked.
> - merged the flowtables offloads low level infrastructure into mlx5-next
>   and updated the mlx5-next merge commit.
> - added mlx5 TC flowtables offload support patch on top of this series.

Pulled, thank you.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-11-15  2:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-13 22:41 [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12 Saeed Mahameed
2019-11-13 22:41 ` [net-next V2 1/7] net/mlx5: DR, Fix matcher builders select check Saeed Mahameed
2019-11-13 22:41 ` [net-next V2 2/7] net/mlx5: Read num_vfs before disabling SR-IOV Saeed Mahameed
2019-11-13 22:41 ` [net-next V2 3/7] net/mlx5: Remove redundant NULL initializations Saeed Mahameed
2019-11-13 22:41 ` [net-next V2 4/7] net/mlx5e: Fix error flow cleanup in mlx5e_tc_tun_create_header_ipv4/6 Saeed Mahameed
2019-11-13 22:41 ` [net-next V2 5/7] net/mlx5e: Set netdev name space on creation Saeed Mahameed
2019-11-13 22:41 ` [net-next V2 6/7] net/mlx5: Add devlink reload Saeed Mahameed
2019-11-13 22:41 ` [net-next V2 7/7] net/mlx5: TC: Offload flow table rules Saeed Mahameed
2019-11-15  2:02 ` [pull request][net-next V2 0/7] Mellanox, mlx5 updates 2019-11-12 David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).