net/virtio: add link speed tuning
Subsystems (2)
PATCH v6 11/25 examples/ip_*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications:
* ip_fragmentation
* ip_reassembly
* l3fwd-acl
--- examples/ip_fragmentation/main.c | 13 +++++-------- examples/ip_reassembly/main.c | 12 ++++-------- examples/l3fwd-acl/main.c | 12 ++++-------- 3 files changed, 13 insertions(+), 24 deletions(-)
examples/ip_fragmentation/main.c +5 -8
@@ -593,6 +593,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -612,14 +613,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/ip_reassembly/main.c +4 -8
@@ -712,6 +712,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -731,14 +732,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l3fwd-acl/main.c +4 -8
@@ -1815,6 +1815,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1834,14 +1835,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v6 12/25 examples/ip_pipeline: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ip_pipeline/cli.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
examples/ip_pipeline/cli.c +7 -5
@@ -249,7 +249,8 @@ print_link_info(struct link *link, char *out, size_t out_size)struct rte_eth_link eth_link;uint16_t mtu;int ret; - +char link_speed_text[16 ]; +char link_status_text[10 ];memset (&stats,0 ,sizeof (stats));rte_eth_stats_get (link->port_id, &stats);
@@ -268,18 +269,19 @@ print_link_info(struct link *link, char *out, size_t out_size) }rte_eth_dev_get_mtu (link->port_id, &mtu); - +rte_eth_link_strf (link_speed_text,16 ,"%M" , ð_link); +rte_eth_link_strf (link_status_text,10 ,"%S" , ð_link); snprintf(out, out_size, "\n" "%s: flags=<%s> mtu %u\n" "\tether %02X:%02X:%02X:%02X:%02X:%02X rxqueues %u txqueues %u\n" - "\tport# %u speed %u Mbps\n" + "\tport# %u speed %s Mbps\n" "\tRX packets %" PRIu64" bytes %" PRIu64"\n" "\tRX errors %" PRIu64" missed %" PRIu64" no-mbuf %" PRIu64"\n" "\tTX packets %" PRIu64" bytes %" PRIu64"\n" "\tTX errors %" PRIu64"\n", link->name, - eth_link.link_status == 0 ? "DOWN" : "UP", + link_status_text, mtu, mac_addr.addr_bytes[0], mac_addr.addr_bytes[1], mac_addr.addr_bytes[2], mac_addr.addr_bytes[3],
@@ -287,7 +289,7 @@ print_link_info(struct link *link, char *out, size_t out_size) link->n_rxq, link->n_txq, link->port_id, - eth_link.link_speed, + link_speed_text, stats.ipackets, stats.ibytes, stats.ierrors,
Signature · 1 line
2.17.1
PATCH v6 13/25 examples/ipsec-secgw: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ipsec-secgw/ipsec-secgw.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +4 -8
@@ -1775,6 +1775,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1794,14 +1795,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v6 14/25 examples/kni: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/kni/main.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
examples/kni/main.c +9 -17
@@ -661,6 +661,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status\n" );fflush (stdout);
@@ -680,14 +681,9 @@ 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 %uMbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
@@ -717,19 +713,15 @@ check_all_ports_link_status(uint32_t port_mask)static void log_link_state (struct rte_kni *kni,int prev,struct rte_eth_link *link) { +char link_status_text[60 ];if (kni ==NULL || link ==NULL )return ; -if (prev ==ETH_LINK_DOWN && link->link_status ==ETH_LINK_UP ) { -RTE_LOG (INFO ,APP ,"%s NIC Link is Up %d Mbps %s %s.\n" , +rte_eth_link_strf (link_status_text,60 ,NULL , link); +if (prev != link->link_status) +RTE_LOG (INFO ,APP ,"%s NIC %s" ,rte_kni_get_name (kni), - link->link_speed, - link->link_autoneg ?"(AutoNeg)" :"(Fixed)" , - link->link_duplex ?"Full Duplex" :"Half Duplex" ); - }else if (prev ==ETH_LINK_UP && link->link_status ==ETH_LINK_DOWN ) { -RTE_LOG (INFO ,APP ,"%s NIC Link is Down.\n" , -rte_kni_get_name (kni)); - } + link_status_text); }/*
Signature · 1 line
2.17.1
PATCH v6 15/25 examples/l2fwd-crypt: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l2fwd-crypto/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/l2fwd-crypto/main.c +4 -8
@@ -1734,6 +1734,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1753,14 +1754,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v6 16/25 examples/l2fwd-event: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l2fwd-event/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/l2fwd-event/main.c +4 -8
@@ -366,6 +366,7 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc,uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status..." );fflush (stdout);
@@ -389,14 +390,9 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc, }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - port_id, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , port_id); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , port_id, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v6 17/25 examples/l2fwd: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l2fwd/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/l2fwd/main.c +4 -8
@@ -571,6 +571,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -594,14 +595,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v6 18/25 examples/l3fwd-graph: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l3fwd-graph/main.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
examples/l3fwd-graph/main.c +4 -10
@@ -599,6 +599,7 @@ check_all_ports_link_status(uint32_t port_mask)struct rte_eth_link link;uint16_t portid;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -623,16 +624,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex == -ETH_LINK_FULL_DUPLEX ) - ? ("full-duplex" ) - : ("half-duplex\n" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* Clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v6 19/25 examples/l3fwd-power: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l3fwd-power/main.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
examples/l3fwd-power/main.c +4 -9
@@ -1945,6 +1945,7 @@ check_all_ports_link_status(uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1964,15 +1965,9 @@ 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" , (uint8_t )portid, - (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - (uint8_t )portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v6 20/25 examples/multi_proc*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- .../client_server_mp/mp_server/init.c | 14 +++++--------- examples/multi_process/symmetric_mp/main.c | 12 ++++-------- 2 files changed, 9 insertions(+), 17 deletions(-)
examples/multi_process/client_server_mp/mp_server/init.c +5 -9
@@ -185,6 +185,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -204,15 +205,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , ports->id[portid], - (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - (uint8_t )ports->id[portid]); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , (uint8_t )ports->id[portid], + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/multi_process/symmetric_mp/main.c +4 -8
@@ -365,6 +365,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -384,14 +385,9 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v6 21/25 examples/ntb: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ntb/ntb_fwd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
examples/ntb/ntb_fwd.c +5 -5
@@ -729,6 +729,7 @@ start_pkt_fwd(void)struct rte_eth_link eth_link;uint32_t lcore_id;int ret, i; +char link_status_text[60 ]; ret =ntb_fwd_config_setup ();if (ret <0 ) {
@@ -747,11 +748,10 @@ start_pkt_fwd(void)return ; }if (eth_link.link_status) { -printf ("Eth%u Link Up. Speed %u Mbps - %s\n" , - eth_port_id, eth_link.link_speed, - (eth_link.link_duplex == -ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Eth%u %s" , eth_port_id, + link_status_text);break ; } }
Signature · 1 line
2.17.1
PATCH v6 22/25 example/performance*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/performance-thread/l3fwd-thread/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/performance-thread/l3fwd-thread/main.c +4 -8
@@ -3433,6 +3433,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -3452,14 +3453,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v6 23/25 examples/qos_sched: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/qos_sched/init.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
examples/qos_sched/init.c +2 -8
@@ -160,14 +160,8 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)"rte_eth_link_get: err=%d, port=%u: %s\n" , ret, portid, rte_strerror(-ret)); -if (link.link_status) { -printf (" Link Up - speed %u Mbps - %s\n" , - (uint32_t ) link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else { -printf (" Link Down\n" ); - } +rte_eth_link_printf (NULL , &link); + ret =rte_eth_promiscuous_enable (portid);if (ret !=0 ) rte_exit(EXIT_FAILURE,
Signature · 1 line
2.17.1
PATCH v6 24/25 examples/server_nod*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/server_node_efd/server/init.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
examples/server_node_efd/server/init.c +5 -10
@@ -247,6 +247,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -266,16 +267,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , - info->id[portid], - link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - info->id[portid]); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , info->id[portid], + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v6 25/25 examples/vm_power_*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/vm_power_manager/main.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
examples/vm_power_manager/main.c +5 -9
@@ -244,6 +244,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[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -267,15 +268,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_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
v7 cover ethdev: allow unknown link speed
In reply to Ivan DyukovMAINTAINERS | 1 +
app/proc-info/main.c | 9 ++---- app/test-pipeline/init.c | 11 ++++--- app/test-pmd/config.c | 20 ++++++++----- app/test-pmd/testpmd.c | 9 +----- app/test/Makefile | 3 ++ app/test/meson.build | 2 ++ app/test/test_ethdev_link.c | 278 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app/test/test_pmd_perf.c | 17 +++++------ doc/guides/sample_app_ug/link_status_intr.rst | 10 +++---- drivers/net/i40e/i40e_ethdev.c | 5 +++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++---- drivers/net/ice/ice_ethdev.c | 5 +++- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +--- examples/bbdev_app/main.c | 8 ++--- examples/ioat/ioatfwd.c | 13 ++++---- examples/ip_fragmentation/main.c | 13 ++++---- examples/ip_pipeline/cli.c | 12 ++++---- examples/ip_reassembly/main.c | 12 +++----- examples/ipsec-secgw/ipsec-secgw.c | 12 +++----- examples/ipv4_multicast/main.c | 12 +++----- examples/kni/main.c | 26 ++++++---------- examples/l2fwd-crypto/main.c | 12 +++----- examples/l2fwd-event/main.c | 12 +++----- examples/l2fwd-jobstats/main.c | 12 +++----- examples/l2fwd-keepalive/main.c | 12 +++----- examples/l2fwd/main.c | 12 +++----- examples/l3fwd-acl/main.c | 12 +++----- examples/l3fwd-graph/main.c | 14 +++------ examples/l3fwd-power/main.c | 13 +++----- examples/l3fwd/main.c | 12 +++----- examples/link_status_interrupt/main.c | 30 ++++++++----------- examples/multi_process/client_server_mp/mp_server/init.c | 14 ++++----- examples/multi_process/symmetric_mp/main.c | 12 +++----- examples/ntb/ntb_fwd.c | 10 +++---- examples/performance-thread/l3fwd-thread/main.c | 12 +++----- examples/qos_sched/init.c | 10 ++----- examples/server_node_efd/server/init.c | 15 ++++------ examples/vm_power_manager/main.c | 14 ++++----- lib/librte_ethdev/rte_ethdev.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 74 +++++++++++++++++++++++++++++++++++++++------- lib/librte_ethdev/rte_ethdev_version.map | 4 +++ 42 files changed, 687 insertions(+), 282 deletions(-)
v7 changes:
* fix meson build
* change _strf function. now it does not fails in case of unknown specifiers like %d. it just copy it to target string.
* remove invalid_fmt unit test.
* add unknown specifier test.
* fix codestyle
v6 changes:
* fix spelling in comments according to checkpatch warning
v5 changes:
* rename rte_eth_link_format to rte_eth_link_strf
* add '\n' to default strings
* update remaining examples. patch with subj 'examples: new link status print format' contains examples which have no maintainers. TBD:
update remaining nic drivers with 'unknown' speed. It should be provided in separate patchset.
v4 changes:
* refactor rte_eth_link_format using strlcat func instead of snprintf
* added new checks to unit tests
* few minor fixes according review comments
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v3 changes:
* remove rte_eth_link_prepare_text function
* add rte_eth_link_format and rte_eth_link_printf functions
* added unit tests for rte_eth_link_format function
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v2 changes:
* add function which format link status to textual representation
* update drivers for Intel nics with 'unknown' speed
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
PATCH v7 1/25 ethdev: allow unknown link speed
From: Thomas Monjalon <[email protected]>
When querying the link information, the link status is a mandatory major information.
Other boolean values are supposed to be accurate:
- duplex mode (half/full)
- negotiation (auto/fixed)
This API update is making explicit that the link speed information is optional.
The value ETH_SPEED_NUM_NONE (0) was already part of the API. The value ETH_SPEED_NUM_UNKNOWN (infinite) is added to cover two different cases:
- speed is not known by the driver
- device is virtual
--- lib/librte_ethdev/rte_ethdev.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
lib/librte_ethdev/rte_ethdev.h +10 -10
@@ -303,6 +303,7 @@ struct rte_eth_stats {#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ #define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ #define ETH_SPEED_NUM_200G 200000/**< 200 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN UINT32_MAX/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
@@ -2262,15 +2263,16 @@ int rte_eth_allmulticast_disable(uint16_t port_id);int rte_eth_allmulticast_get (uint16_t port_id);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It might need -* to wait up to 9 seconds in it. +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). +* +* It might need to wait up to 9 seconds. +* @see rte_eth_link_get_nowait. * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
@@ -2279,15 +2281,13 @@ int rte_eth_allmulticast_get(uint16_t port_id);int rte_eth_link_get (uint16_t port_id,struct rte_eth_link *link);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait -* version of rte_eth_link_get(). +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
Signature · 1 line
2.17.1
PATCH v7 2/25 ethdev: add a link status text representation
In reply to Ivan DyukovThis commit add function which treat link status structure and format it to text representation.
--- MAINTAINERS | 1 + app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 299 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 174 +++++++++++++ lib/librte_ethdev/rte_ethdev.h | 54 ++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + 7 files changed, 537 insertions(+) create mode 100644 app/test/test_ethdev_link.c
MAINTAINERS +1 -0
@@ -393,6 +393,7 @@ T: git://dpdk.org/next/dpdk-next-net F: lib/librte_ethdev/ F: devtools/test-null.sh F: doc/guides/prog_guide/switch_representation.rst +F: app/test/test_ethdev* Flow API M: Ori Kam <[email protected]>
app/test/Makefile +3 -0
@@ -251,6 +251,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c test_ipsec_perf.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c + +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c + ifeq ($(CONFIG_RTE_LIBRTE_IPSEC),y) LDLIBS += -lrte_ipsec endif
app/test/meson.build +2 -0
@@ -39,6 +39,7 @@ test_sources = files('commands.c', 'test_efd.c', 'test_efd_perf.c', 'test_errno.c', + 'test_ethdev_link.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',
@@ -199,6 +200,7 @@ fast_tests = [ ['eal_flags_misc_autotest', false], ['eal_fs_autotest', true], ['errno_autotest', true], + ['ethdev_link_status', true], ['event_ring_autotest', true], ['fib_autotest', true], ['fib6_autotest', true],
app/test/test_ethdev_link.c new file +299 -0
299 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.c +174 -0
180 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.h +54 -0
60 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +4 -0
@@ -241,4 +241,8 @@ EXPERIMENTAL { __rte_ethdev_trace_rx_burst; __rte_ethdev_trace_tx_burst; rte_flow_get_aged_flows; + + # added in 20.08 + rte_eth_link_strf; + rte_eth_link_printf; };
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v7 02/25] ethdev: add a link status text representation
Quoted 4 lines · Ivan Dyukov
This commit add function which treat link status structure and format it to text representation.
Signed-off-by Ivan Dyukov <[email protected]>
<...>
Quoted 64 lines
lib/librte_ethdev/rte_ethdev.c +64
-0+static int +rte_eth_link_strf_parser (char *str,size_t len,const char *const fmt, +const struct rte_eth_link *link) +{ +size_t offset =0 ; +const char *fmt_cur = fmt; +char *str_cur = str; +double gbits = (double )link->link_speed /1000. ; +static const char autoneg_str[] ="Autoneg" ; +static const char fixed_str[] ="Fixed" ; +static const char fdx_str[] ="FDX" ; +static const char hdx_str[] ="HDX" ; +static const char unknown_str[] ="Unknown" ; +static const char up_str[] ="Up" ; +static const char down_str[] ="Down" ; +char gbits_str[20 ]; +char mbits_str[20 ]; + +/* preformat complex formatting to easily concatinate it further */ +snprintf (mbits_str,sizeof (mbits_str),"%u" , link->link_speed); +snprintf (gbits_str,sizeof (gbits_str),"%.1f" , gbits); +/* init str before formatting */ + str[0 ] =0 ; +while (*fmt_cur) { +/* check str bounds */ +if (offset > (len -1 )) { + str[len -1 ] ='\0' ; +return -1 ; + } +if (*fmt_cur =='%' ) { +/* set null terminator to current position, +* it's required for strlcat +*/ + *str_cur ='\0' ; +switch (*++fmt_cur) { +/* Speed in Mbits/s */ +case 'M' : +if (link->link_speed == +ETH_SPEED_NUM_UNKNOWN ) + offset =strlcat (str, unknown_str, + len); +else + offset =strlcat (str, mbits_str, len); +break ; +/* Speed in Gbits/s */ +case 'G' : +if (link->link_speed == +ETH_SPEED_NUM_UNKNOWN ) + offset =strlcat (str, unknown_str, + len); +else + offset =strlcat (str, gbits_str, len); +break ; +/* Link status */ +case 'S' : + offset =strlcat (str, link->link_status ? + up_str : down_str, len); +break ; +/* Link autoneg */ +case 'A' : + offset =strlcat (str, link->link_autoneg ? + autoneg_str : fixed_str, len); +break ; +/* Link duplex */
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2459
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+case 'D' : + offset =strlcat (str, link->link_duplex ? + fdx_str : hdx_str, len); +break ; +/* ignore unknown specifier */ +default : + *str_cur ='%' ; + offset++; + fmt_cur--; +break ;
What do you think ignoring the unknown specifiers and keep continue processing the string, instead of break? Just keep unknown specifier as it is in the output string.
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2463
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +4
-0+ + } +if (offset > (len -1 )) +return -1 ;
For me "offset >= len" is simpler than "offset > (len - 1)", also it prevents any possible error when "len == 0" ('len' is unsigned) although I can see you have check for it. Anyway both deos same thing, up to you.
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2468
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +5
-0+ + str_cur = str + offset; + }else { + *str_cur++ = *fmt_cur; + offset++;
Why keeping both offset and the pointer ('str_cur'), just offset should be enough "str[offset++] = *fmt_cur;", I think this simplifies a little bit.
Quoted 29 lines
lib/librte_ethdev/rte_ethdev.c +29
-0+ } + fmt_cur++; + } + *str_cur ='\0' ; +return offset; +} + +int +rte_eth_link_printf (const char *const fmt, +const struct rte_eth_link *link) +{ +char text[200 ]; +int ret; + + ret =rte_eth_link_strf (text,200 , fmt, link); +if (ret >0 ) +printf ("%s" , text); +return ret; +} + +int +rte_eth_link_strf (char *str,size_t len,const char *const fmt, +const struct rte_eth_link *link) +{ +size_t offset =0 ; +double gbits = (double )link->link_speed /1000. ; +char speed_gbits_str[20 ]; +char speed_mbits_str[20 ]; +/* TBD: make it international? */
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2507
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+static const char link_down_str[] ="Link down\n" ; +static const char link_up_str[] ="Link up at " ; +static const char unknown_speed_str[] ="Unknown speed " ; +static const char mbits_str[] ="Mbit/s" ; +static const char gbits_str[] ="Gbit/s" ; +static const char fdx_str[] ="FDX " ; +static const char hdx_str[] ="HDX " ; +/* autoneg is latest param in default string, so add '\n' */ +static const char autoneg_str[] ="Autoneg\n" ; +static const char fixed_str[] ="Fixed\n" ;
Please put an empty line after variables.
<...>
Quoted 19 lines
+/**
+ * Format link status to textual representation. This function threats all
+ * special values likeETH_SPEED_NUM_UNKNOWN,ETH_LINK_DOWNetc. and convert
+ * them to textual representation.
+ *
+ * @param str
+ * A pointer to a string to be filled with textual representation of
+ * device status.
+ * @param len
+ * Length of available memory at 'str' string.
+ * @param fmt+ * Format string which allow to format link status. If NULL is provided + * , default formatting will be applied. + * Following specifiers are available: + * - '%M' link speed in Mbits/s + * - '%G' link speed in Gbits/s + * - '%S' link status. e.g. Up or Down + * - '%A' link autonegotiation state + * - '%D' link duplex state
Quoted 1 line
+ * @param link
It should be 'eth_link' otherwise doxygen is complaining.
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2351
Quoted 9 lines
+ * Link status provided by
rte_eth_link_getfunction
+ * @return
+ * - Number of bytes written to str array. In case of error, -1 is returned.
+ *
+ */lib/librte_ethdev/rte_ethdev.h +4
-0+__rte_experimental +int rte_eth_link_strf(char *str, size_t len, const char *const fmt, +const struct rte_eth_link *eth_link); +
For the API name, I guess 'strf' is for 'stringify' but what do you think about 'rte_eth_link_to_str()', I think more clear and simpler.
Re: [dpdk-dev] [PATCH v7 02/25] ethdev: add a link status text representation
Quoted 10 lines · Ferruh
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2459
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6
-0+/* ignore unknown specifier */ +default : + *str_cur ='%' ; + offset++; + fmt_cur--; +break ;What do you think ignoring the unknown specifiers and keep continue processing the string, instead of break? Just keep unknown specifier as it is in the output string.
My comment was that the function should behave the same as snprintf() does when handed unknown specifier. What snprintf does is duplicate the string in the output buffer (like any other non format character).
Re: [dpdk-dev] [PATCH v7 02/25] ethdev: add a link status text representation
Quoted 14 lines
Quoted 10 lines · Ferruh
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2459
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6
-0+/* ignore unknown specifier */ +default : + *str_cur ='%' ; + offset++; + fmt_cur--; +break ;What do you think ignoring the unknown specifiers and keep continue processing the string, instead of break? Just keep unknown specifier as it is in the output string.
Quoted 4 lines
My comment was that the function should behave the same as
snprintf()does when handed unknown specifier. What snprintf does is duplicate the string in the output buffer (like any other non format character).
+1
Re: [dpdk-dev] [PATCH v7 02/25] ethdev: add a link status text representation
In reply to Stephen Hemminger10.07.2020 18:22, Stephen Hemminger пишет:
Quoted 12 lines
Quoted 9 lines · Ferruh
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2459
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6
-0+/* ignore unknown specifier */ +default : + *str_cur ='%' ; + offset++; + fmt_cur--; +break ;What do you think ignoring the unknown specifiers and keep continue processing the string, instead of break? Just keep unknown specifier as it is in the output string.
Quoted 4 lines
My comment was that the function should behave the same as
snprintf()does when handed unknown specifier. What snprintf does is duplicate the string in the output buffer (like any other non format character).
Looks like I need to rewrite comment "ignore unkown specifier". It's not what code do. This function work like snprintf.
Re: [dpdk-dev] [PATCH v7 02/25] ethdev: add a link status text representation
In reply to Yigit, Ferruh10.07.2020 16:06, Yigit, Ferruh пишет:
Quoted 76 lines · Ivan Dyukov
Quoted 4 lines
This commit add function which treat link status structure and format it to text representation.
Signed-off-by Ivan Dyukov <[email protected]><...>
Quoted 69 lines
lib/librte_ethdev/rte_ethdev.c +69
-0+static int +rte_eth_link_strf_parser (char *str,size_t len,const char *const fmt, +const struct rte_eth_link *link) +{ +size_t offset =0 ; +const char *fmt_cur = fmt; +char *str_cur = str; +double gbits = (double )link->link_speed /1000. ; +static const char autoneg_str[] ="Autoneg" ; +static const char fixed_str[] ="Fixed" ; +static const char fdx_str[] ="FDX" ; +static const char hdx_str[] ="HDX" ; +static const char unknown_str[] ="Unknown" ; +static const char up_str[] ="Up" ; +static const char down_str[] ="Down" ; +char gbits_str[20 ]; +char mbits_str[20 ]; + +/* preformat complex formatting to easily concatinate it further */ +snprintf (mbits_str,sizeof (mbits_str),"%u" , link->link_speed); +snprintf (gbits_str,sizeof (gbits_str),"%.1f" , gbits); +/* init str before formatting */ + str[0 ] =0 ; +while (*fmt_cur) { +/* check str bounds */ +if (offset > (len -1 )) { + str[len -1 ] ='\0' ; +return -1 ; + } +if (*fmt_cur =='%' ) { +/* set null terminator to current position, +* it's required for strlcat +*/ + *str_cur ='\0' ; +switch (*++fmt_cur) { +/* Speed in Mbits/s */ +case 'M' : +if (link->link_speed == +ETH_SPEED_NUM_UNKNOWN ) + offset =strlcat (str, unknown_str, + len); +else + offset =strlcat (str, mbits_str, len); +break ; +/* Speed in Gbits/s */ +case 'G' : +if (link->link_speed == +ETH_SPEED_NUM_UNKNOWN ) + offset =strlcat (str, unknown_str, + len); +else + offset =strlcat (str, gbits_str, len); +break ; +/* Link status */ +case 'S' : + offset =strlcat (str, link->link_status ? + up_str : down_str, len); +break ; +/* Link autoneg */ +case 'A' : + offset =strlcat (str, link->link_autoneg ? + autoneg_str : fixed_str, len); +break ; +/* Link duplex */ +case 'D' : + offset =strlcat (str, link->link_duplex ? + fdx_str : hdx_str, len); +break ; +/* ignore unknown specifier */
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2459
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +5
-0+default : + *str_cur ='%' ; + offset++; + fmt_cur--; +break ;What do you think ignoring the unknown specifiers and keep continue processing the string, instead of break? Just keep unknown specifier as it is in the output string.
yep. it's exactly what code do. break exit from the switch but not from string processing. I have unit tests for this case. They work fine. Please review unit tests and send me more cases if they need to be tested.
Quoted 91 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2463
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +4
-0+ + } +if (offset > (len -1 )) +return -1 ;For me "offset >= len" is simpler than "offset > (len - 1)", also it prevents any possible error when "len == 0" ('len' is unsigned) although I can see you have check for it. Anyway both deos same thing, up to you.
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2468
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +5
-0+ + str_cur = str + offset; + }else { + *str_cur++ = *fmt_cur; + offset++;Why keeping both offset and the pointer ('
str_cur'), just offset should be enough "str[offset++] =*fmt_cur;", I think this simplifies a little bit.Quoted 29 lines
lib/librte_ethdev/rte_ethdev.c +29
-0+ } + fmt_cur++; + } + *str_cur ='\0' ; +return offset; +} + +int +rte_eth_link_printf (const char *const fmt, +const struct rte_eth_link *link) +{ +char text[200 ]; +int ret; + + ret =rte_eth_link_strf (text,200 , fmt, link); +if (ret >0 ) +printf ("%s" , text); +return ret; +} + +int +rte_eth_link_strf (char *str,size_t len,const char *const fmt, +const struct rte_eth_link *link) +{ +size_t offset =0 ; +double gbits = (double )link->link_speed /1000. ; +char speed_gbits_str[20 ]; +char speed_mbits_str[20 ]; +/* TBD: make it international? */ lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2507
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+static const char link_down_str[] ="Link down\n" ; +static const char link_up_str[] ="Link up at " ; +static const char unknown_speed_str[] ="Unknown speed " ; +static const char mbits_str[] ="Mbit/s" ; +static const char gbits_str[] ="Gbit/s" ; +static const char fdx_str[] ="FDX " ; +static const char hdx_str[] ="HDX " ; +/* autoneg is latest param in default string, so add '\n' */ +static const char autoneg_str[] ="Autoneg\n" ; +static const char fixed_str[] ="Fixed\n" ;Please put an empty line after variables.
<...>
Quoted 19 lines
+/**
+ * Format link status to textual representation. This function threats all
+ * special values likeETH_SPEED_NUM_UNKNOWN,ETH_LINK_DOWNetc. and convert
+ * them to textual representation.
+ *
+ * @param str
+ * A pointer to a string to be filled with textual representation of
+ * device status.
+ * @param len
+ * Length of available memory at 'str' string.
+ * @param fmt+ * Format string which allow to format link status. If NULL is provided + * , default formatting will be applied. + * Following specifiers are available: + * - '%M' link speed in Mbits/s + * - '%G' link speed in Gbits/s + * - '%S' link status. e.g. Up or Down + * - '%A' link autonegotiation state + * - '%D' link duplex stateQuoted 1 line
+ * @param link
It should be '
eth_link' otherwise doxygen is complaining.lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2351
Quoted 9 lines
+ * Link status provided by
rte_eth_link_getfunction
+ * @return
+ * - Number of bytes written to str array. In case of error, -1 is returned.
+ *
+ */lib/librte_ethdev/rte_ethdev.h +4
-0+__rte_experimental +int rte_eth_link_strf(char *str, size_t len, const char *const fmt, +const struct rte_eth_link *eth_link); +For the API name, I guess 'strf' is for 'stringify' but what do you think about '
rte_eth_link_to_str()', I think more clear and simpler.
Re: [dpdk-dev] [PATCH v7 02/25] ethdev: add a link status text representation
Quoted 86 lines
Subject: Re: [PATCH v7 02/25] ethdev: add a link status text representation
10.07.2020 16:06, Yigit, Ferruh пишет:
Quoted 75 lines · Ivan Dyukov
Quoted 4 lines
This commit add function which treat link status structure and format it to text representation.
Signed-off-by Ivan Dyukov <[email protected]><...>
Quoted 68 lines
lib/librte_ethdev/rte_ethdev.c +68
-0+static int +rte_eth_link_strf_parser (char *str,size_t len,const char *const fmt, +const struct rte_eth_link *link) { +size_t offset =0 ; +const char *fmt_cur = fmt; +char *str_cur = str; +double gbits = (double )link->link_speed /1000. ; +static const char autoneg_str[] ="Autoneg" ; +static const char fixed_str[] ="Fixed" ; +static const char fdx_str[] ="FDX" ; +static const char hdx_str[] ="HDX" ; +static const char unknown_str[] ="Unknown" ; +static const char up_str[] ="Up" ; +static const char down_str[] ="Down" ; +char gbits_str[20 ]; +char mbits_str[20 ]; + +/* preformat complex formatting to easily concatinate it further */ +snprintf (mbits_str,sizeof (mbits_str),"%u" , link->link_speed); +snprintf (gbits_str,sizeof (gbits_str),"%.1f" , gbits); +/* init str before formatting */ + str[0 ] =0 ; +while (*fmt_cur) { +/* check str bounds */ +if (offset > (len -1 )) { + str[len -1 ] ='\0' ; +return -1 ; + } +if (*fmt_cur =='%' ) { +/* set null terminator to current position, +* it's required for strlcat +*/ + *str_cur ='\0' ; +switch (*++fmt_cur) { +/* Speed in Mbits/s */ +case 'M' : +if (link->link_speed == +ETH_SPEED_NUM_UNKNOWN ) + offset =strlcat (str, unknown_str, + len); +else + offset =strlcat (str, mbits_str, len); +break ; +/* Speed in Gbits/s */ +case 'G' : +if (link->link_speed == +ETH_SPEED_NUM_UNKNOWN ) + offset =strlcat (str, unknown_str, + len); +else + offset =strlcat (str, gbits_str, len); +break ; +/* Link status */ +case 'S' : + offset =strlcat (str, link->link_status ? + up_str : down_str, len); +break ; +/* Link autoneg */ +case 'A' : + offset =strlcat (str, link->link_autoneg ? + autoneg_str : fixed_str, len); +break ; +/* Link duplex */ +case 'D' : + offset =strlcat (str, link->link_duplex ? + fdx_str : hdx_str, len); +break ; +/* ignore unknown specifier */ Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2459
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +5
-0+default : + *str_cur ='%' ; + offset++; + fmt_cur--; +break ;What do you think ignoring the unknown specifiers and keep continue processing the string, instead of break? Just keep unknown specifier as it is in the output string.
Quoted 3 lines
yep. it's exactly what code do. break exit from the switch but not from string processing. I have unit tests for this case. They work fine. Please review unit tests and send me more cases if they need to be tested.
yes it does as you explained, I miss read it, so it is good, please ignore this comment.
Re: [dpdk-dev] [PATCH v7 02/25] ethdev: add a link status text representation
In reply to Ivan Dyukov10/07/2020 09:02, Ivan Dyukov:
Quoted 2 lines
This commit add function which treat link status structure and format it to text representation.
It is missing an explanation about why it is required. Which problem is it solving?
Quoted 1 line
Signed-off-by Ivan Dyukov <[email protected]>
I'm surprised there is not so much review on this patch.
[...]
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2302
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.h +4
-0+/** +* print formatted link status to stdout. This function threats all +* special values like ETH_SPEED_NUM_UNKNOWN, ETH_LINK_DOWN etc. and convert +* them to textual representation.
I don't understand the need for this function.
If needed, the application can send the output of rte_eth_link_strf() to fprintf or a log function.
Quoted 16 lines
+ *
+ * @param fmt+ * Format string which allow to format link status. If NULL is provided + * , default formatting will be applied. + * Following specifiers are available: + * - '%M' link speed in Mbits/s + * - '%G' link speed in Gbits/s + * - '%S' link status. e.g. Up or Down + * - '%A' link autonegotiation state + * - '%D' link duplex state+ * @param link
+ * Link status provided byrte_eth_link_getfunction
+ * @return
+ * - Number of bytes written to stdout. In case of error, -1 is returned.
+ *
+ */
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2324
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.h +6
-0+__rte_experimental +int rte_eth_link_printf(const char *const fmt, +const struct rte_eth_link *link); + +/** +* Format link status to textual representation. This function threats all
not "threats"
Quoted 11 lines
+ * special values like
ETH_SPEED_NUM_UNKNOWN,ETH_LINK_DOWNetc. and convert
+ * them to textual representation.
+ *
+ * @param str
+ * A pointer to a string to be filled with textual representation of
+ * device status.
+ * @param len
+ * Length of available memory at 'str' string.
+ * @param fmt
+ * Format string which allow to format link status. If NULL is provided
+ * , default formatting will be applied.
Please do not start a line with a comma,
it should be ending the previous line, like here ;) Even better: start the new sentence on a new line.
Quoted 6 lines
+ * Following specifiers are available:
+ * - '%M' link speed in Mbits/s + * - '%G' link speed in Gbits/s + * - '%S' link status. e.g. Up or Down + * - '%A' link autonegotiation state + * - '%D' link duplex state
These specifiers look OK.
Quoted 4 lines
+ * @param link
+ * Link status provided byrte_eth_link_getfunction
+ * @return
+ * - Number of bytes written to str array. In case of error, -1 is returned.
Better to have error case on a separate line.
Quoted 5 lines
+ *
+ */lib/librte_ethdev/rte_ethdev.h +3
-0+__rte_experimental +int rte_eth_link_strf(char *str, size_t len, const char *const fmt, +const struct rte_eth_link *eth_link);
PATCH v7 3/25 app: UNKNOWN link speed print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- app/proc-info/main.c | 9 +++------ app/test-pipeline/init.c | 11 +++++------ app/test-pmd/config.c | 20 ++++++++++++-------- app/test-pmd/testpmd.c | 9 +-------- app/test/test_pmd_perf.c | 17 +++++++---------- 5 files changed, 28 insertions(+), 38 deletions(-)
app/proc-info/main.c +3 -6
@@ -685,12 +685,9 @@ show_port(void)printf ("Link get failed (port %u): %s\n" , i,rte_strerror (-ret)); }else { -printf ("\t -- link speed %d duplex %d," -" auto neg %d status %d\n" , - link.link_speed, - link.link_duplex, - link.link_autoneg, - link.link_status); +rte_eth_link_printf ("\t -- link speed: %M, duplex: %D," +" auto neg: %A, status: %S\n" , + &link); }printf ("\t -- promiscuous (%d)\n" ,rte_eth_promiscuous_get (i));
app/test-pipeline/init.c +5 -6
@@ -155,7 +155,7 @@ static voidapp_ports_check_link (void) {uint32_t all_ports_up, i; - +char link_status_text[50 ]; all_ports_up =1 ;for (i =0 ; i < app.n_ports; i++) {
@@ -173,12 +173,11 @@ app_ports_check_link(void) all_ports_up =0 ;continue ; } - -RTE_LOG (INFO ,USER1 ,"Port %u (%u Gbps) %s\n" , +rte_eth_link_strf (link_status_text,50 ,"(%G Gbps) %S" , + &link); +RTE_LOG (INFO ,USER1 ,"Port %u %s\n" , port, - link.link_speed /1000 , - link.link_status ?"UP" :"DOWN" ); - + link_status_text);if (link.link_status ==ETH_LINK_DOWN ) all_ports_up =0 ; }
app/test-pmd/config.c +12 -8
@@ -604,10 +604,9 @@ port_infos_display(portid_t port_id) }else printf ("\nmemory allocation on the socket: %u" ,port->socket_id); -printf ("\nLink status: %s\n" , (link.link_status) ? ("up" ) : ("down" )); -printf ("Link speed: %u Mbps\n" , (unsigned ) link.link_speed); -printf ("Link duplex: %s\n" , (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_printf ("\nLink status: %S\n" +"Link speed: %M Mbps\n" +"Link duplex: %D\n" , &link);if (!rte_eth_dev_get_mtu (port_id, &mtu))printf ("MTU: %u\n" , mtu);
@@ -730,6 +729,8 @@ port_summary_display(portid_t port_id)struct rte_eth_link link;struct rte_eth_dev_info dev_info;char name[RTE_ETH_NAME_MAX_LEN ]; +char status_text[6 ]; +char speed_text[12 ];int ret;if (port_id_is_invalid (port_id,ENABLED_WARN )) {
@@ -750,12 +751,14 @@ port_summary_display(portid_t port_id)if (ret !=0 )return ; -printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n" , +rte_eth_link_strf (status_text,6 ,"%S" , &link); +rte_eth_link_strf (speed_text,12 ,"%M" , &link); +printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %sMbps\n" , port_id, mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ], name, - dev_info.driver_name, (link.link_status) ? ("up" ) : ("down" ), - (unsigned int ) link.link_speed); + dev_info.driver_name, status_text, + speed_text); }void
@@ -3899,7 +3902,8 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate) ret =eth_link_get_nowait_print_err (port_id, &link);if (ret <0 )return 1 ; -if (rate > link.link_speed) { +if (link.link_speed !=ETH_SPEED_NUM_UNKNOWN && + rate > link.link_speed) {printf ("Invalid rate value:%u bigger than link speed: %u\n" , rate, link.link_speed);return 1 ;
app/test-pmd/testpmd.c +1 -8
@@ -3010,14 +3010,7 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_printf (NULL , &link);continue ; }/* clear all_ports_up flag if any link down */
app/test/test_pmd_perf.c +7 -10
@@ -126,6 +126,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status[50 ];printf ("Checking link statuses...\n" );fflush (stdout);
@@ -146,16 +147,12 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -if (link_mbps ==0 ) - link_mbps = link.link_speed; - }else -printf ("Port %d Link Down\n" , portid); +if (link.link_status && link_mbps ==0 ) + link_mbps = link.link_speed; + +rte_eth_link_strf (link_status,50 ,NULL , + &link); +printf ("Port %d %s\n" , portid, link_status);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v7 4/25 doc: update sample app with unknown speed
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- doc/guides/sample_app_ug/link_status_intr.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
doc/guides/sample_app_ug/link_status_intr.rst +5 -5
@@ -158,6 +158,7 @@ An example callback function that has been written as indicated below. { struct rte_eth_link link; int ret; + char link_status[200]; RTE_SET_USED(param);
@@ -169,11 +170,10 @@ An example callback function that has been written as indicated below. if (ret < 0) { printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret)); - } else if (link.link_status) { - printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); - } else - printf("Port %d Link Down\n\n", port_id); + } else { + rte_eth_link_strf(link_status, 200, NULL, &link); + printf("Port %d %s\n\n", port_id, link_status); + } } This function is called when a link status interrupt is present for the right port.
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v7 04/25] doc: update sample app with unknown speed
10/07/2020 09:02, Ivan Dyukov:
Quoted 7 lines
Add usage of
rte_eth_link_strffunction to example applicationsSigned-off-by Ivan Dyukov <[email protected]>--- doc/guides/sample_app_ug/link_status_intr.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
This one reason why I don't like code in docs.
Anyway, this patch can be merged in previous one, updating apps.
PATCH v7 5/25 net/ixgbe: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available
--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -5
@@ -4300,11 +4300,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case IXGBE_LINK_SPEED_100_FULL :
Signature · 1 line
2.17.1
PATCH v7 6/25 net/i40e: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/i40e/i40e_ethdev.c | 5 ++++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_ethdev.c +4 -1
@@ -2891,7 +2891,10 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link, link->link_speed =ETH_SPEED_NUM_40G ;break ;default : - link->link_speed =ETH_SPEED_NUM_NONE ; +if (link->link_status) + link->link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + link->link_speed =ETH_SPEED_NUM_NONE ;break ; } }
drivers/net/i40e/i40e_ethdev_vf.c +5 -5
@@ -2163,15 +2163,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_speed =ETH_SPEED_NUM_40G ;break ;default : - new_link.link_speed =ETH_SPEED_NUM_NONE ; +if (vf->link_up) + new_link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + new_link.link_speed =ETH_SPEED_NUM_NONE ;break ; }/* full duplex only */ new_link.link_duplex =ETH_LINK_FULL_DUPLEX ; - new_link.link_status = vf->link_up && - new_link.link_speed !=ETH_SPEED_NUM_NONE - ?ETH_LINK_UP - :ETH_LINK_DOWN ; + new_link.link_status = vf->link_up ?ETH_LINK_UP :ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds Ð_LINK_SPEED_FIXED );
Signature · 1 line
2.17.1
PATCH v7 7/25 net/ice: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/ice/ice_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +4 -1
@@ -3135,8 +3135,11 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) link.link_speed =ETH_SPEED_NUM_100G ;break ;case ICE_AQ_LINK_SPEED_UNKNOWN : -default :PMD_DRV_LOG (ERR ,"Unknown link speed" ); + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +break ; +default : +PMD_DRV_LOG (ERR ,"None link speed" ); link.link_speed =ETH_SPEED_NUM_NONE ;break ; }
Signature · 1 line
2.17.1
PATCH v7 8/25 examples: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications:
* ipv4_multicast
* l2fwd-jobstats
* l2fwd-keepalive
* l3fwd
* link_status_interrupt
--- examples/ipv4_multicast/main.c | 12 ++++------- examples/l2fwd-jobstats/main.c | 12 ++++------- examples/l2fwd-keepalive/main.c | 12 ++++------- examples/l3fwd/main.c | 12 ++++------- examples/link_status_interrupt/main.c | 30 +++++++++++---------------- 5 files changed, 28 insertions(+), 50 deletions(-)
examples/ipv4_multicast/main.c +4 -8
@@ -572,6 +572,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -591,14 +592,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l2fwd-jobstats/main.c +4 -8
@@ -689,6 +689,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -708,14 +709,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l2fwd-keepalive/main.c +4 -8
@@ -453,6 +453,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -472,14 +473,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l3fwd/main.c +4 -8
@@ -810,6 +810,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -833,14 +834,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/link_status_interrupt/main.c +12 -18
@@ -118,6 +118,7 @@ print_stats(void)const char clr[] = {27 ,'[' ,'2' ,'J' ,'\0' };const char topLeft[] = {27 ,'[' ,'1' ,';' ,'1' ,'H' ,'\0' };int link_get_err; +char link_speed_text[16 ];/* Clear screen and move to top left */ printf ("%s%s" , clr, topLeft);
@@ -131,9 +132,10 @@ print_stats(void)memset (&link,0 ,sizeof (link)); link_get_err =rte_eth_link_get_nowait (portid, &link); +rte_eth_link_strf (link_speed_text,16 ,"%M" , &link);printf ("\nStatistics for port %u ------------------------------" "\nLink status: %25s" -"\nLink speed: %26u" +"\nLink speed: %26s" "\nLink duplex: %25s" "\nPackets sent: %24" PRIu64 "\nPackets received: %20"PRIu64
@@ -141,8 +143,7 @@ print_stats(void) portid, link_get_err <0 ?"Link get failed" : (link.link_status ?"Link up" :"Link down" ), - link_get_err <0 ?0 : - (unsigned int )link.link_speed, + link_get_err <0 ?"0" : link_speed_text, link_get_err <0 ?"Link get failed" : (link.link_duplex ==ETH_LINK_FULL_DUPLEX ? \ "full-duplex" : "half-duplex"),
@@ -445,6 +446,7 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, {struct rte_eth_link link;int ret; +char link_status_text[60 ];RTE_SET_USED (param);RTE_SET_USED (ret_param);
@@ -457,13 +459,8 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, 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, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else -printf ("Port %d Link Down\n\n" , port_id); +rte_eth_link_strf (link_status_text,60 ,NULL , &link); +printf ("Port %d %s\n" , port_id, link_status_text);return 0 ; }
@@ -478,6 +475,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -497,14 +495,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v7 9/25 examples/bbdev_app: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/bbdev_app/main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
examples/bbdev_app/main.c +3 -5
@@ -313,6 +313,7 @@ check_port_link_status(uint16_t port_id)uint8_t count;struct rte_eth_link link;int link_get_err = -EINVAL ; +char link_status_text[60 ];printf ("\nChecking link status." );fflush (stdout);
@@ -323,11 +324,8 @@ check_port_link_status(uint16_t port_id) link_get_err =rte_eth_link_get_nowait (port_id, &link);if (link_get_err >=0 && link.link_status) { -const char *dp = (link.link_duplex == -ETH_LINK_FULL_DUPLEX ) ? -"full-duplex" :"half-duplex" ; -printf ("\nPort %u Link Up - speed %u Mbps - %s\n" , - port_id, link.link_speed, dp); +rte_eth_link_strf (link_status_text,60 ,NULL , &link); +printf ("\nPort %u %s" , port_id, link_status_text);return 0 ; }printf ("." );
Signature · 1 line
2.17.1
PATCH v7 10/25 examples/ioat: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ioat/ioatfwd.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/ioat/ioatfwd.c +5 -8
@@ -700,6 +700,7 @@ check_link_status(uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret, link_status =0 ; +char link_status_text[60 ];printf ("\nChecking link status\n" );RTE_ETH_FOREACH_DEV (portid) {
@@ -715,15 +716,11 @@ check_link_status(uint32_t port_mask) }/* Print link status */ -if (link.link_status) { -printf ( -"Port %d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_strf (link_status_text,60 ,NULL , &link); +printf ("Port %d %s" , portid, link_status_text); + +if (link.link_status) link_status =1 ; - }else -printf ("Port %d Link Down\n" , portid); }return link_status; }
Signature · 1 line
2.17.1
PATCH v7 11/25 examples/ip_*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications:
* ip_fragmentation
* ip_reassembly
* l3fwd-acl
--- examples/ip_fragmentation/main.c | 13 +++++-------- examples/ip_reassembly/main.c | 12 ++++-------- examples/l3fwd-acl/main.c | 12 ++++-------- 3 files changed, 13 insertions(+), 24 deletions(-)
examples/ip_fragmentation/main.c +5 -8
@@ -593,6 +593,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -612,14 +613,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/ip_reassembly/main.c +4 -8
@@ -712,6 +712,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -731,14 +732,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l3fwd-acl/main.c +4 -8
@@ -1815,6 +1815,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1834,14 +1835,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v7 12/25 examples/ip_pipeline: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ip_pipeline/cli.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
examples/ip_pipeline/cli.c +7 -5
@@ -249,7 +249,8 @@ print_link_info(struct link *link, char *out, size_t out_size)struct rte_eth_link eth_link;uint16_t mtu;int ret; - +char link_speed_text[16 ]; +char link_status_text[10 ];memset (&stats,0 ,sizeof (stats));rte_eth_stats_get (link->port_id, &stats);
@@ -268,18 +269,19 @@ print_link_info(struct link *link, char *out, size_t out_size) }rte_eth_dev_get_mtu (link->port_id, &mtu); - +rte_eth_link_strf (link_speed_text,16 ,"%M" , ð_link); +rte_eth_link_strf (link_status_text,10 ,"%S" , ð_link); snprintf(out, out_size, "\n" "%s: flags=<%s> mtu %u\n" "\tether %02X:%02X:%02X:%02X:%02X:%02X rxqueues %u txqueues %u\n" - "\tport# %u speed %u Mbps\n" + "\tport# %u speed %s Mbps\n" "\tRX packets %" PRIu64" bytes %" PRIu64"\n" "\tRX errors %" PRIu64" missed %" PRIu64" no-mbuf %" PRIu64"\n" "\tTX packets %" PRIu64" bytes %" PRIu64"\n" "\tTX errors %" PRIu64"\n", link->name, - eth_link.link_status == 0 ? "DOWN" : "UP", + link_status_text, mtu, mac_addr.addr_bytes[0], mac_addr.addr_bytes[1], mac_addr.addr_bytes[2], mac_addr.addr_bytes[3],
@@ -287,7 +289,7 @@ print_link_info(struct link *link, char *out, size_t out_size) link->n_rxq, link->n_txq, link->port_id, - eth_link.link_speed, + link_speed_text, stats.ipackets, stats.ibytes, stats.ierrors,
Signature · 1 line
2.17.1
PATCH v7 13/25 examples/ipsec-secgw: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ipsec-secgw/ipsec-secgw.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +4 -8
@@ -1775,6 +1775,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1794,14 +1795,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v7 14/25 examples/kni: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/kni/main.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
examples/kni/main.c +9 -17
@@ -661,6 +661,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status\n" );fflush (stdout);
@@ -680,14 +681,9 @@ 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 %uMbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
@@ -717,19 +713,15 @@ check_all_ports_link_status(uint32_t port_mask)static void log_link_state (struct rte_kni *kni,int prev,struct rte_eth_link *link) { +char link_status_text[60 ];if (kni ==NULL || link ==NULL )return ; -if (prev ==ETH_LINK_DOWN && link->link_status ==ETH_LINK_UP ) { -RTE_LOG (INFO ,APP ,"%s NIC Link is Up %d Mbps %s %s.\n" , +rte_eth_link_strf (link_status_text,60 ,NULL , link); +if (prev != link->link_status) +RTE_LOG (INFO ,APP ,"%s NIC %s" ,rte_kni_get_name (kni), - link->link_speed, - link->link_autoneg ?"(AutoNeg)" :"(Fixed)" , - link->link_duplex ?"Full Duplex" :"Half Duplex" ); - }else if (prev ==ETH_LINK_UP && link->link_status ==ETH_LINK_DOWN ) { -RTE_LOG (INFO ,APP ,"%s NIC Link is Down.\n" , -rte_kni_get_name (kni)); - } + link_status_text); }/*
Signature · 1 line
2.17.1
PATCH v7 15/25 examples/l2fwd-crypt: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l2fwd-crypto/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/l2fwd-crypto/main.c +4 -8
@@ -1734,6 +1734,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1753,14 +1754,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v7 16/25 examples/l2fwd-event: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l2fwd-event/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/l2fwd-event/main.c +4 -8
@@ -366,6 +366,7 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc,uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status..." );fflush (stdout);
@@ -389,14 +390,9 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc, }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - port_id, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , port_id); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , port_id, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v7 17/25 examples/l2fwd: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l2fwd/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/l2fwd/main.c +4 -8
@@ -571,6 +571,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -594,14 +595,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v7 18/25 examples/l3fwd-graph: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l3fwd-graph/main.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
examples/l3fwd-graph/main.c +4 -10
@@ -599,6 +599,7 @@ check_all_ports_link_status(uint32_t port_mask)struct rte_eth_link link;uint16_t portid;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -623,16 +624,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex == -ETH_LINK_FULL_DUPLEX ) - ? ("full-duplex" ) - : ("half-duplex\n" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* Clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v7 19/25 examples/l3fwd-power: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l3fwd-power/main.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
examples/l3fwd-power/main.c +4 -9
@@ -1945,6 +1945,7 @@ check_all_ports_link_status(uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1964,15 +1965,9 @@ 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" , (uint8_t )portid, - (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - (uint8_t )portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v7 20/25 examples/multi_proc*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- .../client_server_mp/mp_server/init.c | 14 +++++--------- examples/multi_process/symmetric_mp/main.c | 12 ++++-------- 2 files changed, 9 insertions(+), 17 deletions(-)
examples/multi_process/client_server_mp/mp_server/init.c +5 -9
@@ -185,6 +185,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -204,15 +205,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , ports->id[portid], - (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - (uint8_t )ports->id[portid]); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , (uint8_t )ports->id[portid], + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/multi_process/symmetric_mp/main.c +4 -8
@@ -365,6 +365,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -384,14 +385,9 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v7 21/25 examples/ntb: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ntb/ntb_fwd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
examples/ntb/ntb_fwd.c +5 -5
@@ -729,6 +729,7 @@ start_pkt_fwd(void)struct rte_eth_link eth_link;uint32_t lcore_id;int ret, i; +char link_status_text[60 ]; ret =ntb_fwd_config_setup ();if (ret <0 ) {
@@ -747,11 +748,10 @@ start_pkt_fwd(void)return ; }if (eth_link.link_status) { -printf ("Eth%u Link Up. Speed %u Mbps - %s\n" , - eth_port_id, eth_link.link_speed, - (eth_link.link_duplex == -ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Eth%u %s" , eth_port_id, + link_status_text);break ; } }
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v7 21/25] examples/ntb: new link status print format
Quoted 45 lines
-----Original Message-----
From: Ivan Dyukov <[email protected]>
Sent: Friday, July 10, 2020 8:02 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; Zhao1, Wei <[email protected]>; Guo, Jia <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Lu, Wenzhuo <[email protected]>; [email protected]; [email protected]; Chautru, Nicolas <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; Dumitrescu, Cristian <[email protected]>; Nicolau, Radu <[email protected]>; [email protected]; Doherty, Declan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Hunt, David <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Wu, Jingjing <[email protected]>; Mcnamara, John <[email protected]>; Singh, Jasvinder <[email protected]>; Marohn, Byron <[email protected]>; Wang, Yipeng1 <[email protected]>
Subject: [PATCH v7 21/25] examples/ntb: new link status print formatAdd usage of
rte_eth_link_strffunction to example applicationsSigned-off-by Ivan Dyukov <[email protected]>--- examples/ntb/ntb_fwd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)examples/ntb/ntb_fwd.c index renamed from examples/ntb/ntb_fwd.c +0
-0
eba8ebf9f..84fe374c4100644examples/ntb/ntb_fwd.c +1
-0@@ -729,6 +729,7 @@ start_pkt_fwd(void)struct rte_eth_link eth_link;uint32_t lcore_id;int ret, i; +char link_status_text[60 ]; ret =ntb_fwd_config_setup ();if (ret <0 ) {@@ -747,11 +748,10 @@ start_pkt_fwd(void)return ;
examples/ntb/ntb_fwd.c start_pkt_fwd(void) · line 753
Quoted 10 lines
examples/ntb/ntb_fwd.c +2
-5}if (eth_link.link_status) { - printf("Eth%u Link Up. Speed %u Mbps - %s\n", - eth_port_id, eth_link.link_speed, - (eth_link.link_duplex == -ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); + rte_eth_link_strf(link_status_text, 60, NULL, + &link);
s/link/eth_link/
.../examples/ntb/ntb_fwd.c:752:11: error: passing argument 4 of ‘rte_eth_link_strf’ from incompatible pointer type [-Werror=incompatible-pointer-types]
752 | &link);
| ^~~~~
| |
| int (*)(const char *, const char *)Quoted 7 lines
examples/ntb/ntb_fwd.c +2
-0+printf ("Eth%u %s" , eth_port_id, + link_status_text);break ; }}
--
2.17.1
PATCH v7 22/25 example/performance*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/performance-thread/l3fwd-thread/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/performance-thread/l3fwd-thread/main.c +4 -8
@@ -3433,6 +3433,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -3452,14 +3453,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v7 23/25 examples/qos_sched: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/qos_sched/init.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
examples/qos_sched/init.c +2 -8
@@ -160,14 +160,8 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)"rte_eth_link_get: err=%d, port=%u: %s\n" , ret, portid, rte_strerror(-ret)); -if (link.link_status) { -printf (" Link Up - speed %u Mbps - %s\n" , - (uint32_t ) link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else { -printf (" Link Down\n" ); - } +rte_eth_link_printf (NULL , &link); + ret =rte_eth_promiscuous_enable (portid);if (ret !=0 ) rte_exit(EXIT_FAILURE,
Signature · 1 line
2.17.1
PATCH v7 24/25 examples/server_nod*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/server_node_efd/server/init.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
examples/server_node_efd/server/init.c +5 -10
@@ -247,6 +247,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -266,16 +267,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , - info->id[portid], - link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - info->id[portid]); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , info->id[portid], + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v7 25/25 examples/vm_power_*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/vm_power_manager/main.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
examples/vm_power_manager/main.c +5 -9
@@ -244,6 +244,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[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -267,15 +268,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_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v7 0/25] ethdev: allow unknown link speed
In reply to Ivan DyukovThere are still comments in this patchset which is doing two things:
1/ declare unknown speed
2/ format link infos
Could we merge the first part in 20.08-rc1,
while waiting to complete the second part in -rc2 or 20.11? How much both parts are related?
Re: [dpdk-dev] [PATCH v7 0/25] ethdev: allow unknown link speed
Quoted 10 lines
Subject: Re: [dpdk-dev] [PATCH v7 0/25] ethdev: allow unknown link speed
There are still comments in this patchset which is doing two things:
1/ declare unknown speed
2/ format link infosCould we merge the first part in 20.08-rc1, while waiting to complete the second part in -rc2 or 20.11?
How much both parts are related?
+1 to get the (1), but this will lead UNKNOWN speed printed as UINT_MAX in the logs, this is what (2) is fixing.
If we say printing UNKNOWN speed as UINT_MAX for this release is acceptable, I am OK to get only (1).
Re: [dpdk-dev] [PATCH v7 0/25] ethdev: allow unknown link speed
10/07/2020 17:47, Yigit, Ferruh:
Quoted 6 lines
Quoted 6 lines
Subject: Re: [dpdk-dev] [PATCH v7 0/25] ethdev: allow unknown link speed
There are still comments in this patchset which is doing two things:
1/ declare unknown speed
2/ format link infos
Quoted 8 lines
Quoted 4 lines
Could we merge the first part in 20.08-rc1, while waiting to complete the second part in -rc2 or 20.11?
How much both parts are related?+1 to get the (1), but this will lead UNKNOWN speed printed as
UINT_MAXin the logs, this is what (2) is fixing.If we say printing UNKNOWN speed as
UINT_MAXfor this release is acceptable, I am OK to get only (1).
I think it's better to wait to have everything ready for 20.11.
Re: [dpdk-dev] [PATCH v7 0/25] ethdev: allow unknown link speed
In reply to Thomas Monjalon10.07.2020 18:02, Thomas Monjalon пишет:
Quoted 3 lines
There are still comments in this patchset which is doing two things:
1/ declare unknown speed
2/ format link infos
3/ update drivers with unknown speed.
this patchset contains only Intel drivers. remaining drivers will be provided later.
Quoted 7 lines
Could we merge the first part in 20.08-rc1,
while waiting to complete the second part in -rc2 or 20.11? How much both parts are related?
v8 cover ethdev: allow unknown link speed
In reply to Ivan DyukovMAINTAINERS | 1 + app/proc-info/main.c | 9 +- app/test-pipeline/init.c | 11 ++- app/test-pmd/config.c | 20 +++-- app/test-pmd/testpmd.c | 9 +- app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app/test/test_pmd_perf.c | 17 ++-- doc/guides/sample_app_ug/link_status_intr.rst | 10 +-- drivers/net/i40e/i40e_ethdev.c | 5 +- drivers/net/i40e/i40e_ethdev_vf.c | 10 +-- drivers/net/ice/ice_ethdev.c | 5 +- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +- examples/bbdev_app/main.c | 8 +- examples/ioat/ioatfwd.c | 13 ++- examples/ip_fragmentation/main.c | 13 ++- examples/ip_pipeline/cli.c | 12 +-- examples/ip_reassembly/main.c | 12 +-- examples/ipsec-secgw/ipsec-secgw.c | 12 +-- examples/ipv4_multicast/main.c | 12 +-- examples/kni/main.c | 26 ++---- examples/l2fwd-crypto/main.c | 12 +-- examples/l2fwd-event/main.c | 12 +-- examples/l2fwd-jobstats/main.c | 12 +-- examples/l2fwd-keepalive/main.c | 12 +-- examples/l2fwd/main.c | 12 +-- examples/l3fwd-acl/main.c | 12 +-- examples/l3fwd-graph/main.c | 14 +-- examples/l3fwd-power/main.c | 13 +-- examples/l3fwd/main.c | 12 +-- examples/link_status_interrupt/main.c | 30 +++---- examples/multi_process/client_server_mp/mp_server/init.c | 14 ++- examples/multi_process/symmetric_mp/main.c | 12 +-- examples/ntb/ntb_fwd.c | 10 +-- examples/performance-thread/l3fwd-thread/main.c | 12 +-- examples/qos_sched/init.c | 10 +-- examples/server_node_efd/server/init.c | 15 ++-- examples/vm_power_manager/main.c | 14 ++- lib/librte_ethdev/rte_ethdev.c | 174 ++++++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 76 ++++++++++++++--- lib/librte_ethdev/rte_ethdev_version.map | 4 + 42 files changed, 715 insertions(+), 282 deletions(-)
v8 changes:
* rename rte_eth_link_strf to rte_eth_link_to_str
* refactor rte_eth_link_to_str according to review comments
* fix codestyle
* fix commit message in 02 patch
* fix compile error in ntb application
* merge "app" and "doc" commits
v7 changes:
* fix meson build
* change _strf function. now it does not fails in case of unknown specifiers like %d. it just copy it to target string.
* remove invalid_fmt unit test.
* add unknown specifier test.
* fix codestyle
v6 changes:
* fix spelling in comments according to checkpatch warning
v5 changes:
* rename rte_eth_link_format to rte_eth_link_strf
* add '\n' to default strings
* update remaining examples. patch with subj 'examples: new link status print format' contains examples which have no maintainers. TBD:
update remaining nic drivers with 'unknown' speed. It should be provided in separate patchset.
v4 changes:
* refactor rte_eth_link_format using strlcat func instead of snprintf
* added new checks to unit tests
* few minor fixes according review comments
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v3 changes:
* remove rte_eth_link_prepare_text function
* add rte_eth_link_format and rte_eth_link_printf functions
* added unit tests for rte_eth_link_format function
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v2 changes:
* add function which format link status to textual representation
* update drivers for Intel nics with 'unknown' speed
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
PATCH v8 1/24 ethdev: allow unknown link speed
From: Thomas Monjalon <[email protected]>
When querying the link information, the link status is a mandatory major information.
Other boolean values are supposed to be accurate:
- duplex mode (half/full)
- negotiation (auto/fixed)
This API update is making explicit that the link speed information is optional.
The value ETH_SPEED_NUM_NONE (0) was already part of the API. The value ETH_SPEED_NUM_UNKNOWN (infinite) is added to cover two different cases:
- speed is not known by the driver
- device is virtual
--- lib/librte_ethdev/rte_ethdev.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
lib/librte_ethdev/rte_ethdev.h +10 -10
@@ -303,6 +303,7 @@ struct rte_eth_stats {#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ #define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ #define ETH_SPEED_NUM_200G 200000/**< 200 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN UINT32_MAX/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
@@ -2262,15 +2263,16 @@ int rte_eth_allmulticast_disable(uint16_t port_id);int rte_eth_allmulticast_get (uint16_t port_id);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It might need -* to wait up to 9 seconds in it. +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). +* +* It might need to wait up to 9 seconds. +* @see rte_eth_link_get_nowait. * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
@@ -2279,15 +2281,13 @@ int rte_eth_allmulticast_get(uint16_t port_id);int rte_eth_link_get (uint16_t port_id,struct rte_eth_link *link);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait -* version of rte_eth_link_get(). +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
Signature · 1 line
2.17.1
PATCH v8 2/24 ethdev: add a link status text representation
In reply to Ivan Dyukovlink status structure keeps complicated values which are hard to represent to end user. e.g. link_speed has INT_MAX value which means that speed is unknown. To simplify processing of the values in application, new dpdk function is introduced.
This commit adds function which treat link status structure and format it to text representation.
--- MAINTAINERS | 1 + app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 306 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 174 +++++++++++++ lib/librte_ethdev/rte_ethdev.h | 56 +++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + 7 files changed, 546 insertions(+) create mode 100644 app/test/test_ethdev_link.c
MAINTAINERS +1 -0
@@ -393,6 +393,7 @@ T: git://dpdk.org/next/dpdk-next-net F: lib/librte_ethdev/ F: devtools/test-null.sh F: doc/guides/prog_guide/switch_representation.rst +F: app/test/test_ethdev* Flow API M: Ori Kam <[email protected]>
app/test/Makefile +3 -0
@@ -251,6 +251,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c test_ipsec_perf.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c + +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c + ifeq ($(CONFIG_RTE_LIBRTE_IPSEC),y) LDLIBS += -lrte_ipsec endif
app/test/meson.build +2 -0
@@ -39,6 +39,7 @@ test_sources = files('commands.c', 'test_efd.c', 'test_efd_perf.c', 'test_errno.c', + 'test_ethdev_link.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',
@@ -199,6 +200,7 @@ fast_tests = [ ['eal_flags_misc_autotest', false], ['eal_fs_autotest', true], ['errno_autotest', true], + ['ethdev_link_status', true], ['event_ring_autotest', true], ['fib_autotest', true], ['fib6_autotest', true],
app/test/test_ethdev_link.c new file +306 -0
306 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.c +174 -0
180 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.h +56 -0
62 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +4 -0
@@ -241,4 +241,8 @@ EXPERIMENTAL { __rte_ethdev_trace_rx_burst; __rte_ethdev_trace_tx_burst; rte_flow_get_aged_flows; + + # added in 20.08 + rte_eth_link_to_str; + rte_eth_link_printf; };
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v8 02/24] ethdev: add a link status text representation
11/07/2020 12:43, Ivan Dyukov:
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2322
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +3
-0+__rte_experimental +int rte_eth_link_printf(const char *const fmt, +const struct rte_eth_link *eth_link);
Maybe I missed your reply,
I still don't understand the need for this function.
Re: [dpdk-dev] [PATCH v8 02/24] ethdev: add a link status text representation
11.07.2020 14:27, Thomas Monjalon пишет:
Quoted 11 lines
11/07/2020 12:43, Ivan Dyukov:
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2322
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +3
-0+__rte_experimental +int rte_eth_link_printf(const char *const fmt, +const struct rte_eth_link *eth_link);Maybe I missed your reply,
I still don't understand the need for this function.
I used it few times in apps in this patchset. It allows to avoid code duplication in examples. i.e. declare array, call rte_eth_link_to_str, call printf.
It's simple and usefull function. Why not?
Re: [dpdk-dev] [PATCH v8 02/24] ethdev: add a link status text representation
11/07/2020 20:58, Ivan Dyukov:
Quoted 9 lines
11.07.2020 14:27, Thomas Monjalon пишет:
Quoted 8 lines
11/07/2020 12:43, Ivan Dyukov:
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2322
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +3
-0+__rte_experimental +int rte_eth_link_printf(const char *const fmt, +const struct rte_eth_link *eth_link);Maybe I missed your reply,
I still don't understand the need for this function.
Quoted 5 lines
I used it few times in apps in this patchset. It allows to avoid code duplication in examples. i.e. declare array, call
rte_eth_link_to_str, call printf.It's simple and usefull function. Why not?
Why not is not a good justification :)
We must avoid adding too much in the API.
Re: [dpdk-dev] [PATCH v8 02/24] ethdev: add a link status text representation
Quoted 10 lines · On Sun, 12 Jul 2020 09:35:23 +0200 Thomas Monjalon <[email protected]> wrote:
11/07/2020 20:58, Ivan Dyukov:
Quoted 9 lines
11.07.2020 14:27, Thomas Monjalon пишет:
Quoted 8 lines
11/07/2020 12:43, Ivan Dyukov:
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2322
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +3
-0+__rte_experimental +int rte_eth_link_printf(const char *const fmt, +const struct rte_eth_link *eth_link);Maybe I missed your reply,
I still don't understand the need for this function.
Quoted 10 lines
Quoted 5 lines
I used it few times in apps in this patchset. It allows to avoid code duplication in examples. i.e. declare array, call
rte_eth_link_to_str, call printf.It's simple and usefull function. Why not?
Why not is not a good justification :)
We must avoid adding too much in the API.
I agree with Thomas, this whole exercise seems like a lot of effort for a log message that probably should be debug only.
The DPDK should adopt the policy that all core and drivers print no log messages by default, and only log at NOTICE or higher in case of error.
Re: [dpdk-dev] [PATCH v8 02/24] ethdev: add a link status textrepresentation
Quoted 22 lines
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Sunday, July 12, 2020 9:21 PMQuoted 16 lines · On Sun, 12 Jul 2020 09:35:23 +0200 Thomas Monjalon <[email protected]> wrote:
11/07/2020 20:58, Ivan Dyukov:
Quoted 14 lines
11.07.2020 14:27, Thomas Monjalon пишет:
Quoted 8 lines
11/07/2020 12:43, Ivan Dyukov:
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2322
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +3
-0+__rte_experimental +int rte_eth_link_printf(const char *const fmt, +const struct rte_eth_link *eth_link);Maybe I missed your reply,
I still don't understand the need for this function.I used it few times in apps in this patchset. It allows to avoid code duplication in examples. i.e. declare array, call
rte_eth_link_to_str, call printf.It's simple and usefull function. Why not?
Quoted 7 lines
Quoted 4 lines
Why not is not a good justification :)
We must avoid adding too much in the API.I agree with Thomas, this whole exercise seems like a lot of effort for a log message that probably should be debug only.
Adding a text formatting function to DPDK is questionable, but that was already discussed and approved. And I agree that it is generic enough to be useful.
However, providing a wrapper function to printf the output from a text formatting function is not useful. The application can do that. Who is to say that stdout is the right output channel for the application anyway... it might as well be a debug log, SYSLOG or something else. Certainly application specific.
Quoted 4 lines
The DPDK should adopt the policy that all core and drivers print no log messages by default, and only log at NOTICE or higher in case of error.
+1
I am totally with Stephen here! Any printf will kill performance. If anything, use the log or trace libraries. And the log library does not exactly provide "data plane performance", so it should be used with extreme caution.
On a side note: It looks like Cisco considers link status change events ERROR severity for operational state changes and NOTICE severity for administrative state changes. Source: https://networklessons.com/cisco/ccie-routing-switching/cisco-ios-syslog-messages
Re: [dpdk-dev] [PATCH v8 02/24] ethdev: add a link status text representation
In reply to Thomas Monjalon12.07.2020 10:35, Thomas Monjalon пишет:
Quoted 10 lines
11/07/2020 20:58, Ivan Dyukov:
Quoted 9 lines
11.07.2020 14:27, Thomas Monjalon пишет:
Quoted 8 lines
11/07/2020 12:43, Ivan Dyukov:
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2322
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +3
-0+__rte_experimental +int rte_eth_link_printf(const char *const fmt, +const struct rte_eth_link *eth_link);Maybe I missed your reply,
I still don't understand the need for this function.
Quoted 6 lines
Quoted 5 lines
I used it few times in apps in this patchset. It allows to avoid code duplication in examples. i.e. declare array, call
rte_eth_link_to_str, call printf.It's simple and usefull function. Why not?
Why not is not a good justification :)
I still don't understand your objections against this tiny shiny function.
Quoted 3 lines
We must avoid adding too much in the API.
I agree that this function is superfluous for DPDK library, but I would note that it's not just 'DPDK library' change, it's 'DPDK library + DPDK examples' change. With this change, the entire code is getting better. The new function adds usefull functionality. It allows to reduce code size and remove duplicates. so technically it's good change but practically I would like to ask maintainers to decide this.
P.S.
I'll we on vacation next two weeks. May be I'll check email but I don't guarantee that.
PATCH v8 3/24 app: UNKNOWN link speed print
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications and docs
--- app/proc-info/main.c | 9 +++------ app/test-pipeline/init.c | 11 +++++----- app/test-pmd/config.c | 20 +++++++++++-------- app/test-pmd/testpmd.c | 9 +-------- app/test/test_pmd_perf.c | 17 +++++++--------- doc/guides/sample_app_ug/link_status_intr.rst | 10 +++++----- 6 files changed, 33 insertions(+), 43 deletions(-)
app/proc-info/main.c +3 -6
@@ -685,12 +685,9 @@ show_port(void)printf ("Link get failed (port %u): %s\n" , i,rte_strerror (-ret)); }else { -printf ("\t -- link speed %d duplex %d," -" auto neg %d status %d\n" , - link.link_speed, - link.link_duplex, - link.link_autoneg, - link.link_status); +rte_eth_link_printf ("\t -- link speed: %M, duplex: %D," +" auto neg: %A, status: %S\n" , + &link); }printf ("\t -- promiscuous (%d)\n" ,rte_eth_promiscuous_get (i));
app/test-pipeline/init.c +5 -6
@@ -155,7 +155,7 @@ static voidapp_ports_check_link (void) {uint32_t all_ports_up, i; - +char link_status_text[50 ]; all_ports_up =1 ;for (i =0 ; i < app.n_ports; i++) {
@@ -173,12 +173,11 @@ app_ports_check_link(void) all_ports_up =0 ;continue ; } - -RTE_LOG (INFO ,USER1 ,"Port %u (%u Gbps) %s\n" , +rte_eth_link_to_str (link_status_text,50 ,"(%G Gbps) %S" , + &link); +RTE_LOG (INFO ,USER1 ,"Port %u %s\n" , port, - link.link_speed /1000 , - link.link_status ?"UP" :"DOWN" ); - + link_status_text);if (link.link_status ==ETH_LINK_DOWN ) all_ports_up =0 ; }
app/test-pmd/config.c +12 -8
@@ -604,10 +604,9 @@ port_infos_display(portid_t port_id) }else printf ("\nmemory allocation on the socket: %u" ,port->socket_id); -printf ("\nLink status: %s\n" , (link.link_status) ? ("up" ) : ("down" )); -printf ("Link speed: %u Mbps\n" , (unsigned ) link.link_speed); -printf ("Link duplex: %s\n" , (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_printf ("\nLink status: %S\n" +"Link speed: %M Mbps\n" +"Link duplex: %D\n" , &link);if (!rte_eth_dev_get_mtu (port_id, &mtu))printf ("MTU: %u\n" , mtu);
@@ -730,6 +729,8 @@ port_summary_display(portid_t port_id)struct rte_eth_link link;struct rte_eth_dev_info dev_info;char name[RTE_ETH_NAME_MAX_LEN ]; +char status_text[6 ]; +char speed_text[12 ];int ret;if (port_id_is_invalid (port_id,ENABLED_WARN )) {
@@ -750,12 +751,14 @@ port_summary_display(portid_t port_id)if (ret !=0 )return ; -printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n" , +rte_eth_link_to_str (status_text,6 ,"%S" , &link); +rte_eth_link_to_str (speed_text,12 ,"%M" , &link); +printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %sMbps\n" , port_id, mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ], name, - dev_info.driver_name, (link.link_status) ? ("up" ) : ("down" ), - (unsigned int ) link.link_speed); + dev_info.driver_name, status_text, + speed_text); }void
@@ -3899,7 +3902,8 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate) ret =eth_link_get_nowait_print_err (port_id, &link);if (ret <0 )return 1 ; -if (rate > link.link_speed) { +if (link.link_speed !=ETH_SPEED_NUM_UNKNOWN && + rate > link.link_speed) {printf ("Invalid rate value:%u bigger than link speed: %u\n" , rate, link.link_speed);return 1 ;
app/test-pmd/testpmd.c +1 -8
@@ -3010,14 +3010,7 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_printf (NULL , &link);continue ; }/* clear all_ports_up flag if any link down */
app/test/test_pmd_perf.c +7 -10
@@ -126,6 +126,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status[50 ];printf ("Checking link statuses...\n" );fflush (stdout);
@@ -146,16 +147,12 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -if (link_mbps ==0 ) - link_mbps = link.link_speed; - }else -printf ("Port %d Link Down\n" , portid); +if (link.link_status && link_mbps ==0 ) + link_mbps = link.link_speed; + +rte_eth_link_to_str (link_status,50 ,NULL , + &link); +printf ("Port %d %s\n" , portid, link_status);continue ; }/* clear all_ports_up flag if any link down */
doc/guides/sample_app_ug/link_status_intr.rst +5 -5
@@ -158,6 +158,7 @@ An example callback function that has been written as indicated below. { struct rte_eth_link link; int ret; + char link_status[200]; RTE_SET_USED(param);
@@ -169,11 +170,10 @@ An example callback function that has been written as indicated below. if (ret < 0) { printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret)); - } else if (link.link_status) { - printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); - } else - printf("Port %d Link Down\n\n", port_id); + } else { + rte_eth_link_to_str(link_status, 200, NULL, &link); + printf("Port %d %s\n\n", port_id, link_status); + } } This function is called when a link status interrupt is present for the right port.
Signature · 1 line
2.17.1
PATCH v8 4/24 net/ixgbe: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available
--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -5
@@ -4300,11 +4300,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case IXGBE_LINK_SPEED_100_FULL :
Signature · 1 line
2.17.1
PATCH v8 5/24 net/i40e: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/i40e/i40e_ethdev.c | 5 ++++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_ethdev.c +4 -1
@@ -2891,7 +2891,10 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link, link->link_speed =ETH_SPEED_NUM_40G ;break ;default : - link->link_speed =ETH_SPEED_NUM_NONE ; +if (link->link_status) + link->link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + link->link_speed =ETH_SPEED_NUM_NONE ;break ; } }
drivers/net/i40e/i40e_ethdev_vf.c +5 -5
@@ -2163,15 +2163,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_speed =ETH_SPEED_NUM_40G ;break ;default : - new_link.link_speed =ETH_SPEED_NUM_NONE ; +if (vf->link_up) + new_link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + new_link.link_speed =ETH_SPEED_NUM_NONE ;break ; }/* full duplex only */ new_link.link_duplex =ETH_LINK_FULL_DUPLEX ; - new_link.link_status = vf->link_up && - new_link.link_speed !=ETH_SPEED_NUM_NONE - ?ETH_LINK_UP - :ETH_LINK_DOWN ; + new_link.link_status = vf->link_up ?ETH_LINK_UP :ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds Ð_LINK_SPEED_FIXED );
Signature · 1 line
2.17.1
PATCH v8 6/24 net/ice: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/ice/ice_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +4 -1
@@ -3135,8 +3135,11 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) link.link_speed =ETH_SPEED_NUM_100G ;break ;case ICE_AQ_LINK_SPEED_UNKNOWN : -default :PMD_DRV_LOG (ERR ,"Unknown link speed" ); + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +break ; +default : +PMD_DRV_LOG (ERR ,"None link speed" ); link.link_speed =ETH_SPEED_NUM_NONE ;break ; }
Signature · 1 line
2.17.1
PATCH v8 7/24 examples: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications:
* ipv4_multicast
* l2fwd-jobstats
* l2fwd-keepalive
* l3fwd
* link_status_interrupt
--- examples/ipv4_multicast/main.c | 12 ++++------- examples/l2fwd-jobstats/main.c | 12 ++++------- examples/l2fwd-keepalive/main.c | 12 ++++------- examples/l3fwd/main.c | 12 ++++------- examples/link_status_interrupt/main.c | 30 +++++++++++---------------- 5 files changed, 28 insertions(+), 50 deletions(-)
examples/ipv4_multicast/main.c +4 -8
@@ -572,6 +572,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -591,14 +592,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l2fwd-jobstats/main.c +4 -8
@@ -689,6 +689,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -708,14 +709,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l2fwd-keepalive/main.c +4 -8
@@ -453,6 +453,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -472,14 +473,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l3fwd/main.c +4 -8
@@ -810,6 +810,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -833,14 +834,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/link_status_interrupt/main.c +12 -18
@@ -118,6 +118,7 @@ print_stats(void)const char clr[] = {27 ,'[' ,'2' ,'J' ,'\0' };const char topLeft[] = {27 ,'[' ,'1' ,';' ,'1' ,'H' ,'\0' };int link_get_err; +char link_speed_text[16 ];/* Clear screen and move to top left */ printf ("%s%s" , clr, topLeft);
@@ -131,9 +132,10 @@ print_stats(void)memset (&link,0 ,sizeof (link)); link_get_err =rte_eth_link_get_nowait (portid, &link); +rte_eth_link_to_str (link_speed_text,16 ,"%M" , &link);printf ("\nStatistics for port %u ------------------------------" "\nLink status: %25s" -"\nLink speed: %26u" +"\nLink speed: %26s" "\nLink duplex: %25s" "\nPackets sent: %24" PRIu64 "\nPackets received: %20"PRIu64
@@ -141,8 +143,7 @@ print_stats(void) portid, link_get_err <0 ?"Link get failed" : (link.link_status ?"Link up" :"Link down" ), - link_get_err <0 ?0 : - (unsigned int )link.link_speed, + link_get_err <0 ?"0" : link_speed_text, link_get_err <0 ?"Link get failed" : (link.link_duplex ==ETH_LINK_FULL_DUPLEX ? \ "full-duplex" : "half-duplex"),
@@ -445,6 +446,7 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, {struct rte_eth_link link;int ret; +char link_status_text[60 ];RTE_SET_USED (param);RTE_SET_USED (ret_param);
@@ -457,13 +459,8 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, 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, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else -printf ("Port %d Link Down\n\n" , port_id); +rte_eth_link_to_str (link_status_text,60 ,NULL , &link); +printf ("Port %d %s\n" , port_id, link_status_text);return 0 ; }
@@ -478,6 +475,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -497,14 +495,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v8 8/24 examples/bbdev_app: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/bbdev_app/main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
examples/bbdev_app/main.c +3 -5
@@ -313,6 +313,7 @@ check_port_link_status(uint16_t port_id)uint8_t count;struct rte_eth_link link;int link_get_err = -EINVAL ; +char link_status_text[60 ];printf ("\nChecking link status." );fflush (stdout);
@@ -323,11 +324,8 @@ check_port_link_status(uint16_t port_id) link_get_err =rte_eth_link_get_nowait (port_id, &link);if (link_get_err >=0 && link.link_status) { -const char *dp = (link.link_duplex == -ETH_LINK_FULL_DUPLEX ) ? -"full-duplex" :"half-duplex" ; -printf ("\nPort %u Link Up - speed %u Mbps - %s\n" , - port_id, link.link_speed, dp); +rte_eth_link_to_str (link_status_text,60 ,NULL , &link); +printf ("\nPort %u %s" , port_id, link_status_text);return 0 ; }printf ("." );
Signature · 1 line
2.17.1
PATCH v8 9/24 examples/ioat: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/ioat/ioatfwd.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/ioat/ioatfwd.c +5 -8
@@ -700,6 +700,7 @@ check_link_status(uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret, link_status =0 ; +char link_status_text[60 ];printf ("\nChecking link status\n" );RTE_ETH_FOREACH_DEV (portid) {
@@ -715,15 +716,11 @@ check_link_status(uint32_t port_mask) }/* Print link status */ -if (link.link_status) { -printf ( -"Port %d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_to_str (link_status_text,60 ,NULL , &link); +printf ("Port %d %s" , portid, link_status_text); + +if (link.link_status) link_status =1 ; - }else -printf ("Port %d Link Down\n" , portid); }return link_status; }
Signature · 1 line
2.17.1
PATCH v8 10/24 examples/ip_*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications:
* ip_fragmentation
* ip_reassembly
* l3fwd-acl
--- examples/ip_fragmentation/main.c | 13 +++++-------- examples/ip_reassembly/main.c | 12 ++++-------- examples/l3fwd-acl/main.c | 12 ++++-------- 3 files changed, 13 insertions(+), 24 deletions(-)
examples/ip_fragmentation/main.c +5 -8
@@ -593,6 +593,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -612,14 +613,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/ip_reassembly/main.c +4 -8
@@ -712,6 +712,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -731,14 +732,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l3fwd-acl/main.c +4 -8
@@ -1815,6 +1815,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1834,14 +1835,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v8 11/24 examples/ip_pipeline: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/ip_pipeline/cli.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
examples/ip_pipeline/cli.c +7 -5
@@ -249,7 +249,8 @@ print_link_info(struct link *link, char *out, size_t out_size)struct rte_eth_link eth_link;uint16_t mtu;int ret; - +char link_speed_text[16 ]; +char link_status_text[10 ];memset (&stats,0 ,sizeof (stats));rte_eth_stats_get (link->port_id, &stats);
@@ -268,18 +269,19 @@ print_link_info(struct link *link, char *out, size_t out_size) }rte_eth_dev_get_mtu (link->port_id, &mtu); - +rte_eth_link_to_str (link_speed_text,16 ,"%M" , ð_link); +rte_eth_link_to_str (link_status_text,10 ,"%S" , ð_link); snprintf(out, out_size, "\n" "%s: flags=<%s> mtu %u\n" "\tether %02X:%02X:%02X:%02X:%02X:%02X rxqueues %u txqueues %u\n" - "\tport# %u speed %u Mbps\n" + "\tport# %u speed %s Mbps\n" "\tRX packets %" PRIu64" bytes %" PRIu64"\n" "\tRX errors %" PRIu64" missed %" PRIu64" no-mbuf %" PRIu64"\n" "\tTX packets %" PRIu64" bytes %" PRIu64"\n" "\tTX errors %" PRIu64"\n", link->name, - eth_link.link_status == 0 ? "DOWN" : "UP", + link_status_text, mtu, mac_addr.addr_bytes[0], mac_addr.addr_bytes[1], mac_addr.addr_bytes[2], mac_addr.addr_bytes[3],
@@ -287,7 +289,7 @@ print_link_info(struct link *link, char *out, size_t out_size) link->n_rxq, link->n_txq, link->port_id, - eth_link.link_speed, + link_speed_text, stats.ipackets, stats.ibytes, stats.ierrors,
Signature · 1 line
2.17.1
PATCH v8 12/24 examples/ipsec-secgw: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/ipsec-secgw/ipsec-secgw.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +4 -8
@@ -1775,6 +1775,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1794,14 +1795,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v8 12/24] examples/ipsec-secgw: new link status print format
Hi Ivan,
Quoted 13 lines
Add usage of
rte_eth_link_to_strfunction to example applicationSigned-off-by Ivan Dyukov <[email protected]>--- examples/ipsec-secgw/ipsec-secgw.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)examples/ipsec-secgw/ipsec-secgw.c +0
-0
examples/ipsec-secgw/ipsec-secgw.c check_all_ports_link_status(uint32_t port_mask) · line 1778
Quoted 4 lines
examples/ipsec-secgw/ipsec-secgw.c +1
-0@@ -1775,6 +1775,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];
Wonder where this magic number (60) came from?
Probably makes sense to have define for it,
(RTE_ETHDEV_LINK_STATUS_MAX_LEN or so),
as it seems to be used all over the places.
Quoted 6 lines
examples/ipsec-secgw/ipsec-secgw.c +0
-0printf ("\nChecking link status" );fflush (stdout);@@ -1794,14 +1795,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */
examples/ipsec-secgw/ipsec-secgw.c check_all_ports_link_status(uint32_t port_mask) · line 1798
Quoted 10 lines
examples/ipsec-secgw/ipsec-secgw.c +1
-8if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up - speed %u Mbps -%s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); + rte_eth_link_to_str(link_status_text, 60, NULL,
s/60/sizeof((link_status_text)/
?
Quoted 7 lines
examples/ipsec-secgw/ipsec-secgw.c +2
-1+ &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */ --2.17.1
PATCH v8 13/24 examples/kni: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/kni/main.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
examples/kni/main.c +9 -17
@@ -661,6 +661,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status\n" );fflush (stdout);
@@ -680,14 +681,9 @@ 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 %uMbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
@@ -717,19 +713,15 @@ check_all_ports_link_status(uint32_t port_mask)static void log_link_state (struct rte_kni *kni,int prev,struct rte_eth_link *link) { +char link_status_text[60 ];if (kni ==NULL || link ==NULL )return ; -if (prev ==ETH_LINK_DOWN && link->link_status ==ETH_LINK_UP ) { -RTE_LOG (INFO ,APP ,"%s NIC Link is Up %d Mbps %s %s.\n" , +rte_eth_link_to_str (link_status_text,60 ,NULL , link); +if (prev != link->link_status) +RTE_LOG (INFO ,APP ,"%s NIC %s" ,rte_kni_get_name (kni), - link->link_speed, - link->link_autoneg ?"(AutoNeg)" :"(Fixed)" , - link->link_duplex ?"Full Duplex" :"Half Duplex" ); - }else if (prev ==ETH_LINK_UP && link->link_status ==ETH_LINK_DOWN ) { -RTE_LOG (INFO ,APP ,"%s NIC Link is Down.\n" , -rte_kni_get_name (kni)); - } + link_status_text); }/*
Signature · 1 line
2.17.1
PATCH v8 14/24 examples/l2fwd-crypt: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l2fwd-crypto/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/l2fwd-crypto/main.c +4 -8
@@ -1734,6 +1734,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1753,14 +1754,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v8 15/24 examples/l2fwd-event: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l2fwd-event/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/l2fwd-event/main.c +4 -8
@@ -366,6 +366,7 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc,uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status..." );fflush (stdout);
@@ -389,14 +390,9 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc, }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - port_id, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , port_id); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , port_id, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v8 16/24 examples/l2fwd: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l2fwd/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/l2fwd/main.c +4 -8
@@ -571,6 +571,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -594,14 +595,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v8 17/24 examples/l3fwd-graph: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l3fwd-graph/main.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
examples/l3fwd-graph/main.c +4 -10
@@ -599,6 +599,7 @@ check_all_ports_link_status(uint32_t port_mask)struct rte_eth_link link;uint16_t portid;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -623,16 +624,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex == -ETH_LINK_FULL_DUPLEX ) - ? ("full-duplex" ) - : ("half-duplex\n" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* Clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v8 18/24 examples/l3fwd-power: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l3fwd-power/main.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
examples/l3fwd-power/main.c +4 -9
@@ -1945,6 +1945,7 @@ check_all_ports_link_status(uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1964,15 +1965,9 @@ 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" , (uint8_t )portid, - (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - (uint8_t )portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v8 19/24 examples/multi_proc*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- .../client_server_mp/mp_server/init.c | 14 +++++--------- examples/multi_process/symmetric_mp/main.c | 12 ++++-------- 2 files changed, 9 insertions(+), 17 deletions(-)
examples/multi_process/client_server_mp/mp_server/init.c +5 -9
@@ -185,6 +185,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -204,15 +205,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , ports->id[portid], - (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - (uint8_t )ports->id[portid]); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , (uint8_t )ports->id[portid], + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/multi_process/symmetric_mp/main.c +4 -8
@@ -365,6 +365,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -384,14 +385,9 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v8 20/24 examples/ntb: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ntb/ntb_fwd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
examples/ntb/ntb_fwd.c +5 -5
@@ -729,6 +729,7 @@ start_pkt_fwd(void)struct rte_eth_link eth_link;uint32_t lcore_id;int ret, i; +char link_status_text[60 ]; ret =ntb_fwd_config_setup ();if (ret <0 ) {
@@ -747,11 +748,10 @@ start_pkt_fwd(void)return ; }if (eth_link.link_status) { -printf ("Eth%u Link Up. Speed %u Mbps - %s\n" , - eth_port_id, eth_link.link_speed, - (eth_link.link_duplex == -ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_to_str (link_status_text,60 ,NULL , + ð_link); +printf ("Eth%u %s" , eth_port_id, + link_status_text);break ; } }
Signature · 1 line
2.17.1
PATCH v8 21/24 example/performance*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/performance-thread/l3fwd-thread/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/performance-thread/l3fwd-thread/main.c +4 -8
@@ -3433,6 +3433,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -3452,14 +3453,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v8 22/24 examples/qos_sched: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/qos_sched/init.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
examples/qos_sched/init.c +2 -8
@@ -160,14 +160,8 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)"rte_eth_link_get: err=%d, port=%u: %s\n" , ret, portid, rte_strerror(-ret)); -if (link.link_status) { -printf (" Link Up - speed %u Mbps - %s\n" , - (uint32_t ) link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else { -printf (" Link Down\n" ); - } +rte_eth_link_printf (NULL , &link); + ret =rte_eth_promiscuous_enable (portid);if (ret !=0 ) rte_exit(EXIT_FAILURE,
Signature · 1 line
2.17.1
PATCH v8 23/24 examples/server_nod*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/server_node_efd/server/init.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
examples/server_node_efd/server/init.c +5 -10
@@ -247,6 +247,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -266,16 +267,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , - info->id[portid], - link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - info->id[portid]); +rte_eth_link_to_str (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , info->id[portid], + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v8 24/24 examples/vm_power_*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/vm_power_manager/main.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
examples/vm_power_manager/main.c +5 -9
@@ -244,6 +244,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[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -267,15 +268,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,60 ,NULL , + &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
v9 cover ethdev: allow unknown link speed
In reply to Ivan DyukovMAINTAINERS | 1 + app/proc-info/main.c | 9 +- app/test-pipeline/init.c | 11 ++- app/test-pmd/config.c | 20 +++-- app/test-pmd/testpmd.c | 9 +- app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app/test/test_pmd_perf.c | 17 ++-- doc/guides/sample_app_ug/link_status_intr.rst | 10 +-- drivers/net/i40e/i40e_ethdev.c | 5 +- drivers/net/i40e/i40e_ethdev_vf.c | 10 +-- drivers/net/ice/ice_ethdev.c | 5 +- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +- examples/bbdev_app/main.c | 8 +- examples/ioat/ioatfwd.c | 13 ++- examples/ip_fragmentation/main.c | 13 ++- examples/ip_pipeline/cli.c | 12 +-- examples/ip_reassembly/main.c | 12 +-- examples/ipsec-secgw/ipsec-secgw.c | 12 +-- examples/ipv4_multicast/main.c | 12 +-- examples/kni/main.c | 26 ++---- examples/l2fwd-crypto/main.c | 12 +-- examples/l2fwd-event/main.c | 12 +-- examples/l2fwd-jobstats/main.c | 12 +-- examples/l2fwd-keepalive/main.c | 12 +-- examples/l2fwd/main.c | 12 +-- examples/l3fwd-acl/main.c | 12 +-- examples/l3fwd-graph/main.c | 14 +-- examples/l3fwd-power/main.c | 13 +-- examples/l3fwd/main.c | 12 +-- examples/link_status_interrupt/main.c | 30 +++---- examples/multi_process/client_server_mp/mp_server/init.c | 14 ++- examples/multi_process/symmetric_mp/main.c | 12 +-- examples/ntb/ntb_fwd.c | 10 +-- examples/performance-thread/l3fwd-thread/main.c | 12 +-- examples/qos_sched/init.c | 10 +-- examples/server_node_efd/server/init.c | 15 ++-- examples/vm_power_manager/main.c | 14 ++- lib/librte_ethdev/rte_ethdev.c | 174 ++++++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 76 ++++++++++++++--- lib/librte_ethdev/rte_ethdev_version.map | 4 + 42 files changed, 715 insertions(+), 282 deletions(-)
v9 changes:
* remove rte_eth_link_printf function
* add ETH_LINK_MAX_STR_LEN definition
* add usage of ETH_LINK_MAX_STR_LEN in examples
v8 changes:
* rename rte_eth_link_strf to rte_eth_link_to_str
* refactor rte_eth_link_to_str according to review comments
* fix codestyle
* fix commit message in 02 patch
* fix compile error in ntb application
* merge "app" and "doc" commits
v7 changes:
* fix meson build
* change _strf function. now it does not fails in case of unknown specifiers like %d. it just copy it to target string.
* remove invalid_fmt unit test.
* add unknown specifier test.
* fix codestyle
v6 changes:
* fix spelling in comments according to checkpatch warning
v5 changes:
* rename rte_eth_link_format to rte_eth_link_strf
* add '\n' to default strings
* update remaining examples. patch with subj 'examples: new link status print format' contains examples which have no maintainers. TBD:
update remaining nic drivers with 'unknown' speed. It should be provided in separate patchset.
v4 changes:
* refactor rte_eth_link_format using strlcat func instead of snprintf
* added new checks to unit tests
* few minor fixes according review comments
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v3 changes:
* remove rte_eth_link_prepare_text function
* add rte_eth_link_format and rte_eth_link_printf functions
* added unit tests for rte_eth_link_format function
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v2 changes:
* add function which format link status to textual representation
* update drivers for Intel nics with 'unknown' speed
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
PATCH v9 1/24 ethdev: allow unknown link speed
From: Thomas Monjalon <[email protected]>
When querying the link information, the link status is a mandatory major information.
Other boolean values are supposed to be accurate:
- duplex mode (half/full)
- negotiation (auto/fixed)
This API update is making explicit that the link speed information is optional.
The value ETH_SPEED_NUM_NONE (0) was already part of the API. The value ETH_SPEED_NUM_UNKNOWN (infinite) is added to cover two different cases:
- speed is not known by the driver
- device is virtual
--- lib/librte_ethdev/rte_ethdev.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
lib/librte_ethdev/rte_ethdev.h +10 -10
@@ -303,6 +303,7 @@ struct rte_eth_stats {#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ #define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ #define ETH_SPEED_NUM_200G 200000/**< 200 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN UINT32_MAX/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
@@ -2262,15 +2263,16 @@ int rte_eth_allmulticast_disable(uint16_t port_id);int rte_eth_allmulticast_get (uint16_t port_id);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It might need -* to wait up to 9 seconds in it. +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). +* +* It might need to wait up to 9 seconds. +* @see rte_eth_link_get_nowait. * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
@@ -2279,15 +2281,13 @@ int rte_eth_allmulticast_get(uint16_t port_id);int rte_eth_link_get (uint16_t port_id,struct rte_eth_link *link);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait -* version of rte_eth_link_get(). +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
Signature · 1 line
2.17.1
PATCH v9 2/24 ethdev: add a link status text representation
In reply to Ivan DyukovLink status structure keeps complicated values which are hard to represent to end user. e.g. link_speed has INT_MAX value which means that speed is unknown, link_duplex equal to 0 means 'half-duplex' etc. To simplify processing of the values in application, new dpdk function is introduced.
This commit adds function which treat link status structure and format it to text representation. User may create custom link status string using format string. If format string is NULL, the function construct standard link status string.
--- MAINTAINERS | 1 + app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 315 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 160 ++++++++++++ lib/librte_ethdev/rte_ethdev.h | 32 +++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 7 files changed, 516 insertions(+) create mode 100644 app/test/test_ethdev_link.c
MAINTAINERS +1 -0
@@ -393,6 +393,7 @@ T: git://dpdk.org/next/dpdk-next-net F: lib/librte_ethdev/ F: devtools/test-null.sh F: doc/guides/prog_guide/switch_representation.rst +F: app/test/test_ethdev* Flow API M: Ori Kam <[email protected]>
app/test/Makefile +3 -0
@@ -251,6 +251,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c test_ipsec_perf.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c + +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c + ifeq ($(CONFIG_RTE_LIBRTE_IPSEC),y) LDLIBS += -lrte_ipsec endif
app/test/meson.build +2 -0
@@ -39,6 +39,7 @@ test_sources = files('commands.c', 'test_efd.c', 'test_efd_perf.c', 'test_errno.c', + 'test_ethdev_link.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',
@@ -199,6 +200,7 @@ fast_tests = [ ['eal_flags_misc_autotest', false], ['eal_fs_autotest', true], ['errno_autotest', true], + ['ethdev_link_status', true], ['event_ring_autotest', true], ['fib_autotest', true], ['fib6_autotest', true],
app/test/test_ethdev_link.c new file +315 -0
315 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.c +160 -0
166 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.h +32 -0
@@ -323,6 +323,7 @@ struct rte_eth_link {#define ETH_LINK_UP 1/**< Link is up (see link_status). */ #define ETH_LINK_FIXED 0/**< No autonegotiation (see link_autoneg). */ #define ETH_LINK_AUTONEG 1/**< Autonegotiated (see link_autoneg). */ +#define ETH_LINK_MAX_STR_LEN 60/**< Max length of default link string. */ /** * A structure used to configure the ring threshold registers of an RX/TX
@@ -2295,6 +2296,37 @@ int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);*/ int rte_eth_link_get_nowait (uint16_t port_id,struct rte_eth_link *link); +/** +* Format link status to textual representation. This function treats all +* special values like ETH_SPEED_NUM_UNKNOWN, ETH_LINK_DOWN etc. and convert +* them to textual representation. +* +* @param str +* A pointer to a string to be filled with textual representation of +* device status. At least ETH_LINK_MAX_STR_LEN bytes should be allocated to +* store default link status text. +* @param len +* Length of available memory at 'str' string. +* @param fmt +* Format string which allows to format link status. +* If NULL is provided, default formatting will be applied. +* Following specifiers are available: +* - '%M' link speed in Mbits/s +* - '%G' link speed in Gbits/s +* - '%S' link status. e.g. Up or Down +* - '%A' link autonegotiation state +* - '%D' link duplex state +* @param eth_link +* Link status provided by rte_eth_link_get function +* @return +* - Number of bytes written to str array. +* - (-EINVAL) if size of target buffer is too small for the string +* +*/ +__rte_experimental +int rte_eth_link_to_str(char *str, size_t len, const char *const fmt, +const struct rte_eth_link *eth_link); +/** * Retrieve the general I/O statistics of an Ethernet device. *
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -241,4 +241,7 @@ EXPERIMENTAL { __rte_ethdev_trace_rx_burst; __rte_ethdev_trace_tx_burst; rte_flow_get_aged_flows; + + # added in 20.11 + rte_eth_link_to_str; };
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v9 02/24] ethdev: add a link status text representation
Quoted 6 lines · Ivan Dyukov
Link status structure keeps complicated values which are hard to represent to end user. e.g.
link_speedhasINT_MAXvalue which means that speed is unknown,link_duplexequal to 0 means 'half-duplex' etc. To simplify processing of the values in application, new dpdk function is introduced.
Quoted 6 lines
This commit adds function which treat link status structure and format it to text representation. User may create custom link status string using format string. If format string is NULL, the function construct standard link status string.
Signed-off-by Ivan Dyukov <[email protected]>
Hello Ivan,
I don't see much difference for this patch, from what I read in previous thread on the principle it does not seem motivated enough?
I'd have a few nits on the implementation, but on the principle: I think this can be an incentive to get properly formatted port status strings.
The API is a little awkward however, and it is definitely complex to maintain a format-based function. I think we could do without.
I've tried a smaller alternative.
+ simpler to use.
+ simpler to maintain.
+ safer in general.
+ no need to declare local string to store intermediate output.
- one ugly macro.
@Thomas, Stephen: would something like this be easier to accept in librte_ethdev?
index d79699e2ed..9d72a0b70e 100644
examples/ip_pipeline/cli.c +3 -3
@@ -273,13 +273,13 @@ print_link_info(struct link *link, char *out, size_t out_size)"\n" "%s: flags=<%s> mtu %u\n" "\tether %02X:%02X:%02X:%02X:%02X:%02X rxqueues %u txqueues %u\n" -"\tport# %u speed %u Mbps\n" +"\tport# %u speed %s\n" "\tRX packets %" PRIu64" bytes %" PRIu64"\n" "\tRX errors %" PRIu64" missed %" PRIu64" no-mbuf %" PRIu64"\n" "\tTX packets %" PRIu64" bytes %" PRIu64"\n" "\tTX errors %" PRIu64"\n" , link->name, - eth_link.link_status ==0 ?"DOWN" :"UP" , +rte_eth_link_status_str (eth_link.link_status), mtu, mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], mac_addr.addr_bytes[2], mac_addr.addr_bytes[3],
@@ -287,7 +287,7 @@ print_link_info(struct link *link, char *out, size_t out_size) link->n_rxq, link->n_txq, link->port_id, - eth_link.link_speed, +rte_eth_link_speed_str (eth_link.link_speed), stats.ipackets, stats.ibytes, stats.ierrors,
examples/ipv4_multicast/main.c +2 -8
@@ -591,14 +591,8 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +printf ("Port %s " RTE_ETH_LINK_FMT "\n" , +RTE_ETH_LINK_STR (link));continue ; }/* clear all_ports_up flag if any link down */
lib/librte_ethdev/rte_ethdev.h +96 -0
102 lines not on this page · raw message
Signature · 1 line
Gaëtan
Re: [dpdk-dev] [PATCH v9 02/24] ethdev: add a link status text representation
11.08.2020 14:02, Gaëtan Rivet пишет:
Quoted 24 lines · Ivan Dyukov
Quoted 6 lines
Link status structure keeps complicated values which are hard to represent to end user. e.g.
link_speedhasINT_MAXvalue which means that speed is unknown,link_duplexequal to 0 means 'half-duplex' etc. To simplify processing of the values in application, new dpdk function is introduced.Quoted 6 lines
This commit adds function which treat link status structure and format it to text representation. User may create custom link status string using format string. If format string is NULL, the function construct standard link status string.
Signed-off-by Ivan Dyukov <[email protected]>Hello Ivan,
I don't see much difference for this patch, from what I read in previous thread on the principle it does not seem motivated enough?
I'd have a few nits on the implementation, but on the principle: I think this can be an incentive to get properly formatted port status strings.
The API is a little awkward however, and it is definitely complex to maintain a format-based function. I think we could do without.
Quoted 8 lines
I've tried a smaller alternative.
+ simpler to use.
+ simpler to maintain.
+ safer in general.
+ no need to declare local string to store intermediate output.- one ugly macro.
It would be good for all values except link_speed because link speed should be formated using sprintf e.g.
char str[15];
...
char *rte_eth_link_speed_str(uint32_t link_speed) {
if (link_speed == UINT32_MAX)
return "Unknown";
else
snprintf(str,sizeof(str),"%d",link_speed);
return str;
}
so rte_eth_link_speed_str will require some global string, not local.
Quoted 161 lines
@Thomas, Stephen: would something like this be easier to accept in
librte_ethdev?index
d79699e2ed..9d72a0b70e100644examples/ip_pipeline/cli.c +3
-3@@ -273,13 +273,13 @@ print_link_info(struct link *link, char *out, size_t out_size)"\n" "%s: flags=<%s> mtu %u\n" "\tether %02X:%02X:%02X:%02X:%02X:%02X rxqueues %u txqueues %u\n" -"\tport# %u speed %u Mbps\n" +"\tport# %u speed %s\n" "\tRX packets %" PRIu64" bytes %" PRIu64"\n" "\tRX errors %" PRIu64" missed %" PRIu64" no-mbuf %" PRIu64"\n" "\tTX packets %" PRIu64" bytes %" PRIu64"\n" "\tTX errors %" PRIu64"\n" , link->name, - eth_link.link_status ==0 ?"DOWN" :"UP" , +rte_eth_link_status_str (eth_link.link_status), mtu, mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], mac_addr.addr_bytes[2], mac_addr.addr_bytes[3],@@ -287,7 +287,7 @@ print_link_info(struct link *link, char *out, size_t out_size) link->n_rxq, link->n_txq, link->port_id, - eth_link.link_speed, +rte_eth_link_speed_str (eth_link.link_speed), stats.ipackets, stats.ibytes, stats.ierrors,examples/ipv4_multicast/main.c +2
-8@@ -591,14 +591,8 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +printf ("Port %s " RTE_ETH_LINK_FMT "\n" , +RTE_ETH_LINK_STR (link));continue ; }/* clear all_ports_up flag if any link down */ lib/librte_ethdev/rte_ethdev.h +96
-0@@ -4993,6 +4993,102 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,return rte_eth_tx_buffer_flush (port_id, queue_id, buffer); } +/** +* Missing: doc. +*/ +static inline const char * +rte_eth_link_speed_str (uint32_t speed) +{ +struct { +const char *str; +uint32_t speed; + } speed_str_map[] = { + {"Unknown" ,ETH_SPEED_NUM_NONE }, + {"10 Mbps" ,ETH_SPEED_NUM_10M }, + {"100 Mbps" ,ETH_SPEED_NUM_100M }, + {"1 Gbps" ,ETH_SPEED_NUM_1G }, + {"2.5 Gbps" ,ETH_SPEED_NUM_2_5G }, + {"5 Gbps" ,ETH_SPEED_NUM_5G }, + {"10 Gbps" ,ETH_SPEED_NUM_10G }, + {"20 Gbps" ,ETH_SPEED_NUM_20G }, + {"25 Gbps" ,ETH_SPEED_NUM_25G }, + {"40 Gbps" ,ETH_SPEED_NUM_40G }, + {"50 Gbps" ,ETH_SPEED_NUM_50G }, + {"56 Gbps" ,ETH_SPEED_NUM_56G }, + {"100 Gbps" ,ETH_SPEED_NUM_100G }, + {"200 Gbps" ,ETH_SPEED_NUM_200G }, + }; +size_t i; + +for (i =0 ; i <RTE_DIM (speed_str_map); i++) { +if (speed == speed_str_map[i].speed) +return speed_str_map[i].str; + } + +return speed_str_map[0 ].str; +} + +/** +* Missing: doc. +*/ +static inline const char * +rte_eth_link_duplex_str (uint16_t duplex) +{ +const char *str[] = { + [0 ] ="HDX" , + [1 ] ="FDX" , + }; + +return str[!!duplex]; +} + +/** +* Missing: doc. +*/ +static inline const char * +rte_eth_link_autoneg_str (uint16_t autoneg) +{ +const char *str[] = { + [0 ] ="Fixed" , + [1 ] ="Autoneg" , + }; + +return str[!!autoneg]; +} + +/** +* Missing: doc. +*/ +static inline const char * +rte_eth_link_status_str (uint16_t status) +{ +const char *str[] = { + [0 ] ="Down" , + [1 ] ="Up" , + }; + +return str[!!status]; +} + +/* internal. */ +#define RTE_ETH_LINK_DOWN_OR_WHAT_ (link, what, sep) \ + ((link).link_status == ETH_LINK_DOWN ? "" : (what)), \ + ((link).link_status == ETH_LINK_DOWN ? "" : (sep)) \ + +/** +* Missing: doc. +*/ +#define RTE_ETH_LINK_FMT "%s%s%s%s%s%s" + +/** +* Missing: doc. +*/ +#define RTE_ETH_LINK_STR (link) \ + ((link).link_status == ETH_LINK_DOWN ? "Link down" : "Link up at "), \ + RTE_ETH_LINK_DOWN_OR_WHAT_(link, rte_eth_link_speed_str((link).link_speed), " "), \ + RTE_ETH_LINK_DOWN_OR_WHAT_(link, rte_eth_link_duplex_str((link).link_duplex), " "), \ + RTE_ETH_LINK_DOWN_OR_WHAT_(link, rte_eth_link_autoneg_str((link).link_autoneg), "") + #ifdef __cplusplus }#endif
Re: [dpdk-dev] [PATCH v9 02/24] ethdev: add a link status text representation
Quoted 49 lines · Ivan Dyukov
11.08.2020 14:02, Gaëtan Rivet пишет:
Quoted 24 lines · Ivan Dyukov
Quoted 6 lines
Link status structure keeps complicated values which are hard to represent to end user. e.g.
link_speedhasINT_MAXvalue which means that speed is unknown,link_duplexequal to 0 means 'half-duplex' etc. To simplify processing of the values in application, new dpdk function is introduced.Quoted 6 lines
This commit adds function which treat link status structure and format it to text representation. User may create custom link status string using format string. If format string is NULL, the function construct standard link status string.
Signed-off-by Ivan Dyukov <[email protected]>Hello Ivan,
I don't see much difference for this patch, from what I read in previous thread on the principle it does not seem motivated enough?
I'd have a few nits on the implementation, but on the principle: I think this can be an incentive to get properly formatted port status strings.
The API is a little awkward however, and it is definitely complex to maintain a format-based function. I think we could do without.
Quoted 8 lines
I've tried a smaller alternative.
+ simpler to use.
+ simpler to maintain.
+ safer in general.
+ no need to declare local string to store intermediate output.- one ugly macro.
It would be good for all values except
link_speedbecause link speed should be formated using sprintf e.g.char str[15];
...
char *rte_eth_link_speed_str(uint32_t
link_speed) {if (
link_speed==UINT32_MAX)return "Unknown";
else
Quoted 7 lines
snprintf(str,sizeof(str),"%d",link_speed);
return str;
}
so
rte_eth_link_speed_strwill require some global string, not local.
Sorry I don't understand your point, the implementation below works?
Quoted 34 lines
Quoted 34 lines
lib/librte_ethdev/rte_ethdev.h +34
-0+/** +* Missing: doc. +*/ +static inline const char * +rte_eth_link_speed_str (uint32_t speed) +{ +struct { +const char *str; +uint32_t speed; + } speed_str_map[] = { + {"Unknown" ,ETH_SPEED_NUM_NONE }, + {"10 Mbps" ,ETH_SPEED_NUM_10M }, + {"100 Mbps" ,ETH_SPEED_NUM_100M }, + {"1 Gbps" ,ETH_SPEED_NUM_1G }, + {"2.5 Gbps" ,ETH_SPEED_NUM_2_5G }, + {"5 Gbps" ,ETH_SPEED_NUM_5G }, + {"10 Gbps" ,ETH_SPEED_NUM_10G }, + {"20 Gbps" ,ETH_SPEED_NUM_20G }, + {"25 Gbps" ,ETH_SPEED_NUM_25G }, + {"40 Gbps" ,ETH_SPEED_NUM_40G }, + {"50 Gbps" ,ETH_SPEED_NUM_50G }, + {"56 Gbps" ,ETH_SPEED_NUM_56G }, + {"100 Gbps" ,ETH_SPEED_NUM_100G }, + {"200 Gbps" ,ETH_SPEED_NUM_200G }, + }; +size_t i; + +for (i =0 ; i <RTE_DIM (speed_str_map); i++) { +if (speed == speed_str_map[i].speed) +return speed_str_map[i].str; + } + +return speed_str_map[0 ].str; +}
Signature · 1 line
Gaëtan
Re: [dpdk-dev] [PATCH v9 02/24] ethdev: add a link status text representation
11.08.2020 15:53, Gaëtan Rivet пишет:
Quoted 49 lines · Ivan Dyukov
Quoted 48 lines
11.08.2020 14:02, Gaëtan Rivet пишет:
Quoted 24 lines · Ivan Dyukov
Quoted 6 lines
Link status structure keeps complicated values which are hard to represent to end user. e.g.
link_speedhasINT_MAXvalue which means that speed is unknown,link_duplexequal to 0 means 'half-duplex' etc. To simplify processing of the values in application, new dpdk function is introduced.Quoted 6 lines
This commit adds function which treat link status structure and format it to text representation. User may create custom link status string using format string. If format string is NULL, the function construct standard link status string.
Signed-off-by Ivan Dyukov <[email protected]>Hello Ivan,
I don't see much difference for this patch, from what I read in previous thread on the principle it does not seem motivated enough?
I'd have a few nits on the implementation, but on the principle: I think this can be an incentive to get properly formatted port status strings.
The API is a little awkward however, and it is definitely complex to maintain a format-based function. I think we could do without.
Quoted 8 lines
I've tried a smaller alternative.
+ simpler to use.
+ simpler to maintain.
+ safer in general.
+ no need to declare local string to store intermediate output.- one ugly macro.
It would be good for all values except
link_speedbecause link speed should be formated using sprintf e.g.char str[15];
...
char *rte_eth_link_speed_str(uint32_t
link_speed) {if (
link_speed==UINT32_MAX)return "Unknown";
else
Quoted 8 lines
Quoted 7 lines
snprintf(str,sizeof(str),"%d",link_speed);
return str;
}
so
rte_eth_link_speed_strwill require some global string, not local.Sorry I don't understand your point, the implementation below works?
Oh. Sorry I missed it. Thanks for clarification. It should work. Let's wait Thomas and Stephen comments.
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
lib/librte_ethdev/rte_ethdev.h +34
-0+/** +* Missing: doc. +*/ +static inline const char * +rte_eth_link_speed_str (uint32_t speed) +{ +struct { +const char *str; +uint32_t speed; + } speed_str_map[] = { + {"Unknown" ,ETH_SPEED_NUM_NONE }, + {"10 Mbps" ,ETH_SPEED_NUM_10M }, + {"100 Mbps" ,ETH_SPEED_NUM_100M }, + {"1 Gbps" ,ETH_SPEED_NUM_1G }, + {"2.5 Gbps" ,ETH_SPEED_NUM_2_5G }, + {"5 Gbps" ,ETH_SPEED_NUM_5G }, + {"10 Gbps" ,ETH_SPEED_NUM_10G }, + {"20 Gbps" ,ETH_SPEED_NUM_20G }, + {"25 Gbps" ,ETH_SPEED_NUM_25G }, + {"40 Gbps" ,ETH_SPEED_NUM_40G }, + {"50 Gbps" ,ETH_SPEED_NUM_50G }, + {"56 Gbps" ,ETH_SPEED_NUM_56G }, + {"100 Gbps" ,ETH_SPEED_NUM_100G }, + {"200 Gbps" ,ETH_SPEED_NUM_200G }, + }; +size_t i; + +for (i =0 ; i <RTE_DIM (speed_str_map); i++) { +if (speed == speed_str_map[i].speed) +return speed_str_map[i].str; + } + +return speed_str_map[0 ].str; +}
Re: [dpdk-dev] [PATCH v9 02/24] ethdev: add a link status text representation
In reply to Ivan DyukovQuoted 6 lines · On Tue, 11 Aug 2020 11:52:21 +0300 Ivan Dyukov <[email protected]> wrote:
Link status structure keeps complicated values which are hard to represent to end user. e.g.
link_speedhasINT_MAXvalue which means that speed is unknown,link_duplexequal to 0 means 'half-duplex' etc. To simplify processing of the values in application, new dpdk function is introduced.
Quoted 6 lines
This commit adds function which treat link status structure and format it to text representation. User may create custom link status string using format string. If format string is NULL, the function construct standard link status string.
Signed-off-by Ivan Dyukov <[email protected]>
Why pander to driver specific link messages?
This should come from core code in one format for all drivers.
Re: [dpdk-dev] [PATCH v9 02/24] ethdev: add a link status text representation
11.08.2020 18:47, Stephen Hemminger пишет:
Quoted 9 lines
Quoted 6 lines · On Tue, 11 Aug 2020 11:52:21 +0300 Ivan Dyukov <[email protected]> wrote:
Link status structure keeps complicated values which are hard to represent to end user. e.g.
link_speedhasINT_MAXvalue which means that speed is unknown,link_duplexequal to 0 means 'half-duplex' etc. To simplify processing of the values in application, new dpdk function is introduced.
Quoted 9 lines
Quoted 6 lines
This commit adds function which treat link status structure and format it to text representation. User may create custom link status string using format string. If format string is NULL, the function construct standard link status string.
Signed-off-by Ivan Dyukov <[email protected]>Why pander to driver specific link messages?
This should come from core code in one format for all drivers.
I'm not sure that I understand your question correctly, but there is no driver specific messages.The function is intended for application usage only, not for drivers. The function has default format of link status, but application can customize it for own needs. We have disscussed it before. some dpdk applications like testpmd has custom status formating which lays on few lines of screen. so the function supports custom link messages just to not break screen layout of applications.
PATCH v9 3/24 app: UNKNOWN link speed print
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications and docs
--- app/proc-info/main.c | 13 ++++++----- app/test-pipeline/init.c | 11 ++++----- app/test-pmd/config.c | 23 ++++++++++++------- app/test-pmd/testpmd.c | 12 ++++------ app/test/test_ethdev_link.c | 6 ++--- app/test/test_pmd_perf.c | 17 ++++++-------- doc/guides/sample_app_ug/link_status_intr.rst | 10 ++++---- 7 files changed, 46 insertions(+), 46 deletions(-)
app/proc-info/main.c +7 -6
@@ -672,6 +672,7 @@ show_port(void)struct rte_eth_dev_info dev_info;struct rte_eth_rxq_info queue_info;struct rte_eth_rss_conf rss_conf; +char link_status_text[100 ];memset (&rss_conf,0 ,sizeof (rss_conf));
@@ -685,12 +686,12 @@ show_port(void)printf ("Link get failed (port %u): %s\n" , i,rte_strerror (-ret)); }else { -printf ("\t -- link speed %d duplex %d," -" auto neg %d status %d\n" , - link.link_speed, - link.link_duplex, - link.link_autoneg, - link.link_status); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text), +"\t -- link speed: %M, duplex: %D," +" auto neg: %A, status: %S\n" , + &link); +printf ("%s" , link_status_text); }printf ("\t -- promiscuous (%d)\n" ,rte_eth_promiscuous_get (i));
app/test-pipeline/init.c +5 -6
@@ -155,7 +155,7 @@ static voidapp_ports_check_link (void) {uint32_t all_ports_up, i; - +char link_status_text[50 ]; all_ports_up =1 ;for (i =0 ; i < app.n_ports; i++) {
@@ -173,12 +173,11 @@ app_ports_check_link(void) all_ports_up =0 ;continue ; } - -RTE_LOG (INFO ,USER1 ,"Port %u (%u Gbps) %s\n" , +rte_eth_link_to_str (link_status_text,sizeof (link_status_text), +"(%G Gbps) %S" , &link); +RTE_LOG (INFO ,USER1 ,"Port %u %s\n" , port, - link.link_speed /1000 , - link.link_status ?"UP" :"DOWN" ); - + link_status_text);if (link.link_status ==ETH_LINK_DOWN ) all_ports_up =0 ; }
app/test-pmd/config.c +15 -8
@@ -564,6 +564,7 @@ port_infos_display(portid_t port_id)char name[RTE_ETH_NAME_MAX_LEN ];int ret;char fw_version[ETHDEV_FWVERS_LEN ]; +char link_status[70 ];if (port_id_is_invalid (port_id,ENABLED_WARN )) {print_valid_ports ();
@@ -604,10 +605,11 @@ port_infos_display(portid_t port_id) }else printf ("\nmemory allocation on the socket: %u" ,port->socket_id); -printf ("\nLink status: %s\n" , (link.link_status) ? ("up" ) : ("down" )); -printf ("Link speed: %u Mbps\n" , (unsigned ) link.link_speed); -printf ("Link duplex: %s\n" , (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_to_str (link_status,sizeof (link_status), +"\nLink status: %S\n" +"Link speed: %M Mbps\n" +"Link duplex: %D\n" , &link); +printf ("%s" , link_status);if (!rte_eth_dev_get_mtu (port_id, &mtu))printf ("MTU: %u\n" , mtu);
@@ -730,6 +732,8 @@ port_summary_display(portid_t port_id)struct rte_eth_link link;struct rte_eth_dev_info dev_info;char name[RTE_ETH_NAME_MAX_LEN ]; +char status_text[6 ]; +char speed_text[12 ];int ret;if (port_id_is_invalid (port_id,ENABLED_WARN )) {
@@ -750,12 +754,14 @@ port_summary_display(portid_t port_id)if (ret !=0 )return ; -printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n" , +rte_eth_link_to_str (status_text,6 ,"%S" , &link); +rte_eth_link_to_str (speed_text,12 ,"%M" , &link); +printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %sMbps\n" , port_id, mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ], name, - dev_info.driver_name, (link.link_status) ? ("up" ) : ("down" ), - (unsigned int ) link.link_speed); + dev_info.driver_name, status_text, + speed_text); }void
@@ -3899,7 +3905,8 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate) ret =eth_link_get_nowait_print_err (port_id, &link);if (ret <0 )return 1 ; -if (rate > link.link_speed) { +if (link.link_speed !=ETH_SPEED_NUM_UNKNOWN && + rate > link.link_speed) {printf ("Invalid rate value:%u bigger than link speed: %u\n" , rate, link.link_speed);return 1 ;
app/test-pmd/testpmd.c +4 -8
@@ -2991,6 +2991,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status[ETH_LINK_MAX_STR_LEN ];printf ("Checking link statuses...\n" );fflush (stdout);
@@ -3010,14 +3011,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status, +sizeof (link_status),NULL , &link); +printf ("Port %d %s\n" , portid, link_status);continue ; }/* clear all_ports_up flag if any link down */
app/test/test_ethdev_link.c +3 -3
@@ -19,7 +19,7 @@ test_link_status_up_default(void) .link_autoneg = ETH_LINK_AUTONEG, .link_duplex = ETH_LINK_FULL_DUPLEX }; -char text[RTE_ETH_LINK_MAX_STR_LEN +1 ]; +char text[ETH_LINK_MAX_STR_LEN +1 ]; ret =rte_eth_link_to_str (text,sizeof (text),NULL , &link_status);RTE_TEST_ASSERT (ret >0 ,"Failed to format default string\n" );
@@ -51,7 +51,7 @@ test_link_status_up_default(void) link_status.link_autoneg =ETH_LINK_AUTONEG ; ret =rte_eth_link_to_str (text,sizeof (text),NULL , &link_status);printf ("Default link up #4:len = %d, %s\n" , ret, text); -RTE_TEST_ASSERT (ret >RTE_ETH_LINK_MAX_STR_LEN , +RTE_TEST_ASSERT (ret <ETH_LINK_MAX_STR_LEN ,"String length exceeds max allowed value\n" );return TEST_SUCCESS ; }
@@ -66,7 +66,7 @@ test_link_status_down_default(void) .link_autoneg = ETH_LINK_AUTONEG, .link_duplex = ETH_LINK_FULL_DUPLEX }; -char text[RTE_ETH_LINK_MAX_STR_LEN ]; +char text[ETH_LINK_MAX_STR_LEN ]; ret =rte_eth_link_to_str (text,sizeof (text),NULL , &link_status);RTE_TEST_ASSERT (ret >0 ,"Failed to format default string\n" );
app/test/test_pmd_perf.c +7 -10
@@ -126,6 +126,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status[ETH_LINK_MAX_STR_LEN ];printf ("Checking link statuses...\n" );fflush (stdout);
@@ -146,16 +147,12 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -if (link_mbps ==0 ) - link_mbps = link.link_speed; - }else -printf ("Port %d Link Down\n" , portid); +if (link.link_status && link_mbps ==0 ) + link_mbps = link.link_speed; + +rte_eth_link_to_str (link_status, +sizeof (link_status),NULL , &link); +printf ("Port %d %s\n" , portid, link_status);continue ; }/* clear all_ports_up flag if any link down */
doc/guides/sample_app_ug/link_status_intr.rst +5 -5
@@ -158,6 +158,7 @@ An example callback function that has been written as indicated below. { struct rte_eth_link link; int ret; + char link_status[RTE_ETH_LINK_MAX_STR_LEN]; RTE_SET_USED(param);
@@ -169,11 +170,10 @@ An example callback function that has been written as indicated below. if (ret < 0) { printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret)); - } else if (link.link_status) { - printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); - } else - printf("Port %d Link Down\n\n", port_id); + } else { + rte_eth_link_to_str(link_status, sizeof(link_status), NULL, &link); + printf("Port %d %s\n\n", port_id, link_status); + } } This function is called when a link status interrupt is present for the right port.
Signature · 1 line
2.17.1
PATCH v9 4/24 net/ixgbe: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available
--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -5
@@ -4300,11 +4300,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case IXGBE_LINK_SPEED_100_FULL :
Signature · 1 line
2.17.1
PATCH v9 5/24 net/i40e: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/i40e/i40e_ethdev.c | 5 ++++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_ethdev.c +4 -1
@@ -2891,7 +2891,10 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link, link->link_speed =ETH_SPEED_NUM_40G ;break ;default : - link->link_speed =ETH_SPEED_NUM_NONE ; +if (link->link_status) + link->link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + link->link_speed =ETH_SPEED_NUM_NONE ;break ; } }
drivers/net/i40e/i40e_ethdev_vf.c +5 -5
@@ -2163,15 +2163,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_speed =ETH_SPEED_NUM_40G ;break ;default : - new_link.link_speed =ETH_SPEED_NUM_NONE ; +if (vf->link_up) + new_link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + new_link.link_speed =ETH_SPEED_NUM_NONE ;break ; }/* full duplex only */ new_link.link_duplex =ETH_LINK_FULL_DUPLEX ; - new_link.link_status = vf->link_up && - new_link.link_speed !=ETH_SPEED_NUM_NONE - ?ETH_LINK_UP - :ETH_LINK_DOWN ; + new_link.link_status = vf->link_up ?ETH_LINK_UP :ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds Ð_LINK_SPEED_FIXED );
Signature · 1 line
2.17.1
PATCH v9 6/24 net/ice: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/ice/ice_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +4 -1
@@ -3135,8 +3135,11 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) link.link_speed =ETH_SPEED_NUM_100G ;break ;case ICE_AQ_LINK_SPEED_UNKNOWN : -default :PMD_DRV_LOG (ERR ,"Unknown link speed" ); + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +break ; +default : +PMD_DRV_LOG (ERR ,"None link speed" ); link.link_speed =ETH_SPEED_NUM_NONE ;break ; }
Signature · 1 line
2.17.1
PATCH v9 7/24 examples: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications:
* ipv4_multicast
* l2fwd-jobstats
* l2fwd-keepalive
* l3fwd
* link_status_interrupt
--- examples/ipv4_multicast/main.c | 14 ++++++------ examples/l2fwd-jobstats/main.c | 13 +++++------ examples/l2fwd-keepalive/main.c | 13 +++++------ examples/l3fwd/main.c | 13 +++++------ examples/link_status_interrupt/main.c | 31 +++++++++++---------------- 5 files changed, 34 insertions(+), 50 deletions(-)
examples/ipv4_multicast/main.c +6 -8
@@ -572,6 +572,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -591,14 +592,11 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , + &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l2fwd-jobstats/main.c +5 -8
@@ -689,6 +689,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -708,14 +709,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l2fwd-keepalive/main.c +5 -8
@@ -453,6 +453,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -472,14 +473,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l3fwd/main.c +5 -8
@@ -810,6 +810,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -833,14 +834,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/link_status_interrupt/main.c +13 -18
@@ -118,6 +118,7 @@ print_stats(void)const char clr[] = {27 ,'[' ,'2' ,'J' ,'\0' };const char topLeft[] = {27 ,'[' ,'1' ,';' ,'1' ,'H' ,'\0' };int link_get_err; +char link_speed_text[16 ];/* Clear screen and move to top left */ printf ("%s%s" , clr, topLeft);
@@ -131,9 +132,10 @@ print_stats(void)memset (&link,0 ,sizeof (link)); link_get_err =rte_eth_link_get_nowait (portid, &link); +rte_eth_link_to_str (link_speed_text,16 ,"%M" , &link);printf ("\nStatistics for port %u ------------------------------" "\nLink status: %25s" -"\nLink speed: %26u" +"\nLink speed: %26s" "\nLink duplex: %25s" "\nPackets sent: %24" PRIu64 "\nPackets received: %20"PRIu64
@@ -141,8 +143,7 @@ print_stats(void) portid, link_get_err <0 ?"Link get failed" : (link.link_status ?"Link up" :"Link down" ), - link_get_err <0 ?0 : - (unsigned int )link.link_speed, + link_get_err <0 ?"0" : link_speed_text, link_get_err <0 ?"Link get failed" : (link.link_duplex ==ETH_LINK_FULL_DUPLEX ? \ "full-duplex" : "half-duplex"),
@@ -445,6 +446,7 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, {struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];RTE_SET_USED (param);RTE_SET_USED (ret_param);
@@ -457,13 +459,9 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, 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, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else -printf ("Port %d Link Down\n\n" , port_id); +rte_eth_link_to_str (link_status_text,sizeof (link_status_text), +NULL , &link); +printf ("Port %d %s\n\n" , port_id, link_status_text);return 0 ; }
@@ -478,6 +476,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -497,14 +496,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v9 8/24 examples/bbdev_app: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/bbdev_app/main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
examples/bbdev_app/main.c +4 -5
@@ -313,6 +313,7 @@ check_port_link_status(uint16_t port_id)uint8_t count;struct rte_eth_link link;int link_get_err = -EINVAL ; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status." );fflush (stdout);
@@ -323,11 +324,9 @@ check_port_link_status(uint16_t port_id) link_get_err =rte_eth_link_get_nowait (port_id, &link);if (link_get_err >=0 && link.link_status) { -const char *dp = (link.link_duplex == -ETH_LINK_FULL_DUPLEX ) ? -"full-duplex" :"half-duplex" ; -printf ("\nPort %u Link Up - speed %u Mbps - %s\n" , - port_id, link.link_speed, dp); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("\nPort %u %s\n" , port_id, link_status_text);return 0 ; }printf ("." );
Signature · 1 line
2.17.1
PATCH v9 9/24 examples/ioat: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/ioat/ioatfwd.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
examples/ioat/ioatfwd.c +6 -8
@@ -700,6 +700,7 @@ check_link_status(uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret, link_status =0 ; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status\n" );RTE_ETH_FOREACH_DEV (portid) {
@@ -715,15 +716,12 @@ check_link_status(uint32_t port_mask) }/* Print link status */ -if (link.link_status) { -printf ( -"Port %d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , portid, link_status_text); + +if (link.link_status) link_status =1 ; - }else -printf ("Port %d Link Down\n" , portid); }return link_status; }
Signature · 1 line
2.17.1
PATCH v9 10/24 examples/ip_*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications:
* ip_fragmentation
* ip_reassembly
* l3fwd-acl
--- examples/ip_fragmentation/main.c | 13 +++++-------- examples/ip_reassembly/main.c | 13 +++++-------- examples/l3fwd-acl/main.c | 13 +++++-------- 3 files changed, 15 insertions(+), 24 deletions(-)
examples/ip_fragmentation/main.c +5 -8
@@ -593,6 +593,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -612,14 +613,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/ip_reassembly/main.c +5 -8
@@ -712,6 +712,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -731,14 +732,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l3fwd-acl/main.c +5 -8
@@ -1815,6 +1815,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -1834,14 +1835,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v9 11/24 examples/ip_pipeline: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/ip_pipeline/cli.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
examples/ip_pipeline/cli.c +7 -5
@@ -249,7 +249,8 @@ print_link_info(struct link *link, char *out, size_t out_size)struct rte_eth_link eth_link;uint16_t mtu;int ret; - +char link_speed_text[16 ]; +char link_status_text[10 ];memset (&stats,0 ,sizeof (stats));rte_eth_stats_get (link->port_id, &stats);
@@ -268,18 +269,19 @@ print_link_info(struct link *link, char *out, size_t out_size) }rte_eth_dev_get_mtu (link->port_id, &mtu); - +rte_eth_link_to_str (link_speed_text,16 ,"%M" , ð_link); +rte_eth_link_to_str (link_status_text,10 ,"%S" , ð_link); snprintf(out, out_size, "\n" "%s: flags=<%s> mtu %u\n" "\tether %02X:%02X:%02X:%02X:%02X:%02X rxqueues %u txqueues %u\n" - "\tport# %u speed %u Mbps\n" + "\tport# %u speed %s Mbps\n" "\tRX packets %" PRIu64" bytes %" PRIu64"\n" "\tRX errors %" PRIu64" missed %" PRIu64" no-mbuf %" PRIu64"\n" "\tTX packets %" PRIu64" bytes %" PRIu64"\n" "\tTX errors %" PRIu64"\n", link->name, - eth_link.link_status == 0 ? "DOWN" : "UP", + link_status_text, mtu, mac_addr.addr_bytes[0], mac_addr.addr_bytes[1], mac_addr.addr_bytes[2], mac_addr.addr_bytes[3],
@@ -287,7 +289,7 @@ print_link_info(struct link *link, char *out, size_t out_size) link->n_rxq, link->n_txq, link->port_id, - eth_link.link_speed, + link_speed_text, stats.ipackets, stats.ibytes, stats.ierrors,
Signature · 1 line
2.17.1
PATCH v9 12/24 examples/ipsec-secgw: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/ipsec-secgw/ipsec-secgw.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +5 -8
@@ -1775,6 +1775,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -1794,14 +1795,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v9 13/24 examples/kni: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/kni/main.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
examples/kni/main.c +9 -17
@@ -661,6 +661,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status\n" );fflush (stdout);
@@ -680,14 +681,9 @@ 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 %uMbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
@@ -717,19 +713,15 @@ check_all_ports_link_status(uint32_t port_mask)static void log_link_state (struct rte_kni *kni,int prev,struct rte_eth_link *link) { +char link_status_text[60 ];if (kni ==NULL || link ==NULL )return ; -if (prev ==ETH_LINK_DOWN && link->link_status ==ETH_LINK_UP ) { -RTE_LOG (INFO ,APP ,"%s NIC Link is Up %d Mbps %s %s.\n" , +rte_eth_link_to_str (link_status_text,60 ,NULL , link); +if (prev != link->link_status) +RTE_LOG (INFO ,APP ,"%s NIC %s" ,rte_kni_get_name (kni), - link->link_speed, - link->link_autoneg ?"(AutoNeg)" :"(Fixed)" , - link->link_duplex ?"Full Duplex" :"Half Duplex" ); - }else if (prev ==ETH_LINK_UP && link->link_status ==ETH_LINK_DOWN ) { -RTE_LOG (INFO ,APP ,"%s NIC Link is Down.\n" , -rte_kni_get_name (kni)); - } + link_status_text); }/*
Signature · 1 line
2.17.1
PATCH v9 14/24 examples/l2fwd-crypt: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l2fwd-crypto/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/l2fwd-crypto/main.c +4 -8
@@ -1734,6 +1734,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -1753,14 +1754,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v9 15/24 examples/l2fwd-event: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l2fwd-event/main.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/l2fwd-event/main.c +5 -8
@@ -366,6 +366,7 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc,uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status..." );fflush (stdout);
@@ -389,14 +390,10 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc, }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - port_id, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , port_id); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , port_id, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v9 16/24 examples/l2fwd: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l2fwd/main.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/l2fwd/main.c +5 -8
@@ -571,6 +571,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -594,14 +595,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v9 17/24 examples/l3fwd-graph: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l3fwd-graph/main.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
examples/l3fwd-graph/main.c +5 -10
@@ -599,6 +599,7 @@ check_all_ports_link_status(uint32_t port_mask)struct rte_eth_link link;uint16_t portid;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -623,16 +624,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" , - portid, link.link_speed, - (link.link_duplex == -ETH_LINK_FULL_DUPLEX ) - ? ("full-duplex" ) - : ("half-duplex\n" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* Clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v9 18/24 examples/l3fwd-power: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l3fwd-power/main.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
examples/l3fwd-power/main.c +5 -9
@@ -1945,6 +1945,7 @@ check_all_ports_link_status(uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -1964,15 +1965,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" , (uint8_t )portid, - (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - (uint8_t )portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v9 19/24 examples/multi_proc*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- .../client_server_mp/mp_server/init.c | 15 ++++++--------- examples/multi_process/symmetric_mp/main.c | 13 +++++-------- 2 files changed, 11 insertions(+), 17 deletions(-)
examples/multi_process/client_server_mp/mp_server/init.c +6 -9
@@ -185,6 +185,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -204,15 +205,11 @@ check_all_ports_link_status(uint16_t port_num, 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" , ports->id[portid], - (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - (uint8_t )ports->id[portid]); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , + (uint8_t )ports->id[portid], + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/multi_process/symmetric_mp/main.c +5 -8
@@ -365,6 +365,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -384,14 +385,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v9 20/24 examples/ntb: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ntb/ntb_fwd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
examples/ntb/ntb_fwd.c +6 -5
@@ -729,6 +729,7 @@ start_pkt_fwd(void)struct rte_eth_link eth_link;uint32_t lcore_id;int ret, i; +char link_status_text[ETH_LINK_MAX_STR_LEN ]; ret =ntb_fwd_config_setup ();if (ret <0 ) {
@@ -747,11 +748,11 @@ start_pkt_fwd(void)return ; }if (eth_link.link_status) { -printf ("Eth%u Link Up. Speed %u Mbps - %s\n" , - eth_port_id, eth_link.link_speed, - (eth_link.link_duplex == -ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , + ð_link); +printf ("Eth%u %s\n" , eth_port_id, + link_status_text);break ; } }
Signature · 1 line
2.17.1
PATCH v9 21/24 example/performance*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/performance-thread/l3fwd-thread/main.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/performance-thread/l3fwd-thread/main.c +5 -8
@@ -3433,6 +3433,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -3452,14 +3453,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v9 22/24 examples/qos_sched: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/qos_sched/init.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/qos_sched/init.c +5 -8
@@ -76,6 +76,7 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)uint16_t rx_size;uint16_t tx_size;struct rte_eth_conf local_port_conf = port_conf; +char link_status_text[ETH_LINK_MAX_STR_LEN ];/* check if port already initialized (multistream configuration) */ if (app_inited_port_mask & (1u << portid))
@@ -160,14 +161,10 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)"rte_eth_link_get: err=%d, port=%u: %s\n" , ret, portid, rte_strerror(-ret)); -if (link.link_status) { -printf (" Link Up - speed %u Mbps - %s\n" , - (uint32_t ) link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else { -printf (" Link Down\n" ); - } +rte_eth_link_to_str (link_status_text,sizeof (link_status_text), +NULL , &link); +printf ("%s\n" , link_status_text); + ret =rte_eth_promiscuous_enable (portid);if (ret !=0 ) rte_exit(EXIT_FAILURE,
Signature · 1 line
2.17.1
PATCH v9 23/24 examples/server_nod*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/server_node_efd/server/init.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
examples/server_node_efd/server/init.c +5 -10
@@ -247,6 +247,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -266,16 +267,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , - info->id[portid], - link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - info->id[portid]); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s\n" , info->id[portid], + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v9 24/24 examples/vm_power_*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/vm_power_manager/main.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
examples/vm_power_manager/main.c +5 -9
@@ -244,6 +244,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[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -267,15 +268,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),NULL , &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v9 00/24] ethdev: allow unknown link speed
In reply to Ivan DyukovOn 8/11/2020 9:52 AM, Ivan Dyukov wrote:
<...>
Quoted 54 lines
v9 changes:
* removerte_eth_link_printffunction
* addETH_LINK_MAX_STR_LENdefinition
* add usage ofETH_LINK_MAX_STR_LENin examplesv8 changes:
* renamerte_eth_link_strftorte_eth_link_to_str
* refactorrte_eth_link_to_straccording to review comments
* fix codestyle
* fix commit message in 02 patch
* fix compile error in ntb application
* merge "app" and "doc" commitsv7 changes:
* fix meson build
* change_strffunction. now it does not fails in case of unknown specifiers like %d. it just copy it to target string.
* removeinvalid_fmtunit test.
* add unknown specifier test.
* fix codestylev6 changes:
* fix spelling in comments according to checkpatch warningv5 changes:
* renamerte_eth_link_formattorte_eth_link_strf
* add '\n' to default strings
* update remaining examples. patch with subj 'examples: new link status print format' contains examples which have no maintainers. TBD:
update remaining nic drivers with 'unknown' speed. It should be provided in separate patchset.v4 changes:
* refactorrte_eth_link_formatusing strlcat func instead of snprintf
* added new checks to unit tests
* few minor fixes according review comments
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speedv3 changes:
* removerte_eth_link_prepare_textfunction
* addrte_eth_link_formatandrte_eth_link_printffunctions
* added unit tests forrte_eth_link_formatfunction
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speedv2 changes:
* add function which format link status to textual representation
* update drivers for Intel nics with 'unknown' speed
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
Quoted 7 lines
v1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
Hi Ivan,
Logging discussion is going on, this is preventing 'unknown' link speed merged and used by drivers. This has potential conflict in more drivers.
So I will get those patches (1,4,5,6/24) although logging link speed won't be correct, and logging discussions can continue separately.
Related to the link speed logging, the problem we are trying to solve is 'unknown' speed value representation (UINT_MAX) won't be correct and can be confusing, which requires additional check/parsing before log.
The proposed solution is a link to string function. Because of the logging difference/needs in the applications the function provides fine grade logging capability, which works fine but I think it is too complex for the problem it is solving. I wonder if the logging link information differences in the applications is an actual need, or it happened by time since those samples/applications developed by different people and common logging function was missing. So perhaps we can switch all to a generic logging.
What do you think following:
For the immediate need for 'unknown' link speed parsing, can have a 'rte_eth_link_speed_to_str()' function which returns only link speed and applications need custom message can use it for logging.
And can have a simple/brief link to string function for generic usage, and if application want custom message it can parse link struct itself. The link string can be something like: "Link Up 10Gbps full-duplex autoneg"
Re: [dpdk-dev] [PATCH v9 00/24] ethdev: allow unknown link speed
Quoted 39 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, September 7, 2020 3:25 PMOn 8/11/2020 9:52 AM, Ivan Dyukov wrote:
<...>
Quoted 6 lines
v9 changes:
* removerte_eth_link_printffunction
* addETH_LINK_MAX_STR_LENdefinition
* add usage ofETH_LINK_MAX_STR_LENin examplesQuoted 7 lines
v1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.Hi Ivan,
Logging discussion is going on, this is preventing 'unknown' link speed merged
and used by drivers. This has potential conflict in more drivers.So I will get those patches (1,4,5,6/24) although logging link speed won't be
correct, and logging discussions can continue separately.Related to the link speed logging, the problem we are trying to solve is
'unknown' speed value representation (UINT_MAX) won't be correct and can be
confusing, which requires additional check/parsing before log.
Quoted 14 lines
The proposed solution is a link to string function. Because of the logging
difference/needs in the applications the function provides fine grade logging
capability, which works fine but I think it is too complex for the problem it is
solving.
I wonder if the logging link information differences in the applications is an
actual need, or it happened by time since thosesamples/applicationsdeveloped
by different people and common logging function was missing. So perhaps we can
switch all to a generic logging.
Good thinking, Ferruh. I agree that examples probably use different formatting by accident, not by deliberate choice.
Quoted 7 lines
What do you think following:
For the immediate need for 'unknown' link speed parsing, can have a '
rte_eth_link_speed_to_str()' function which returns only link speed and
applications need custom message can use it for logging.
That function is unlikely to serve application specific needs for formatting speed.
But it might serve the needs of DPDK libraries and examples.
Quoted 7 lines
And can have a simple/brief link to string function for generic usage, and if
application want custom message it can parse link struct itself. The link string can be something like: "Link Up 10Gbps full-duplex autoneg"
For DPDK libraries and examples, I agree that a generic one-format-fits-all function should suffice.
And as a DPDK application developer, parsing the link struct ourselves suffices for our application. In this context, an strf-style function is "nice to have", not "must have".
Med venlig hilsen / kind regards
- Morten Brørup
Re: [dpdk-dev] [PATCH v9 00/24] ethdev: allow unknown link speed
Hi Ferruh, Morten,
07.09.2020 18:29, Morten Brørup пишет:
Quoted 69 lines
Quoted 37 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, September 7, 2020 3:25 PMOn 8/11/2020 9:52 AM, Ivan Dyukov wrote:
<...>
Quoted 5 lines
v9 changes:
* removerte_eth_link_printffunction
* addETH_LINK_MAX_STR_LENdefinition
* add usage ofETH_LINK_MAX_STR_LENin examplesQuoted 7 lines
v1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.Hi Ivan,
Logging discussion is going on, this is preventing 'unknown' link speed merged
and used by drivers. This has potential conflict in more drivers.So I will get those patches (1,4,5,6/24) although logging link speed won't be
correct, and logging discussions can continue separately.Related to the link speed logging, the problem we are trying to solve is
'unknown' speed value representation (UINT_MAX) won't be correct and can be
confusing, which requires additional check/parsing before log.Quoted 14 lines
The proposed solution is a link to string function. Because of the logging
difference/needs in the applications the function provides fine grade logging
capability, which works fine but I think it is too complex for the problem it is
solving.
I wonder if the logging link information differences in the applications is an
actual need, or it happened by time since thosesamples/applicationsdeveloped
by different people and common logging function was missing. So perhaps we can
switch all to a generic logging.Good thinking, Ferruh. I agree that examples probably use different formatting by accident, not by deliberate choice.
Quoted 6 lines
What do you think following:
For the immediate need for 'unknown' link speed parsing, can have a '
rte_eth_link_speed_to_str()' function which returns only link speed and
applications need custom message can use it for logging.That function is unlikely to serve application specific needs for formatting speed.
But it might serve the needs of DPDK libraries and examples.
Quoted 6 lines
And can have a simple/brief link to string function for generic usage, and if
application want custom message it can parse link struct itself. The link string can be something like: "Link Up 10Gbps full-duplex autoneg"
Quoted 3 lines
For DPDK libraries and examples, I agree that a generic one-format-fits-all function should suffice.
And as a DPDK application developer, parsing the link struct ourselves suffices for our application. In this context, an strf-style function is "nice to have", not "must have".
Almost all examples have same link status formating, except two cases:
testpmd has multiline link status format and another application has extremely brief status info which is mixed with other text. so I would prefer to keep such statuses without changes but we should give some helpers for such cases.I would prefer MACROS:
#define RTE_ETH_LINK_STATUS_TO_STR(link_status) (link_status == ETH_LINK_DOWN ? "Down" : "Up")
#define RTE_ETH_LINK_SPEED_TO_STR(link_speed) (link_speed == ETH_SPEED_NUM_UNKNOWN ? "Unknown" : \
link_speed ==
ETH_SPEED_NUM_NONE ? "0" : \
link_speed ==
ETH_SPEED_NUM_10M ? "10 Mbps" : \
link_speed ==
ETH_SPEED_NUM_100M ? "100 Mbps" : \
link_speed ==
ETH_SPEED_NUM_1G ? "1 Gbps" : \
link_speed
==ETH_SPEED_NUM_2_5G ? "2.5 Gbps" : \
link_speed
==ETH_SPEED_NUM_5G ? "5 Gbps" : \
link_speed
==ETH_SPEED_NUM_10G ? "10 Gbps" : \
link_speed ==
ETH_SPEED_NUM_20G ? "20 Gbps" : \
link_speed ==ETH_SPEED_NUM_25G ? "25 Gbps" : \
link_speed ==ETH_SPEED_NUM_40G ? "40 Gbps" : \
link_speed ==ETH_SPEED_NUM_50G ? "50 Gbps" : \
link_speed ==ETH_SPEED_NUM_56G ? "56 Gbps" : \link_speed == ETH_SPEED_NUM_100G ? "100 Gbps" : \link_speed == ETH_SPEED_NUM_200G ? "200 Gbps" : \
"Invalid speed")
#define RTE_ETH_LINK_DUPLEX_TO_STR(link_duplex) (link_duplex == ETH_LINK_FULL_DUPLEX? "FDX" : "HDX")
#define RTE_ETH_LINK_AUTONEG_TO_STR(link_autoneg) (link_autoneg== ETH_LINK_FULL_DUPLEX? "Autoneg" : "Fixed")
and one function which construct a default status string:
int rte_eth_link_to_str(char *str, size_t len, const struct rte_eth_link *eth_link) {
static const char link_down_str[] = "Link down";
static const char link_up_str[] = "Link up at";
if (eth_link->link_status == ETH_LINK_DOWN)
return snprintf(str, len, "%s", link_down_str);
else
return snprintf(str, len, "%s %s %s %s", link_up_str,
RTE_ETH_LINK_SPEED_TO_STR(eth_link->link_speed),
RTE_ETH_LINK_DUPLEX_TO_STR(eth_link->link_duplex),
RTE_ETH_LINK_AUTONEG_TO_STR(eth_link->link_autoneg));
}
Quoted 5 lines
Med venlig hilsen / kind regards
- Morten Brørup
Morten Brørup
Acked-byRe: [dpdk-dev] [PATCH v9 00/24] ethdev: allow unknown link speed
Quoted 147 lines
From: dev [mailto:[email protected]] On Behalf Of Ivan Dyukov
Sent: Tuesday, September 8, 2020 8:16 AMHi Ferruh, Morten,
07.09.2020 18:29, Morten Brørup пишет:
Quoted 19 lines
Quoted 19 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, September 7, 2020 3:25 PMOn 8/11/2020 9:52 AM, Ivan Dyukov wrote:
<...>
Quoted 12 lines
v9 changes:
* removerte_eth_link_printffunction
* addETH_LINK_MAX_STR_LENdefinition
* add usage ofETH_LINK_MAX_STR_LENin examplesv1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.Quoted 3 lines
Quoted 3 lines
Hi Ivan,
Logging discussion is going on, this is preventing 'unknown' link
speed
Quoted 10 lines
Quoted 10 lines
merged
and used by drivers. This has potential conflict in more drivers.So I will get those patches (1,4,5,6/24) although logging link speed won't be
correct, and logging discussions can continue separately.Related to the link speed logging, the problem we are trying to
solve
Quoted 8 lines
Quoted 8 lines
is
'unknown' speed value representation (UINT_MAX) won't be correct and can be
confusing, which requires additional check/parsing before log.The proposed solution is a link to string function. Because of the logging
difference/needs in the applications the function provides finegrade
Quoted 9 lines
Quoted 9 lines
logging
capability, which works fine but I think it is too complex for the problem it is
solving.
I wonder if the logging link information differences in the applications is an
actual need, or it happened by time since thosesamples/applicationsdeveloped
by different people and common logging function was missing. Soperhaps
Quoted 3 lines
Quoted 2 lines
we can
switch all to a generic logging.Good thinking, Ferruh. I agree that examples probably use different
formatting by accident, not by deliberate choice.
Quoted 7 lines
Quoted 6 lines
What do you think following:
For the immediate need for 'unknown' link speed parsing, can have a '
rte_eth_link_speed_to_str()' function which returns only link speed and
applications need custom message can use it for logging.That function is unlikely to serve application specific needs for
formatting speed.
Quoted 4 lines
But it might serve the needs of DPDK libraries and examples.
Quoted 1 line
And can have a simple/brief link to string function for generic
usage,
Quoted 6 lines
Quoted 5 lines
and if
application want custom message it can parse link struct itself. The link string can be something like: "Link Up 10Gbps full-duplex autoneg"For DPDK libraries and examples, I agree that a generic one-format-
fits-all function should suffice.
Quoted 2 lines
And as a DPDK application developer, parsing the link struct
ourselves suffices for our application. In this context, an strf-style function is "nice to have", not "must have".
Almost all examples have same link status formating, except two cases:
testpmd has multiline link status format and another application has extremely brief status info which is mixed with other text. so I would prefer to keep such statuses without changes but we should give some helpers for such cases.I would prefer MACROS:
#defineRTE_ETH_LINK_STATUS_TO_STR(link_status)(link_status==ETH_LINK_DOWN? "Down" : "Up")
#define RTE_ETH_LINK_SPEED_TO_STR(link_speed) (link_speed==ETH_SPEED_NUM_UNKNOWN? "Unknown" : \
link_speed==
ETH_SPEED_NUM_NONE ? "0" : \
link_speed==
ETH_SPEED_NUM_10M ? "10 Mbps" : \
link_speed==
ETH_SPEED_NUM_100M ? "100 Mbps" : \
link_speed==
ETH_SPEED_NUM_1G ? "1 Gbps" : \
link_speed
==ETH_SPEED_NUM_2_5G ? "2.5 Gbps" : \
link_speed
==ETH_SPEED_NUM_5G ? "5 Gbps" : \
link_speed
==ETH_SPEED_NUM_10G ? "10 Gbps" : \
link_speed==
ETH_SPEED_NUM_20G ? "20 Gbps" : \
link_speed==ETH_SPEED_NUM_25G? "25 Gbps" : \
link_speed==ETH_SPEED_NUM_40G? "40 Gbps" : \
link_speed==ETH_SPEED_NUM_50G? "50 Gbps" : \
link_speed==ETH_SPEED_NUM_56G? "56 Gbps" : \link_speed== ETH_SPEED_NUM_100G ? "100 Gbps" : \link_speed== ETH_SPEED_NUM_200G ? "200 Gbps" : \
"Invalid speed")
#define RTE_ETH_LINK_DUPLEX_TO_STR(link_duplex) (link_duplex==ETH_LINK_FULL_DUPLEX? "FDX" : "HDX")
#define RTE_ETH_LINK_AUTONEG_TO_STR(link_autoneg) (link_autoneg==ETH_LINK_FULL_DUPLEX? "Autoneg" : "Fixed")and one function which construct a default status string:
int rte_eth_link_to_str(char *str,
size_tlen, const structrte_eth_link*eth_link) {static const char link_down_str[] = "Link down";
static const char link_up_str[] = "Link up at";
if (
eth_link->link_status==ETH_LINK_DOWN)return
snprintf(str, len, "%s", link_down_str);else
return snprintf(str, len, "%s %s %s %s",
link_up_str,
Quoted 7 lines
RTE_ETH_LINK_SPEED_TO_STR(eth_link->link_speed),
RTE_ETH_LINK_DUPLEX_TO_STR(eth_link->link_duplex),
RTE_ETH_LINK_AUTONEG_TO_STR(eth_link->link_autoneg));}
I think that the DPDK developer community has a preference for functions over macros. This is not in the fast path, so there is no need for macros.
Make the macros functions instead, and consider it...
v10 cover ethdev: allow unknown link speed
In reply to Ivan DyukovMAINTAINERS | 1 + app/proc-info/main.c | 9 +- app/test-pipeline/init.c | 11 ++- app/test-pmd/config.c | 20 +++-- app/test-pmd/testpmd.c | 9 +- app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app/test/test_pmd_perf.c | 17 ++-- doc/guides/sample_app_ug/link_status_intr.rst | 10 +-- drivers/net/i40e/i40e_ethdev.c | 5 +- drivers/net/i40e/i40e_ethdev_vf.c | 10 +-- drivers/net/ice/ice_ethdev.c | 5 +- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +- examples/bbdev_app/main.c | 8 +- examples/ioat/ioatfwd.c | 13 ++- examples/ip_fragmentation/main.c | 13 ++- examples/ip_pipeline/cli.c | 12 +-- examples/ip_reassembly/main.c | 12 +-- examples/ipsec-secgw/ipsec-secgw.c | 12 +-- examples/ipv4_multicast/main.c | 12 +-- examples/kni/main.c | 26 ++---- examples/l2fwd-crypto/main.c | 12 +-- examples/l2fwd-event/main.c | 12 +-- examples/l2fwd-jobstats/main.c | 12 +-- examples/l2fwd-keepalive/main.c | 12 +-- examples/l2fwd/main.c | 12 +-- examples/l3fwd-acl/main.c | 12 +-- examples/l3fwd-graph/main.c | 14 +-- examples/l3fwd-power/main.c | 13 +-- examples/l3fwd/main.c | 12 +-- examples/link_status_interrupt/main.c | 30 +++---- examples/multi_process/client_server_mp/mp_server/init.c | 14 ++- examples/multi_process/symmetric_mp/main.c | 12 +-- examples/ntb/ntb_fwd.c | 10 +-- examples/performance-thread/l3fwd-thread/main.c | 12 +-- examples/qos_sched/init.c | 10 +-- examples/server_node_efd/server/init.c | 15 ++-- examples/vm_power_manager/main.c | 14 ++- lib/librte_ethdev/rte_ethdev.c | 174 ++++++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 76 ++++++++++++++--- lib/librte_ethdev/rte_ethdev_version.map | 4 + 42 files changed, 715 insertions(+), 282 deletions(-)
v10 changes:
* remove format string arg from rte_eth_link_to_str function
* add rte_eth_link_speed_to_str function
* add usage of rte_eth_link_speed_to_str in examples
v9 changes:
* remove rte_eth_link_printf function
* add ETH_LINK_MAX_STR_LEN definition
* add usage of ETH_LINK_MAX_STR_LEN in examples
v8 changes:
* rename rte_eth_link_strf to rte_eth_link_to_str
* refactor rte_eth_link_to_str according to review comments
* fix codestyle
* fix commit message in 02 patch
* fix compile error in ntb application
* merge "app" and "doc" commits
v7 changes:
* fix meson build
* change _strf function. now it does not fails in case of unknown specifiers like %d. it just copy it to target string.
* remove invalid_fmt unit test.
* add unknown specifier test.
* fix codestyle
v6 changes:
* fix spelling in comments according to checkpatch warning
v5 changes:
* rename rte_eth_link_format to rte_eth_link_strf
* add '\n' to default strings
* update remaining examples. patch with subj 'examples: new link status print format' contains examples which have no maintainers. TBD:
update remaining nic drivers with 'unknown' speed. It should be provided in separate patchset.
v4 changes:
* refactor rte_eth_link_format using strlcat func instead of snprintf
* added new checks to unit tests
* few minor fixes according review comments
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v3 changes:
* remove rte_eth_link_prepare_text function
* add rte_eth_link_format and rte_eth_link_printf functions
* added unit tests for rte_eth_link_format function
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v2 changes:
* add function which format link status to textual representation
* update drivers for Intel nics with 'unknown' speed
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
PATCH v10 1/24 ethdev: allow unknown link speed
From: Thomas Monjalon <[email protected]>
When querying the link information, the link status is a mandatory major information.
Other boolean values are supposed to be accurate:
- duplex mode (half/full)
- negotiation (auto/fixed)
This API update is making explicit that the link speed information is optional.
The value ETH_SPEED_NUM_NONE (0) was already part of the API. The value ETH_SPEED_NUM_UNKNOWN (infinite) is added to cover two different cases:
- speed is not known by the driver
- device is virtual
--- lib/librte_ethdev/rte_ethdev.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
lib/librte_ethdev/rte_ethdev.h +10 -10
@@ -303,6 +303,7 @@ struct rte_eth_stats {#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ #define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ #define ETH_SPEED_NUM_200G 200000/**< 200 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN UINT32_MAX/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
@@ -2262,15 +2263,16 @@ int rte_eth_allmulticast_disable(uint16_t port_id);int rte_eth_allmulticast_get (uint16_t port_id);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It might need -* to wait up to 9 seconds in it. +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). +* +* It might need to wait up to 9 seconds. +* @see rte_eth_link_get_nowait. * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
@@ -2279,15 +2281,13 @@ int rte_eth_allmulticast_get(uint16_t port_id);int rte_eth_link_get (uint16_t port_id,struct rte_eth_link *link);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait -* version of rte_eth_link_get(). +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
Signature · 1 line
2.17.1
PATCH v10 2/24 ethdev: format a link status text
In reply to Ivan DyukovThere is new link_speed value introduced. It's INT_MAX value which means that speed is unknown. To simplify processing of the value in application, new function is added which convert link_speed to string. Also dpdk examples have many duplicated code which format entire link status structure to text.
This commit adds two functions:
* rte_eth_link_speed_to_str - format link_speed to string
* rte_eth_link_to_str - convert link status structure to string
--- MAINTAINERS | 1 + app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 169 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 53 +++++++ lib/librte_ethdev/rte_ethdev.h | 32 +++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + 7 files changed, 264 insertions(+) create mode 100644 app/test/test_ethdev_link.c
MAINTAINERS +1 -0
@@ -393,6 +393,7 @@ T: git://dpdk.org/next/dpdk-next-net F: lib/librte_ethdev/ F: devtools/test-null.sh F: doc/guides/prog_guide/switch_representation.rst +F: app/test/test_ethdev* Flow API M: Ori Kam <[email protected]>
app/test/Makefile +3 -0
@@ -251,6 +251,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c test_ipsec_perf.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c + +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c + ifeq ($(CONFIG_RTE_LIBRTE_IPSEC),y) LDLIBS += -lrte_ipsec endif
app/test/meson.build +2 -0
@@ -39,6 +39,7 @@ test_sources = files('commands.c', 'test_efd.c', 'test_efd_perf.c', 'test_errno.c', + 'test_ethdev_link.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',
@@ -199,6 +200,7 @@ fast_tests = [ ['eal_flags_misc_autotest', false], ['eal_fs_autotest', true], ['errno_autotest', true], + ['ethdev_link_status', true], ['event_ring_autotest', true], ['fib_autotest', true], ['fib6_autotest', true],
app/test/test_ethdev_link.c new file +169 -0
169 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.c +53 -0
59 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.h +32 -0
@@ -323,6 +323,7 @@ struct rte_eth_link {#define ETH_LINK_UP 1/**< Link is up (see link_status). */ #define ETH_LINK_FIXED 0/**< No autonegotiation (see link_autoneg). */ #define ETH_LINK_AUTONEG 1/**< Autonegotiated (see link_autoneg). */ +#define RTE_ETH_LINK_MAX_STR_LEN 40/**< Max length of default link string. */ /** * A structure used to configure the ring threshold registers of an RX/TX
@@ -2295,6 +2296,37 @@ int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);*/ int rte_eth_link_get_nowait (uint16_t port_id,struct rte_eth_link *link); +/** +* The function converts a link_speed to a string. It handles all special +* values like unknown or none speed. +* @param link_speed +* link_speed of rte_eth_link struct +* @return +* Link speed in textual format. It's pointer to immutable memory. +* No free is required. +*/ +__rte_experimental +const char *rte_eth_link_speed_to_str(uint32_t speed_link); + +/** +* The function converts a rte_eth_link struct representing a link status to +* a string. +* @param str +* A pointer to a string to be filled with textual representation of +* device status. At least ETH_LINK_MAX_STR_LEN bytes should be allocated to +* store default link status text. +* @param len +* Length of available memory at 'str' string. +* @param eth_link +* Link status returned by rte_eth_link_get function +* @return +* - Number of bytes written to str array. +* +*/ +__rte_experimental +int rte_eth_link_to_str(char *str, size_t len, +const struct rte_eth_link *eth_link); +/** * Retrieve the general I/O statistics of an Ethernet device. *
lib/librte_ethdev/rte_ethdev_version.map +4 -0
@@ -241,4 +241,8 @@ EXPERIMENTAL { __rte_ethdev_trace_rx_burst; __rte_ethdev_trace_tx_burst; rte_flow_get_aged_flows; + + # added in 20.11 + rte_eth_link_to_str; + rte_eth_link_speed_to_str; };
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v10 02/24] ethdev: format a link status text
Quoted 15 lines
From: Ivan Dyukov [mailto:[email protected]]
Sent: Thursday, September 10, 2020 9:34 PMThere is new
link_speedvalue introduced. It'sINT_MAXvalue which means that speed is unknown. To simplify processing of the value in application, new function is added which convertlink_speedto string. Also dpdk examples have many duplicated code which format entire link status structure to text.This commit adds two functions:
*rte_eth_link_speed_to_str- formatlink_speedto string
*rte_eth_link_to_str- convert link status structure to stringSigned-off-by Ivan Dyukov <[email protected]>---
[...]
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +0
-0
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct · line 2392
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +6
-0@@ -2383,6 +2383,59 @@ rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)return 0 ; } +const char * +rte_eth_link_speed_to_str (uint32_t link_speed) +{ +switch (link_speed) { +case ETH_SPEED_NUM_UNKNOWN : +return "Unknown" ;
Suggest moving case ETH_SPEED_NUM_UNKNOWN to the bottom of the switch, keeping it in the same order as the enums in the header file. No strong opinion on this, just an observation.
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2393
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.c +2
-0+case ETH_SPEED_NUM_NONE : +return "0 Mbps" ;
Return "None" instead of "0 Mbps".
Quoted 18 lines
lib/librte_ethdev/rte_ethdev.c +18
-0+case ETH_SPEED_NUM_10M : +return "10 Mbps" ; +case ETH_SPEED_NUM_100M : +return "100 Mbps" ; +case ETH_SPEED_NUM_1G : +return "1 Gbps" ; +case ETH_SPEED_NUM_2_5G : +return "2.5 Gbps" ; +case ETH_SPEED_NUM_5G : +return "5 Gbps" ; +case ETH_SPEED_NUM_10G : +return "10 Gbps" ; +case ETH_SPEED_NUM_20G : +return "20 Gbps" ; +case ETH_SPEED_NUM_25G : +return "25 Gbps" ; +case ETH_SPEED_NUM_40G : +return "40 Gbps" ;
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2421
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+case ETH_SPEED_NUM_50G : +return "50 Gbps" ; +case ETH_SPEED_NUM_56G : +return "56 Gbps" ; +case ETH_SPEED_NUM_100G : +return "100 Gbps" ; +case ETH_SPEED_NUM_200G : +return "200 Gbps" ; +default : +return "Invalid speed" ;
Suggest "Invalid" instead, only to avoid a relatively long string. Again, no strong opinion on this.
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct · line 2424
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.c +2
-0+ } +}
Remember to update test_link_speed_all_values() accordingly.
PATCH v10 3/24 app: update apps&docs with new UNKNOWN link speed
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications and docs
--- app/proc-info/main.c | 11 +++++------ app/test-pipeline/init.c | 11 +++++------ app/test-pmd/config.c | 9 +++++---- app/test-pmd/testpmd.c | 12 ++++-------- app/test/test_pmd_perf.c | 17 +++++++---------- doc/guides/sample_app_ug/link_status_intr.rst | 10 +++++----- 6 files changed, 31 insertions(+), 39 deletions(-)
app/proc-info/main.c +5 -6
@@ -672,6 +672,7 @@ show_port(void)struct rte_eth_dev_info dev_info;struct rte_eth_rxq_info queue_info;struct rte_eth_rss_conf rss_conf; +char link_status_text[RTE_ETH_LINK_MAX_STR_LEN ];memset (&rss_conf,0 ,sizeof (rss_conf));
@@ -685,12 +686,10 @@ show_port(void)printf ("Link get failed (port %u): %s\n" , i,rte_strerror (-ret)); }else { -printf ("\t -- link speed %d duplex %d," -" auto neg %d status %d\n" , - link.link_speed, - link.link_duplex, - link.link_autoneg, - link.link_status); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text), + &link); +printf ("\t%s\n" , link_status_text); }printf ("\t -- promiscuous (%d)\n" ,rte_eth_promiscuous_get (i));
app/test-pipeline/init.c +5 -6
@@ -155,7 +155,7 @@ static voidapp_ports_check_link (void) {uint32_t all_ports_up, i; - +char link_status_text[RTE_ETH_LINK_MAX_STR_LEN ]; all_ports_up =1 ;for (i =0 ; i < app.n_ports; i++) {
@@ -173,12 +173,11 @@ app_ports_check_link(void) all_ports_up =0 ;continue ; } - -RTE_LOG (INFO ,USER1 ,"Port %u (%u Gbps) %s\n" , +rte_eth_link_to_str (link_status_text,sizeof (link_status_text), + &link); +RTE_LOG (INFO ,USER1 ,"Port %u %s\n" , port, - link.link_speed /1000 , - link.link_status ?"UP" :"DOWN" ); - + link_status_text);if (link.link_status ==ETH_LINK_DOWN ) all_ports_up =0 ; }
app/test-pmd/config.c +5 -4
@@ -605,7 +605,7 @@ port_infos_display(portid_t port_id)printf ("\nmemory allocation on the socket: %u" ,port->socket_id);printf ("\nLink status: %s\n" , (link.link_status) ? ("up" ) : ("down" )); -printf ("Link speed: %u Mbps\n" , (unsigned ) link.link_speed); +printf ("Link speed: %s\n" ,rte_eth_link_speed_to_str (link.link_speed));printf ("Link duplex: %s\n" , (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? ("full-duplex" ) : ("half-duplex" ));
@@ -750,12 +750,12 @@ port_summary_display(portid_t port_id)if (ret !=0 )return ; -printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n" , +printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %s\n" , port_id, mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ], name, dev_info.driver_name, (link.link_status) ? ("up" ) : ("down" ), - (unsigned int ) link.link_speed); +rte_eth_link_speed_to_str (link.link_speed)); }void
@@ -3899,7 +3899,8 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate) ret =eth_link_get_nowait_print_err (port_id, &link);if (ret <0 )return 1 ; -if (rate > link.link_speed) { +if (link.link_speed !=ETH_SPEED_NUM_UNKNOWN && + rate > link.link_speed) {printf ("Invalid rate value:%u bigger than link speed: %u\n" , rate, link.link_speed);return 1 ;
app/test-pmd/testpmd.c +4 -8
@@ -2991,6 +2991,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status[RTE_ETH_LINK_MAX_STR_LEN ];printf ("Checking link statuses...\n" );fflush (stdout);
@@ -3010,14 +3011,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status, +sizeof (link_status), &link); +printf ("Port %d %s\n" , portid, link_status);continue ; }/* clear all_ports_up flag if any link down */
app/test/test_pmd_perf.c +7 -10
@@ -126,6 +126,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status[RTE_ETH_LINK_MAX_STR_LEN ];printf ("Checking link statuses...\n" );fflush (stdout);
@@ -146,16 +147,12 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -if (link_mbps ==0 ) - link_mbps = link.link_speed; - }else -printf ("Port %d Link Down\n" , portid); +if (link.link_status && link_mbps ==0 ) + link_mbps = link.link_speed; + +rte_eth_link_to_str (link_status, +sizeof (link_status), &link); +printf ("Port %d %s\n" , portid, link_status);continue ; }/* clear all_ports_up flag if any link down */
doc/guides/sample_app_ug/link_status_intr.rst +5 -5
@@ -158,6 +158,7 @@ An example callback function that has been written as indicated below. { struct rte_eth_link link; int ret; + char link_status[RTE_ETH_LINK_MAX_STR_LEN]; RTE_SET_USED(param);
@@ -169,11 +170,10 @@ An example callback function that has been written as indicated below. if (ret < 0) { printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret)); - } else if (link.link_status) { - printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); - } else - printf("Port %d Link Down\n\n", port_id); + } else { + rte_eth_link_to_str(link_status, sizeof(link_status), &link); + printf("Port %d %s\n", port_id, link_status); + } } This function is called when a link status interrupt is present for the right port.
Signature · 1 line
2.17.1
PATCH v10 4/24 net/ixgbe: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available
--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -5
@@ -4300,11 +4300,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case IXGBE_LINK_SPEED_100_FULL :
Signature · 1 line
2.17.1
PATCH v10 5/24 net/i40e: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/i40e/i40e_ethdev.c | 5 ++++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_ethdev.c +4 -1
@@ -2891,7 +2891,10 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link, link->link_speed =ETH_SPEED_NUM_40G ;break ;default : - link->link_speed =ETH_SPEED_NUM_NONE ; +if (link->link_status) + link->link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + link->link_speed =ETH_SPEED_NUM_NONE ;break ; } }
drivers/net/i40e/i40e_ethdev_vf.c +5 -5
@@ -2163,15 +2163,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_speed =ETH_SPEED_NUM_40G ;break ;default : - new_link.link_speed =ETH_SPEED_NUM_NONE ; +if (vf->link_up) + new_link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + new_link.link_speed =ETH_SPEED_NUM_NONE ;break ; }/* full duplex only */ new_link.link_duplex =ETH_LINK_FULL_DUPLEX ; - new_link.link_status = vf->link_up && - new_link.link_speed !=ETH_SPEED_NUM_NONE - ?ETH_LINK_UP - :ETH_LINK_DOWN ; + new_link.link_status = vf->link_up ?ETH_LINK_UP :ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds Ð_LINK_SPEED_FIXED );
Signature · 1 line
2.17.1
PATCH v10 6/24 net/ice: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/ice/ice_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +4 -1
@@ -3135,8 +3135,11 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) link.link_speed =ETH_SPEED_NUM_100G ;break ;case ICE_AQ_LINK_SPEED_UNKNOWN : -default :PMD_DRV_LOG (ERR ,"Unknown link speed" ); + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +break ; +default : +PMD_DRV_LOG (ERR ,"None link speed" ); link.link_speed =ETH_SPEED_NUM_NONE ;break ; }
Signature · 1 line
2.17.1
PATCH v10 7/24 examples: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications:
* ipv4_multicast
* l2fwd-jobstats
* l2fwd-keepalive
* l3fwd
* link_status_interrupt
--- examples/ipv4_multicast/main.c | 14 ++++++------- examples/l2fwd-jobstats/main.c | 13 +++++------- examples/l2fwd-keepalive/main.c | 13 +++++------- examples/l3fwd/main.c | 13 +++++------- examples/link_status_interrupt/main.c | 30 +++++++++++---------------- 5 files changed, 33 insertions(+), 50 deletions(-)
examples/ipv4_multicast/main.c +6 -8
@@ -572,6 +572,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -591,14 +592,11 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
examples/l2fwd-jobstats/main.c +5 -8
@@ -689,6 +689,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -708,14 +709,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
examples/l2fwd-keepalive/main.c +5 -8
@@ -453,6 +453,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -472,14 +473,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
examples/l3fwd/main.c +5 -8
@@ -810,6 +810,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -833,14 +834,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
examples/link_status_interrupt/main.c +12 -18
@@ -133,7 +133,7 @@ print_stats(void) link_get_err =rte_eth_link_get_nowait (portid, &link);printf ("\nStatistics for port %u ------------------------------" "\nLink status: %25s" -"\nLink speed: %26u" +"\nLink speed: %26s" "\nLink duplex: %25s" "\nPackets sent: %24" PRIu64 "\nPackets received: %20"PRIu64
@@ -141,8 +141,8 @@ print_stats(void) portid, link_get_err <0 ?"Link get failed" : (link.link_status ?"Link up" :"Link down" ), - link_get_err <0 ?0 : - (unsigned int )link.link_speed, + link_get_err <0 ?"0" : +rte_eth_link_speed_to_str (link.link_speed), link_get_err <0 ?"Link get failed" : (link.link_duplex ==ETH_LINK_FULL_DUPLEX ? \ "full-duplex" : "half-duplex"),
@@ -445,6 +445,7 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, {struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];RTE_SET_USED (param);RTE_SET_USED (ret_param);
@@ -457,13 +458,9 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, 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, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else -printf ("Port %d Link Down\n\n" , port_id); +rte_eth_link_to_str (link_status_text,sizeof (link_status_text), +NULL , &link); +printf ("Port %d %s\n\n" , port_id, link_status_text);return 0 ; }
@@ -478,6 +475,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -497,14 +495,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v10 8/24 examples/bbdev_app: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/bbdev_app/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
examples/bbdev_app/main.c +4 -2
@@ -326,8 +326,10 @@ check_port_link_status(uint16_t port_id)const char *dp = (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ?"full-duplex" :"half-duplex" ; -printf ("\nPort %u Link Up - speed %u Mbps - %s\n" , - port_id, link.link_speed, dp); +printf ("\nPort %u Link Up - speed %s Mbps - %s\n" , + port_id, +rte_eth_link_speed_to_str (link.link_speed), + dp);return 0 ; }printf ("." );
Signature · 1 line
2.17.1
PATCH v10 9/24 examples/ioat: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/ioat/ioatfwd.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
examples/ioat/ioatfwd.c +6 -8
@@ -700,6 +700,7 @@ check_link_status(uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret, link_status =0 ; +char link_status_text[RTE_ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status\n" );RTE_ETH_FOREACH_DEV (portid) {
@@ -715,15 +716,12 @@ check_link_status(uint32_t port_mask) }/* Print link status */ -if (link.link_status) { -printf ( -"Port %d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text), &link); +printf ("Port %d %s\n" , portid, link_status_text); + +if (link.link_status) link_status =1 ; - }else -printf ("Port %d Link Down\n" , portid); }return link_status; }
Signature · 1 line
2.17.1
PATCH v10 10/24 examples/ip_*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications:
* ip_fragmentation
* ip_reassembly
* l3fwd-acl
--- examples/ip_fragmentation/main.c | 13 +++++-------- examples/ip_reassembly/main.c | 13 +++++-------- examples/l3fwd-acl/main.c | 13 +++++-------- 3 files changed, 15 insertions(+), 24 deletions(-)
examples/ip_fragmentation/main.c +5 -8
@@ -593,6 +593,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -612,14 +613,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
examples/ip_reassembly/main.c +5 -8
@@ -712,6 +712,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -731,14 +732,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
examples/l3fwd-acl/main.c +5 -8
@@ -1815,6 +1815,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -1834,14 +1835,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
Signature · 1 line
2.17.1
PATCH v10 11/24 examples/ip_pipeline: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_speed_to_str function to example applications
--- examples/ip_pipeline/cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
examples/ip_pipeline/cli.c +2 -2
@@ -273,7 +273,7 @@ print_link_info(struct link *link, char *out, size_t out_size)"\n" "%s: flags=<%s> mtu %u\n" "\tether %02X:%02X:%02X:%02X:%02X:%02X rxqueues %u txqueues %u\n" -"\tport# %u speed %u Mbps\n" +"\tport# %u speed %s Mbps\n" "\tRX packets %" PRIu64" bytes %" PRIu64"\n" "\tRX errors %" PRIu64" missed %" PRIu64" no-mbuf %" PRIu64"\n" "\tTX packets %" PRIu64" bytes %" PRIu64"\n"
@@ -287,7 +287,7 @@ print_link_info(struct link *link, char *out, size_t out_size) link->n_rxq, link->n_txq, link->port_id, - eth_link.link_speed, +rte_eth_link_speed_to_str (eth_link.link_speed), stats.ipackets, stats.ibytes, stats.ierrors,
Signature · 1 line
2.17.1
PATCH v10 12/24 examples/ipsec-secgw: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/ipsec-secgw/ipsec-secgw.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +5 -8
@@ -1775,6 +1775,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -1794,14 +1795,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
Signature · 1 line
2.17.1
PATCH v10 13/24 examples/kni: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/kni/main.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-)
examples/kni/main.c +10 -17
@@ -661,6 +661,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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\n" );fflush (stdout);
@@ -680,14 +681,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 %uMbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
@@ -717,19 +714,15 @@ check_all_ports_link_status(uint32_t port_mask)static void log_link_state (struct rte_kni *kni,int prev,struct rte_eth_link *link) { +char link_status_text[60 ];if (kni ==NULL || link ==NULL )return ; -if (prev ==ETH_LINK_DOWN && link->link_status ==ETH_LINK_UP ) { -RTE_LOG (INFO ,APP ,"%s NIC Link is Up %d Mbps %s %s.\n" , +rte_eth_link_to_str (link_status_text,60 ,NULL , link); +if (prev != link->link_status) +RTE_LOG (INFO ,APP ,"%s NIC %s" ,rte_kni_get_name (kni), - link->link_speed, - link->link_autoneg ?"(AutoNeg)" :"(Fixed)" , - link->link_duplex ?"Full Duplex" :"Half Duplex" ); - }else if (prev ==ETH_LINK_UP && link->link_status ==ETH_LINK_DOWN ) { -RTE_LOG (INFO ,APP ,"%s NIC Link is Down.\n" , -rte_kni_get_name (kni)); - } + link_status_text); }/*
Signature · 1 line
2.17.1
PATCH v10 14/24 examples/l2fwd-crypt: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l2fwd-crypto/main.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/l2fwd-crypto/main.c +5 -8
@@ -1734,6 +1734,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -1753,14 +1754,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
Signature · 1 line
2.17.1
PATCH v10 15/24 examples/l2fwd-event: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l2fwd-event/main.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/l2fwd-event/main.c +5 -8
@@ -366,6 +366,7 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc,uint8_t 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);
@@ -389,14 +390,10 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc, }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - port_id, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , port_id); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text), &link); +printf ("Port %d %s\n" , port_id, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v10 16/24 examples/l2fwd: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l2fwd/main.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/l2fwd/main.c +5 -8
@@ -571,6 +571,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -594,14 +595,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
Signature · 1 line
2.17.1
PATCH v10 17/24 examples/l3fwd-graph: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l3fwd-graph/main.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
examples/l3fwd-graph/main.c +5 -10
@@ -599,6 +599,7 @@ check_all_ports_link_status(uint32_t port_mask)struct rte_eth_link link;uint16_t portid;int ret; +char link_status_text[RTE_ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -623,16 +624,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" , - portid, link.link_speed, - (link.link_duplex == -ETH_LINK_FULL_DUPLEX ) - ? ("full-duplex" ) - : ("half-duplex\n" )); -else -printf ("Port %d Link Down\n" , 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 */
Signature · 1 line
2.17.1
PATCH v10 18/24 examples/l3fwd-power: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/l3fwd-power/main.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
examples/l3fwd-power/main.c +5 -9
@@ -1945,6 +1945,7 @@ check_all_ports_link_status(uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[RTE_ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -1964,15 +1965,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" , (uint8_t )portid, - (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - (uint8_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 */
Signature · 1 line
2.17.1
PATCH v10 19/24 examples/multi_proc*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- .../client_server_mp/mp_server/init.c | 15 ++++++--------- examples/multi_process/symmetric_mp/main.c | 13 +++++-------- 2 files changed, 11 insertions(+), 17 deletions(-)
examples/multi_process/client_server_mp/mp_server/init.c +6 -9
@@ -185,6 +185,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t 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);
@@ -204,15 +205,11 @@ check_all_ports_link_status(uint16_t port_num, 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" , ports->id[portid], - (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - (uint8_t )ports->id[portid]); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text), &link); +printf ("Port %d %s\n" , + (uint8_t )ports->id[portid], + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/multi_process/symmetric_mp/main.c +5 -8
@@ -365,6 +365,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t 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);
@@ -384,14 +385,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
Signature · 1 line
2.17.1
PATCH v10 20/24 examples/ntb: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ntb/ntb_fwd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
examples/ntb/ntb_fwd.c +6 -5
@@ -729,6 +729,7 @@ start_pkt_fwd(void)struct rte_eth_link eth_link;uint32_t lcore_id;int ret, i; +char link_status_text[RTE_ETH_LINK_MAX_STR_LEN ]; ret =ntb_fwd_config_setup ();if (ret <0 ) {
@@ -747,11 +748,11 @@ start_pkt_fwd(void)return ; }if (eth_link.link_status) { -printf ("Eth%u Link Up. Speed %u Mbps - %s\n" , - eth_port_id, eth_link.link_speed, - (eth_link.link_duplex == -ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text), + ð_link); +printf ("Eth%u %s\n" , eth_port_id, + link_status_text);break ; } }
Signature · 1 line
2.17.1
PATCH v10 21/24 example/performance*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/performance-thread/l3fwd-thread/main.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/performance-thread/l3fwd-thread/main.c +5 -8
@@ -3433,6 +3433,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -3452,14 +3453,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
Signature · 1 line
2.17.1
PATCH v10 22/24 examples/qos_sched: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/qos_sched/init.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/qos_sched/init.c +4 -8
@@ -76,6 +76,7 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)uint16_t rx_size;uint16_t tx_size;struct rte_eth_conf local_port_conf = port_conf; +char link_status_text[RTE_ETH_LINK_MAX_STR_LEN ];/* check if port already initialized (multistream configuration) */ if (app_inited_port_mask & (1u << portid))
@@ -160,14 +161,9 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)"rte_eth_link_get: err=%d, port=%u: %s\n" , ret, portid, rte_strerror(-ret)); -if (link.link_status) { -printf (" Link Up - speed %u Mbps - %s\n" , - (uint32_t ) link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else { -printf (" Link Down\n" ); - } +rte_eth_link_to_str (link_status_text,sizeof (link_status_text), &link); +printf ("%s\n" , link_status_text); + ret =rte_eth_promiscuous_enable (portid);if (ret !=0 ) rte_exit(EXIT_FAILURE,
Signature · 1 line
2.17.1
PATCH v10 23/24 examples/server_nod*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/server_node_efd/server/init.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
examples/server_node_efd/server/init.c +5 -10
@@ -247,6 +247,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[RTE_ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -266,16 +267,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , - info->id[portid], - link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - info->id[portid]); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text), &link); +printf ("Port %d %s\n" , info->id[portid], + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v10 24/24 examples/vm_power_*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/vm_power_manager/main.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
examples/vm_power_manager/main.c +5 -9
@@ -244,6 +244,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);
@@ -267,15 +268,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 */
Signature · 1 line
2.17.1
v11 cover ethdev: allow unknown link speed
In reply to Ivan DyukovMAINTAINERS | 1 + app/proc-info/main.c | 11 ++--- app/test-pipeline/init.c | 11 ++--- app/test-pmd/config.c | 9 ++-- app/test-pmd/testpmd.c | 12 ++--- app/test/Makefile | 3 ++ app/test/meson.build | 2 + app/test/test_ethdev_link.c | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app/test/test_pmd_perf.c | 17 +++---- doc/guides/sample_app_ug/link_status_intr.rst | 10 ++-- drivers/net/i40e/i40e_ethdev.c | 5 +- drivers/net/i40e/i40e_ethdev_vf.c | 10 ++-- drivers/net/ice/ice_ethdev.c | 5 +- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +-- examples/bbdev_app/main.c | 6 ++- examples/ioat/ioatfwd.c | 14 +++--- examples/ip_fragmentation/main.c | 13 ++---- examples/ip_pipeline/cli.c | 4 +- examples/ip_reassembly/main.c | 13 ++---- examples/ipsec-secgw/ipsec-secgw.c | 13 ++---- examples/ipv4_multicast/main.c | 14 +++--- examples/kni/main.c | 27 ++++------- examples/l2fwd-crypto/main.c | 13 ++---- examples/l2fwd-event/main.c | 13 ++---- examples/l2fwd-jobstats/main.c | 13 ++---- examples/l2fwd-keepalive/main.c | 13 ++---- examples/l2fwd/main.c | 13 ++---- examples/l3fwd-acl/main.c | 13 ++---- examples/l3fwd-graph/main.c | 15 ++---- examples/l3fwd-power/main.c | 14 ++---- examples/l3fwd/main.c | 13 ++---- examples/link_status_interrupt/main.c | 30 +++++------- examples/multi_process/client_server_mp/mp_server/init.c | 15 +++--- examples/multi_process/symmetric_mp/main.c | 13 ++---- examples/ntb/ntb_fwd.c | 11 +++-- examples/performance-thread/l3fwd-thread/main.c | 13 ++---- examples/qos_sched/init.c | 12 ++--- examples/server_node_efd/server/init.c | 15 ++---- examples/vm_power_manager/main.c | 14 ++---- lib/librte_ethdev/rte_ethdev.c | 37 +++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 52 +++++++++++++++++---- lib/librte_ethdev/rte_ethdev_version.map | 4 ++ 42 files changed, 439 insertions(+), 272 deletions(-)
v11 changes:
* 0 Mbps => None
* Invalid speed => Invalid
* Change code style of rte_eth_link_speed_to_str
v10 changes:
* remove format string arg from rte_eth_link_to_str function
* add rte_eth_link_speed_to_str function
* add usage of rte_eth_link_speed_to_str in examples
v9 changes:
* remove rte_eth_link_printf function
* add ETH_LINK_MAX_STR_LEN definition
* add usage of ETH_LINK_MAX_STR_LEN in examples
v8 changes:
* rename rte_eth_link_strf to rte_eth_link_to_str
* refactor rte_eth_link_to_str according to review comments
* fix codestyle
* fix commit message in 02 patch
* fix compile error in ntb application
* merge "app" and "doc" commits
v7 changes:
* fix meson build
* change _strf function. now it does not fails in case of unknown specifiers like %d. it just copy it to target string.
* remove invalid_fmt unit test.
* add unknown specifier test.
* fix codestyle
v6 changes:
* fix spelling in comments according to checkpatch warning
v5 changes:
* rename rte_eth_link_format to rte_eth_link_strf
* add '\n' to default strings
* update remaining examples. patch with subj 'examples: new link status print format' contains examples which have no maintainers. TBD:
update remaining nic drivers with 'unknown' speed. It should be provided in separate patchset.
v4 changes:
* refactor rte_eth_link_format using strlcat func instead of snprintf
* added new checks to unit tests
* few minor fixes according review comments
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v3 changes:
* remove rte_eth_link_prepare_text function
* add rte_eth_link_format and rte_eth_link_printf functions
* added unit tests for rte_eth_link_format function
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v2 changes:
* add function which format link status to textual representation
* update drivers for Intel nics with 'unknown' speed
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
PATCH v11 1/24 ethdev: allow unknown link speed
From: Thomas Monjalon <[email protected]>
When querying the link information, the link status is a mandatory major information.
Other boolean values are supposed to be accurate:
- duplex mode (half/full)
- negotiation (auto/fixed)
This API update is making explicit that the link speed information is optional.
The value ETH_SPEED_NUM_NONE (0) was already part of the API. The value ETH_SPEED_NUM_UNKNOWN (infinite) is added to cover two different cases:
- speed is not known by the driver
- device is virtual
--- lib/librte_ethdev/rte_ethdev.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
lib/librte_ethdev/rte_ethdev.h +10 -10
@@ -303,6 +303,7 @@ struct rte_eth_stats {#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ #define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ #define ETH_SPEED_NUM_200G 200000/**< 200 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN UINT32_MAX/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
@@ -2262,15 +2263,16 @@ int rte_eth_allmulticast_disable(uint16_t port_id);int rte_eth_allmulticast_get (uint16_t port_id);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It might need -* to wait up to 9 seconds in it. +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). +* +* It might need to wait up to 9 seconds. +* @see rte_eth_link_get_nowait. * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
@@ -2279,15 +2281,13 @@ int rte_eth_allmulticast_get(uint16_t port_id);int rte_eth_link_get (uint16_t port_id,struct rte_eth_link *link);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait -* version of rte_eth_link_get(). +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
Signature · 1 line
2.17.1
PATCH v11 2/24 ethdev: format a link status text
In reply to Ivan DyukovThere is new link_speed value introduced. It's INT_MAX value which means that speed is unknown. To simplify processing of the value in application, new function is added which convert link_speed to string. Also dpdk examples have many duplicated code which format entire link status structure to text.
This commit adds two functions:
* rte_eth_link_speed_to_str - format link_speed to string
* rte_eth_link_to_str - convert link status structure to string
--- MAINTAINERS | 1 + app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 169 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 37 +++++ lib/librte_ethdev/rte_ethdev.h | 32 +++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + 7 files changed, 248 insertions(+) create mode 100644 app/test/test_ethdev_link.c
MAINTAINERS +1 -0
@@ -393,6 +393,7 @@ T: git://dpdk.org/next/dpdk-next-net F: lib/librte_ethdev/ F: devtools/test-null.sh F: doc/guides/prog_guide/switch_representation.rst +F: app/test/test_ethdev* Flow API M: Ori Kam <[email protected]>
app/test/Makefile +3 -0
@@ -251,6 +251,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c test_ipsec_perf.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c + +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c + ifeq ($(CONFIG_RTE_LIBRTE_IPSEC),y) LDLIBS += -lrte_ipsec endif
app/test/meson.build +2 -0
@@ -39,6 +39,7 @@ test_sources = files('commands.c', 'test_efd.c', 'test_efd_perf.c', 'test_errno.c', + 'test_ethdev_link.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',
@@ -199,6 +200,7 @@ fast_tests = [ ['eal_flags_misc_autotest', false], ['eal_fs_autotest', true], ['errno_autotest', true], + ['ethdev_link_status', true], ['event_ring_autotest', true], ['fib_autotest', true], ['fib6_autotest', true],
app/test/test_ethdev_link.c new file +169 -0
169 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.c +37 -0
@@ -2383,6 +2383,43 @@ rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)return 0 ; } +const char * +rte_eth_link_speed_to_str (uint32_t link_speed) +{ +switch (link_speed) { +case ETH_SPEED_NUM_NONE :return "None" ; +case ETH_SPEED_NUM_10M :return "10 Mbps" ; +case ETH_SPEED_NUM_100M :return "100 Mbps" ; +case ETH_SPEED_NUM_1G :return "1 Gbps" ; +case ETH_SPEED_NUM_2_5G :return "2.5 Gbps" ; +case ETH_SPEED_NUM_5G :return "5 Gbps" ; +case ETH_SPEED_NUM_10G :return "10 Gbps" ; +case ETH_SPEED_NUM_20G :return "20 Gbps" ; +case ETH_SPEED_NUM_25G :return "25 Gbps" ; +case ETH_SPEED_NUM_40G :return "40 Gbps" ; +case ETH_SPEED_NUM_50G :return "50 Gbps" ; +case ETH_SPEED_NUM_56G :return "56 Gbps" ; +case ETH_SPEED_NUM_100G :return "100 Gbps" ; +case ETH_SPEED_NUM_200G :return "200 Gbps" ; +case ETH_SPEED_NUM_UNKNOWN :return "Unknown" ; +default :return "Invalid" ; + } +} + +int +rte_eth_link_to_str (char *str,size_t len,const struct rte_eth_link *eth_link) +{ +if (eth_link->link_status ==ETH_LINK_DOWN ) +return snprintf (str, len,"Link down" ); +else +return snprintf (str, len,"Link up at %s %s %s" , +rte_eth_link_speed_to_str (eth_link->link_speed), + (eth_link->link_duplex ==ETH_LINK_FULL_DUPLEX ) ? +"FDX" :"HDX" , + (eth_link->link_autoneg ==ETH_LINK_AUTONEG ) ? +"Autoneg" :"Fixed" ); +} +int rte_eth_stats_get (uint16_t port_id,struct rte_eth_stats *stats) {
lib/librte_ethdev/rte_ethdev.h +32 -0
@@ -323,6 +323,7 @@ struct rte_eth_link {#define ETH_LINK_UP 1/**< Link is up (see link_status). */ #define ETH_LINK_FIXED 0/**< No autonegotiation (see link_autoneg). */ #define ETH_LINK_AUTONEG 1/**< Autonegotiated (see link_autoneg). */ +#define RTE_ETH_LINK_MAX_STR_LEN 40/**< Max length of default link string. */ /** * A structure used to configure the ring threshold registers of an RX/TX
@@ -2295,6 +2296,37 @@ int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);*/ int rte_eth_link_get_nowait (uint16_t port_id,struct rte_eth_link *link); +/** +* The function converts a link_speed to a string. It handles all special +* values like unknown or none speed. +* @param link_speed +* link_speed of rte_eth_link struct +* @return +* Link speed in textual format. It's pointer to immutable memory. +* No free is required. +*/ +__rte_experimental +const char *rte_eth_link_speed_to_str(uint32_t speed_link); + +/** +* The function converts a rte_eth_link struct representing a link status to +* a string. +* @param str +* A pointer to a string to be filled with textual representation of +* device status. At least ETH_LINK_MAX_STR_LEN bytes should be allocated to +* store default link status text. +* @param len +* Length of available memory at 'str' string. +* @param eth_link +* Link status returned by rte_eth_link_get function +* @return +* - Number of bytes written to str array. +* +*/ +__rte_experimental +int rte_eth_link_to_str(char *str, size_t len, +const struct rte_eth_link *eth_link); +/** * Retrieve the general I/O statistics of an Ethernet device. *
lib/librte_ethdev/rte_ethdev_version.map +4 -0
@@ -241,4 +241,8 @@ EXPERIMENTAL { __rte_ethdev_trace_rx_burst; __rte_ethdev_trace_tx_burst; rte_flow_get_aged_flows; + + # added in 20.11 + rte_eth_link_to_str; + rte_eth_link_speed_to_str; };
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v11 02/24] ethdev: format a link status text
Quoted 376 lines
From: Ivan Dyukov [mailto:[email protected]]
Sent: Tuesday, September 15, 2020 9:07 PMThere is new
link_speedvalue introduced. It'sINT_MAXvalue which means that speed is unknown. To simplify processing of the value in application, new function is added which convertlink_speedto string. Also dpdk examples have many duplicated code which format entire link status structure to text.This commit adds two functions:
*rte_eth_link_speed_to_str- formatlink_speedto string
*rte_eth_link_to_str- convert link status structure to stringSigned-off-by Ivan Dyukov <[email protected]>--- MAINTAINERS | 1 + app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 169 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 37 +++++ lib/librte_ethdev/rte_ethdev.h | 32 +++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + 7 files changed, 248 insertions(+) create mode 100644 app/test/test_ethdev_link.cMAINTAINERS +1
-0@@ -393,6 +393,7 @@ T: git://dpdk.org/next/dpdk-next-net F: lib/librte_ethdev/ F: devtools/test-null.sh F: doc/guides/prog_guide/switch_representation.rst +F: app/test/test_ethdev* Flow API M: Ori Kam <[email protected]>app/test/Makefile +0
-0@@ -251,6 +251,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) +=
test_security.cSRCS-$(CONFIG_RTE_LIBRTE_IPSEC) +=
test_ipsec.ctest_ipsec_perf.cSRCS-$(CONFIG_RTE_LIBRTE_IPSEC) +=test_ipsec_sad.capp/test/Makefile +3
-0+ +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c + ifeq ($(CONFIG_RTE_LIBRTE_IPSEC),y) LDLIBS += -lrte_ipsec endifapp/test/meson.build +2
-0@@ -39,6 +39,7 @@ test_sources = files('commands.c', 'test_efd.c', 'test_efd_perf.c', 'test_errno.c', + 'test_ethdev_link.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',@@ -199,6 +200,7 @@ fast_tests = [ ['eal_flags_misc_autotest', false], ['eal_fs_autotest', true], ['errno_autotest', true], + ['ethdev_link_status', true], ['event_ring_autotest', true], ['fib_autotest', true], ['fib6_autotest', true],app/test/test_ethdev_link.c new file +104
-0@@ -0,0 +1,169 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved +*/ + +#include <rte_log.h> +#include <rte_ethdev.h> + +#include <rte_test.h> +#include "test.h" + + +static int32_t +test_link_status_up_default (void ) +{ +int ret =0 ; +struct rte_eth_link link_status = { + .link_speed =ETH_SPEED_NUM_2_5G , + .link_status =ETH_LINK_UP , + .link_autoneg =ETH_LINK_AUTONEG , + .link_duplex =ETH_LINK_FULL_DUPLEX + }; +char text[RTE_ETH_LINK_MAX_STR_LEN ]; + + ret =rte_eth_link_to_str (text,sizeof (text), &link_status); +RTE_TEST_ASSERT (ret >0 ,"Failed to format default string\n" ); +printf ("Default link up #1: %s\n" , text); +TEST_ASSERT_BUFFERS_ARE_EQUAL ("Link up at 2.5 Gbps FDX Autoneg" , + text,strlen (text),"Invalid default link status string" ); + + link_status.link_duplex =ETH_LINK_HALF_DUPLEX ; + link_status.link_autoneg =ETH_LINK_FIXED ; + link_status.link_speed =ETH_SPEED_NUM_10M , + ret =rte_eth_link_to_str (text,sizeof (text), &link_status); +printf ("Default link up #2: %s\n" , text); +RTE_TEST_ASSERT (ret >0 ,"Failed to format default string\n" ); +TEST_ASSERT_BUFFERS_ARE_EQUAL ("Link up at 10 Mbps HDX Fixed" , + text,strlen (text),"Invalid default link status " +"string with HDX" ); + + link_status.link_speed =ETH_SPEED_NUM_UNKNOWN ; + ret =rte_eth_link_to_str (text,sizeof (text), &link_status); +printf ("Default link up #3: %s\n" , text); +RTE_TEST_ASSERT (ret >0 ,"Failed to format default string\n" ); +TEST_ASSERT_BUFFERS_ARE_EQUAL ("Link up at Unknown HDX Fixed" , + text,strlen (text),"Invalid default link status " +"string with HDX" ); + + link_status.link_speed =ETH_SPEED_NUM_NONE ; + ret =rte_eth_link_to_str (text,sizeof (text), &link_status); +printf ("Default link up #3: %s\n" , text); +RTE_TEST_ASSERT (ret >0 ,"Failed to format default string\n" ); +TEST_ASSERT_BUFFERS_ARE_EQUAL ("Link up at None HDX Fixed" , + text,strlen (text),"Invalid default link status " +"string with HDX" ); + +/* test max str len */ + link_status.link_speed =ETH_SPEED_NUM_200G ; + link_status.link_duplex =ETH_LINK_HALF_DUPLEX ; + link_status.link_autoneg =ETH_LINK_AUTONEG ; + ret =rte_eth_link_to_str (text,sizeof (text), &link_status); +printf ("Default link up #4:len = %d, %s\n" , ret, text); +RTE_TEST_ASSERT (ret <RTE_ETH_LINK_MAX_STR_LEN , +"String length exceeds max allowed value\n" ); +return TEST_SUCCESS ; +} + +static int32_t +test_link_status_down_default (void ) +{ +int ret =0 ; +struct rte_eth_link link_status = { + .link_speed =ETH_SPEED_NUM_2_5G , + .link_status =ETH_LINK_DOWN , + .link_autoneg =ETH_LINK_AUTONEG , + .link_duplex =ETH_LINK_FULL_DUPLEX + }; +char text[RTE_ETH_LINK_MAX_STR_LEN ]; + + ret =rte_eth_link_to_str (text,sizeof (text), &link_status); +RTE_TEST_ASSERT (ret >0 ,"Failed to format default string\n" ); +TEST_ASSERT_BUFFERS_ARE_EQUAL ("Link down" , + text,strlen (text),"Invalid default link status string" ); + +return TEST_SUCCESS ; +} + +static int32_t +test_link_status_invalid (void ) +{ +int ret =0 ; +struct rte_eth_link link_status = { + .link_speed =55555 , + .link_status =ETH_LINK_UP , + .link_autoneg =ETH_LINK_AUTONEG , + .link_duplex =ETH_LINK_FULL_DUPLEX + }; +char text[RTE_ETH_LINK_MAX_STR_LEN ]; + + ret =rte_eth_link_to_str (text,sizeof (text), &link_status); +RTE_TEST_ASSERT (ret <RTE_ETH_LINK_MAX_STR_LEN , +"Failed to format invalid string\n" ); +printf ("invalid link up #1: len=%d %s\n" , ret, text); + TEST_ASSERT_BUFFERS_ARE_EQUAL("Link up at Invalid FDX Autoneg", + text, strlen(text), "Incorrect invalid link statusstring");
app/test/test_ethdev_link.c new file +33
-0+ +return TEST_SUCCESS ; +} + + +static int32_t +test_link_speed_all_values(void) +{ + const char *speed; + uint32_t i; + struct link_speed_t { + const char *value; + uint32_t link_speed; + } speed_str_map[] = { + { "None", ETH_SPEED_NUM_NONE }, + { "10 Mbps", ETH_SPEED_NUM_10M }, + { "100 Mbps", ETH_SPEED_NUM_100M }, + { "1 Gbps", ETH_SPEED_NUM_1G }, + { "2.5 Gbps", ETH_SPEED_NUM_2_5G }, + { "5 Gbps", ETH_SPEED_NUM_5G }, + { "10 Gbps", ETH_SPEED_NUM_10G }, + { "20 Gbps", ETH_SPEED_NUM_20G }, + { "25 Gbps", ETH_SPEED_NUM_25G }, + { "40 Gbps", ETH_SPEED_NUM_40G }, + { "50 Gbps", ETH_SPEED_NUM_50G }, + { "56 Gbps", ETH_SPEED_NUM_56G }, + { "100 Gbps", ETH_SPEED_NUM_100G }, + { "200 Gbps", ETH_SPEED_NUM_200G }, + { "Unknown", ETH_SPEED_NUM_UNKNOWN }, + { "Invalid", 50505 } + }; + + for (i = 0; i < sizeof(speed_str_map) / sizeof(struct
link_speed_t);app/test/test_ethdev_link.c new file +2
-0+ i++) { + speed =
rte_eth_link_speed_to_str(speed_str_map[i].link_speed);app/test/test_ethdev_link.c new file +30
-0+TEST_ASSERT_BUFFERS_ARE_EQUAL (speed_str_map[i].value, + speed,strlen (speed_str_map[i].value), +"Invalid link speed string" ); + } +return TEST_SUCCESS ; +} + +static struct unit_test_suite link_status_testsuite = { + .suite_name ="link status formatting" , + .setup =NULL , + .teardown =NULL , + .unit_test_cases = { +TEST_CASE (test_link_status_up_default), +TEST_CASE (test_link_status_down_default), +TEST_CASE (test_link_speed_all_values), +TEST_CASE (test_link_status_invalid), +TEST_CASES_END ()/**< NULL terminate unit test array */ + } +}; + +static int +test_link_status (void ) +{ +rte_log_set_global_level (RTE_LOG_DEBUG ); +rte_log_set_level (RTE_LOGTYPE_EAL ,RTE_LOG_DEBUG ); + +return unit_test_suite_runner (&link_status_testsuite); +} + +REGISTER_TEST_COMMAND (ethdev_link_status, test_link_status);lib/librte_ethdev/rte_ethdev.c +37
-0@@ -2383,6 +2383,43 @@ rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)return 0 ; } +const char * +rte_eth_link_speed_to_str (uint32_t link_speed) +{ +switch (link_speed) { +case ETH_SPEED_NUM_NONE :return "None" ; +case ETH_SPEED_NUM_10M :return "10 Mbps" ; +case ETH_SPEED_NUM_100M :return "100 Mbps" ; +case ETH_SPEED_NUM_1G :return "1 Gbps" ; +case ETH_SPEED_NUM_2_5G :return "2.5 Gbps" ; +case ETH_SPEED_NUM_5G :return "5 Gbps" ; +case ETH_SPEED_NUM_10G :return "10 Gbps" ; +case ETH_SPEED_NUM_20G :return "20 Gbps" ; +case ETH_SPEED_NUM_25G :return "25 Gbps" ; +case ETH_SPEED_NUM_40G :return "40 Gbps" ; +case ETH_SPEED_NUM_50G :return "50 Gbps" ; +case ETH_SPEED_NUM_56G :return "56 Gbps" ; +case ETH_SPEED_NUM_100G :return "100 Gbps" ; +case ETH_SPEED_NUM_200G :return "200 Gbps" ; +case ETH_SPEED_NUM_UNKNOWN :return "Unknown" ; +default :return "Invalid" ; + } +} + +int +rte_eth_link_to_str (char *str,size_t len,const struct rte_eth_link *eth_link) +{ +if (eth_link->link_status ==ETH_LINK_DOWN ) +return snprintf (str, len,"Link down" ); +else +return snprintf (str, len,"Link up at %s %s %s" , +rte_eth_link_speed_to_str (eth_link->link_speed), + (eth_link->link_duplex ==ETH_LINK_FULL_DUPLEX ) ? +"FDX" :"HDX" , + (eth_link->link_autoneg ==ETH_LINK_AUTONEG ) ? +"Autoneg" :"Fixed" ); +} +int
rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats){lib/librte_ethdev/rte_ethdev.h +0
-0@@ -323,6 +323,7 @@ struct rte_eth_link {#define ETH_LINK_UP 1/**< Link is up (see link_status). */ #define ETH_LINK_FIXED 0/**< No autonegotiation (see
link_autoneg). */
#defineETH_LINK_AUTONEG1 /**< Autonegotiated (seelink_autoneg).
*/
+#defineRTE_ETH_LINK_MAX_STR_LEN40 /**< Max length of default link string. *//**
* A structure used to configure the ring threshold registers of an
RX/TXlib/librte_ethdev/rte_ethdev.h +2
-0@@ -2295,6 +2296,37 @@ int rte_eth_link_get(uint16_t port_id, structrte_eth_link *link); */ int rte_eth_link_get_nowait (uint16_t port_id,struct rte_eth_link *link); +/** +* The function converts a link_speed to a string. It handles all special
+ * values like unknown or none speed.
+ * @paramlink_speed
+ *link_speedofrte_eth_linkstruct
+ * @return
+ * Link speed in textual format. It's pointer to immutable memory.
+ * No free is required.
+ */lib/librte_ethdev/rte_ethdev.h +5
-0+__rte_experimental +const char *rte_eth_link_speed_to_str(uint32_t speed_link); + +/** +* The function converts a rte_eth_link struct representing a link status to
+ * a string.
+ * @param str
+ * A pointer to a string to be filled with textual representation of
+ * device status. At leastETH_LINK_MAX_STR_LENbytes should be
allocated to
+ * store default link status text.
+ * @param len
+ * Length of available memory at 'str' string.
+ * @parameth_link
+ * Link status returned byrte_eth_link_getfunction
+ * @return
+ * - Number of bytes written to str array.
+ *
+ */lib/librte_ethdev/rte_ethdev.h +4
-0+__rte_experimental +int rte_eth_link_to_str(char *str, size_t len, +const struct rte_eth_link *eth_link); +/** * Retrieve the general I/O statistics of an Ethernet device. * lib/librte_ethdev/rte_ethdev_version.map +4
-1@@ -241,4 +241,8 @@ EXPERIMENTAL { __rte_ethdev_trace_rx_burst; __rte_ethdev_trace_tx_burst; rte_flow_get_aged_flows; + + # added in 20.11 + rte_eth_link_to_str; + rte_eth_link_speed_to_str; }; --
Quoted 2 lines
2.17.1
Great work, Ivan!
Ferruh Yigit
Reviewed-byRe: [dpdk-dev] [PATCH v11 02/24] ethdev: format a link status text
Quoted 9 lines · Morten Brørup
Quoted 9 lines
From: Ivan Dyukov [mailto:[email protected]]
Sent: Tuesday, September 15, 2020 9:07 PMThere is new
link_speedvalue introduced. It'sINT_MAXvalue which means that speed is unknown. To simplify processing of the value in application, new function is added which convertlink_speedto string. Also dpdk examples have many duplicated code which format entire link status structure to text.
Quoted 8 lines
Quoted 5 lines
This commit adds two functions:
*rte_eth_link_speed_to_str- formatlink_speedto string
*rte_eth_link_to_str- convert link status structure to stringSigned-off-by Ivan Dyukov <[email protected]>Great work, Ivan!
+1
Quoted 2 lines
Acked-by Morten Brørup <[email protected]>
PATCH v11 3/24 app: update apps&docs with new UNKNOWN link speed
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications and docs
--- app/proc-info/main.c | 11 +++++------ app/test-pipeline/init.c | 11 +++++------ app/test-pmd/config.c | 9 +++++---- app/test-pmd/testpmd.c | 12 ++++-------- app/test/test_pmd_perf.c | 17 +++++++---------- doc/guides/sample_app_ug/link_status_intr.rst | 10 +++++----- 6 files changed, 31 insertions(+), 39 deletions(-)
app/proc-info/main.c +5 -6
@@ -672,6 +672,7 @@ show_port(void)struct rte_eth_dev_info dev_info;struct rte_eth_rxq_info queue_info;struct rte_eth_rss_conf rss_conf; +char link_status_text[RTE_ETH_LINK_MAX_STR_LEN ];memset (&rss_conf,0 ,sizeof (rss_conf));
@@ -685,12 +686,10 @@ show_port(void)printf ("Link get failed (port %u): %s\n" , i,rte_strerror (-ret)); }else { -printf ("\t -- link speed %d duplex %d," -" auto neg %d status %d\n" , - link.link_speed, - link.link_duplex, - link.link_autoneg, - link.link_status); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text), + &link); +printf ("\t%s\n" , link_status_text); }printf ("\t -- promiscuous (%d)\n" ,rte_eth_promiscuous_get (i));
app/test-pipeline/init.c +5 -6
@@ -155,7 +155,7 @@ static voidapp_ports_check_link (void) {uint32_t all_ports_up, i; - +char link_status_text[RTE_ETH_LINK_MAX_STR_LEN ]; all_ports_up =1 ;for (i =0 ; i < app.n_ports; i++) {
@@ -173,12 +173,11 @@ app_ports_check_link(void) all_ports_up =0 ;continue ; } - -RTE_LOG (INFO ,USER1 ,"Port %u (%u Gbps) %s\n" , +rte_eth_link_to_str (link_status_text,sizeof (link_status_text), + &link); +RTE_LOG (INFO ,USER1 ,"Port %u %s\n" , port, - link.link_speed /1000 , - link.link_status ?"UP" :"DOWN" ); - + link_status_text);if (link.link_status ==ETH_LINK_DOWN ) all_ports_up =0 ; }
app/test-pmd/config.c +5 -4
@@ -605,7 +605,7 @@ port_infos_display(portid_t port_id)printf ("\nmemory allocation on the socket: %u" ,port->socket_id);printf ("\nLink status: %s\n" , (link.link_status) ? ("up" ) : ("down" )); -printf ("Link speed: %u Mbps\n" , (unsigned ) link.link_speed); +printf ("Link speed: %s\n" ,rte_eth_link_speed_to_str (link.link_speed));printf ("Link duplex: %s\n" , (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? ("full-duplex" ) : ("half-duplex" ));
@@ -750,12 +750,12 @@ port_summary_display(portid_t port_id)if (ret !=0 )return ; -printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n" , +printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %s\n" , port_id, mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ], name, dev_info.driver_name, (link.link_status) ? ("up" ) : ("down" ), - (unsigned int ) link.link_speed); +rte_eth_link_speed_to_str (link.link_speed)); }void
@@ -3899,7 +3899,8 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate) ret =eth_link_get_nowait_print_err (port_id, &link);if (ret <0 )return 1 ; -if (rate > link.link_speed) { +if (link.link_speed !=ETH_SPEED_NUM_UNKNOWN && + rate > link.link_speed) {printf ("Invalid rate value:%u bigger than link speed: %u\n" , rate, link.link_speed);return 1 ;
app/test-pmd/testpmd.c +4 -8
@@ -2991,6 +2991,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status[RTE_ETH_LINK_MAX_STR_LEN ];printf ("Checking link statuses...\n" );fflush (stdout);
@@ -3010,14 +3011,9 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status, +sizeof (link_status), &link); +printf ("Port %d %s\n" , portid, link_status);continue ; }/* clear all_ports_up flag if any link down */
app/test/test_pmd_perf.c +7 -10
@@ -126,6 +126,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status[RTE_ETH_LINK_MAX_STR_LEN ];printf ("Checking link statuses...\n" );fflush (stdout);
@@ -146,16 +147,12 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -if (link_mbps ==0 ) - link_mbps = link.link_speed; - }else -printf ("Port %d Link Down\n" , portid); +if (link.link_status && link_mbps ==0 ) + link_mbps = link.link_speed; + +rte_eth_link_to_str (link_status, +sizeof (link_status), &link); +printf ("Port %d %s\n" , portid, link_status);continue ; }/* clear all_ports_up flag if any link down */
doc/guides/sample_app_ug/link_status_intr.rst +5 -5
@@ -158,6 +158,7 @@ An example callback function that has been written as indicated below. { struct rte_eth_link link; int ret; + char link_status[RTE_ETH_LINK_MAX_STR_LEN]; RTE_SET_USED(param);
@@ -169,11 +170,10 @@ An example callback function that has been written as indicated below. if (ret < 0) { printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret)); - } else if (link.link_status) { - printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); - } else - printf("Port %d Link Down\n\n", port_id); + } else { + rte_eth_link_to_str(link_status, sizeof(link_status), &link); + printf("Port %d %s\n", port_id, link_status); + } } This function is called when a link status interrupt is present for the right port.
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v11 03/24] app: update apps&docs with new UNKNOWN link speed
Quoted 5 lines · Ivan Dyukov
Add usage of
rte_eth_link_to_strfunction to example applications and docsSigned-off-by Ivan Dyukov <[email protected]>
PATCH v11 4/24 net/ixgbe: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available
--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -5
@@ -4300,11 +4300,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case IXGBE_LINK_SPEED_100_FULL :
Signature · 1 line
2.17.1
PATCH v11 5/24 net/i40e: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/i40e/i40e_ethdev.c | 5 ++++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_ethdev.c +4 -1
@@ -2891,7 +2891,10 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link, link->link_speed =ETH_SPEED_NUM_40G ;break ;default : - link->link_speed =ETH_SPEED_NUM_NONE ; +if (link->link_status) + link->link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + link->link_speed =ETH_SPEED_NUM_NONE ;break ; } }
drivers/net/i40e/i40e_ethdev_vf.c +5 -5
@@ -2163,15 +2163,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_speed =ETH_SPEED_NUM_40G ;break ;default : - new_link.link_speed =ETH_SPEED_NUM_NONE ; +if (vf->link_up) + new_link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + new_link.link_speed =ETH_SPEED_NUM_NONE ;break ; }/* full duplex only */ new_link.link_duplex =ETH_LINK_FULL_DUPLEX ; - new_link.link_status = vf->link_up && - new_link.link_speed !=ETH_SPEED_NUM_NONE - ?ETH_LINK_UP - :ETH_LINK_DOWN ; + new_link.link_status = vf->link_up ?ETH_LINK_UP :ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds Ð_LINK_SPEED_FIXED );
Signature · 1 line
2.17.1
PATCH v11 6/24 net/ice: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/ice/ice_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +4 -1
@@ -3135,8 +3135,11 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) link.link_speed =ETH_SPEED_NUM_100G ;break ;case ICE_AQ_LINK_SPEED_UNKNOWN : -default :PMD_DRV_LOG (ERR ,"Unknown link speed" ); + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +break ; +default : +PMD_DRV_LOG (ERR ,"None link speed" ); link.link_speed =ETH_SPEED_NUM_NONE ;break ; }
Signature · 1 line
2.17.1
PATCH v11 7/24 examples: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications:
* ipv4_multicast
* l2fwd-jobstats
* l2fwd-keepalive
* l3fwd
* link_status_interrupt
--- examples/ipv4_multicast/main.c | 14 ++++++------- examples/l2fwd-jobstats/main.c | 13 +++++------- examples/l2fwd-keepalive/main.c | 13 +++++------- examples/l3fwd/main.c | 13 +++++------- examples/link_status_interrupt/main.c | 30 +++++++++++---------------- 5 files changed, 33 insertions(+), 50 deletions(-)
examples/ipv4_multicast/main.c +6 -8
@@ -572,6 +572,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -591,14 +592,11 @@ 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
examples/l2fwd-jobstats/main.c +5 -8
@@ -689,6 +689,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -708,14 +709,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
examples/l2fwd-keepalive/main.c +5 -8
@@ -453,6 +453,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -472,14 +473,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
examples/l3fwd/main.c +5 -8
@@ -810,6 +810,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -833,14 +834,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
examples/link_status_interrupt/main.c +12 -18
@@ -133,7 +133,7 @@ print_stats(void) link_get_err =rte_eth_link_get_nowait (portid, &link);printf ("\nStatistics for port %u ------------------------------" "\nLink status: %25s" -"\nLink speed: %26u" +"\nLink speed: %26s" "\nLink duplex: %25s" "\nPackets sent: %24" PRIu64 "\nPackets received: %20"PRIu64
@@ -141,8 +141,8 @@ print_stats(void) portid, link_get_err <0 ?"Link get failed" : (link.link_status ?"Link up" :"Link down" ), - link_get_err <0 ?0 : - (unsigned int )link.link_speed, + link_get_err <0 ?"0" : +rte_eth_link_speed_to_str (link.link_speed), link_get_err <0 ?"Link get failed" : (link.link_duplex ==ETH_LINK_FULL_DUPLEX ? \ "full-duplex" : "half-duplex"),
@@ -445,6 +445,7 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, {struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];RTE_SET_USED (param);RTE_SET_USED (ret_param);
@@ -457,13 +458,9 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, 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, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else -printf ("Port %d Link Down\n\n" , port_id); +rte_eth_link_to_str (link_status_text,sizeof (link_status_text), +NULL , &link); +printf ("Port %d %s\n\n" , port_id, link_status_text);return 0 ; }
@@ -478,6 +475,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);
@@ -497,14 +495,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v11 07/24] examples: new link status print format
Quoted 9 lines · Ivan Dyukov
Add usage of
rte_eth_link_to_strfunction to example applications:
*ipv4_multicast
* l2fwd-jobstats
* l2fwd-keepalive
* l3fwd
*link_status_interruptSigned-off-by Ivan Dyukov <[email protected]>
<...>
Quoted 23 lines
examples/link_status_interrupt/main.c +3
-3@@ -133,7 +133,7 @@ print_stats(void) link_get_err =rte_eth_link_get_nowait (portid, &link);printf ("\nStatistics for port %u ------------------------------" "\nLink status: %25s" -"\nLink speed: %26u" +"\nLink speed: %26s" "\nLink duplex: %25s" "\nPackets sent: %24" PRIu64 "\nPackets received: %20"PRIu64@@ -141,8 +141,8 @@ print_stats(void) portid, link_get_err <0 ?"Link get failed" : (link.link_status ?"Link up" :"Link down" ), - link_get_err <0 ?0 : - (unsigned int )link.link_speed, + link_get_err <0 ?"0" : +rte_eth_link_speed_to_str (link.link_speed), link_get_err <0 ?"Link get failed" : (link.link_duplex ==ETH_LINK_FULL_DUPLEX ? \ "full-duplex" : "half-duplex"),
examples/link_status_interrupt/main.c lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, · line 448
Quoted 4 lines
examples/link_status_interrupt/main.c +1
-0@@ -445,6 +445,7 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, {struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];
s/ETH_LINK_MAX_STR_LEN/RTE_ETH_LINK_MAX_STR_LEN/
Quoted 21 lines
examples/link_status_interrupt/main.c +3
-7RTE_SET_USED (param);RTE_SET_USED (ret_param);@@ -457,13 +458,9 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, 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, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else -printf ("Port %d Link Down\n\n" , port_id); +rte_eth_link_to_str (link_status_text,sizeof (link_status_text), +NULL , &link); +printf ("Port %d %s\n\n" , port_id, link_status_text);return 0 ; }
examples/link_status_interrupt/main.c check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) · line 478
Quoted 4 lines
examples/link_status_interrupt/main.c +1
-0@@ -478,6 +475,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];
s/ETH_LINK_MAX_STR_LEN/RTE_ETH_LINK_MAX_STR_LEN/
Quoted 23 lines
examples/link_status_interrupt/main.c +4
-8printf ("\nChecking link status" );fflush (stdout);@@ -497,14 +495,10 @@ check_all_ports_link_status(uint16_t port_num, 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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Re: [dpdk-dev] [PATCH v11 07/24] examples: new link status print format
In reply to Ivan DyukovQuoted 9 lines · Ivan Dyukov
Add usage of
rte_eth_link_to_strfunction to example applications:
*ipv4_multicast
* l2fwd-jobstats
* l2fwd-keepalive
* l3fwd
*link_status_interruptSigned-off-by Ivan Dyukov <[email protected]>
<...>
examples/link_status_interrupt/main.c lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, · line 462
Quoted 13 lines
examples/link_status_interrupt/main.c +2
-7@@ -457,13 +458,9 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, 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, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else -printf ("Port %d Link Down\n\n" , port_id); +rte_eth_link_to_str (link_status_text,sizeof (link_status_text), +NULL , &link);
There is additional parameter, should be removed.
Quoted 16 lines
examples/link_status_interrupt/main.c +2
-0+printf ("Port %d %s\n\n" , port_id, link_status_text);return 0 ; }@@ -478,6 +475,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status" );fflush (stdout);@@ -497,14 +495,10 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) {
examples/link_status_interrupt/main.c check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) · line 499
Quoted 10 lines
examples/link_status_interrupt/main.c +2
-8-if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text),NULL , &link);
ditto.
Quoted 6 lines
examples/link_status_interrupt/main.c +2
-0+printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Re: [dpdk-dev] [PATCH v11 07/24] examples: new link status print format
In reply to Ivan DyukovQuoted 9 lines · Ivan Dyukov
Add usage of
rte_eth_link_to_strfunction to example applications:
*ipv4_multicast
* l2fwd-jobstats
* l2fwd-keepalive
* l3fwd
*link_status_interruptSigned-off-by Ivan Dyukov <[email protected]>
<...>
Quoted 19 lines
examples/l3fwd/main.c +1
-3@@ -810,6 +810,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);@@ -833,14 +834,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",
examples/l3fwd/main.c check_all_ports_link_status(uint32_t port_mask) · line 841
Quoted 10 lines
examples/l3fwd/main.c +4
-5- portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex")); - else - printf("Port %d Link Down\n", portid); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text), &link); +printf ("Port %d %s\n" , portid, + link_status_text);continue ;
l3fwd/Makefile is missing "CFLAGS += -DALLOW_EXPERIMENTAL_API", although the meson file has it.
Using this new experimental API is causing build error, will updating as following as part of this patch:
+# Added for 'rte_eth_link_to_str()'
+CFLAGS += -DALLOW_EXPERIMENTAL_API
PATCH v11 8/24 examples/bbdev_app: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/bbdev_app/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
examples/bbdev_app/main.c +4 -2
@@ -326,8 +326,10 @@ check_port_link_status(uint16_t port_id)const char *dp = (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ?"full-duplex" :"half-duplex" ; -printf ("\nPort %u Link Up - speed %u Mbps - %s\n" , - port_id, link.link_speed, dp); +printf ("\nPort %u Link Up - speed %s Mbps - %s\n" , + port_id, +rte_eth_link_speed_to_str (link.link_speed), + dp);return 0 ; }printf ("." );
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v11 08/24] examples/bbdev_app: new link status print format
Quoted 13 lines · Ivan Dyukov
Add usage of
rte_eth_link_to_strfunction to example applicationsSigned-off-by Ivan Dyukov <[email protected]>--- examples/bbdev_app/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)examples/bbdev_app/main.c +0
-0
examples/bbdev_app/main.c check_port_link_status(uint16_t port_id) · line 332
Quoted 9 lines
examples/bbdev_app/main.c +4
-2@@ -326,8 +326,10 @@ check_port_link_status(uint16_t port_id)const char *dp = (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ?"full-duplex" :"half-duplex" ; -printf ("\nPort %u Link Up - speed %u Mbps - %s\n" , - port_id, link.link_speed, dp); +printf ("\nPort %u Link Up - speed %s Mbps - %s\n" , + port_id, +rte_eth_link_speed_to_str (link.link_speed), + dp);
Can drop " Mbps" part since 'rte_eth_link_speed_to_str()' returns string with it.
If the the required changes are minor changes like this, I can update them while merging, let me comment on them first.
PATCH v11 9/24 examples/ioat: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications
--- examples/ioat/ioatfwd.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
examples/ioat/ioatfwd.c +6 -8
@@ -700,6 +700,7 @@ check_link_status(uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret, link_status =0 ; +char link_status_text[RTE_ETH_LINK_MAX_STR_LEN ];printf ("\nChecking link status\n" );RTE_ETH_FOREACH_DEV (portid) {
@@ -715,15 +716,12 @@ check_link_status(uint32_t port_mask) }/* Print link status */ -if (link.link_status) { -printf ( -"Port %d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_to_str (link_status_text, +sizeof (link_status_text), &link); +printf ("Port %d %s\n" , portid, link_status_text); + +if (link.link_status) link_status =1 ; - }else -printf ("Port %d Link Down\n" , portid); }return link_status; }
Signature · 1 line
2.17.1
PATCH v11 10/24 examples/ip_*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_to_str function to example applications:
* ip_fragmentation
* ip_reassembly
* l3fwd-acl
--- examples/ip_fragmentation/main.c | 13 +++++-------- examples/ip_reassembly/main.c | 13 +++++-------- examples/l3fwd-acl/main.c | 13 +++++-------- 3 files changed, 15 insertions(+), 24 deletions(-)
examples/ip_fragmentation/main.c +5 -8
@@ -593,6 +593,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -612,14 +613,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
examples/ip_reassembly/main.c +5 -8
@@ -712,6 +712,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -731,14 +732,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
examples/l3fwd-acl/main.c +5 -8
@@ -1815,6 +1815,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t 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);
@@ -1834,14 +1835,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" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , 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 */
Signature · 1 line
2.17.1
PATCH v11 11/24 examples/ip_pipeline: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_speed_to_str function to example applications
--- examples/ip_pipeline/cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
examples/ip_pipeline/cli.c +2 -2
@@ -273,7 +273,7 @@ print_link_info(struct link *link, char *out, size_t out_size)"\n" "%s: flags=<%s> mtu %u\n" "\tether %02X:%02X:%02X:%02X:%02X:%02X rxqueues %u txqueues %u\n" -"\tport# %u speed %u Mbps\n" +"\tport# %u speed %s Mbps\n" "\tRX packets %" PRIu64" bytes %" PRIu64"\n" "\tRX errors %" PRIu64" missed %" PRIu64" no-mbuf %" PRIu64"\n" "\tTX packets %" PRIu64" bytes %" PRIu64"\n"
@@ -287,7 +287,7 @@ print_link_info(struct link *link, char *out, size_t out_size) link->n_rxq, link->n_txq, link->port_id, - eth_link.link_speed, +rte_eth_link_speed_to_str (eth_link.link_speed), stats.ipackets, stats.ibytes, stats.ierrors,
Signature · 1 line
2.17.1