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 #include "common/lib/test_env.c" 34 35 const char * 36 spdk_nvme_transport_id_trtype_str(enum spdk_nvme_transport_type trtype) 37 { 38 switch (trtype) { 39 case SPDK_NVME_TRANSPORT_PCIE: 40 return "PCIe"; 41 case SPDK_NVME_TRANSPORT_RDMA: 42 return "RDMA"; 43 case SPDK_NVME_TRANSPORT_FC: 44 return "FC"; 45 default: 46 return NULL; 47 } 48 } 49 50 int 51 spdk_nvme_transport_id_populate_trstring(struct spdk_nvme_transport_id *trid, const char *trstring) 52 { 53 int len, i; 54 55 if (trstring == NULL) { 56 return -EINVAL; 57 } 58 59 len = strnlen(trstring, SPDK_NVMF_TRSTRING_MAX_LEN); 60 if (len == SPDK_NVMF_TRSTRING_MAX_LEN) { 61 return -EINVAL; 62 } 63 64 /* cast official trstring to uppercase version of input. */ 65 for (i = 0; i < len; i++) { 66 trid->trstring[i] = toupper(trstring[i]); 67 } 68 return 0; 69 } 70 71 DEFINE_STUB(nvme_request_check_timeout, int, (struct nvme_request *req, uint16_t cid, 72 struct spdk_nvme_ctrlr_process *active_proc, uint64_t now_tick), 0); 73 DEFINE_STUB_V(nvme_ctrlr_destruct_finish, (struct spdk_nvme_ctrlr *ctrlr)); 74 DEFINE_STUB(nvme_ctrlr_construct, int, (struct spdk_nvme_ctrlr *ctrlr), 0); 75 DEFINE_STUB_V(nvme_ctrlr_destruct, (struct spdk_nvme_ctrlr *ctrlr)); 76 DEFINE_STUB(nvme_ctrlr_get_vs, int, (struct spdk_nvme_ctrlr *ctrlr, 77 union spdk_nvme_vs_register *vs), 0); 78 DEFINE_STUB(nvme_ctrlr_get_cap, int, (struct spdk_nvme_ctrlr *ctrlr, 79 union spdk_nvme_cap_register *cap), 0); 80 DEFINE_STUB_V(nvme_qpair_deinit, (struct spdk_nvme_qpair *qpair)); 81 DEFINE_STUB_V(spdk_nvme_transport_register, (const struct spdk_nvme_transport_ops *ops)); 82 DEFINE_STUB(nvme_transport_ctrlr_connect_qpair, int, (struct spdk_nvme_ctrlr *ctrlr, 83 struct spdk_nvme_qpair *qpair), 0); 84 DEFINE_STUB(nvme_ctrlr_get_current_process, struct spdk_nvme_ctrlr_process *, 85 (struct spdk_nvme_ctrlr *ctrlr), (struct spdk_nvme_ctrlr_process *)(uintptr_t)0x1); 86 DEFINE_STUB(nvme_ctrlr_add_process, int, (struct spdk_nvme_ctrlr *ctrlr, void *devhandle), 0); 87 DEFINE_STUB_V(spdk_nvme_trid_populate_transport, (struct spdk_nvme_transport_id *trid, 88 enum spdk_nvme_transport_type trtype)); 89 DEFINE_STUB(nvme_get_transport, const struct spdk_nvme_transport *, (const char *transport_name), 90 NULL); 91 DEFINE_STUB(spdk_nvme_qpair_process_completions, int32_t, (struct spdk_nvme_qpair *qpair, 92 uint32_t max_completions), 0); 93 94 /* Fabric transports only */ 95 DEFINE_STUB_V(nvme_ctrlr_disconnect_qpair, (struct spdk_nvme_qpair *qpair)); 96 DEFINE_STUB(nvme_fabric_ctrlr_set_reg_4, int, (struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, 97 uint32_t value), 0); 98 DEFINE_STUB(nvme_fabric_ctrlr_set_reg_8, int, (struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, 99 uint64_t value), 0); 100 DEFINE_STUB(nvme_fabric_ctrlr_get_reg_4, int, (struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, 101 uint32_t *value), 0); 102 DEFINE_STUB(nvme_fabric_ctrlr_get_reg_8, int, (struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, 103 uint64_t *value), 0); 104 DEFINE_STUB(nvme_fabric_ctrlr_set_reg_4_async, int, (struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, 105 uint32_t value, spdk_nvme_reg_cb cb, void *ctx), 0); 106 DEFINE_STUB(nvme_fabric_ctrlr_set_reg_8_async, int, (struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, 107 uint64_t value, spdk_nvme_reg_cb cb, void *ctx), 0); 108 DEFINE_STUB(nvme_fabric_ctrlr_get_reg_4_async, int, (struct spdk_nvme_ctrlr *ctrlr, 109 uint32_t offset, spdk_nvme_reg_cb cb, void *ctx), 0); 110 DEFINE_STUB(nvme_fabric_ctrlr_get_reg_8_async, int, (struct spdk_nvme_ctrlr *ctrlr, 111 uint32_t offset, spdk_nvme_reg_cb cb, void *ctx), 0); 112 DEFINE_STUB(nvme_fabric_ctrlr_scan, int, (struct spdk_nvme_probe_ctx *probe_ctx, 113 bool direct_connect), 0); 114 DEFINE_STUB(nvme_fabric_qpair_connect, int, (struct spdk_nvme_qpair *qpair, uint32_t num_entries), 115 0); 116 DEFINE_STUB(nvme_fabric_qpair_connect_async, int, (struct spdk_nvme_qpair *qpair, 117 uint32_t num_entries), 0); 118 DEFINE_STUB(nvme_fabric_qpair_connect_poll, int, (struct spdk_nvme_qpair *qpair), 0); 119 DEFINE_STUB_V(nvme_transport_ctrlr_disconnect_qpair, (struct spdk_nvme_ctrlr *ctrlr, 120 struct spdk_nvme_qpair *qpair)); 121 DEFINE_STUB(nvme_poll_group_disconnect_qpair, int, (struct spdk_nvme_qpair *qpair), 0); 122 123 int 124 nvme_qpair_init(struct spdk_nvme_qpair *qpair, uint16_t id, 125 struct spdk_nvme_ctrlr *ctrlr, 126 enum spdk_nvme_qprio qprio, 127 uint32_t num_requests, bool async) 128 { 129 qpair->ctrlr = ctrlr; 130 qpair->id = id; 131 qpair->qprio = qprio; 132 qpair->async = async; 133 qpair->trtype = SPDK_NVME_TRANSPORT_TCP; 134 qpair->poll_group = (void *)0xDEADBEEF; 135 136 return 0; 137 } 138