From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0071.outbound.protection.outlook.com [207.46.100.71]) by dpdk.org (Postfix) with ESMTP id E02B09AAA for ; Tue, 14 Jun 2016 21:08:32 +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=/SSFU648vtZVAOwjQXgPAFKPdDkCJCZf6YuvldXGsIk=; b=m3Ghm2Se6BKgbcZ25aceEqZjQia1i5sW9HetlHokkTNDZHBRdX6iwerhbUL0RQ8oEse6+Sa6jjm08WHW3+rjwvXnC5RdZruBYpXjUDTfsZmArA4GDvsHbqkLiH7Ua+ovas+h0HXYwy8xDOOALzewLn4dtcwsmh2kMk0yGHXrJSU= 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:08:28 +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:36 +0530 Message-ID: <1465931200-23912-22-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: 3138a635-f659-49aa-93f6-08d394874681 X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 2:ZcJbA6ECWUJC6qfjEWzYBwC0qTxWsjQcWfYHfGRblF9Iy0rIR9PTREYYtfcp7qmJ5Wtf4+gwUGnYQ0au2SJ6dJVUEpU1AHvme2YG3JyyOFOeVfvjSQaeoE0nqFolRofRZ2bkn7ru22fNxaXrc/N5hQ1cC9C8wFAoUB5ZQIzb8412sgkVoC6piwbia67azj/M; 3:2xCeDGkZYx+4QjjMRAxHTDMqzemm1JSThhmtqQR2Ts36Is9IlEKWJgpdA5Jfzx3p7pGbyEJZKPRlSIZnZ9lj3u1MNoajIF14IoJO/GkKpnq2+eRiUGdlLl8rIX/f/yIK; 25:Gyx4JAWkQspBHoq0UZrEwXi8n1Nf2JMheRnCgylQRfhSEhVjc3oiRlGW8dQGs6z9aeSERH98M5VH0q57L6mKyqNzuk1qKa69pvYjbeIgRFtnQDGeVYA/tzdAms45Yi1yPXRlBY13CoHs7YmKU9N816tfXkGqVkVJOLWTJX1az3yn2ozIIPnaGgkUo52yHugjHyoPfsG8PKBLVdr7k82uHPejNvPhIgQDzrnlY8zj7CK37dhBzoufDFc0Toy8I4nyX60PwcKxz3of82ATEPFjbxtmjLrrj+AdFus1mFeUJdOEWHucvhM6ul9pjEAJuEb3VcB5gywFvaX1C9M5DtfZN4k+k0G691z7GiNoBWohs79sRZR4sqa76pyOMtIgPCsIn7dOyQke9XoWNe9gl7HsYUc9vIIUgx7xpI4Nka1E56Q= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 20:Y6b/8mI6dX7OnmrmXJXAz+s45DpYK9CDsBeXGdQSb7vTjPyAqQVDRB24ljaz16EvKV7XV+NsbA0HvJtqCLvYn/PPcVf5kLTLz7gd2FSLoYEaCS7cy1bNOMikUHZ+4oPqoIWKx4q7ENlZXJRQGh0J0/v15IoABRh+yCXykOuFClmWseEq0NY0ZNPjB5s1bxjdWOydMFVMa8LovRMKeNxOEaglg3bReEPqtxgIjaJU11wSSEL9HLCwijkTMcH+8iou9Dm+KZgDRgkNWsG2L3/5s3Z9GEJp+XpetIJoA2iA7cDbaYQ2WKDKvFOLn8uMz64D1pelRh6lCXL7lwjhP1YPSafB6H5/9+6wDrMIdNobxECGFTl0lo+AyDLOYRDtf9yuTygWsiUadNSggcsKyasxfxU/iztqf0iyH89JOwdKUVcevXn6MIotjaMugYOSO+bfp/88fSlf6aWqqHroCwfRWMKIfs2IGyVWkZRusbl0AFE9bgGmNLwcBOf2zix2Zy30NJG+Av+9XBRxRJbx6kw4WdSqwk1BTBcDcrNvPXgzXXRKdRSFLw0cIZ+PGwQGmYf0CDr5TeWb4clIdL5tpdFoD140VRFmL2ei7eHwzmwh20E= 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:BY1PR0701MB1723; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 4:1nMvqNn7mxdd2h1NgGBAs787ToVOsHshMKAwe/0ZCcHjcx9hx5FRs97+mnFwSAAa3eohVu3Hxyg0UEPFWXZfEdElrTuCOTSCq07nxj7qPJ8DCBcSNqGRR+M20x9LQErzY1ne5kzWCqpSGLa5UybsN90r/CuTwPfyVHtH4eQovLFFX5+zDtm40XKHwtWmH1M/uOvtoG9PfqD7WuJPVE+/oGC3fkt8asFPN86xnL0e9uKATJlSwQfKjHdiaQVHGK6S9IksMPsbdKBXfUIOSeoVMMBRReaVs9pBnc1msio+k3C4swWfnWl3PTEE912NRkqkxY1U0YDiIIqZWl4EHJTJOuopcVPqwihXxZbuiSQayxW2saJW4mciiUNuIJBa9CV9 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:SS4NXNAyBRdgw9XzO2t9d4DE9DgsXKXRifs+fwL?= =?us-ascii?Q?LsppbKX+nZ2ooZLjybL0sq7oVRaEn5IYszVt3X7btEj6h/tQaEttvIdO4vhn?= =?us-ascii?Q?H1mrnS7gQJog0EF2tpiiMC9Lo7S02cbY4lMM/gWGq83tHuieONo3m4ZRvQjB?= =?us-ascii?Q?7HSS7cZlUgH5rOrAP/w8HKi8XOGOBJLr+PbB3PG+yWsdVkzMDum8IAexGU8v?= =?us-ascii?Q?hhHkTtKNmBjN8s0XUY6T5FsHvRSqpm0b/jkzGuOlh5nTzIew8G04UZSfzJiM?= =?us-ascii?Q?09J/S8hNxtTS161VUsBGak1kzBpKy7nrqKYi09IAJbmvg1eEgC2biCjx3nrG?= =?us-ascii?Q?i0u5uoyGw/wcxUHNaLwETYPab66YPdmDELOIi30R5LhrXaauckW+orE4LSpO?= =?us-ascii?Q?FVA1FpsWJz3MEqW7PPNfLzImb0fOV6aOINXCJyfqmbkD6X8VnzTIW3Na/fWs?= =?us-ascii?Q?OwKJKidm0smYXXdHJA+gHhRb37rIwGTO6W/bBwX8AJFpyho9y6P578T+NEK+?= =?us-ascii?Q?Iu+apcn+NSihg1X9V+2B2c4MhUmZpwTm3DuajZum4W0J3+DyhcS26YnKXUYn?= =?us-ascii?Q?JXuunK68i9OcnSTK9etVMQjTILJCMJC0Q3mQC71/x3i8RehjTtq6v9fiWSxr?= =?us-ascii?Q?oYtUBFPrC/wsoyKX8W6ODpVuTSnk4JnPBP6i9/X0DvIV06UfXNanJObnAnTP?= =?us-ascii?Q?LBXTCoIQ8XlWTWEXHqkj/sPU9spdBi0DzuIfxOpMvIFclE3JwNXozxTZEFre?= =?us-ascii?Q?0lAOXoneGwZcXG4NiXh9VdynpyHJCXPc1nzq9dW3fwvMPDaSGTt0vkQh1Umi?= =?us-ascii?Q?ATBJNfhJf9LFIS8CtVbfskvMX/6/o0Zs3ryr7WER2l//9dC02AfN8UxBn58E?= =?us-ascii?Q?bPhCuWpdaHnzUZlKan9RUTesFWblpmehuHIrgIFYCj8aKwLv8lcoNESc5vMp?= =?us-ascii?Q?l1Kk4+a5qSXOd2g/lT8j1cNFZYNQU1Brx3lBlyLXgM6ic+r/pOz43GrDkKt+?= =?us-ascii?Q?bACCtZJrwHxLg/pxHhXwl2FKdDl9qx/jaKdffwRhFYwMMaBaRGLAcynmfjlM?= =?us-ascii?Q?U4+xXnJb6svkcpnqtVhLAnycm1M4m00Rd1UlJZCjCsL/P5GwU6B4LBcL34nx?= =?us-ascii?Q?KuxPTdwQCz0VStI1P+N40dzXXBClC/ICPtbe7qzrhZgxPWFHBYeBsuu3MGY/?= =?us-ascii?Q?O3G/JlxcMHSHCqc0=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 5:l6HI+rlxBnvZTqnVYbEGjSq3AEcEkBCeNKMl9xiNrAZhsFXQMxg6bkNura85TsbSqP20lKsuBUKOop6aW42QR+phwUrAWMkjuDgzFG7NbSQyhz0fsQmhfAeYO5w8FLgrXjBdkU7fryXDRx6bmndWHg==; 24:ZioL8AdD0PM7NhojRz9euuoF8xRtPv/0fQ8P/cMSivcq6Om9PJDhvmcaetpW1MILjUF8Fa2Erffa7iVCNrCvY8+FGWOB1NyptLbqPRVa0nc=; 7:xy7u3AWCAUHin44tckkjE3ewk3g+c+OBVwCPPzrWci8dR2pETaKt7zzFlxisDxZ//aSxS1HB8LkwMLCwrPIoMZ0bs4vQDe7AVXPvslCsYP+2XoehRJ9lUsuph4VdlWN5tt59QQEdHZVT0Gthl140U0QYNmSBGkLw58fguSOi5q8MPfJNDHzAK82UU+7DKQx/9t/FICcxKf52DYyBwE4lhw== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2016 19:08:28.7670 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1723 Subject: [dpdk-dev] [PATCH v5 21/25] net/thunderx: add Rx queue start and stop 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:33 -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 | 167 ++++++++++++++++++++++++++++++++++++ drivers/net/thunderx/nicvf_rxtx.c | 18 ++++ drivers/net/thunderx/nicvf_rxtx.h | 1 + 3 files changed, 186 insertions(+) diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index 8b8d9d9..7a58cb3 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -562,6 +562,54 @@ nicvf_tx_queue_reset(struct nicvf_txq *txq) txq->xmit_bufs = 0; } + +static inline int +nicvf_configure_cpi(struct rte_eth_dev *dev) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + uint16_t qidx, qcnt; + int ret; + + /* Count started rx queues */ + for (qidx = qcnt = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) + if (dev->data->rx_queue_state[qidx] == + RTE_ETH_QUEUE_STATE_STARTED) + qcnt++; + + nic->cpi_alg = CPI_ALG_NONE; + ret = nicvf_mbox_config_cpi(nic, qcnt); + if (ret) + PMD_INIT_LOG(ERR, "Failed to configure CPI %d", ret); + + return ret; +} + +static int +nicvf_configure_rss_reta(struct rte_eth_dev *dev) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + unsigned int idx, qmap_size; + uint8_t qmap[RTE_MAX_QUEUES_PER_PORT]; + uint8_t default_reta[NIC_MAX_RSS_IDR_TBL_SIZE]; + + if (nic->cpi_alg != CPI_ALG_NONE) + return -EINVAL; + + /* Prepare queue map */ + for (idx = 0, qmap_size = 0; idx < dev->data->nb_rx_queues; idx++) { + if (dev->data->rx_queue_state[idx] == + RTE_ETH_QUEUE_STATE_STARTED) + qmap[qmap_size++] = idx; + } + + /* Update default RSS RETA */ + for (idx = 0; idx < NIC_MAX_RSS_IDR_TBL_SIZE; idx++) + default_reta[idx] = qmap[idx % qmap_size]; + + return nicvf_rss_reta_update(nic, default_reta, + NIC_MAX_RSS_IDR_TBL_SIZE); +} + static void nicvf_dev_tx_queue_release(void *sq) { @@ -687,6 +735,33 @@ nicvf_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, return 0; } +static inline void +nicvf_rx_queue_release_mbufs(struct nicvf_rxq *rxq) +{ + uint32_t rxq_cnt; + uint32_t nb_pkts, released_pkts = 0; + uint32_t refill_cnt = 0; + struct rte_eth_dev *dev = rxq->nic->eth_dev; + struct rte_mbuf *rx_pkts[NICVF_MAX_RX_FREE_THRESH]; + + if (dev->rx_pkt_burst == NULL) + return; + + while ((rxq_cnt = nicvf_dev_rx_queue_count(dev, rxq->queue_id))) { + nb_pkts = dev->rx_pkt_burst(rxq, rx_pkts, + NICVF_MAX_RX_FREE_THRESH); + PMD_DRV_LOG(INFO, "nb_pkts=%d rxq_cnt=%d", nb_pkts, rxq_cnt); + while (nb_pkts) { + rte_pktmbuf_free_seg(rx_pkts[--nb_pkts]); + released_pkts++; + } + } + + refill_cnt += nicvf_dev_rbdr_refill(dev, rxq->queue_id); + PMD_DRV_LOG(INFO, "free_cnt=%d refill_cnt=%d", + released_pkts, refill_cnt); +} + static void nicvf_rx_queue_reset(struct nicvf_rxq *rxq) { @@ -695,6 +770,69 @@ nicvf_rx_queue_reset(struct nicvf_rxq *rxq) rxq->recv_buffers = 0; } +static inline int +nicvf_start_rx_queue(struct rte_eth_dev *dev, uint16_t qidx) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + struct nicvf_rxq *rxq; + int ret; + + if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) + return 0; + + /* Update rbdr pointer to all rxq */ + rxq = dev->data->rx_queues[qidx]; + rxq->shared_rbdr = nic->rbdr; + + ret = nicvf_qset_rq_config(nic, qidx, rxq); + if (ret) { + PMD_INIT_LOG(ERR, "Failed to configure rq %d %d", qidx, ret); + goto config_rq_error; + } + ret = nicvf_qset_cq_config(nic, qidx, rxq); + if (ret) { + PMD_INIT_LOG(ERR, "Failed to configure cq %d %d", qidx, ret); + goto config_cq_error; + } + + dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED; + return 0; + +config_cq_error: + nicvf_qset_cq_reclaim(nic, qidx); +config_rq_error: + nicvf_qset_rq_reclaim(nic, qidx); + return ret; +} + +static inline int +nicvf_stop_rx_queue(struct rte_eth_dev *dev, uint16_t qidx) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + struct nicvf_rxq *rxq; + int ret, other_error; + + if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) + return 0; + + ret = nicvf_qset_rq_reclaim(nic, qidx); + if (ret) + PMD_INIT_LOG(ERR, "Failed to reclaim rq %d %d", qidx, ret); + + other_error = ret; + rxq = dev->data->rx_queues[qidx]; + nicvf_rx_queue_release_mbufs(rxq); + nicvf_rx_queue_reset(rxq); + + ret = nicvf_qset_cq_reclaim(nic, qidx); + if (ret) + PMD_INIT_LOG(ERR, "Failed to reclaim cq %d %d", qidx, ret); + + other_error |= ret; + dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED; + return other_error; +} + static void nicvf_dev_rx_queue_release(void *rx_queue) { @@ -707,6 +845,33 @@ nicvf_dev_rx_queue_release(void *rx_queue) } static int +nicvf_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t qidx) +{ + int ret; + + ret = nicvf_start_rx_queue(dev, qidx); + if (ret) + return ret; + + ret = nicvf_configure_cpi(dev); + if (ret) + return ret; + + return nicvf_configure_rss_reta(dev); +} + +static int +nicvf_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx) +{ + int ret; + + ret = nicvf_stop_rx_queue(dev, qidx); + ret |= nicvf_configure_cpi(dev); + ret |= nicvf_configure_rss_reta(dev); + return ret; +} + +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, @@ -933,6 +1098,8 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = { .reta_query = nicvf_dev_reta_query, .rss_hash_update = nicvf_dev_rss_hash_update, .rss_hash_conf_get = nicvf_dev_rss_hash_conf_get, + .rx_queue_start = nicvf_dev_rx_queue_start, + .rx_queue_stop = nicvf_dev_rx_queue_stop, .rx_queue_setup = nicvf_dev_rx_queue_setup, .rx_queue_release = nicvf_dev_rx_queue_release, .rx_queue_count = nicvf_dev_rx_queue_count, diff --git a/drivers/net/thunderx/nicvf_rxtx.c b/drivers/net/thunderx/nicvf_rxtx.c index 1c6d6a8..eb51a72 100644 --- a/drivers/net/thunderx/nicvf_rxtx.c +++ b/drivers/net/thunderx/nicvf_rxtx.c @@ -579,3 +579,21 @@ nicvf_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_idx) rxq = dev->data->rx_queues[queue_idx]; return nicvf_addr_read(rxq->cq_status) & NICVF_CQ_CQE_COUNT_MASK; } + +uint32_t +nicvf_dev_rbdr_refill(struct rte_eth_dev *dev, uint16_t queue_idx) +{ + struct nicvf_rxq *rxq; + uint32_t to_process; + uint32_t rx_free; + + rxq = dev->data->rx_queues[queue_idx]; + to_process = rxq->recv_buffers; + while (rxq->recv_buffers > 0) { + rx_free = RTE_MIN(rxq->recv_buffers, NICVF_MAX_RX_FREE_THRESH); + rxq->recv_buffers -= nicvf_fill_rbdr(rxq, rx_free); + } + + assert(rxq->recv_buffers == 0); + return to_process; +} diff --git a/drivers/net/thunderx/nicvf_rxtx.h b/drivers/net/thunderx/nicvf_rxtx.h index ded87f3..9dad8a5 100644 --- a/drivers/net/thunderx/nicvf_rxtx.h +++ b/drivers/net/thunderx/nicvf_rxtx.h @@ -85,6 +85,7 @@ fill_sq_desc_gather(union sq_entry_t *entry, struct rte_mbuf *pkt) #endif uint32_t nicvf_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_idx); +uint32_t nicvf_dev_rbdr_refill(struct rte_eth_dev *dev, uint16_t queue_idx); uint16_t nicvf_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts, uint16_t pkts); uint16_t nicvf_recv_pkts_multiseg(void *rx_queue, struct rte_mbuf **rx_pkts, -- 2.5.5