From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0074.outbound.protection.outlook.com [104.47.38.74]) by dpdk.org (Postfix) with ESMTP id 69E727CF1 for ; Thu, 7 Dec 2017 21:38:21 +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=shCPShCakZJi3FzkswbkQkIbrv3+A3KZfN3Yt4T2ZGg=; b=QLBhSa573U8A4cwTkD50o4XzIlUmKLhXgG6wHL71+vLsXKW0QfZ8Mt280SEmgxepdSTje5GUOkLn5o7NS732wkrKuWyQ5qtWcD4MCl53srENNfWkgqNHkKqN/1SdJlIgrqvT3OdA6+J+VKJdSWM+QZxdnyOqJWC+m/uhBtpT7co= 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:16 +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:53 +0530 Message-Id: <20171207203705.25020-2-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: e3f7ade8-6763-4f17-7eb7-08d53db27398 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:f3xt9+xhj03DT4w9Nn2g2fBhdLD0fBp4inMu6/YXkxhjoeG8BjZZZfkAx06pLpFNbTDQwMQ5/BlTXw+izqxh8FxsraJbdVAwfc/S+4ofRmiGtMnD7XKOJD1T2L95DguhwsC8PH2i5833xiAfEKlkcQeafI+Mmp5nKcE8H0KItAgPqv8l6V8cN4WbZ/JH5OOGdeqE2afxE6A7hWWuZ0F5JzlJy61Qfr5Bv2rk8C+vUoLQtF3R1mj2zpHJ6ZAJgBOL; 25:SGp95W+pYsC4t0mjUK6NESIhRzFGivnTR472b6ZsbDczIS/3xpJzL5K97ekNDtntrBQS20SvnO7XCxOnkvVYf4hfCKBkmhTNzlQfhZmsQh/eWUxGVY2dzneUnH1dhi4MNZ0/axfN51DRFteEEKFH0m5SnlynQ10SdpD0/fH/42YmG+2YPTREIfmxTzADNG8fLd2H4DJvifqYG7Ol/M1sz8XOAWOaklnIMMbMpylXqMhKNClw5D82S0MJQtngnbdhv613bUHdYwAmBKlYke1g6PISev5Uym7ArQvPx3hCsdO3OfIIWSYxcu7LmNAgYzBsJsM3yNUWqEZW4D6Rvo8nTQ==; 31:O4CfxE1Fjs34oEUZezV6XJqxVzTxupLys4kU4tWVQat4x3E2NQoBH954q97cXHgZLu7PfOMZzYRL4o4dTEEfdbF2Fzd5t452VfFA3XniXXjTgCuG49G/bdKHGSkJ7jLPbp/13ID2bp1pT4vXT7jhfxdZKijwUfOrd4vl9dar1WEK+93ABTzTzG6yYXQe5eoiOqu9c0EnBGnnj15sgXC3ewdgNeBP6f6G3t3k7A9h+u4= X-MS-TrafficTypeDiagnostic: DM5PR07MB3468: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3468; 20:jLaqwmX7AUihN/PurZq4S/oawap+Cu+vNlGFPc41Jvo4yLC6U3NNn4BnIJBMnRsmtAvpEvw5YE9+zDQ7bR6pKkc8QRNukikKBRUfTyp20djjYXdaD0pnHqyOmq/N4OwGkg/5IWFq88udybRsTlMzD9KJfyAzAW6TtY/kjK6Ar6/GBpNNrgexl/T/WS9ihTKii0I/9ZfOvsUNDHtWDbxg2C7EX8PAHvyHxu86w/ofN9MrNaEIzcd00S4yS0rOxDpIOd6tNcyUAE60w7uSg7+tiNvk51B3kUD4azpsejM1kMVLVU78Q06SduVIGDkXluDEdQXYA8IhU77Ytqxeg/2M49/dy2Zu4COX6UUjhQvIQF8LewRLHmsjhnOqWeSCphmsOKLQXzu7zbQP2ZMd7i12muW+zaC8IZ1P+ii9wvZYeC4IsY5Boc6lz1KGHcqAz7qAj7okhHPFEqs6/2OkYk4KZUWNFxI0nsCO4n8By9NyMyg5lyd9CTdFQAHaX9SF5yBj51i4+kMtG37VCn49kP+s/1Zh/QftMOYtBdFgrxxS0UrzUTL4/d3e4FYUmMjk4nmAoZCJx8hgWvs7bhHQBNop3CUe/m4ZekryMt0HlgWEpmE=; 4:17fB25kP7LWyKFo/WTNmOqo3ebkozq82Tm2J0cTpLDilknUL++SHcSnqL3CPtV+ehA3T4udn+fEpmyXDD0mtSjTM/gBVCKTldFULfrIaBq9ZI4b++ux8eq5TnzYWXJrfJyIYL8R+M6bh4oll6EguQ+jUMJxQyoE0fBS+wgIFyOxK7YzuRao2Cl8WS2C3QmMuE/Xv6PGwHL3ansmxnYtkEzZDDolR2X0ZnQqw2TUsc0lRxvBOXUY3uaxcnihu4i1R94Ye2noLbuZr+hsut1bUFA== 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)(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:Po1F1p6KBvMbr5pvgALIpYop8V08tw/8j6fT1UwAM?= =?us-ascii?Q?Uv8ZnR65irOcv9FyeC7OxL/9PSdcHK1epZqmaLDXhsueadDvTN+7ObiqyyW3?= =?us-ascii?Q?qmzvTciBiwdJ6MP+rmrkv9wvjcCtnVWAYbo35RoJxjDdM+nJwLF2KpoPb8/X?= =?us-ascii?Q?gyLHBhxe4AmJ4jc9Yt3cIynYEci1awj6y+EpmyneriQN/CjjZQDn+DGEzxw4?= =?us-ascii?Q?kUALiZnZcvAbE2y6iEr5RklLC6ns+e2B6JyyGl3H47DSUp7u4eOZl980fK7N?= =?us-ascii?Q?soE7JdQBvu5kmXiIpsodQ3S4HiCgKqudfAfKb6w4tfqgrhxRIKbbCG7dOUnz?= =?us-ascii?Q?5VRqa3SeEbe2iH0LZBnP0efo7tahPK+6xbE9UT9DYgsSflGBmv4it5DehfiV?= =?us-ascii?Q?+3zaP4DStEELm4NyIW5f2/leRznFRgLH2KS0EIJ6eUu31NESM/+TXUvzXIKv?= =?us-ascii?Q?6PtUkI8wKhrA8/zwWy4u8zrvKJsxyO+Vv5haHzMv1Pl97vWeX/eNEuK9brSg?= =?us-ascii?Q?HCnsbqvQGc2uMCM8z2ag/vCXL2c/gjPvvfWpUdHKyfPMDTABkOOiXwqWaGd2?= =?us-ascii?Q?IAidT6q79AoXnwJbDkC6CIhzSx45MtSyMip1+L5N5Uo8+2WdAcGZuhml+yVD?= =?us-ascii?Q?BsB95/fGyrBuKxMGNbARisgfeSFVycmTOjSRrF6jPeS88UbdfPFZ1dt+Cw07?= =?us-ascii?Q?Xctao4VP2hhPEHtxc3HMC4xt1mSNG069apCIq3SuTTeI25sK16ImsvxLiVe6?= =?us-ascii?Q?2LepAG3RU91G34hG6oiJztlsAfwv/Jfa61qFg95VYZbemxBFX+H+m6amCusp?= =?us-ascii?Q?sE7muCGAPnDXzIYkqWMN1zjiMXKK8VlMDtph7XRrF3m3YJ1vsM75v4MzJfAV?= =?us-ascii?Q?ehKOFvUkviEHFuu+4PVTEutHv5osC3H8l7zB/emEDT0ylnnxcpYOYifdvVhD?= =?us-ascii?Q?7LtUHAHYNWzHHqTTBKGtbaCu79cTqRxu0fqxArA717NZ74w7VxRr3XDI4T9o?= =?us-ascii?Q?p82InnxmVuqRJU0zXDCgGpczVEQYHF3F6F8fCNgffi+0jI81Pz4b2gFyLNRP?= =?us-ascii?Q?HiF5yY4zlDSa954YCmpEAFxjnV/s6XO3e1MNGlJ25J5MwFlZkbeda31Cw4JK?= =?us-ascii?Q?d952xQlS0t1+RIo48yff88XtbBsvSuRnHlV0HSptxdVLc+ezsTCdA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3468; 6:KnpJbX2YNQYALtqXd7rXCceLxXRZz+JjRfjF9xbO08wXpr8pKvvfjHTlcJJ+SdjihVqFKEnAgnynZIIhHU4CvXWGOwpxlKHpn2aOAfbXQkY/IVhF3oWfjwggdz4RJfGfzWUcnHUml1IOIPQz14DJa0otrd/PJlneQ7BwN4KzmZgbPamcFdoAegUQ3ZfU3mxcwZEHFarRDtd52LN1rX8d7NyvhgSbJxY9JlyExpI7sSj32thu0oIHMzF6SP/fS/38hRJGd6AG5itsteiMSK8gF7WCfKWAlIXx+vY770xfXJ71EixyCaZDwdu+pVHgr56Ma1+ZgKsgZEOGwLATeKdZfnFHiKukR5hgqqZtVRMUGzM=; 5:E2KxIp1omqq18gMXmrhKtKyXbOqbnuwM/eKyn4SFLltmWKidYt8XmgWOruEd2DHXzRKFojBLxsGYoQ7QNn8+hgxPiPZnbvJMcDJh08l/kMfvB7GQrmLM/V6dZzSL9mL0/SsWVHlLzNDMrvDSsvcoFwECj6tCBUxO0aXWN1uZLYo=; 24:q3UhDx9rg1iFPEzV/FVWRhLHe84gJxp/KJaFNRfXMAIfDF0Yux38KK1AWAEu9ifAABlnrNFTMA6NTFu8XDKf1op+5GjQk6Dzk2PNKZWaiw4=; 7:dO+yIozY63cECeOuwnBD8KHAXAXicnefddkWtiZyoK2K+1oOnoRPnyRTpGT+hfWADuLe8MWt5VlIokUDBUsmvP8ya/gDrdEbpbXq3GJVI/lBPl4DNjO00zZI2S3Iw/9XVVsdZpozEy7ynZv5aSKOL7Bv3CTs/sTFDsiAAKsJPlMkGWzyooWOtDCQYAKl9T5CDKKdSXuB41pVYeLRdC2kN0/OQHov5vEZTdzDj7CeKvMQ0oPrLahpUCkOUbbn6jVD SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2017 20:38:16.2671 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3f7ade8-6763-4f17-7eb7-08d53db27398 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 01/13] examples/eventdev: add Rx adapter support 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:21 -0000 Use event Rx adapter for packets Rx instead of explicit producer logic. Use service run iter function for granular control instead of using dedicated service lcore. Signed-off-by: Pavan Nikhilesh --- examples/eventdev_pipeline_sw_pmd/main.c | 149 +++++++++++++++++-------------- 1 file changed, 82 insertions(+), 67 deletions(-) diff --git a/examples/eventdev_pipeline_sw_pmd/main.c b/examples/eventdev_pipeline_sw_pmd/main.c index 5f431d87d..bb87c9544 100644 --- a/examples/eventdev_pipeline_sw_pmd/main.c +++ b/examples/eventdev_pipeline_sw_pmd/main.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #define MAX_NUM_STAGES 8 @@ -78,6 +79,7 @@ struct fastpath_data { uint32_t tx_lock; uint32_t sched_lock; uint32_t evdev_service_id; + uint32_t rxadptr_service_id; bool rx_single; bool tx_single; bool sched_single; @@ -105,6 +107,7 @@ struct config_data { unsigned int worker_cq_depth; int16_t next_qid[MAX_NUM_STAGES+2]; int16_t qid[MAX_NUM_STAGES]; + uint8_t rx_adapter_id; }; static struct config_data cdata = { @@ -193,53 +196,12 @@ consumer(void) return 0; } -static int -producer(void) -{ - static uint8_t eth_port; - struct rte_mbuf *mbufs[BATCH_SIZE+2]; - struct rte_event ev[BATCH_SIZE+2]; - uint32_t i, num_ports = prod_data.num_nic_ports; - int32_t qid = prod_data.qid; - uint8_t dev_id = prod_data.dev_id; - uint8_t port_id = prod_data.port_id; - uint32_t prio_idx = 0; - - const uint16_t nb_rx = rte_eth_rx_burst(eth_port, 0, mbufs, BATCH_SIZE); - if (++eth_port == num_ports) - eth_port = 0; - if (nb_rx == 0) { - rte_pause(); - return 0; - } - - for (i = 0; i < nb_rx; i++) { - ev[i].flow_id = mbufs[i]->hash.rss; - ev[i].op = RTE_EVENT_OP_NEW; - ev[i].sched_type = cdata.queue_type; - ev[i].queue_id = qid; - ev[i].event_type = RTE_EVENT_TYPE_ETHDEV; - ev[i].sub_event_type = 0; - ev[i].priority = RTE_EVENT_DEV_PRIORITY_NORMAL; - ev[i].mbuf = mbufs[i]; - RTE_SET_USED(prio_idx); - } - - const int nb_tx = rte_event_enqueue_burst(dev_id, port_id, ev, nb_rx); - if (nb_tx != nb_rx) { - for (i = nb_tx; i < nb_rx; i++) - rte_pktmbuf_free(mbufs[i]); - } - - return 0; -} - static inline void schedule_devices(unsigned int lcore_id) { if (fdata->rx_core[lcore_id] && (fdata->rx_single || rte_atomic32_cmpset(&(fdata->rx_lock), 0, 1))) { - producer(); + rte_service_run_iter_on_app_lcore(fdata->rxadptr_service_id, 1); rte_atomic32_clear((rte_atomic32_t *)&(fdata->rx_lock)); } @@ -553,6 +515,79 @@ parse_app_args(int argc, char **argv) } } +static inline void +init_rx_adapter(uint16_t nb_ports) +{ + int i; + int ret; + uint8_t evdev_id = 0; + uint8_t port_needed = 0; + struct rte_event_dev_info dev_info; + + ret = rte_event_dev_info_get(evdev_id, &dev_info); + + struct rte_event_port_conf rx_p_conf = { + .dequeue_depth = 8, + .enqueue_depth = 8, + .new_event_threshold = 1200, + }; + + if (rx_p_conf.dequeue_depth > dev_info.max_event_port_dequeue_depth) + rx_p_conf.dequeue_depth = dev_info.max_event_port_dequeue_depth; + if (rx_p_conf.enqueue_depth > dev_info.max_event_port_enqueue_depth) + rx_p_conf.enqueue_depth = dev_info.max_event_port_enqueue_depth; + + ret = rte_event_eth_rx_adapter_create(cdata.rx_adapter_id, evdev_id, + &rx_p_conf); + if (ret) + rte_exit(EXIT_FAILURE, "failed to create rx adapter[%d]", + cdata.rx_adapter_id); + + struct rte_event_eth_rx_adapter_queue_conf queue_conf = { + .ev.sched_type = cdata.queue_type, + .ev.queue_id = cdata.qid[0], + }; + + for (i = 0; i < nb_ports; i++) { + uint32_t cap; + + ret = rte_event_eth_rx_adapter_caps_get(evdev_id, i, &cap); + if (ret) + rte_exit(EXIT_FAILURE, + "failed to get event rx adapter " + "capabilities"); + /* Producer needs port. */ + port_needed |= !(cap & + RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT); + + ret = rte_event_eth_rx_adapter_queue_add(cdata.rx_adapter_id, i, + -1, &queue_conf); + if (ret) + rte_exit(EXIT_FAILURE, + "Failed to add queues to Rx adapter"); + } + + if (port_needed) + prod_data.port_id = cons_data.port_id + 1; + prod_data.dev_id = evdev_id; + prod_data.qid = cdata.qid[0]; + + ret = rte_event_eth_rx_adapter_service_id_get(cdata.rx_adapter_id, + &fdata->rxadptr_service_id); + if (ret != -ESRCH && ret != 0) { + rte_exit(EXIT_FAILURE, + "Error getting the service ID for Rx adapter\n"); + } + rte_service_runstate_set(fdata->rxadptr_service_id, 1); + rte_service_set_runstate_mapped_check(fdata->rxadptr_service_id, 0); + + ret = rte_event_eth_rx_adapter_start(cdata.rx_adapter_id); + if (ret) + rte_exit(EXIT_FAILURE, "Rx adapter[%d] start failed", + cdata.rx_adapter_id); + +} + /* * Initializes a given port using global settings and with the RX buffers * coming from the mbuf_pool passed as a parameter. @@ -663,15 +698,14 @@ struct port_link { }; static int -setup_eventdev(struct prod_data *prod_data, - struct cons_data *cons_data, +setup_eventdev(struct cons_data *cons_data, struct worker_data *worker_data) { const uint8_t dev_id = 0; /* +1 stages is for a SINGLE_LINK TX stage */ const uint8_t nb_queues = cdata.num_stages + 1; - /* + 2 is one port for producer and one for consumer */ - const uint8_t nb_ports = cdata.num_workers + 2; + /* + 1 for consumer */ + const uint8_t nb_ports = cdata.num_workers + 1; struct rte_event_dev_config config = { .nb_event_queues = nb_queues, .nb_event_ports = nb_ports, @@ -818,26 +852,6 @@ setup_eventdev(struct prod_data *prod_data, __LINE__, i); return -1; } - /* port for producer, no links */ - struct rte_event_port_conf rx_p_conf = { - .dequeue_depth = 8, - .enqueue_depth = 8, - .new_event_threshold = 1200, - }; - - if (rx_p_conf.dequeue_depth > config.nb_event_port_dequeue_depth) - rx_p_conf.dequeue_depth = config.nb_event_port_dequeue_depth; - if (rx_p_conf.enqueue_depth > config.nb_event_port_enqueue_depth) - rx_p_conf.enqueue_depth = config.nb_event_port_enqueue_depth; - - if (rte_event_port_setup(dev_id, i + 1, &rx_p_conf) < 0) { - printf("Error setting up port %d\n", i); - return -1; - } - - *prod_data = (struct prod_data){.dev_id = dev_id, - .port_id = i + 1, - .qid = cdata.qid[0] }; *cons_data = (struct cons_data){.dev_id = dev_id, .port_id = i }; @@ -940,12 +954,13 @@ main(int argc, char **argv) if (worker_data == NULL) rte_panic("rte_calloc failed\n"); - int dev_id = setup_eventdev(&prod_data, &cons_data, worker_data); + int dev_id = setup_eventdev(&cons_data, worker_data); if (dev_id < 0) rte_exit(EXIT_FAILURE, "Error setting up eventdev\n"); prod_data.num_nic_ports = num_ports; init_ports(num_ports); + init_rx_adapter(num_ports); int worker_idx = 0; RTE_LCORE_FOREACH_SLAVE(lcore_id) { -- 2.14.1