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 BB1D766DA for ; Sun, 29 May 2016 18:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=4yuHULV+TyPbr0Z1Hubp3fWt+Ow+rPbz8cf/9WColxo=; b=Dlf9CW097Lj7hg/x4ED0bwtl6v2/LH3Q27Jc+LVJSMr/a4tWeDgRJCDKZBZvLqmsqE1TADqjnwCWRQw+E2aiBaEEQ2suemmP2DvWFbI/f+g7I3Go+VLg8UTOcqXX4VRcOS/WFUDs3+D7hoXHkLlSplM31dwWbVKoucNqH0kVGQY= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost.localdomain.localdomain (122.167.187.184) by CY1PR0701MB1725.namprd07.prod.outlook.com (10.163.21.14) with Microsoft SMTP Server (TLS) id 15.1.506.9; Sun, 29 May 2016 16:48:33 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Sun, 29 May 2016 22:16:51 +0530 Message-ID: <1464540424-12631-8-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1464540424-12631-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1462634198-2289-1-git-send-email-jerin.jacob@caviumnetworks.com> <1464540424-12631-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [122.167.187.184] X-ClientProxiedBy: BM1PR01CA0003.INDPRD01.PROD.OUTLOOK.COM (10.163.198.138) To CY1PR0701MB1725.namprd07.prod.outlook.com (10.163.21.14) X-MS-Office365-Filtering-Correlation-Id: c692a5a2-91e6-4832-694b-08d387e1145e X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 2:Y6XKxZ3dlryJPSlPCzxUhiS2lgtdpVyyVdV7NeTV7QxeAv1tWY7UbhXwbBO5cwJf3+laArLvmQKehYuH00M9lBbASX9gYGfiGcwaN2x1NkYMTWMSFNBA10YVhYhL0dVCuuiz7eT/1VXnIQPMmqoDy9SKpy+UZI8oDQ8PItVM97i/AZs86R3WBNhGVKCdnL+k; 3:c0CxNFlktzcVhXGaLVu9stkqtRLpYpdbHNFbkqSTiW3bdcvvJoDTE/Sv8WlyMtNeeIJh5JZQrH3nIA2+fnVmmjPOaLir1YsxnOq3A/psUAYu+apPpby+NDKSqO0ZeJ9/ X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0701MB1725; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 25:E8WF1mOAfXGneFWotX7EYbAx03eSmYZVPCIdUI+ut5U1m1oRo2agvCVUMg77CFNfhYNCEDBgUcJF1qN7MTLtDQ5ffSDJ/YD5uQVNAHrSMnW76SjOxwThrmVo8f5DZPbzJ9sFW1on9bqaFUb++USRs/OugBGwWgzKv6F/Eq1FRCONOQp7vYCFxft1GxXWGG4NmCsyEdpB3B9jjRIooqsMk6UVwxSEMRZFJnX41oBwBcOtxQ0pnw+G4rR3Pc1UaHX9TvB3krYs0irVraBBq3LLxNFwe8YKOSDrmWe53yR1yaTYnuRXzJpHDhrpn0SXE1oP9NNA1Ft44urQpeK3TzINxD1DyTmkPXuG9vuPbFw7fhHAiH5x8ctVnhqYLBPIc3Bjxo3uIKn+aEaVqw76WBm0K+Ba05HbUxebMrQOH3qmkJtHiO95RdQhdO+Zueeo3b1Q6mtVTwcMQZC98RnhmgIyKo5VAVEse7oTih14xL1ZG+0AHye1g2XALu4dwWIPx7eIswOs08/M+sfkIZK1o/ldTlHbXd/YR7aBPm7jWUYRcG9wIN24WnVkWP8HUAs5UKSAI80ttjgmWgYu9HOZgK+devKCvk5+pU975Q3XquUGIZFIa3ClwTwHEgp85SMSmL4fXak+fbPGmSzO7j4A+b5T06c8ZtBI7ol/LRs1h5CtVS7rIKTLnYGXax6kIimy3Exae8a8bYkYK4tUaFNb83ZQ/hQB8iboNWwNl0qB0zoru7hvFtK0622vYDh7vjSwKcKa X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 20:lSzAI7jeu8JO+4okjHtx0GzuMES3JCeBCdn+wFQ4xQpRyciKRWLfi8759F8OmygT9j6sLO8QxacOM4GgPYOxhV9X6BfOWI5t7VbaxcrgHdWTPy/fz27x4oPlrbe9lpeqMUi4jdNbHi0Fa8A/Njaq6At2ZbzLfvdO+2jNaDbNLoquk479/vCvBrv8O0dvue77Em37Xg8609cht4Emuj6psiLTK8822TyHkhpW3wldMUuR4o6W8PkUAuzh4fQu1b/9kpwKEWIpzg4t0NxqPBoVmXTSmz6Bz6ycgvam6CD+Xotu2TCIyd3JcStM0mnvmMXTSVZFZAmLwAZ5XB8rgzMs7rtrfrpxsn1y+MXHZ8vsUORDYreY8bbq7fw9WWP7WxuEhzYARezvDcKxQwEROZ8uKBq/bqbMs2O/6UXOPmMpHZFTaKq8yR+adbFNC1iAg4KwZaoWDUe9SpKeoWCH1ZVecw9i4wuZa9w9fgwigzTy6K5gaCtegXCxlA7mcWxRjwjAi4TNeojHRiQbvmRqpu3kib8aoV4qAB5ujPfQFQT4t8/KQ1O0A5lf4md2Od94zR6s1dEX0r5HZ6ZOyqybkd0Byt0M9CKBtsN5zGK0tABxK+E= 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)(10201501046)(3002001); SRVR:CY1PR0701MB1725; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0701MB1725; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 4:0qY5vPquA+DLafaMv6D80cW3eJB5p0/oPbKKH8Y+/B/aXZoNmCAXBkWaRxmBE3xtMPDw5V/WB2YsglxosTdTpQzBZktacvId68xQzxFF7GXEa5oO/ihDeAwqPPlHE0FloCiku15+EjHu0Mx5V1onsY6J6NjyH6xbEmDUjKSgo6i/9fcwNAnMKGtw6+8PA9++fXnBMA7wGZh4TlBDeukTqgN6lCakU2tBtkVwcfNQYHSjnBRCsXKEKN0KLoXdIubAngr5bpgsx/KtnKR/lLb77iBIYGQ8qqXt0XUCVI65oGTLO82hyLoXJ0ncxRaU1Y2e4rZnKX73OPBMTXPRjMc0yE72HnYOCmdGcoPmaPUWNqYErIBjFA2LCzDFt7n9YoPr X-Forefront-PRVS: 0957AD37A0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(4326007)(92566002)(189998001)(2351001)(81166006)(33646002)(76176999)(229853001)(2950100001)(50986999)(19580405001)(19580395003)(36756003)(50466002)(110136002)(8676002)(2906002)(586003)(3846002)(77096005)(5004730100002)(5003940100001)(50226002)(66066001)(47776003)(48376002)(42186005)(5008740100001)(6116002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0701MB1725; H:localhost.localdomain.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 23:CpHohmOoSfmlJrPWUw8KarRNY/xtDz0zCpgHz5aLFpTSJYLqkwXVqapKmWOF5+fI0YhPeNJpsrGnD0YBTgmOpjVsxP1vEdqwuRr+rb++3aDe+QcNu2dQPOdjLLbmvLDVI5X+uETUMf7JAmu5CMABurrkVfeQDg7KBGiFPOFgEOAabdD8ZjZZVGjMwQ3H60VxGRAWESSgqt/v04Lxg9mhyuNnYAmDKMbzluNJ+RCc80GWxdFqoJuAAhWO2NWIkh+b1CGIKFoowiazqzsPD+OzrRIu1IhvS32OWqsI8nPiNLUAMb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1iHJM4DDhxxepIzzs SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2016 16:48:33.2712 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0701MB1725 Subject: [dpdk-dev] [PATCH v2 07/20] thunderx/nicvf: add rx_queue_setup/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: Sun, 29 May 2016 16:48:39 -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 | 141 ++++++++++++++++++++++++++++++++++++ drivers/net/thunderx/nicvf_ethdev.h | 2 + 2 files changed, 143 insertions(+) diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index f5858af..8fa3256 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -73,6 +73,11 @@ static int nicvf_dev_configure(struct rte_eth_dev *dev); static int nicvf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); static void nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); +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); +static void nicvf_dev_rx_queue_release(void *rx_queue); static int nicvf_dev_get_reg_length(struct rte_eth_dev *dev); static int nicvf_dev_get_regs(struct rte_eth_dev *dev, struct rte_dev_reg_info *regs); @@ -198,6 +203,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) { @@ -324,6 +463,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