examples: take promiscuous mode switch result into account
authorIvan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Sat, 14 Sep 2019 11:37:33 +0000 (12:37 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 7 Oct 2019 13:00:54 +0000 (15:00 +0200)
rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable() return
value was changed from void to int, so this patch modify usage
of these functions across examples according to new return type.

Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
35 files changed:
examples/bbdev_app/main.c
examples/bond/main.c
examples/distributor/main.c
examples/eventdev_pipeline/main.c
examples/exception_path/main.c
examples/flow_classify/flow_classify.c
examples/flow_filtering/main.c
examples/ip_fragmentation/main.c
examples/ip_pipeline/link.c
examples/ip_reassembly/main.c
examples/ipsec-secgw/ipsec-secgw.c
examples/l2fwd-cat/l2fwd-cat.c
examples/l2fwd-crypto/main.c
examples/l2fwd-jobstats/main.c
examples/l2fwd-keepalive/main.c
examples/l2fwd/main.c
examples/l3fwd-acl/main.c
examples/l3fwd-power/main.c
examples/l3fwd/main.c
examples/link_status_interrupt/main.c
examples/load_balancer/init.c
examples/multi_process/client_server_mp/mp_server/init.c
examples/multi_process/symmetric_mp/main.c
examples/netmap_compat/bridge/bridge.c
examples/packet_ordering/main.c
examples/performance-thread/l3fwd-thread/main.c
examples/ptpclient/ptpclient.c
examples/qos_meter/main.c
examples/qos_sched/init.c
examples/quota_watermark/qw/init.c
examples/rxtx_callbacks/main.c
examples/server_node_efd/server/init.c
examples/skeleton/basicfwd.c
examples/vhost/main.c
examples/vm_power_manager/main.c

index 9acf666..3d36629 100644 (file)
@@ -477,7 +477,12 @@ initialize_ports(struct app_config_params *app_params,
                }
        }
 
-       rte_eth_promiscuous_enable(port_id);
+       ret = rte_eth_promiscuous_enable(port_id);
+       if (ret != 0) {
+               printf("Cannot enable promiscuous mode: err=%s, port=%u\n",
+                       rte_strerror(-ret), port_id);
+               return ret;
+       }
 
        rte_eth_macaddr_get(port_id, &bbdev_port_eth_addr);
        print_mac(port_id, &bbdev_port_eth_addr);
index be62c17..39214cf 100644 (file)
@@ -299,7 +299,13 @@ bond_port_init(struct rte_mempool *mbuf_pool)
                        rte_exit(-1, "\nFailed to activate slaves\n");
        }
 
-       rte_eth_promiscuous_enable(BOND_PORT);
+       retval = rte_eth_promiscuous_enable(BOND_PORT);
+       if (retval != 0) {
+               rte_exit(EXIT_FAILURE,
+                               "port %u: promiscuous mode enable failed: %s\n",
+                               BOND_PORT, rte_strerror(-retval));
+               return;
+       }
 
        struct rte_ether_addr addr;
 
index 8942f36..125ee87 100644 (file)
@@ -194,7 +194,9 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
                        addr.addr_bytes[2], addr.addr_bytes[3],
                        addr.addr_bytes[4], addr.addr_bytes[5]);
 
-       rte_eth_promiscuous_enable(port);
+       retval = rte_eth_promiscuous_enable(port);
+       if (retval != 0)
+               return retval;
 
        return 0;
 }
index 3789fbf..c734c77 100644 (file)
@@ -333,7 +333,9 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
                        addr.addr_bytes[4], addr.addr_bytes[5]);
 
        /* Enable RX in promiscuous mode for the Ethernet device. */
-       rte_eth_promiscuous_enable(port);
+       retval = rte_eth_promiscuous_enable(port);
+       if (retval != 0)
+               return retval;
 
        return 0;
 }
index d7f3598..f3c0206 100644 (file)
@@ -473,7 +473,10 @@ init_port(uint16_t port)
        if (ret < 0)
                FATAL_ERROR("Could not start port%u (%d)", port, ret);
 
-       rte_eth_promiscuous_enable(port);
+       ret = rte_eth_promiscuous_enable(port);
+       if (ret != 0)
+               FATAL_ERROR("Could not enable promiscuous mode for port%u (%s)",
+                           port, rte_strerror(-ret));
 }
 
 /* Check the link status of all ports in up to 9s, and print them finally */
index 2130c13..ae0faf6 100644 (file)
@@ -251,7 +251,9 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
                        addr.addr_bytes[4], addr.addr_bytes[5]);
 
        /* Enable RX in promiscuous mode for the Ethernet device. */
-       rte_eth_promiscuous_enable(port);
+       retval = rte_eth_promiscuous_enable(port);
+       if (retval != 0)
+               return retval;
 
        return 0;
 }
index fe064fa..c40cfd0 100644 (file)
@@ -180,7 +180,12 @@ init_port(void)
                }
        }
 
-       rte_eth_promiscuous_enable(port_id);
+       ret = rte_eth_promiscuous_enable(port_id);
+       if (ret != 0)
+               rte_exit(EXIT_FAILURE,
+                       ":: promiscuous mode enable failed: err=%s, port=%u\n",
+                       rte_strerror(-ret), port_id);
+
        ret = rte_eth_dev_start(port_id);
        if (ret < 0) {
                rte_exit(EXIT_FAILURE,
index 6b83244..70139ee 100644 (file)
@@ -1038,7 +1038,11 @@ main(int argc, char **argv)
                        rte_exit(EXIT_FAILURE, "rte_eth_dev_start: err=%d, port=%d\n",
                                ret, portid);
 
-               rte_eth_promiscuous_enable(portid);
+               ret = rte_eth_promiscuous_enable(portid);
+               if (ret != 0)
+                       rte_exit(EXIT_FAILURE,
+                               "rte_eth_promiscuous_enable: err=%s, port=%d\n",
+                               rte_strerror(-ret), portid);
 
                if (check_ptype(portid) == 0) {
                        rte_eth_add_rx_callback(portid, 0, cb_parse_ptype, NULL);
index 4e3a40b..744abf3 100644 (file)
@@ -176,8 +176,11 @@ link_create(const char *name, struct link_params *params)
        if (status < 0)
                return NULL;
 
-       if (params->promiscuous)
-               rte_eth_promiscuous_enable(port_id);
+       if (params->promiscuous) {
+               status = rte_eth_promiscuous_enable(port_id);
+               if (status != 0)
+                       return NULL;
+       }
 
        /* Port RX */
        for (i = 0; i < params->rx.n_queues; i++) {
index 87d4b5c..e810e9f 100644 (file)
@@ -1169,7 +1169,11 @@ main(int argc, char **argv)
                        rte_exit(EXIT_FAILURE, "rte_eth_dev_start: err=%d, port=%d\n",
                                ret, portid);
 
-               rte_eth_promiscuous_enable(portid);
+               ret = rte_eth_promiscuous_enable(portid);
+               if (ret != 0)
+                       rte_exit(EXIT_FAILURE,
+                               "rte_eth_promiscuous_enable: err=%s, port=%d\n",
+                               rte_strerror(-ret), portid);
        }
 
        if (init_routing_table() < 0)
index 5ed4131..dac0d18 100644 (file)
@@ -2470,8 +2470,13 @@ main(int32_t argc, char **argv)
                 * to itself through 2 cross-connected  ports of the
                 * target machine.
                 */
-               if (promiscuous_on)
-                       rte_eth_promiscuous_enable(portid);
+               if (promiscuous_on) {
+                       ret = rte_eth_promiscuous_enable(portid);
+                       if (ret != 0)
+                               rte_exit(EXIT_FAILURE,
+                                       "rte_eth_promiscuous_enable: err=%s, port=%d\n",
+                                       rte_strerror(-ret), portid);
+               }
 
                rte_eth_dev_callback_register(portid,
                        RTE_ETH_EVENT_IPSEC, inline_ipsec_event_callback, NULL);
index b34b40a..b15f033 100644 (file)
@@ -83,7 +83,9 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
                        addr.addr_bytes[4], addr.addr_bytes[5]);
 
        /* Enable RX in promiscuous mode for the Ethernet device. */
-       rte_eth_promiscuous_enable(port);
+       retval = rte_eth_promiscuous_enable(port);
+       if (retval != 0)
+               return retval;
 
        return 0;
 }
index 9a370f2..c4ef310 100644 (file)
@@ -2574,7 +2574,12 @@ initialize_ports(struct l2fwd_crypto_options *options)
                        return -1;
                }
 
-               rte_eth_promiscuous_enable(portid);
+               retval = rte_eth_promiscuous_enable(portid);
+               if (retval != 0) {
+                       printf("rte_eth_promiscuous_enable:err=%s, port=%u\n",
+                               rte_strerror(-retval), portid);
+                       return -1;
+               }
 
                rte_eth_macaddr_get(portid, &l2fwd_ports_eth_addr[portid]);
 
index 5fcba5c..3dd6e45 100644 (file)
@@ -916,7 +916,14 @@ main(int argc, char **argv)
 
                printf("done:\n");
 
-               rte_eth_promiscuous_enable(portid);
+               ret = rte_eth_promiscuous_enable(portid);
+               if (ret != 0) {
+                       rte_exit(EXIT_FAILURE,
+                                "rte_eth_promiscuous_enable:err=%s, port=%u\n",
+                                rte_strerror(-ret), portid);
+                       return ret;
+
+               }
 
                printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n",
                                portid,
index a051390..708f44e 100644 (file)
@@ -709,7 +709,11 @@ main(int argc, char **argv)
                                "rte_eth_dev_start:err=%d, port=%u\n",
                                  ret, portid);
 
-               rte_eth_promiscuous_enable(portid);
+               ret = rte_eth_promiscuous_enable(portid);
+               if (ret != 0)
+                       rte_exit(EXIT_FAILURE,
+                                "rte_eth_promiscuous_enable:err=%s, port=%u\n",
+                                rte_strerror(-ret), portid);
 
                printf("Port %u, MAC address: "
                        "%02X:%02X:%02X:%02X:%02X:%02X\n\n",
index 8d4c539..db070a1 100644 (file)
@@ -708,7 +708,11 @@ main(int argc, char **argv)
 
                printf("done: \n");
 
-               rte_eth_promiscuous_enable(portid);
+               ret = rte_eth_promiscuous_enable(portid);
+               if (ret != 0)
+                       rte_exit(EXIT_FAILURE,
+                                "rte_eth_promiscuous_enable:err=%s, port=%u\n",
+                                rte_strerror(-ret), portid);
 
                printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n",
                                portid,
index 60531ce..c974a35 100644 (file)
@@ -2085,8 +2085,13 @@ main(int argc, char **argv)
                 * to itself through 2 cross-connected  ports of the
                 * target machine.
                 */
-               if (promiscuous_on)
-                       rte_eth_promiscuous_enable(portid);
+               if (promiscuous_on) {
+                       ret = rte_eth_promiscuous_enable(portid);
+                       if (ret != 0)
+                               rte_exit(EXIT_FAILURE,
+                                       "rte_eth_promiscuous_enable: err=%s, port=%u\n",
+                                       rte_strerror(-ret), portid);
+               }
        }
 
        check_all_ports_link_status(enabled_port_mask);
index bfcaa46..8ddc9ce 100644 (file)
@@ -2453,8 +2453,13 @@ main(int argc, char **argv)
                 * to itself through 2 cross-connected  ports of the
                 * target machine.
                 */
-               if (promiscuous_on)
-                       rte_eth_promiscuous_enable(portid);
+               if (promiscuous_on) {
+                       ret = rte_eth_promiscuous_enable(portid);
+                       if (ret != 0)
+                               rte_exit(EXIT_FAILURE,
+                                       "rte_eth_promiscuous_enable: err=%s, port=%u\n",
+                                       rte_strerror(-ret), portid);
+               }
                /* initialize spinlock for each port */
                rte_spinlock_init(&(locks[portid]));
        }
index 3294ac2..9ed495e 100644 (file)
@@ -1035,8 +1035,13 @@ main(int argc, char **argv)
                 * to itself through 2 cross-connected  ports of the
                 * target machine.
                 */
-               if (promiscuous_on)
-                       rte_eth_promiscuous_enable(portid);
+               if (promiscuous_on) {
+                       ret = rte_eth_promiscuous_enable(portid);
+                       if (ret != 0)
+                               rte_exit(EXIT_FAILURE,
+                                       "rte_eth_promiscuous_enable: err=%s, port=%u\n",
+                                       rte_strerror(-ret), portid);
+               }
        }
 
        printf("\n");
index 0c3dfc6..be57e6a 100644 (file)
@@ -689,7 +689,11 @@ main(int argc, char **argv)
                                  ret, (unsigned) portid);
                printf("done:\n");
 
-               rte_eth_promiscuous_enable(portid);
+               ret = rte_eth_promiscuous_enable(portid);
+               if (ret != 0)
+                       rte_exit(EXIT_FAILURE,
+                               "rte_eth_promiscuous_enable: err=%s, port=%u\n",
+                               rte_strerror(-ret), portid);
 
                printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n",
                                (unsigned) portid,
index 660f5a8..4d49c95 100644 (file)
@@ -440,7 +440,11 @@ app_init_nics(void)
                if (ret < 0) {
                        rte_panic("Cannot init NIC port %u (%d)\n", port, ret);
                }
-               rte_eth_promiscuous_enable(port);
+
+               ret = rte_eth_promiscuous_enable(port);
+               if (ret != 0)
+                       rte_panic("Cannot enable promiscuous mode on port %u (%s)\n",
+                               port, rte_strerror(-ret));
 
                nic_rx_ring_size = app.nic_rx_ring_size;
                nic_tx_ring_size = app.nic_tx_ring_size;
index 3af5dc6..e55def8 100644 (file)
@@ -132,7 +132,9 @@ init_port(uint16_t port_num)
                if (retval < 0) return retval;
        }
 
-       rte_eth_promiscuous_enable(port_num);
+       retval = rte_eth_promiscuous_enable(port_num);
+       if (retval < 0)
+               return retval;
 
        retval  = rte_eth_dev_start(port_num);
        if (retval < 0) return retval;
index 9ae8efb..95058a5 100644 (file)
@@ -261,7 +261,9 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
                        return retval;
        }
 
-       rte_eth_promiscuous_enable(port);
+       retval = rte_eth_promiscuous_enable(port);
+       if (retval != 0)
+               return retval;
 
        retval  = rte_eth_dev_start(port);
        if (retval < 0)
index d40e163..f3819d2 100644 (file)
@@ -261,7 +261,11 @@ int main(int argc, char *argv[])
                        rte_exit(EXIT_FAILURE, "Couldn't setup port %hhu\n",
                                ports.p[i].id);
 
-               rte_eth_promiscuous_enable(ports.p[i].id);
+               err = rte_eth_promiscuous_enable(ports.p[i].id);
+               if (err != 0)
+                       rte_exit(EXIT_FAILURE,
+                               "Couldn't enable promiscuous mode on port %u: %s\n",
+                               ports.p[i].id, rte_strerror(-err));
        }
 
        for (i = 0; i != ports.num; i++) {
index a99961f..132f582 100644 (file)
@@ -330,7 +330,9 @@ configure_eth_port(uint16_t port_id)
                        addr.addr_bytes[2], addr.addr_bytes[3],
                        addr.addr_bytes[4], addr.addr_bytes[5]);
 
-       rte_eth_promiscuous_enable(port_id);
+       ret = rte_eth_promiscuous_enable(port_id);
+       if (ret != 0)
+               return ret;
 
        return 0;
 }
index 00f5350..9e25f06 100644 (file)
@@ -3706,8 +3706,13 @@ main(int argc, char **argv)
                 * to itself through 2 cross-connected  ports of the
                 * target machine.
                 */
-               if (promiscuous_on)
-                       rte_eth_promiscuous_enable(portid);
+               if (promiscuous_on) {
+                       ret = rte_eth_promiscuous_enable(portid);
+                       if (ret != 0)
+                               rte_exit(EXIT_FAILURE,
+                                       "rte_eth_promiscuous_enable: err=%s, port=%u\n",
+                                       rte_strerror(-ret), portid);
+               }
        }
 
        for (i = 0; i < n_rx_thread; i++) {
index bc427a5..6e273f6 100644 (file)
@@ -247,7 +247,12 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
        }
 
        /* Enable RX in promiscuous mode for the Ethernet device. */
-       rte_eth_promiscuous_enable(port);
+       retval = rte_eth_promiscuous_enable(port);
+       if (retval != 0) {
+               printf("Promiscuous mode enable failed: %s\n",
+                       rte_strerror(-retval));
+               return retval;
+       }
 
        return 0;
 }
index 13c85e9..e8112c8 100644 (file)
@@ -439,9 +439,17 @@ main(int argc, char **argv)
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Port %d start error (%d)\n", port_tx, ret);
 
-       rte_eth_promiscuous_enable(port_rx);
+       ret = rte_eth_promiscuous_enable(port_rx);
+       if (ret != 0)
+               rte_exit(EXIT_FAILURE,
+                       "Port %d promiscuous mode enable error (%s)\n",
+                       port_rx, rte_strerror(-ret));
 
-       rte_eth_promiscuous_enable(port_tx);
+       ret = rte_eth_promiscuous_enable(port_tx);
+       if (ret != 0)
+               rte_exit(EXIT_FAILURE,
+                       "Port %d promiscuous mode enable error (%s)\n",
+                       port_rx, rte_strerror(-ret));
 
        /* App configuration */
        ret = app_configure_flow_table();
index cf9e8f4..dbdbdef 100644 (file)
@@ -163,7 +163,11 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)
        } else {
                printf(" Link Down\n");
        }
-       rte_eth_promiscuous_enable(portid);
+       ret = rte_eth_promiscuous_enable(portid);
+       if (ret != 0)
+               rte_exit(EXIT_FAILURE,
+                       "rte_eth_promiscuous_enable: err=%s, port=%u\n",
+                       rte_strerror(-ret), portid);
 
        /* mark port as initialized */
        app_inited_port_mask |= 1u << portid;
index 5a0f64f..5ebcc83 100644 (file)
@@ -103,7 +103,11 @@ void configure_eth_port(uint16_t port_id)
                                (unsigned int) port_id, ret);
 
        /* Put it in promiscuous mode */
-       rte_eth_promiscuous_enable(port_id);
+       ret = rte_eth_promiscuous_enable(port_id);
+       if (ret != 0)
+               rte_exit(EXIT_FAILURE,
+                       "Failed to enable promiscuous mode for port %u: %s\n",
+                       port_id, rte_strerror(-ret));
 }
 
 void
index 9fd4b8e..5d54511 100644 (file)
@@ -196,7 +196,10 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
                        addr.addr_bytes[2], addr.addr_bytes[3],
                        addr.addr_bytes[4], addr.addr_bytes[5]);
 
-       rte_eth_promiscuous_enable(port);
+       retval = rte_eth_promiscuous_enable(port);
+       if (retval != 0)
+               return retval;
+
        rte_eth_add_rx_callback(port, 0, add_timestamps, NULL);
        rte_eth_add_tx_callback(port, 0, calc_latency, NULL);
 
index 773780b..335741a 100644 (file)
@@ -150,7 +150,9 @@ init_port(uint16_t port_num)
                        return retval;
        }
 
-       rte_eth_promiscuous_enable(port_num);
+       retval = rte_eth_promiscuous_enable(port_num);
+       if (retval != 0)
+               return retval;
 
        retval = rte_eth_dev_start(port_num);
        if (retval < 0)
index 171ebde..8f1805a 100644 (file)
@@ -98,7 +98,9 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
                        addr.addr_bytes[4], addr.addr_bytes[5]);
 
        /* Enable RX in promiscuous mode for the Ethernet device. */
-       rte_eth_promiscuous_enable(port);
+       retval = rte_eth_promiscuous_enable(port);
+       if (retval != 0)
+               return retval;
 
        return 0;
 }
index 794d12b..b5632d7 100644 (file)
@@ -336,8 +336,15 @@ port_init(uint16_t port)
                return retval;
        }
 
-       if (promiscuous)
-               rte_eth_promiscuous_enable(port);
+       if (promiscuous) {
+               retval = rte_eth_promiscuous_enable(port);
+               if (retval != 0) {
+                       RTE_LOG(ERR, VHOST_PORT,
+                               "Failed to enable promiscuous mode on port %u: %s\n",
+                               port, rte_strerror(-retval));
+                       return retval;
+               }
+       }
 
        rte_eth_macaddr_get(port, &vmdq_ports_eth_addr[port]);
        RTE_LOG(INFO, VHOST_PORT, "Max virtio devices supported: %u\n", num_devices);
index 0f48ae9..3778b53 100644 (file)
@@ -121,7 +121,9 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
                        addr.addr_bytes[4], addr.addr_bytes[5]);
 
        /* Enable RX in promiscuous mode for the Ethernet device. */
-       rte_eth_promiscuous_enable(port);
+       retval = rte_eth_promiscuous_enable(port);
+       if (retval != 0)
+               return retval;
 
 
        return 0;