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 53EF1A2EDB for ; Wed, 2 Oct 2019 22:59:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 57D721BF94; Wed, 2 Oct 2019 22:58:29 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 10B4B1BF94 for ; Wed, 2 Oct 2019 22:58:27 +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 x92Kt52D028851; Wed, 2 Oct 2019 13:58:27 -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=KnQgAbA7Bs7qdk3GfcU/vSgT7xVtQC4tROkWsLdTO4A=; b=JU/wm7+x55gFBrHNDly2NIbTMpvKF5jKFbWXQkHTfNaWXGaVeuanr69kC7IqBD6g9Pin Rn/yzn42A+HH8y/bdmcrAFP9Ks3OjxxBopaD3zmwauvRf0hWh3h4xNxOvc5gtipunlmo IE7na69lPcAvAJzLTTjGplwMBM8ZfWjZ6so8kUlujVYj94hm2AIzXu1Uk1pksblnIa0j XnfiNhVFWhK5QFAS8z+l0asq41HXYT+9w2v9idgSW+2P0hV++6kqnPMo6VlatSB7eTYe pBZrM8eDDJgz8WbKpfUEhqleaa4UBAFtfb/dveu7AcDjiLLl1jQPgdkZxnDN9ncCCX/F GQ== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 2vd0y70m9g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 02 Oct 2019 13:58:27 -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; Wed, 2 Oct 2019 13:58:26 -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; Wed, 2 Oct 2019 13:58:26 -0700 Received: from BG-LT7430.marvell.com (unknown [10.28.17.68]) by maili.marvell.com (Postfix) with ESMTP id 2E70E3F703F; Wed, 2 Oct 2019 13:58:22 -0700 (PDT) From: To: , , , Marko Kovacevic , Ori Kam , Radu Nicolau , Tomasz Kantecki , Sunil Kumar Kori , "Pavan Nikhilesh" CC: Date: Thu, 3 Oct 2019 02:27:51 +0530 Message-ID: <20191002205754.11746-8-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191002205754.11746-1-pbhagavatula@marvell.com> References: <20190924094209.3827-1-pbhagavatula@marvell.com> <20191002205754.11746-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-02_08:2019-10-01,2019-10-02 signatures=0 Subject: [dpdk-dev] [PATCH v5 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 | 87 ++++++++++++++++++++++++++++++ examples/l2fwd-event/l2fwd_event.h | 1 + examples/l2fwd-event/main.c | 3 ++ 3 files changed, 91 insertions(+) diff --git a/examples/l2fwd-event/l2fwd_event.c b/examples/l2fwd-event/l2fwd_event.c index 293ecc129..adba40069 100644 --- a/examples/l2fwd-event/l2fwd_event.c +++ b/examples/l2fwd-event/l2fwd_event.c @@ -17,6 +17,93 @@ #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 *l2fwd_rsrc) +{ + struct l2fwd_event_resources *event_rsrc = l2fwd_rsrc->event_rsrc; + struct rte_event_dev_info evdev_info; + uint32_t service_id, caps; + int ret, i; + + rte_event_dev_info_get(event_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(event_rsrc->event_d_id, + &service_id); + if (ret != -ESRCH && ret != 0) + rte_exit(EXIT_FAILURE, + "Error in starting eventdev service\n"); + l2fwd_event_service_enable(service_id); + } + + for (i = 0; i < event_rsrc->rx_adptr.nb_rx_adptr; i++) { + ret = rte_event_eth_rx_adapter_caps_get(event_rsrc->event_d_id, + event_rsrc->rx_adptr.rx_adptr[i], &caps); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Failed to get Rx adapter[%d] caps\n", + event_rsrc->rx_adptr.rx_adptr[i]); + ret = rte_event_eth_rx_adapter_service_id_get( + event_rsrc->event_d_id, + &service_id); + if (ret != -ESRCH && ret != 0) + rte_exit(EXIT_FAILURE, + "Error in starting Rx adapter[%d] service\n", + event_rsrc->rx_adptr.rx_adptr[i]); + l2fwd_event_service_enable(service_id); + } + + for (i = 0; i < event_rsrc->tx_adptr.nb_tx_adptr; i++) { + ret = rte_event_eth_tx_adapter_caps_get(event_rsrc->event_d_id, + event_rsrc->tx_adptr.tx_adptr[i], &caps); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Failed to get Rx adapter[%d] caps\n", + event_rsrc->tx_adptr.tx_adptr[i]); + ret = rte_event_eth_tx_adapter_service_id_get( + event_rsrc->event_d_id, + &service_id); + if (ret != -ESRCH && ret != 0) + rte_exit(EXIT_FAILURE, + "Error in starting Rx adapter[%d] service\n", + event_rsrc->tx_adptr.tx_adptr[i]); + l2fwd_event_service_enable(service_id); + } +} + static void l2fwd_event_capability_setup(struct l2fwd_event_resources *event_rsrc) { diff --git a/examples/l2fwd-event/l2fwd_event.h b/examples/l2fwd-event/l2fwd_event.h index e0cfee8b8..e0c589f93 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 *l2fwd_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 *l2fwd_rsrc); #endif /* __L2FWD_EVENT_H__ */ diff --git a/examples/l2fwd-event/main.c b/examples/l2fwd-event/main.c index 01b1d531d..3c27bfb4f 100644 --- a/examples/l2fwd-event/main.c +++ b/examples/l2fwd-event/main.c @@ -398,6 +398,9 @@ main(int argc, char **argv) port_id); } + if (l2fwd_rsrc->event_mode) + l2fwd_event_service_setup(l2fwd_rsrc); + check_all_ports_link_status(l2fwd_rsrc, l2fwd_rsrc->enabled_port_mask); /* launch per-lcore init on every lcore */ -- 2.17.1