test/threads: add unit test
[dpdk.git] / app / test / test_kni.c
index 931e8cb..622315c 100644 (file)
@@ -2,16 +2,13 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#include "test.h"
+
 #include <stdio.h>
 #include <stdint.h>
 #include <unistd.h>
 #include <string.h>
-#include <sys/wait.h>
-#include <dirent.h>
-
-#include "test.h"
-
-#if !defined(RTE_EXEC_ENV_LINUX) || !defined(RTE_LIBRTE_KNI)
+#if !defined(RTE_EXEC_ENV_LINUX) || !defined(RTE_LIB_KNI)
 
 static int
 test_kni(void)
@@ -22,6 +19,9 @@ test_kni(void)
 
 #else
 
+#include <sys/wait.h>
+#include <dirent.h>
+
 #include <rte_string_fns.h>
 #include <rte_mempool.h>
 #include <rte_ethdev.h>
@@ -74,7 +74,7 @@ static const struct rte_eth_txconf tx_conf = {
 
 static const struct rte_eth_conf port_conf = {
        .txmode = {
-               .mq_mode = ETH_DCB_NONE,
+               .mq_mode = RTE_ETH_MQ_TX_NONE,
        },
 };
 
@@ -85,7 +85,7 @@ static struct rte_kni_ops kni_ops = {
        .config_promiscusity = NULL,
 };
 
-static unsigned lcore_master, lcore_ingress, lcore_egress;
+static unsigned int lcore_main, lcore_ingress, lcore_egress;
 static struct rte_kni *test_kni_ctx;
 static struct test_kni_stats stats;
 
@@ -202,7 +202,7 @@ error:
  * supported by KNI kernel module. The ingress lcore will allocate mbufs and
  * transmit them to kernel space; while the egress lcore will receive the mbufs
  * from kernel space and free them.
- * On the master lcore, several commands will be run to check handling the
+ * On the main lcore, several commands will be run to check handling the
  * kernel requests. And it will finally set the flag to exit the KNI
  * transmitting/receiving to/from the kernel space.
  *
@@ -217,7 +217,7 @@ test_kni_loop(__rte_unused void *arg)
        const unsigned lcore_id = rte_lcore_id();
        struct rte_mbuf *pkts_burst[PKT_BURST_SZ];
 
-       if (lcore_id == lcore_master) {
+       if (lcore_id == lcore_main) {
                rte_delay_ms(KNI_TIMEOUT_MS);
                /* tests of handling kernel request */
                if (system(IFCONFIG TEST_KNI_PORT" up") == -1)
@@ -276,12 +276,12 @@ test_kni_allocate_lcores(void)
 {
        unsigned i, count = 0;
 
-       lcore_master = rte_get_master_lcore();
-       printf("master lcore: %u\n", lcore_master);
+       lcore_main = rte_get_main_lcore();
+       printf("main lcore: %u\n", lcore_main);
        for (i = 0; i < RTE_MAX_LCORE; i++) {
                if (count >=2 )
                        break;
-               if (rte_lcore_is_enabled(i) && i != lcore_master) {
+               if (rte_lcore_is_enabled(i) && i != lcore_main) {
                        count ++;
                        if (count == 1)
                                lcore_ingress = i;
@@ -326,7 +326,7 @@ test_kni_register_handler_mp(void)
 
                /* Check with the invalid parameters */
                if (rte_kni_register_handlers(kni, NULL) == 0) {
-                       printf("Unexpectedly register successuflly "
+                       printf("Unexpectedly register successfully "
                                        "with NULL ops pointer\n");
                        exit(-1);
                }
@@ -475,7 +475,7 @@ test_kni_processing(uint16_t port_id, struct rte_mempool *mp)
 
        /**
         * Check multiple processes support on
-        * registerring/unregisterring handlers.
+        * registering/unregistering handlers.
         */
        if (test_kni_register_handler_mp() < 0) {
                printf("fail to check multiple process support\n");
@@ -487,8 +487,8 @@ test_kni_processing(uint16_t port_id, struct rte_mempool *mp)
        if (ret != 0)
                goto fail_kni;
 
-       rte_eal_mp_remote_launch(test_kni_loop, NULL, CALL_MASTER);
-       RTE_LCORE_FOREACH_SLAVE(i) {
+       rte_eal_mp_remote_launch(test_kni_loop, NULL, CALL_MAIN);
+       RTE_LCORE_FOREACH_WORKER(i) {
                if (rte_eal_wait_lcore(i) < 0) {
                        ret = -1;
                        goto fail_kni;
@@ -562,8 +562,12 @@ test_kni(void)
        }
        closedir(dir);
 
-       /* Initialize KNI subsytem */
-       rte_kni_init(KNI_TEST_MAX_PORTS);
+       /* Initialize KNI subsystem */
+       ret = rte_kni_init(KNI_TEST_MAX_PORTS);
+       if (ret < 0) {
+               printf("fail to initialize KNI subsystem\n");
+               return -1;
+       }
 
        if (test_kni_allocate_lcores() < 0) {
                printf("No enough lcores for kni processing\n");