1a9de470cSBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 2a9de470cSBruce Richardson * Copyright 2017 NXP 3a9de470cSBruce Richardson */ 4*3c60274cSJie Zhou 5*3c60274cSJie Zhou #include "test.h" 6*3c60274cSJie Zhou 7a9de470cSBruce Richardson #include <rte_common.h> 8a9de470cSBruce Richardson #include <rte_mbuf.h> 9a9de470cSBruce Richardson #include <rte_malloc.h> 10a9de470cSBruce Richardson #include <rte_memcpy.h> 11a9de470cSBruce Richardson #include <rte_dev.h> 12*3c60274cSJie Zhou 13*3c60274cSJie Zhou #ifdef RTE_EXEC_ENV_WINDOWS 14*3c60274cSJie Zhou static int test_rawdev_selftests(void)15*3c60274cSJie Zhoutest_rawdev_selftests(void) 16*3c60274cSJie Zhou { 17*3c60274cSJie Zhou printf("rawdev not supported on Windows, skipping test\n"); 18*3c60274cSJie Zhou return TEST_SKIPPED; 19*3c60274cSJie Zhou } 20*3c60274cSJie Zhou #else 21*3c60274cSJie Zhou 22a9de470cSBruce Richardson #include <rte_rawdev.h> 23a9de470cSBruce Richardson #include <rte_bus_vdev.h> 24a9de470cSBruce Richardson 25a9de470cSBruce Richardson static int test_rawdev_selftest_impl(const char * pmd,const char * opts)26a9de470cSBruce Richardsontest_rawdev_selftest_impl(const char *pmd, const char *opts) 27a9de470cSBruce Richardson { 2839f7b298SBruce Richardson int ret; 2939f7b298SBruce Richardson 3039f7b298SBruce Richardson printf("\n### Test rawdev infrastructure using skeleton driver\n"); 31a9de470cSBruce Richardson rte_vdev_init(pmd, opts); 3239f7b298SBruce Richardson ret = rte_rawdev_selftest(rte_rawdev_get_dev_id(pmd)); 3339f7b298SBruce Richardson rte_vdev_uninit(pmd); 3439f7b298SBruce Richardson return ret; 35a9de470cSBruce Richardson } 36a9de470cSBruce Richardson 37a9de470cSBruce Richardson static int test_rawdev_selftest_skeleton(void)38a9de470cSBruce Richardsontest_rawdev_selftest_skeleton(void) 39a9de470cSBruce Richardson { 40a9de470cSBruce Richardson return test_rawdev_selftest_impl("rawdev_skeleton", ""); 41a9de470cSBruce Richardson } 42a9de470cSBruce Richardson 4339f7b298SBruce Richardson static int test_rawdev_selftests(void)4439f7b298SBruce Richardsontest_rawdev_selftests(void) 4539f7b298SBruce Richardson { 4639f7b298SBruce Richardson const int count = rte_rawdev_count(); 4739f7b298SBruce Richardson int ret = 0; 4839f7b298SBruce Richardson int i; 4939f7b298SBruce Richardson 5039f7b298SBruce Richardson /* basic sanity on rawdev infrastructure */ 5139f7b298SBruce Richardson if (test_rawdev_selftest_skeleton() < 0) 5239f7b298SBruce Richardson return -1; 5339f7b298SBruce Richardson 5439f7b298SBruce Richardson /* now run self-test on all rawdevs */ 5539f7b298SBruce Richardson if (count > 0) 5639f7b298SBruce Richardson printf("\n### Run selftest on each available rawdev\n"); 5739f7b298SBruce Richardson for (i = 0; i < count; i++) { 5839f7b298SBruce Richardson int result = rte_rawdev_selftest(i); 5939f7b298SBruce Richardson printf("Rawdev %u (%s) selftest: %s\n", i, 6039f7b298SBruce Richardson rte_rawdevs[i].name, 6139f7b298SBruce Richardson result == 0 ? "Passed" : "Failed"); 6239f7b298SBruce Richardson ret |= result; 6339f7b298SBruce Richardson } 6439f7b298SBruce Richardson 6539f7b298SBruce Richardson return ret; 6639f7b298SBruce Richardson } 6739f7b298SBruce Richardson 68*3c60274cSJie Zhou #endif /* !RTE_EXEC_ENV_WINDOWS */ 69*3c60274cSJie Zhou 7039f7b298SBruce Richardson REGISTER_TEST_COMMAND(rawdev_autotest, test_rawdev_selftests); 71