app/testpmd: check stopping port is not forwarding

Add calls to port_is_forwarding function in stop_port and
close_port functions to check that port is not forwarding.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
This commit is contained in:
Bernard Iremonger 2016-06-14 16:35:36 +01:00 committed by Thomas Monjalon
parent ebf5e9b715
commit a8ef3e3a98
3 changed files with 29 additions and 16 deletions

View File

@ -1,7 +1,7 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
* Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -1565,6 +1565,22 @@ set_fwd_ports_number(uint16_t nb_pt)
(unsigned int) nb_fwd_ports);
}
int
port_is_forwarding(portid_t port_id)
{
unsigned int i;
if (port_id_is_invalid(port_id, ENABLED_WARN))
return -1;
for (i = 0; i < nb_fwd_ports; i++) {
if (fwd_ports_ids[i] == port_id)
return 1;
}
return 0;
}
void
set_nb_pkt_per_burst(uint16_t nb)
{

View File

@ -1279,11 +1279,6 @@ start_port(portid_t pid)
struct rte_port *port;
struct ether_addr mac_addr;
if (test_done == 0) {
printf("Please stop forwarding first\n");
return -1;
}
if (port_id_is_invalid(pid, ENABLED_WARN))
return 0;
@ -1435,10 +1430,6 @@ stop_port(portid_t pid)
struct rte_port *port;
int need_check_link_status = 0;
if (test_done == 0) {
printf("Please stop forwarding first\n");
return;
}
if (dcb_test) {
dcb_test = 0;
dcb_config = 0;
@ -1453,6 +1444,11 @@ stop_port(portid_t pid)
if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
continue;
if (port_is_forwarding(pi) != 0 && test_done == 0) {
printf("Please remove port %d from forwarding configuration.\n", pi);
continue;
}
port = &ports[pi];
if (rte_atomic16_cmpset(&(port->port_status), RTE_PORT_STARTED,
RTE_PORT_HANDLING) == 0)
@ -1477,11 +1473,6 @@ close_port(portid_t pid)
portid_t pi;
struct rte_port *port;
if (test_done == 0) {
printf("Please stop forwarding first\n");
return;
}
if (port_id_is_invalid(pid, ENABLED_WARN))
return;
@ -1491,6 +1482,11 @@ close_port(portid_t pid)
if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
continue;
if (port_is_forwarding(pi) != 0 && test_done == 0) {
printf("Please remove port %d from forwarding configuration.\n", pi);
continue;
}
port = &ports[pi];
if (rte_atomic16_cmpset(&(port->port_status),
RTE_PORT_CLOSED, RTE_PORT_CLOSED) == 1) {

View File

@ -1,7 +1,7 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
* Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -500,6 +500,7 @@ void set_fwd_lcores_number(uint16_t nb_lc);
void set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt);
void set_fwd_ports_mask(uint64_t portmask);
void set_fwd_ports_number(uint16_t nb_pt);
int port_is_forwarding(portid_t port_id);
void rx_vlan_strip_set(portid_t port_id, int on);
void rx_vlan_strip_set_on_queue(portid_t port_id, uint16_t queue_id, int on);