From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <viacheslavo@mellanox.com>
Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])
 by dpdk.org (Postfix) with ESMTP id 5B95D3256
 for <dev@dpdk.org>; Mon, 25 Mar 2019 18:03:46 +0100 (CET)
Received: from Internal Mail-Server by MTLPINE1 (envelope-from
 viacheslavo@mellanox.com)
 with ESMTPS (AES256-SHA encrypted); 25 Mar 2019 19:03:41 +0200
Received: from pegasus12.mtr.labs.mlnx. (pegasus12.mtr.labs.mlnx
 [10.210.17.40])
 by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x2PH3fbe020888;
 Mon, 25 Mar 2019 19:03:41 +0200
From: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
To: dev@dpdk.org
Cc: shahafs@mellanox.com
Date: Mon, 25 Mar 2019 17:03:29 +0000
Message-Id: <1553533414-9911-9-git-send-email-viacheslavo@mellanox.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1553533414-9911-1-git-send-email-viacheslavo@mellanox.com>
References: <1553155888-27498-1-git-send-email-viacheslavo@mellanox.com>
 <1553533414-9911-1-git-send-email-viacheslavo@mellanox.com>
Subject: [dpdk-dev] [PATCH v2 08/13] net/mlx5: switch to the shared context
	IB attributes
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 25 Mar 2019 17:03:47 -0000

The code is updated to use the shared IB device attributes,
located in the shared IB context. It saves some memory if
there are representors created over the single Infiniband
device with multuple ports.

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx5/mlx5.c        |  1 -
 drivers/net/mlx5/mlx5.h        |  1 -
 drivers/net/mlx5/mlx5_ethdev.c |  6 +++---
 drivers/net/mlx5/mlx5_rxq.c    |  8 ++++----
 drivers/net/mlx5/mlx5_txq.c    | 14 +++++++-------
 5 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index cc6657a..93e4eac 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1103,7 +1103,6 @@ struct mlx5_dev_spawn_data {
 	priv->sh = sh;
 	priv->ctx = sh->ctx;
 	priv->ibv_port = spawn->ibv_port;
-	priv->device_attr = sh->device_attr;
 	priv->mtu = ETHER_MTU;
 #ifndef RTE_ARCH_64
 	/* Initialize UAR access locks for 32bit implementations. */
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 4e5f09a..4227010 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -233,7 +233,6 @@ struct mlx5_priv {
 	struct mlx5_ibv_shared *sh; /* Shared IB device context. */
 	uint32_t ibv_port; /* IB device port number. */
 	struct ibv_context *ctx; /* Verbs context. */
-	struct ibv_device_attr_ex device_attr; /* Device properties. */
 	struct ether_addr mac[MLX5_MAX_MAC_ADDRESSES]; /* MAC addresses. */
 	BITFIELD_DECLARE(mac_own, uint64_t, MLX5_MAX_MAC_ADDRESSES);
 	/* Bit-field of MAC addresses owned by the PMD. */
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index e89b705..46d90cd 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -515,8 +515,8 @@ struct ethtool_link_settings {
 	 * Since we need one CQ per QP, the limit is the minimum number
 	 * between the two values.
 	 */
-	max = RTE_MIN(priv->device_attr.orig_attr.max_cq,
-		      priv->device_attr.orig_attr.max_qp);
+	max = RTE_MIN(priv->sh->device_attr.orig_attr.max_cq,
+		      priv->sh->device_attr.orig_attr.max_qp);
 	/* If max >= 65535 then max = 0, max_rx_queues is uint16_t. */
 	if (max >= 65535)
 		max = 65535;
@@ -577,7 +577,7 @@ struct ethtool_link_settings {
 int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
-	struct ibv_device_attr *attr = &priv->device_attr.orig_attr;
+	struct ibv_device_attr *attr = &priv->sh->device_attr.orig_attr;
 	size_t size = strnlen(attr->fw_ver, sizeof(attr->fw_ver)) + 1;
 
 	if (fw_size < size)
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 0496c4e..fd1c3a2 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -856,10 +856,10 @@ struct mlx5_rxq_ibv *
 		rte_errno = ENOMEM;
 		goto error;
 	}
-	DRV_LOG(DEBUG, "port %u priv->device_attr.max_qp_wr is %d",
-		dev->data->port_id, priv->device_attr.orig_attr.max_qp_wr);
-	DRV_LOG(DEBUG, "port %u priv->device_attr.max_sge is %d",
-		dev->data->port_id, priv->device_attr.orig_attr.max_sge);
+	DRV_LOG(DEBUG, "port %u device_attr.max_qp_wr is %d",
+		dev->data->port_id, priv->sh->device_attr.orig_attr.max_qp_wr);
+	DRV_LOG(DEBUG, "port %u device_attr.max_sge is %d",
+		dev->data->port_id, priv->sh->device_attr.orig_attr.max_sge);
 	attr.wq.ibv = (struct ibv_wq_init_attr){
 		.wq_context = NULL, /* Could be useful in the future. */
 		.wq_type = IBV_WQT_RQ,
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index d3a5498..10a3040 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -407,15 +407,15 @@ struct mlx5_txq_ibv *
 		.cap = {
 			/* Max number of outstanding WRs. */
 			.max_send_wr =
-				((priv->device_attr.orig_attr.max_qp_wr <
+				((priv->sh->device_attr.orig_attr.max_qp_wr <
 				  desc) ?
-				 priv->device_attr.orig_attr.max_qp_wr :
+				 priv->sh->device_attr.orig_attr.max_qp_wr :
 				 desc),
 			/*
 			 * Max number of scatter/gather elements in a WR,
 			 * must be 1 to prevent libmlx5 from trying to affect
 			 * too much memory. TX gather is not impacted by the
-			 * priv->device_attr.max_sge limit and will still work
+			 * device_attr.max_sge limit and will still work
 			 * properly.
 			 */
 			.max_send_sge = 1,
@@ -780,10 +780,10 @@ struct mlx5_txq_ctrl *
 	tmpl->txq.elts_n = log2above(desc);
 	tmpl->idx = idx;
 	txq_set_params(tmpl);
-	DRV_LOG(DEBUG, "port %u priv->device_attr.max_qp_wr is %d",
-		dev->data->port_id, priv->device_attr.orig_attr.max_qp_wr);
-	DRV_LOG(DEBUG, "port %u priv->device_attr.max_sge is %d",
-		dev->data->port_id, priv->device_attr.orig_attr.max_sge);
+	DRV_LOG(DEBUG, "port %u device_attr.max_qp_wr is %d",
+		dev->data->port_id, priv->sh->device_attr.orig_attr.max_qp_wr);
+	DRV_LOG(DEBUG, "port %u device_attr.max_sge is %d",
+		dev->data->port_id, priv->sh->device_attr.orig_attr.max_sge);
 	tmpl->txq.elts =
 		(struct rte_mbuf *(*)[1 << tmpl->txq.elts_n])(tmpl + 1);
 	tmpl->txq.stats.idx = idx;
-- 
1.8.3.1

From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by dpdk.space (Postfix) with ESMTP id 357A2A05D3
	for <public@inbox.dpdk.org>; Mon, 25 Mar 2019 18:05:09 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 0FDB34CC7;
	Mon, 25 Mar 2019 18:04:07 +0100 (CET)
Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])
 by dpdk.org (Postfix) with ESMTP id 5B95D3256
 for <dev@dpdk.org>; Mon, 25 Mar 2019 18:03:46 +0100 (CET)
Received: from Internal Mail-Server by MTLPINE1 (envelope-from
 viacheslavo@mellanox.com)
 with ESMTPS (AES256-SHA encrypted); 25 Mar 2019 19:03:41 +0200
Received: from pegasus12.mtr.labs.mlnx. (pegasus12.mtr.labs.mlnx
 [10.210.17.40])
 by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x2PH3fbe020888;
 Mon, 25 Mar 2019 19:03:41 +0200
From: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
To: dev@dpdk.org
Cc: shahafs@mellanox.com
Date: Mon, 25 Mar 2019 17:03:29 +0000
Message-Id: <1553533414-9911-9-git-send-email-viacheslavo@mellanox.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1553533414-9911-1-git-send-email-viacheslavo@mellanox.com>
References: <1553155888-27498-1-git-send-email-viacheslavo@mellanox.com>
 <1553533414-9911-1-git-send-email-viacheslavo@mellanox.com>
Subject: [dpdk-dev] [PATCH v2 08/13] net/mlx5: switch to the shared context
	IB attributes
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <20190325170329.zJsIzcc3r_f1i3MTClK2gp3aY6CdvYNGeNxkGj3KjHo@z>

The code is updated to use the shared IB device attributes,
located in the shared IB context. It saves some memory if
there are representors created over the single Infiniband
device with multuple ports.

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx5/mlx5.c        |  1 -
 drivers/net/mlx5/mlx5.h        |  1 -
 drivers/net/mlx5/mlx5_ethdev.c |  6 +++---
 drivers/net/mlx5/mlx5_rxq.c    |  8 ++++----
 drivers/net/mlx5/mlx5_txq.c    | 14 +++++++-------
 5 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index cc6657a..93e4eac 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1103,7 +1103,6 @@ struct mlx5_dev_spawn_data {
 	priv->sh = sh;
 	priv->ctx = sh->ctx;
 	priv->ibv_port = spawn->ibv_port;
-	priv->device_attr = sh->device_attr;
 	priv->mtu = ETHER_MTU;
 #ifndef RTE_ARCH_64
 	/* Initialize UAR access locks for 32bit implementations. */
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 4e5f09a..4227010 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -233,7 +233,6 @@ struct mlx5_priv {
 	struct mlx5_ibv_shared *sh; /* Shared IB device context. */
 	uint32_t ibv_port; /* IB device port number. */
 	struct ibv_context *ctx; /* Verbs context. */
-	struct ibv_device_attr_ex device_attr; /* Device properties. */
 	struct ether_addr mac[MLX5_MAX_MAC_ADDRESSES]; /* MAC addresses. */
 	BITFIELD_DECLARE(mac_own, uint64_t, MLX5_MAX_MAC_ADDRESSES);
 	/* Bit-field of MAC addresses owned by the PMD. */
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index e89b705..46d90cd 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -515,8 +515,8 @@ struct ethtool_link_settings {
 	 * Since we need one CQ per QP, the limit is the minimum number
 	 * between the two values.
 	 */
-	max = RTE_MIN(priv->device_attr.orig_attr.max_cq,
-		      priv->device_attr.orig_attr.max_qp);
+	max = RTE_MIN(priv->sh->device_attr.orig_attr.max_cq,
+		      priv->sh->device_attr.orig_attr.max_qp);
 	/* If max >= 65535 then max = 0, max_rx_queues is uint16_t. */
 	if (max >= 65535)
 		max = 65535;
@@ -577,7 +577,7 @@ struct ethtool_link_settings {
 int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
-	struct ibv_device_attr *attr = &priv->device_attr.orig_attr;
+	struct ibv_device_attr *attr = &priv->sh->device_attr.orig_attr;
 	size_t size = strnlen(attr->fw_ver, sizeof(attr->fw_ver)) + 1;
 
 	if (fw_size < size)
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 0496c4e..fd1c3a2 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -856,10 +856,10 @@ struct mlx5_rxq_ibv *
 		rte_errno = ENOMEM;
 		goto error;
 	}
-	DRV_LOG(DEBUG, "port %u priv->device_attr.max_qp_wr is %d",
-		dev->data->port_id, priv->device_attr.orig_attr.max_qp_wr);
-	DRV_LOG(DEBUG, "port %u priv->device_attr.max_sge is %d",
-		dev->data->port_id, priv->device_attr.orig_attr.max_sge);
+	DRV_LOG(DEBUG, "port %u device_attr.max_qp_wr is %d",
+		dev->data->port_id, priv->sh->device_attr.orig_attr.max_qp_wr);
+	DRV_LOG(DEBUG, "port %u device_attr.max_sge is %d",
+		dev->data->port_id, priv->sh->device_attr.orig_attr.max_sge);
 	attr.wq.ibv = (struct ibv_wq_init_attr){
 		.wq_context = NULL, /* Could be useful in the future. */
 		.wq_type = IBV_WQT_RQ,
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index d3a5498..10a3040 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -407,15 +407,15 @@ struct mlx5_txq_ibv *
 		.cap = {
 			/* Max number of outstanding WRs. */
 			.max_send_wr =
-				((priv->device_attr.orig_attr.max_qp_wr <
+				((priv->sh->device_attr.orig_attr.max_qp_wr <
 				  desc) ?
-				 priv->device_attr.orig_attr.max_qp_wr :
+				 priv->sh->device_attr.orig_attr.max_qp_wr :
 				 desc),
 			/*
 			 * Max number of scatter/gather elements in a WR,
 			 * must be 1 to prevent libmlx5 from trying to affect
 			 * too much memory. TX gather is not impacted by the
-			 * priv->device_attr.max_sge limit and will still work
+			 * device_attr.max_sge limit and will still work
 			 * properly.
 			 */
 			.max_send_sge = 1,
@@ -780,10 +780,10 @@ struct mlx5_txq_ctrl *
 	tmpl->txq.elts_n = log2above(desc);
 	tmpl->idx = idx;
 	txq_set_params(tmpl);
-	DRV_LOG(DEBUG, "port %u priv->device_attr.max_qp_wr is %d",
-		dev->data->port_id, priv->device_attr.orig_attr.max_qp_wr);
-	DRV_LOG(DEBUG, "port %u priv->device_attr.max_sge is %d",
-		dev->data->port_id, priv->device_attr.orig_attr.max_sge);
+	DRV_LOG(DEBUG, "port %u device_attr.max_qp_wr is %d",
+		dev->data->port_id, priv->sh->device_attr.orig_attr.max_qp_wr);
+	DRV_LOG(DEBUG, "port %u device_attr.max_sge is %d",
+		dev->data->port_id, priv->sh->device_attr.orig_attr.max_sge);
 	tmpl->txq.elts =
 		(struct rte_mbuf *(*)[1 << tmpl->txq.elts_n])(tmpl + 1);
 	tmpl->txq.stats.idx = idx;
-- 
1.8.3.1