eal: fix positive error codes from probe/remove
[dpdk.git] / app / test-pmd / testpmd.c
index 0f2fffe..c578f75 100644 (file)
@@ -1174,7 +1174,8 @@ init_config(void)
                /* Check for maximum number of segments per MTU. Accordingly
                 * update the mbuf data size.
                 */
-               if (port->dev_info.rx_desc_lim.nb_mtu_seg_max != UINT16_MAX) {
+               if (port->dev_info.rx_desc_lim.nb_mtu_seg_max != UINT16_MAX &&
+                               port->dev_info.rx_desc_lim.nb_mtu_seg_max != 0) {
                        data_size = rx_mode.max_rx_pkt_len /
                                port->dev_info.rx_desc_lim.nb_mtu_seg_max;
 
@@ -2382,7 +2383,7 @@ attach_port(char *identifier)
                return;
        }
 
-       if (rte_dev_probe(identifier) != 0) {
+       if (rte_dev_probe(identifier) < 0) {
                TESTPMD_LOG(ERR, "Failed to attach port %s\n", identifier);
                return;
        }
@@ -2452,7 +2453,7 @@ detach_port_device(portid_t port_id)
                        port_flow_flush(port_id);
        }
 
-       if (rte_dev_remove(dev) != 0) {
+       if (rte_dev_remove(dev) < 0) {
                TESTPMD_LOG(ERR, "Failed to detach device %s\n", dev->name);
                return;
        }
@@ -2477,7 +2478,6 @@ detach_port_device(portid_t port_id)
 void
 pmd_test_exit(void)
 {
-       struct rte_device *device;
        portid_t pt_id;
        int ret;
        int i;
@@ -2503,18 +2503,6 @@ pmd_test_exit(void)
                        printf("\nShutting down port %d...\n", pt_id);
                        fflush(stdout);
                        close_port(pt_id);
-
-                       /*
-                        * This is a workaround to fix a virtio-user issue that
-                        * requires to call clean-up routine to remove existing
-                        * socket.
-                        * This workaround valid only for testpmd, needs a fix
-                        * valid for all applications.
-                        * TODO: Implement proper resource cleanup
-                        */
-                       device = rte_eth_devices[pt_id].device;
-                       if (device && !strcmp(device->driver->name, "net_virtio_user"))
-                               detach_port_device(pt_id);
                }
        }