Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright (C) 2015 Intel Corporation. 3 : : * All rights reserved. 4 : : */ 5 : : 6 : : #include "spdk_internal/cunit.h" 7 : : 8 : : #include "ioat/ioat.c" 9 : : 10 : : #include "spdk_internal/mock.h" 11 : : 12 : : #include "common/lib/test_env.c" 13 : : 14 : : int 15 : 0 : spdk_pci_enumerate(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx) 16 : : { 17 : 0 : return -1; 18 : : } 19 : : 20 : : int 21 : 0 : spdk_pci_device_map_bar(struct spdk_pci_device *dev, uint32_t bar, 22 : : void **mapped_addr, uint64_t *phys_addr, uint64_t *size) 23 : : { 24 : 0 : *mapped_addr = NULL; 25 : 0 : *phys_addr = 0; 26 : 0 : *size = 0; 27 : 0 : return 0; 28 : : } 29 : : 30 : : int 31 : 0 : spdk_pci_device_unmap_bar(struct spdk_pci_device *dev, uint32_t bar, void *addr) 32 : : { 33 : 0 : return 0; 34 : : } 35 : : 36 : : int 37 : 0 : spdk_pci_device_cfg_read32(struct spdk_pci_device *dev, uint32_t *value, 38 : : uint32_t offset) 39 : : { 40 : 0 : *value = 0xFFFFFFFFu; 41 : 0 : return 0; 42 : : } 43 : : 44 : : int 45 : 0 : spdk_pci_device_cfg_write32(struct spdk_pci_device *dev, uint32_t value, 46 : : uint32_t offset) 47 : : { 48 : 0 : return 0; 49 : : } 50 : : 51 : : static void 52 : 3 : ioat_state_check(void) 53 : : { 54 : : /* 55 : : * CHANSTS's STATUS field is 3 bits (8 possible values), but only has 5 valid states: 56 : : * ACTIVE 0x0 57 : : * IDLE 0x1 58 : : * SUSPENDED 0x2 59 : : * HALTED 0x3 60 : : * ARMED 0x4 61 : : */ 62 : : 63 : 3 : CU_ASSERT(is_ioat_active(0) == 1); /* ACTIVE */ 64 : 3 : CU_ASSERT(is_ioat_active(1) == 0); /* IDLE */ 65 : 3 : CU_ASSERT(is_ioat_active(2) == 0); /* SUSPENDED */ 66 : 3 : CU_ASSERT(is_ioat_active(3) == 0); /* HALTED */ 67 : 3 : CU_ASSERT(is_ioat_active(4) == 0); /* ARMED */ 68 : 3 : CU_ASSERT(is_ioat_active(5) == 0); /* reserved */ 69 : 3 : CU_ASSERT(is_ioat_active(6) == 0); /* reserved */ 70 : 3 : CU_ASSERT(is_ioat_active(7) == 0); /* reserved */ 71 : : 72 : 3 : CU_ASSERT(is_ioat_idle(0) == 0); /* ACTIVE */ 73 : 3 : CU_ASSERT(is_ioat_idle(1) == 1); /* IDLE */ 74 : 3 : CU_ASSERT(is_ioat_idle(2) == 0); /* SUSPENDED */ 75 : 3 : CU_ASSERT(is_ioat_idle(3) == 0); /* HALTED */ 76 : 3 : CU_ASSERT(is_ioat_idle(4) == 0); /* ARMED */ 77 : 3 : CU_ASSERT(is_ioat_idle(5) == 0); /* reserved */ 78 : 3 : CU_ASSERT(is_ioat_idle(6) == 0); /* reserved */ 79 : 3 : CU_ASSERT(is_ioat_idle(7) == 0); /* reserved */ 80 : : 81 : 3 : CU_ASSERT(is_ioat_suspended(0) == 0); /* ACTIVE */ 82 : 3 : CU_ASSERT(is_ioat_suspended(1) == 0); /* IDLE */ 83 : 3 : CU_ASSERT(is_ioat_suspended(2) == 1); /* SUSPENDED */ 84 : 3 : CU_ASSERT(is_ioat_suspended(3) == 0); /* HALTED */ 85 : 3 : CU_ASSERT(is_ioat_suspended(4) == 0); /* ARMED */ 86 : 3 : CU_ASSERT(is_ioat_suspended(5) == 0); /* reserved */ 87 : 3 : CU_ASSERT(is_ioat_suspended(6) == 0); /* reserved */ 88 : 3 : CU_ASSERT(is_ioat_suspended(7) == 0); /* reserved */ 89 : : 90 : 3 : CU_ASSERT(is_ioat_halted(0) == 0); /* ACTIVE */ 91 : 3 : CU_ASSERT(is_ioat_halted(1) == 0); /* IDLE */ 92 : 3 : CU_ASSERT(is_ioat_halted(2) == 0); /* SUSPENDED */ 93 : 3 : CU_ASSERT(is_ioat_halted(3) == 1); /* HALTED */ 94 : 3 : CU_ASSERT(is_ioat_halted(4) == 0); /* ARMED */ 95 : 3 : CU_ASSERT(is_ioat_halted(5) == 0); /* reserved */ 96 : 3 : CU_ASSERT(is_ioat_halted(6) == 0); /* reserved */ 97 : 3 : CU_ASSERT(is_ioat_halted(7) == 0); /* reserved */ 98 : 3 : } 99 : : 100 : : int 101 : 3 : main(int argc, char **argv) 102 : : { 103 : 3 : CU_pSuite suite = NULL; 104 : : unsigned int num_failures; 105 : : 106 : 3 : CU_initialize_registry(); 107 : : 108 : 3 : suite = CU_add_suite("ioat", NULL, NULL); 109 : : 110 : 3 : CU_ADD_TEST(suite, ioat_state_check); 111 : : 112 : 3 : num_failures = spdk_ut_run_tests(argc, argv, NULL); 113 : 3 : CU_cleanup_registry(); 114 : 3 : return num_failures; 115 : : }