X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fvm_power_manager%2Fmain.c;h=d39f044c1ed1f507dd1d3a08f8741e7fc231414a;hb=4ce384793f842de07ffedb0df80127cee546af3a;hp=1a846af714e6f8a6fc179668d822690ed2dc9d09;hpb=958d14d38659d96859718657743a963bd6e9f1f4;p=dpdk.git diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c index 1a846af714..d39f044c1e 100644 --- a/examples/vm_power_manager/main.c +++ b/examples/vm_power_manager/main.c @@ -31,9 +31,15 @@ #include "vm_power_cli.h" #include "oob_monitor.h" #include "parse.h" +#ifdef RTE_LIBRTE_IXGBE_PMD #include +#endif +#ifdef RTE_LIBRTE_I40E_PMD #include +#endif +#ifdef RTE_LIBRTE_BNXT_PMD #include +#endif #define RX_RING_SIZE 1024 #define TX_RING_SIZE 1024 @@ -48,7 +54,7 @@ static volatile bool force_quit; /****************/ static const struct rte_eth_conf port_conf_default = { .rxmode = { - .max_rx_pkt_len = ETHER_MAX_LEN, + .max_rx_pkt_len = RTE_ETHER_MAX_LEN, }, }; @@ -65,7 +71,13 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) if (!rte_eth_dev_is_valid_port(port)) return -1; - rte_eth_dev_info_get(port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + return retval; + } + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; @@ -99,8 +111,14 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) return retval; /* Display the port MAC address. */ - struct ether_addr addr; - rte_eth_macaddr_get(port, &addr); + struct rte_ether_addr addr; + retval = rte_eth_macaddr_get(port, &addr); + if (retval != 0) { + printf("Failed to get device (port %u) MAC address: %s\n", + port, rte_strerror(-retval)); + return retval; + } + printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n", (unsigned int)port, @@ -109,7 +127,9 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) addr.addr_bytes[4], addr.addr_bytes[5]); /* Enable RX in promiscuous mode for the Ethernet device. */ - rte_eth_promiscuous_enable(port); + retval = rte_eth_promiscuous_enable(port); + if (retval != 0) + return retval; return 0; @@ -223,6 +243,7 @@ check_all_ports_link_status(uint32_t port_mask) #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */ uint16_t portid, count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -236,7 +257,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) @@ -349,7 +377,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; @@ -370,14 +398,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, ð); +#endif +#ifdef RTE_LIBRTE_I40E_PMD if (ret == -ENOTSUP) ret = rte_pmd_i40e_set_vf_mac_addr( portid, w, ð); +#endif +#ifdef RTE_LIBRTE_BNXT_PMD if (ret == -ENOTSUP) ret = rte_pmd_bnxt_set_vf_mac_addr( portid, w, ð); +#endif switch (ret) { case 0: @@ -421,7 +456,7 @@ main(int argc, char **argv) return -1; } - add_host_channel(); + add_host_channels(); printf("Running core monitor on lcore id %d\n", lcore_id); rte_eal_remote_launch(run_core_monitor, NULL, lcore_id);