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
examples/vhost_blk: fix build with gcc 10
[dpdk.git]
/
examples
/
link_status_interrupt
/
main.c
diff --git
a/examples/link_status_interrupt/main.c
b/examples/link_status_interrupt/main.c
index
0c3dfc6
..
a924aa2
100644
(file)
--- a/
examples/link_status_interrupt/main.c
+++ b/
examples/link_status_interrupt/main.c
@@
-117,6
+117,7
@@
print_stats(void)
const char clr[] = { 27, '[', '2', 'J', '\0' };
const char topLeft[] = { 27, '[', '1', ';', '1', 'H','\0' };
const char clr[] = { 27, '[', '2', 'J', '\0' };
const char topLeft[] = { 27, '[', '1', ';', '1', 'H','\0' };
+ int link_get_err;
/* Clear screen and move to top left */
printf("%s%s", clr, topLeft);
/* Clear screen and move to top left */
printf("%s%s", clr, topLeft);
@@
-129,7
+130,7
@@
print_stats(void)
continue;
memset(&link, 0, sizeof(link));
continue;
memset(&link, 0, sizeof(link));
- rte_eth_link_get_nowait(portid, &link);
+
link_get_err =
rte_eth_link_get_nowait(portid, &link);
printf("\nStatistics for port %u ------------------------------"
"\nLink status: %25s"
"\nLink speed: %26u"
printf("\nStatistics for port %u ------------------------------"
"\nLink status: %25s"
"\nLink speed: %26u"
@@
-138,8
+139,11
@@
print_stats(void)
"\nPackets received: %20"PRIu64
"\nPackets dropped: %21"PRIu64,
portid,
"\nPackets received: %20"PRIu64
"\nPackets dropped: %21"PRIu64,
portid,
+ link_get_err < 0 ? "Link get failed" :
(link.link_status ? "Link up" : "Link down"),
(link.link_status ? "Link up" : "Link down"),
- (unsigned)link.link_speed,
+ link_get_err < 0 ? 0 :
+ (unsigned int)link.link_speed,
+ link_get_err < 0 ? "Link get failed" :
(link.link_duplex == ETH_LINK_FULL_DUPLEX ? \
"full-duplex" : "half-duplex"),
port_statistics[portid].tx,
(link.link_duplex == ETH_LINK_FULL_DUPLEX ? \
"full-duplex" : "half-duplex"),
port_statistics[portid].tx,
@@
-438,13
+442,19
@@
lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param,
void *ret_param)
{
struct rte_eth_link link;
void *ret_param)
{
struct rte_eth_link link;
+ int ret;
RTE_SET_USED(param);
RTE_SET_USED(ret_param);
printf("\n\nIn registered callback...\n");
printf("Event type: %s\n", type == RTE_ETH_EVENT_INTR_LSC ? "LSC interrupt" : "unknown event");
RTE_SET_USED(param);
RTE_SET_USED(ret_param);
printf("\n\nIn registered callback...\n");
printf("Event type: %s\n", type == RTE_ETH_EVENT_INTR_LSC ? "LSC interrupt" : "unknown event");
- rte_eth_link_get_nowait(port_id, &link);
+ ret = rte_eth_link_get_nowait(port_id, &link);
+ if (ret < 0) {
+ printf("Failed link get on port %d: %s\n",
+ port_id, rte_strerror(-ret));
+ return ret;
+ }
if (link.link_status) {
printf("Port %d Link Up - speed %u Mbps - %s\n\n",
port_id, (unsigned)link.link_speed,
if (link.link_status) {
printf("Port %d Link Up - speed %u Mbps - %s\n\n",
port_id, (unsigned)link.link_speed,
@@
-465,6
+475,7
@@
check_all_ports_link_status(uint16_t port_num, 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);
@@
-474,7
+485,14
@@
check_all_ports_link_status(uint16_t port_num, 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)
@@
-639,8
+657,12
@@
main(int argc, char **argv)
rte_eth_dev_callback_register(portid,
RTE_ETH_EVENT_INTR_LSC, lsi_event_callback, NULL);
rte_eth_dev_callback_register(portid,
RTE_ETH_EVENT_INTR_LSC, lsi_event_callback, NULL);
- rte_eth_macaddr_get(portid,
+ r
et = r
te_eth_macaddr_get(portid,
&lsi_ports_eth_addr[portid]);
&lsi_ports_eth_addr[portid]);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "rte_eth_macaddr_get: err=%d, port=%u\n",
+ ret, (unsigned int)portid);
/* init one RX queue */
fflush(stdout);
/* init one RX queue */
fflush(stdout);
@@
-689,7
+711,11
@@
main(int argc, char **argv)
ret, (unsigned) portid);
printf("done:\n");
ret, (unsigned) portid);
printf("done:\n");
- rte_eth_promiscuous_enable(portid);
+ 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);
printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n",
(unsigned) portid,
printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n",
(unsigned) portid,