From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0065.outbound.protection.outlook.com [104.47.42.65]) by dpdk.org (Postfix) with ESMTP id 98AC51D0A0 for ; Fri, 8 Jun 2018 19:26:08 +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:X-MS-Exchange-SenderADCheck; bh=yWQOru0m6c0y0Dr2Uk6MiRSya4iJuwmYYNVdP26taHc=; b=HSSbuOVbDmuYOJPKK/wBKukio50elqXnhazu2HbUqbv2lCUwghEu8BoSvveEU0AISe78qt3BqP3hG5I6n+DG2idYsViDqD48/eDAtQeguTr+Y0iDn6AIdwsRrBS0N1WFusOoIXOB0RGinOkBWHo/sRExk8LUxQXsfN/zea/hn/M= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Anoob.Joseph@cavium.com; Received: from ajoseph83.caveonetworks.com.caveonetworks.com (115.113.156.2) by DM6PR07MB4906.namprd07.prod.outlook.com (2603:10b6:5:a3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.841.17; Fri, 8 Jun 2018 17:26:03 +0000 From: Anoob Joseph To: Bruce Richardson , Jerin Jacob , Pablo de Lara Cc: Anoob Joseph , Hemant Agrawal , Narayana Prasad , Nikhil Rao , Pavan Nikhilesh , Sunil Kumar Kori , dev@dpdk.org Date: Fri, 8 Jun 2018 22:54:18 +0530 Message-Id: <1528478659-15859-20-git-send-email-anoob.joseph@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528478659-15859-1-git-send-email-anoob.joseph@caviumnetworks.com> References: <1528478659-15859-1-git-send-email-anoob.joseph@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: BM1PR0101CA0050.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::12) To DM6PR07MB4906.namprd07.prod.outlook.com (2603:10b6:5:a3::11) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DM6PR07MB4906; X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4906; 3:POFPSewyZqKCE1j40+bMv7+QN9rLx+MN+uK2/CsQ2xo1FMcqRf/lV9TBPUQmq0EYh9aNUaraQ4/eGPuTVENPmaGnxTXgL4JCfXVsuhGMaGciVjcNAV+hTE6xYegKv6ZmI00ueUw0QyoIX+qtsn6VJv3Tiq+0C0uLbyACWG0Ck68H4Rf/IZKevrE0OISg49adVhqtMhyoDcAKk54I/vr63NvPSDtihZVYYKiUnqtcFhCU2RBtGhax+usBxVWPVFQ5; 25:SQURKKLPK4jJ4pr3F4LsXF6xbpIrs410T8GS9x4smvTm02fqegjFsAOSmNg3f1PD8nnZmqg8/dk+Q1gsbDfNB3Gz+UdToky+mEVSbAKK8ntSrbtfJnLBplf8FksfJEpFZgJd+odwAVxSz4XhQIVQJoypiAWubEOJyHujms+bnY44Ntfi8LuYvhESVVf7IsbVQJjmSDj3R3D+gdKAKrqhYx3UJP7S08EvusR7rLQICLoDMq5kxXAtmVk4fUJxMPx9D95qjGGFbPBPet9WNThAfR0f/3v5ITFkQt40cJEo3mM/q8xx4nL+ges4/Z26wYCHgTSy3UrG8BrLbgiTPtivdQ==; 31:f2T0rN9B1lqWsgcxQqkycvpFjhSEDug1n3z7ywCmJs5C0JFaEg4tSbWVRjEioW0YO+qsKw1hMcCelS+HHXUfsjE/P5zqDG+QX2mXFgD454/KJHerdhM0gOV4dz7VLcjZ8md/787s5DabllzmQDT14bRZSXRWG4LWnuRMdnR2LEoDUQQ4+knX585cAY6K18OGHw81NOo6jSk7GdkKYTOxPYj9FZukS8hPcr671MgpQZU= X-MS-TrafficTypeDiagnostic: DM6PR07MB4906: X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4906; 20:AK0n50CANMwaVTMX7NdOLJWJMLQBagXEAP3cMB0MW0IyTUiEnO9dJ+boE5fxlSGiNdB3aDWTX2k0TVNZIwHHQeR/loIt3BwWMaaZQpZhHaFMaUeW73/T/tnh7gFrX3CquL/Zo8Z3TAkv00OqIA/fNLaEzdg1o7Shj7XNVIjcSUO73Uu6l+YCc1f9oybgaDAl2en47j0FeyclDCBN8tHTwnhZ6hpEQwGmojanCKOrm8rOXNs3XbfaIdSYXccFtXhYjtgBadfRnINemw4Z8bRlEFRED0ty7gc1XkdK80F0Zh1XM2GUmGKb5/E8BJ6ZkvbQqmFuIynd94hmvrlJ6q+Tym6WUybkzDXF3uq7wQqk9DJYoQIOKwCdVrh2ncDgABHdbLofEp+/u+EihJHp+qEK489Hoh0bhCxHwqD7mF6sdMXMKtAAhShgwR0sAMPq1YhwHAQha0JtbqQ9auijk+FolW78EVi2G7m2yLxsGHpiGklmQ2VQjDmv3sRHGyoNV0tlaiF31FPFh1cSmfq1T5oCk2qkI74s1RE2aKrZk2T4pg/l4Hvg5T244CHRebKPlnYuEo5sZryBMmhdwy3eo2O6Y7iK5dxhuCJGdzT60wh1jJw=; 4:isQeOjZ5+iefD/rqWElEZluf1J29z6VbaxeKOhHlZgU6tHgfdc+p8R59/SkrHhsSn1gNdO/rZ8hiuiZ9gRTpGEfiJ/Kgj+/q75CIT8YHpIvbCnJDtvrMiL4sb/JEYuteFieds5ul+seCVLnMe44692MFtFY6MG9OlwB51UySNr03NCj+uFnCUBmeVT7Q40K3JoMu7MB/scwiSqs/xMPuwgebbcDQY4X0P56NnYU8nGX9qkPJet9mFY0PtbAhXCgPPb72CiupCQUNboEe6/QPfw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(3231254)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:DM6PR07MB4906; BCL:0; PCL:0; RULEID:; SRVR:DM6PR07MB4906; X-Forefront-PRVS: 06973FFAD3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(366004)(376002)(396003)(39380400002)(189003)(199004)(186003)(16526019)(5660300001)(26005)(42882007)(55236004)(66066001)(47776003)(68736007)(6666003)(305945005)(2906002)(8676002)(7736002)(8936002)(36756003)(52116002)(2616005)(956004)(476003)(446003)(50226002)(81166006)(11346002)(44832011)(6506007)(386003)(486006)(59450400001)(76176011)(51416003)(48376002)(50466002)(97736004)(316002)(6512007)(25786009)(53936002)(6486002)(81156014)(4326008)(3846002)(6116002)(16586007)(54906003)(110136005)(105586002)(106356001)(72206003)(478600001)(8656006); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR07MB4906; H:ajoseph83.caveonetworks.com.caveonetworks.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR07MB4906; 23:X3gbHrNGq6pl1JKQuR9Scw1Lb7v54wNi+HXL6tXR1?= =?us-ascii?Q?BLk70QZpbtVBjxVCVRrqPBTdOB9oRtALAIAFLVEr1j3TubyUJvlUbMTsb8ay?= =?us-ascii?Q?bbIK/kzfUWn6kkjcHknIAxZvcShODMcRXTcSB7VALQh17Wsses1F2dtMMFTa?= =?us-ascii?Q?9qIuLtXr2Aj92zUWSFQr7pQMq3bSaPap/VDQWS40AlHlljm9sNSuqL6lSwia?= =?us-ascii?Q?vNQzjB1+aSW3v4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suToLErSCuLxdhdKW8tEBHW6iF3+Fzno0Ei8zzOV7c4KmvF5sbjDeD+PlQKI6TyRFhrPjxBHng6PB52DZ8SDrHiI4laI8DSrow=; 24:dzLaxBZRL9zjm1/4GHhPnA+HayFB++rQVlFbgJH4KV+mGIw7A8jKUsQxG5MJrU2Q88jRSRfO510w8ghBhX3i+rUt11lnPcBc4tiW098fGgE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4906; 7:qYYFjaG0rGHXapSbZ4aSRiyR2LhDqpiF5HMErlMY3VZ9Nc76c/0NXPloBB2yYnsbdnznfzWTPFq/AccU5h85XiDp+eSzY0cv/Cl5Cad17Vsgjpzs6fzwGQki9FLzZcTzKxeBYwOBaNzMSrQjFt32GmoCUE+xS5t3zvx2To48MJOFoomFSwqs7JkwCAQT+ZCkvP3ZmMyqM2ovB2BG+7qskZX+wp+yursBbGwp0owbw9AMJzZM2g6ODRCjkvDzBnu/ X-MS-Office365-Filtering-Correlation-Id: 5b498528-d3a9-4dee-c0fb-08d5cd64eb18 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2018 17:26:03.9515 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5b498528-d3a9-4dee-c0fb-08d5cd64eb18 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR07MB4906 Subject: [dpdk-dev] [PATCH 19/20] eventdev: add routine to launch eventmode workers 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: Fri, 08 Jun 2018 17:26:09 -0000 With eventmode, workers could be drafted differently according to the capabilities of the underlying event device. The added function would receive an array of such workers and probes the eventmode properties to choose the worker. Signed-off-by: Anoob Joseph --- lib/librte_eventdev/rte_eventmode_helper.c | 299 +++++++++++++++++++++ lib/librte_eventdev/rte_eventmode_helper.h | 57 ++++ .../rte_eventmode_helper_internal.h | 23 ++ 3 files changed, 379 insertions(+) diff --git a/lib/librte_eventdev/rte_eventmode_helper.c b/lib/librte_eventdev/rte_eventmode_helper.c index 7f2d269..25cb4a9 100644 --- a/lib/librte_eventdev/rte_eventmode_helper.c +++ b/lib/librte_eventdev/rte_eventmode_helper.c @@ -2,6 +2,7 @@ * Copyright(c) 2018 Cavium, Inc */ #include +#include #include #include @@ -13,6 +14,9 @@ #define CMD_LINE_OPT_TRANSFER_MODE "transfer-mode" +static volatile bool rx_core_running; +static volatile bool eventmode_worker_stop; + static const char short_options[] = "" ; @@ -110,6 +114,16 @@ internal_get_next_active_core(struct eventmode_conf *em_conf, return next_core; } +static inline bool +internal_dev_has_burst_mode(uint8_t dev_id) +{ + struct rte_event_dev_info dev_info; + + rte_event_dev_info_get(dev_id, &dev_info); + return (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_BURST_MODE) ? + true : false; +} + /* Global functions */ void @@ -992,3 +1006,288 @@ rte_eventmode_helper_get_tx_queue(struct rte_eventmode_helper_conf *mode_conf, return eventdev_config->nb_eventqueue; } +/* Helper functions for launching workers */ + +static int32_t +rte_eventmode_helper_start_worker_rx_core(struct eventmode_conf *em_conf, + uint32_t lcore_id) +{ + uint32_t service_id[EVENT_MODE_MAX_ADAPTERS_PER_RX_CORE]; + struct rx_adapter_conf *adapter; + int service_count = 0; + int adapter_id; + int32_t ret; + int i; + + RTE_EM_HLPR_LOG_INFO( + "Entering rx_core processing on lcore %u", lcore_id); + + /* + * Need to parse adapter conf to see which all adapters need to be + * handled this core. + */ + for (i = 0; i < em_conf->nb_rx_adapter; i++) { + /* Check if we have exceeded the max allowed */ + if (service_count > EVENT_MODE_MAX_ADAPTERS_PER_RX_CORE) { + RTE_EM_HLPR_LOG_ERR( + "Exceeded the max allowed adapters per rx core"); + break; + } + + adapter = &(em_conf->adapter[i]); + if (adapter->rx_core_id != lcore_id) + continue; + + /* Adapter need to be handled by this core */ + adapter_id = adapter->adapter_id; + + /* Get the service ID for the adapters */ + ret = rte_event_eth_rx_adapter_service_id_get(adapter_id, + &(service_id[service_count])); + + if (ret != -ESRCH && ret != 0) { + RTE_EM_HLPR_LOG_ERR( + "Error getting service ID used by adapter"); + return ret; + } + + /* Update service count */ + service_count++; + } + + rx_core_running = true; + + while (rx_core_running) { + for (i = 0; i < service_count; i++) { + /* Initiate rx_adapter service */ + rte_service_run_iter_on_app_lcore(service_id[i], 0); + } + } + + return 0; +} + +static int32_t +rte_eventmode_helper_stop_worker_rx_core(void) +{ + if (rx_core_running) { + RTE_EM_HLPR_LOG_INFO("Stopping rx cores\n"); + rx_core_running = false; + } + return 0; +} + +static struct rte_eventmode_helper_app_worker_params * +rte_eventmode_helper_find_worker(uint32_t lcore_id, + struct eventmode_conf *em_conf, + struct rte_eventmode_helper_app_worker_params *app_wrkrs, + uint8_t nb_wrkr_param) +{ + struct rte_eventmode_helper_event_link_info *link = NULL; + uint8_t eventdev_id; + struct eventdev_params *eventdev_config; + int i; + struct rte_eventmode_helper_app_worker_params curr_conf = {0}; + struct rte_eventmode_helper_app_worker_params *tmp_wrkr; + + /* + * Event device to be used will be derived from the first lcore-event + * link. + * + * Assumption: All lcore-event link tied to a core would be using the + * same event device. in other words, one core would be polling on + * queues of a single event device only. + */ + + /* Get a link for this lcore */ + for (i = 0; i < em_conf->nb_link; i++) { + link = &(em_conf->link[i]); + if (link->lcore_id == lcore_id) + break; + } + + if (link == NULL) { + RTE_EM_HLPR_LOG_ERR( + "No valid link found for lcore(%d)", lcore_id); + return NULL; + } + + /* Get event dev ID */ + eventdev_id = link->eventdev_id; + + /* Get the corresponding eventdev config */ + eventdev_config = internal_get_eventdev_params(em_conf, eventdev_id); + + /* Populate the curr_conf with the capabilities */ + + /* Check for burst mode */ + if (internal_dev_has_burst_mode(eventdev_id)) + curr_conf.cap.burst = RTE_EVENTMODE_HELPER_RX_TYPE_BURST; + else + curr_conf.cap.burst = RTE_EVENTMODE_HELPER_RX_TYPE_NON_BURST; + + curr_conf.cap.s1_sched_type = + rte_eventmode_helper_get_s1_sched_type(em_conf); + + curr_conf.cap.s2_sched_type = + rte_eventmode_helper_get_s2_sched_type(em_conf); + + /* TODO make this part of em_conf */ + curr_conf.nb_stage = 1; + + /* Now parse the passed list and see if we have matching capabilties */ + + /* Initialize the pointer used to traverse the list */ + tmp_wrkr = app_wrkrs; + + for (i = 0; i < nb_wrkr_param; i++, tmp_wrkr++) { + + /* Skip this if capabilities are not matching */ + if (tmp_wrkr->cap.u64 != curr_conf.cap.u64) + continue; + + /* Skip if the number of stages is not matching */ + if (tmp_wrkr->nb_stage != curr_conf.nb_stage) + continue; + + /* If the checks pass, we have a match */ + return tmp_wrkr; + } + + /* TODO required for ATQ */ + RTE_SET_USED(eventdev_config); + + return NULL; +} + +static int +rte_eventmode_helper_verify_match_worker( + struct rte_eventmode_helper_app_worker_params *match_wrkr) +{ + if (match_wrkr->nb_stage == 0) { + RTE_EM_HLPR_LOG_ERR("App stages cannot be 0"); + return 0; + } + + /* Verify the stages registered */ + switch (match_wrkr->nb_stage) { + case 2: + if (match_wrkr->s2_worker_thread == NULL) { + RTE_EM_HLPR_LOG_ERR( + "No worker registered for second stage"); + return 0; + } + /* Fall through */ + case 1: + if (match_wrkr->s1_worker_thread == NULL) { + RTE_EM_HLPR_LOG_ERR( + "No worker registered for first stage"); + return 0; + } + break; + default: + RTE_EM_HLPR_LOG_ERR("Only two stages are supported now"); + return 0; + } + + /* Success */ + return 1; +} + +void +rte_eventmode_helper_launch_worker(struct rte_eventmode_helper_conf *mode_conf, + struct rte_eventmode_helper_app_worker_params *app_wrkr, + uint8_t nb_wrkr_param) +{ + struct rte_eventmode_helper_app_worker_params *match_wrkr; + uint32_t lcore_id; + int i; + struct eventmode_conf *em_conf; + + if (mode_conf == NULL) { + RTE_EM_HLPR_LOG_ERR("Invalid conf"); + return; + } + + if (mode_conf->mode_params == NULL) { + RTE_EM_HLPR_LOG_ERR("Invalid mode params"); + return; + } + + /* Get eventmode conf */ + em_conf = (struct eventmode_conf *)(mode_conf->mode_params); + + /* Get core ID */ + lcore_id = rte_lcore_id(); + + /* TODO check capability for rx core */ + + /* Check if this is rx core */ + if (em_conf->rx_core_mask & (1 << lcore_id)) { + rte_eventmode_helper_start_worker_rx_core(em_conf, lcore_id); + return; + } + + if (app_wrkr == NULL || nb_wrkr_param == 0) { + RTE_EM_HLPR_LOG_ERR("Invalid args"); + return; + } + + /* + * This is a regular worker thread. The application would be + * registering multiple workers with various capabilities. The + * worker to be run will be selected by the capabilities of the + * event device configured. + */ + + /* Get the first matching worker for the event device */ + match_wrkr = rte_eventmode_helper_find_worker(lcore_id, + em_conf, + app_wrkr, + nb_wrkr_param); + + if (match_wrkr == NULL) { + RTE_EM_HLPR_LOG_ERR( + "No matching worker registered for lcore %d", lcore_id); + goto clean_and_exit; + } + + /* Verify sanity of the matched worker */ + if (rte_eventmode_helper_verify_match_worker(match_wrkr) != 1) { + RTE_EM_HLPR_LOG_ERR("Error in validating the matched worker"); + goto clean_and_exit; + } + + /* + * If single stage, then the worker thread will have the loop, + * thereby avoiding the dereferencing of the function pointer. + */ + if (match_wrkr->nb_stage == 1) { + match_wrkr->s1_worker_thread((void *)mode_conf); + goto clean_and_exit; + } + + /* TODO write worker stop API */ + eventmode_worker_stop = false; + + /* Run the worker threads */ + while (!eventmode_worker_stop) { + + /* Launch the stages registered */ + for (i = 1; i <= match_wrkr->nb_stage; i++) { + switch (i) { + case 1: + match_wrkr->s1_worker_thread((void *)em_conf); + break; + case 2: + match_wrkr->s2_worker_thread((void *)em_conf); + break; + } + } + } + +clean_and_exit: + + /* Flag rx_cores to stop, if started */ + rte_eventmode_helper_stop_worker_rx_core(); +} diff --git a/lib/librte_eventdev/rte_eventmode_helper.h b/lib/librte_eventdev/rte_eventmode_helper.h index be2fe8d..25b1180 100644 --- a/lib/librte_eventdev/rte_eventmode_helper.h +++ b/lib/librte_eventdev/rte_eventmode_helper.h @@ -12,6 +12,22 @@ enum rte_eventmode_helper_pkt_transfer_mode { RTE_EVENTMODE_HELPER_PKT_TRANSFER_MODE_EVENT, }; +/* Event mode packet rx types */ +enum rte_eventmode_helper_rx_types { + RTE_EVENTMODE_HELPER_RX_TYPE_INVALID = 0, + RTE_EVENTMODE_HELPER_RX_TYPE_NON_BURST, + RTE_EVENTMODE_HELPER_RX_TYPE_BURST, + RTE_EVENTMODE_HELPER_RX_TYPE_MAX = 16 +}; + +/* Event mode packet tx types */ +enum rte_eventmode_helper_tx_types { + RTE_EVETNMODE_HELPER_TX_TYPE_INVALID = 0, + RTE_EVENTMODE_HELPER_TX_TYPE_LOCKED, + RTE_EVENTMODE_HELPER_TX_TYPE_LOCKLESS, + RTE_EVENTMODE_HELPER_TX_TYPE_MAX = 16 +}; + struct rte_eventmode_helper_conf { enum rte_eventmode_helper_pkt_transfer_mode mode; /**< Packet transfer mode of the application */ @@ -36,6 +52,27 @@ struct rte_eventmode_helper_event_link_info { /**< Lcore to be polling on this port */ }; +/* Workers registered by the application */ +struct rte_eventmode_helper_app_worker_params { + union { + struct { + uint64_t burst : 4; + /**< Specify status of rx type burst */ + uint64_t s1_sched_type : 2; + /**< Stage 1 scheduling type for the thread */ + uint64_t s2_sched_type : 2; + /**< Stage 2 scheduling type for the thread */ + }; + uint64_t u64; + } cap; + /**< Capabilities of this worker */ + uint8_t nb_stage; + void (*s1_worker_thread)(void *); + /**< Stage 1 worker thread */ + void (*s2_worker_thread)(void *); + /**< Stage 2 worker thread */ +}; + /* Common helper functions for command line parsing */ /** @@ -152,5 +189,25 @@ uint8_t rte_eventmode_helper_get_tx_queue(struct rte_eventmode_helper_conf *mode_conf, uint8_t eventdev_id); +/** + * Launch eventmode worker + * + * The application can request the eventmode helper subsystem to launch the + * worker based on the capabilities of event device and the options selected + * while initializing the eventmode. + * + * @param mode_conf + * Configuration of the mode in which app is doing packet handling + * @param app_wrkr + * List of all the workers registered by application, along with it's + * capabilties + * @param nb_wrkr_param + * Number of workers passed by the application + * + */ +void +rte_eventmode_helper_launch_worker(struct rte_eventmode_helper_conf *mode_conf, + struct rte_eventmode_helper_app_worker_params *app_wrkr, + uint8_t nb_wrkr_param); #endif /* _RTE_EVENTMODE_HELPER_H_ */ diff --git a/lib/librte_eventdev/rte_eventmode_helper_internal.h b/lib/librte_eventdev/rte_eventmode_helper_internal.h index 3a4e52f..996c654 100644 --- a/lib/librte_eventdev/rte_eventmode_helper_internal.h +++ b/lib/librte_eventdev/rte_eventmode_helper_internal.h @@ -43,6 +43,9 @@ #define EVENT_MODE_MAX_LCORE_LINKS \ (EVENT_MODE_MAX_EVENT_DEVS * EVENT_MODE_MAX_EVENT_QUEUES_PER_DEV) +/* Max adapters that one rx core can handle */ +#define EVENT_MODE_MAX_ADAPTERS_PER_RX_CORE EVENT_MODE_MAX_RX_ADAPTERS + /* Event dev params */ struct eventdev_params { uint8_t eventdev_id; @@ -104,4 +107,24 @@ struct eventmode_conf { /**< 64 bit field to specify extended params */ }; +/* + * Get sched type of the first stage of app + * + */ +static inline uint8_t +rte_eventmode_helper_get_s1_sched_type(struct eventmode_conf *em_conf) +{ + return em_conf->ext_params.s1_sched_type; +} + +/* + * Get sched type of the first stage of app + * + */ +static inline uint8_t +rte_eventmode_helper_get_s2_sched_type(struct eventmode_conf *em_conf) +{ + return em_conf->ext_params.s2_sched_type; +} + #endif /* _RTE_EVENTMODE_HELPER_INTERNAL_H_ */ -- 2.7.4