From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 298FDA04B5; Wed, 4 Dec 2019 15:45:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5D4151BF73; Wed, 4 Dec 2019 15:44:27 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id BBB4D1BE83 for ; Wed, 4 Dec 2019 15:44:25 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xB4Ef325014399; Wed, 4 Dec 2019 06:44:25 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=4k/4Lbd9MoyRU6Uzt6/aqy/Ew1+cwwBk9ghQl/lgZd4=; b=mNAEEfVuJ5mbpwP5pGxevjo9SxKGkIWalhZPNxu2IpGKGNrQPvZWq00NzEJ+4ZC05mAe +lSh+rbw2v4ZWCxxvgDoyjGPaUVfoF5+yJAI4QD7TVoPlGOmqczn+dnVE46iaCocDhgO 1zFp9NUZjWVZ/JYWTtEyd9jw8GLaWTZATdxnLfN0wj4wjrCxSYGFNFZlkhtwVeSywfKl DlT3h2p6s+bHYRvPn46Ts3kEORNaoXJZzGmEO4bvPFKpkC3eFONii18ZsNelwpCf5lO2 /f1bIQi/rh2FwWgJsaBus8Fo+69RgaVr/HvAEIOmYKzsFOWtzflt1uZjqLUcJWMQHbAQ Mg== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 2wnvgvmev3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 04 Dec 2019 06:44:24 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 4 Dec 2019 06:44:23 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 4 Dec 2019 06:44:23 -0800 Received: from localhost.localdomain (unknown [10.36.16.86]) by maili.marvell.com (Postfix) with ESMTP id 51F6B3F703F; Wed, 4 Dec 2019 06:44:19 -0800 (PST) From: To: , Marko Kovacevic , Ori Kam , Bruce Richardson , "Radu Nicolau" , Akhil Goyal , "Tomasz Kantecki" , Sunil Kumar Kori , Pavan Nikhilesh CC: Date: Wed, 4 Dec 2019 20:13:40 +0530 Message-ID: <20191204144345.5736-8-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191204144345.5736-1-pbhagavatula@marvell.com> References: <20191204144345.5736-1-pbhagavatula@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-12-04_03:2019-12-04,2019-12-04 signatures=0 Subject: [dpdk-dev] [PATCH v2 07/11] examples/l3fwd: add service core setup based on caps 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Pavan Nikhilesh Add service core setup when eventdev and Rx/Tx adapter don't have internal port capability. Signed-off-by: Pavan Nikhilesh --- examples/l3fwd/l3fwd_event.c | 6 +++ examples/l3fwd/main.c | 93 ++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) diff --git a/examples/l3fwd/l3fwd_event.c b/examples/l3fwd/l3fwd_event.c index 3a43f30a3..0e796f003 100644 --- a/examples/l3fwd/l3fwd_event.c +++ b/examples/l3fwd/l3fwd_event.c @@ -236,6 +236,7 @@ l3fwd_event_resource_setup(struct rte_eth_conf *port_conf) { struct l3fwd_event_resources *evt_rsrc = l3fwd_get_eventdev_rsrc(); uint32_t event_queue_cfg; + int ret; /* Parse eventdev command line options */ l3fwd_parse_eventdev_args(evt_rsrc->args, evt_rsrc->nb_args); @@ -262,4 +263,9 @@ l3fwd_event_resource_setup(struct rte_eth_conf *port_conf) /* Rx/Tx adapters configuration */ evt_rsrc->ops.adapter_setup(); + + /* Start event device */ + ret = rte_event_dev_start(evt_rsrc->event_d_id); + if (ret < 0) + rte_exit(EXIT_FAILURE, "Error in starting eventdev"); } diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index 20df12748..69d212bc2 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -826,6 +826,93 @@ prepare_ptype_parser(uint16_t portid, uint16_t queueid) return 0; } +static inline int +l3fwd_service_enable(uint32_t service_id) +{ + uint8_t min_service_count = UINT8_MAX; + uint32_t slcore_array[RTE_MAX_LCORE]; + unsigned int slcore = 0; + uint8_t service_count; + int32_t slcore_count; + + if (!rte_service_lcore_count()) + return -ENOENT; + + slcore_count = rte_service_lcore_list(slcore_array, RTE_MAX_LCORE); + if (slcore_count < 0) + return -ENOENT; + /* Get the core which has least number of services running. */ + while (slcore_count--) { + /* Reset default mapping */ + rte_service_map_lcore_set(service_id, + slcore_array[slcore_count], 0); + service_count = rte_service_lcore_count_services( + slcore_array[slcore_count]); + if (service_count < min_service_count) { + slcore = slcore_array[slcore_count]; + min_service_count = service_count; + } + } + if (rte_service_map_lcore_set(service_id, slcore, 1)) + return -ENOENT; + rte_service_lcore_start(slcore); + + return 0; +} + +static void +l3fwd_event_service_setup(void) +{ + struct l3fwd_event_resources *evt_rsrc = l3fwd_get_eventdev_rsrc(); + struct rte_event_dev_info evdev_info; + uint32_t service_id, caps; + int ret, i; + + rte_event_dev_info_get(evt_rsrc->event_d_id, &evdev_info); + if (evdev_info.event_dev_cap & RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED) { + ret = rte_event_dev_service_id_get(evt_rsrc->event_d_id, + &service_id); + if (ret != -ESRCH && ret != 0) + rte_exit(EXIT_FAILURE, + "Error in starting eventdev service\n"); + l3fwd_service_enable(service_id); + } + + for (i = 0; i < evt_rsrc->rx_adptr.nb_rx_adptr; i++) { + ret = rte_event_eth_rx_adapter_caps_get(evt_rsrc->event_d_id, + evt_rsrc->rx_adptr.rx_adptr[i], &caps); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Failed to get Rx adapter[%d] caps\n", + evt_rsrc->rx_adptr.rx_adptr[i]); + ret = rte_event_eth_rx_adapter_service_id_get( + evt_rsrc->event_d_id, + &service_id); + if (ret != -ESRCH && ret != 0) + rte_exit(EXIT_FAILURE, + "Error in starting Rx adapter[%d] service\n", + evt_rsrc->rx_adptr.rx_adptr[i]); + l3fwd_service_enable(service_id); + } + + for (i = 0; i < evt_rsrc->tx_adptr.nb_tx_adptr; i++) { + ret = rte_event_eth_tx_adapter_caps_get(evt_rsrc->event_d_id, + evt_rsrc->tx_adptr.tx_adptr[i], &caps); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Failed to get Rx adapter[%d] caps\n", + evt_rsrc->tx_adptr.tx_adptr[i]); + ret = rte_event_eth_tx_adapter_service_id_get( + evt_rsrc->event_d_id, + &service_id); + if (ret != -ESRCH && ret != 0) + rte_exit(EXIT_FAILURE, + "Error in starting Rx adapter[%d] service\n", + evt_rsrc->tx_adptr.tx_adptr[i]); + l3fwd_service_enable(service_id); + } +} + int main(int argc, char **argv) { @@ -869,6 +956,8 @@ main(int argc, char **argv) evt_rsrc->port_mask = enabled_port_mask; /* Configure eventdev parameters if user has requested */ l3fwd_event_resource_setup(&port_conf); + if (evt_rsrc->enabled) + goto skip_port_config; if (check_lcore_params() < 0) rte_exit(EXIT_FAILURE, "check_lcore_params failed\n"); @@ -1054,6 +1143,7 @@ main(int argc, char **argv) } } +skip_port_config: printf("\n"); /* start ports */ @@ -1083,6 +1173,9 @@ main(int argc, char **argv) } } + if (evt_rsrc->enabled) + l3fwd_event_service_setup(); + printf("\n"); for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { -- 2.17.1