app/testeventdev: add helper functions to dump options
[dpdk.git] / app / test-eventdev / evt_options.h
index a8ec91d..75f129e 100644 (file)
@@ -42,6 +42,8 @@
 
 #include "evt_common.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];
@@ -62,5 +64,196 @@ struct evt_options {
 };
 
 void evt_options_default(struct evt_options *opt);
+void evt_options_dump(struct evt_options *opt);
+
+/* options check helpers */
+static inline bool
+evt_lcores_has_overlap(bool lcores[], int lcore)
+{
+       if (lcores[lcore] == true) {
+               evt_err("lcore overlaps at %d", lcore);
+               return true;
+       }
+
+       return false;
+}
+
+static inline bool
+evt_lcores_has_overlap_multi(bool lcoresx[], bool lcoresy[])
+{
+       int i;
+
+       for (i = 0; i < RTE_MAX_LCORE; i++) {
+               if (lcoresx[i] && lcoresy[i]) {
+                       evt_err("lcores overlaps at %d", i);
+                       return true;
+               }
+       }
+       return false;
+}
+
+static inline bool
+evt_has_active_lcore(bool lcores[])
+{
+       int i;
+
+       for (i = 0; i < RTE_MAX_LCORE; i++)
+               if (lcores[i])
+                       return true;
+       return false;
+}
+
+static inline int
+evt_nr_active_lcores(bool lcores[])
+{
+       int i;
+       int c = 0;
+
+       for (i = 0; i < RTE_MAX_LCORE; i++)
+               if (lcores[i])
+                       c++;
+       return c;
+}
+
+static inline int
+evt_get_first_active_lcore(bool lcores[])
+{
+       int i;
+
+       for (i = 0; i < RTE_MAX_LCORE; i++)
+               if (lcores[i])
+                       return i;
+       return -1;
+}
+
+static inline bool
+evt_has_disabled_lcore(bool lcores[])
+{
+       int i;
+
+       for (i = 0; i < RTE_MAX_LCORE; i++)
+               if ((lcores[i] == true) && !(rte_lcore_is_enabled(i)))
+                       return true;
+       return false;
+}
+
+static inline bool
+evt_has_invalid_stage(struct evt_options *opt)
+{
+       if (!opt->nb_stages) {
+               evt_err("need minimum one stage, check --stlist");
+               return true;
+       }
+       if (opt->nb_stages > EVT_MAX_STAGES) {
+               evt_err("requested changes are beyond EVT_MAX_STAGES=%d",
+                       EVT_MAX_STAGES);
+               return true;
+       }
+       return false;
+}
+
+static inline bool
+evt_has_invalid_sched_type(struct evt_options *opt)
+{
+       int i;
+
+       for (i = 0; i < opt->nb_stages; i++) {
+               if (opt->sched_type_list[i] > RTE_SCHED_TYPE_PARALLEL) {
+                       evt_err("invalid sched_type %d at %d",
+                               opt->sched_type_list[i], i);
+                       return true;
+               }
+       }
+       return false;
+}
+
+/* option dump helpers */
+static inline void
+evt_dump_worker_lcores(struct evt_options *opt)
+{
+       int c;
+
+       evt_dump_begin("worker lcores");
+       for  (c = 0; c < RTE_MAX_LCORE; c++) {
+               if (opt->wlcores[c])
+                       printf("%d ", c);
+       }
+       evt_dump_end;
+}
+
+static inline void
+evt_dump_producer_lcores(struct evt_options *opt)
+{
+       int c;
+
+       evt_dump_begin("producer lcores");
+       for  (c = 0; c < RTE_MAX_LCORE; c++) {
+               if (opt->plcores[c])
+                       printf("%d ", c);
+       }
+       evt_dump_end;
+}
+
+static inline void
+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)
+{
+       evt_dump("worker deq depth", "%d", opt->wkr_deq_dep);
+}
+
+static inline void
+evt_dump_nb_stages(struct evt_options *opt)
+{
+       evt_dump("nb_stages", "%d", opt->nb_stages);
+}
+
+static inline void
+evt_dump_fwd_latency(struct evt_options *opt)
+{
+       evt_dump("fwd_latency", "%s", EVT_BOOL_FMT(opt->fwd_latency));
+}
+
+static inline void
+evt_dump_queue_priority(struct evt_options *opt)
+{
+       evt_dump("queue_priority", "%s", EVT_BOOL_FMT(opt->q_priority));
+}
+
+static inline const char*
+evt_sched_type_2_str(uint8_t sched_type)
+{
+
+       if (sched_type == RTE_SCHED_TYPE_ORDERED)
+               return "O";
+       else if (sched_type == RTE_SCHED_TYPE_ATOMIC)
+               return "A";
+       else if (sched_type == RTE_SCHED_TYPE_PARALLEL)
+               return "P";
+       else
+               return "I";
+}
+
+static inline void
+evt_dump_sched_type_list(struct evt_options *opt)
+{
+       int i;
+
+       evt_dump_begin("sched_type_list");
+       for (i = 0; i < opt->nb_stages; i++)
+               printf("%s ", evt_sched_type_2_str(opt->sched_type_list[i]));
+
+       evt_dump_end;
+}
 
 #endif /* _EVT_OPTIONS_ */