From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0082.outbound.protection.outlook.com [104.47.38.82]) by dpdk.org (Postfix) with ESMTP id DDEA77CE2 for ; Thu, 7 Dec 2017 21:38:56 +0100 (CET) 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=4I+E8ytAF6UcxDRb83cqe3KcivgX1YEpdqcngyY/TrU=; b=UtGm198X6CgRPNpYLBa8M+7E4ghAE2OUjKT+gTW5Nz/12HIUletir7JjVD8A5YuXYtye6mpaI0JpIaybmFScJ+2n1sFwqwwjza5zwYdsnkUo0gickkC8DzN7y/owEW1PAElM/UkK5JnM6z1P7k1e96YAJfp76bzDdlWQ6+29R6Q= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (111.93.218.67) by DM5PR07MB3468.namprd07.prod.outlook.com (10.164.153.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.282.5; Thu, 7 Dec 2017 20:38:43 +0000 From: Pavan Nikhilesh To: gage.eads@intel.com, jerin.jacobkollanukkaran@cavium.com, harry.van.haaren@intel.com, nikhil.rao@intel.com, hemant.agrawal@nxp.com, liang.j.ma@intel.com Cc: dev@dpdk.org, Pavan Nikhilesh Date: Fri, 8 Dec 2017 02:06:58 +0530 Message-Id: <20171207203705.25020-7-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171207203705.25020-1-pbhagavatula@caviumnetworks.com> References: <20171207203705.25020-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: PS1PR0601CA0101.apcprd06.prod.outlook.com (10.170.176.155) To DM5PR07MB3468.namprd07.prod.outlook.com (10.164.153.23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 96a64b41-67f3-4e00-b64c-08d53db288b0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603304); SRVR:DM5PR07MB3468; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3468; 3:CXPEaIEz8gG6Asl9m5Fp3cwuRdNBvJ9VhSQypoLXuB2U+Ql3hZ76/pOrc9HpGikbLZmZF4a/Zv1xLkIhf1BDDqB1WR1xCtVJwZxxT+7YHKUIp0DH3uirc3psG968nVYrpAZ1HjmTmSIRgfiDIDP0riDwUdyt6h8iN0VVV27+cBrKaFbCNE6I8cgWHnTpUBXplz3cgmc5/WlBkk+JHCLIeGEbBjNqLmJds6wrsIA4pX5mgI3dQQ60i0T1sg5GBHTK; 25:LvBn25KxGTxzyJ8j3CLDHORQcTJ9t41ZjUG593nAk3oTd1Qvq/FnB1Laok8ipVO0bgCfS1LLGU9UhJ2xQweFXDJ0wfC1MIUXC+rtq4WQj2yT+jzqOva5A4KV2R10JxnUt0qiLZqsqDaTXKdu40ckegGTjR9wtY0Qh1NI5/W2cKqBAdJ0gm+9XPHht3bEQ9wa8AU6ZUAzbFkhgBXK54bO/g5hjRwTwtgcKRqopRIJGtUvvryKDxVhSSU3MaSc+yyvbsUcMseJTeqqDPnb6JctLPa1HkRKAcSPDk6wkWC8nMxOTuOFKxoSZvZr9Mhen0Rv4nwulWf9UDtrE5ap6ku2Gw==; 31:zE37CefEaxGcoW/D5mIarGh7YvGz2vgXjDIMNiKS0+LFCEjAYR3m+kH6sXZXMs0RayXX7slG99BUTTVtJHowPgJDzYAw4NBspIXqdOsAJEKKBEew6uzlNxMMobetczmewROaq9+mucHmup1Ma58+TWCLjiFCs0/oDTR2ifWpNWwWioxmxGy4Py2EPIsGsXf+EvJKQS6dJNbP3mh18VHw6gNAboXDBEt17C0f71OnzRg= X-MS-TrafficTypeDiagnostic: DM5PR07MB3468: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3468; 20:SHGfMNDm8+e6K4xZxLf2vegqWswuU2B83uEm4GwxQCtZMGSdYqNZh2nqdS5KnL43HFu6d1mMmfcM8v0dloqdi9agoHAUHwqvUsFb9WsPK752WsPz2AG5FKzg4iiXAmk1+yoCILVutQywZD4INVU+BlfIxCW2n1WP2df17g7lYr2aGIKtUNhxiIjh5voyFi38dVV5dgRkA83FHpvi434itrPRSmlSoSWze0KlcXTWcxBO4krEY87cZo+7nC6QGGX8nk8IDlMvt3xtCdjuWr+UKihgCaYl4aGFf/Eo7jU5urWz/wU0wOxs5xYHtXs1UhrPtMJ4hT5HA7YBKnsiQQbwJDIicF7vj+98VB5xY41m4GxpfiQO6abHFizjqVn9/lrWhCH4uJPfXuRqIgP4Etakd6MMU4qE66PJ9D93cgz3nMu4JJNtat9kRZYqU7+/FsOpc7vLd0fdOTDjDX6fimHlUCXSU7+/yB3c+Qzl0rI9XfcNRrN+ShwLI65Q75SbON3gFcHS/jKP8HBE2hqKwl6skLHahsbydnVMN0qm2okL9cwL0dRgv4zvo6Jx5vFt6S67aSkk+Uc1e2Mtaz/gcKCYj8NTLuhQwwAJuJLoGPcoWfQ=; 4:5ZLLbhEJRfMmCsQUR1uQdbl/rzyhEYNu6fZMrHg/bnIhUIpLVcSSHYxLvpSZtWgU5u0F+9C6rw6DOFzLJBh9OlQHNLmcbohZI9PN2c63UdsjENpIrp9FR8L4uESr2Ez/9uoerQtJ4c6GDhVjC0wugx7yUknyT7KSg9GtzVQpyxoLLQ0h56CTeNksiedCezAReHDD+cOgmab9naBPgBZ8e8/ldc3Os6NnxdS2vgfZudaNIGzr7e20GtdeJYKGKCXI9Zyq75Rc2YMrPJ/sY3Wa7w== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(93006095)(3002001)(10201501046)(3231022)(6041248)(20161123560025)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(6072148)(201708071742011); SRVR:DM5PR07MB3468; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DM5PR07MB3468; X-Forefront-PRVS: 05143A8241 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(376002)(366004)(346002)(199004)(189003)(6666003)(8676002)(2950100002)(42882006)(2906002)(50226002)(5009440100003)(305945005)(81156014)(8936002)(97736004)(5660300001)(101416001)(33646002)(478600001)(7736002)(81166006)(68736007)(107886003)(4326008)(25786009)(16526018)(50466002)(16586007)(48376002)(106356001)(6506006)(6486002)(6116002)(105586002)(3846002)(51416003)(76176011)(47776003)(72206003)(52116002)(8656006)(316002)(66066001)(1076002)(53936002)(6512007)(36756003)(41533002)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3468; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; DM5PR07MB3468; 23:PgQIKqk9dqQcFeodZHUlr9qIkVtw4YpXT0EjWsFEE?= =?us-ascii?Q?yPVOjFhW900dazBLkGraEPSniO/qVWECC9Fk5rrOT8CWInhpMoC0yRLWSm4t?= =?us-ascii?Q?tmXaFpPfjGmvJk2nMtl1RlYH3/17fLkG6atz+YtyV+P6I1IMtB5hvGzCDD0W?= =?us-ascii?Q?aowvDMwAqRT7GRDAI4AisUNLukux05TxjR6+fF6r8unTkIYHAh7hHoz8jFHL?= =?us-ascii?Q?N6kAQj4200lycaC1MOFnQmLbkFiRNyfMV5IAQHsFJVwvCkF5TwE5re17vNYz?= =?us-ascii?Q?0aVtHs7VX0Qv61gYg/0QRNEhqNvivwI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EuIZU=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3468; 6:udKm2daSni6AaB5JuB1uTN+EkfDTNux4OatKwLu4TTT4YbPQ0H/S36MRPyUX2XWg0z69Sg/X5JFHb9Uv+KUZG+MWBfkHuwErn3x4PT8/jixLsYbOV8sFLYK3nPBwk/nxWYsazg+tFQwwolw/I/IjItbHvHnCsVnTMXCZ0aFt3NPrZrXTAjru+et6zcn2feNj+XFoMdaGoTwYtxCNgLb5uumahx2764ak7AQWhH4hxWkxacizk5im3bLoAiKgqzbUOZuconpagOsoi9eXi4D7z2pItv7gcWjBPjtjIOf6txX2QfnkDp9I8v4milTfFWDifV+fLRxmoF6X2xVvVvnGy02gmQVLWh38mGhgy4U17rE=; 5:M9U/E59cs9uylMImpn74iir45hJhLfPgK46Mab7xl9zrgj7xjQchc2HXoW77knuC2+lTP65LMxanIY7y/39BnpWkUmnsRJSzuKX5zEnWDgH4DXv6xl2PGtmO1vwdO/AF4wLb0okfFqPIYZny++i8s8fF2/mCpy76vzZXTszk5/I=; 24:jb0nzFTayyp3PTjRIpt1FVkiF7tbjNxY5N4tqladWBem1qvLOp2z9L+iQ4ykhfuYkQTMPCjLxFm80vulVsZO2JiSiujjIB2gxb81xO0+bGs=; 7:S0XP7Hup9dC17xXZCgVHQw6raWLMdMnC2FKqpsDB6Indw5KA5sIeIDO2OYRqN1q3YESnD4tVvveMnkJISYbWJG9+3xACy0yEmYGa7ElRaM02uPQZwzGIpHBSEDA0OaDBCX8wtNEcbaJBj0iyWSaez37p+VyTmmnZLEH/sabRUXxmCWU7p2mpi9g8OE/XSzvD3ISUfqVb3RZnFAL6VgFAnNZuWJP/CqFGNwiJCZ2XRWDoCzv7QzJoEJFmAejgOS8m SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2017 20:38:43.7829 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96a64b41-67f3-4e00-b64c-08d53db288b0 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3468 Subject: [dpdk-dev] [PATCH 06/13] examples/eventdev: add non burst mode generic worker X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Dec 2017 20:38:57 -0000 Currently, worker uses burst dequeue and burst enqueue to forward events. Add a non burst mode based on the event dev capabilities. Signed-off-by: Pavan Nikhilesh --- examples/eventdev_pipeline_sw_pmd/main.c | 12 +- .../pipeline_worker_generic.c | 153 ++++++++++++++++++++- 2 files changed, 160 insertions(+), 5 deletions(-) diff --git a/examples/eventdev_pipeline_sw_pmd/main.c b/examples/eventdev_pipeline_sw_pmd/main.c index 2e80841d0..153467893 100644 --- a/examples/eventdev_pipeline_sw_pmd/main.c +++ b/examples/eventdev_pipeline_sw_pmd/main.c @@ -383,8 +383,16 @@ static void do_capability_setup(uint16_t nb_ethdev, uint8_t eventdev_id) { RTE_SET_USED(nb_ethdev); - RTE_SET_USED(eventdev_id); - set_worker_generic_setup_data(&fdata->cap, 1); + uint8_t burst = 0; + + struct rte_event_dev_info eventdev_info; + memset(&eventdev_info, 0, sizeof(struct rte_event_dev_info)); + + rte_event_dev_info_get(eventdev_id, &eventdev_info); + burst = eventdev_info.event_dev_cap & RTE_EVENT_DEV_CAP_BURST_MODE ? 1 : + 0; + + set_worker_generic_setup_data(&fdata->cap, burst); } static void diff --git a/examples/eventdev_pipeline_sw_pmd/pipeline_worker_generic.c b/examples/eventdev_pipeline_sw_pmd/pipeline_worker_generic.c index a72b7b2f9..5998aae95 100644 --- a/examples/eventdev_pipeline_sw_pmd/pipeline_worker_generic.c +++ b/examples/eventdev_pipeline_sw_pmd/pipeline_worker_generic.c @@ -1,5 +1,91 @@ +/* + * BSD LICENSE + * + * Copyright 2016 Intel Corporation. + * Copyright 2016 Cavium, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Cavium, Inc nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "pipeline_common.h" +static __rte_always_inline int +worker_generic(void *arg) +{ + struct rte_event ev; + + struct worker_data *data = (struct worker_data *)arg; + uint8_t dev_id = data->dev_id; + uint8_t port_id = data->port_id; + size_t sent = 0, received = 0; + unsigned int lcore_id = rte_lcore_id(); + + while (!fdata->done) { + + if (fdata->cap.schedule_loop) + fdata->cap.schedule_loop(lcore_id); + + if (!fdata->worker_core[lcore_id]) { + rte_pause(); + continue; + } + + const uint16_t nb_rx = rte_event_dequeue_burst(dev_id, port_id, + &ev, 1, 0); + + if (nb_rx == 0) { + rte_pause(); + continue; + } + received++; + + /* The first worker stage does classification */ + if (ev.queue_id == cdata.qid[0]) + ev.flow_id = ev.mbuf->hash.rss + % cdata.num_fids; + + ev.queue_id = cdata.next_qid[ev.queue_id]; + ev.op = RTE_EVENT_OP_FORWARD; + ev.sched_type = cdata.queue_type; + + work(ev.mbuf); + + while (rte_event_enqueue_burst(dev_id, port_id, &ev, 1) != 1) + rte_pause(); + sent++; + } + + if (!cdata.quiet) + printf(" worker %u thread done. RX=%zu TX=%zu\n", + rte_lcore_id(), received, sent); + + return 0; +} + static int worker_generic_burst(void *arg) { @@ -60,6 +146,63 @@ worker_generic_burst(void *arg) return 0; } +static __rte_always_inline int +consumer(void) +{ + const uint64_t freq_khz = rte_get_timer_hz() / 1000; + struct rte_event packet; + + static uint64_t received; + static uint64_t last_pkts; + static uint64_t last_time; + static uint64_t start_time; + int i; + uint8_t dev_id = cons_data.dev_id; + uint8_t port_id = cons_data.port_id; + + do { + uint16_t n = rte_event_dequeue_burst(dev_id, port_id, + &packet, 1, 0); + + if (n == 0) { + for (i = 0; i < rte_eth_dev_count(); i++) + rte_eth_tx_buffer_flush(i, 0, fdata->tx_buf[i]); + return 0; + } + if (start_time == 0) + last_time = start_time = rte_get_timer_cycles(); + + received++; + uint8_t outport = packet.mbuf->port; + rte_eth_tx_buffer(outport, 0, fdata->tx_buf[outport], + packet.mbuf); + + /* Print out mpps every 1<22 packets */ + if (!cdata.quiet && received >= last_pkts + (1<<22)) { + const uint64_t now = rte_get_timer_cycles(); + const uint64_t total_ms = (now - start_time) / freq_khz; + const uint64_t delta_ms = (now - last_time) / freq_khz; + uint64_t delta_pkts = received - last_pkts; + + printf("# consumer RX=%"PRIu64", time %"PRIu64 "ms, " + "avg %.3f mpps [current %.3f mpps]\n", + received, + total_ms, + received / (total_ms * 1000.0), + delta_pkts / (delta_ms * 1000.0)); + last_pkts = received; + last_time = now; + } + + cdata.num_packets--; + if (cdata.num_packets <= 0) + fdata->done = 1; + /* Be stuck in this loop if single. */ + } while (!fdata->done && fdata->tx_single); + + return 0; +} + static __rte_always_inline int consumer_burst(void) { @@ -412,9 +555,13 @@ generic_opt_check(void) void set_worker_generic_setup_data(struct setup_data *caps, bool burst) { - RTE_SET_USED(burst); - caps->consumer_loop = consumer_burst; - caps->worker_loop = worker_generic_burst; + if (burst) { + caps->consumer_loop = consumer_burst; + caps->worker_loop = worker_generic_burst; + } else { + caps->consumer_loop = consumer; + caps->worker_loop = worker_generic; + } caps->opt_check = generic_opt_check; caps->rx_adapter_setup = init_rx_adapter; -- 2.14.1