1 #include "iscsi/task.h" 2 #include "iscsi/iscsi.h" 3 #include "iscsi/conn.h" 4 #include "iscsi/acceptor.h" 5 6 #include "spdk/env.h" 7 #include "spdk/event.h" 8 #include "spdk/sock.h" 9 10 #include "spdk_internal/log.h" 11 12 #include "scsi/scsi_internal.h" 13 14 SPDK_LOG_REGISTER_COMPONENT("iscsi", SPDK_LOG_ISCSI) 15 16 TAILQ_HEAD(, spdk_iscsi_pdu) g_write_pdu_list; 17 18 struct spdk_iscsi_task * 19 spdk_iscsi_task_get(struct spdk_iscsi_conn *conn, 20 struct spdk_iscsi_task *parent, 21 spdk_scsi_task_cpl cpl_fn) 22 { 23 struct spdk_iscsi_task *task; 24 25 task = calloc(1, sizeof(*task)); 26 27 return task; 28 } 29 30 void 31 spdk_scsi_task_put(struct spdk_scsi_task *task) 32 { 33 free(task); 34 } 35 36 void 37 spdk_put_pdu(struct spdk_iscsi_pdu *pdu) 38 { 39 if (!pdu) { 40 return; 41 } 42 43 pdu->ref--; 44 if (pdu->ref < 0) { 45 CU_FAIL("negative ref count"); 46 pdu->ref = 0; 47 } 48 49 if (pdu->ref == 0) { 50 if (pdu->data && !pdu->data_from_mempool) { 51 free(pdu->data); 52 } 53 free(pdu); 54 } 55 } 56 57 struct spdk_iscsi_pdu * 58 spdk_get_pdu(void) 59 { 60 struct spdk_iscsi_pdu *pdu; 61 62 pdu = malloc(sizeof(*pdu)); 63 if (!pdu) { 64 return NULL; 65 } 66 67 memset(pdu, 0, offsetof(struct spdk_iscsi_pdu, ahs)); 68 pdu->ref = 1; 69 70 return pdu; 71 } 72 73 void 74 spdk_scsi_task_process_null_lun(struct spdk_scsi_task *task) 75 { 76 } 77 78 void 79 spdk_scsi_dev_queue_task(struct spdk_scsi_dev *dev, 80 struct spdk_scsi_task *task) 81 { 82 } 83 84 struct spdk_scsi_port * 85 spdk_scsi_dev_find_port_by_id(struct spdk_scsi_dev *dev, uint64_t id) 86 { 87 return NULL; 88 } 89 90 void 91 spdk_scsi_dev_queue_mgmt_task(struct spdk_scsi_dev *dev, 92 struct spdk_scsi_task *task, 93 enum spdk_scsi_task_func func) 94 { 95 } 96 97 const char * 98 spdk_scsi_dev_get_name(const struct spdk_scsi_dev *dev) 99 { 100 if (dev != NULL) { 101 return dev->name; 102 } 103 104 return NULL; 105 } 106 107 void 108 spdk_iscsi_acceptor_start(struct spdk_iscsi_portal *p) 109 { 110 } 111 112 void 113 spdk_iscsi_acceptor_stop(struct spdk_iscsi_portal *p) 114 { 115 } 116 117 struct spdk_sock * 118 spdk_sock_listen(const char *ip, int port) 119 { 120 static int g_sock; 121 122 return (struct spdk_sock *)&g_sock; 123 } 124 125 int 126 spdk_sock_close(struct spdk_sock **sock) 127 { 128 *sock = NULL; 129 130 return 0; 131 } 132 133 static struct spdk_cpuset *g_app_core_mask; 134 135 struct spdk_cpuset * 136 spdk_app_get_core_mask(void) 137 { 138 int i; 139 if (!g_app_core_mask) { 140 g_app_core_mask = spdk_cpuset_alloc(); 141 for (i = 0; i < SPDK_CPUSET_SIZE; i++) { 142 spdk_cpuset_set_cpu(g_app_core_mask, i, true); 143 } 144 } 145 return g_app_core_mask; 146 } 147 148 int 149 spdk_app_parse_core_mask(const char *mask, struct spdk_cpuset *cpumask) 150 { 151 int rc; 152 153 if (mask == NULL || cpumask == NULL) { 154 return -1; 155 } 156 157 rc = spdk_cpuset_parse(cpumask, mask); 158 if (rc < 0) { 159 return -1; 160 } 161 return 0; 162 } 163 164 uint32_t 165 spdk_env_get_current_core(void) 166 { 167 return 0; 168 } 169 170 struct spdk_event * 171 spdk_event_allocate(uint32_t core, spdk_event_fn fn, void *arg1, void *arg2) 172 { 173 return NULL; 174 } 175 176 struct spdk_scsi_dev * 177 spdk_scsi_dev_construct(const char *name, const char **bdev_name_list, 178 int *lun_id_list, int num_luns, uint8_t protocol_id, 179 void (*hotremove_cb)(const struct spdk_scsi_lun *, void *), 180 void *hotremove_ctx) 181 { 182 return NULL; 183 } 184 185 void 186 spdk_scsi_dev_destruct(struct spdk_scsi_dev *dev) 187 { 188 } 189 190 int 191 spdk_scsi_dev_add_port(struct spdk_scsi_dev *dev, uint64_t id, const char *name) 192 { 193 return 0; 194 } 195 196 int 197 spdk_iscsi_drop_conns(struct spdk_iscsi_conn *conn, const char *conn_match, 198 int drop_all) 199 { 200 return 0; 201 } 202 203 int 204 spdk_scsi_dev_delete_port(struct spdk_scsi_dev *dev, uint64_t id) 205 { 206 return 0; 207 } 208 209 void 210 spdk_shutdown_iscsi_conns(void) 211 { 212 } 213 214 void 215 spdk_iscsi_task_cpl(struct spdk_scsi_task *scsi_task) 216 { 217 218 } 219 220 void 221 spdk_iscsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task) 222 { 223 224 } 225 226 int 227 spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int bytes, 228 void *buf) 229 { 230 return 0; 231 } 232 233 void 234 spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) 235 { 236 TAILQ_INSERT_TAIL(&g_write_pdu_list, pdu, tailq); 237 } 238 239 void 240 spdk_iscsi_conn_logout(struct spdk_iscsi_conn *conn) 241 { 242 } 243 244 void 245 spdk_scsi_task_set_status(struct spdk_scsi_task *task, int sc, int sk, int asc, int ascq) 246 { 247 } 248 249 void 250 spdk_scsi_task_set_data(struct spdk_scsi_task *task, void *data, uint32_t len) 251 { 252 task->iovs[0].iov_base = data; 253 task->iovs[0].iov_len = len; 254 } 255