Skip to contentSkip to conversation

mlx5 fixes for 4.11

PATCH In review Leon Romanovsky 4 participants 16 messages Jan 18, 2017 – Feb 14, 2017 6 messages not in the archive

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

cover mlx5 fixes for 4.11

Hi Doug,

Please find below seven fixes to mlx5 driver.

This patchset was generated against commit
f502d834950a ("net/mlx5: Activate support for 4K UARs") and it applies cleanly on k.o/for-4.11 branch.

Available in the "topic/mlx5-fixes-4.11" topic branch of this git repo:
git://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git

Or for browsing:
https://git.kernel.org/cgit/linux/kernel/git/leon/linux-rdma.git/log/?h=topic/mlx5-fixes-4.11

Kamal Heib (1):
IB/mlx5: Verify that Q counters are supported

Leon Romanovsky (3):
IB/mlx5: Fix out-of-bound access
IB/mlx5: Return error for unsupported signature type IB/mlx5: Remove deprecated module parameter

Majd Dibbiny (1):
IB/mlx5: Assign DSCP for R-RoCE QPs Address Path

Maor Gottlieb (2):
IB/mlx5: Add additional checks before processing MADs IB/mlx5: Avoid SMP MADs from VFs

 drivers/infiniband/hw/mlx5/mad.c     | 12 ++++++
 drivers/infiniband/hw/mlx5/main.c    | 75 ++++++++++++++++++++++++++++++------
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  2 +
 drivers/infiniband/hw/mlx5/qp.c      | 18 ++++++++-
 drivers/infiniband/hw/mlx5/srq.c     | 11 ++----
 include/linux/mlx5/driver.h          |  1 +
 6 files changed, 97 insertions(+), 22 deletions(-)

--
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170118121036.32642-1-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org

#2 lore raw

PATCH 1/7 IB/mlx5: Fix out-of-bound access

From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>

When we initialize buffer to create SRQ in kernel, the number of pages was less than actually used in following mlx5_fill_page_array().

Fixes e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
Cc <[email protected]> # v3.10+
---
 drivers/infiniband/hw/mlx5/srq.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/infiniband/hw/mlx5/srq.c +3 -8
index 6f4397e..7cb145f 100644
@@ -165,8 +165,6 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
 	int err;
 	int i;
 	struct mlx5_wqe_srq_next_seg *next;
-	int page_shift;
-	int npages;
 
 	err = mlx5_db_alloc(dev->mdev, &srq->db);
 	if (err) {
@@ -179,7 +177,6 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
 		err = -ENOMEM;
 		goto err_db;
 	}
-	page_shift = srq->buf.page_shift;
 
 	srq->head    = 0;
 	srq->tail    = srq->msrq.max - 1;
@@ -191,10 +188,8 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
 			cpu_to_be16((i + 1) & (srq->msrq.max - 1));
 	}
 
-	npages = DIV_ROUND_UP(srq->buf.npages, 1 << (page_shift - PAGE_SHIFT));
-	mlx5_ib_dbg(dev, "buf_size %d, page_shift %d, npages %d, calc npages %d\n",
-		    buf_size, page_shift, srq->buf.npages, npages);
-	in->pas = mlx5_vzalloc(sizeof(*in->pas) * npages);
+	mlx5_ib_dbg(dev, "srq->buf.page_shift = %d\n", srq->buf.page_shift);
+	in->pas = mlx5_vzalloc(sizeof(*in->pas) * srq->buf.npages);
 	if (!in->pas) {
 		err = -ENOMEM;
 		goto err_buf;
@@ -208,7 +203,7 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
 	}
 	srq->wq_sig = !!srq_signature;
 
-	in->log_page_size = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
+	in->log_page_size = srq->buf.page_shift - MLX5_ADAPTER_PAGE_SHIFT;
 	if (MLX5_CAP_GEN(dev->mdev, cqe_version) == MLX5_CQE_VERSION_V1 &&
 	    in->type == IB_SRQT_XRC)
 		in->user_index = MLX5_IB_DEFAULT_UIDX;

--
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

PATCH 2/7 IB/mlx5: Return error for unsupported signature type

In reply to a message not in the archive

From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>

In case of unsupported singature, we returned positive value, while the better approach is to return -EINVAL.

In addition, in this change, the error print is enriched to provide an actual supplied signature type.

Fixes e6631814fb3a ("IB/mlx5: Support IB_WR_REG_SIG_MR")
Cc Sagi Grimberg <[email protected]>
---
 drivers/infiniband/hw/mlx5/qp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +3 -2
index 6a83fb3..9021074 100644
@@ -3637,8 +3637,9 @@ static int set_psv_wr(struct ib_sig_domain *domain,
 		psv_seg->ref_tag = cpu_to_be32(domain->sig.dif.ref_tag);
 		break;
 	default:
-		pr_err("Bad signature type given.\n");
-		return 1;
+		pr_err("Bad signature type (%d) is given.\n",
+		       domain->sig_type);
+		return -EINVAL;
 	}
 
 	*seg += sizeof(*psv_seg);
Signature · 6 lines
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170118121036.32642-3-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org

#5 lore raw

Re: [PATCH rdma-next 2/7] IB/mlx5: Return error for unsupported signature type

Quoted 7 lines · Leon Romanovsky

From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>

In case of unsupported singature, we returned positive value, while the better approach is to return -EINVAL.

In addition, in this change, the error print is enriched to provide an actual supplied signature type.

What's the reason for the empty warnings i see in callers of this function? ("mlx5_ib_warn(dev, "\n");".

Can we remove these while we are here?

Quoted 33 lines
Fixes e6631814fb3a ("IB/mlx5: Support IB_WR_REG_SIG_MR")
Cc Sagi Grimberg <[email protected]>
---
 drivers/infiniband/hw/mlx5/qp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +3 -2
index 6a83fb3..9021074 100644
@@ -3637,8 +3637,9 @@ static int set_psv_wr(struct ib_sig_domain *domain,
 		psv_seg->ref_tag = cpu_to_be32(domain->sig.dif.ref_tag);
 		break;
 	default:
-		pr_err("Bad signature type given.\n");
-		return 1;
+		pr_err("Bad signature type (%d) is given.\n",
+		       domain->sig_type);
+		return -EINVAL;
 	}
 
 	*seg += sizeof(*psv_seg);
Signature · 6 lines
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

Re: [PATCH rdma-next 2/7] IB/mlx5: Return error for unsupported signature type

Quoted 11 lines · Yuval Shaia
Quoted 7 lines · Leon Romanovsky

From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>

In case of unsupported singature, we returned positive value, while the better approach is to return -EINVAL.

In addition, in this change, the error print is enriched to provide an actual supplied signature type.

What's the reason for the empty warnings i see in callers of this function? ("mlx5_ib_warn(dev, "\n");".

mlx5_ib_warn prints line and function name and in this format it mimics tracepoint.

Quoted 2 lines

Can we remove these while we are here?

mlx5 prints deserve complete series, there are a lot of them need to be revised. I prefer to do it all it once.

Quoted 34 lines
Quoted 34 lines
Fixes e6631814fb3a ("IB/mlx5: Support IB_WR_REG_SIG_MR")
Cc Sagi Grimberg <[email protected]>
---
 drivers/infiniband/hw/mlx5/qp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +3 -3
index 6a83fb3..9021074 100644
@@ -3637,8 +3637,9 @@ static int set_psv_wr(struct ib_sig_domain *domain,
 		psv_seg->ref_tag = cpu_to_be32(domain->sig.dif.ref_tag);
 		break;
 	default:
-		pr_err("Bad signature type given.\n");
-		return 1;
+		pr_err("Bad signature type (%d) is given.\n",
+		       domain->sig_type);
+		return -EINVAL;
 	}
 
 	*seg += sizeof(*psv_seg);
--

2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170119064107.GK32481-U/[email protected]

#8 lore raw

Re: [PATCH rdma-next 2/7] IB/mlx5: Return error for unsupported signature type

Quoted 11 lines
Quoted 3 lines

What's the reason for the empty warnings i see in callers of this function? ("mlx5_ib_warn(dev, "\n");".

mlx5_ib_warn prints line and function name and in this format it mimics tracepoint.

Quoted 2 lines

Can we remove these while we are here?

mlx5 prints deserve complete series, there are a lot of them need to be revised. I prefer to do it all it once.

I have to agree with Leon, that would help a lot.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw

PATCH 3/7 IB/mlx5: Verify that Q counters are supported

In reply to a message not in the archive

From: Kamal Heib <kamalh-VPRAkNaXOzVWk0Htik3J/[email protected]>

Make sure that the Q counters are supported by the FW before trying to allocate/deallocte them, this will avoid driver load failure when they aren't supported by the FW.

---
 drivers/infiniband/hw/mlx5/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/infiniband/hw/mlx5/main.c +9 -5
index a191b93..0187f1d 100644
@@ -3313,9 +3313,11 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
 	if (err)
 		goto err_rsrc;
 
-	err = mlx5_ib_alloc_q_counters(dev);
-	if (err)
-		goto err_odp;
+	if (MLX5_CAP_GEN(dev->mdev, max_qp_cnt)) {
+		err = mlx5_ib_alloc_q_counters(dev);
+		if (err)
+			goto err_odp;
+	}
 
 	dev->mdev->priv.uar = mlx5_get_uars_page(dev->mdev);
 	if (!dev->mdev->priv.uar)
@@ -3364,7 +3366,8 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
 	mlx5_put_uars_page(dev->mdev, dev->mdev->priv.uar);
 
 err_q_cnt:
-	mlx5_ib_dealloc_q_counters(dev);
+	if (MLX5_CAP_GEN(dev->mdev, max_qp_cnt))
+		mlx5_ib_dealloc_q_counters(dev);
 
 err_odp:
 	mlx5_ib_odp_remove_one(dev);
@@ -3397,7 +3400,8 @@ static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context)
 	mlx5_free_bfreg(dev->mdev, &dev->fp_bfreg);
 	mlx5_free_bfreg(dev->mdev, &dev->bfreg);
 	mlx5_put_uars_page(dev->mdev, mdev->priv.uar);
-	mlx5_ib_dealloc_q_counters(dev);
+	if (MLX5_CAP_GEN(dev->mdev, max_qp_cnt))
+		mlx5_ib_dealloc_q_counters(dev);
 	destroy_umrc_res(dev);
 	mlx5_ib_odp_remove_one(dev);
 	destroy_dev_resources(&dev->devr);

--
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw

PATCH 4/7 IB/mlx5: Add additional checks before processing MADs

In reply to a message not in the archive

From: Maor Gottlieb <maorg-VPRAkNaXOzVWk0Htik3J/[email protected]>

Check the has_smi bit in vport context and class version of MADs before allowing MADs processing to take place.
MAD_IFC SMI commands can be executed only if smi bit is set.

---
 drivers/infiniband/hw/mlx5/mad.c  | 12 ++++++++++++
 drivers/infiniband/hw/mlx5/main.c | 33 +++++++++++++++++++++++++++++++++
 include/linux/mlx5/driver.h       |  1 +
 3 files changed, 46 insertions(+)
drivers/infiniband/hw/mlx5/mad.c +12 -0
index 39e5848..af962e7 100644
@@ -42,12 +42,24 @@ enum {
 	MLX5_IB_VENDOR_CLASS2 = 0xa
 };
 
+static bool can_do_mad_ifc(struct mlx5_ib_dev *dev, u8 port_num,
+			   struct ib_mad *in_mad)
+{
+	if (in_mad->mad_hdr.mgmt_class != IB_MGMT_CLASS_SUBN_LID_ROUTED &&
+	    in_mad->mad_hdr.mgmt_class != IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
+		return true;
+	return dev->mdev->port_caps[port_num - 1].has_smi;
+}
+
 int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey,
 		 u8 port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
 		 const void *in_mad, void *response_mad)
 {
 	u8 op_modifier = 0;
 
+	if (!can_do_mad_ifc(dev, port, (struct ib_mad *)in_mad))
+		return -EPERM;
+
 	/* Key check traps can't be generated unless we have in_wc to
 	 * tell us where to send the trap.
 	 */
drivers/infiniband/hw/mlx5/main.c +33 -0
index 0187f1d..1dea407 100644
@@ -2533,6 +2533,35 @@ static void mlx5_ib_event(struct mlx5_core_dev *dev, void *context,
 		ibdev->ib_active = false;
 }
 
+static int set_has_smi_cap(struct mlx5_ib_dev *dev)
+{
+	struct mlx5_hca_vport_context vport_ctx;
+	int err;
+	int port;
+
+	for (port = 1; port <= MLX5_CAP_GEN(dev->mdev, num_ports); port++) {
+		dev->mdev->port_caps[port - 1].has_smi = false;
+		if (MLX5_CAP_GEN(dev->mdev, port_type) ==
+		    MLX5_CAP_PORT_TYPE_IB) {
+			if (MLX5_CAP_GEN(dev->mdev, ib_virt)) {
+				err = mlx5_query_hca_vport_context(dev->mdev, 0,
+								   port, 0,
+								   &vport_ctx);
+				if (err) {
+					mlx5_ib_err(dev, "query_hca_vport_context for port=%d failed %d\n",
+						    port, err);
+					return err;
+				}
+				dev->mdev->port_caps[port - 1].has_smi =
+					vport_ctx.has_smi;
+			} else {
+				dev->mdev->port_caps[port - 1].has_smi = true;
+			}
+		}
+	}
+	return 0;
+}
+
 static void get_ext_port_caps(struct mlx5_ib_dev *dev)
 {
 	int port;
@@ -2557,6 +2586,10 @@ static int get_port_caps(struct mlx5_ib_dev *dev)
 	if (!dprops)
 		goto out;
 
+	err = set_has_smi_cap(dev);
+	if (err)
+		goto out;
+
 	err = mlx5_ib_query_device(&dev->ib_dev, dprops, &uhw);
 	if (err) {
 		mlx5_ib_warn(dev, "query_device failed %d\n", err);
include/linux/mlx5/driver.h +1 -0
index 10e6325..319c3e5 100644
@@ -290,6 +290,7 @@ struct mlx5_port_caps {
 	int	gid_table_len;
 	int	pkey_table_len;
 	u8	ext_port_cap;
+	bool	has_smi;
 };
 
 struct mlx5_cmd_mailbox {
Signature · 6 lines
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw

PATCH 5/7 IB/mlx5: Avoid SMP MADs from VFs

In reply to a message not in the archive

From: Maor Gottlieb <maorg-VPRAkNaXOzVWk0Htik3J/[email protected]>

According to the device specification, we need to check that the has_smi bit is set in vport context before allowing send SMP MADs from VF.

Fixes e126ba97dba9 ('mlx5: Add driver for Mellanox Connect-IB adapters')
---
 drivers/infiniband/hw/mlx5/qp.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/infiniband/hw/mlx5/qp.c +6 -0
index 9021074..9af9b95 100644
@@ -3979,6 +3979,12 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 			break;
 
 		case IB_QPT_SMI:
+			if (unlikely(!mdev->port_caps[qp->port - 1].has_smi)) {
+				mlx5_ib_warn(dev, "Send SMP MADs is not allowed\n");
+				err = -EPERM;
+				*bad_wr = wr;
+				goto out;
+			}
 		case MLX5_IB_QPT_HW_GSI:
 			set_datagram_seg(seg, wr);
 			seg += sizeof(struct mlx5_wqe_datagram_seg);
Signature · 6 lines
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw

PATCH 6/7 IB/mlx5: Assign DSCP for R-RoCE QPs Address Path

In reply to a message not in the archive

From: Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/[email protected]>

For Routable RoCE QPs, the DSCP should be set in the QP's address path.

The DSCP's value is derived from the traffic class.

Fixes 2811ba51b049 ("IB/mlx5: Add RoCE fields to Address Vector")
Cc Achiad Shochat <achiad-VPRAkNaXOzVWk0Htik3J/[email protected]>
---
 drivers/infiniband/hw/mlx5/main.c    | 21 +++++++++++++++++++++
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  2 ++
 drivers/infiniband/hw/mlx5/qp.c      |  7 +++++++
 3 files changed, 30 insertions(+)
drivers/infiniband/hw/mlx5/main.c +21 -0
index 1dea407..6a81f027 100644
@@ -325,6 +325,27 @@ __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num,
 	return cpu_to_be16(MLX5_CAP_ROCE(dev->mdev, r_roce_min_src_udp_port));
 }
 
+int mlx5_get_roce_gid_type(struct mlx5_ib_dev *dev, u8 port_num,
+			   int index, enum ib_gid_type *gid_type)
+{
+	struct ib_gid_attr attr;
+	union ib_gid gid;
+	int ret;
+
+	ret = ib_get_cached_gid(&dev->ib_dev, port_num, index, &gid, &attr);
+	if (ret)
+		return ret;
+
+	if (!attr.ndev)
+		return -ENODEV;
+
+	dev_put(attr.ndev);
+
+	*gid_type = attr.gid_type;
+
+	return 0;
+}
+
 static int mlx5_use_mad_ifc(struct mlx5_ib_dev *dev)
 {
 	if (MLX5_CAP_GEN(dev->mdev, port_type) == MLX5_CAP_PORT_TYPE_IB)
drivers/infiniband/hw/mlx5/mlx5_ib.h +2 -0
index e1a4b93d..dda01d7 100644
@@ -872,6 +872,8 @@ int mlx5_ib_set_vf_guid(struct ib_device *device, int vf, u8 port,
 
 __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num,
 			       int index);
+int mlx5_get_roce_gid_type(struct mlx5_ib_dev *dev, u8 port_num,
+			   int index, enum ib_gid_type *gid_type);
 
 /* GSI QP helper functions */
 struct ib_qp *mlx5_ib_gsi_create_qp(struct ib_pd *pd,
drivers/infiniband/hw/mlx5/qp.c +7 -0
index 9af9b95..e22d957 100644
@@ -2198,6 +2198,7 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
 {
 	enum rdma_link_layer ll = rdma_port_get_link_layer(&dev->ib_dev, port);
 	int err;
+	enum ib_gid_type gid_type;
 
 	if (attr_mask & IB_QP_PKEY_INDEX)
 		path->pkey_index = cpu_to_be16(alt ? attr->alt_pkey_index :
@@ -2216,10 +2217,16 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
 	if (ll == IB_LINK_LAYER_ETHERNET) {
 		if (!(ah->ah_flags & IB_AH_GRH))
 			return -EINVAL;
+		err = mlx5_get_roce_gid_type(dev, port, ah->grh.sgid_index,
+					     &gid_type);
+		if (err)
+			return err;
 		memcpy(path->rmac, ah->dmac, sizeof(ah->dmac));
 		path->udp_sport = mlx5_get_roce_udp_sport(dev, port,
 							  ah->grh.sgid_index);
 		path->dci_cfi_prio_sl = (ah->sl & 0x7) << 4;
+		if (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP)
+			path->ecn_dscp = (ah->grh.traffic_class >> 2) & 0x3f;
 	} else {
 		path->fl_free_ar = (path_flags & MLX5_PATH_FLAG_FL) ? 0x80 : 0;
 		path->fl_free_ar |=
Signature · 6 lines
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170118121036.32642-7-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org

#14 lore raw

Re: [PATCH rdma-next 6/7] IB/mlx5: Assign DSCP for R-RoCE QPs Address Path

Quoted 29 lines · Leon Romanovsky

From: Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/[email protected]>

For Routable RoCE QPs, the DSCP should be set in the QP's address path.

The DSCP's value is derived from the traffic class.

Fixes 2811ba51b049 ("IB/mlx5: Add RoCE fields to Address Vector")
Cc Achiad Shochat <achiad-VPRAkNaXOzVWk0Htik3J/[email protected]>
---
 drivers/infiniband/hw/mlx5/main.c    | 21 +++++++++++++++++++++
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  2 ++
 drivers/infiniband/hw/mlx5/qp.c      |  7 +++++++
 3 files changed, 30 insertions(+)
drivers/infiniband/hw/mlx5/main.c +3 -0
index 1dea407..6a81f027 100644
@@ -325,6 +325,27 @@ __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num,
 	return cpu_to_be16(MLX5_CAP_ROCE(dev->mdev, r_roce_min_src_udp_port));
 }
 
+int mlx5_get_roce_gid_type(struct mlx5_ib_dev *dev, u8 port_num,
+			   int index, enum ib_gid_type *gid_type)
+{

drivers/infiniband/hw/mlx5/main.c __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num, · line 340

Quoted 10 lines
drivers/infiniband/hw/mlx5/main.c +10 -0
+	struct ib_gid_attr attr;
+	union ib_gid gid;
+	int ret;
+
+	ret = ib_get_cached_gid(&dev->ib_dev, port_num, index, &gid, &attr);
+	if (ret)
+		return ret;
+
+	if (!attr.ndev)
+		return -ENODEV;

Two questions:
First for my understanding :) I see that this check is already done in __ib_cache_gid_get so why it is not enough?
Second: Since this is light test, can we have it before the call to ib_get_cached_gid?

Quoted 60 lines
drivers/infiniband/hw/mlx5/main.c +8 -0
+
+	dev_put(attr.ndev);
+
+	*gid_type = attr.gid_type;
+
+	return 0;
+}
+
 static int mlx5_use_mad_ifc(struct mlx5_ib_dev *dev)
 {
 	if (MLX5_CAP_GEN(dev->mdev, port_type) == MLX5_CAP_PORT_TYPE_IB)
drivers/infiniband/hw/mlx5/mlx5_ib.h +2 -0
index e1a4b93d..dda01d7 100644
@@ -872,6 +872,8 @@ int mlx5_ib_set_vf_guid(struct ib_device *device, int vf, u8 port,
 
 __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num,
 			       int index);
+int mlx5_get_roce_gid_type(struct mlx5_ib_dev *dev, u8 port_num,
+			   int index, enum ib_gid_type *gid_type);
 
 /* GSI QP helper functions */
 struct ib_qp *mlx5_ib_gsi_create_qp(struct ib_pd *pd,
drivers/infiniband/hw/mlx5/qp.c +7 -0
index 9af9b95..e22d957 100644
@@ -2198,6 +2198,7 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
 {
 	enum rdma_link_layer ll = rdma_port_get_link_layer(&dev->ib_dev, port);
 	int err;
+	enum ib_gid_type gid_type;
 
 	if (attr_mask & IB_QP_PKEY_INDEX)
 		path->pkey_index = cpu_to_be16(alt ? attr->alt_pkey_index :
@@ -2216,10 +2217,16 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
 	if (ll == IB_LINK_LAYER_ETHERNET) {
 		if (!(ah->ah_flags & IB_AH_GRH))
 			return -EINVAL;
+		err = mlx5_get_roce_gid_type(dev, port, ah->grh.sgid_index,
+					     &gid_type);
+		if (err)
+			return err;
 		memcpy(path->rmac, ah->dmac, sizeof(ah->dmac));
 		path->udp_sport = mlx5_get_roce_udp_sport(dev, port,
 							  ah->grh.sgid_index);
 		path->dci_cfi_prio_sl = (ah->sl & 0x7) << 4;
+		if (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP)
+			path->ecn_dscp = (ah->grh.traffic_class >> 2) & 0x3f;
 	} else {
 		path->fl_free_ar = (path_flags & MLX5_PATH_FLAG_FL) ? 0x80 : 0;
 		path->fl_free_ar |=
Signature · 6 lines
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#15 lore raw

Re: [PATCH rdma-next 6/7] IB/mlx5: Assign DSCP for R-RoCE QPs Address Path

Quoted 38 lines · Yuval Shaia
Quoted 37 lines · Leon Romanovsky

From: Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/[email protected]>

For Routable RoCE QPs, the DSCP should be set in the QP's address path.

The DSCP's value is derived from the traffic class.

Fixes 2811ba51b049 ("IB/mlx5: Add RoCE fields to Address Vector")
Cc Achiad Shochat <achiad-VPRAkNaXOzVWk0Htik3J/[email protected]>
---
 drivers/infiniband/hw/mlx5/main.c    | 21 +++++++++++++++++++++
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  2 ++
 drivers/infiniband/hw/mlx5/qp.c      |  7 +++++++
 3 files changed, 30 insertions(+)
drivers/infiniband/hw/mlx5/main.c +11 -0
index 1dea407..6a81f027 100644
@@ -325,6 +325,27 @@ __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num,
 	return cpu_to_be16(MLX5_CAP_ROCE(dev->mdev, r_roce_min_src_udp_port));
 }
 
+int mlx5_get_roce_gid_type(struct mlx5_ib_dev *dev, u8 port_num,
+			   int index, enum ib_gid_type *gid_type)
+{
+	struct ib_gid_attr attr;
+	union ib_gid gid;
+	int ret;
+
+	ret = ib_get_cached_gid(&dev->ib_dev, port_num, index, &gid, &attr);
+	if (ret)
+		return ret;
+
Quoted 8 lines

drivers/infiniband/hw/mlx5/main.c __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num, · line 340

Quoted 2 lines
drivers/infiniband/hw/mlx5/main.c +2 -0
+	if (!attr.ndev)
+		return -ENODEV;

Two questions:
First for my understanding :) I see that this check is already done in __ib_cache_gid_get so why it is not enough?
Second: Since this is light test, can we have it before the call to ib_get_cached_gid?

I don't see such check there, can you point me?

428 static int __ib_cache_gid_get(struct ib_device *ib_dev, u8 port, int index,
429 union ib_gid *gid, struct ib_gid_attr *attr)
430 {
431 struct ib_gid_table **ports_table = ib_dev->cache.gid_cache;
432 struct ib_gid_table *table;
433
434 table = ports_table[port - rdma_start_port(ib_dev)];
435
436 if (index < 0 || index >= table->sz)
437 return -EINVAL;
438
439 if (table->data_vec[index].props &GID_TABLE_ENTRY_INVALID)
440 return -EAGAIN;
441
442 memcpy(gid, &table->data_vec[index].gid, sizeof(*gid));
443 if (attr) {
444 memcpy(attr, &table->data_vec[index].attr, sizeof(*attr));
445 if (attr->ndev)
446 dev_hold(attr->ndev);
447 }
448
449 return 0;

And regarding your second question, as you can see above in line 444, we are overwriting attr->ndev, so it can be zero. It requires us to check attr->ndev after calling to ib_get_cached_gid too.

Thanks

A message that is not in the archive (sent off-list or not yet received): 20170119075454.GL32481-U/[email protected]

Reviewed-by
#17 lore raw

Re: [PATCH rdma-next 6/7] IB/mlx5: Assign DSCP for R-RoCE QPs Address Path

Quoted 48 lines · Leon Romanovsky
Quoted 38 lines · Yuval Shaia
Quoted 37 lines · Leon Romanovsky

From: Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/[email protected]>

For Routable RoCE QPs, the DSCP should be set in the QP's address path.

The DSCP's value is derived from the traffic class.

Fixes 2811ba51b049 ("IB/mlx5: Add RoCE fields to Address Vector")
Cc Achiad Shochat <achiad-VPRAkNaXOzVWk0Htik3J/[email protected]>
---
 drivers/infiniband/hw/mlx5/main.c    | 21 +++++++++++++++++++++
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  2 ++
 drivers/infiniband/hw/mlx5/qp.c      |  7 +++++++
 3 files changed, 30 insertions(+)
drivers/infiniband/hw/mlx5/main.c +11 -0
index 1dea407..6a81f027 100644
@@ -325,6 +325,27 @@ __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num,
 	return cpu_to_be16(MLX5_CAP_ROCE(dev->mdev, r_roce_min_src_udp_port));
 }
 
+int mlx5_get_roce_gid_type(struct mlx5_ib_dev *dev, u8 port_num,
+			   int index, enum ib_gid_type *gid_type)
+{
+	struct ib_gid_attr attr;
+	union ib_gid gid;
+	int ret;
+
+	ret = ib_get_cached_gid(&dev->ib_dev, port_num, index, &gid, &attr);
+	if (ret)
+		return ret;
+
Quoted 8 lines

drivers/infiniband/hw/mlx5/main.c __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num, · line 340

Quoted 2 lines
drivers/infiniband/hw/mlx5/main.c +2 -0
+	if (!attr.ndev)
+		return -ENODEV;

Two questions:
First for my understanding :) I see that this check is already done in __ib_cache_gid_get so why it is not enough?
Second: Since this is light test, can we have it before the call to ib_get_cached_gid?

Quoted 1 line

I don't see such check there, can you point me?

Line 445.
But please ignore this question, i now realized that still there is a need to check it in mlx5_get_roce_gid_type.

Quoted 24 lines

428 static int __ib_cache_gid_get(struct ib_device *ib_dev, u8 port, int index,
429 union ib_gid *gid, struct ib_gid_attr *attr)
430 {
431 struct ib_gid_table **ports_table = ib_dev->cache.gid_cache;
432 struct ib_gid_table *table;
433
434 table = ports_table[port - rdma_start_port(ib_dev)];
435
436 if (index < 0 || index >= table->sz)
437 return -EINVAL;
438
439 if (table->data_vec[index].props &GID_TABLE_ENTRY_INVALID)
440 return -EAGAIN;
441
442 memcpy(gid, &table->data_vec[index].gid, sizeof(*gid));
443 if (attr) {
444 memcpy(attr, &table->data_vec[index].attr, sizeof(*attr));
445 if (attr->ndev)
446 dev_hold(attr->ndev);
447 }
448
449 return 0;

Quoted 3 lines

And regarding your second question, as you can see above in line 444, we are overwriting attr->ndev, so it can be zero. It requires us to check attr->ndev after calling to ib_get_cached_gid too.

Picture looks clear now, thanks.

Quoted 2 lines

Thanks

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#18 lore raw

PATCH 7/7 IB/mlx5: Remove deprecated module parameter

In reply to a message not in the archive

From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>

Commit 9603b61de1ee ("mlx5: Move pci device handling from mlx5_ib to mlx5_core") moved prof_sel module parameter from mlx5_ib to mlx5_core and marked it as deprecated in 2014.

Three years after deprecation, it is time to remove the deprecated module parameter.

---
 drivers/infiniband/hw/mlx5/main.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/infiniband/hw/mlx5/main.c +0 -7
index 6a81f027..fc02f5f 100644
@@ -64,10 +64,6 @@ MODULE_DESCRIPTION("Mellanox Connect-IB HCA IB driver");
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_VERSION(DRIVER_VERSION);
 
-static int deprecated_prof_sel = 2;
-module_param_named(prof_sel, deprecated_prof_sel, int, 0444);
-MODULE_PARM_DESC(prof_sel, "profile selector. Deprecated here. Moved to module mlx5_core");
-
 static char mlx5_version[] =
 	DRIVER_NAME ": Mellanox Connect-IB Infiniband driver v"
 	DRIVER_VERSION " (" DRIVER_RELDATE ")\n";
@@ -3479,9 +3475,6 @@ static int __init mlx5_ib_init(void)
 {
 	int err;
 
-	if (deprecated_prof_sel != 2)
-		pr_warn("prof_sel is deprecated for mlx5_ib, set it for mlx5_core\n");
-
 	err = mlx5_register_interface(&mlx5_ib_interface);
 
 	return err;
Signature · 6 lines
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170118121036.32642-8-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org

Reviewed-by
#20 lore raw

Re: [PATCH rdma-next 7/7] IB/mlx5: Remove deprecated module parameter

Quoted 21 lines · Leon Romanovsky

From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>

Commit 9603b61de1ee ("mlx5: Move pci device handling from mlx5_ib to mlx5_core") moved prof_sel module parameter from mlx5_ib to mlx5_core and marked it as deprecated in 2014.

Three years after deprecation, it is time to remove the deprecated module parameter.

---
 drivers/infiniband/hw/mlx5/main.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/infiniband/hw/mlx5/main.c +0 -0
index 6a81f027..fc02f5f 100644

drivers/infiniband/hw/mlx5/main.c MODULE_DESCRIPTION("Mellanox Connect-IB HCA IB driver"); · line 70

Quoted 7 lines
drivers/infiniband/hw/mlx5/main.c +0 -4
@@ -64,10 +64,6 @@ MODULE_DESCRIPTION("Mellanox Connect-IB HCA IB driver");
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_VERSION(DRIVER_VERSION);
 
-static int deprecated_prof_sel = 2;
-module_param_named(prof_sel, deprecated_prof_sel, int, 0444);
-MODULE_PARM_DESC(prof_sel, "profile selector. Deprecated here. Moved to module mlx5_core");
-

An example for why module parameters should not be used :)

Quoted 20 lines
drivers/infiniband/hw/mlx5/main.c +0 -3
 static char mlx5_version[] =
 	DRIVER_NAME ": Mellanox Connect-IB Infiniband driver v"
 	DRIVER_VERSION " (" DRIVER_RELDATE ")\n";
@@ -3479,9 +3475,6 @@ static int __init mlx5_ib_init(void)
 {
 	int err;
 
-	if (deprecated_prof_sel != 2)
-		pr_warn("prof_sel is deprecated for mlx5_ib, set it for mlx5_core\n");
-
 	err = mlx5_register_interface(&mlx5_ib_interface);
 
 	return err;
Signature · 6 lines
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#21 lore raw
In reply to a message not in the archive
Quoted 8 lines · Leon Romanovsky

Hi Doug,

Please find below seven fixes to mlx5 driver.

This patchset was generated against commit f502d834950a ("net/mlx5: Activate support for 4K UARs") and it applies
cleanly on k.o/for-4.11 branch.

Thanks, series applied.

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