Skip to content

Commit

Permalink
app/testpmd: check stopping port is not forwarding
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bairemon authored and Thomas Monjalon committed Jun 16, 2016
1 parent ebf5e9b commit a8ef3e3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
18 changes: 17 additions & 1 deletion app/test-pmd/config.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
{
Expand Down
24 changes: 10 additions & 14 deletions app/test-pmd/testpmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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;

Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion app/test-pmd/testpmd.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a8ef3e3

Please sign in to comment.