public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel•org>
To: Doug Ledford <dledford@redhat•com>, Jason Gunthorpe <jgg@mellanox•com>
Cc: Leon Romanovsky <leonro@mellanox•com>,
	RDMA mailing list <linux-rdma@vger•kernel.org>,
	Majd Dibbiny <majd@mellanox•com>, Moni Shoua <monis@mellanox•com>,
	Saeed Mahameed <saeedm@mellanox•com>,
	linux-netdev <netdev@vger•kernel.org>
Subject: [PATCH mlx5-next 12/12] net/mlx5: Set ODP SRQ support in firmware
Date: Tue, 22 Jan 2019 08:48:51 +0200	[thread overview]
Message-ID: <20190122064851.6032-13-leon@kernel.org> (raw)
In-Reply-To: <20190122064851.6032-1-leon@kernel.org>

From: Moni Shoua <monis@mellanox•com>

To avoid compatibility issue with older kernels the firmware doesn't
allow SRQ to work with ODP unless kernel asks for it.

Signed-off-by: Moni Shoua <monis@mellanox•com>
Reviewed-by: Majd Dibbiny <majd@mellanox•com>
Signed-off-by: Leon Romanovsky <leonro@mellanox•com>
---
 .../net/ethernet/mellanox/mlx5/core/main.c    | 53 +++++++++++++++++++
 include/linux/mlx5/device.h                   |  3 ++
 include/linux/mlx5/mlx5_ifc.h                 |  1 +
 3 files changed, 57 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index be81b319b0dc..b3a76df0cf6c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -459,6 +459,53 @@ static int handle_hca_cap_atomic(struct mlx5_core_dev *dev)
 	return err;
 }
 
+static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
+{
+	void *set_ctx;
+	void *set_hca_cap;
+	int set_sz = MLX5_ST_SZ_BYTES(set_hca_cap_in);
+	int err;
+
+	if (!MLX5_CAP_GEN(dev, pg))
+		return 0;
+
+	err = mlx5_core_get_caps(dev, MLX5_CAP_ODP);
+	if (err)
+		return err;
+
+	/**
+	 * If all bits are cleared we shouldn't try to set it
+	 * or we might fail while trying to access a reserved bit.
+	 */
+	if (!(MLX5_CAP_ODP_MAX(dev, ud_odp_caps.srq_receive) ||
+	      MLX5_CAP_ODP_MAX(dev, rc_odp_caps.srq_receive) ||
+	      MLX5_CAP_ODP_MAX(dev, xrc_odp_caps.srq_receive)))
+		return 0;
+
+	set_ctx = kzalloc(set_sz, GFP_KERNEL);
+	if (!set_ctx)
+		return -ENOMEM;
+
+	set_hca_cap = MLX5_ADDR_OF(set_hca_cap_in, set_ctx, capability);
+	memcpy(set_hca_cap, dev->caps.hca_cur[MLX5_CAP_ODP],
+	       MLX5_ST_SZ_BYTES(odp_cap));
+
+	/* set ODP SRQ support for RC/UD and XRC transports */
+	MLX5_SET(odp_cap, set_hca_cap, ud_odp_caps.srq_receive,
+		 (MLX5_CAP_ODP_MAX(dev, ud_odp_caps.srq_receive)));
+
+	MLX5_SET(odp_cap, set_hca_cap, rc_odp_caps.srq_receive,
+		 (MLX5_CAP_ODP_MAX(dev, rc_odp_caps.srq_receive)));
+
+	MLX5_SET(odp_cap, set_hca_cap, xrc_odp_caps.srq_receive,
+		 (MLX5_CAP_ODP_MAX(dev, xrc_odp_caps.srq_receive)));
+
+	err = set_caps(dev, set_ctx, set_sz, MLX5_SET_HCA_CAP_OP_MOD_ODP);
+
+	kfree(set_ctx);
+	return err;
+}
+
 static int handle_hca_cap(struct mlx5_core_dev *dev)
 {
 	void *set_ctx = NULL;
@@ -926,6 +973,12 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
 		goto reclaim_boot_pages;
 	}
 
+	err = handle_hca_cap_odp(dev);
+	if (err) {
+		dev_err(&pdev->dev, "handle_hca_cap_odp failed\n");
+		goto reclaim_boot_pages;
+	}
+
 	err = mlx5_satisfy_startup_pages(dev, 0);
 	if (err) {
 		dev_err(&pdev->dev, "failed to allocate init pages\n");
diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
index 8c4a820bd4c1..0845a227a7b2 100644
--- a/include/linux/mlx5/device.h
+++ b/include/linux/mlx5/device.h
@@ -1201,6 +1201,9 @@ enum mlx5_qcam_feature_groups {
 #define MLX5_CAP_ODP(mdev, cap)\
 	MLX5_GET(odp_cap, mdev->caps.hca_cur[MLX5_CAP_ODP], cap)
 
+#define MLX5_CAP_ODP_MAX(mdev, cap)\
+	MLX5_GET(odp_cap, mdev->caps.hca_max[MLX5_CAP_ODP], cap)
+
 #define MLX5_CAP_VECTOR_CALC(mdev, cap) \
 	MLX5_GET(vector_calc_cap, \
 		 mdev->caps.hca_cur[MLX5_CAP_VECTOR_CALC], cap)
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 5407db8ba8e1..c5c679390fbd 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -72,6 +72,7 @@ enum {
 
 enum {
 	MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE        = 0x0,
+	MLX5_SET_HCA_CAP_OP_MOD_ODP                   = 0x2,
 	MLX5_SET_HCA_CAP_OP_MOD_ATOMIC                = 0x3,
 };
 
-- 
2.19.1


  parent reply	other threads:[~2019-01-22  6:49 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-22  6:48 [PATCH rdma-next 00/12] Add SRQ and XRC support for ODP MRs Leon Romanovsky
2019-01-22  6:48 ` [PATCH rdma-next 01/12] IB/mlx5: Fix locking SRQ object in ODP event Leon Romanovsky
2019-01-22  6:48 ` [PATCH rdma-next 02/12] IB/core: Allocate bit for SRQ ODP support Leon Romanovsky
2019-01-22  6:48 ` [PATCH rdma-next 03/12] IB/uverbs: Expose XRC ODP device capabilities Leon Romanovsky
2019-01-22  6:48 ` [PATCH rdma-next 04/12] IB/mlx5: Remove useless check in ODP handler Leon Romanovsky
2019-01-22  6:48 ` [PATCH rdma-next 05/12] IB/mlx5: Clean mlx5_ib_mr_responder_pfault_handler() signature Leon Romanovsky
2019-01-22  6:48 ` [PATCH rdma-next 06/12] IB/mlx5: Add XRC initiator ODP support Leon Romanovsky
2019-01-22  6:48 ` [PATCH rdma-next 07/12] IB/mlx5: Let read user wqe also from SRQ buffer Leon Romanovsky
2019-01-22  6:48 ` [PATCH rdma-next 08/12] IB/mlx5: Add ODP SRQ support Leon Romanovsky
2019-01-22  6:48 ` [PATCH rdma-next 09/12] IB/mlx5: Advertise SRQ ODP support for supported transports Leon Romanovsky
2019-01-22  6:48 ` [PATCH mlx5-next 10/12] net/mlx5: Add XRC transport to ODP device capabilities layout Leon Romanovsky
2019-01-22  6:48 ` [PATCH rdma-next 11/12] IB/mlx5: Advertise XRC ODP support Leon Romanovsky
2019-01-22  6:48 ` Leon Romanovsky [this message]
2019-01-31 23:28   ` [PATCH mlx5-next 12/12] net/mlx5: Set ODP SRQ support in firmware Jason Gunthorpe
2019-02-03  9:03     ` Leon Romanovsky
2019-02-04 21:23       ` Jason Gunthorpe
2019-02-04 23:54         ` Saeed Mahameed
2019-02-04 23:47   ` Saeed Mahameed
2019-02-05  6:27     ` Leon Romanovsky
2019-01-24 12:25 ` [PATCH rdma-next 00/12] Add SRQ and XRC support for ODP MRs Leon Romanovsky
2019-01-31 23:27 ` Jason Gunthorpe
2019-02-03 10:54   ` Leon Romanovsky
2019-02-04 21:53     ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190122064851.6032-13-leon@kernel.org \
    --to=leon@kernel$(echo .)org \
    --cc=dledford@redhat$(echo .)com \
    --cc=jgg@mellanox$(echo .)com \
    --cc=leonro@mellanox$(echo .)com \
    --cc=linux-rdma@vger$(echo .)kernel.org \
    --cc=majd@mellanox$(echo .)com \
    --cc=monis@mellanox$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=saeedm@mellanox$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox