From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0070.outbound.protection.outlook.com [207.46.100.70]) by dpdk.org (Postfix) with ESMTP id 7C10DA24E for ; Tue, 14 Jun 2016 21:08:00 +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=L3SD4/dJLda+8vyRFXQzFNRKjmd54mSiETIIjCDYkSs=; b=RH/ganAegHRlvbXMPiSaHyT+KfcJ61QMeZ2wBRnV1ywsE1GL60jgpB4MqC0biyi5K3dvhx/Jr6/W793gZ7zoh6nxpOl2gHfHZhyYGNvG4tIQ5jWeOhaOm1r9m145vhApYkC9dUh6cw1/cyDxO/G+6b2Y+lfYcYqiR6LzBymjfFw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.caveonetworks.com (111.93.218.67) by BY1PR0701MB1723.namprd07.prod.outlook.com (10.162.111.142) with Microsoft SMTP Server (TLS) id 15.1.511.8; Tue, 14 Jun 2016 19:07:56 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Wed, 15 Jun 2016 00:36:28 +0530 Message-ID: <1465931200-23912-14-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465931200-23912-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1465826143-22159-1-git-send-email-jerin.jacob@caviumnetworks.com> <1465931200-23912-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MA1PR01CA0040.INDPRD01.PROD.OUTLOOK.COM (10.164.116.140) To BY1PR0701MB1723.namprd07.prod.outlook.com (10.162.111.142) X-MS-Office365-Filtering-Correlation-Id: c06dc593-546a-4d33-2e60-08d39487334d X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 2:CQUPfAKWq/NhwoJTK1QMzl55rqa7y/PWpVPQT2JuezOyUgKvofLOH8bKLR5XJ1zUwVejBrotglPdGUHdkhIPPcGMZXFOqE6xnevaFyGU38hrNaEBJX0g1wHtWuiPgB0D3C5RG8LA4y2B4r4Sgqw1XnDJyT8cGGXpY5ii1NBlon5VLt72qiRrUSwA5ryLLrSa; 3:mEZd/+xk2GhYy37jqwiFYQdA8pCk+sQ7WHpzgyGxgOrZvoQWKkhThLrxK+yuy+TlVGpTsdwi7TqZnRE2SMWnhB0WKeH6klXzyXxzutJJuK5Ptr3tGNm31m/n5jv1zCY+; 25:VMgF7Sd72fKxGxdHcjq6UsnRHzOKqkjvAKq1cv4tDYz2FDHIcVJsTQDkFeUdRJN/z84SwR2y+XT7SBCGZE3MBJOHEOHxM3xiNNMJwcJyI2q/NfooYicwitALzVrUVQcN95bTe0pr3XnrMZXBVPjrOdz5b9jM9e8hM67QJS+CnE77MPEJ9Wy7/chvVdRjXH3vVuGzNpveorfuynOxWU35kTRHtihBTLdNs3LXmIRTh0JLxA3mccBmsX5eeqA/tCjvhC+xk3Ovjt+g6oaT8flq0LSsUmJTTDSx5VGbuO27pnuwz4DyPKsElTWwAgJnx5zNGN0945HmC6yCDwD0KpPOVP+UAHZ29qEFxhxeRXhjyKk//FI1ZdlsFeh6DqdC3XRUvAB0uSHu9IblcCfR4aOn7iULcOA+lm0IhZByR8Nz0Fg= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 20:Xy1AbWNuiW6Z6J90w+2wZOuYmalN7Gwk5/BMFIhXTKLLgo8K8pp+PhUOvE19DUGDMYBsJdP5oUZ2S4rdGzgruj89g0eG+JwUilAnBNzSZoOuFSECsrZj+C7dL43AojNzErlfbXH2ed9v6facdS5pV5cYvmtwSQ3NpyYv27Y9XYV9dC6uaJVWdXgVI9UHq+sQAAHEx7jF1YfAH28kv5o0QoVgeeKBdZ8r+thF8ODqKFePe7O6YXxNPfdS6FxCsl9Ae6Bmdn/MKNa9AGDEC/xCPvq9uaby+6QYqUBeWKNofhiaYyP2X5iYQ/hhk3b2kYhx4h4DftaBtzJXhtjrK0Lm6G3ByL245/O2C8FIqkV0fGsnqR4E6H/H+LoUfUhuqAFegFM8S3j7pcBcbdTevQMhptyfyhw0eYK4QGIUNAPWdBJ2jAJ27fjoPH6MW72CKxZ1lTcRLzu4Wv955gTx//ii9BzHGmZybvgQHyuTHdzvKewCc5U1GV6gKPXl0goJcN31LFO3JkMb3SVy6HcI75SrSSBD+uCDgN37kUvcZVFDBqjVV40owdp6dJKg15BjUp8BlreY+rzZR0v6x9TASUR1sNerodZRotVTMuD2Itzw5AQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BY1PR0701MB1723; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 4:LwR/8NVNzx+KCUSDO2HBXXdd2dwlEzUbIpyQckcEWq2fftdTCH0BbCOkuAmKAyLU7OYYfXMQQM/c3bbX5SwhGG3mXavlnG95LP+N+n9j7vi1QifaCEW9xnFKxf7tuOUJbwyEQbjnP/vkIiY025gJAmOGPf4eavS5uvxCi7RcX81dB9RoI1WXDYW8kz9TnhyO6XB1iDfEph7DmCyJSD3Lyf9K0iUnhZpStYsaYv4pBpuOW0LhGzIU53Qmh12+Ey54/MKYnu3Y9vyxBDIXQ77mtpny2uK0bf61qtgntmDOFOHndl9BXFxmF5Z8GzraAsfXKGQYaKOK27tlOKwDcr5leYPDbWkN3b5VncGGD9HINYzPaelQAs3EVbiBevjOb8654S+8AljgxWAAYkPiv0u9ukX5R5fMP4dkmbvRciFHu2A= X-Forefront-PRVS: 09730BD177 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(189002)(199003)(69596002)(189998001)(2950100001)(48376002)(77096005)(36756003)(19580405001)(5004730100002)(19580395003)(76176999)(5009440100003)(50986999)(97736004)(5003940100001)(68736007)(110136002)(92566002)(101416001)(5008740100001)(81166006)(8676002)(229853001)(81156014)(66066001)(4326007)(50466002)(2906002)(105586002)(106356001)(2351001)(47776003)(53416004)(76506005)(42186005)(33646002)(586003)(3846002)(6116002)(50226002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1723; H:localhost.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR0701MB1723; 23:zBSqBSXtyjHdek4IYgMup3AFVAQ3jFPAgegNRX2?= =?us-ascii?Q?hWCK4GmriI8XoXsZNIZm7ZSWsSJInF9jcc30LX3aZxp8nFxoVEVFlDRJ8Sin?= =?us-ascii?Q?B3174/RmOebEVlNq8anWz/EGEH9KdivaduIJyXqPdcCAksOXW9X0YelqQ5hU?= =?us-ascii?Q?wANOV/vOyZl/Pi+8gGcGQvirnVLVsBKQX6sZnQuhGcsrHlr6g/rqZ95TSHan?= =?us-ascii?Q?InqPdnr2ybT34H9Ut5uprCdzoZ3BH1Csju85r0hw16f793p6JYlGkwi0XoN0?= =?us-ascii?Q?InvpU4Mu0aFsiSwRrQB/nib4/MoM7tmDdDZ6STJSWqjpm4zHXRBLhJABkJsr?= =?us-ascii?Q?kxsiwO6W5HgKa//90EPZiyY1Xk1gaGDu3AShdpIoeyImcRHN2eVHWHmGhsxZ?= =?us-ascii?Q?5Tyu8CCbNYYTcSaACBx3JwSr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/wJEgtbt7PCWAuNsPfUlie8NR/ZqVciDlTuoHdFUJk48EysBGo1rNYTfMCl6v6gNM/QtmZdWA==; 24:YPWXSHftf1vUdHL5SK6IfYskD4t/SRBDkItNf97jV9sHAA040+aD3PkMgyYCxIvnQYLVW7tw6Y9gNHNtVPpg0AuE7nCxnuZthzoryVWawXU=; 7:Z/avOcpxuVwemeWZSVaLRiwKM4VA+uNXHdILJdDfXETCt9peLr7jiA2GtxOBrRx3QtN2TFbPy4poCVGt27605MGYbCijlDiNdZBqb90j8RDIpsU1c/oaSe+pvVXrx/aEfGohcm2TBxwEi6HBpfxhlt/tiIUABM8GcE7FOlr6ysVnNI8DIexsJ4ucm5f3pi94dqU8a7cdTcnPb8AKOK2V4Q== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2016 19:07:56.5469 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1723 Subject: [dpdk-dev] [PATCH v5 13/25] net/thunderx: add Rx 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: Tue, 14 Jun 2016 19:08:01 -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 Reviewed-by: Ferruh Yigit --- drivers/net/thunderx/nicvf_ethdev.c | 136 ++++++++++++++++++++++++++++++++++++ drivers/net/thunderx/nicvf_ethdev.h | 2 + 2 files changed, 138 insertions(+) diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index 109c6cb..4652438 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -168,6 +168,140 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct rte_dev_reg_info *regs) return -ENOTSUP; } +static int +nicvf_qset_cq_alloc(struct nicvf *nic, struct nicvf_rxq *rxq, uint16_t qidx, + uint32_t desc_cnt) +{ + const struct rte_memzone *rz; + uint32_t ring_size = desc_cnt * sizeof(union cq_entry_t); + + rz = rte_eth_dma_zone_reserve(nic->eth_dev, "cq_ring", qidx, ring_size, + NICVF_CQ_BASE_ALIGN_BYTES, nic->node); + if (rz == NULL) { + PMD_INIT_LOG(ERR, "Failed to allocate mem for cq hw ring"); + return -ENOMEM; + } + + memset(rz->addr, 0, ring_size); + + rxq->phys = rz->phys_addr; + rxq->desc = rz->addr; + rxq->qlen_mask = desc_cnt - 1; + + return 0; +} + +static void +nicvf_rx_queue_reset(struct nicvf_rxq *rxq) +{ + rxq->head = 0; + rxq->available_space = 0; + rxq->recv_buffers = 0; +} + +static void +nicvf_dev_rx_queue_release(void *rx_queue) +{ + struct nicvf_rxq *rxq = rx_queue; + + PMD_INIT_FUNC_TRACE(); + + if (rxq) + rte_free(rxq); +} + +static int +nicvf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, + uint16_t nb_desc, unsigned int socket_id, + const struct rte_eth_rxconf *rx_conf, + struct rte_mempool *mp) +{ + uint16_t rx_free_thresh; + struct nicvf_rxq *rxq; + 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); + + /* Mempool memory should be contiguous */ + if (mp->nb_mem_chunks != 1) { + PMD_INIT_LOG(ERR, "Non contiguous mempool, check huge page sz"); + return -EINVAL; + } + + /* Rx deferred start is not supported */ + if (rx_conf->rx_deferred_start) { + PMD_INIT_LOG(ERR, "Rx deferred start not supported"); + return -EINVAL; + } + + /* Roundup nb_desc to available qsize and validate max number of desc */ + nb_desc = nicvf_qsize_cq_roundup(nb_desc); + if (nb_desc == 0) { + PMD_INIT_LOG(ERR, "Value nb_desc beyond available hw cq qsize"); + return -EINVAL; + } + + /* Check rx_free_thresh upper bound */ + rx_free_thresh = (uint16_t)((rx_conf->rx_free_thresh) ? + rx_conf->rx_free_thresh : + NICVF_DEFAULT_RX_FREE_THRESH); + if (rx_free_thresh > NICVF_MAX_RX_FREE_THRESH || + rx_free_thresh >= nb_desc * .75) { + PMD_INIT_LOG(ERR, "rx_free_thresh greater than expected %d", + rx_free_thresh); + return -EINVAL; + } + + /* Free memory prior to re-allocation if needed */ + if (dev->data->rx_queues[qidx] != NULL) { + PMD_RX_LOG(DEBUG, "Freeing memory prior to re-allocation %d", + qidx); + nicvf_dev_rx_queue_release(dev->data->rx_queues[qidx]); + dev->data->rx_queues[qidx] = NULL; + } + + /* Allocate rxq memory */ + rxq = rte_zmalloc_socket("ethdev rx queue", sizeof(struct nicvf_rxq), + RTE_CACHE_LINE_SIZE, nic->node); + if (rxq == NULL) { + PMD_INIT_LOG(ERR, "Failed to allocate rxq=%d", qidx); + return -ENOMEM; + } + + rxq->nic = nic; + rxq->pool = mp; + rxq->queue_id = qidx; + rxq->port_id = dev->data->port_id; + rxq->rx_free_thresh = rx_free_thresh; + rxq->rx_drop_en = rx_conf->rx_drop_en; + rxq->cq_status = nicvf_qset_base(nic, qidx) + NIC_QSET_CQ_0_7_STATUS; + rxq->cq_door = nicvf_qset_base(nic, qidx) + NIC_QSET_CQ_0_7_DOOR; + rxq->precharge_cnt = 0; + rxq->rbptr_offset = NICVF_CQE_RBPTR_WORD; + + /* Alloc completion queue */ + if (nicvf_qset_cq_alloc(nic, rxq, rxq->queue_id, nb_desc)) { + PMD_INIT_LOG(ERR, "failed to allocate cq %u", rxq->queue_id); + nicvf_dev_rx_queue_release(rxq); + return -ENOMEM; + } + + nicvf_rx_queue_reset(rxq); + + PMD_RX_LOG(DEBUG, "[%d] rxq=%p pool=%s nb_desc=(%d/%d) phy=%" PRIx64, + qidx, rxq, mp->name, nb_desc, + rte_mempool_count(mp), rxq->phys); + + dev->data->rx_queues[qidx] = rxq; + dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED; + return 0; +} + static void nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { @@ -294,6 +428,8 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = { .dev_configure = nicvf_dev_configure, .link_update = nicvf_dev_link_update, .dev_infos_get = nicvf_dev_info_get, + .rx_queue_setup = nicvf_dev_rx_queue_setup, + .rx_queue_release = nicvf_dev_rx_queue_release, .get_reg_length = nicvf_dev_get_reg_length, .get_reg = nicvf_dev_get_regs, }; diff --git a/drivers/net/thunderx/nicvf_ethdev.h b/drivers/net/thunderx/nicvf_ethdev.h index e31657d..afb875a 100644 --- a/drivers/net/thunderx/nicvf_ethdev.h +++ b/drivers/net/thunderx/nicvf_ethdev.h @@ -59,6 +59,8 @@ #define NICVF_DEFAULT_RX_FREE_THRESH 224 #define NICVF_DEFAULT_TX_FREE_THRESH 224 #define NICVF_TX_FREE_MPOOL_THRESH 16 +#define NICVF_MAX_RX_FREE_THRESH 1024 +#define NICVF_MAX_TX_FREE_THRESH 1024 static inline struct nicvf * nicvf_pmd_priv(struct rte_eth_dev *eth_dev) -- 2.5.5