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 77F63A04C3 for ; Fri, 22 Nov 2019 15:43:01 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6A3B491; Fri, 22 Nov 2019 15:43:01 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 13E8791 for ; Fri, 22 Nov 2019 15:42:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574433779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9GUDAK4KnfhcdWDZNf9dmrH0uy6pTsiJNv1RfsuED+o=; b=eFKJ/qUhcvidVOmpW9Asnl8TeFgWiwXaPZvywbgyc6sfNdD97Ax3qPh2bNhEaeCnuLZ7jh eUgIg4n9ZcHtilhE2XCOBqiF5XOoHBM1SbSIX/jQ6ZpmWMYI1ZlD5H+EV/cLijN+KSJvC7 1n+Z0aCEIT9Zmq/r1g+0QBIaWCQ5o2U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-414-YQeE5Pf7P9aSwD9RHPjG4w-1; Fri, 22 Nov 2019 09:42:58 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 544C81005509; Fri, 22 Nov 2019 14:42:57 +0000 (UTC) Received: from rh.redhat.com (unknown [10.36.118.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79B198516; Fri, 22 Nov 2019 14:42:56 +0000 (UTC) From: Kevin Traynor To: Shahed Shaikh Cc: dpdk stable Date: Fri, 22 Nov 2019 14:41:25 +0000 Message-Id: <20191122144131.21231-39-ktraynor@redhat.com> In-Reply-To: <20191122144131.21231-1-ktraynor@redhat.com> References: <20191122144131.21231-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: YQeE5Pf7P9aSwD9RHPjG4w-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'net/qede: refactor Rx and Tx queue setup' has been queued to LTS release 18.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/29/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasi= ng (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/13b44f308adbfc118a= fec6f7329e1dcf6e6cd9e4 Thanks. Kevin. --- >From 13b44f308adbfc118afec6f7329e1dcf6e6cd9e4 Mon Sep 17 00:00:00 2001 From: Shahed Shaikh Date: Thu, 12 Sep 2019 08:24:12 -0700 Subject: [PATCH] net/qede: refactor Rx and Tx queue setup [ upstream commit 642f25da9c561f6e831cb5ea6f7d79c04d804081 ] This patch refactors Rx and Tx queue setup flow required to allow odd number of queues to be configured in next patch. This is the first patch of the series required to fix an issue where qede port initialization in ovs-dpdk fails due to 1 Rx/Tx queue configuration. Detailed explanation is given in next patch. Fixes: 2af14ca79c0a ("net/qede: support 100G") Signed-off-by: Shahed Shaikh --- drivers/net/qede/qede_rxtx.c | 228 ++++++++++++++++++++++------------- 1 file changed, 141 insertions(+), 87 deletions(-) diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c index 03f7785b6..64fd9e063 100644 --- a/drivers/net/qede/qede_rxtx.c +++ b/drivers/net/qede/qede_rxtx.c @@ -125,34 +125,18 @@ qede_calc_rx_buf_size(struct rte_eth_dev *dev, uint16= _t mbufsz, } =20 -int -qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, -=09=09 uint16_t nb_desc, unsigned int socket_id, -=09=09 __rte_unused const struct rte_eth_rxconf *rx_conf, -=09=09 struct rte_mempool *mp) +static struct qede_rx_queue * +qede_alloc_rx_queue_mem(struct rte_eth_dev *dev, +=09=09=09uint16_t queue_idx, +=09=09=09uint16_t nb_desc, +=09=09=09unsigned int socket_id, +=09=09=09struct rte_mempool *mp, +=09=09=09uint16_t bufsz) { =09struct qede_dev *qdev =3D QEDE_INIT_QDEV(dev); =09struct ecore_dev *edev =3D QEDE_INIT_EDEV(qdev); -=09struct rte_eth_rxmode *rxmode =3D &dev->data->dev_conf.rxmode; =09struct qede_rx_queue *rxq; -=09uint16_t max_rx_pkt_len; -=09uint16_t bufsz; =09size_t size; =09int rc; =20 -=09PMD_INIT_FUNC_TRACE(edev); - -=09/* Note: Ring size/align is controlled by struct rte_eth_desc_lim */ -=09if (!rte_is_power_of_2(nb_desc)) { -=09=09DP_ERR(edev, "Ring size %u is not power of 2\n", -=09=09=09 nb_desc); -=09=09return -EINVAL; -=09} - -=09/* Free memory prior to re-allocation if needed... */ -=09if (dev->data->rx_queues[queue_idx] !=3D NULL) { -=09=09qede_rx_queue_release(dev->data->rx_queues[queue_idx]); -=09=09dev->data->rx_queues[queue_idx] =3D NULL; -=09} - =09/* First allocate the rx queue data structure */ =09rxq =3D rte_zmalloc_socket("qede_rx_queue", sizeof(struct qede_rx_queue= ), @@ -162,5 +146,5 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t q= ueue_idx, =09=09DP_ERR(edev, "Unable to allocate memory for rxq on socket %u", =09=09=09 socket_id); -=09=09return -ENOMEM; +=09=09return NULL; =09} =20 @@ -171,25 +155,6 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t = queue_idx, =09rxq->port_id =3D dev->data->port_id; =20 -=09max_rx_pkt_len =3D (uint16_t)rxmode->max_rx_pkt_len; =20 -=09/* Fix up RX buffer size */ -=09bufsz =3D (uint16_t)rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADRO= OM; -=09/* cache align the mbuf size to simplfy rx_buf_size calculation */ -=09bufsz =3D QEDE_FLOOR_TO_CACHE_LINE_SIZE(bufsz); -=09if ((rxmode->offloads & DEV_RX_OFFLOAD_SCATTER)=09|| -=09 (max_rx_pkt_len + QEDE_ETH_OVERHEAD) > bufsz) { -=09=09if (!dev->data->scattered_rx) { -=09=09=09DP_INFO(edev, "Forcing scatter-gather mode\n"); -=09=09=09dev->data->scattered_rx =3D 1; -=09=09} -=09} - -=09rc =3D qede_calc_rx_buf_size(dev, bufsz, max_rx_pkt_len); -=09if (rc < 0) { -=09=09rte_free(rxq); -=09=09return rc; -=09} - -=09rxq->rx_buf_size =3D rc; +=09rxq->rx_buf_size =3D bufsz; =20 =09DP_INFO(edev, "mtu %u mbufsz %u bd_max_bytes %u scatter_mode %d\n", @@ -204,5 +169,5 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t q= ueue_idx, =09=09 " socket %u\n", socket_id); =09=09rte_free(rxq); -=09=09return -ENOMEM; +=09=09return NULL; =09} =20 @@ -222,5 +187,5 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t q= ueue_idx, =09=09rte_free(rxq->sw_rx_ring); =09=09rte_free(rxq); -=09=09return -ENOMEM; +=09=09return NULL; =09} =20 @@ -241,12 +206,69 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t= queue_idx, =09=09rte_free(rxq->sw_rx_ring); =09=09rte_free(rxq); +=09=09return NULL; +=09} + +=09return rxq; +} + +int +qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, +=09=09 uint16_t nb_desc, unsigned int socket_id, +=09=09 __rte_unused const struct rte_eth_rxconf *rx_conf, +=09=09 struct rte_mempool *mp) +{ +=09struct qede_dev *qdev =3D QEDE_INIT_QDEV(dev); +=09struct ecore_dev *edev =3D QEDE_INIT_EDEV(qdev); +=09struct rte_eth_rxmode *rxmode =3D &dev->data->dev_conf.rxmode; +=09struct qede_rx_queue *rxq; +=09uint16_t max_rx_pkt_len; +=09uint16_t bufsz; +=09int rc; + +=09PMD_INIT_FUNC_TRACE(edev); + +=09/* Note: Ring size/align is controlled by struct rte_eth_desc_lim */ +=09if (!rte_is_power_of_2(nb_desc)) { +=09=09DP_ERR(edev, "Ring size %u is not power of 2\n", +=09=09=09 nb_desc); +=09=09return -EINVAL; +=09} + +=09/* Free memory prior to re-allocation if needed... */ +=09if (dev->data->rx_queues[qid] !=3D NULL) { +=09=09qede_rx_queue_release(dev->data->rx_queues[qid]); +=09=09dev->data->rx_queues[qid] =3D NULL; +=09} + +=09max_rx_pkt_len =3D (uint16_t)rxmode->max_rx_pkt_len; + +=09/* Fix up RX buffer size */ +=09bufsz =3D (uint16_t)rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADRO= OM; +=09/* cache align the mbuf size to simplfy rx_buf_size calculation */ +=09bufsz =3D QEDE_FLOOR_TO_CACHE_LINE_SIZE(bufsz); +=09if ((rxmode->offloads & DEV_RX_OFFLOAD_SCATTER)=09|| +=09 (max_rx_pkt_len + QEDE_ETH_OVERHEAD) > bufsz) { +=09=09if (!dev->data->scattered_rx) { +=09=09=09DP_INFO(edev, "Forcing scatter-gather mode\n"); +=09=09=09dev->data->scattered_rx =3D 1; +=09=09} +=09} + +=09rc =3D qede_calc_rx_buf_size(dev, bufsz, max_rx_pkt_len); +=09if (rc < 0) +=09=09return rc; + +=09bufsz =3D rc; + +=09rxq =3D qede_alloc_rx_queue_mem(dev, qid, nb_desc, +=09=09=09=09 socket_id, mp, bufsz); +=09if (!rxq) =09=09return -ENOMEM; -=09} =20 -=09dev->data->rx_queues[queue_idx] =3D rxq; -=09qdev->fp_array[queue_idx].rxq =3D rxq; +=09dev->data->rx_queues[qid] =3D rxq; +=09qdev->fp_array[qid].rxq =3D rxq; =20 =09DP_INFO(edev, "rxq %d num_desc %u rx_buf_size=3D%u socket %u\n", -=09=09 queue_idx, nb_desc, rxq->rx_buf_size, socket_id); +=09=09 qid, nb_desc, rxq->rx_buf_size, socket_id); =20 =09return 0; @@ -279,4 +301,15 @@ static void qede_rx_queue_release_mbufs(struct qede_rx= _queue *rxq) } =20 +static void _qede_rx_queue_release(struct qede_dev *qdev, +=09=09=09=09 struct ecore_dev *edev, +=09=09=09=09 struct qede_rx_queue *rxq) +{ +=09qede_rx_queue_release_mbufs(rxq); +=09qdev->ops->common->chain_free(edev, &rxq->rx_bd_ring); +=09qdev->ops->common->chain_free(edev, &rxq->rx_comp_ring); +=09rte_free(rxq->sw_rx_ring); +=09rte_free(rxq); +} + void qede_rx_queue_release(void *rx_queue) { @@ -289,9 +322,5 @@ void qede_rx_queue_release(void *rx_queue) =09=09edev =3D QEDE_INIT_EDEV(qdev); =09=09PMD_INIT_FUNC_TRACE(edev); -=09=09qede_rx_queue_release_mbufs(rxq); -=09=09qdev->ops->common->chain_free(edev, &rxq->rx_bd_ring); -=09=09qdev->ops->common->chain_free(edev, &rxq->rx_comp_ring); -=09=09rte_free(rxq->sw_rx_ring); -=09=09rte_free(rxq); +=09=09_qede_rx_queue_release(qdev, edev, rxq); =09} } @@ -307,6 +336,6 @@ static int qede_rx_queue_stop(struct rte_eth_dev *eth_d= ev, uint16_t rx_queue_id) =09int rc; =20 -=09if (rx_queue_id < eth_dev->data->nb_rx_queues) { -=09=09rxq =3D eth_dev->data->rx_queues[rx_queue_id]; +=09if (rx_queue_id < qdev->num_rx_queues) { +=09=09rxq =3D qdev->fp_array[rx_queue_id].rxq; =09=09hwfn_index =3D rx_queue_id % edev->num_hwfns; =09=09p_hwfn =3D &edev->hwfns[hwfn_index]; @@ -330,10 +359,10 @@ static int qede_rx_queue_stop(struct rte_eth_dev *eth= _dev, uint16_t rx_queue_id) } =20 -int -qede_tx_queue_setup(struct rte_eth_dev *dev, -=09=09 uint16_t queue_idx, -=09=09 uint16_t nb_desc, -=09=09 unsigned int socket_id, -=09=09 const struct rte_eth_txconf *tx_conf) +static struct qede_tx_queue * +qede_alloc_tx_queue_mem(struct rte_eth_dev *dev, +=09=09=09uint16_t queue_idx, +=09=09=09uint16_t nb_desc, +=09=09=09unsigned int socket_id, +=09=09=09const struct rte_eth_txconf *tx_conf) { =09struct qede_dev *qdev =3D dev->data->dev_private; @@ -342,18 +371,4 @@ qede_tx_queue_setup(struct rte_eth_dev *dev, =09int rc; =20 -=09PMD_INIT_FUNC_TRACE(edev); - -=09if (!rte_is_power_of_2(nb_desc)) { -=09=09DP_ERR(edev, "Ring size %u is not power of 2\n", -=09=09 nb_desc); -=09=09return -EINVAL; -=09} - -=09/* Free memory prior to re-allocation if needed... */ -=09if (dev->data->tx_queues[queue_idx] !=3D NULL) { -=09=09qede_tx_queue_release(dev->data->tx_queues[queue_idx]); -=09=09dev->data->tx_queues[queue_idx] =3D NULL; -=09} - =09txq =3D rte_zmalloc_socket("qede_tx_queue", sizeof(struct qede_tx_queue= ), =09=09=09=09 RTE_CACHE_LINE_SIZE, socket_id); @@ -363,5 +378,5 @@ qede_tx_queue_setup(struct rte_eth_dev *dev, =09=09 "Unable to allocate memory for txq on socket %u", =09=09 socket_id); -=09=09return -ENOMEM; +=09=09return NULL; =09} =20 @@ -383,5 +398,5 @@ qede_tx_queue_setup(struct rte_eth_dev *dev, =09=09 socket_id); =09=09qede_tx_queue_release(txq); -=09=09return -ENOMEM; +=09=09return NULL; =09} =20 @@ -398,5 +413,5 @@ qede_tx_queue_setup(struct rte_eth_dev *dev, =09=09qdev->ops->common->chain_free(edev, &txq->tx_pbl); =09=09qede_tx_queue_release(txq); -=09=09return -ENOMEM; +=09=09return NULL; =09} =20 @@ -409,10 +424,42 @@ qede_tx_queue_setup(struct rte_eth_dev *dev, =09 (txq->nb_tx_desc - QEDE_DEFAULT_TX_FREE_THRESH); =20 -=09dev->data->tx_queues[queue_idx] =3D txq; -=09qdev->fp_array[queue_idx].txq =3D txq; - =09DP_INFO(edev, =09=09 "txq %u num_desc %u tx_free_thresh %u socket %u\n", =09=09 queue_idx, nb_desc, txq->tx_free_thresh, socket_id); +=09return txq; +} + +int +qede_tx_queue_setup(struct rte_eth_dev *dev, +=09=09 uint16_t queue_idx, +=09=09 uint16_t nb_desc, +=09=09 unsigned int socket_id, +=09=09 const struct rte_eth_txconf *tx_conf) +{ +=09struct qede_dev *qdev =3D dev->data->dev_private; +=09struct ecore_dev *edev =3D &qdev->edev; +=09struct qede_tx_queue *txq; + +=09PMD_INIT_FUNC_TRACE(edev); + +=09if (!rte_is_power_of_2(nb_desc)) { +=09=09DP_ERR(edev, "Ring size %u is not power of 2\n", +=09=09 nb_desc); +=09=09return -EINVAL; +=09} + +=09/* Free memory prior to re-allocation if needed... */ +=09if (dev->data->tx_queues[queue_idx] !=3D NULL) { +=09=09qede_tx_queue_release(dev->data->tx_queues[queue_idx]); +=09=09dev->data->tx_queues[queue_idx] =3D NULL; +=09} + +=09txq =3D qede_alloc_tx_queue_mem(dev, queue_idx, nb_desc, +=09=09=09=09 socket_id, tx_conf); +=09if (!txq) +=09=09return -ENOMEM; + +=09dev->data->tx_queues[queue_idx] =3D txq; +=09qdev->fp_array[queue_idx].txq =3D txq; =20 =09return 0; @@ -444,4 +491,14 @@ static void qede_tx_queue_release_mbufs(struct qede_tx= _queue *txq) } =20 +static void _qede_tx_queue_release(struct qede_dev *qdev, +=09=09=09=09 struct ecore_dev *edev, +=09=09=09=09 struct qede_tx_queue *txq) +{ +=09qede_tx_queue_release_mbufs(txq); +=09qdev->ops->common->chain_free(edev, &txq->tx_pbl); +=09rte_free(txq->sw_tx_ring); +=09rte_free(txq); +} + void qede_tx_queue_release(void *tx_queue) { @@ -454,8 +511,5 @@ void qede_tx_queue_release(void *tx_queue) =09=09edev =3D QEDE_INIT_EDEV(qdev); =09=09PMD_INIT_FUNC_TRACE(edev); -=09=09qede_tx_queue_release_mbufs(txq); -=09=09qdev->ops->common->chain_free(edev, &txq->tx_pbl); -=09=09rte_free(txq->sw_tx_ring); -=09=09rte_free(txq); +=09=09_qede_tx_queue_release(qdev, edev, txq); =09} } --=20 2.21.0 --- Diff of the applied patch vs upstream commit (please double-check if non-= empty: --- --- -=092019-11-22 14:36:57.282241548 +0000 +++ 0039-net-qede-refactor-Rx-and-Tx-queue-setup.patch=092019-11-22 14:36:5= 5.214148923 +0000 @@ -1 +1 @@ -From 642f25da9c561f6e831cb5ea6f7d79c04d804081 Mon Sep 17 00:00:00 2001 +From 13b44f308adbfc118afec6f7329e1dcf6e6cd9e4 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 642f25da9c561f6e831cb5ea6f7d79c04d804081 ] + @@ -14 +15,0 @@ -Cc: stable@dpdk.org @@ -22 +23 @@ -index c38cbb905..cb8ac9bf6 100644 +index 03f7785b6..64fd9e063 100644