]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/lib/nvme/unit/nvme_quirks_c/nvme_quirks_ut.c
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / spdk / test / lib / nvme / unit / nvme_quirks_c / nvme_quirks_ut.c
1 /*-
2 * BSD LICENSE
3 *
4 * Copyright (c) Intel Corporation.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
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
16 * distribution.
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.
20 *
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.
32 */
33
34 #include "spdk_cunit.h"
35
36 #include "nvme/nvme_quirks.c"
37
38 static void
39 test_nvme_quirks_striping(void)
40 {
41 struct spdk_pci_id pci_id = {};
42 uint64_t quirks = 0;
43
44 /* Non-Intel device should not have striping enabled */
45 quirks = nvme_get_quirks(&pci_id);
46 CU_ASSERT((quirks & NVME_INTEL_QUIRK_STRIPING) == 0);
47
48 /* Set the vendor id to Intel, but no device id. No striping. */
49 pci_id.vendor_id = SPDK_PCI_VID_INTEL;
50 quirks = nvme_get_quirks(&pci_id);
51 CU_ASSERT((quirks & NVME_INTEL_QUIRK_STRIPING) == 0);
52
53 /* Device ID 0x0953 should have striping enabled */
54 pci_id.device_id = 0x0953;
55 quirks = nvme_get_quirks(&pci_id);
56 CU_ASSERT((quirks & NVME_INTEL_QUIRK_STRIPING) != 0);
57
58 /* Even if specific subvendor/subdevice ids are set,
59 * striping should be enabled.
60 */
61 pci_id.subvendor_id = SPDK_PCI_VID_INTEL;
62 pci_id.subdevice_id = 0x3704;
63 quirks = nvme_get_quirks(&pci_id);
64 CU_ASSERT((quirks & NVME_INTEL_QUIRK_STRIPING) != 0);
65
66 pci_id.subvendor_id = 1234;
67 pci_id.subdevice_id = 42;
68 quirks = nvme_get_quirks(&pci_id);
69 CU_ASSERT((quirks & NVME_INTEL_QUIRK_STRIPING) != 0);
70 }
71
72 int main(int argc, char **argv)
73 {
74 CU_pSuite suite = NULL;
75 unsigned int num_failures;
76
77 if (CU_initialize_registry() != CUE_SUCCESS) {
78 return CU_get_error();
79 }
80
81 suite = CU_add_suite("nvme_quirks", NULL, NULL);
82 if (suite == NULL) {
83 CU_cleanup_registry();
84 return CU_get_error();
85 }
86
87 if (
88 CU_add_test(suite, "test nvme_quirks striping",
89 test_nvme_quirks_striping) == NULL
90 ) {
91 CU_cleanup_registry();
92 return CU_get_error();
93 }
94
95 CU_basic_set_mode(CU_BRM_VERBOSE);
96 CU_basic_run_tests();
97 num_failures = CU_get_number_of_failures();
98 CU_cleanup_registry();
99 return num_failures;
100 }