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 81144A2EDB for ; Wed, 2 Oct 2019 22:58:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5F16F1BF71; Wed, 2 Oct 2019 22:58:10 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 4DFF61BF78 for ; Wed, 2 Oct 2019 22:58:08 +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 x92Kt5Zb028848; Wed, 2 Oct 2019 13:58:07 -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=Lmoc7O57fcG/qxyzvyUSwEAhSeTRrJyySef65ucD2HE=; b=nghaT5q1FjWjMN2BSIrp0yruK5G9uRraAtDOq/HqWRDcdIFJqu9VDpoAUIuELv7FKwoy Cx/ZDP0oeARj4DLDZWSQyx//mCDUaArvteCEE6swQugDtdToOvmVXSdQQF0UiwXNJDHn encmeUU6F4a/aoAcrOsn/uQS1DUUed8sgbMRnZs4h9BSHDtaTV+HRo6DWlqlWsUo/kjz +hDnnKl/f2FLvXk2oqaOlWbBlqWs1lLzf95zMuX7rElg3tjl6uvvjmu0Sr6UQGQnHrX/ woTWobuoSzeODQ9u/nR0fjBKO03JDyKTJKZ8fUUgue/LYy+abxzAoxUtEQFSnWNyR45T LA== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 2vd0y70m7t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 02 Oct 2019 13:58:07 -0700 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, 2 Oct 2019 13:58:06 -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:06 -0700 Received: from BG-LT7430.marvell.com (unknown [10.28.17.68]) by maili.marvell.com (Postfix) with ESMTP id 17BE03F7040; Wed, 2 Oct 2019 13:58:02 -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:46 +0530 Message-ID: <20191002205754.11746-3-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 02/10] examples/l2fwd-event: add infra for eventdev 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 infra to select event device as a mode to process packets through command line arguments. Also, allow the user to select the schedule type to be either RTE_SCHED_TYPE_ORDERED or RTE_SCHED_TYPE_ATOMIC. Usage: `--mode="eventdev"` or `--mode="poll"` `--eventq-sched="ordered"` or `--eventq-sched="atomic"` Signed-off-by: Sunil Kumar Kori Signed-off-by: Pavan Nikhilesh --- examples/l2fwd-event/Makefile | 1 + examples/l2fwd-event/l2fwd_common.h | 3 ++ examples/l2fwd-event/l2fwd_event.c | 34 ++++++++++++++++++++ examples/l2fwd-event/l2fwd_event.h | 21 ++++++++++++ examples/l2fwd-event/main.c | 50 +++++++++++++++++++++++++++-- examples/l2fwd-event/meson.build | 1 + 6 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 examples/l2fwd-event/l2fwd_event.c create mode 100644 examples/l2fwd-event/l2fwd_event.h diff --git a/examples/l2fwd-event/Makefile b/examples/l2fwd-event/Makefile index 73f02dd3b..08ba1835d 100644 --- a/examples/l2fwd-event/Makefile +++ b/examples/l2fwd-event/Makefile @@ -8,6 +8,7 @@ APP = l2fwd-event # all source are stored in SRCS-y SRCS-y := main.c SRCS-y += l2fwd_poll.c +SRCS-y += l2fwd_event.c SRCS-y += l2fwd_common.c # Build using pkg-config variables if possible diff --git a/examples/l2fwd-event/l2fwd_common.h b/examples/l2fwd-event/l2fwd_common.h index 7b5958c7d..cdafa52c7 100644 --- a/examples/l2fwd-event/l2fwd_common.h +++ b/examples/l2fwd-event/l2fwd_common.h @@ -65,6 +65,8 @@ struct l2fwd_port_statistics { struct l2fwd_resources { volatile uint8_t force_quit; + uint8_t event_mode; + uint8_t sched_type; uint8_t mac_updating; uint8_t rx_queue_per_lcore; uint16_t nb_rxd; @@ -75,6 +77,7 @@ struct l2fwd_resources { uint32_t dst_ports[RTE_MAX_ETHPORTS]; struct rte_ether_addr eth_addr[RTE_MAX_ETHPORTS]; struct l2fwd_port_statistics port_stats[RTE_MAX_ETHPORTS]; + void *event_rsrc; void *poll_rsrc; } __rte_cache_aligned; diff --git a/examples/l2fwd-event/l2fwd_event.c b/examples/l2fwd-event/l2fwd_event.c new file mode 100644 index 000000000..621ff63f0 --- /dev/null +++ b/examples/l2fwd-event/l2fwd_event.c @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "l2fwd_event.h" + +void +l2fwd_event_resource_setup(struct l2fwd_resources *l2fwd_rsrc) +{ + struct l2fwd_event_resources *event_rsrc; + + if (!rte_event_dev_count()) + rte_exit(EXIT_FAILURE, "No Eventdev found\n"); + + event_rsrc = rte_zmalloc("l2fwd_event", + sizeof(struct l2fwd_event_resources), 0); + if (event_rsrc == NULL) + rte_exit(EXIT_FAILURE, "failed to allocate memory\n"); + + l2fwd_rsrc->event_rsrc = event_rsrc; +} diff --git a/examples/l2fwd-event/l2fwd_event.h b/examples/l2fwd-event/l2fwd_event.h new file mode 100644 index 000000000..8ac2dc266 --- /dev/null +++ b/examples/l2fwd-event/l2fwd_event.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#ifndef __L2FWD_EVENT_H__ +#define __L2FWD_EVENT_H__ + +#include +#include +#include +#include +#include + +#include "l2fwd_common.h" + +struct l2fwd_event_resources { +}; + +void l2fwd_event_resource_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 887a979d5..01b1d531d 100644 --- a/examples/l2fwd-event/main.c +++ b/examples/l2fwd-event/main.c @@ -2,6 +2,7 @@ * Copyright(C) 2019 Marvell International Ltd. */ +#include "l2fwd_event.h" #include "l2fwd_poll.h" /* display usage */ @@ -16,7 +17,12 @@ l2fwd_event_usage(const char *prgname) " --[no-]mac-updating: Enable or disable MAC addresses updating (enabled by default)\n" " When enabled:\n" " - The source MAC address is replaced by the TX port MAC address\n" - " - The destination MAC address is replaced by 02:00:00:00:00:TX_PORT_ID\n", + " - The destination MAC address is replaced by 02:00:00:00:00:TX_PORT_ID\n" + " --mode: Packet transfer mode for I/O, poll or eventdev\n" + " Default mode = eventdev\n" + " --eventq-sched: Event queue schedule type, ordered or atomic.\n" + " Default: atomic\n" + " Valid only if --mode=eventdev\n\n", prgname); } @@ -71,6 +77,26 @@ l2fwd_event_parse_timer_period(const char *q_arg) return n; } +static void +l2fwd_event_parse_mode(const char *optarg, + struct l2fwd_resources *l2fwd_rsrc) +{ + if (!strncmp(optarg, "poll", 4)) + l2fwd_rsrc->event_mode = false; + else if (!strncmp(optarg, "eventdev", 8)) + l2fwd_rsrc->event_mode = true; +} + +static void +l2fwd_event_parse_eventq_sched(const char *optarg, + struct l2fwd_resources *l2fwd_rsrc) +{ + if (!strncmp(optarg, "ordered", 7)) + l2fwd_rsrc->sched_type = RTE_SCHED_TYPE_ORDERED; + else if (!strncmp(optarg, "atomic", 6)) + l2fwd_rsrc->sched_type = RTE_SCHED_TYPE_ATOMIC; +} + static const char short_options[] = "p:" /* portmask */ "q:" /* number of queues */ @@ -79,6 +105,8 @@ static const char short_options[] = #define CMD_LINE_OPT_MAC_UPDATING "mac-updating" #define CMD_LINE_OPT_NO_MAC_UPDATING "no-mac-updating" +#define CMD_LINE_OPT_MODE "mode" +#define CMD_LINE_OPT_EVENTQ_SCHED "eventq-sched" enum { /* long options mapped to a short option */ @@ -87,6 +115,8 @@ enum { * conflict with short options */ CMD_LINE_OPT_MIN_NUM = 256, + CMD_LINE_OPT_MODE_NUM, + CMD_LINE_OPT_EVENTQ_SCHED_NUM, }; /* Parse the argument given in the command line of the application */ @@ -98,6 +128,10 @@ l2fwd_event_parse_args(int argc, char **argv, struct option lgopts[] = { { CMD_LINE_OPT_MAC_UPDATING, no_argument, &mac_updating, 1}, { CMD_LINE_OPT_NO_MAC_UPDATING, no_argument, &mac_updating, 0}, + { CMD_LINE_OPT_MODE, required_argument, NULL, + CMD_LINE_OPT_MODE_NUM}, + { CMD_LINE_OPT_EVENTQ_SCHED, required_argument, NULL, + CMD_LINE_OPT_EVENTQ_SCHED_NUM}, {NULL, 0, 0, 0} }; int opt, ret, timer_secs; @@ -145,6 +179,14 @@ l2fwd_event_parse_args(int argc, char **argv, l2fwd_rsrc->timer_period *= rte_get_timer_hz(); break; + case CMD_LINE_OPT_MODE_NUM: + l2fwd_event_parse_mode(optarg, l2fwd_rsrc); + break; + + case CMD_LINE_OPT_EVENTQ_SCHED_NUM: + l2fwd_event_parse_eventq_sched(optarg, l2fwd_rsrc); + break; + /* long options */ case 0: break; @@ -332,7 +374,11 @@ main(int argc, char **argv) "All available ports are disabled. Please set portmask.\n"); } - l2fwd_poll_resource_setup(l2fwd_rsrc); + /* Configure eventdev parameters if required */ + if (l2fwd_rsrc->event_mode) + l2fwd_event_resource_setup(l2fwd_rsrc); + else + l2fwd_poll_resource_setup(l2fwd_rsrc); /* initialize port stats */ memset(&l2fwd_rsrc->port_stats, 0, diff --git a/examples/l2fwd-event/meson.build b/examples/l2fwd-event/meson.build index f482e1817..84ee1af84 100644 --- a/examples/l2fwd-event/meson.build +++ b/examples/l2fwd-event/meson.build @@ -11,4 +11,5 @@ sources = files( 'main.c', 'l2fwd_poll.c', 'l2fwd_common.c', + 'l2fwd_event.c', ) -- 2.17.1