* [dpdk-dev] [PATCH 1/6] app/testpmd: fix valid ports prints
2018-05-03 10:31 [dpdk-dev] [PATCH 0/6] Testpmd: fix port hotplug Matan Azrad
@ 2018-05-03 10:31 ` Matan Azrad
2018-05-03 10:31 ` [dpdk-dev] [PATCH 2/6] app/testpmd: fix forward ports update Matan Azrad
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Matan Azrad @ 2018-05-03 10:31 UTC (permalink / raw)
To: Wenzhuo Lu, Jingjing Wu; +Cc: dev, stable
There are several cases of an invalid port data access that causes the
printing of all the valid ports, for example, when the user asks to
receive a port information of an invalid port.
Wrongly, the port with id 0 is printed in all the above described
cases, regardless of its validity.
Print port 0 only if it is valid as done for the rest of the ports.
Fixes: af75078fece3 ("first public release")
Fixes: b6ea6408fbc7 ("ethdev: store numa_node per device")
Fixes: edab33b1c01d ("app/testpmd: support port hotplug")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
app/test-pmd/config.c | 36 +++++++++++++++---------------------
app/test-pmd/parameters.c | 12 ++----------
app/test-pmd/testpmd.h | 1 +
3 files changed, 18 insertions(+), 31 deletions(-)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 16fc481..fc1abe0 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -121,15 +121,11 @@
struct rte_eth_stats stats;
struct rte_port *port = &ports[port_id];
uint8_t i;
- portid_t pid;
static const char *nic_stats_border = "########################";
if (port_id_is_invalid(port_id, ENABLED_WARN)) {
- printf("Valid port range is [0");
- RTE_ETH_FOREACH_DEV(pid)
- printf(", %d", pid);
- printf("]\n");
+ print_valid_ports();
return;
}
rte_eth_stats_get(port_id, &stats);
@@ -203,13 +199,8 @@
void
nic_stats_clear(portid_t port_id)
{
- portid_t pid;
-
if (port_id_is_invalid(port_id, ENABLED_WARN)) {
- printf("Valid port range is [0");
- RTE_ETH_FOREACH_DEV(pid)
- printf(", %d", pid);
- printf("]\n");
+ print_valid_ports();
return;
}
rte_eth_stats_reset(port_id);
@@ -286,15 +277,11 @@
{
struct rte_port *port = &ports[port_id];
uint16_t i;
- portid_t pid;
static const char *nic_stats_mapping_border = "########################";
if (port_id_is_invalid(port_id, ENABLED_WARN)) {
- printf("Valid port range is [0");
- RTE_ETH_FOREACH_DEV(pid)
- printf(", %d", pid);
- printf("]\n");
+ print_valid_ports();
return;
}
@@ -405,15 +392,11 @@
int vlan_offload;
struct rte_mempool * mp;
static const char *info_border = "*********************";
- portid_t pid;
uint16_t mtu;
char name[RTE_ETH_NAME_MAX_LEN];
if (port_id_is_invalid(port_id, ENABLED_WARN)) {
- printf("Valid port range is [0");
- RTE_ETH_FOREACH_DEV(pid)
- printf(", %d", pid);
- printf("]\n");
+ print_valid_ports();
return;
}
port = &ports[port_id];
@@ -774,6 +757,17 @@
return 1;
}
+void print_valid_ports(void)
+{
+ portid_t pid;
+
+ printf("The valid ports array is [");
+ RTE_ETH_FOREACH_DEV(pid) {
+ printf(" %d", pid);
+ }
+ printf(" ]\n");
+}
+
static int
vlan_id_is_invalid(uint16_t vlan_id)
{
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index aea8af8..b64b925 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -375,7 +375,6 @@
};
unsigned long int_fld[_NUM_FLD];
char *str_fld[_NUM_FLD];
- portid_t pid;
/* reset from value set at definition */
while ((p = strchr(p0,'(')) != NULL) {
@@ -399,10 +398,7 @@
port_id = (portid_t)int_fld[FLD_PORT];
if (port_id_is_invalid(port_id, ENABLED_WARN) ||
port_id == (portid_t)RTE_PORT_ALL) {
- printf("Valid port range is [0");
- RTE_ETH_FOREACH_DEV(pid)
- printf(", %d", pid);
- printf("]\n");
+ print_valid_ports();
return -1;
}
socket_id = (uint8_t)int_fld[FLD_SOCKET];
@@ -433,7 +429,6 @@
};
unsigned long int_fld[_NUM_FLD];
char *str_fld[_NUM_FLD];
- portid_t pid;
#define RX_RING_ONLY 0x1
#define TX_RING_ONLY 0x2
#define RXTX_RING 0x3
@@ -460,10 +455,7 @@
port_id = (portid_t)int_fld[FLD_PORT];
if (port_id_is_invalid(port_id, ENABLED_WARN) ||
port_id == (portid_t)RTE_PORT_ALL) {
- printf("Valid port range is [0");
- RTE_ETH_FOREACH_DEV(pid)
- printf(", %d", pid);
- printf("]\n");
+ print_valid_ports();
return -1;
}
socket_id = (uint8_t)int_fld[FLD_SOCKET];
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 1af87b8..8dfd574 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -726,6 +726,7 @@ enum print_warning {
DISABLED_WARN
};
int port_id_is_invalid(portid_t port_id, enum print_warning warning);
+void print_valid_ports(void);
int new_socket_id(unsigned int socket_id);
queueid_t get_allowed_max_nb_rxq(portid_t *pid);
--
1.9.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH 2/6] app/testpmd: fix forward ports update
2018-05-03 10:31 [dpdk-dev] [PATCH 0/6] Testpmd: fix port hotplug Matan Azrad
2018-05-03 10:31 ` [dpdk-dev] [PATCH 1/6] app/testpmd: fix valid ports prints Matan Azrad
@ 2018-05-03 10:31 ` Matan Azrad
2018-05-03 10:31 ` [dpdk-dev] [PATCH 3/6] app/testpmd: fix forward ports Rx flush Matan Azrad
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Matan Azrad @ 2018-05-03 10:31 UTC (permalink / raw)
To: Wenzhuo Lu, Jingjing Wu; +Cc: dev, stable
When the forward ports are changed either by new portlist\portmask
configurations or by a port detachment, all the old forward streams
are freed and new streams are allocated to be aligned with the new
forward ports.
If the number of the forward ports drops to 0, there is an attempt
to wrongly allocate 0 memory for the streams.
Skip the streams memory allocation if no forward ports are configured.
Fixes: ce8d561418d4 ("app/testpmd: add port configuration settings")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
app/test-pmd/testpmd.c | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index db23f23..8ac2070 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -882,18 +882,23 @@ static void eth_dev_event_callback(char *device_name,
/* init new */
nb_fwd_streams = nb_fwd_streams_new;
- fwd_streams = rte_zmalloc("testpmd: fwd_streams",
- sizeof(struct fwd_stream *) * nb_fwd_streams, RTE_CACHE_LINE_SIZE);
- if (fwd_streams == NULL)
- rte_exit(EXIT_FAILURE, "rte_zmalloc(%d (struct fwd_stream *)) "
- "failed\n", nb_fwd_streams);
-
- for (sm_id = 0; sm_id < nb_fwd_streams; sm_id++) {
- fwd_streams[sm_id] = rte_zmalloc("testpmd: struct fwd_stream",
- sizeof(struct fwd_stream), RTE_CACHE_LINE_SIZE);
- if (fwd_streams[sm_id] == NULL)
- rte_exit(EXIT_FAILURE, "rte_zmalloc(struct fwd_stream)"
- " failed\n");
+ if (nb_fwd_streams) {
+ fwd_streams = rte_zmalloc("testpmd: fwd_streams",
+ sizeof(struct fwd_stream *) * nb_fwd_streams,
+ RTE_CACHE_LINE_SIZE);
+ if (fwd_streams == NULL)
+ rte_exit(EXIT_FAILURE, "rte_zmalloc(%d"
+ " (struct fwd_stream *)) failed\n",
+ nb_fwd_streams);
+
+ for (sm_id = 0; sm_id < nb_fwd_streams; sm_id++) {
+ fwd_streams[sm_id] = rte_zmalloc("testpmd:"
+ " struct fwd_stream", sizeof(struct fwd_stream),
+ RTE_CACHE_LINE_SIZE);
+ if (fwd_streams[sm_id] == NULL)
+ rte_exit(EXIT_FAILURE, "rte_zmalloc"
+ "(struct fwd_stream) failed\n");
+ }
}
return 0;
--
1.9.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH 3/6] app/testpmd: fix forward ports Rx flush
2018-05-03 10:31 [dpdk-dev] [PATCH 0/6] Testpmd: fix port hotplug Matan Azrad
2018-05-03 10:31 ` [dpdk-dev] [PATCH 1/6] app/testpmd: fix valid ports prints Matan Azrad
2018-05-03 10:31 ` [dpdk-dev] [PATCH 2/6] app/testpmd: fix forward ports update Matan Azrad
@ 2018-05-03 10:31 ` Matan Azrad
2018-05-03 10:31 ` [dpdk-dev] [PATCH 4/6] app/testpmd: fix synchronic port hotplug Matan Azrad
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Matan Azrad @ 2018-05-03 10:31 UTC (permalink / raw)
To: Wenzhuo Lu, Jingjing Wu; +Cc: dev, stable
A port Rx queue flush is done when the packet forwarding starts in
order to clean the port statistics for a new traffic session.
The flush operation is wrongly called before the update of the new
forward ports, and may fail due to flush operation for an invalid port
configured by the old session.
Move the new forward port setup to be done before the Rx queue flush.
Fixes: 7741e4cf16c0 ("app/testpmd: VMDq and DCB updates")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
app/test-pmd/testpmd.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 8ac2070..1d3ede1 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1249,10 +1249,6 @@ static void eth_dev_event_callback(char *device_name,
return;
}
- if (init_fwd_streams() < 0) {
- printf("Fail from init_fwd_streams()\n");
- return;
- }
if(dcb_test) {
for (i = 0; i < nb_fwd_ports; i++) {
@@ -1272,10 +1268,11 @@ static void eth_dev_event_callback(char *device_name,
}
test_done = 0;
+ fwd_config_setup();
+
if(!no_flush_rx)
flush_fwd_rx_queues();
- fwd_config_setup();
pkt_fwd_config_display(&cur_fwd_config);
rxtx_config_display();
--
1.9.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH 4/6] app/testpmd: fix synchronic port hotplug
2018-05-03 10:31 [dpdk-dev] [PATCH 0/6] Testpmd: fix port hotplug Matan Azrad
` (2 preceding siblings ...)
2018-05-03 10:31 ` [dpdk-dev] [PATCH 3/6] app/testpmd: fix forward ports Rx flush Matan Azrad
@ 2018-05-03 10:31 ` Matan Azrad
2018-05-03 10:31 ` [dpdk-dev] [PATCH 5/6] app/testpmd: fix removed device link status asking Matan Azrad
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Matan Azrad @ 2018-05-03 10:31 UTC (permalink / raw)
To: Wenzhuo Lu, Jingjing Wu; +Cc: dev, stable
When the user uses the synchronic hot-plug commands, attach\detach, in
order to insert\remove a port from the system, the forward ports list
update is missed in the current implementation.
Thus, an invalid port may be used for data-path in case of detach
because the detached port was not removed from the forward port list.
In addition, a new port is not used for data-path in case of attach, as the
default behavior of Testpmd, because the attached port was not inserted
to the forward port list.
Update the forward port list in the above cases to allow the correct
port usage for data-path in the next packet forwarding start.
Fixes: edab33b1c01d ("app/testpmd: support port hotplug")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
app/test-pmd/testpmd.c | 29 +++++++++++++++++++++++++++++
app/test-pmd/testpmd.h | 1 +
2 files changed, 30 insertions(+)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 1d3ede1..35f97f0 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1215,6 +1215,31 @@ static void eth_dev_event_callback(char *device_name,
}
/*
+ * Update the forward ports list.
+ */
+void
+update_fwd_ports(portid_t new_pid)
+{
+ unsigned int i;
+ unsigned int new_nb_fwd_ports = 0;
+ int move = 0;
+
+ for (i = 0; i < nb_fwd_ports; ++i) {
+ if (port_id_is_invalid(fwd_ports_ids[i], DISABLED_WARN))
+ move = 1;
+ else if (move)
+ fwd_ports_ids[new_nb_fwd_ports++] = fwd_ports_ids[i];
+ else
+ new_nb_fwd_ports++;
+ }
+ if (new_pid < RTE_MAX_ETHPORTS)
+ fwd_ports_ids[new_nb_fwd_ports++] = new_pid;
+
+ nb_fwd_ports = new_nb_fwd_ports;
+ nb_cfg_ports = new_nb_fwd_ports;
+}
+
+/*
* Launch packet forwarding configuration.
*/
void
@@ -1934,6 +1959,8 @@ static void eth_dev_event_callback(char *device_name,
ports[pi].port_status = RTE_PORT_STOPPED;
+ update_fwd_ports(pi);
+
printf("Port %d is attached. Now total ports is %d\n", pi, nb_ports);
printf("Done\n");
}
@@ -1960,6 +1987,8 @@ static void eth_dev_event_callback(char *device_name,
nb_ports = rte_eth_dev_count_avail();
+ update_fwd_ports(RTE_MAX_ETHPORTS);
+
printf("Port '%s' is detached. Now total ports is %d\n",
name, nb_ports);
printf("Done\n");
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 8dfd574..ee781d6 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -596,6 +596,7 @@ unsigned int parse_item_list(char* str, const char* item_name,
void set_def_fwd_config(void);
void reconfig(portid_t new_port_id, unsigned socket_id);
int init_fwd_streams(void);
+void update_fwd_ports(portid_t new_pid);
void set_fwd_eth_peer(portid_t port_id, char *peer_addr);
--
1.9.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH 5/6] app/testpmd: fix removed device link status asking
2018-05-03 10:31 [dpdk-dev] [PATCH 0/6] Testpmd: fix port hotplug Matan Azrad
` (3 preceding siblings ...)
2018-05-03 10:31 ` [dpdk-dev] [PATCH 4/6] app/testpmd: fix synchronic port hotplug Matan Azrad
@ 2018-05-03 10:31 ` Matan Azrad
2018-05-03 10:31 ` [dpdk-dev] [PATCH 6/6] app/testpmd: fix asynchronic port removal Matan Azrad
2018-05-14 2:22 ` [dpdk-dev] [PATCH 0/6] Testpmd: fix port hotplug Thomas Monjalon
6 siblings, 0 replies; 8+ messages in thread
From: Matan Azrad @ 2018-05-03 10:31 UTC (permalink / raw)
To: Wenzhuo Lu, Jingjing Wu; +Cc: dev, stable
In the RMV device event callback, there is a call for the removed
device stop operation which trigers a link status operation for the
removed device.
It may casue an error from the removed device PMD.
Skip the link status operation in the above described case.
Fixes: 284c908cc588 ("app/testpmd: request device removal interrupt")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
app/test-pmd/testpmd.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 35f97f0..33a9e96 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2096,13 +2096,16 @@ struct pmd_test_command {
static void
rmv_event_callback(void *arg)
{
+ int org_no_link_check = no_link_check;
struct rte_eth_dev *dev;
portid_t port_id = (intptr_t)arg;
RTE_ETH_VALID_PORTID_OR_RET(port_id);
dev = &rte_eth_devices[port_id];
+ no_link_check = 1;
stop_port(port_id);
+ no_link_check = org_no_link_check;
close_port(port_id);
printf("removing device %s\n", dev->device->name);
if (rte_eal_dev_detach(dev->device))
--
1.9.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH 6/6] app/testpmd: fix asynchronic port removal
2018-05-03 10:31 [dpdk-dev] [PATCH 0/6] Testpmd: fix port hotplug Matan Azrad
` (4 preceding siblings ...)
2018-05-03 10:31 ` [dpdk-dev] [PATCH 5/6] app/testpmd: fix removed device link status asking Matan Azrad
@ 2018-05-03 10:31 ` Matan Azrad
2018-05-14 2:22 ` [dpdk-dev] [PATCH 0/6] Testpmd: fix port hotplug Thomas Monjalon
6 siblings, 0 replies; 8+ messages in thread
From: Matan Azrad @ 2018-05-03 10:31 UTC (permalink / raw)
To: Wenzhuo Lu, Jingjing Wu; +Cc: dev, stable
When a removable device is plugged-out, a RMV interrupt is invoked and
the application can catch the event in order to stop the device
management.
The Testpmd wrong behavior in this case is to detach the removed device
using the EAL detach API.
The EAL API does not invalidate the ethdev port and the port keeps
appearing as valid from the ethdev point of view.
Thus, the next operations for the ethtev port X may trigger an invalid
rte_device access. For example, calling "show port info X" may cause
segfault.
Moreover, the removed port is not removed from the Testpmd data-path
structures. Therefore, the invalid device may still be used by the
Testpmd data-path.
Call the Testpmd detach_port() function which uses the ethdev detach
API, and prepare the Testpmd forward ports database for a new
forwarding session without the detached port.
Fixes: 284c908cc588 ("app/testpmd: request device removal interrupt")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
---
app/test-pmd/testpmd.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 33a9e96..2edf644 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2096,21 +2096,23 @@ struct pmd_test_command {
static void
rmv_event_callback(void *arg)
{
+ int need_to_start = 0;
int org_no_link_check = no_link_check;
- struct rte_eth_dev *dev;
portid_t port_id = (intptr_t)arg;
RTE_ETH_VALID_PORTID_OR_RET(port_id);
- dev = &rte_eth_devices[port_id];
+ if (!test_done && port_is_forwarding(port_id)) {
+ need_to_start = 1;
+ stop_packet_forwarding();
+ }
no_link_check = 1;
stop_port(port_id);
no_link_check = org_no_link_check;
close_port(port_id);
- printf("removing device %s\n", dev->device->name);
- if (rte_eal_dev_detach(dev->device))
- TESTPMD_LOG(ERR, "Failed to detach device %s\n",
- dev->device->name);
+ detach_port(port_id);
+ if (need_to_start)
+ start_packet_forwarding(0);
}
/* This function is used by the interrupt thread */
--
1.9.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH 0/6] Testpmd: fix port hotplug
2018-05-03 10:31 [dpdk-dev] [PATCH 0/6] Testpmd: fix port hotplug Matan Azrad
` (5 preceding siblings ...)
2018-05-03 10:31 ` [dpdk-dev] [PATCH 6/6] app/testpmd: fix asynchronic port removal Matan Azrad
@ 2018-05-14 2:22 ` Thomas Monjalon
6 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2018-05-14 2:22 UTC (permalink / raw)
To: Matan Azrad; +Cc: dev, Wenzhuo Lu, Jingjing Wu
> Matan Azrad (6):
> app/testpmd: fix valid ports prints
> app/testpmd: fix forward ports update
> app/testpmd: fix forward ports Rx flush
> app/testpmd: fix synchronic port hotplug
> app/testpmd: fix removed device link status asking
> app/testpmd: fix asynchronic port removal
Applied, thanks
^ permalink raw reply [flat|nested] 8+ messages in thread