15129044dSC.J. Collier/*-
25129044dSC.J. Collier *   BSD LICENSE
35129044dSC.J. Collier *
45129044dSC.J. Collier *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
55129044dSC.J. Collier *   All rights reserved.
65129044dSC.J. Collier *
75129044dSC.J. Collier *   Redistribution and use in source and binary forms, with or without
85129044dSC.J. Collier *   modification, are permitted provided that the following conditions
95129044dSC.J. Collier *   are met:
105129044dSC.J. Collier *
115129044dSC.J. Collier *     * Redistributions of source code must retain the above copyright
125129044dSC.J. Collier *       notice, this list of conditions and the following disclaimer.
135129044dSC.J. Collier *     * Redistributions in binary form must reproduce the above copyright
145129044dSC.J. Collier *       notice, this list of conditions and the following disclaimer in
155129044dSC.J. Collier *       the documentation and/or other materials provided with the
165129044dSC.J. Collier *       distribution.
175129044dSC.J. Collier *     * Neither the name of Intel Corporation nor the names of its
185129044dSC.J. Collier *       contributors may be used to endorse or promote products derived
195129044dSC.J. Collier *       from this software without specific prior written permission.
205129044dSC.J. Collier *
215129044dSC.J. Collier *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
225129044dSC.J. Collier *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
235129044dSC.J. Collier *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
245129044dSC.J. Collier *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
255129044dSC.J. Collier *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
265129044dSC.J. Collier *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
275129044dSC.J. Collier *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
285129044dSC.J. Collier *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
295129044dSC.J. Collier *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
305129044dSC.J. Collier *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
315129044dSC.J. Collier *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
325129044dSC.J. Collier */
335129044dSC.J. Collier
345129044dSC.J. Collier#include <stdio.h>
355129044dSC.J. Collier#include <stdint.h>
365129044dSC.J. Collier#include <unistd.h>
375129044dSC.J. Collier#include <sys/queue.h>
385129044dSC.J. Collier
395129044dSC.J. Collier#include <rte_memory.h>
405129044dSC.J. Collier#include <rte_memzone.h>
415129044dSC.J. Collier#include <rte_per_lcore.h>
425129044dSC.J. Collier#include <rte_launch.h>
435129044dSC.J. Collier#include <rte_atomic.h>
445129044dSC.J. Collier#include <rte_eal.h>
455129044dSC.J. Collier#include <rte_per_lcore.h>
465129044dSC.J. Collier#include <rte_lcore.h>
475129044dSC.J. Collier
485129044dSC.J. Collier#include "test.h"
495129044dSC.J. Collier
505129044dSC.J. Collier/*
515129044dSC.J. Collier * Atomic Variables
525129044dSC.J. Collier * ================
535129044dSC.J. Collier *
545129044dSC.J. Collier * - The main test function performs three subtests. The first test
555129044dSC.J. Collier *   checks that the usual inc/dec/add/sub functions are working
565129044dSC.J. Collier *   correctly:
575129044dSC.J. Collier *
585129044dSC.J. Collier *   - Initialize 16-bit, 32-bit and 64-bit atomic variables to specific
595129044dSC.J. Collier *     values.
605129044dSC.J. Collier *
615129044dSC.J. Collier *   - These variables are incremented and decremented on each core at
625129044dSC.J. Collier *     the same time in ``test_atomic_usual()``.
635129044dSC.J. Collier *
645129044dSC.J. Collier *   - The function checks that once all lcores finish their function,
655129044dSC.J. Collier *     the value of the atomic variables are still the same.
665129044dSC.J. Collier *
675129044dSC.J. Collier * - The second test verifies the behavior of "test and set" functions.
685129044dSC.J. Collier *
695129044dSC.J. Collier *   - Initialize 16-bit, 32-bit and 64-bit atomic variables to zero.
705129044dSC.J. Collier *
715129044dSC.J. Collier *   - Invoke ``test_atomic_tas()`` on each lcore: before doing anything
725129044dSC.J. Collier *     else. The cores are waiting a synchro using ``while
735129044dSC.J. Collier *     (rte_atomic32_read(&val) == 0)`` which is triggered by the main test
745129044dSC.J. Collier *     function. Then all cores do a
755129044dSC.J. Collier *     ``rte_atomicXX_test_and_set()`` at the same time. If it is successful,
765129044dSC.J. Collier *     it increments another atomic counter.
775129044dSC.J. Collier *
785129044dSC.J. Collier *   - The main function checks that the atomic counter was incremented
795129044dSC.J. Collier *     twice only (one for 16-bit, one for 32-bit and one for 64-bit values).
805129044dSC.J. Collier *
815129044dSC.J. Collier * - Test "add/sub and return"
825129044dSC.J. Collier *
835129044dSC.J. Collier *   - Initialize 16-bit, 32-bit and 64-bit atomic variables to zero.
845129044dSC.J. Collier *
855129044dSC.J. Collier *   - Invoke ``test_atomic_addsub_return()`` on each lcore. Before doing
865129044dSC.J. Collier *     anything else, the cores are waiting a synchro. Each lcore does
875129044dSC.J. Collier *     this operation several times::
885129044dSC.J. Collier *
895129044dSC.J. Collier *       tmp = rte_atomicXX_add_return(&a, 1);
905129044dSC.J. Collier *       atomic_add(&count, tmp);
915129044dSC.J. Collier *       tmp = rte_atomicXX_sub_return(&a, 1);
925129044dSC.J. Collier *       atomic_sub(&count, tmp+1);
935129044dSC.J. Collier *
945129044dSC.J. Collier *   - At the end of the test, the *count* value must be 0.
955129044dSC.J. Collier */
965129044dSC.J. Collier
975129044dSC.J. Collier#define NUM_ATOMIC_TYPES 3
985129044dSC.J. Collier
995129044dSC.J. Collier#define N 10000
1005129044dSC.J. Collier
1015129044dSC.J. Collierstatic rte_atomic16_t a16;
1025129044dSC.J. Collierstatic rte_atomic32_t a32;
1035129044dSC.J. Collierstatic rte_atomic64_t a64;
1045129044dSC.J. Collierstatic rte_atomic64_t count;
1055129044dSC.J. Collierstatic rte_atomic32_t synchro;
1065129044dSC.J. Collier
1075129044dSC.J. Collierstatic int
1085129044dSC.J. Colliertest_atomic_usual(__attribute__((unused)) void *arg)
1095129044dSC.J. Collier{
1105129044dSC.J. Collier	unsigned i;
1115129044dSC.J. Collier
1125129044dSC.J. Collier	while (rte_atomic32_read(&synchro) == 0)
1135129044dSC.J. Collier		;
1145129044dSC.J. Collier
1155129044dSC.J. Collier	for (i = 0; i < N; i++)
1165129044dSC.J. Collier		rte_atomic16_inc(&a16);
1175129044dSC.J. Collier	for (i = 0; i < N; i++)
1185129044dSC.J. Collier		rte_atomic16_dec(&a16);
1195129044dSC.J. Collier	for (i = 0; i < (N / 5); i++)
1205129044dSC.J. Collier		rte_atomic16_add(&a16, 5);
1215129044dSC.J. Collier	for (i = 0; i < (N / 5); i++)
1225129044dSC.J. Collier		rte_atomic16_sub(&a16, 5);
1235129044dSC.J. Collier
1245129044dSC.J. Collier	for (i = 0; i < N; i++)
1255129044dSC.J. Collier		rte_atomic32_inc(&a32);
1265129044dSC.J. Collier	for (i = 0; i < N; i++)
1275129044dSC.J. Collier		rte_atomic32_dec(&a32);
1285129044dSC.J. Collier	for (i = 0; i < (N / 5); i++)
1295129044dSC.J. Collier		rte_atomic32_add(&a32, 5);
1305129044dSC.J. Collier	for (i = 0; i < (N / 5); i++)
1315129044dSC.J. Collier		rte_atomic32_sub(&a32, 5);
1325129044dSC.J. Collier
1335129044dSC.J. Collier	for (i = 0; i < N; i++)
1345129044dSC.J. Collier		rte_atomic64_inc(&a64);
1355129044dSC.J. Collier	for (i = 0; i < N; i++)
1365129044dSC.J. Collier		rte_atomic64_dec(&a64);
1375129044dSC.J. Collier	for (i = 0; i < (N / 5); i++)
1385129044dSC.J. Collier		rte_atomic64_add(&a64, 5);
1395129044dSC.J. Collier	for (i = 0; i < (N / 5); i++)
1405129044dSC.J. Collier		rte_atomic64_sub(&a64, 5);
1415129044dSC.J. Collier
1425129044dSC.J. Collier	return 0;
1435129044dSC.J. Collier}
1445129044dSC.J. Collier
1455129044dSC.J. Collierstatic int
1465129044dSC.J. Colliertest_atomic_tas(__attribute__((unused)) void *arg)
1475129044dSC.J. Collier{
1485129044dSC.J. Collier	while (rte_atomic32_read(&synchro) == 0)
1495129044dSC.J. Collier		;
1505129044dSC.J. Collier
1515129044dSC.J. Collier	if (rte_atomic16_test_and_set(&a16))
1525129044dSC.J. Collier		rte_atomic64_inc(&count);
1535129044dSC.J. Collier	if (rte_atomic32_test_and_set(&a32))
1545129044dSC.J. Collier		rte_atomic64_inc(&count);
1555129044dSC.J. Collier	if (rte_atomic64_test_and_set(&a64))
1565129044dSC.J. Collier		rte_atomic64_inc(&count);
1575129044dSC.J. Collier
1585129044dSC.J. Collier	return 0;
1595129044dSC.J. Collier}
1605129044dSC.J. Collier
1615129044dSC.J. Collierstatic int
1625129044dSC.J. Colliertest_atomic_addsub_and_return(__attribute__((unused)) void *arg)
1635129044dSC.J. Collier{
1645129044dSC.J. Collier	uint32_t tmp16;
1655129044dSC.J. Collier	uint32_t tmp32;
1665129044dSC.J. Collier	uint64_t tmp64;
1675129044dSC.J. Collier	unsigned i;
1685129044dSC.J. Collier
1695129044dSC.J. Collier	while (rte_atomic32_read(&synchro) == 0)
1705129044dSC.J. Collier		;
1715129044dSC.J. Collier
1725129044dSC.J. Collier	for (i = 0; i < N; i++) {
1735129044dSC.J. Collier		tmp16 = rte_atomic16_add_return(&a16, 1);
1745129044dSC.J. Collier		rte_atomic64_add(&count, tmp16);
1755129044dSC.J. Collier
1765129044dSC.J. Collier		tmp16 = rte_atomic16_sub_return(&a16, 1);
1775129044dSC.J. Collier		rte_atomic64_sub(&count, tmp16+1);
1785129044dSC.J. Collier
1795129044dSC.J. Collier		tmp32 = rte_atomic32_add_return(&a32, 1);
1805129044dSC.J. Collier		rte_atomic64_add(&count, tmp32);
1815129044dSC.J. Collier
1825129044dSC.J. Collier		tmp32 = rte_atomic32_sub_return(&a32, 1);
1835129044dSC.J. Collier		rte_atomic64_sub(&count, tmp32+1);
1845129044dSC.J. Collier
1855129044dSC.J. Collier		tmp64 = rte_atomic64_add_return(&a64, 1);
1865129044dSC.J. Collier		rte_atomic64_add(&count, tmp64);
1875129044dSC.J. Collier
1885129044dSC.J. Collier		tmp64 = rte_atomic64_sub_return(&a64, 1);
1895129044dSC.J. Collier		rte_atomic64_sub(&count, tmp64+1);
1905129044dSC.J. Collier	}
1915129044dSC.J. Collier
1925129044dSC.J. Collier	return 0;
1935129044dSC.J. Collier}
1945129044dSC.J. Collier
1955129044dSC.J. Collier/*
1965129044dSC.J. Collier * rte_atomic32_inc_and_test() would increase a 32 bits counter by one and then
1975129044dSC.J. Collier * test if that counter is equal to 0. It would return true if the counter is 0
1985129044dSC.J. Collier * and false if the counter is not 0. rte_atomic64_inc_and_test() could do the
1995129044dSC.J. Collier * same thing but for a 64 bits counter.
2005129044dSC.J. Collier * Here checks that if the 32/64 bits counter is equal to 0 after being atomically
2015129044dSC.J. Collier * increased by one. If it is, increase the variable of "count" by one which would
2025129044dSC.J. Collier * be checked as the result later.
2035129044dSC.J. Collier *
2045129044dSC.J. Collier */
2055129044dSC.J. Collierstatic int
2065129044dSC.J. Colliertest_atomic_inc_and_test(__attribute__((unused)) void *arg)
2075129044dSC.J. Collier{
2085129044dSC.J. Collier	while (rte_atomic32_read(&synchro) == 0)
2095129044dSC.J. Collier		;
2105129044dSC.J. Collier
2115129044dSC.J. Collier	if (rte_atomic16_inc_and_test(&a16)) {
2125129044dSC.J. Collier		rte_atomic64_inc(&count);
2135129044dSC.J. Collier	}
2145129044dSC.J. Collier	if (rte_atomic32_inc_and_test(&a32)) {
2155129044dSC.J. Collier		rte_atomic64_inc(&count);
2165129044dSC.J. Collier	}
2175129044dSC.J. Collier	if (rte_atomic64_inc_and_test(&a64)) {
2185129044dSC.J. Collier		rte_atomic64_inc(&count);
2195129044dSC.J. Collier	}
2205129044dSC.J. Collier
2215129044dSC.J. Collier	return 0;
2225129044dSC.J. Collier}
2235129044dSC.J. Collier
2245129044dSC.J. Collier/*
2255129044dSC.J. Collier * rte_atomicXX_dec_and_test() should decrease a 32 bits counter by one and then
2265129044dSC.J. Collier * test if that counter is equal to 0. It should return true if the counter is 0
2275129044dSC.J. Collier * and false if the counter is not 0.
2285129044dSC.J. Collier * This test checks if the counter is equal to 0 after being atomically
2295129044dSC.J. Collier * decreased by one. If it is, increase the value of "count" by one which is to
2305129044dSC.J. Collier * be checked as the result later.
2315129044dSC.J. Collier */
2325129044dSC.J. Collierstatic int
2335129044dSC.J. Colliertest_atomic_dec_and_test(__attribute__((unused)) void *arg)
2345129044dSC.J. Collier{
2355129044dSC.J. Collier	while (rte_atomic32_read(&synchro) == 0)
2365129044dSC.J. Collier		;
2375129044dSC.J. Collier
2385129044dSC.J. Collier	if (rte_atomic16_dec_and_test(&a16))
2395129044dSC.J. Collier		rte_atomic64_inc(&count);
2405129044dSC.J. Collier
2415129044dSC.J. Collier	if (rte_atomic32_dec_and_test(&a32))
2425129044dSC.J. Collier		rte_atomic64_inc(&count);
2435129044dSC.J. Collier
2445129044dSC.J. Collier	if (rte_atomic64_dec_and_test(&a64))
2455129044dSC.J. Collier		rte_atomic64_inc(&count);
2465129044dSC.J. Collier
2475129044dSC.J. Collier	return 0;
2485129044dSC.J. Collier}
2495129044dSC.J. Collier
2505129044dSC.J. Collierstatic int
2515129044dSC.J. Colliertest_atomic(void)
2525129044dSC.J. Collier{
2535129044dSC.J. Collier	rte_atomic16_init(&a16);
2545129044dSC.J. Collier	rte_atomic32_init(&a32);
2555129044dSC.J. Collier	rte_atomic64_init(&a64);
2565129044dSC.J. Collier	rte_atomic64_init(&count);
2575129044dSC.J. Collier	rte_atomic32_init(&synchro);
2585129044dSC.J. Collier
2595129044dSC.J. Collier	rte_atomic16_set(&a16, 1UL << 10);
2605129044dSC.J. Collier	rte_atomic32_set(&a32, 1UL << 10);
2615129044dSC.J. Collier	rte_atomic64_set(&a64, 1ULL << 33);
2625129044dSC.J. Collier
2635129044dSC.J. Collier	printf("usual inc/dec/add/sub functions\n");
2645129044dSC.J. Collier
2655129044dSC.J. Collier	rte_eal_mp_remote_launch(test_atomic_usual, NULL, SKIP_MASTER);
2665129044dSC.J. Collier	rte_atomic32_set(&synchro, 1);
2675129044dSC.J. Collier	rte_eal_mp_wait_lcore();
2685129044dSC.J. Collier	rte_atomic32_set(&synchro, 0);
2695129044dSC.J. Collier
2705129044dSC.J. Collier	if (rte_atomic16_read(&a16) != 1UL << 10) {
2715129044dSC.J. Collier		printf("Atomic16 usual functions failed\n");
2725129044dSC.J. Collier		return -1;
2735129044dSC.J. Collier	}
2745129044dSC.J. Collier
2755129044dSC.J. Collier	if (rte_atomic32_read(&a32) != 1UL << 10) {
2765129044dSC.J. Collier		printf("Atomic32 usual functions failed\n");
2775129044dSC.J. Collier		return -1;
2785129044dSC.J. Collier	}
2795129044dSC.J. Collier
2805129044dSC.J. Collier	if (rte_atomic64_read(&a64) != 1ULL << 33) {
2815129044dSC.J. Collier		printf("Atomic64 usual functions failed\n");
2825129044dSC.J. Collier		return -1;
2835129044dSC.J. Collier	}
2845129044dSC.J. Collier
2855129044dSC.J. Collier	printf("test and set\n");
2865129044dSC.J. Collier
2875129044dSC.J. Collier	rte_atomic64_set(&a64, 0);
2885129044dSC.J. Collier	rte_atomic32_set(&a32, 0);
2895129044dSC.J. Collier	rte_atomic16_set(&a16, 0);
2905129044dSC.J. Collier	rte_atomic64_set(&count, 0);
2915129044dSC.J. Collier	rte_eal_mp_remote_launch(test_atomic_tas, NULL, SKIP_MASTER);
2925129044dSC.J. Collier	rte_atomic32_set(&synchro, 1);
2935129044dSC.J. Collier	rte_eal_mp_wait_lcore();
2945129044dSC.J. Collier	rte_atomic32_set(&synchro, 0);
2955129044dSC.J. Collier
2965129044dSC.J. Collier	if (rte_atomic64_read(&count) != NUM_ATOMIC_TYPES) {
2975129044dSC.J. Collier		printf("Atomic test and set failed\n");
2985129044dSC.J. Collier		return -1;
2995129044dSC.J. Collier	}
3005129044dSC.J. Collier
3015129044dSC.J. Collier	printf("add/sub and return\n");
3025129044dSC.J. Collier
3035129044dSC.J. Collier	rte_atomic64_set(&a64, 0);
3045129044dSC.J. Collier	rte_atomic32_set(&a32, 0);
3055129044dSC.J. Collier	rte_atomic16_set(&a16, 0);
3065129044dSC.J. Collier	rte_atomic64_set(&count, 0);
3075129044dSC.J. Collier	rte_eal_mp_remote_launch(test_atomic_addsub_and_return, NULL,
3085129044dSC.J. Collier				 SKIP_MASTER);
3095129044dSC.J. Collier	rte_atomic32_set(&synchro, 1);
3105129044dSC.J. Collier	rte_eal_mp_wait_lcore();
3115129044dSC.J. Collier	rte_atomic32_set(&synchro, 0);
3125129044dSC.J. Collier
3135129044dSC.J. Collier	if (rte_atomic64_read(&count) != 0) {
3145129044dSC.J. Collier		printf("Atomic add/sub+return failed\n");
3155129044dSC.J. Collier		return -1;
3165129044dSC.J. Collier	}
3175129044dSC.J. Collier
3185129044dSC.J. Collier	/*
3195129044dSC.J. Collier	 * Set a64, a32 and a16 with the same value of minus "number of slave
3205129044dSC.J. Collier	 * lcores", launch all slave lcores to atomically increase by one and
3215129044dSC.J. Collier	 * test them respectively.
3225129044dSC.J. Collier	 * Each lcore should have only one chance to increase a64 by one and
3235129044dSC.J. Collier	 * then check if it is equal to 0, but there should be only one lcore
3245129044dSC.J. Collier	 * that finds that it is 0. It is similar for a32 and a16.
3255129044dSC.J. Collier	 * Then a variable of "count", initialized to zero, is increased by
3265129044dSC.J. Collier	 * one if a64, a32 or a16 is 0 after being increased and tested
3275129044dSC.J. Collier	 * atomically.
3285129044dSC.J. Collier	 * We can check if "count" is finally equal to 3 to see if all slave
3295129044dSC.J. Collier	 * lcores performed "atomic inc and test" right.
3305129044dSC.J. Collier	 */
3315129044dSC.J. Collier	printf("inc and test\n");
3325129044dSC.J. Collier
3335129044dSC.J. Collier	rte_atomic64_clear(&a64);
3345129044dSC.J. Collier	rte_atomic32_clear(&a32);
3355129044dSC.J. Collier	rte_atomic16_clear(&a16);
3365129044dSC.J. Collier	rte_atomic32_clear(&synchro);
3375129044dSC.J. Collier	rte_atomic64_clear(&count);
3385129044dSC.J. Collier
3395129044dSC.J. Collier	rte_atomic64_set(&a64, (int64_t)(1 - (int64_t)rte_lcore_count()));
3405129044dSC.J. Collier	rte_atomic32_set(&a32, (int32_t)(1 - (int32_t)rte_lcore_count()));
3415129044dSC.J. Collier	rte_atomic16_set(&a16, (int16_t)(1 - (int16_t)rte_lcore_count()));
3425129044dSC.J. Collier	rte_eal_mp_remote_launch(test_atomic_inc_and_test, NULL, SKIP_MASTER);
3435129044dSC.J. Collier	rte_atomic32_set(&synchro, 1);
3445129044dSC.J. Collier	rte_eal_mp_wait_lcore();
3455129044dSC.J. Collier	rte_atomic32_clear(&synchro);
3465129044dSC.J. Collier
3475129044dSC.J. Collier	if (rte_atomic64_read(&count) != NUM_ATOMIC_TYPES) {
3485129044dSC.J. Collier		printf("Atomic inc and test failed %d\n", (int)count.cnt);
3495129044dSC.J. Collier		return -1;
3505129044dSC.J. Collier	}
3515129044dSC.J. Collier
3525129044dSC.J. Collier	/*
3535129044dSC.J. Collier	 * Same as above, but this time we set the values to "number of slave
3545129044dSC.J. Collier	 * lcores", and decrement instead of increment.
3555129044dSC.J. Collier	 */
3565129044dSC.J. Collier	printf("dec and test\n");
3575129044dSC.J. Collier
3585129044dSC.J. Collier	rte_atomic32_clear(&synchro);
3595129044dSC.J. Collier	rte_atomic64_clear(&count);
3605129044dSC.J. Collier
3615129044dSC.J. Collier	rte_atomic64_set(&a64, (int64_t)(rte_lcore_count() - 1));
3625129044dSC.J. Collier	rte_atomic32_set(&a32, (int32_t)(rte_lcore_count() - 1));
3635129044dSC.J. Collier	rte_atomic16_set(&a16, (int16_t)(rte_lcore_count() - 1));
3645129044dSC.J. Collier	rte_eal_mp_remote_launch(test_atomic_dec_and_test, NULL, SKIP_MASTER);
3655129044dSC.J. Collier	rte_atomic32_set(&synchro, 1);
3665129044dSC.J. Collier	rte_eal_mp_wait_lcore();
3675129044dSC.J. Collier	rte_atomic32_clear(&synchro);
3685129044dSC.J. Collier
3695129044dSC.J. Collier	if (rte_atomic64_read(&count) != NUM_ATOMIC_TYPES) {
3705129044dSC.J. Collier		printf("Atomic dec and test failed\n");
3715129044dSC.J. Collier		return -1;
3725129044dSC.J. Collier	}
3735129044dSC.J. Collier
3745129044dSC.J. Collier	return 0;
3755129044dSC.J. Collier}
3765129044dSC.J. Collier
3779ecc306dSRicardo SalvetiREGISTER_TEST_COMMAND(atomic_autotest, test_atomic);
378