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 BE038A2EFC for ; Mon, 14 Oct 2019 20:24:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 340CF1D17D; Mon, 14 Oct 2019 20:23:27 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 31B5D1D17A for ; Mon, 14 Oct 2019 20:23:24 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9EIM4Xt024841; Mon, 14 Oct 2019 11:23:23 -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=pVAiYv+beADzpmi4WHmPcAlkK43sLE6A9o5rYwkO9kQ=; b=CIlUKtvfTH76TfkPFJE2b6/XJX91Gvf84OzBZDjdNyiH82u9cKMxxZVoVhq6lwKTMii1 edUqc9FOnSrBdl+3hGxIWwEbF8gGT1w5Zo4V5/siSa2BMwPM6t3yj6Yq4k6TkcVEBp8k SWwdSfBpQLaIQRdldMs7PdQzCURTepkY+kVIAnR4w/slNEO9IpW3rJlVMIYcRx3qJ2/g sW7hypAV0Qe1E4H6EZRmfH8OG906XEHW5pIrN1RD2zmnrAiBf9qNzoscO15TzqiFk3Tf XFfpJYnIgScSc/FzgLk7LhPLqN3EV32c5ys6dRt0KCv8w4YYJArldktZwc1HHsXjuVst MQ== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2vkebnxsek-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 14 Oct 2019 11:23:23 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 14 Oct 2019 11:23:21 -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; Mon, 14 Oct 2019 11:23:21 -0700 Received: from BG-LT7430.marvell.com (pe-lt7585.marvell.com [10.28.17.46]) by maili.marvell.com (Postfix) with ESMTP id 4B00E3F7041; Mon, 14 Oct 2019 11:23:18 -0700 (PDT) From: To: , , , Marko Kovacevic , "Ori Kam" , Radu Nicolau , Akhil Goyal , Tomasz Kantecki , "Sunil Kumar Kori" , Pavan Nikhilesh CC: Date: Mon, 14 Oct 2019 23:52:44 +0530 Message-ID: <20191014182247.961-8-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191014182247.961-1-pbhagavatula@marvell.com> References: <20191002205754.11746-1-pbhagavatula@marvell.com> <20191014182247.961-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-14_09:2019-10-11,2019-10-14 signatures=0 Subject: [dpdk-dev] [PATCH v6 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 f60ab0c73..48a91dc70 100644 --- a/examples/l2fwd-event/main.c +++ b/examples/l2fwd-event/main.c @@ -397,6 +397,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