]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/unit/lib/ioat/ioat.c/ioat_ut.c
4 * Copyright (c) Intel Corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "spdk_cunit.h"
36 #include "ioat/ioat.c"
38 #include "spdk_internal/mock.h"
40 #include "common/lib/test_env.c"
43 spdk_pci_ioat_enumerate(spdk_pci_enum_cb enum_cb
, void *enum_ctx
)
49 spdk_pci_device_map_bar(struct spdk_pci_device
*dev
, uint32_t bar
,
50 void **mapped_addr
, uint64_t *phys_addr
, uint64_t *size
)
59 spdk_pci_device_unmap_bar(struct spdk_pci_device
*dev
, uint32_t bar
, void *addr
)
65 spdk_pci_device_cfg_read32(struct spdk_pci_device
*dev
, uint32_t *value
,
73 spdk_pci_device_cfg_write32(struct spdk_pci_device
*dev
, uint32_t value
,
79 static void ioat_state_check(void)
82 * CHANSTS's STATUS field is 3 bits (8 possible values), but only has 5 valid states:
90 CU_ASSERT(is_ioat_active(0) == 1); /* ACTIVE */
91 CU_ASSERT(is_ioat_active(1) == 0); /* IDLE */
92 CU_ASSERT(is_ioat_active(2) == 0); /* SUSPENDED */
93 CU_ASSERT(is_ioat_active(3) == 0); /* HALTED */
94 CU_ASSERT(is_ioat_active(4) == 0); /* ARMED */
95 CU_ASSERT(is_ioat_active(5) == 0); /* reserved */
96 CU_ASSERT(is_ioat_active(6) == 0); /* reserved */
97 CU_ASSERT(is_ioat_active(7) == 0); /* reserved */
99 CU_ASSERT(is_ioat_idle(0) == 0); /* ACTIVE */
100 CU_ASSERT(is_ioat_idle(1) == 1); /* IDLE */
101 CU_ASSERT(is_ioat_idle(2) == 0); /* SUSPENDED */
102 CU_ASSERT(is_ioat_idle(3) == 0); /* HALTED */
103 CU_ASSERT(is_ioat_idle(4) == 0); /* ARMED */
104 CU_ASSERT(is_ioat_idle(5) == 0); /* reserved */
105 CU_ASSERT(is_ioat_idle(6) == 0); /* reserved */
106 CU_ASSERT(is_ioat_idle(7) == 0); /* reserved */
108 CU_ASSERT(is_ioat_suspended(0) == 0); /* ACTIVE */
109 CU_ASSERT(is_ioat_suspended(1) == 0); /* IDLE */
110 CU_ASSERT(is_ioat_suspended(2) == 1); /* SUSPENDED */
111 CU_ASSERT(is_ioat_suspended(3) == 0); /* HALTED */
112 CU_ASSERT(is_ioat_suspended(4) == 0); /* ARMED */
113 CU_ASSERT(is_ioat_suspended(5) == 0); /* reserved */
114 CU_ASSERT(is_ioat_suspended(6) == 0); /* reserved */
115 CU_ASSERT(is_ioat_suspended(7) == 0); /* reserved */
117 CU_ASSERT(is_ioat_halted(0) == 0); /* ACTIVE */
118 CU_ASSERT(is_ioat_halted(1) == 0); /* IDLE */
119 CU_ASSERT(is_ioat_halted(2) == 0); /* SUSPENDED */
120 CU_ASSERT(is_ioat_halted(3) == 1); /* HALTED */
121 CU_ASSERT(is_ioat_halted(4) == 0); /* ARMED */
122 CU_ASSERT(is_ioat_halted(5) == 0); /* reserved */
123 CU_ASSERT(is_ioat_halted(6) == 0); /* reserved */
124 CU_ASSERT(is_ioat_halted(7) == 0); /* reserved */
127 int main(int argc
, char **argv
)
129 CU_pSuite suite
= NULL
;
130 unsigned int num_failures
;
132 if (CU_initialize_registry() != CUE_SUCCESS
) {
133 return CU_get_error();
136 suite
= CU_add_suite("ioat", NULL
, NULL
);
138 CU_cleanup_registry();
139 return CU_get_error();
143 CU_add_test(suite
, "ioat_state_check", ioat_state_check
) == NULL
) {
144 CU_cleanup_registry();
145 return CU_get_error();
148 CU_basic_set_mode(CU_BRM_VERBOSE
);
149 CU_basic_run_tests();
150 num_failures
= CU_get_number_of_failures();
151 CU_cleanup_registry();