X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fl2fwd-event%2Fmain.c;h=2a1fe4e11822bf8415ffb3a62c4ec77e5f743f28;hb=1b2143aa681ae2412da98a076e46c477fafb8588;hp=a4e41ddb40e9eb2bff7b1b5227e24c09b443660a;hpb=4ff457986f760a9d96a2bc82e3f24f2817cd33aa;p=dpdk.git diff --git a/examples/l2fwd-event/main.c b/examples/l2fwd-event/main.c index a4e41ddb40..2a1fe4e118 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, atomic or parallel.\n" + " Default: atomic\n" + " Valid only if --mode=eventdev\n\n", prgname); } @@ -71,6 +77,28 @@ l2fwd_event_parse_timer_period(const char *q_arg) return n; } +static void +l2fwd_event_parse_mode(const char *optarg, + struct l2fwd_resources *rsrc) +{ + if (!strncmp(optarg, "poll", 4)) + rsrc->event_mode = false; + else if (!strncmp(optarg, "eventdev", 8)) + rsrc->event_mode = true; +} + +static void +l2fwd_event_parse_eventq_sched(const char *optarg, + struct l2fwd_resources *rsrc) +{ + if (!strncmp(optarg, "ordered", 7)) + rsrc->sched_type = RTE_SCHED_TYPE_ORDERED; + else if (!strncmp(optarg, "atomic", 6)) + rsrc->sched_type = RTE_SCHED_TYPE_ATOMIC; + else if (!strncmp(optarg, "parallel", 8)) + rsrc->sched_type = RTE_SCHED_TYPE_PARALLEL; +} + static const char short_options[] = "p:" /* portmask */ "q:" /* number of queues */ @@ -79,6 +107,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 +117,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 +130,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 +181,14 @@ l2fwd_event_parse_args(int argc, char **argv, rsrc->timer_period *= rte_get_timer_hz(); break; + case CMD_LINE_OPT_MODE_NUM: + l2fwd_event_parse_mode(optarg, rsrc); + break; + + case CMD_LINE_OPT_EVENTQ_SCHED_NUM: + l2fwd_event_parse_eventq_sched(optarg, rsrc); + break; + /* long options */ case 0: break; @@ -404,7 +448,11 @@ main(int argc, char **argv) if (!nb_ports_available) rte_panic("All available ports are disabled. Please set portmask.\n"); - l2fwd_poll_resource_setup(rsrc); + /* Configure eventdev parameters if required */ + if (rsrc->event_mode) + l2fwd_event_resource_setup(rsrc); + else + l2fwd_poll_resource_setup(rsrc); /* initialize port stats */ memset(&rsrc->port_stats, 0,