net/enic: fix VXLAN match
[dpdk.git] / examples / vm_power_manager / main.c
index 613a40a..893bf4c 100644 (file)
@@ -29,6 +29,7 @@
 #include "channel_monitor.h"
 #include "power_manager.h"
 #include "vm_power_cli.h"
+#include "oob_monitor.h"
 #include "parse.h"
 #include <rte_pmd_ixgbe.h>
 #include <rte_pmd_i40e.h>
@@ -140,16 +141,19 @@ parse_args(int argc, char **argv)
        int option_index;
        char *prgname = argv[0];
        struct core_info *ci;
+       float branch_ratio;
        static struct option lgopts[] = {
                { "mac-updating", no_argument, 0, 1},
                { "no-mac-updating", no_argument, 0, 0},
                { "core-list", optional_argument, 0, 'l'},
+               { "port-list", optional_argument, 0, 'p'},
+               { "branch-ratio", optional_argument, 0, 'b'},
                {NULL, 0, 0, 0}
        };
        argvopt = argv;
        ci = get_core_info();
 
-       while ((opt = getopt_long(argc, argvopt, "l:p:q:T:",
+       while ((opt = getopt_long(argc, argvopt, "l:p:q:T:b:",
                                  lgopts, &option_index)) != EOF) {
 
                switch (opt) {
@@ -182,6 +186,18 @@ parse_args(int argc, char **argv)
                        }
                        free(oob_enable);
                        break;
+               case 'b':
+                       branch_ratio = 0.0;
+                       if (strlen(optarg))
+                               branch_ratio = atof(optarg);
+                       if (branch_ratio <= 0.0) {
+                               printf("invalid branch ratio specified\n");
+                               return -1;
+                       }
+                       ci->branch_ratio_threshold = branch_ratio;
+                       printf("***Setting branch ratio to %f\n",
+                                       branch_ratio);
+                       break;
                /* long options */
                case 0:
                        break;
@@ -267,6 +283,17 @@ run_monitor(__attribute__((unused)) void *arg)
        return 0;
 }
 
+static int
+run_core_monitor(__attribute__((unused)) void *arg)
+{
+       if (branch_monitor_init() < 0) {
+               printf("Unable to initialize core monitor\n");
+               return -1;
+       }
+       run_branch_monitor();
+       return 0;
+}
+
 static void
 sig_handler(int signo)
 {
@@ -285,12 +312,15 @@ main(int argc, char **argv)
        unsigned int nb_ports;
        struct rte_mempool *mbuf_pool;
        uint16_t portid;
+       struct core_info *ci;
 
 
        ret = core_info_init();
        if (ret < 0)
                rte_panic("Cannot allocate core info\n");
 
+       ci = get_core_info();
+
        ret = rte_eal_init(argc, argv);
        if (ret < 0)
                rte_panic("Cannot init EAL\n");
@@ -365,16 +395,23 @@ main(int argc, char **argv)
                }
        }
 
+       check_all_ports_link_status(enabled_port_mask);
+
        lcore_id = rte_get_next_lcore(-1, 1, 0);
        if (lcore_id == RTE_MAX_LCORE) {
-               RTE_LOG(ERR, EAL, "A minimum of two cores are required to run "
+               RTE_LOG(ERR, EAL, "A minimum of three cores are required to run "
                                "application\n");
                return 0;
        }
-
-       check_all_ports_link_status(enabled_port_mask);
+       printf("Running channel monitor on lcore id %d\n", lcore_id);
        rte_eal_remote_launch(run_monitor, NULL, lcore_id);
 
+       lcore_id = rte_get_next_lcore(lcore_id, 1, 0);
+       if (lcore_id == RTE_MAX_LCORE) {
+               RTE_LOG(ERR, EAL, "A minimum of three cores are required to run "
+                               "application\n");
+               return 0;
+       }
        if (power_manager_init() < 0) {
                printf("Unable to initialize power manager\n");
                return -1;
@@ -383,8 +420,19 @@ main(int argc, char **argv)
                printf("Unable to initialize channel manager\n");
                return -1;
        }
+
+       add_host_channel();
+
+       printf("Running core monitor on lcore id %d\n", lcore_id);
+       rte_eal_remote_launch(run_core_monitor, NULL, lcore_id);
+
        run_cli(NULL);
 
+       branch_monitor_exit();
+
        rte_eal_mp_wait_lcore();
+
+       free(ci->cd);
+
        return 0;
 }