ethdev: add represented port action to flow API
[dpdk.git] / app / test / test_mbuf.c
index 71bdab6..8277710 100644 (file)
@@ -72,7 +72,7 @@
 
 #ifdef RTE_MBUF_REFCNT_ATOMIC
 
-static volatile uint32_t refcnt_stop_slaves;
+static volatile uint32_t refcnt_stop_workers;
 static unsigned refcnt_lcore[RTE_MAX_LCORE];
 
 #endif
@@ -1000,7 +1000,7 @@ test_pktmbuf_free_segment(struct rte_mempool *pktmbuf_pool)
 #ifdef RTE_MBUF_REFCNT_ATOMIC
 
 static int
-test_refcnt_slave(void *arg)
+test_refcnt_worker(void *arg)
 {
        unsigned lcore, free;
        void *mp = 0;
@@ -1010,7 +1010,7 @@ test_refcnt_slave(void *arg)
        printf("%s started at lcore %u\n", __func__, lcore);
 
        free = 0;
-       while (refcnt_stop_slaves == 0) {
+       while (refcnt_stop_workers == 0) {
                if (rte_ring_dequeue(refcnt_mbuf_ring, &mp) == 0) {
                        free++;
                        rte_pktmbuf_free(mp);
@@ -1038,7 +1038,7 @@ test_refcnt_iter(unsigned int lcore, unsigned int iter,
        /* For each mbuf in the pool:
         * - allocate mbuf,
         * - increment it's reference up to N+1,
-        * - enqueue it N times into the ring for slave cores to free.
+        * - enqueue it N times into the ring for worker cores to free.
         */
        for (i = 0, n = rte_mempool_avail_count(refcnt_pool);
            i != n && (m = rte_pktmbuf_alloc(refcnt_pool)) != NULL;
@@ -1062,7 +1062,7 @@ test_refcnt_iter(unsigned int lcore, unsigned int iter,
                rte_panic("(lcore=%u, iter=%u): was able to allocate only "
                          "%u from %u mbufs\n", lcore, iter, i, n);
 
-       /* wait till slave lcores  will consume all mbufs */
+       /* wait till worker lcores  will consume all mbufs */
        while (!rte_ring_empty(refcnt_mbuf_ring))
                ;
 
@@ -1083,7 +1083,7 @@ test_refcnt_iter(unsigned int lcore, unsigned int iter,
 }
 
 static int
-test_refcnt_master(struct rte_mempool *refcnt_pool,
+test_refcnt_main(struct rte_mempool *refcnt_pool,
                   struct rte_ring *refcnt_mbuf_ring)
 {
        unsigned i, lcore;
@@ -1094,7 +1094,7 @@ test_refcnt_master(struct rte_mempool *refcnt_pool,
        for (i = 0; i != REFCNT_MAX_ITER; i++)
                test_refcnt_iter(lcore, i, refcnt_pool, refcnt_mbuf_ring);
 
-       refcnt_stop_slaves = 1;
+       refcnt_stop_workers = 1;
        rte_wmb();
 
        printf("%s finished at lcore %u\n", __func__, lcore);
@@ -1107,7 +1107,7 @@ static int
 test_refcnt_mbuf(void)
 {
 #ifdef RTE_MBUF_REFCNT_ATOMIC
-       unsigned int master, slave, tref;
+       unsigned int main_lcore, worker, tref;
        int ret = -1;
        struct rte_mempool *refcnt_pool = NULL;
        struct rte_ring *refcnt_mbuf_ring = NULL;
@@ -1126,39 +1126,38 @@ test_refcnt_mbuf(void)
                                              SOCKET_ID_ANY);
        if (refcnt_pool == NULL) {
                printf("%s: cannot allocate " MAKE_STRING(refcnt_pool) "\n",
-                   __func__);
+                      __func__);
                return -1;
        }
 
        refcnt_mbuf_ring = rte_ring_create("refcnt_mbuf_ring",
-                       rte_align32pow2(REFCNT_RING_SIZE), SOCKET_ID_ANY,
-                                       RING_F_SP_ENQ);
+                                          rte_align32pow2(REFCNT_RING_SIZE), SOCKET_ID_ANY,
+                                          RING_F_SP_ENQ);
        if (refcnt_mbuf_ring == NULL) {
                printf("%s: cannot allocate " MAKE_STRING(refcnt_mbuf_ring)
-                   "\n", __func__);
+                      "\n", __func__);
                goto err;
        }
 
-       refcnt_stop_slaves = 0;
+       refcnt_stop_workers = 0;
        memset(refcnt_lcore, 0, sizeof (refcnt_lcore));
 
-       rte_eal_mp_remote_launch(test_refcnt_slave, refcnt_mbuf_ring,
-                                SKIP_MASTER);
+       rte_eal_mp_remote_launch(test_refcnt_worker, refcnt_mbuf_ring, SKIP_MAIN);
 
-       test_refcnt_master(refcnt_pool, refcnt_mbuf_ring);
+       test_refcnt_main(refcnt_pool, refcnt_mbuf_ring);
 
        rte_eal_mp_wait_lcore();
 
        /* check that we porcessed all references */
        tref = 0;
-       master = rte_get_master_lcore();
+       main_lcore = rte_get_main_lcore();
 
-       RTE_LCORE_FOREACH_SLAVE(slave)
-               tref += refcnt_lcore[slave];
+       RTE_LCORE_FOREACH_WORKER(worker)
+               tref += refcnt_lcore[worker];
 
-       if (tref != refcnt_lcore[master])
+       if (tref != refcnt_lcore[main_lcore])
                rte_panic("referenced mbufs: %u, freed mbufs: %u\n",
-                         tref, refcnt_lcore[master]);
+                         tref, refcnt_lcore[main_lcore]);
 
        rte_mempool_dump(stdout, refcnt_pool);
        rte_ring_dump(stdout, refcnt_mbuf_ring);
@@ -1175,6 +1174,8 @@ err:
 }
 
 #include <unistd.h>
+#include <sys/resource.h>
+#include <sys/time.h>
 #include <sys/wait.h>
 
 /* use fork() to test mbuf errors panic */
@@ -1187,9 +1188,14 @@ verify_mbuf_check_panics(struct rte_mbuf *buf)
        pid = fork();
 
        if (pid == 0) {
+               struct rlimit rl;
+
+               /* No need to generate a coredump when panicking. */
+               rl.rlim_cur = rl.rlim_max = 0;
+               setrlimit(RLIMIT_CORE, &rl);
                rte_mbuf_sanity_check(buf, 1); /* should panic */
                exit(0);  /* return normally if it doesn't panic */
-       } else if (pid < 0){
+       } else if (pid < 0) {
                printf("Fork Failed\n");
                return -1;
        }
@@ -1614,7 +1620,7 @@ test_get_rx_ol_flag_name(void)
                VAL_NAME(PKT_RX_IP_CKSUM_BAD),
                VAL_NAME(PKT_RX_IP_CKSUM_GOOD),
                VAL_NAME(PKT_RX_IP_CKSUM_NONE),
-               VAL_NAME(PKT_RX_EIP_CKSUM_BAD),
+               VAL_NAME(PKT_RX_OUTER_IP_CKSUM_BAD),
                VAL_NAME(PKT_RX_VLAN_STRIPPED),
                VAL_NAME(PKT_RX_IEEE1588_PTP),
                VAL_NAME(PKT_RX_IEEE1588_TMST),
@@ -1622,7 +1628,6 @@ test_get_rx_ol_flag_name(void)
                VAL_NAME(PKT_RX_FDIR_FLX),
                VAL_NAME(PKT_RX_QINQ_STRIPPED),
                VAL_NAME(PKT_RX_LRO),
-               VAL_NAME(PKT_RX_TIMESTAMP),
                VAL_NAME(PKT_RX_SEC_OFFLOAD),
                VAL_NAME(PKT_RX_SEC_OFFLOAD_FAILED),
                VAL_NAME(PKT_RX_OUTER_L4_CKSUM_BAD),
@@ -2358,7 +2363,7 @@ test_pktmbuf_ext_shinfo_init_helper(struct rte_mempool *pktmbuf_pool)
        if (rte_mbuf_refcnt_read(m) != 1)
                GOTO_FAIL("%s: Invalid refcnt in mbuf\n", __func__);
 
-       buf_iova = rte_mempool_virt2iova(ext_buf_addr);
+       buf_iova = rte_mem_virt2iova(ext_buf_addr);
        rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
                ret_shinfo);
        if (m->ol_flags != EXT_ATTACHED_MBUF)
@@ -2572,6 +2577,16 @@ test_mbuf_dyn(struct rte_mempool *pktmbuf_pool)
                .align = 3,
                .flags = 0,
        };
+       const struct rte_mbuf_dynfield dynfield_fail_flag = {
+               .name = "test-dynfield",
+               .size = sizeof(uint8_t),
+               .align = __alignof__(uint8_t),
+               .flags = 1,
+       };
+       const struct rte_mbuf_dynflag dynflag_fail_flag = {
+               .name = "test-dynflag",
+               .flags = 1,
+       };
        const struct rte_mbuf_dynflag dynflag = {
                .name = "test-dynflag",
                .flags = 0,
@@ -2609,9 +2624,13 @@ test_mbuf_dyn(struct rte_mempool *pktmbuf_pool)
 
        offset3 = rte_mbuf_dynfield_register_offset(&dynfield3,
                                offsetof(struct rte_mbuf, dynfield1[1]));
-       if (offset3 != offsetof(struct rte_mbuf, dynfield1[1]))
-               GOTO_FAIL("failed to register dynamic field 3, offset=%d: %s",
-                       offset3, strerror(errno));
+       if (offset3 != offsetof(struct rte_mbuf, dynfield1[1])) {
+               if (rte_errno == EBUSY)
+                       printf("mbuf test error skipped: dynfield is busy\n");
+               else
+                       GOTO_FAIL("failed to register dynamic field 3, offset="
+                               "%d: %s", offset3, strerror(errno));
+       }
 
        printf("dynfield: offset=%d, offset2=%d, offset3=%d\n",
                offset, offset2, offset3);
@@ -2629,6 +2648,14 @@ test_mbuf_dyn(struct rte_mempool *pktmbuf_pool)
        if (ret != -1)
                GOTO_FAIL("dynamic field creation should fail (not avail)");
 
+       ret = rte_mbuf_dynfield_register(&dynfield_fail_flag);
+       if (ret != -1)
+               GOTO_FAIL("dynamic field creation should fail (invalid flag)");
+
+       ret = rte_mbuf_dynflag_register(&dynflag_fail_flag);
+       if (ret != -1)
+               GOTO_FAIL("dynamic flag creation should fail (invalid flag)");
+
        flag = rte_mbuf_dynflag_register(&dynflag);
        if (flag == -1)
                GOTO_FAIL("failed to register dynamic flag, flag=%d: %s",
@@ -2647,7 +2674,7 @@ test_mbuf_dyn(struct rte_mempool *pktmbuf_pool)
        flag3 = rte_mbuf_dynflag_register_bitnum(&dynflag3,
                                                rte_bsf64(PKT_LAST_FREE));
        if (flag3 != rte_bsf64(PKT_LAST_FREE))
-               GOTO_FAIL("failed to register dynamic flag 3, flag2=%d: %s",
+               GOTO_FAIL("failed to register dynamic flag 3, flag3=%d: %s",
                        flag3, strerror(errno));
 
        printf("dynflag: flag=%d, flag2=%d, flag3=%d\n", flag, flag2, flag3);