examples/eventdev: add ops to check cmdline args
authorPavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Wed, 10 Jan 2018 11:10:03 +0000 (16:40 +0530)
committerJerin Jacob <jerin.jacob@caviumnetworks.com>
Fri, 19 Jan 2018 15:09:56 +0000 (16:09 +0100)
Each eventdev pipeline needs to allow different cmdline args combination
based on pipeline type.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
examples/eventdev_pipeline_sw_pmd/main.c
examples/eventdev_pipeline_sw_pmd/pipeline_common.h
examples/eventdev_pipeline_sw_pmd/pipeline_worker_generic.c

index 5635fc5..f260944 100644 (file)
@@ -225,17 +225,11 @@ parse_app_args(int argc, char **argv)
                }
        }
 
-       if (worker_lcore_mask == 0 || rx_lcore_mask == 0 ||
-           sched_lcore_mask == 0 || tx_lcore_mask == 0) {
-               printf("Core part of pipeline was not assigned any cores. "
-                       "This will stall the pipeline, please check core masks "
-                       "(use -h for details on setting core masks):\n"
-                       "\trx: %"PRIu64"\n\ttx: %"PRIu64"\n\tsched: %"PRIu64
-                       "\n\tworkers: %"PRIu64"\n",
-                       rx_lcore_mask, tx_lcore_mask, sched_lcore_mask,
-                       worker_lcore_mask);
-               rte_exit(-1, "Fix core masks\n");
-       }
+       cdata.worker_lcore_mask = worker_lcore_mask;
+       cdata.sched_lcore_mask = sched_lcore_mask;
+       cdata.rx_lcore_mask = rx_lcore_mask;
+       cdata.tx_lcore_mask = tx_lcore_mask;
+
        if (cdata.num_stages == 0 || cdata.num_stages > MAX_NUM_STAGES)
                usage();
 
index 379ba9d..9e1f5e9 100644 (file)
@@ -82,6 +82,10 @@ struct config_data {
        int16_t next_qid[MAX_NUM_STAGES+2];
        int16_t qid[MAX_NUM_STAGES];
        uint8_t rx_adapter_id;
+       uint64_t worker_lcore_mask;
+       uint64_t rx_lcore_mask;
+       uint64_t tx_lcore_mask;
+       uint64_t sched_lcore_mask;
 };
 
 struct port_link {
index d2bc6d3..d1b0e1d 100644 (file)
@@ -385,6 +385,48 @@ init_rx_adapter(uint16_t nb_ports)
                                cdata.rx_adapter_id);
 }
 
+static void
+generic_opt_check(void)
+{
+       int i;
+       int ret;
+       uint32_t cap = 0;
+       uint8_t rx_needed = 0;
+       struct rte_event_dev_info eventdev_info;
+
+       memset(&eventdev_info, 0, sizeof(struct rte_event_dev_info));
+       rte_event_dev_info_get(0, &eventdev_info);
+
+       for (i = 0; i < rte_eth_dev_count(); i++) {
+               ret = rte_event_eth_rx_adapter_caps_get(0, i, &cap);
+               if (ret)
+                       rte_exit(EXIT_FAILURE,
+                               "failed to get event rx adapter capabilities");
+               rx_needed |=
+                       !(cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT);
+       }
+
+       if (cdata.worker_lcore_mask == 0 ||
+                       (rx_needed && cdata.rx_lcore_mask == 0) ||
+                       cdata.tx_lcore_mask == 0 || (cdata.sched_lcore_mask == 0
+                               && !(eventdev_info.event_dev_cap &
+                                       RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED))) {
+               printf("Core part of pipeline was not assigned any cores. "
+                       "This will stall the pipeline, please check core masks "
+                       "(use -h for details on setting core masks):\n"
+                       "\trx: %"PRIu64"\n\ttx: %"PRIu64"\n\tsched: %"PRIu64
+                       "\n\tworkers: %"PRIu64"\n",
+                       cdata.rx_lcore_mask, cdata.tx_lcore_mask,
+                       cdata.sched_lcore_mask,
+                       cdata.worker_lcore_mask);
+               rte_exit(-1, "Fix core masks\n");
+       }
+
+       if (eventdev_info.event_dev_cap & RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED)
+               memset(fdata->sched_core, 0,
+                               sizeof(unsigned int) * MAX_NUM_CORE);
+}
+
 void
 set_worker_generic_setup_data(struct setup_data *caps, bool burst)
 {
@@ -395,4 +437,5 @@ set_worker_generic_setup_data(struct setup_data *caps, bool burst)
        caps->adptr_setup = init_rx_adapter;
        caps->scheduler = schedule_devices;
        caps->evdev_setup = setup_eventdev_generic;
+       caps->check_opt = generic_opt_check;
 }