From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0080.outbound.protection.outlook.com [207.46.100.80]) by dpdk.org (Postfix) with ESMTP id C909837AF for ; Mon, 13 Jun 2016 15:57:12 +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=CXTvHPdBfmtp27DUvXlxV1+6XuVH1goHKJjWL9yA36hyhfTAlcU+4SWCvFSKdX6w4F+PR16QpwkSnA1+cQJN2kZSciv9XQ6tAjqx1uo+0N2T4q/kSLyMIAWrou9cPMBdJp/H+Msol0e3dpuAEZ9yFoXGpilVVranlBUFAafOkWY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.localdomain.localdomain (171.48.21.3) by BN3PR0701MB1717.namprd07.prod.outlook.com (10.163.39.16) with Microsoft SMTP Server (TLS) id 15.1.517.8; Mon, 13 Jun 2016 13:57:04 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Mon, 13 Jun 2016 19:25:31 +0530 Message-ID: <1465826143-22159-8-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465826143-22159-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1465317632-11471-2-git-send-email-jerin.jacob@caviumnetworks.com> <1465826143-22159-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.48.21.3] X-ClientProxiedBy: BM1PR01CA0031.INDPRD01.PROD.OUTLOOK.COM (10.163.198.166) To BN3PR0701MB1717.namprd07.prod.outlook.com (10.163.39.16) X-MS-Office365-Filtering-Correlation-Id: 82e42048-7377-4c2e-528d-08d393929bd7 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 2:Ujk0/7zM/yPwWDYs/7p7hIXVP6Nkvt3YHObI2EZudOjxOM0aYMAlesOuYqb2jLKcPrnPVUS1kLC03AFtm7NlpKLlE6Q2s8V7rxChsjXIHaHgOMASjWqHUgAHHwNMfUPXaNqi+mBUGr8vo/PADSLxsrygdQaGlo4AcEuX7E+gKSOeh+5GlkbBaq8Eb1WN8Z3b; 3:zV5v9BUjriN5Key8qRlhuxJc1idFpjyI4HJ/m6Y8LzVJn35S6d8+VscI0iyW/FUzT4wbGzUF8dNxGuiPvUEPj8dkcNVcjWMxx3eF07ni8f3HgWHij2+kYGhCGy1owgp5 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1717; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 25:CimVRYdiw1nTtDc90nDf3mayDn6Q9V1BDTZDnvf8/j+w6ysH/pmx1jGBxvxkR7sa+1QOSFxSOzVN/Pd+esmcC3gFq+PPkbZ/KmnJmG2ivhkxoZq01Rb+qjDe+TMAopE4jXBdZV+HXyuBcE7n6ez2/RxdzOLcFlOGYX7VZnYkQwpBZ8XM6tYmFDedZLQmgopPV2QaemN2lnnYTUfqhLtUi4BLdGY30w9MOn3yH8PUADcqFd+JpR3L/OfyxdrkjzwXhlWGwmTSyZ+q73TNzo9qHvWlGtLyv+ws0/jWHxw6OtOV07yf7jKXArrDhZyQ9GNwkifCcdzrAtm4Q9x8ae6U62Xjzvtb4Y7CP9ms2NtVSUV8mQPpCJD2XoFKBVH/AMrU+GM0XQXErV+yScpsBQwS2qhFoNIVKyvVM6cATZghsVKfMwWqYudhSqCIMFezsCe1rVb+MGVL/0DuL/Qu3yFm65yyjT+tqPhNClFBC+WGV0i1KriNM07M0abtXaDVf+FrlzTHcuhElxSLOB/gdSAfXPIICDQlox/PpwM9ioaUxg9vDHyk7IkY/Xr/uLleElGDcGZfVa63/LfXanPE5s5dPqOH0uhH804JvqGYArbSwCy7F8mrXLV+t3fkjLwqhOFMXAz9ZQTWxR5VoSqCyGfrHdAM2lfsrwvP0D9d778McfxOfkSFmCOtdrBXimkf8UaUtaUlsBhG07WWrwVjvur1184VltaDItS+VTqsmCp7KP7UTtMIsS/4QVyJb06yVu4W X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 20:VG2flzamz51MCEPK5s89yWWaj/++DwohPQoqHSBiyoi3AkruzNeo+AqGR/VizlIky40lyE1mXtMUZCJbaaOOof9wNoQS20C54+kZIyMVX0jyvl34pWj8Q8tCusLIXjZoOiddnBy3Nlx+gYXEIQTBIvEnN61Ko8gThnCN/Ly0vnyfyLuI794QDUsrU7kt4UM09e/Hvd4KrHXXyRk4i41VzV9blbR8CH7//JPZj07zta/WtDBtRIh8lBI2PBUaZr99R4vtrrXvLTaP/WER9NTy/8UCqqbqeVyUCafIpwhVQXnQKGPGfVdZlVXyh945rlviCSRjqFS0KYKwS2wlCXHsp03QWecU7S8q2KlFQiMfpiQYwI6tcpJTjx622dQ4BwrGa56bgjj/gXg4JJrFM0tLcn68L+8oFTgo6uvE9ND1NKKsON1Vp06OzvjTy7Rznqg4jlYzfl9Y43yEPEpn7ezHmwYh7q2t3wUhdhu2+x79Sw6Ryoeg4p9JhLfrFeUQG3bUmc4dXUK/Ho7I+S35BiCmjtOqfSCT/RN5T2JPr61BYijPHrHjzbapFinZNTeGNxQTHFoi4gy9GU4Tt0ETvclDj2WPVuPMm3EysOHFrHqqbr0= 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:BN3PR0701MB1717; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1717; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 4:aEdF6xBPqKh3usqdWrXHwjKzA5IoQcJ78NqkPkHZKSZEVP3fKUT/SQHWiLw3JQk9rkaBXzprS9xFQANaZn3joWA0QDtLCdGFYz0HjFwgPo4YDhB23P2H3jM+6RgjFoyZbyAcOA1bsPHNiDtaUMccfIyDZ+MCD6EBSwVhEwT4HV/tFDHMcKXCUMlK3uJGUqCUrdLZvJzF9eWLNdunP9hYNnOeZJD5wqMbWRxX5yh1p0uNUBZzbicvQxlz9opSKV680CVzgpvh2pM2SMMT0OWDmwp7RnpGFQYyR7/MLBHumzcDcj3o9os90WBffPrDmWYp8EW2IaILQ1U96CwD4R6NPWUdQy20xhScH8gIxvmSpBysey9ArVdp7pdBS1ZnWulTfmwAL3gzAxyz4Vc0mz3SLCFTjZhYtsT2/tnueZui42c= X-Forefront-PRVS: 0972DEC1D9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(979002)(6009001)(6069001)(7916002)(189002)(199003)(50466002)(48376002)(101416001)(42186005)(50986999)(92566002)(76176999)(105586002)(106356001)(33646002)(2351001)(5004730100002)(47776003)(66066001)(36756003)(586003)(3846002)(6116002)(19580405001)(19580395003)(77096005)(8676002)(2906002)(81156014)(81166006)(4326007)(189998001)(97736004)(2950100001)(110136002)(5008740100001)(229853001)(5003940100001)(50226002)(68736007)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1717; H:localhost.localdomain.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; BN3PR0701MB1717; 23:3jMDiloN41tiklzq6v7+kF5n5/PRNbDJ/2r4dvf?= =?us-ascii?Q?k7LJisLdzkGtadVj7KZt1aux6Yytt/3bdPg1w0p2CiOm/CsdmEdo/z8v9zih?= =?us-ascii?Q?B6zTI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tt91qt1q5Bz7ktBomZJvSodBhKoFAb5p8Q= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2016 13:57:04.0389 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1717 Subject: [dpdk-dev] [PATCH v4 07/19] net/thunderx: 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: Mon, 13 Jun 2016 13:57:13 -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