vhost: fix packed ring index wrapping
[dpdk.git] / examples / vm_power_manager / main.c
index 77797b1..7d5bf68 100644 (file)
 #include "vm_power_cli.h"
 #include "oob_monitor.h"
 #include "parse.h"
-#ifdef RTE_LIBRTE_IXGBE_PMD
+#ifdef RTE_NET_IXGBE
 #include <rte_pmd_ixgbe.h>
 #endif
-#ifdef RTE_LIBRTE_I40E_PMD
+#ifdef RTE_NET_I40E
 #include <rte_pmd_i40e.h>
 #endif
-#ifdef RTE_LIBRTE_BNXT_PMD
+#ifdef RTE_NET_BNXT
 #include <rte_pmd_bnxt.h>
 #endif
 
@@ -144,10 +144,7 @@ parse_portmask(const char *portmask)
        /* parse hexadecimal string */
        pm = strtoul(portmask, &end, 16);
        if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
-               return -1;
-
-       if (pm == 0)
-               return -1;
+               return 0;
 
        return pm;
 }
@@ -209,6 +206,7 @@ parse_args(int argc, char **argv)
                        }
                        if (branch_ratio <= 0.0 || branch_ratio > 100.0) {
                                printf("invalid branch ratio specified\n");
+                               free(oob_enable);
                                return -1;
                        }
                        for (i = 0; i < ci->core_count; i++) {
@@ -249,6 +247,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid, count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
        int ret;
+       char link_status_text[RTE_ETH_LINK_MAX_STR_LEN];
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -272,15 +271,10 @@ check_all_ports_link_status(uint32_t port_mask)
                        }
                        /* print link status if flag set */
                        if (print_flag == 1) {
-                               if (link.link_status)
-                                       printf("Port %d Link Up - speed %u "
-                                               "Mbps - %s\n", (uint16_t)portid,
-                                               (unsigned int)link.link_speed,
-                               (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
-                                       ("full-duplex") : ("half-duplex"));
-                               else
-                                       printf("Port %d Link Down\n",
-                                               (uint16_t)portid);
+                               rte_eth_link_to_str(link_status_text,
+                                       sizeof(link_status_text), &link);
+                               printf("Port %d %s\n", portid,
+                                      link_status_text);
                                continue;
                        }
                       /* clear all_ports_up flag if any link down */
@@ -400,20 +394,20 @@ main(int argc, char **argv)
                                        "Cannot init port %"PRIu8 "\n",
                                        portid);
 
-                       for (w = 0; w < MAX_VFS; w++) {
+                       for (w = 0; w < RTE_POWER_MAX_VFS; w++) {
                                eth.addr_bytes[5] = w + 0xf0;
 
                                ret = -ENOTSUP;
-#ifdef RTE_LIBRTE_IXGBE_PMD
+#ifdef RTE_NET_IXGBE
                                ret = rte_pmd_ixgbe_set_vf_mac_addr(portid,
                                                        w, &eth);
 #endif
-#ifdef RTE_LIBRTE_I40E_PMD
+#ifdef RTE_NET_I40E
                                if (ret == -ENOTSUP)
                                        ret = rte_pmd_i40e_set_vf_mac_addr(
                                                        portid, w, &eth);
 #endif
-#ifdef RTE_LIBRTE_BNXT_PMD
+#ifdef RTE_NET_BNXT
                                if (ret == -ENOTSUP)
                                        ret = rte_pmd_bnxt_set_vf_mac_addr(
                                                        portid, w, &eth);
@@ -474,5 +468,8 @@ main(int argc, char **argv)
 
        free(ci->cd);
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }