From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0084.outbound.protection.outlook.com [157.56.110.84]) by dpdk.org (Postfix) with ESMTP id 13686D081 for ; Fri, 17 Jun 2016 15:31:46 +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=Z4EGij2aIEOA4J8WrkyzoWnXxqgapfV7yxR1N9JKNAk=; b=dlmpbAJ2XMJDtTW1ornrJ143inIUnX+YJP9P7V6GcDzxVXTreyNimJ4g56icCTxTSIdx8orSrFU3MtYiDwwhjcX9mpVfgn9Xb1ifcNRxfEMeKvCgO8M8r/xzaz0PwoHcV6ZF/ahYkVqSr5FPoADfIUuKEdz7ErFtIIbdusbV+yM= 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:40 +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:40 +0530 Message-ID: <1466170194-28393-14-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: a7ddd3ee-1e20-49c0-a3e6-08d396b3b9a9 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 2:D0UhsdDN0CHTXfmf46DQCiO+yi5M/AHISDkckefWIv9qvptZjAhrJEr9DYuvx7Ji6tRoQyLjyJMPzL/yQgXQC89FLlEFTkUSfJskggwD61zi7oWoBMnQxwRu4i7zQzfbNypIYefcOic+XPiqYdzmPSPzMo5Fqs4ea+sddLbSjCAKHzaL2NfX7MflCx4GwM9I; 3:5lGjg8MhbMlSkqv/1pGHd8Rjmy9Va4EDlRZD6JcUOD3wtaH0Ma7zDrPhe8xequ3uDK7OC/1Yc+2z864TV1TxYSf3ZGpSYWE4uJ0fraG5XOB2aIspbJvC1iPYCBujnlLh X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 25:aUS7ageZVuN3WDzy0yKSbswEqJh9aCScHEbor4owXEnECqMhU3hUVpAyTbAWMihNCjz2O/gR3e57CQyBlaCFWxcfmuL4YGbv3iBndwjOHCcR03BpLS/e/EJR4ZSiHJAbo2/TXiFUCxB3a9+VPbYedgeA88+gL6/OyZsbJxFR53yShH1yn6/FhKEvOYds9m9RGLQ/3OKLEv6PIWmPO1Ha3MxFm0U+T4AIzSRdnDyGUrf28lPEjEkrYfxmZtopWZqiB0runZOefWSsx1Dt9t6f1lWs0mMLqYxtQcxC6Lt68tcTXRBVzY/3WWMnGyHhpNe+D4+DGjThiyTOysvLnKgmyTviwPm5ITdpt6FJK3cvyfzH8Ol8eThxcshy8rB7RgxBpZRc54Hy3NpoGUioBtTPDZdbEk24r9GhNioOZYQoCllm7u7gy+WJMVvEzZoMw6ZucGt51pjaba6FIirCevjUlV5regfP3IgTN6RvaQFSqeAJ6H1LnmGxAFysQCyGY4ICf4t2Z7iL6/SuTsrwoktkmjyBreyGoBBF7XdwDpvdFPAMwfVqGYdfD8ilplSJZI2TyO6HVW1W1f8AGZmlcLZ15JZTPaR05YKw/HBcRtQ+ZF9AZTOOu4JD5luTg/QNnj/Ny8BLwR5VefzxMFko4prWEn8HMhMd3fDqjPzUWK50GEGp4STyuQDRNpMZGq/HMBiKZg+5WE+en3y2LiOnha7E1i5zOxcO+L3/kPQjiLLPbATo6/+cvZAP/Jq9DKeZw4KRh0dOAwRQnKava5altIB5Tg== X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 20:sGVIj0MXSIcKc6xixdllCcdzsUKkEElM1q+STjpklrym//1CcSGiUC+4Fgb/RTfjCssvsinFzuV6RSQhkMpTFxgRxuUeWQwiaLbtOs7rbDTUWv9jCPlI41ZL/+/XeOXQhbyQya85+4fta2O16ebNch4+/5jcA7WtKM3o9lONKiSFEkQVlGBJgnd+FQCgrM6hmEiB8Vl99rSKs/OPlKsb0anEUBDQqECEPq0OJCIHPQIAwiyg9Upp3iGO9lkODB4mj0G1ShGpeO5p9fFZYomVAs7BMPaRfn7mH6ysgrmM5193mDgVo71ezlGAF/w7T5MZ3/eY4+iOPRKKFhxC3xrwl2v4+I5+RdVryXP0W0HmhMeIu3dC1HYkKooJJvNM6J7S/ujLfxUKYNUdC0VcymHchFghkAI8a2d+ozDvTMjX4EOz7qW/56ivGe13d7X9SUL5BU6gpfoJWuxKb3npRF1HfKXwlwcZF47nK/pMY+jHuy8baoKKt4vT+ZoWVRHlohi6mh3fHTbeKlDwpCUYgaTyz8I6wR0/ErrmcUjyu4EEtX4CVMJrm44XMR+lNeWRux4TgAFrRtX1X6kFSEc+0i4zGM/G5kjsfXTw9Mfdf+DVYGA= 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:BN3PR0701MB1718; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 4:F1RjiSaiu2X4XkkJHKGLU99jTiQ0ppklbD6PZF9mygImc+7UvG9qsD/QsRsg4PIC1dC39PBlOdP8TUu7DIyww/ZyxJiAPYqKIHuvBe5NbNvZhyy4H2kIHxWQ7JMNrOcdjQwT+R/BeRizIzgiWnM+HP/Lk9kh9X63KPqRaa6hK0pQ/RnC0jvsoAwkqT3Fs3luqu5HwLFRHSM4o5sbCHhkV3hwo7NeMMx+LyB+nBbUzr+ObBWMWFFkQNqDEMfZu45NZi1Ay9EKvNqxDuAm6hpW+IzoQH9lneYMr9tKRInL7hg06xDEZBg3m0Z0C4gTz1rVWYd+e5mXsW1b36bp6VD3pIZs6QcXwiDLnrpqdL7mzZScqYfJJE21yR2oFX7uxuUTjix2nou9NIt4O9Zuk78fXafPi6Z6vRRXZf3F1CkEDCI= 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:SsEYUAm68RGXLgI86oDO8Bwc99Hb2kMyg3qQtYl?= =?us-ascii?Q?2aswJliZWDWnSpKkQXewJWTzH147P9DeNSc53jZj5a9jwYEz8MCakwvLcFkv?= =?us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jbA+iSGgaFNPXqI/OCHbxZWGOkzx?= =?us-ascii?Q?GwwQD1fEELWr9+/C00MPuW2ZjJ96+2UwX7ygGZkx07y+jV4tCtIhjwg0K1AU?= =?us-ascii?Q?KowgAtVP1a5FjvZCcnOKHDRcWAO1T?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 6:YfRkFREsBEYbMOe1VKxEnKkhg+zQj7fhBymqVDZLbh6naoJt/2CZFcNOaVtlc/QXLQv/UrEDBHC0YpdLuRtg6cdU4RKLlllA+qWwhBLCfGwmtGvSSsN4vLkp4zG4ywULEdfIdR1l7JDwY5jkN2BhV/+/bjdUxZVWTyikkrkRYOrbq5unxsdwpsUc8JBykbMc2Oj/HiH3atq91qKRguL2aaJsCVQs7Rp8byLw/tcSuc42FpQFv+fWZENTh/+Vd6SWNLVuH6rV3LFX0hO5EDpQst/m8DlrXs2U6ZGV0uV10Ms=; 5:Smv+zvQ46K6frF8cA7XjrJ5nP/sZu/nHXQGHQ13h+B6Opb36OV6DfxlLgIuKH/0qh8u49vXuu49S3DZET99O2AtNehUTRTNpjPdXLuxLRK6JHINK3SHJMEEFI85TIYVdl9iqBXgrV3L5yI7U9mSDAg==; 24:XImKQUffkVSZvO4vvGQiGFykCpQoSzWq4q7PDOyNT1RinCLKc7IM/KU3sXeLRUutUKqngFVXWM+2ScydZ45yyr0bH5OyGp8QgEF0AxXBumA=; 7:vR1DjSO9Nu/JoRxQSCJDs7PZUV7foF0GajHvXy5UuHdRpitk7IY5ttuCbg+fYqe0/MB1cKNW8VZVoCBrTaW9k6y32Fqb+ZX6xHkAKJ+No4AjBvkyPkldsrRLkeGEqvJnrGgmInygXYneEGRxaqUC1ztjhl2Oq8lC5i8YgvlOPv2L3K98zOcA/6mQcWzxNF16Uai/Utu3QNO/kBsW48DgwQ== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2016 13:31:40.8210 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1718 Subject: [dpdk-dev] [PATCH v6 13/27] 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: Fri, 17 Jun 2016 13:31:46 -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 1bea851..52856ab 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