net: add rte prefix to ether structures
[dpdk.git] / examples / vm_power_manager / main.c
index f9990f1..f8cab11 100644 (file)
 #include "vm_power_cli.h"
 #include "oob_monitor.h"
 #include "parse.h"
+#ifdef RTE_LIBRTE_IXGBE_PMD
 #include <rte_pmd_ixgbe.h>
+#endif
+#ifdef RTE_LIBRTE_I40E_PMD
 #include <rte_pmd_i40e.h>
+#endif
+#ifdef RTE_LIBRTE_BNXT_PMD
 #include <rte_pmd_bnxt.h>
+#endif
 
 #define RX_RING_SIZE 1024
 #define TX_RING_SIZE 1024
@@ -99,7 +105,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
                return retval;
 
        /* Display the port MAC address. */
-       struct ether_addr addr;
+       struct rte_ether_addr addr;
        rte_eth_macaddr_get(port, &addr);
        printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8
                           " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n",
@@ -141,17 +147,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) {
@@ -173,6 +181,7 @@ parse_args(int argc, char **argv)
                        if (cnt < 0) {
                                printf("Invalid core-list - [%s]\n",
                                                optarg);
+                               free(oob_enable);
                                break;
                        }
                        for (i = 0; i < ci->core_count; i++) {
@@ -184,6 +193,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;
@@ -334,7 +355,7 @@ main(int argc, char **argv)
 
                /* Initialize ports. */
                RTE_ETH_FOREACH_DEV(portid) {
-                       struct ether_addr eth;
+                       struct rte_ether_addr eth;
                        int w, j;
                        int ret;
 
@@ -355,14 +376,21 @@ main(int argc, char **argv)
                        for (w = 0; w < MAX_VFS; w++) {
                                eth.addr_bytes[5] = w + 0xf0;
 
+                               ret = -ENOTSUP;
+#ifdef RTE_LIBRTE_IXGBE_PMD
                                ret = rte_pmd_ixgbe_set_vf_mac_addr(portid,
                                                        w, &eth);
+#endif
+#ifdef RTE_LIBRTE_I40E_PMD
                                if (ret == -ENOTSUP)
                                        ret = rte_pmd_i40e_set_vf_mac_addr(
                                                        portid, w, &eth);
+#endif
+#ifdef RTE_LIBRTE_BNXT_PMD
                                if (ret == -ENOTSUP)
                                        ret = rte_pmd_bnxt_set_vf_mac_addr(
                                                        portid, w, &eth);
+#endif
 
                                switch (ret) {
                                case 0:
@@ -376,7 +404,6 @@ main(int argc, char **argv)
                                        break;
                                }
                                printf("\n");
-                               break;
                        }
                }
        }
@@ -407,6 +434,8 @@ main(int argc, char **argv)
                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);