From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 050A5A045E for ; Thu, 30 May 2019 12:21:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7203A1B9B1; Thu, 30 May 2019 12:20:58 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 4B29C1B957; Thu, 30 May 2019 12:20:45 +0200 (CEST) From: Matan Azrad To: Shahaf Shuler , Yongseok Koh Cc: dev@dpdk.org, stable@dpdk.org Date: Thu, 30 May 2019 10:20:35 +0000 Message-Id: <1559211639-17442-6-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1559211639-17442-1-git-send-email-matan@mellanox.com> References: <1559211639-17442-1-git-send-email-matan@mellanox.com> Subject: [dpdk-dev] [PATCH v1 5/9] net/mlx5: separate Rx queue initialization 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" Move the RQ WQEs initialization code to separate function as an arrangement to CQE error recovering for code reuse. CC: stable@dpdk.org Signed-off-by: Matan Azrad --- drivers/net/mlx5/mlx5_rxq.c | 43 ++--------------------------------- drivers/net/mlx5/mlx5_rxtx.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 41 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 282295f..90e8c49 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -779,7 +779,6 @@ struct mlx5_rxq_ibv * struct mlx5_rxq_ibv *tmpl; struct mlx5dv_cq cq_info; struct mlx5dv_rwq rwq; - unsigned int i; int ret = 0; struct mlx5dv_obj obj; struct mlx5_dev_config *config = &priv->config; @@ -964,53 +963,15 @@ struct mlx5_rxq_ibv * } /* Fill the rings. */ rxq_data->wqes = rwq.buf; - for (i = 0; (i != wqe_n); ++i) { - volatile struct mlx5_wqe_data_seg *scat; - uintptr_t addr; - uint32_t byte_count; - - if (mprq_en) { - struct mlx5_mprq_buf *buf = (*rxq_data->mprq_bufs)[i]; - - scat = &((volatile struct mlx5_wqe_mprq *) - rxq_data->wqes)[i].dseg; - addr = (uintptr_t)mlx5_mprq_buf_addr(buf); - byte_count = (1 << rxq_data->strd_sz_n) * - (1 << rxq_data->strd_num_n); - } else { - struct rte_mbuf *buf = (*rxq_data->elts)[i]; - - scat = &((volatile struct mlx5_wqe_data_seg *) - rxq_data->wqes)[i]; - addr = rte_pktmbuf_mtod(buf, uintptr_t); - byte_count = DATA_LEN(buf); - } - /* scat->addr must be able to store a pointer. */ - assert(sizeof(scat->addr) >= sizeof(uintptr_t)); - *scat = (struct mlx5_wqe_data_seg){ - .addr = rte_cpu_to_be_64(addr), - .byte_count = rte_cpu_to_be_32(byte_count), - .lkey = mlx5_rx_addr2mr(rxq_data, addr), - }; - } rxq_data->rq_db = rwq.dbrec; rxq_data->cqe_n = log2above(cq_info.cqe_cnt); - rxq_data->cq_ci = 0; - rxq_data->consumed_strd = 0; - rxq_data->rq_pi = 0; - rxq_data->zip = (struct rxq_zip){ - .ai = 0, - }; rxq_data->cq_db = cq_info.dbrec; rxq_data->cqes = (volatile struct mlx5_cqe (*)[])(uintptr_t)cq_info.buf; rxq_data->cq_uar = cq_info.cq_uar; rxq_data->cqn = cq_info.cqn; rxq_data->cq_arm_sn = 0; - rxq_data->decompressed = 0; - /* Update doorbell counter. */ - rxq_data->rq_ci = wqe_n >> rxq_data->sges_n; - rte_cio_wmb(); - *rxq_data->rq_db = rte_cpu_to_be_32(rxq_data->rq_ci); + mlx5_rxq_initialize(rxq_data); + rxq_data->cq_ci = 0; DRV_LOG(DEBUG, "port %u rxq %u updated with %p", dev->data->port_id, idx, (void *)&tmpl); rte_atomic32_inc(&tmpl->refcnt); diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 2c8d066..aec0185 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -1831,6 +1831,59 @@ } /** + * Initialize Rx WQ and indexes. + * + * @param[in] rxq + * Pointer to RX queue structure. + */ +void +mlx5_rxq_initialize(struct mlx5_rxq_data *rxq) +{ + const unsigned int wqe_n = 1 << rxq->elts_n; + unsigned int i; + + for (i = 0; (i != wqe_n); ++i) { + volatile struct mlx5_wqe_data_seg *scat; + uintptr_t addr; + uint32_t byte_count; + + if (mlx5_rxq_mprq_enabled(rxq)) { + struct mlx5_mprq_buf *buf = (*rxq->mprq_bufs)[i]; + + scat = &((volatile struct mlx5_wqe_mprq *) + rxq->wqes)[i].dseg; + addr = (uintptr_t)mlx5_mprq_buf_addr(buf); + byte_count = (1 << rxq->strd_sz_n) * + (1 << rxq->strd_num_n); + } else { + struct rte_mbuf *buf = (*rxq->elts)[i]; + + scat = &((volatile struct mlx5_wqe_data_seg *) + rxq->wqes)[i]; + addr = rte_pktmbuf_mtod(buf, uintptr_t); + byte_count = DATA_LEN(buf); + } + /* scat->addr must be able to store a pointer. */ + assert(sizeof(scat->addr) >= sizeof(uintptr_t)); + *scat = (struct mlx5_wqe_data_seg){ + .addr = rte_cpu_to_be_64(addr), + .byte_count = rte_cpu_to_be_32(byte_count), + .lkey = mlx5_rx_addr2mr(rxq, addr), + }; + } + rxq->consumed_strd = 0; + rxq->decompressed = 0; + rxq->rq_pi = 0; + rxq->zip = (struct rxq_zip){ + .ai = 0, + }; + /* Update doorbell counter. */ + rxq->rq_ci = wqe_n >> rxq->sges_n; + rte_cio_wmb(); + *rxq->rq_db = rte_cpu_to_be_32(rxq->rq_ci); +} + +/** * Get size of the next packet for a given CQE. For compressed CQEs, the * consumer index is updated only once all packets of the current one have * been processed. -- 1.8.3.1