app: check code of promiscuous mode switch
authorIvan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Sat, 14 Sep 2019 11:37:26 +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 apps according to new return type.

Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
app/pdump/main.c
app/test-eventdev/test_perf_common.c
app/test-eventdev/test_pipeline_common.c
app/test-pipeline/init.c
app/test/test_event_eth_rx_adapter.c
app/test/test_event_eth_tx_adapter.c
app/test/test_link_bonding.c
app/test/test_link_bonding_mode4.c
app/test/test_pmd_perf.c

index c1b9012..9d6be8e 100644 (file)
@@ -614,7 +614,13 @@ configure_vdev(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) {
+               rte_exit(EXIT_FAILURE,
+                        "promiscuous mode enable failed: %s\n",
+                        rte_strerror(-ret));
+               return ret;
+       }
 
        return 0;
 }
index e75582b..e245191 100644 (file)
@@ -726,7 +726,12 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
                        return -EINVAL;
                }
 
-               rte_eth_promiscuous_enable(i);
+               ret = rte_eth_promiscuous_enable(i);
+               if (ret != 0) {
+                       evt_err("Failed to enable promiscuous mode for eth port [%d]: %s",
+                               i, rte_strerror(-ret));
+                       return ret;
+               }
        }
 
        return 0;
index ef8ae28..6166516 100644 (file)
@@ -233,7 +233,12 @@ pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt)
                        return -EINVAL;
                }
 
-               rte_eth_promiscuous_enable(i);
+               ret = rte_eth_promiscuous_enable(i);
+               if (ret != 0) {
+                       evt_err("Failed to enable promiscuous mode for eth port [%d]: %s",
+                               i, rte_strerror(-ret));
+                       return ret;
+               }
        }
 
        return 0;
index b75688a..871d9fa 100644 (file)
@@ -200,7 +200,10 @@ app_init_ports(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 for port %u: %s\n",
+                               port, rte_strerror(-ret));
 
                /* Init RX queues */
                ret = rte_eth_rx_queue_setup(
index 950bc67..6254fcd 100644 (file)
@@ -90,7 +90,9 @@ port_init_common(uint16_t port, const struct rte_eth_conf *port_conf,
                        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 208d20c..73f6afe 100644 (file)
@@ -94,7 +94,9 @@ port_init_common(uint8_t port, const struct rte_eth_conf *port_conf,
                        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 938fafc..cbbbc98 100644 (file)
@@ -1760,13 +1760,17 @@ static int
 test_roundrobin_verify_promiscuous_enable_disable(void)
 {
        int i, promiscuous_en;
+       int ret;
 
        /* Initialize bonded device with 4 slaves in round robin mode */
        TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
                        BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
                        "Failed to initialize bonded device with slaves");
 
-       rte_eth_promiscuous_enable(test_params->bonded_port_id);
+       ret = rte_eth_promiscuous_enable(test_params->bonded_port_id);
+       TEST_ASSERT_SUCCESS(ret,
+               "Failed to enable promiscuous mode for port %d: %s",
+               test_params->bonded_port_id, rte_strerror(-ret));
 
        promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
        TEST_ASSERT_EQUAL(promiscuous_en, 1,
@@ -1781,7 +1785,10 @@ test_roundrobin_verify_promiscuous_enable_disable(void)
                                test_params->slave_port_ids[i]);
        }
 
-       rte_eth_promiscuous_disable(test_params->bonded_port_id);
+       ret = rte_eth_promiscuous_disable(test_params->bonded_port_id);
+       TEST_ASSERT_SUCCESS(ret,
+               "Failed to disable promiscuous mode for port %d: %s",
+               test_params->bonded_port_id, rte_strerror(-ret));
 
        promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
        TEST_ASSERT_EQUAL(promiscuous_en, 0,
@@ -2200,6 +2207,7 @@ static int
 test_activebackup_verify_promiscuous_enable_disable(void)
 {
        int i, primary_port, promiscuous_en;
+       int ret;
 
        /* Initialize bonded device with 4 slaves in round robin mode */
        TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
@@ -2211,7 +2219,10 @@ test_activebackup_verify_promiscuous_enable_disable(void)
                        "failed to get primary slave for bonded port (%d)",
                        test_params->bonded_port_id);
 
-       rte_eth_promiscuous_enable(test_params->bonded_port_id);
+       ret = rte_eth_promiscuous_enable(test_params->bonded_port_id);
+       TEST_ASSERT_SUCCESS(ret,
+               "Failed to enable promiscuous mode for port %d: %s",
+               test_params->bonded_port_id, rte_strerror(-ret));
 
        TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 1,
                        "Port (%d) promiscuous mode not enabled",
@@ -2232,7 +2243,10 @@ test_activebackup_verify_promiscuous_enable_disable(void)
 
        }
 
-       rte_eth_promiscuous_disable(test_params->bonded_port_id);
+       ret = rte_eth_promiscuous_disable(test_params->bonded_port_id);
+       TEST_ASSERT_SUCCESS(ret,
+               "Failed to disable promiscuous mode for port %d: %s",
+               test_params->bonded_port_id, rte_strerror(-ret));
 
        TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 0,
                        "Port (%d) promiscuous mode not disabled\n",
@@ -3110,13 +3124,17 @@ static int
 test_balance_verify_promiscuous_enable_disable(void)
 {
        int i;
+       int ret;
 
        /* Initialize bonded device with 4 slaves in round robin mode */
        TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
                        BONDING_MODE_BALANCE, 0, 4, 1),
                        "Failed to initialise bonded device");
 
-       rte_eth_promiscuous_enable(test_params->bonded_port_id);
+       ret = rte_eth_promiscuous_enable(test_params->bonded_port_id);
+       TEST_ASSERT_SUCCESS(ret,
+               "Failed to enable promiscuous mode for port %d: %s",
+               test_params->bonded_port_id, rte_strerror(-ret));
 
        TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 1,
                        "Port (%d) promiscuous mode not enabled",
@@ -3129,7 +3147,10 @@ test_balance_verify_promiscuous_enable_disable(void)
                                test_params->slave_port_ids[i]);
        }
 
-       rte_eth_promiscuous_disable(test_params->bonded_port_id);
+       ret = rte_eth_promiscuous_disable(test_params->bonded_port_id);
+       TEST_ASSERT_SUCCESS(ret,
+               "Failed to disable promiscuous mode for port %d: %s",
+               test_params->bonded_port_id, rte_strerror(-ret));
 
        TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 0,
                        "Port (%d) promiscuous mode not disabled",
@@ -3696,13 +3717,17 @@ static int
 test_broadcast_verify_promiscuous_enable_disable(void)
 {
        int i;
+       int ret;
 
        /* Initialize bonded device with 4 slaves in round robin mode */
        TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
                        BONDING_MODE_BROADCAST, 0, 4, 1),
                        "Failed to initialise bonded device");
 
-       rte_eth_promiscuous_enable(test_params->bonded_port_id);
+       ret = rte_eth_promiscuous_enable(test_params->bonded_port_id);
+       TEST_ASSERT_SUCCESS(ret,
+               "Failed to enable promiscuous mode for port %d: %s",
+               test_params->bonded_port_id, rte_strerror(-ret));
 
 
        TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 1,
@@ -3716,7 +3741,10 @@ test_broadcast_verify_promiscuous_enable_disable(void)
                                test_params->slave_port_ids[i]);
        }
 
-       rte_eth_promiscuous_disable(test_params->bonded_port_id);
+       ret = rte_eth_promiscuous_disable(test_params->bonded_port_id);
+       TEST_ASSERT_SUCCESS(ret,
+               "Failed to disable promiscuous mode for port %d: %s",
+               test_params->bonded_port_id, rte_strerror(-ret));
 
        TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 0,
                        "Port (%d) promiscuous mode not disabled",
@@ -4174,6 +4202,7 @@ static int
 test_tlb_verify_promiscuous_enable_disable(void)
 {
        int i, primary_port, promiscuous_en;
+       int ret;
 
        /* Initialize bonded device with 4 slaves in transmit load balancing mode */
        TEST_ASSERT_SUCCESS( initialize_bonded_device_with_slaves(
@@ -4185,7 +4214,10 @@ test_tlb_verify_promiscuous_enable_disable(void)
                        "failed to get primary slave for bonded port (%d)",
                        test_params->bonded_port_id);
 
-       rte_eth_promiscuous_enable(test_params->bonded_port_id);
+       ret = rte_eth_promiscuous_enable(test_params->bonded_port_id);
+       TEST_ASSERT_SUCCESS(ret,
+               "Failed to enable promiscuous mode for port %d: %s",
+               test_params->bonded_port_id, rte_strerror(-ret));
 
        promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
        TEST_ASSERT_EQUAL(promiscuous_en, (int)1,
@@ -4206,7 +4238,10 @@ test_tlb_verify_promiscuous_enable_disable(void)
 
        }
 
-       rte_eth_promiscuous_disable(test_params->bonded_port_id);
+       ret = rte_eth_promiscuous_disable(test_params->bonded_port_id);
+       TEST_ASSERT_SUCCESS(ret,
+               "Failed to disable promiscuous mode for port %d: %s\n",
+               test_params->bonded_port_id, rte_strerror(-ret));
 
        promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
        TEST_ASSERT_EQUAL(promiscuous_en, (int)0,
index bbb4e9c..70b95d0 100644 (file)
@@ -312,6 +312,7 @@ static int
 initialize_bonded_device_with_slaves(uint16_t slave_count, uint8_t external_sm)
 {
        uint8_t i;
+       int ret;
 
        RTE_VERIFY(test_params.bonded_port_id != INVALID_PORT_ID);
 
@@ -323,7 +324,10 @@ initialize_bonded_device_with_slaves(uint16_t slave_count, uint8_t external_sm)
 
        /* Reset mode 4 configuration */
        rte_eth_bond_8023ad_setup(test_params.bonded_port_id, NULL);
-       rte_eth_promiscuous_disable(test_params.bonded_port_id);
+       ret = rte_eth_promiscuous_disable(test_params.bonded_port_id);
+       TEST_ASSERT_SUCCESS(ret,
+               "Failed disable promiscuous mode for port %d: %s",
+               test_params.bonded_port_id, rte_strerror(-ret));
 
        if (external_sm) {
                struct rte_eth_bond_8023ad_conf conf;
@@ -824,7 +828,10 @@ test_mode4_rx(void)
        /* First try with promiscuous mode enabled.
         * Add 2 packets to each slave. First with bonding MAC address, second with
         * different. Check if we received all of them. */
-       rte_eth_promiscuous_enable(test_params.bonded_port_id);
+       retval = rte_eth_promiscuous_enable(test_params.bonded_port_id);
+       TEST_ASSERT_SUCCESS(retval,
+                       "Failed to enable promiscuous mode for port %d: %s",
+                       test_params.bonded_port_id, rte_strerror(-retval));
 
        expected_pkts_cnt = 0;
        FOR_EACH_SLAVE(i, slave) {
@@ -869,7 +876,10 @@ test_mode4_rx(void)
 
        /* Now, disable promiscuous mode. When promiscuous mode is disabled we
         * expect to receive only packets that are directed to bonding port. */
-       rte_eth_promiscuous_disable(test_params.bonded_port_id);
+       retval = rte_eth_promiscuous_disable(test_params.bonded_port_id);
+       TEST_ASSERT_SUCCESS(retval,
+               "Failed to disable promiscuous mode for port %d: %s",
+               test_params.bonded_port_id, rte_strerror(-retval));
 
        expected_pkts_cnt = 0;
        FOR_EACH_SLAVE(i, slave) {
index 4f9fc0d..85ef118 100644 (file)
@@ -745,7 +745,11 @@ test_pmd_perf(void)
                                ret, portid);
 
                /* always eanble promiscuous */
-               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);
 
                lcore_conf[slave_id].portlist[num++] = portid;
                lcore_conf[slave_id].nb_ports++;