Skip to contentSkip to conversation

Mellanox, mlx5 fixes 2019-05-28

GIT PULL New Saeed Mahameed 2 participants 8 messages May 29, 2019 – May 30, 2019

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

Hi Dave,

This series introduces some fixes to mlx5 driver.

Please pull and let me know if there is any problem.

For -stable v4.13:
('net/mlx5: Allocate root ns memory using kzalloc to match kfree')

For -stable v4.16:
('net/mlx5: Avoid double free in fs init error unwinding path')

For -stable v4.18:
('net/mlx5e: Disable rxhash when CQE compress is enabled')

Thanks,
Saeed.

---
The following changes since commit a6cd0d2d493ab7806b49f738b4f66362437cc09e:

Documentation: net-sysfs: Remove duplicate PHY device documentation (2019-05-28 17:26:44 -0700)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2019-05-28

for you to fetch changes up to c0194e2d0ef0e5ce5e21a35640d23a706827ae28:

net/mlx5e: Disable rxhash when CQE compress is enabled (2019-05-28 18:25:42 -0700)

----------------------------------------------------------------
mlx5-fixes-2019-05-28

----------------------------------------------------------------
Parav Pandit (3):
net/mlx5: Avoid double free of root ns in the error flow path net/mlx5: Avoid double free in fs init error unwinding path net/mlx5: Allocate root ns memory using kzalloc to match kfree

Saeed Mahameed (2):
net/mlx5: Fix error handling in mlx5_load() net/mlx5e: Disable rxhash when CQE compress is enabled

wenxu (1):
net/mlx5e: restrict the real_dev of vlan device is the same as uplink device

 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 13 ++++++++++++
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c  |  2 +-
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 24 ++++++++---------------
 drivers/net/ethernet/mellanox/mlx5/core/main.c    |  2 +-
 4 files changed, 23 insertions(+), 18 deletions(-)
#1 lore raw

PATCH 1/6 net/mlx5: Fix error handling in mlx5_load()

In case mlx5_core_set_hca_defaults fails, it should jump to mlx5_cleanup_fs, fix that.

Fixes c85023e153e3 ("IB/mlx5: Add raw ethernet local loopback support")
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +1 -1
index 61fa1d162d28..23d53163ce15 100644
@@ -1067,7 +1067,7 @@ static int mlx5_load(struct mlx5_core_dev *dev)
 	err = mlx5_core_set_hca_defaults(dev);
 	if (err) {
 		mlx5_core_err(dev, "Failed to set hca defaults\n");
-		goto err_fs;
+		goto err_sriov;
 	}
 
 	err = mlx5_sriov_attach(dev);
Signature · 1 line
2.21.0
#2 lore raw

PATCH 2/6 net/mlx5: Avoid double free of root ns in the error flow path

In reply to Saeed Mahameed

From: Parav Pandit <[email protected]>

When root ns setup for rdma, sniffer tx and sniffer rx fails, such root ns cleanup is done by the error unwinding path of mlx5_cleanup_fs().
Below call graph shows an example for sniffer_rx_root_ns.

mlx5_init_fs()
init_sniffer_rx_root_ns()

    cleanup_root_ns(steering->sniffer_rx_root_ns);

mlx5_cleanup_fs()
cleanup_root_ns(steering->sniffer_rx_root_ns);
/* double free of sniffer_rx_root_ns */

Hence, use the existing cleanup_fs to cleanup.

Fixes d83eb50e29de3 ("net/mlx5: Add support in RDMA RX steering")
Fixes 87d22483ce68e ("net/mlx5: Add sniffer namespaces")
---
 .../net/ethernet/mellanox/mlx5/core/fs_core.c  | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +3 -15
index d7ca7e82a832..4fa87ca63bca 100644
@@ -2474,11 +2474,7 @@ static int init_sniffer_tx_root_ns(struct mlx5_flow_steering *steering)
 
 	/* Create single prio */
 	prio = fs_create_prio(&steering->sniffer_tx_root_ns->ns, 0, 1);
-	if (IS_ERR(prio)) {
-		cleanup_root_ns(steering->sniffer_tx_root_ns);
-		return PTR_ERR(prio);
-	}
-	return 0;
+	return PTR_ERR_OR_ZERO(prio);
 }
 
 static int init_sniffer_rx_root_ns(struct mlx5_flow_steering *steering)
@@ -2491,11 +2487,7 @@ static int init_sniffer_rx_root_ns(struct mlx5_flow_steering *steering)
 
 	/* Create single prio */
 	prio = fs_create_prio(&steering->sniffer_rx_root_ns->ns, 0, 1);
-	if (IS_ERR(prio)) {
-		cleanup_root_ns(steering->sniffer_rx_root_ns);
-		return PTR_ERR(prio);
-	}
-	return 0;
+	return PTR_ERR_OR_ZERO(prio);
 }
 
 static int init_rdma_rx_root_ns(struct mlx5_flow_steering *steering)
@@ -2511,11 +2503,7 @@ static int init_rdma_rx_root_ns(struct mlx5_flow_steering *steering)
 
 	/* Create single prio */
 	prio = fs_create_prio(&steering->rdma_rx_root_ns->ns, 0, 1);
-	if (IS_ERR(prio)) {
-		cleanup_root_ns(steering->rdma_rx_root_ns);
-		return PTR_ERR(prio);
-	}
-	return 0;
+	return PTR_ERR_OR_ZERO(prio);
 }
 static int init_fdb_root_ns(struct mlx5_flow_steering *steering)
 {
Signature · 1 line
2.21.0
#3 lore raw

PATCH 3/6 net/mlx5: Avoid double free in fs init error unwinding path

In reply to Saeed Mahameed

From: Parav Pandit <[email protected]>

In below code flow, for ingress acl table root ns memory leads to double free.

mlx5_init_fs
init_ingress_acls_root_ns()

    init_ingress_acl_root_ns
       kfree(steering->esw_ingress_root_ns);
       /* steering->esw_ingress_root_ns is not marked NULL */
  mlx5_cleanup_fs
    cleanup_ingress_acls_root_ns
       steering->esw_ingress_root_ns non NULL check passes.
       kfree(steering->esw_ingress_root_ns);
       /* double free */

Similar issue exist for other tables.

Hence zero out the pointers to not process the table again.

Fixes 9b93ab981e3bf ("net/mlx5: Separate ingress/egress namespaces for each vport")
Fixes 40c3eebb49e51 ("net/mlx5: Add support in RDMA RX steering")
---
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +4 -0
index 4fa87ca63bca..34276a2b6da2 100644
@@ -2427,6 +2427,7 @@ static void cleanup_egress_acls_root_ns(struct mlx5_core_dev *dev)
 		cleanup_root_ns(steering->esw_egress_root_ns[i]);
 
 	kfree(steering->esw_egress_root_ns);
+	steering->esw_egress_root_ns = NULL;
 }
 
 static void cleanup_ingress_acls_root_ns(struct mlx5_core_dev *dev)
@@ -2441,6 +2442,7 @@ static void cleanup_ingress_acls_root_ns(struct mlx5_core_dev *dev)
 		cleanup_root_ns(steering->esw_ingress_root_ns[i]);
 
 	kfree(steering->esw_ingress_root_ns);
+	steering->esw_ingress_root_ns = NULL;
 }
 
 void mlx5_cleanup_fs(struct mlx5_core_dev *dev)
@@ -2625,6 +2627,7 @@ static int init_egress_acls_root_ns(struct mlx5_core_dev *dev)
 	for (i--; i >= 0; i--)
 		cleanup_root_ns(steering->esw_egress_root_ns[i]);
 	kfree(steering->esw_egress_root_ns);
+	steering->esw_egress_root_ns = NULL;
 	return err;
 }
 
@@ -2652,6 +2655,7 @@ static int init_ingress_acls_root_ns(struct mlx5_core_dev *dev)
 	for (i--; i >= 0; i--)
 		cleanup_root_ns(steering->esw_ingress_root_ns[i]);
 	kfree(steering->esw_ingress_root_ns);
+	steering->esw_ingress_root_ns = NULL;
 	return err;
 }
 
Signature · 1 line
2.21.0
#4 lore raw

PATCH 4/6 net/mlx5: Allocate root ns memory using kzalloc to match kfree

In reply to Saeed Mahameed

From: Parav Pandit <[email protected]>

root ns is yet another fs core node which is freed using kfree() by tree_put_node().
Rest of the other fs core objects are also allocated using kmalloc variants.

However, root ns memory is allocated using kvzalloc(). Hence allocate root ns memory using kzalloc().

Fixes 2530236303d9e ("net/mlx5_core: Flow steering tree initialization")
---
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +1 -1
index 34276a2b6da2..fe76c6fd6d80 100644
@@ -2284,7 +2284,7 @@ static struct mlx5_flow_root_namespace
 		cmds = mlx5_fs_cmd_get_default_ipsec_fpga_cmds(table_type);
 
 	/* Create the root namespace */
-	root_ns = kvzalloc(sizeof(*root_ns), GFP_KERNEL);
+	root_ns = kzalloc(sizeof(*root_ns), GFP_KERNEL);
 	if (!root_ns)
 		return NULL;
 
Signature · 1 line
2.21.0
#5 lore raw

PATCH 5/6 net/mlx5e: restrict the real_dev of vlan device is the same as uplink device

In reply to Saeed Mahameed

From: wenxu <[email protected]>

When register indr block for vlan device, it should check the real_dev of vlan device is same as uplink device. Or it will set offload rule to mlx5e which will never hit.

Fixes 35a605db168c ("net/mlx5e: Offload TC e-switch rules with ingress VLAN device")
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +1 -1
index 5283e16c69e4..9aea9c5b2ce8 100644
@@ -813,7 +813,7 @@ static int mlx5e_nic_rep_netdevice_event(struct notifier_block *nb,
 	struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
 
 	if (!mlx5e_tc_tun_device_to_offload(priv, netdev) &&
-	    !is_vlan_dev(netdev))
+	    !(is_vlan_dev(netdev) && vlan_dev_real_dev(netdev) == rpriv->netdev))
 		return NOTIFY_OK;
 
 	switch (event) {
Signature · 1 line
2.21.0
#6 lore raw

PATCH 6/6 net/mlx5e: Disable rxhash when CQE compress is enabled

In reply to Saeed Mahameed

When CQE compression is enabled (Multi-host systems), compressed CQEs might arrive to the driver rx, compressed CQEs don't have a valid hash offload and the driver already reports a hash value of 0 and invalid hash type on the skb for compressed CQEs, but this is not good enough.

On a congested PCIe, where CQE compression will kick in aggressively, gro will deliver lots of out of order packets due to the invalid hash and this might cause a serious performance drop.

The only valid solution, is to disable rxhash offload at all when CQE compression is favorable (Multi-host systems).

Fixes 7219ab34f184 ("net/mlx5e: CQE compression")
CC Jes Sorensen <[email protected]>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +13 -0
index 457cc39423f2..c65cefd84eda 100644
@@ -3687,6 +3687,12 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev,
 			netdev_warn(netdev, "Disabling LRO, not supported in legacy RQ\n");
 	}
 
+	if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS)) {
+		features &= ~NETIF_F_RXHASH;
+		if (netdev->features & NETIF_F_RXHASH)
+			netdev_warn(netdev, "Disabling rxhash, not supported when CQE compress is active\n");
+	}
+
 	mutex_unlock(&priv->state_lock);
 
 	return features;
@@ -3812,6 +3818,9 @@ int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr)
 	memcpy(&priv->tstamp, &config, sizeof(config));
 	mutex_unlock(&priv->state_lock);
 
+	/* might need to fix some features */
+	netdev_update_features(priv->netdev);
+
 	return copy_to_user(ifr->ifr_data, &config,
 			    sizeof(config)) ? -EFAULT : 0;
 }
@@ -4680,6 +4689,10 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
 	if (!priv->channels.params.scatter_fcs_en)
 		netdev->features  &= ~NETIF_F_RXFCS;
 
+	/* prefere CQE compression over rxhash */
+	if (MLX5E_GET_PFLAG(&priv->channels.params, MLX5E_PFLAG_RX_CQE_COMPRESS))
+		netdev->features &= ~NETIF_F_RXHASH;
+
 #define FT_CAP(f) MLX5_CAP_FLOWTABLE(mdev, flow_table_properties_nic_receive.f)
 	if (FT_CAP(flow_modify_en) &&
 	    FT_CAP(modify_root) &&
Signature · 1 line
2.21.0
maintainer
#7 lore raw
In reply to Saeed Mahameed

From: Saeed Mahameed <[email protected]>
Date: Wed, 29 May 2019 02:07:57 +0000

Quoted 3 lines

This series introduces some fixes to mlx5 driver.

Please pull and let me know if there is any problem.

Pulled.

Quoted 8 lines

For -stable v4.13:
('net/mlx5: Allocate root ns memory using kzalloc to match kfree')

For -stable v4.16:
('net/mlx5: Avoid double free in fs init error unwinding path')

For -stable v4.18:
('net/mlx5e: Disable rxhash when CQE compress is enabled')

Queued up.