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 F1549A32A8 for ; Sat, 26 Oct 2019 13:12:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 59C2D1BFCD; Sat, 26 Oct 2019 13:11:47 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id EBAE61B9A9 for ; Sat, 26 Oct 2019 13:11:32 +0200 (CEST) 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 x9QB5bqG010488; Sat, 26 Oct 2019 04:11:32 -0700 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=2c4H7tmkT7xUqT7Dg93b3lRKJkTZChDDGpD3L7De5AU=; b=rX4DM+R7P2INjFTklKEO7DUttnbJ06a7V32nNww1uLbmJih711+PavhWhZSIhAVsZ3Fr Yruu5pc0mqgG8139NyFtUSpFTcJzBy0M24dV8lwDsaVf/xJHVg9r4r3Z3goIL0HZyEaJ HwKeM8Ukcf8OEEa7fJ+hNCAIxquq0MAKuEKRMXSRlFoHO90aMgay85slf3OmP9H6S8Zx jZUAEEV+IStdUOnZDW3fzEAyO8a3TQjgbzjtc1lbl++SIJHw7AempSp/tCjclta/HKSR 1critaZAEU5G73C/eRMPR9kLbD/3g46xSGGUdYR2h9vjHIw0M2z4/diTmCdQGlgmARl5 xw== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 2vvkgq06c4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 26 Oct 2019 04:11:32 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sat, 26 Oct 2019 04:11:30 -0700 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; Sat, 26 Oct 2019 04:11:30 -0700 Received: from BG-LT7430.marvell.com (unknown [10.28.17.85]) by maili.marvell.com (Postfix) with ESMTP id 2C2E03F7040; Sat, 26 Oct 2019 04:11:26 -0700 (PDT) From: To: , , , Marko Kovacevic , "Ori Kam" , Radu Nicolau , Akhil Goyal , Tomasz Kantecki , "Sunil Kumar Kori" , Pavan Nikhilesh CC: Date: Sat, 26 Oct 2019 16:40:51 +0530 Message-ID: <20191026111054.15491-8-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191026111054.15491-1-pbhagavatula@marvell.com> References: <20191014182247.961-1-pbhagavatula@marvell.com> <20191026111054.15491-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,1.0.8 definitions=2019-10-26_02:2019-10-25,2019-10-26 signatures=0 Subject: [dpdk-dev] [PATCH v7 07/10] examples/l2fwd-event: add service core setup 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 Setup service cores for eventdev and Rx/Tx adapter when they don't have internal port capability. Signed-off-by: Pavan Nikhilesh --- examples/l2fwd-event/l2fwd_event.c | 82 ++++++++++++++++++++++++++++++ examples/l2fwd-event/l2fwd_event.h | 1 + examples/l2fwd-event/main.c | 3 ++ 3 files changed, 86 insertions(+) diff --git a/examples/l2fwd-event/l2fwd_event.c b/examples/l2fwd-event/l2fwd_event.c index 33c702739..562d61292 100644 --- a/examples/l2fwd-event/l2fwd_event.c +++ b/examples/l2fwd-event/l2fwd_event.c @@ -17,6 +17,88 @@ #include "l2fwd_event.h" +static inline int +l2fwd_event_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; +} + +void +l2fwd_event_service_setup(struct l2fwd_resources *rsrc) +{ + struct l2fwd_event_resources *evt_rsrc = rsrc->evt_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_panic("Error in starting eventdev service\n"); + l2fwd_event_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_panic("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_panic("Error in starting Rx adapter[%d] service\n", + evt_rsrc->rx_adptr.rx_adptr[i]); + l2fwd_event_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_panic("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_panic("Error in starting Rx adapter[%d] service\n", + evt_rsrc->tx_adptr.tx_adptr[i]); + l2fwd_event_service_enable(service_id); + } +} + static void l2fwd_event_capability_setup(struct l2fwd_event_resources *evt_rsrc) { diff --git a/examples/l2fwd-event/l2fwd_event.h b/examples/l2fwd-event/l2fwd_event.h index 1d7090ddf..ebfbfe460 100644 --- a/examples/l2fwd-event/l2fwd_event.h +++ b/examples/l2fwd-event/l2fwd_event.h @@ -66,5 +66,6 @@ struct l2fwd_event_resources { void l2fwd_event_resource_setup(struct l2fwd_resources *rsrc); void l2fwd_event_set_generic_ops(struct event_setup_ops *ops); void l2fwd_event_set_internal_port_ops(struct event_setup_ops *ops); +void l2fwd_event_service_setup(struct l2fwd_resources *rsrc); #endif /* __L2FWD_EVENT_H__ */ diff --git a/examples/l2fwd-event/main.c b/examples/l2fwd-event/main.c index 2a1fe4e11..1ae18bb51 100644 --- a/examples/l2fwd-event/main.c +++ b/examples/l2fwd-event/main.c @@ -471,6 +471,9 @@ main(int argc, char **argv) port_id); } + if (rsrc->event_mode) + l2fwd_event_service_setup(rsrc); + check_all_ports_link_status(rsrc, rsrc->enabled_port_mask); /* launch per-lcore init on every lcore */ -- 2.17.1