From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C7183A04DB; Thu, 3 Sep 2020 12:16:15 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C5BF41C138; Thu, 3 Sep 2020 12:14:56 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 0EE531C132 for ; Thu, 3 Sep 2020 12:14:54 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from michaelba@nvidia.com) with SMTP; 3 Sep 2020 13:14:52 +0300 Received: from nvidia.com (pegasus07.mtr.labs.mlnx [10.210.16.112]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 083AEP97031645; Thu, 3 Sep 2020 13:14:52 +0300 From: Michael Baum To: dev@dpdk.org Cc: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Date: Thu, 3 Sep 2020 10:13:40 +0000 Message-Id: <1599128029-2092-10-git-send-email-michaelba@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599128029-2092-1-git-send-email-michaelba@nvidia.com> References: <1599128029-2092-1-git-send-email-michaelba@nvidia.com> Subject: [dpdk-dev] [PATCH v1 09/18] net/mlx5: rearrange the creation of WQ and CQ object X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Rearrangement of WQ and CQ creation for Verbs Rx queue: 1. Rename the allocation function. 2. Reduce the number of arguments that the creation functions receive. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_verbs.c | 52 ++++++++++++++----------------------- drivers/net/mlx5/mlx5_devx.c | 22 ---------------- drivers/net/mlx5/mlx5_rxq.c | 22 ++++++++++++++++ drivers/net/mlx5/mlx5_rxtx.h | 1 + 4 files changed, 43 insertions(+), 54 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c index 16e5900..d9cf911 100644 --- a/drivers/net/mlx5/linux/mlx5_verbs.c +++ b/drivers/net/mlx5/linux/mlx5_verbs.c @@ -96,23 +96,21 @@ * * @param dev * Pointer to Ethernet device. - * @param priv - * Pointer to device private data. - * @param rxq_data - * Pointer to Rx queue data. - * @param cqe_n - * Number of CQEs in CQ. - * @param rxq_obj - * Pointer to Rx queue object data. + * @param idx + * Queue index in DPDK Rx queue array. * * @return - * The Verbs object initialized, NULL otherwise and rte_errno is set. + * The Verbs CQ object initialized, NULL otherwise and rte_errno is set. */ static struct ibv_cq * -mlx5_ibv_cq_new(struct rte_eth_dev *dev, struct mlx5_priv *priv, - struct mlx5_rxq_data *rxq_data, - unsigned int cqe_n, struct mlx5_rxq_obj *rxq_obj) +mlx5_rxq_ibv_cq_create(struct rte_eth_dev *dev, uint16_t idx) { + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; + struct mlx5_rxq_ctrl *rxq_ctrl = + container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); + struct mlx5_rxq_obj *rxq_obj = rxq_ctrl->obj; + unsigned int cqe_n = mlx5_rxq_cqe_num(rxq_data); struct { struct ibv_cq_init_attr_ex ibv; struct mlx5dv_cq_init_attr mlx5; @@ -165,25 +163,21 @@ * * @param dev * Pointer to Ethernet device. - * @param priv - * Pointer to device private data. - * @param rxq_data - * Pointer to Rx queue data. * @param idx * Queue index in DPDK Rx queue array. - * @param wqe_n - * Number of WQEs in WQ. - * @param rxq_obj - * Pointer to Rx queue object data. * * @return - * The Verbs object initialized, NULL otherwise and rte_errno is set. + * The Verbs WQ object initialized, NULL otherwise and rte_errno is set. */ static struct ibv_wq * -mlx5_ibv_wq_new(struct rte_eth_dev *dev, struct mlx5_priv *priv, - struct mlx5_rxq_data *rxq_data, uint16_t idx, - unsigned int wqe_n, struct mlx5_rxq_obj *rxq_obj) +mlx5_rxq_ibv_wq_create(struct rte_eth_dev *dev, uint16_t idx) { + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; + struct mlx5_rxq_ctrl *rxq_ctrl = + container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); + struct mlx5_rxq_obj *rxq_obj = rxq_ctrl->obj; + unsigned int wqe_n = 1 << rxq_data->elts_n; struct { struct ibv_wq_init_attr ibv; #ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT @@ -279,8 +273,6 @@ struct mlx5_rxq_ctrl *rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); struct ibv_wq_attr mod; - unsigned int cqe_n; - unsigned int wqe_n = 1 << rxq_data->elts_n; struct mlx5_rxq_obj *tmpl = rxq_ctrl->obj; struct mlx5dv_cq cq_info; struct mlx5dv_rwq rwq; @@ -304,12 +296,8 @@ } tmpl->fd = ((struct ibv_comp_channel *)(tmpl->ibv_channel))->fd; } - if (mlx5_rxq_mprq_enabled(rxq_data)) - cqe_n = wqe_n * (1 << rxq_data->strd_num_n) - 1; - else - cqe_n = wqe_n - 1; /* Create CQ using Verbs API. */ - tmpl->ibv_cq = mlx5_ibv_cq_new(dev, priv, rxq_data, cqe_n, tmpl); + tmpl->ibv_cq = mlx5_rxq_ibv_cq_create(dev, idx); if (!tmpl->ibv_cq) { DRV_LOG(ERR, "Port %u Rx queue %u CQ creation failure.", dev->data->port_id, idx); @@ -338,7 +326,7 @@ rxq_data->cq_uar = cq_info.cq_uar; rxq_data->cqn = cq_info.cqn; /* Create WQ (RQ) using Verbs API. */ - tmpl->wq = mlx5_ibv_wq_new(dev, priv, rxq_data, idx, wqe_n, tmpl); + tmpl->wq = mlx5_rxq_ibv_wq_create(dev, idx); if (!tmpl->wq) { DRV_LOG(ERR, "Port %u Rx queue %u WQ creation failure.", dev->data->port_id, idx); diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c index 5a3ac49..8bbc664 100644 --- a/drivers/net/mlx5/mlx5_devx.c +++ b/drivers/net/mlx5/mlx5_devx.c @@ -24,28 +24,6 @@ /** - * Calculate the number of CQEs in CQ for the Rx queue. - * - * @param rxq_data - * Pointer to receive queue structure. - * - * @return - * Number of CQEs in CQ. - */ -static unsigned int -mlx5_rxq_cqe_num(struct mlx5_rxq_data *rxq_data) -{ - unsigned int cqe_n; - unsigned int wqe_n = 1 << rxq_data->elts_n; - - if (mlx5_rxq_mprq_enabled(rxq_data)) - cqe_n = wqe_n * (1 << rxq_data->strd_num_n) - 1; - else - cqe_n = wqe_n - 1; - return cqe_n; -} - -/** * Modify RQ vlan stripping offload * * @param rxq_obj diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 00ef230..3115f5a 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -123,6 +123,28 @@ } /** + * Calculate the number of CQEs in CQ for the Rx queue. + * + * @param rxq_data + * Pointer to receive queue structure. + * + * @return + * Number of CQEs in CQ. + */ +unsigned int +mlx5_rxq_cqe_num(struct mlx5_rxq_data *rxq_data) +{ + unsigned int cqe_n; + unsigned int wqe_n = 1 << rxq_data->elts_n; + + if (mlx5_rxq_mprq_enabled(rxq_data)) + cqe_n = wqe_n * (1 << rxq_data->strd_num_n) - 1; + else + cqe_n = wqe_n - 1; + return cqe_n; +} + +/** * Allocate RX queue elements for Multi-Packet RQ. * * @param rxq_ctrl diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 6d135dd..75eedff 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -371,6 +371,7 @@ struct mlx5_txq_ctrl { int mlx5_check_mprq_support(struct rte_eth_dev *dev); int mlx5_rxq_mprq_enabled(struct mlx5_rxq_data *rxq); int mlx5_mprq_enabled(struct rte_eth_dev *dev); +unsigned int mlx5_rxq_cqe_num(struct mlx5_rxq_data *rxq_data); int mlx5_mprq_free_mp(struct rte_eth_dev *dev); int mlx5_mprq_alloc_mp(struct rte_eth_dev *dev); int mlx5_rx_queue_start(struct rte_eth_dev *dev, uint16_t queue_id); -- 1.8.3.1