git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
vhost: add packed ring single dequeue
[dpdk.git]
/
examples
/
l3fwd-power
/
main.c
diff --git
a/examples/l3fwd-power/main.c
b/examples/l3fwd-power/main.c
index
fb2a9d6
..
a03f64a
100644
(file)
--- 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
*/
* reference CYCLES to be used to
* measure core busyness based on poll count
*/
-#define MIN_CYCLES 1500000ULL
-#define MAX_CYCLES 2
5
00000ULL
+#define MIN_CYCLES
1500000ULL
+#define MAX_CYCLES 2
20
00000ULL
/* (500ms) */
#define TELEMETRY_INTERVALS_PER_SEC 2
/* (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 = FULL;
} else if (diff_tsc > MIN_CYCLES &&
diff_tsc < MAX_CYCLES) {
- br =
PARTIAL
;
+ br =
(diff_tsc * 100) / MAX_CYCLES
;
} else {
br = ZERO;
}
} 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;
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);
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));
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)
/* 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);
}
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)
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);
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;
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;
/* 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;
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);
"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(", ");
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;
/* 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;
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 = \
if (numa_on)
socketid = \
@@
-2395,9
+2422,14
@@
main(int argc, char **argv)
printf("rxq=%d,%d,%d ", portid, queueid, socketid);
fflush(stdout);
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 = 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]);
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.
*/
* 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]));
}
/* initialize spinlock for each port */
rte_spinlock_init(&(locks[portid]));
}
@@
-2468,10
+2505,12
@@
main(int argc, char **argv)
rte_eal_mp_remote_launch(main_empty_poll_loop, NULL,
SKIP_MASTER);
} else {
rte_eal_mp_remote_launch(main_empty_poll_loop, NULL,
SKIP_MASTER);
} else {
+ unsigned int i;
+
/* Init metrics library */
rte_metrics_init(rte_socket_id());
/** Register stats with metrics library */
/* Init metrics library */
rte_metrics_init(rte_socket_id());
/** Register stats with metrics library */
- for (
unsigned int
i = 0; i < num_telstats; i++)
+ for (i = 0; i < num_telstats; i++)
ptr_strings[i] = telstats_strings[i].name;
ret = rte_metrics_reg_names(ptr_strings, num_telstats);
ptr_strings[i] = telstats_strings[i].name;
ret = rte_metrics_reg_names(ptr_strings, num_telstats);