From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0079.outbound.protection.outlook.com [157.56.110.79]) by dpdk.org (Postfix) with ESMTP id 20BDDCF65 for ; Fri, 17 Jun 2016 15:31:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=yIpnR73cFbmHeInihOgFjHOz8kySzaOV5+7XaO6YzWg=; b=Hc6i0pqhVH3s6v+4yo+KIo2OSAwZQiWXwc7MDJDm1XplLuKRMv557dU8bYzxMpqfOtQK+VGyjL9rA571+vg4LOlT2yOVXqDC5bdUu7S6CUs5MmIqr/rn+gVyzQ2yz0um9GFjvX4+8hqyrGN8hEYJxG9/rDWm8pB+0Mf9pCZ2kQQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.localdomain.localdomain (171.48.17.70) by BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) with Microsoft SMTP Server (TLS) id 15.1.517.8; Fri, 17 Jun 2016 13:31:46 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Fri, 17 Jun 2016 18:59:41 +0530 Message-ID: <1466170194-28393-15-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1466170194-28393-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1465931200-23912-1-git-send-email-jerin.jacob@caviumnetworks.com> <1466170194-28393-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.48.17.70] X-ClientProxiedBy: BM1PR01CA0028.INDPRD01.PROD.OUTLOOK.COM (10.163.198.163) To BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) X-MS-Office365-Filtering-Correlation-Id: 33d28794-779b-4175-a92b-08d396b3bd33 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 2:5cWNNecp8E34HL0v8Et5zsVr7k9oTYL8r0LEiYNy69W1wyWXCCMfDw9KUfm68IQvsH0PTwjIqM1HnD1wpi+ODh+eNTdct1lbFJq1WdtKsY2c1DU9ft2/f8Zp8WhDDpPSHGEfNdCFGG0Rkv+h2BCxuSlJSwbaAhBMgNBsBrE9xS56AF0W8dcNeWy7bUzAP0kq; 3:yE4FMhRvtkHDgUPrpxTJnn2CwGca49G5qjeRCMNJ8kl3MejUJH736zCPKB61AksXCUGYerhZ6cPuwKGbXeqkfY8MttlBwRsG+fq8nKa5zNfcGptXYm5kBQE1vyamagE6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 25:8P9x0XWTnDt8OZus3BSIsGYdPU6LhnVjpCh4b/9TkqVb1/m+wNEAAstwkNIfCYDxlev2RHhRIRm5j7sgbqzQ3kgl9Zrn0Y2Ch35jZzq6zEqHRCAql+LjmGIzvvz6aUK1AqdeRT684icF5e1PBARKKPdTi0N40SdEHndBunGit8Z2UD9rrPxSXU8NdcVz9cojUEFt1KY08lS1bExUfXZfzAGGcA2pdu2HJSmbZKSRcyog82wTsCxAd8/wO1cSc26uE27BNnh0rkt5QtR4gcZZy40IS0BkGECfUSgNk16Vy+6BUkmVi43EF5m1RaFJlVm5xnlpKLk8RvTZ64yLxyMznH7LoKHbMDZvfDSjHSE55geNrlTPsHmOjAZqkYK6Zvz6CTUnbMVTft4KhW4u+JGwwUqFfcpmXckBM47+UL4/3Zi+l/lncsyfk6ixxK7gnZjioVgbCRrBvr+ZqnIffbEGsPGF2RwbpNti8bSakAQ7jQcKnDGfLhEGZs0zML7V96hHxG9BC4Qejw94peX8y8PXhgYGsP0dyYSPlhZGa7SVbacG5NeqQw54gjYK6ZIF+unbmdN3RQT3kTV4+03dPworvnJ0Wc+cXDJv9muUPLDEcNs2uFhuVQ7Rs6znKvbVcv6Ty4G2Yv876pMLFasBd07xGZd1xCxPeUiOLis6W6Axb7TegLz1W4u/9pyrav6To5LHce/70WLt0113A8tYFiN9DDfzjLk0be3hMPjQdL6njzik3Z203vrpqnCiJY25VDDqwAzsPuz+Du2LbDCByAG/Vg== X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 20:25BAnIVv2KFpAqendUhUYuDY9pvOid2Pm6wM2uqizQ9e9p6lcML/n+NpSt64Z1xK7mOyXFqYd1Fm1f6avTvPE3pkJcG5kjFWp4/ujaqTAgcueIkH/Z6PxCzSO4Dg8JaXNoXGannNYTniXY2Fei0IogcO1NVUTc40WbaNYoLLs3loSV1gOGEmOZ1LE8Ygdt9GY5CiP4jfOhamXGMiGTf5KVKF24eLYYBh5W0gVGF7c/hl9i0iLV9UzcjIHz5iaUgNfg5n40HapkLxWo3cC1o+SL6OBWUqM4Nwmb6HysZulrXB3aHpCYOVi0IZ99cMsH8XKSDBcjHT/ExKKrFGU64UWOscRlqk+oBL3cSQ6GeI+hM88buoZY/Mq0cYfUqIxXlDjZzBCqSprUEDRipVGuM6B2YS/D6/MCsL3ZoZvX7pZWIJv8GVDnnHq7LgI3VZH3vVoU/xaCGGrosSRG3C7m+qu/biksSbAQ64bE2mD7q3+NaqFS4GqrA01Za/9UN2BcBcf1BZ1F3D17NojGa8XiyXb/WI5v9JWmKYlQIW4sM1MevZXXAiOIqcP5Dlz4gmdWGoGyEgl+PZAhgPsvRB3CC3Ns2JG+alvYSfHRV6BF1CDGM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BN3PR0701MB1718; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 4:DoPk1wJ27rJ1i85uDQIrZpGgel1frpGP+atIomjcGPuGm1BJI+KH/0rMcpo3dCfFNX0rogDREqGhcJubBaYjCv3jJCjXZ5Y6gpLyf1IfQ2JxyAfvW5BNyHEK6Hh0OpRg3X/xPPf3e2A4ErEpSB3MCnJME2fgrhEatl+wxmietQdgsBRVScT/yiOArErl2SjwLDYvwjmnQf6ZgQYsyErQadbFvRyauyzXMYMi8LWTayxSDt8jahgK4QDfGrRmtODq585/rY1GZVL3PYFH0hjyfmZYr741TiUUZdAdizbzrDXfqvFkSzZY8UvsMZudm2JJI837xmMDfiMYUnDGZb4fH9n1AqE75RGCUMTedmxBllg1DO7brtC21nqebu5HocTC X-Forefront-PRVS: 09760A0505 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(199003)(189002)(48376002)(19580395003)(68736007)(2351001)(47776003)(229853001)(97736004)(19580405001)(586003)(50986999)(110136002)(36756003)(3846002)(66066001)(92566002)(105586002)(189998001)(76176999)(33646002)(42186005)(81156014)(5004730100002)(101416001)(50466002)(2950100001)(5003940100001)(4326007)(5008740100001)(50226002)(2906002)(6116002)(77096005)(81166006)(8676002)(106356001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1718; H:localhost.localdomain.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; CAT:NONE; LANG:en; CAT:NONE; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0701MB1718; 23:+/weQR15J98wn827gs75BohWKl33x/N8vWfXhUK?= =?us-ascii?Q?+b+4RIckrFBCp01nwsfF6yG5XloU21tVVZ/HcTQVYehAtxEc+OvJEiZO+bTG?= =?us-ascii?Q?6//jeRXpgeMwgwBdZQTXZeOY0MBsm2bqwmWm2meGhU4/nT5JCeQ7FkPi8+g9?= =?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C2so6hELq0D8mwOE0U?= =?us-ascii?Q?2yKDUwIVQSrVolQxcdIdkFY0rTA8y?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 6:ZXbfFWnDyb5KIMshjndybFpBPkYrqJVn4YisT3N+eClE3Ln8/17cU14szV/NP2OfBxpW9G/mNBh5N4tZ94ghBhn+PZEPnLc8iI3ijb1CYhTdXTPDmWhbzwmi+XzBqH5YypQt96t2jl78zvfeKfnRAnI0qvQCzCftnMx6+ljbKLRThHPbI64p8v/EtpHKrXvxGInq5hONMlg7bpfSlcZnKvbY6EC6k2Lk6UkkA0csmDrwsn9lfOBKdJr+Hx3kycTEXjUsKW0sDBLpTB2wWY2UR9NkiFMZDSBylK6p6Uzjsb8=; 5:ZzSLJt0fOAMtkDDLpCghKUNyKHkDYjsCC68mdEiUBi03T0itOL/YDFjSoj38v03LTiXMsEqK6tykNFhzQzIlitMTuFr24Wd5e309CcDczCMvAtg+J0ZWF7IJF6DEBoKdNuQIRo8FCAaJbgx5aRuhiw==; 24:IQtTGnQK37dddbYbxiQLyN0gtYxKhZEP+A7uwIDYI4YHx8H1ilkBJYBscOtfpj73UyyYqST1+jQ9iBoapGKkGcKypDyfNO1RaFzvDMGAC04=; 7:8W2zZsxoCDXAmpDjqzyJzThkOKZrVlBffddeGBoUr5yvdDrsUdjtFqUKOfVugMOj/hFHrSM4+4qEa+/HIJvgL/qMPbfvu2EljRYb9nxB7sLpi070y9c963hQqv5hPjodEWCvKLU7PE/M5s/mews5hCP1GLZAaQkcQ3NPqb9+qjD9DpjY5FS7aG+iEDaOt4NM/QpKnO8LYH0Sn9pyXjaFjg== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2016 13:31:46.8368 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1718 Subject: [dpdk-dev] [PATCH v6 14/27] net/thunderx: add Tx queue setup and release support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 13:31:52 -0000 Signed-off-by: Jerin Jacob Signed-off-by: Maciej Czekaj Signed-off-by: Kamil Rytarowski Signed-off-by: Zyta Szpak Signed-off-by: Slawomir Rosek Signed-off-by: Radoslaw Biernacki --- drivers/net/thunderx/nicvf_ethdev.c | 175 ++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index 52856ab..e786481 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -191,6 +191,179 @@ nicvf_qset_cq_alloc(struct nicvf *nic, struct nicvf_rxq *rxq, uint16_t qidx, return 0; } +static int +nicvf_qset_sq_alloc(struct nicvf *nic, struct nicvf_txq *sq, uint16_t qidx, + uint32_t desc_cnt) +{ + const struct rte_memzone *rz; + uint32_t ring_size = desc_cnt * sizeof(union sq_entry_t); + + rz = rte_eth_dma_zone_reserve(nic->eth_dev, "sq", qidx, ring_size, + NICVF_SQ_BASE_ALIGN_BYTES, nic->node); + if (rz == NULL) { + PMD_INIT_LOG(ERR, "Failed allocate mem for sq hw ring"); + return -ENOMEM; + } + + memset(rz->addr, 0, ring_size); + + sq->phys = rz->phys_addr; + sq->desc = rz->addr; + sq->qlen_mask = desc_cnt - 1; + + return 0; +} + +static inline void +nicvf_tx_queue_release_mbufs(struct nicvf_txq *txq) +{ + uint32_t head; + + head = txq->head; + while (head != txq->tail) { + if (txq->txbuffs[head]) { + rte_pktmbuf_free_seg(txq->txbuffs[head]); + txq->txbuffs[head] = NULL; + } + head++; + head = head & txq->qlen_mask; + } +} + +static void +nicvf_tx_queue_reset(struct nicvf_txq *txq) +{ + uint32_t txq_desc_cnt = txq->qlen_mask + 1; + + memset(txq->desc, 0, sizeof(union sq_entry_t) * txq_desc_cnt); + memset(txq->txbuffs, 0, sizeof(struct rte_mbuf *) * txq_desc_cnt); + txq->tail = 0; + txq->head = 0; + txq->xmit_bufs = 0; +} + +static void +nicvf_dev_tx_queue_release(void *sq) +{ + struct nicvf_txq *txq; + + PMD_INIT_FUNC_TRACE(); + + txq = (struct nicvf_txq *)sq; + if (txq) { + if (txq->txbuffs != NULL) { + nicvf_tx_queue_release_mbufs(txq); + rte_free(txq->txbuffs); + txq->txbuffs = NULL; + } + rte_free(txq); + } +} + +static int +nicvf_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, + uint16_t nb_desc, unsigned int socket_id, + const struct rte_eth_txconf *tx_conf) +{ + uint16_t tx_free_thresh; + uint8_t is_single_pool; + struct nicvf_txq *txq; + struct nicvf *nic = nicvf_pmd_priv(dev); + + PMD_INIT_FUNC_TRACE(); + + /* Socket id check */ + if (socket_id != (unsigned int)SOCKET_ID_ANY && socket_id != nic->node) + PMD_DRV_LOG(WARNING, "socket_id expected %d, configured %d", + socket_id, nic->node); + + /* Tx deferred start is not supported */ + if (tx_conf->tx_deferred_start) { + PMD_INIT_LOG(ERR, "Tx deferred start not supported"); + return -EINVAL; + } + + /* Roundup nb_desc to available qsize and validate max number of desc */ + nb_desc = nicvf_qsize_sq_roundup(nb_desc); + if (nb_desc == 0) { + PMD_INIT_LOG(ERR, "Value of nb_desc beyond available sq qsize"); + return -EINVAL; + } + + /* Validate tx_free_thresh */ + tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ? + tx_conf->tx_free_thresh : + NICVF_DEFAULT_TX_FREE_THRESH); + + if (tx_free_thresh > (nb_desc) || + tx_free_thresh > NICVF_MAX_TX_FREE_THRESH) { + PMD_INIT_LOG(ERR, + "tx_free_thresh must be less than the number of TX " + "descriptors. (tx_free_thresh=%u port=%d " + "queue=%d)", (unsigned int)tx_free_thresh, + (int)dev->data->port_id, (int)qidx); + return -EINVAL; + } + + /* Free memory prior to re-allocation if needed. */ + if (dev->data->tx_queues[qidx] != NULL) { + PMD_TX_LOG(DEBUG, "Freeing memory prior to re-allocation %d", + qidx); + nicvf_dev_tx_queue_release(dev->data->tx_queues[qidx]); + dev->data->tx_queues[qidx] = NULL; + } + + /* Allocating tx queue data structure */ + txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct nicvf_txq), + RTE_CACHE_LINE_SIZE, nic->node); + if (txq == NULL) { + PMD_INIT_LOG(ERR, "Failed to allocate txq=%d", qidx); + return -ENOMEM; + } + + txq->nic = nic; + txq->queue_id = qidx; + txq->tx_free_thresh = tx_free_thresh; + txq->txq_flags = tx_conf->txq_flags; + txq->sq_head = nicvf_qset_base(nic, qidx) + NIC_QSET_SQ_0_7_HEAD; + txq->sq_door = nicvf_qset_base(nic, qidx) + NIC_QSET_SQ_0_7_DOOR; + is_single_pool = (txq->txq_flags & ETH_TXQ_FLAGS_NOREFCOUNT && + txq->txq_flags & ETH_TXQ_FLAGS_NOMULTMEMP); + + /* Choose optimum free threshold value for multipool case */ + if (!is_single_pool) { + txq->tx_free_thresh = (uint16_t) + (tx_conf->tx_free_thresh == NICVF_DEFAULT_TX_FREE_THRESH ? + NICVF_TX_FREE_MPOOL_THRESH : + tx_conf->tx_free_thresh); + } + + /* Allocate software ring */ + txq->txbuffs = rte_zmalloc_socket("txq->txbuffs", + nb_desc * sizeof(struct rte_mbuf *), + RTE_CACHE_LINE_SIZE, nic->node); + + if (txq->txbuffs == NULL) { + nicvf_dev_tx_queue_release(txq); + return -ENOMEM; + } + + if (nicvf_qset_sq_alloc(nic, txq, qidx, nb_desc)) { + PMD_INIT_LOG(ERR, "Failed to allocate mem for sq %d", qidx); + nicvf_dev_tx_queue_release(txq); + return -ENOMEM; + } + + nicvf_tx_queue_reset(txq); + + PMD_TX_LOG(DEBUG, "[%d] txq=%p nb_desc=%d desc=%p phys=0x%" PRIx64, + qidx, txq, nb_desc, txq->desc, txq->phys); + + dev->data->tx_queues[qidx] = txq; + dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED; + return 0; +} + static void nicvf_rx_queue_reset(struct nicvf_rxq *rxq) { @@ -430,6 +603,8 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = { .dev_infos_get = nicvf_dev_info_get, .rx_queue_setup = nicvf_dev_rx_queue_setup, .rx_queue_release = nicvf_dev_rx_queue_release, + .tx_queue_setup = nicvf_dev_tx_queue_setup, + .tx_queue_release = nicvf_dev_tx_queue_release, .get_reg_length = nicvf_dev_get_reg_length, .get_reg = nicvf_dev_get_regs, }; -- 2.5.5