X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fl3fwd-power%2Fmain.c;h=a03f64a1a35a1317f29ffd71efd8b7192fe4c936;hb=47ac243ac4ced228da5d55bfc9121a8e466dbe01;hp=99c1208ce14cbc524bc8477ce0fc11349c9859ee;hpb=292472ba0be75da85dec045a608e8dd162094141;p=dpdk.git diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index 99c1208ce1..a03f64a1a3 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -184,8 +184,8 @@ enum busy_rate { * reference CYCLES to be used to * measure core busyness based on poll count */ -#define MIN_CYCLES 1500000ULL -#define MAX_CYCLES 2500000ULL +#define MIN_CYCLES 1500000ULL +#define MAX_CYCLES 22000000ULL /* (500ms) */ #define TELEMETRY_INTERVALS_PER_SEC 2 @@ -1034,7 +1034,7 @@ main_telemetry_loop(__attribute__((unused)) void *dummy) br = FULL; } else if (diff_tsc > MIN_CYCLES && diff_tsc < MAX_CYCLES) { - br = PARTIAL; + br = (diff_tsc * 100) / MAX_CYCLES; } else { br = ZERO; } @@ -1970,6 +1970,7 @@ check_all_ports_link_status(uint32_t port_mask) uint8_t count, all_ports_up, print_flag = 0; uint16_t portid; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -1979,7 +1980,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) @@ -2100,9 +2108,16 @@ update_telemetry(__attribute__((unused)) struct rte_timer *tim, rte_spinlock_unlock(&stats[lcore_id].telemetry_lock); } - values[0] = round(app_eps/count); - values[1] = round(app_fps/count); - values[2] = round(app_br/count); + if (count > 0) { + values[0] = app_eps/count; + values[1] = app_fps/count; + values[2] = app_br/count; + } else { + values[0] = 0; + values[1] = 0; + values[2] = 0; + } + ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index, values, RTE_DIM(values)); if (ret < 0) @@ -2250,7 +2265,12 @@ main(int argc, char **argv) printf("Initializing port %d ... ", portid ); fflush(stdout); - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + dev_rxq_num = dev_info.max_rx_queues; dev_txq_num = dev_info.max_tx_queues; @@ -2268,7 +2288,13 @@ main(int argc, char **argv) /* If number of Rx queue is 0, no need to enable Rx interrupt */ if (nb_rx_queue == 0) local_port_conf.intr_conf.rxq = 0; - rte_eth_dev_info_get(portid, &dev_info); + + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; @@ -2297,7 +2323,12 @@ main(int argc, char **argv) "Cannot adjust number of descriptors: err=%d, port=%d\n", ret, portid); - rte_eth_macaddr_get(portid, &ports_eth_addr[portid]); + ret = rte_eth_macaddr_get(portid, &ports_eth_addr[portid]); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Cannot get MAC address: err=%d, port=%d\n", + ret, portid); + print_ethaddr(" Address:", &ports_eth_addr[portid]); printf(", "); @@ -2378,13 +2409,9 @@ main(int argc, char **argv) /* init RX queues */ for(queue = 0; queue < qconf->n_rx_queue; ++queue) { struct rte_eth_rxconf rxq_conf; - struct rte_eth_dev *dev; - struct rte_eth_conf *conf; portid = qconf->rx_queue_list[queue].port_id; queueid = qconf->rx_queue_list[queue].queue_id; - dev = &rte_eth_devices[portid]; - conf = &dev->data->dev_conf; if (numa_on) socketid = \ @@ -2395,9 +2422,14 @@ main(int argc, char **argv) printf("rxq=%d,%d,%d ", portid, queueid, socketid); fflush(stdout); - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + rxq_conf = dev_info.default_rxconf; - rxq_conf.offloads = conf->rxmode.offloads; + rxq_conf.offloads = port_conf.rxmode.offloads; ret = rte_eth_rx_queue_setup(portid, queueid, nb_rxd, socketid, &rxq_conf, pktmbuf_pool[socketid]); @@ -2434,8 +2466,13 @@ main(int argc, char **argv) * to itself through 2 cross-connected ports of the * target machine. */ - if (promiscuous_on) - rte_eth_promiscuous_enable(portid); + if (promiscuous_on) { + ret = rte_eth_promiscuous_enable(portid); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "rte_eth_promiscuous_enable: err=%s, port=%u\n", + rte_strerror(-ret), portid); + } /* initialize spinlock for each port */ rte_spinlock_init(&(locks[portid])); }