test mbuf attach
[dpdk.git] / app / test-eventdev / evt_options.h
index 75f129e..748e54f 100644 (file)
@@ -1,33 +1,5 @@
-/*
- *   BSD LICENSE
- *
- *   Copyright (C) Cavium 2017.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in
- *       the documentation and/or other materials provided with the
- *       distribution.
- *     * Neither the name of Cavium networks nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017 Cavium, Inc
  */
 
 #ifndef _EVT_OPTIONS_
@@ -37,6 +9,7 @@
 #include <stdbool.h>
 
 #include <rte_common.h>
+#include <rte_ethdev.h>
 #include <rte_eventdev.h>
 #include <rte_lcore.h>
 
 
 #define EVT_BOOL_FMT(x)          ((x) ? "true" : "false")
 
-struct evt_options {
-#define EVT_TEST_NAME_MAX_LEN     32
-       char test_name[EVT_TEST_NAME_MAX_LEN];
-       bool plcores[RTE_MAX_LCORE];
-       bool wlcores[RTE_MAX_LCORE];
-       uint8_t sched_type_list[EVT_MAX_STAGES];
-       int slcore;
-       uint32_t nb_flows;
-       int socket_id;
-       int pool_sz;
-       int nb_stages;
-       int verbose_level;
-       uint64_t nb_pkts;
-       uint16_t wkr_deq_dep;
-       uint8_t dev_id;
-       uint32_t fwd_latency:1;
-       uint32_t q_priority:1;
-};
+#define EVT_VERBOSE              ("verbose")
+#define EVT_DEVICE               ("dev")
+#define EVT_TEST                 ("test")
+#define EVT_PROD_LCORES          ("plcores")
+#define EVT_WORK_LCORES          ("wlcores")
+#define EVT_NB_FLOWS             ("nb_flows")
+#define EVT_SOCKET_ID            ("socket_id")
+#define EVT_POOL_SZ              ("pool_sz")
+#define EVT_WKR_DEQ_DEP          ("worker_deq_depth")
+#define EVT_NB_PKTS              ("nb_pkts")
+#define EVT_NB_STAGES            ("nb_stages")
+#define EVT_SCHED_TYPE_LIST      ("stlist")
+#define EVT_FWD_LATENCY          ("fwd_latency")
+#define EVT_QUEUE_PRIORITY       ("queue_priority")
+#define EVT_DEQ_TMO_NSEC         ("deq_tmo_nsec")
+#define EVT_PROD_ETHDEV          ("prod_type_ethdev")
+#define EVT_PROD_TIMERDEV        ("prod_type_timerdev")
+#define EVT_PROD_TIMERDEV_BURST  ("prod_type_timerdev_burst")
+#define EVT_NB_TIMERS            ("nb_timers")
+#define EVT_NB_TIMER_ADPTRS      ("nb_timer_adptrs")
+#define EVT_TIMER_TICK_NSEC      ("timer_tick_nsec")
+#define EVT_MAX_TMO_NSEC         ("max_tmo_nsec")
+#define EVT_EXPIRY_NSEC          ("expiry_nsec")
+#define EVT_MBUF_SZ              ("mbuf_sz")
+#define EVT_MAX_PKT_SZ           ("max_pkt_sz")
+#define EVT_HELP                 ("help")
 
 void evt_options_default(struct evt_options *opt);
+int evt_options_parse(struct evt_options *opt, int argc, char **argv);
 void evt_options_dump(struct evt_options *opt);
 
 /* options check helpers */
@@ -200,12 +182,6 @@ evt_dump_nb_flows(struct evt_options *opt)
        evt_dump("nb_flows", "%d", opt->nb_flows);
 }
 
-static inline void
-evt_dump_scheduler_lcore(struct evt_options *opt)
-{
-       evt_dump("scheduler lcore", "%d", opt->slcore);
-}
-
 static inline void
 evt_dump_worker_dequeue_depth(struct evt_options *opt)
 {
@@ -256,4 +232,58 @@ evt_dump_sched_type_list(struct evt_options *opt)
        evt_dump_end;
 }
 
+static inline const char *
+evt_prod_id_to_name(enum evt_prod_type prod_type)
+{
+       switch (prod_type) {
+       default:
+       case EVT_PROD_TYPE_SYNT:
+               return "Synthetic producer lcores";
+       case EVT_PROD_TYPE_ETH_RX_ADPTR:
+               return "Ethdev Rx Adapter";
+       case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
+               return "Event timer adapter";
+       }
+
+       return "";
+}
+
+#define EVT_PROD_MAX_NAME_LEN 50
+static inline void
+evt_dump_producer_type(struct evt_options *opt)
+{
+       char name[EVT_PROD_MAX_NAME_LEN];
+
+       switch (opt->prod_type) {
+       default:
+       case EVT_PROD_TYPE_SYNT:
+               snprintf(name, EVT_PROD_MAX_NAME_LEN,
+                               "Synthetic producer lcores");
+               break;
+       case EVT_PROD_TYPE_ETH_RX_ADPTR:
+               snprintf(name, EVT_PROD_MAX_NAME_LEN,
+                               "Ethdev Rx Adapter producers");
+               evt_dump("nb_ethdev", "%d", rte_eth_dev_count_avail());
+               break;
+       case EVT_PROD_TYPE_EVENT_TIMER_ADPTR:
+               if (opt->timdev_use_burst)
+                       snprintf(name, EVT_PROD_MAX_NAME_LEN,
+                               "Event timer adapter burst mode producer");
+               else
+                       snprintf(name, EVT_PROD_MAX_NAME_LEN,
+                               "Event timer adapter producer");
+               evt_dump("nb_timer_adapters", "%d", opt->nb_timer_adptrs);
+               evt_dump("max_tmo_nsec", "%"PRIu64"", opt->max_tmo_nsec);
+               evt_dump("expiry_nsec", "%"PRIu64"", opt->expiry_nsec);
+               if (opt->optm_timer_tick_nsec)
+                       evt_dump("optm_timer_tick_nsec", "%"PRIu64"",
+                                       opt->optm_timer_tick_nsec);
+               else
+                       evt_dump("timer_tick_nsec", "%"PRIu64"",
+                                       opt->timer_tick_nsec);
+               break;
+       }
+       evt_dump("prod_type", "%s", name);
+}
+
 #endif /* _EVT_OPTIONS_ */