Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * This file contains the Linux/SCSI LLD virtual SCSI initiator driver |
| 4 | * for emulated SAS initiator ports |
| 5 | * |
| 6 | * © Copyright 2011 RisingTide Systems LLC. |
| 7 | * |
| 8 | * Licensed to the Linux Foundation under the General Public License (GPL) version 2. |
| 9 | * |
| 10 | * Author: Nicholas A. Bellinger <nab@risingtidesystems.com> |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | ****************************************************************************/ |
| 22 | |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/moduleparam.h> |
| 25 | #include <linux/init.h> |
| 26 | #include <linux/slab.h> |
| 27 | #include <linux/types.h> |
| 28 | #include <linux/configfs.h> |
| 29 | #include <scsi/scsi.h> |
| 30 | #include <scsi/scsi_tcq.h> |
| 31 | #include <scsi/scsi_host.h> |
| 32 | #include <scsi/scsi_device.h> |
| 33 | #include <scsi/scsi_cmnd.h> |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 34 | |
| 35 | #include <target/target_core_base.h> |
Christoph Hellwig | c4795fb | 2011-11-16 09:46:48 -0500 | [diff] [blame] | 36 | #include <target/target_core_fabric.h> |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 37 | #include <target/target_core_fabric_configfs.h> |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 38 | #include <target/target_core_configfs.h> |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 39 | |
| 40 | #include "tcm_loop.h" |
| 41 | |
| 42 | #define to_tcm_loop_hba(hba) container_of(hba, struct tcm_loop_hba, dev) |
| 43 | |
| 44 | /* Local pointer to allocated TCM configfs fabric module */ |
| 45 | static struct target_fabric_configfs *tcm_loop_fabric_configfs; |
| 46 | |
Christoph Hellwig | afe2cb7 | 2012-02-02 17:04:41 -0500 | [diff] [blame^] | 47 | static struct workqueue_struct *tcm_loop_workqueue; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 48 | static struct kmem_cache *tcm_loop_cmd_cache; |
| 49 | |
| 50 | static int tcm_loop_hba_no_cnt; |
| 51 | |
| 52 | /* |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 53 | * Called by struct target_core_fabric_ops->new_cmd_map() |
| 54 | * |
| 55 | * Always called in process context. A non zero return value |
| 56 | * here will signal to handle an exception based on the return code. |
| 57 | */ |
| 58 | static int tcm_loop_new_cmd_map(struct se_cmd *se_cmd) |
| 59 | { |
| 60 | struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, |
| 61 | struct tcm_loop_cmd, tl_se_cmd); |
| 62 | struct scsi_cmnd *sc = tl_cmd->sc; |
Andy Grover | 5951146d | 2011-07-19 10:26:37 +0000 | [diff] [blame] | 63 | struct scatterlist *sgl_bidi = NULL; |
| 64 | u32 sgl_bidi_count = 0; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 65 | int ret; |
| 66 | /* |
| 67 | * Allocate the necessary tasks to complete the received CDB+data |
| 68 | */ |
Andy Grover | 5951146d | 2011-07-19 10:26:37 +0000 | [diff] [blame] | 69 | ret = transport_generic_allocate_tasks(se_cmd, sc->cmnd); |
Nicholas Bellinger | 03e98c9 | 2011-11-04 02:36:16 -0700 | [diff] [blame] | 70 | if (ret != 0) |
| 71 | return ret; |
Andy Grover | 5951146d | 2011-07-19 10:26:37 +0000 | [diff] [blame] | 72 | /* |
| 73 | * For BIDI commands, pass in the extra READ buffer |
| 74 | * to transport_generic_map_mem_to_cmd() below.. |
| 75 | */ |
Christoph Hellwig | 33c3faf | 2011-11-14 11:36:30 -0500 | [diff] [blame] | 76 | if (se_cmd->se_cmd_flags & SCF_BIDI) { |
Andy Grover | 5951146d | 2011-07-19 10:26:37 +0000 | [diff] [blame] | 77 | struct scsi_data_buffer *sdb = scsi_in(sc); |
| 78 | |
| 79 | sgl_bidi = sdb->table.sgl; |
| 80 | sgl_bidi_count = sdb->table.nents; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 81 | } |
Nicholas Bellinger | 8cd79f2 | 2011-10-24 13:35:37 -0700 | [diff] [blame] | 82 | /* |
| 83 | * Because some userspace code via scsi-generic do not memset their |
| 84 | * associated read buffers, go ahead and do that here for type |
| 85 | * SCF_SCSI_CONTROL_SG_IO_CDB. Also note that this is currently |
| 86 | * guaranteed to be a single SGL for SCF_SCSI_CONTROL_SG_IO_CDB |
| 87 | * by target core in transport_generic_allocate_tasks() -> |
| 88 | * transport_generic_cmd_sequencer(). |
| 89 | */ |
| 90 | if (se_cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB && |
| 91 | se_cmd->data_direction == DMA_FROM_DEVICE) { |
| 92 | struct scatterlist *sg = scsi_sglist(sc); |
| 93 | unsigned char *buf = kmap(sg_page(sg)) + sg->offset; |
| 94 | |
| 95 | if (buf != NULL) { |
| 96 | memset(buf, 0, sg->length); |
| 97 | kunmap(sg_page(sg)); |
| 98 | } |
| 99 | } |
Andy Grover | 5951146d | 2011-07-19 10:26:37 +0000 | [diff] [blame] | 100 | |
Andy Grover | ec98f78 | 2011-07-20 19:28:46 +0000 | [diff] [blame] | 101 | /* Tell the core about our preallocated memory */ |
Nicholas Bellinger | 03e98c9 | 2011-11-04 02:36:16 -0700 | [diff] [blame] | 102 | return transport_generic_map_mem_to_cmd(se_cmd, scsi_sglist(sc), |
Andy Grover | 5951146d | 2011-07-19 10:26:37 +0000 | [diff] [blame] | 103 | scsi_sg_count(sc), sgl_bidi, sgl_bidi_count); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | /* |
| 107 | * Called from struct target_core_fabric_ops->check_stop_free() |
| 108 | */ |
Nicholas Bellinger | 88dd9e2 | 2011-11-02 03:33:16 -0700 | [diff] [blame] | 109 | static int tcm_loop_check_stop_free(struct se_cmd *se_cmd) |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 110 | { |
| 111 | /* |
| 112 | * Do not release struct se_cmd's containing a valid TMR |
| 113 | * pointer. These will be released directly in tcm_loop_device_reset() |
| 114 | * with transport_generic_free_cmd(). |
| 115 | */ |
Andy Grover | c8e31f2 | 2012-01-19 13:39:17 -0800 | [diff] [blame] | 116 | if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) |
Nicholas Bellinger | 88dd9e2 | 2011-11-02 03:33:16 -0700 | [diff] [blame] | 117 | return 0; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 118 | /* |
| 119 | * Release the struct se_cmd, which will make a callback to release |
| 120 | * struct tcm_loop_cmd * in tcm_loop_deallocate_core_cmd() |
| 121 | */ |
Christoph Hellwig | 82f1c8a | 2011-09-13 23:09:01 +0200 | [diff] [blame] | 122 | transport_generic_free_cmd(se_cmd, 0); |
Nicholas Bellinger | 88dd9e2 | 2011-11-02 03:33:16 -0700 | [diff] [blame] | 123 | return 1; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 124 | } |
| 125 | |
Christoph Hellwig | 3546297 | 2011-05-31 23:56:57 -0400 | [diff] [blame] | 126 | static void tcm_loop_release_cmd(struct se_cmd *se_cmd) |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 127 | { |
| 128 | struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, |
| 129 | struct tcm_loop_cmd, tl_se_cmd); |
| 130 | |
| 131 | kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); |
| 132 | } |
| 133 | |
| 134 | static int tcm_loop_proc_info(struct Scsi_Host *host, char *buffer, |
| 135 | char **start, off_t offset, |
| 136 | int length, int inout) |
| 137 | { |
| 138 | return sprintf(buffer, "tcm_loop_proc_info()\n"); |
| 139 | } |
| 140 | |
| 141 | static int tcm_loop_driver_probe(struct device *); |
| 142 | static int tcm_loop_driver_remove(struct device *); |
| 143 | |
| 144 | static int pseudo_lld_bus_match(struct device *dev, |
| 145 | struct device_driver *dev_driver) |
| 146 | { |
| 147 | return 1; |
| 148 | } |
| 149 | |
| 150 | static struct bus_type tcm_loop_lld_bus = { |
| 151 | .name = "tcm_loop_bus", |
| 152 | .match = pseudo_lld_bus_match, |
| 153 | .probe = tcm_loop_driver_probe, |
| 154 | .remove = tcm_loop_driver_remove, |
| 155 | }; |
| 156 | |
| 157 | static struct device_driver tcm_loop_driverfs = { |
| 158 | .name = "tcm_loop", |
| 159 | .bus = &tcm_loop_lld_bus, |
| 160 | }; |
| 161 | /* |
| 162 | * Used with root_device_register() in tcm_loop_alloc_core_bus() below |
| 163 | */ |
| 164 | struct device *tcm_loop_primary; |
| 165 | |
| 166 | /* |
| 167 | * Copied from drivers/scsi/libfc/fc_fcp.c:fc_change_queue_depth() and |
| 168 | * drivers/scsi/libiscsi.c:iscsi_change_queue_depth() |
| 169 | */ |
| 170 | static int tcm_loop_change_queue_depth( |
| 171 | struct scsi_device *sdev, |
| 172 | int depth, |
| 173 | int reason) |
| 174 | { |
| 175 | switch (reason) { |
| 176 | case SCSI_QDEPTH_DEFAULT: |
| 177 | scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth); |
| 178 | break; |
| 179 | case SCSI_QDEPTH_QFULL: |
| 180 | scsi_track_queue_full(sdev, depth); |
| 181 | break; |
| 182 | case SCSI_QDEPTH_RAMP_UP: |
| 183 | scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth); |
| 184 | break; |
| 185 | default: |
| 186 | return -EOPNOTSUPP; |
| 187 | } |
| 188 | return sdev->queue_depth; |
| 189 | } |
| 190 | |
| 191 | /* |
Christoph Hellwig | f872c9f | 2012-02-02 17:04:40 -0500 | [diff] [blame] | 192 | * Locate the SAM Task Attr from struct scsi_cmnd * |
| 193 | */ |
| 194 | static int tcm_loop_sam_attr(struct scsi_cmnd *sc) |
| 195 | { |
| 196 | if (sc->device->tagged_supported) { |
| 197 | switch (sc->tag) { |
| 198 | case HEAD_OF_QUEUE_TAG: |
| 199 | return MSG_HEAD_TAG; |
| 200 | case ORDERED_QUEUE_TAG: |
| 201 | return MSG_ORDERED_TAG; |
| 202 | default: |
| 203 | break; |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | return MSG_SIMPLE_TAG; |
| 208 | } |
| 209 | |
Christoph Hellwig | afe2cb7 | 2012-02-02 17:04:41 -0500 | [diff] [blame^] | 210 | static void tcm_loop_submission_work(struct work_struct *work) |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 211 | { |
Christoph Hellwig | afe2cb7 | 2012-02-02 17:04:41 -0500 | [diff] [blame^] | 212 | struct tcm_loop_cmd *tl_cmd = |
| 213 | container_of(work, struct tcm_loop_cmd, work); |
| 214 | struct se_cmd *se_cmd = &tl_cmd->tl_se_cmd; |
| 215 | struct scsi_cmnd *sc = tl_cmd->sc; |
| 216 | struct tcm_loop_nexus *tl_nexus; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 217 | struct tcm_loop_hba *tl_hba; |
| 218 | struct tcm_loop_tpg *tl_tpg; |
Christoph Hellwig | f872c9f | 2012-02-02 17:04:40 -0500 | [diff] [blame] | 219 | |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 220 | tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host); |
| 221 | tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id]; |
Christoph Hellwig | afe2cb7 | 2012-02-02 17:04:41 -0500 | [diff] [blame^] | 222 | |
Nicholas Bellinger | 0a02043 | 2011-10-10 19:44:05 -0700 | [diff] [blame] | 223 | /* |
| 224 | * Ensure that this tl_tpg reference from the incoming sc->device->id |
| 225 | * has already been configured via tcm_loop_make_naa_tpg(). |
| 226 | */ |
| 227 | if (!tl_tpg->tl_hba) { |
| 228 | set_host_byte(sc, DID_NO_CONNECT); |
Christoph Hellwig | f872c9f | 2012-02-02 17:04:40 -0500 | [diff] [blame] | 229 | goto out_done; |
Nicholas Bellinger | 0a02043 | 2011-10-10 19:44:05 -0700 | [diff] [blame] | 230 | } |
Christoph Hellwig | f872c9f | 2012-02-02 17:04:40 -0500 | [diff] [blame] | 231 | |
| 232 | tl_nexus = tl_hba->tl_nexus; |
| 233 | if (!tl_nexus) { |
| 234 | scmd_printk(KERN_ERR, sc, "TCM_Loop I_T Nexus" |
| 235 | " does not exist\n"); |
| 236 | set_host_byte(sc, DID_ERROR); |
| 237 | goto out_done; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 238 | } |
Christoph Hellwig | f872c9f | 2012-02-02 17:04:40 -0500 | [diff] [blame] | 239 | |
Christoph Hellwig | afe2cb7 | 2012-02-02 17:04:41 -0500 | [diff] [blame^] | 240 | transport_init_se_cmd(se_cmd, tl_tpg->tl_se_tpg.se_tpg_tfo, |
| 241 | tl_nexus->se_sess, |
Christoph Hellwig | f872c9f | 2012-02-02 17:04:40 -0500 | [diff] [blame] | 242 | scsi_bufflen(sc), sc->sc_data_direction, |
| 243 | tcm_loop_sam_attr(sc), &tl_cmd->tl_sense_buf[0]); |
| 244 | |
| 245 | if (scsi_bidi_cmnd(sc)) |
| 246 | se_cmd->se_cmd_flags |= SCF_BIDI; |
| 247 | |
| 248 | if (transport_lookup_cmd_lun(se_cmd, tl_cmd->sc->device->lun) < 0) { |
| 249 | kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); |
| 250 | set_host_byte(sc, DID_NO_CONNECT); |
| 251 | goto out_done; |
| 252 | } |
| 253 | |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 254 | transport_generic_handle_cdb_map(se_cmd); |
Christoph Hellwig | afe2cb7 | 2012-02-02 17:04:41 -0500 | [diff] [blame^] | 255 | return; |
Christoph Hellwig | f872c9f | 2012-02-02 17:04:40 -0500 | [diff] [blame] | 256 | |
| 257 | out_done: |
| 258 | sc->scsi_done(sc); |
Christoph Hellwig | afe2cb7 | 2012-02-02 17:04:41 -0500 | [diff] [blame^] | 259 | return; |
| 260 | } |
| 261 | |
| 262 | /* |
| 263 | * ->queuecommand can be and usually is called from interrupt context, so |
| 264 | * defer the actual submission to a workqueue. |
| 265 | */ |
| 266 | static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc) |
| 267 | { |
| 268 | struct tcm_loop_cmd *tl_cmd; |
| 269 | |
| 270 | pr_debug("tcm_loop_queuecommand() %d:%d:%d:%d got CDB: 0x%02x" |
| 271 | " scsi_buf_len: %u\n", sc->device->host->host_no, |
| 272 | sc->device->id, sc->device->channel, sc->device->lun, |
| 273 | sc->cmnd[0], scsi_bufflen(sc)); |
| 274 | |
| 275 | tl_cmd = kmem_cache_zalloc(tcm_loop_cmd_cache, GFP_ATOMIC); |
| 276 | if (!tl_cmd) { |
| 277 | pr_err("Unable to allocate struct tcm_loop_cmd\n"); |
| 278 | set_host_byte(sc, DID_ERROR); |
| 279 | sc->scsi_done(sc); |
| 280 | return 0; |
| 281 | } |
| 282 | |
| 283 | tl_cmd->sc = sc; |
| 284 | INIT_WORK(&tl_cmd->work, tcm_loop_submission_work); |
| 285 | queue_work(tcm_loop_workqueue, &tl_cmd->work); |
Christoph Hellwig | f872c9f | 2012-02-02 17:04:40 -0500 | [diff] [blame] | 286 | return 0; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | /* |
| 290 | * Called from SCSI EH process context to issue a LUN_RESET TMR |
| 291 | * to struct scsi_device |
| 292 | */ |
| 293 | static int tcm_loop_device_reset(struct scsi_cmnd *sc) |
| 294 | { |
| 295 | struct se_cmd *se_cmd = NULL; |
| 296 | struct se_portal_group *se_tpg; |
| 297 | struct se_session *se_sess; |
| 298 | struct tcm_loop_cmd *tl_cmd = NULL; |
| 299 | struct tcm_loop_hba *tl_hba; |
| 300 | struct tcm_loop_nexus *tl_nexus; |
| 301 | struct tcm_loop_tmr *tl_tmr = NULL; |
| 302 | struct tcm_loop_tpg *tl_tpg; |
Andy Grover | c8e31f2 | 2012-01-19 13:39:17 -0800 | [diff] [blame] | 303 | int ret = FAILED, rc; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 304 | /* |
| 305 | * Locate the tcm_loop_hba_t pointer |
| 306 | */ |
| 307 | tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host); |
| 308 | /* |
| 309 | * Locate the tl_nexus and se_sess pointers |
| 310 | */ |
| 311 | tl_nexus = tl_hba->tl_nexus; |
| 312 | if (!tl_nexus) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 313 | pr_err("Unable to perform device reset without" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 314 | " active I_T Nexus\n"); |
| 315 | return FAILED; |
| 316 | } |
| 317 | se_sess = tl_nexus->se_sess; |
| 318 | /* |
| 319 | * Locate the tl_tpg and se_tpg pointers from TargetID in sc->device->id |
| 320 | */ |
| 321 | tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id]; |
| 322 | se_tpg = &tl_tpg->tl_se_tpg; |
| 323 | |
| 324 | tl_cmd = kmem_cache_zalloc(tcm_loop_cmd_cache, GFP_KERNEL); |
| 325 | if (!tl_cmd) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 326 | pr_err("Unable to allocate memory for tl_cmd\n"); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 327 | return FAILED; |
| 328 | } |
| 329 | |
| 330 | tl_tmr = kzalloc(sizeof(struct tcm_loop_tmr), GFP_KERNEL); |
| 331 | if (!tl_tmr) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 332 | pr_err("Unable to allocate memory for tl_tmr\n"); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 333 | goto release; |
| 334 | } |
| 335 | init_waitqueue_head(&tl_tmr->tl_tmr_wait); |
| 336 | |
| 337 | se_cmd = &tl_cmd->tl_se_cmd; |
| 338 | /* |
| 339 | * Initialize struct se_cmd descriptor from target_core_mod infrastructure |
| 340 | */ |
| 341 | transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess, 0, |
Nicholas Bellinger | 61db180 | 2011-05-19 20:19:14 -0700 | [diff] [blame] | 342 | DMA_NONE, MSG_SIMPLE_TAG, |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 343 | &tl_cmd->tl_sense_buf[0]); |
Andy Grover | c8e31f2 | 2012-01-19 13:39:17 -0800 | [diff] [blame] | 344 | |
| 345 | rc = core_tmr_alloc_req(se_cmd, tl_tmr, TMR_LUN_RESET, GFP_KERNEL); |
| 346 | if (rc < 0) |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 347 | goto release; |
| 348 | /* |
| 349 | * Locate the underlying TCM struct se_lun from sc->device->lun |
| 350 | */ |
Andy Grover | 5951146d | 2011-07-19 10:26:37 +0000 | [diff] [blame] | 351 | if (transport_lookup_tmr_lun(se_cmd, sc->device->lun) < 0) |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 352 | goto release; |
| 353 | /* |
| 354 | * Queue the TMR to TCM Core and sleep waiting for tcm_loop_queue_tm_rsp() |
| 355 | * to wake us up. |
| 356 | */ |
| 357 | transport_generic_handle_tmr(se_cmd); |
| 358 | wait_event(tl_tmr->tl_tmr_wait, atomic_read(&tl_tmr->tmr_complete)); |
| 359 | /* |
| 360 | * The TMR LUN_RESET has completed, check the response status and |
| 361 | * then release allocations. |
| 362 | */ |
| 363 | ret = (se_cmd->se_tmr_req->response == TMR_FUNCTION_COMPLETE) ? |
| 364 | SUCCESS : FAILED; |
| 365 | release: |
| 366 | if (se_cmd) |
Christoph Hellwig | 82f1c8a | 2011-09-13 23:09:01 +0200 | [diff] [blame] | 367 | transport_generic_free_cmd(se_cmd, 1); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 368 | else |
| 369 | kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); |
| 370 | kfree(tl_tmr); |
| 371 | return ret; |
| 372 | } |
| 373 | |
| 374 | static int tcm_loop_slave_alloc(struct scsi_device *sd) |
| 375 | { |
| 376 | set_bit(QUEUE_FLAG_BIDI, &sd->request_queue->queue_flags); |
| 377 | return 0; |
| 378 | } |
| 379 | |
| 380 | static int tcm_loop_slave_configure(struct scsi_device *sd) |
| 381 | { |
| 382 | return 0; |
| 383 | } |
| 384 | |
| 385 | static struct scsi_host_template tcm_loop_driver_template = { |
| 386 | .proc_info = tcm_loop_proc_info, |
| 387 | .proc_name = "tcm_loopback", |
| 388 | .name = "TCM_Loopback", |
| 389 | .queuecommand = tcm_loop_queuecommand, |
| 390 | .change_queue_depth = tcm_loop_change_queue_depth, |
| 391 | .eh_device_reset_handler = tcm_loop_device_reset, |
Christoph Hellwig | 2e88efd | 2011-11-29 03:20:41 -0500 | [diff] [blame] | 392 | .can_queue = 1024, |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 393 | .this_id = -1, |
Christoph Hellwig | 2e88efd | 2011-11-29 03:20:41 -0500 | [diff] [blame] | 394 | .sg_tablesize = 256, |
| 395 | .cmd_per_lun = 1024, |
| 396 | .max_sectors = 0xFFFF, |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 397 | .use_clustering = DISABLE_CLUSTERING, |
| 398 | .slave_alloc = tcm_loop_slave_alloc, |
| 399 | .slave_configure = tcm_loop_slave_configure, |
| 400 | .module = THIS_MODULE, |
| 401 | }; |
| 402 | |
| 403 | static int tcm_loop_driver_probe(struct device *dev) |
| 404 | { |
| 405 | struct tcm_loop_hba *tl_hba; |
| 406 | struct Scsi_Host *sh; |
| 407 | int error; |
| 408 | |
| 409 | tl_hba = to_tcm_loop_hba(dev); |
| 410 | |
| 411 | sh = scsi_host_alloc(&tcm_loop_driver_template, |
| 412 | sizeof(struct tcm_loop_hba)); |
| 413 | if (!sh) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 414 | pr_err("Unable to allocate struct scsi_host\n"); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 415 | return -ENODEV; |
| 416 | } |
| 417 | tl_hba->sh = sh; |
| 418 | |
| 419 | /* |
| 420 | * Assign the struct tcm_loop_hba pointer to struct Scsi_Host->hostdata |
| 421 | */ |
| 422 | *((struct tcm_loop_hba **)sh->hostdata) = tl_hba; |
| 423 | /* |
| 424 | * Setup single ID, Channel and LUN for now.. |
| 425 | */ |
| 426 | sh->max_id = 2; |
| 427 | sh->max_lun = 0; |
| 428 | sh->max_channel = 0; |
| 429 | sh->max_cmd_len = TL_SCSI_MAX_CMD_LEN; |
| 430 | |
| 431 | error = scsi_add_host(sh, &tl_hba->dev); |
| 432 | if (error) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 433 | pr_err("%s: scsi_add_host failed\n", __func__); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 434 | scsi_host_put(sh); |
| 435 | return -ENODEV; |
| 436 | } |
| 437 | return 0; |
| 438 | } |
| 439 | |
| 440 | static int tcm_loop_driver_remove(struct device *dev) |
| 441 | { |
| 442 | struct tcm_loop_hba *tl_hba; |
| 443 | struct Scsi_Host *sh; |
| 444 | |
| 445 | tl_hba = to_tcm_loop_hba(dev); |
| 446 | sh = tl_hba->sh; |
| 447 | |
| 448 | scsi_remove_host(sh); |
| 449 | scsi_host_put(sh); |
| 450 | return 0; |
| 451 | } |
| 452 | |
| 453 | static void tcm_loop_release_adapter(struct device *dev) |
| 454 | { |
| 455 | struct tcm_loop_hba *tl_hba = to_tcm_loop_hba(dev); |
| 456 | |
| 457 | kfree(tl_hba); |
| 458 | } |
| 459 | |
| 460 | /* |
| 461 | * Called from tcm_loop_make_scsi_hba() in tcm_loop_configfs.c |
| 462 | */ |
| 463 | static int tcm_loop_setup_hba_bus(struct tcm_loop_hba *tl_hba, int tcm_loop_host_id) |
| 464 | { |
| 465 | int ret; |
| 466 | |
| 467 | tl_hba->dev.bus = &tcm_loop_lld_bus; |
| 468 | tl_hba->dev.parent = tcm_loop_primary; |
| 469 | tl_hba->dev.release = &tcm_loop_release_adapter; |
| 470 | dev_set_name(&tl_hba->dev, "tcm_loop_adapter_%d", tcm_loop_host_id); |
| 471 | |
| 472 | ret = device_register(&tl_hba->dev); |
| 473 | if (ret) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 474 | pr_err("device_register() failed for" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 475 | " tl_hba->dev: %d\n", ret); |
| 476 | return -ENODEV; |
| 477 | } |
| 478 | |
| 479 | return 0; |
| 480 | } |
| 481 | |
| 482 | /* |
| 483 | * Called from tcm_loop_fabric_init() in tcl_loop_fabric.c to load the emulated |
| 484 | * tcm_loop SCSI bus. |
| 485 | */ |
| 486 | static int tcm_loop_alloc_core_bus(void) |
| 487 | { |
| 488 | int ret; |
| 489 | |
| 490 | tcm_loop_primary = root_device_register("tcm_loop_0"); |
| 491 | if (IS_ERR(tcm_loop_primary)) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 492 | pr_err("Unable to allocate tcm_loop_primary\n"); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 493 | return PTR_ERR(tcm_loop_primary); |
| 494 | } |
| 495 | |
| 496 | ret = bus_register(&tcm_loop_lld_bus); |
| 497 | if (ret) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 498 | pr_err("bus_register() failed for tcm_loop_lld_bus\n"); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 499 | goto dev_unreg; |
| 500 | } |
| 501 | |
| 502 | ret = driver_register(&tcm_loop_driverfs); |
| 503 | if (ret) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 504 | pr_err("driver_register() failed for" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 505 | "tcm_loop_driverfs\n"); |
| 506 | goto bus_unreg; |
| 507 | } |
| 508 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 509 | pr_debug("Initialized TCM Loop Core Bus\n"); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 510 | return ret; |
| 511 | |
| 512 | bus_unreg: |
| 513 | bus_unregister(&tcm_loop_lld_bus); |
| 514 | dev_unreg: |
| 515 | root_device_unregister(tcm_loop_primary); |
| 516 | return ret; |
| 517 | } |
| 518 | |
| 519 | static void tcm_loop_release_core_bus(void) |
| 520 | { |
| 521 | driver_unregister(&tcm_loop_driverfs); |
| 522 | bus_unregister(&tcm_loop_lld_bus); |
| 523 | root_device_unregister(tcm_loop_primary); |
| 524 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 525 | pr_debug("Releasing TCM Loop Core BUS\n"); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | static char *tcm_loop_get_fabric_name(void) |
| 529 | { |
| 530 | return "loopback"; |
| 531 | } |
| 532 | |
| 533 | static u8 tcm_loop_get_fabric_proto_ident(struct se_portal_group *se_tpg) |
| 534 | { |
Jörn Engel | 8359cf4 | 2011-11-24 02:05:51 +0100 | [diff] [blame] | 535 | struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 536 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
| 537 | /* |
| 538 | * tl_proto_id is set at tcm_loop_configfs.c:tcm_loop_make_scsi_hba() |
| 539 | * time based on the protocol dependent prefix of the passed configfs group. |
| 540 | * |
| 541 | * Based upon tl_proto_id, TCM_Loop emulates the requested fabric |
| 542 | * ProtocolID using target_core_fabric_lib.c symbols. |
| 543 | */ |
| 544 | switch (tl_hba->tl_proto_id) { |
| 545 | case SCSI_PROTOCOL_SAS: |
| 546 | return sas_get_fabric_proto_ident(se_tpg); |
| 547 | case SCSI_PROTOCOL_FCP: |
| 548 | return fc_get_fabric_proto_ident(se_tpg); |
| 549 | case SCSI_PROTOCOL_ISCSI: |
| 550 | return iscsi_get_fabric_proto_ident(se_tpg); |
| 551 | default: |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 552 | pr_err("Unknown tl_proto_id: 0x%02x, using" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 553 | " SAS emulation\n", tl_hba->tl_proto_id); |
| 554 | break; |
| 555 | } |
| 556 | |
| 557 | return sas_get_fabric_proto_ident(se_tpg); |
| 558 | } |
| 559 | |
| 560 | static char *tcm_loop_get_endpoint_wwn(struct se_portal_group *se_tpg) |
| 561 | { |
Jörn Engel | 8359cf4 | 2011-11-24 02:05:51 +0100 | [diff] [blame] | 562 | struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 563 | /* |
| 564 | * Return the passed NAA identifier for the SAS Target Port |
| 565 | */ |
| 566 | return &tl_tpg->tl_hba->tl_wwn_address[0]; |
| 567 | } |
| 568 | |
| 569 | static u16 tcm_loop_get_tag(struct se_portal_group *se_tpg) |
| 570 | { |
Jörn Engel | 8359cf4 | 2011-11-24 02:05:51 +0100 | [diff] [blame] | 571 | struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 572 | /* |
| 573 | * This Tag is used when forming SCSI Name identifier in EVPD=1 0x83 |
| 574 | * to represent the SCSI Target Port. |
| 575 | */ |
| 576 | return tl_tpg->tl_tpgt; |
| 577 | } |
| 578 | |
| 579 | static u32 tcm_loop_get_default_depth(struct se_portal_group *se_tpg) |
| 580 | { |
| 581 | return 1; |
| 582 | } |
| 583 | |
| 584 | static u32 tcm_loop_get_pr_transport_id( |
| 585 | struct se_portal_group *se_tpg, |
| 586 | struct se_node_acl *se_nacl, |
| 587 | struct t10_pr_registration *pr_reg, |
| 588 | int *format_code, |
| 589 | unsigned char *buf) |
| 590 | { |
Jörn Engel | 8359cf4 | 2011-11-24 02:05:51 +0100 | [diff] [blame] | 591 | struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 592 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
| 593 | |
| 594 | switch (tl_hba->tl_proto_id) { |
| 595 | case SCSI_PROTOCOL_SAS: |
| 596 | return sas_get_pr_transport_id(se_tpg, se_nacl, pr_reg, |
| 597 | format_code, buf); |
| 598 | case SCSI_PROTOCOL_FCP: |
| 599 | return fc_get_pr_transport_id(se_tpg, se_nacl, pr_reg, |
| 600 | format_code, buf); |
| 601 | case SCSI_PROTOCOL_ISCSI: |
| 602 | return iscsi_get_pr_transport_id(se_tpg, se_nacl, pr_reg, |
| 603 | format_code, buf); |
| 604 | default: |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 605 | pr_err("Unknown tl_proto_id: 0x%02x, using" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 606 | " SAS emulation\n", tl_hba->tl_proto_id); |
| 607 | break; |
| 608 | } |
| 609 | |
| 610 | return sas_get_pr_transport_id(se_tpg, se_nacl, pr_reg, |
| 611 | format_code, buf); |
| 612 | } |
| 613 | |
| 614 | static u32 tcm_loop_get_pr_transport_id_len( |
| 615 | struct se_portal_group *se_tpg, |
| 616 | struct se_node_acl *se_nacl, |
| 617 | struct t10_pr_registration *pr_reg, |
| 618 | int *format_code) |
| 619 | { |
Jörn Engel | 8359cf4 | 2011-11-24 02:05:51 +0100 | [diff] [blame] | 620 | struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 621 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
| 622 | |
| 623 | switch (tl_hba->tl_proto_id) { |
| 624 | case SCSI_PROTOCOL_SAS: |
| 625 | return sas_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg, |
| 626 | format_code); |
| 627 | case SCSI_PROTOCOL_FCP: |
| 628 | return fc_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg, |
| 629 | format_code); |
| 630 | case SCSI_PROTOCOL_ISCSI: |
| 631 | return iscsi_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg, |
| 632 | format_code); |
| 633 | default: |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 634 | pr_err("Unknown tl_proto_id: 0x%02x, using" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 635 | " SAS emulation\n", tl_hba->tl_proto_id); |
| 636 | break; |
| 637 | } |
| 638 | |
| 639 | return sas_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg, |
| 640 | format_code); |
| 641 | } |
| 642 | |
| 643 | /* |
| 644 | * Used for handling SCSI fabric dependent TransportIDs in SPC-3 and above |
| 645 | * Persistent Reservation SPEC_I_PT=1 and PROUT REGISTER_AND_MOVE operations. |
| 646 | */ |
| 647 | static char *tcm_loop_parse_pr_out_transport_id( |
| 648 | struct se_portal_group *se_tpg, |
| 649 | const char *buf, |
| 650 | u32 *out_tid_len, |
| 651 | char **port_nexus_ptr) |
| 652 | { |
Jörn Engel | 8359cf4 | 2011-11-24 02:05:51 +0100 | [diff] [blame] | 653 | struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 654 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
| 655 | |
| 656 | switch (tl_hba->tl_proto_id) { |
| 657 | case SCSI_PROTOCOL_SAS: |
| 658 | return sas_parse_pr_out_transport_id(se_tpg, buf, out_tid_len, |
| 659 | port_nexus_ptr); |
| 660 | case SCSI_PROTOCOL_FCP: |
| 661 | return fc_parse_pr_out_transport_id(se_tpg, buf, out_tid_len, |
| 662 | port_nexus_ptr); |
| 663 | case SCSI_PROTOCOL_ISCSI: |
| 664 | return iscsi_parse_pr_out_transport_id(se_tpg, buf, out_tid_len, |
| 665 | port_nexus_ptr); |
| 666 | default: |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 667 | pr_err("Unknown tl_proto_id: 0x%02x, using" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 668 | " SAS emulation\n", tl_hba->tl_proto_id); |
| 669 | break; |
| 670 | } |
| 671 | |
| 672 | return sas_parse_pr_out_transport_id(se_tpg, buf, out_tid_len, |
| 673 | port_nexus_ptr); |
| 674 | } |
| 675 | |
| 676 | /* |
| 677 | * Returning (1) here allows for target_core_mod struct se_node_acl to be generated |
| 678 | * based upon the incoming fabric dependent SCSI Initiator Port |
| 679 | */ |
| 680 | static int tcm_loop_check_demo_mode(struct se_portal_group *se_tpg) |
| 681 | { |
| 682 | return 1; |
| 683 | } |
| 684 | |
| 685 | static int tcm_loop_check_demo_mode_cache(struct se_portal_group *se_tpg) |
| 686 | { |
| 687 | return 0; |
| 688 | } |
| 689 | |
| 690 | /* |
| 691 | * Allow I_T Nexus full READ-WRITE access without explict Initiator Node ACLs for |
| 692 | * local virtual Linux/SCSI LLD passthrough into VM hypervisor guest |
| 693 | */ |
| 694 | static int tcm_loop_check_demo_mode_write_protect(struct se_portal_group *se_tpg) |
| 695 | { |
| 696 | return 0; |
| 697 | } |
| 698 | |
| 699 | /* |
| 700 | * Because TCM_Loop does not use explict ACLs and MappedLUNs, this will |
| 701 | * never be called for TCM_Loop by target_core_fabric_configfs.c code. |
| 702 | * It has been added here as a nop for target_fabric_tf_ops_check() |
| 703 | */ |
| 704 | static int tcm_loop_check_prod_mode_write_protect(struct se_portal_group *se_tpg) |
| 705 | { |
| 706 | return 0; |
| 707 | } |
| 708 | |
| 709 | static struct se_node_acl *tcm_loop_tpg_alloc_fabric_acl( |
| 710 | struct se_portal_group *se_tpg) |
| 711 | { |
| 712 | struct tcm_loop_nacl *tl_nacl; |
| 713 | |
| 714 | tl_nacl = kzalloc(sizeof(struct tcm_loop_nacl), GFP_KERNEL); |
| 715 | if (!tl_nacl) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 716 | pr_err("Unable to allocate struct tcm_loop_nacl\n"); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 717 | return NULL; |
| 718 | } |
| 719 | |
| 720 | return &tl_nacl->se_node_acl; |
| 721 | } |
| 722 | |
| 723 | static void tcm_loop_tpg_release_fabric_acl( |
| 724 | struct se_portal_group *se_tpg, |
| 725 | struct se_node_acl *se_nacl) |
| 726 | { |
| 727 | struct tcm_loop_nacl *tl_nacl = container_of(se_nacl, |
| 728 | struct tcm_loop_nacl, se_node_acl); |
| 729 | |
| 730 | kfree(tl_nacl); |
| 731 | } |
| 732 | |
| 733 | static u32 tcm_loop_get_inst_index(struct se_portal_group *se_tpg) |
| 734 | { |
| 735 | return 1; |
| 736 | } |
| 737 | |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 738 | static int tcm_loop_is_state_remove(struct se_cmd *se_cmd) |
| 739 | { |
| 740 | /* |
| 741 | * Assume struct scsi_cmnd is not in remove state.. |
| 742 | */ |
| 743 | return 0; |
| 744 | } |
| 745 | |
| 746 | static int tcm_loop_sess_logged_in(struct se_session *se_sess) |
| 747 | { |
| 748 | /* |
| 749 | * Assume that TL Nexus is always active |
| 750 | */ |
| 751 | return 1; |
| 752 | } |
| 753 | |
| 754 | static u32 tcm_loop_sess_get_index(struct se_session *se_sess) |
| 755 | { |
| 756 | return 1; |
| 757 | } |
| 758 | |
| 759 | static void tcm_loop_set_default_node_attributes(struct se_node_acl *se_acl) |
| 760 | { |
| 761 | return; |
| 762 | } |
| 763 | |
| 764 | static u32 tcm_loop_get_task_tag(struct se_cmd *se_cmd) |
| 765 | { |
| 766 | return 1; |
| 767 | } |
| 768 | |
| 769 | static int tcm_loop_get_cmd_state(struct se_cmd *se_cmd) |
| 770 | { |
| 771 | struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, |
| 772 | struct tcm_loop_cmd, tl_se_cmd); |
| 773 | |
| 774 | return tl_cmd->sc_cmd_state; |
| 775 | } |
| 776 | |
| 777 | static int tcm_loop_shutdown_session(struct se_session *se_sess) |
| 778 | { |
| 779 | return 0; |
| 780 | } |
| 781 | |
| 782 | static void tcm_loop_close_session(struct se_session *se_sess) |
| 783 | { |
| 784 | return; |
| 785 | }; |
| 786 | |
| 787 | static void tcm_loop_stop_session( |
| 788 | struct se_session *se_sess, |
| 789 | int sess_sleep, |
| 790 | int conn_sleep) |
| 791 | { |
| 792 | return; |
| 793 | } |
| 794 | |
| 795 | static void tcm_loop_fall_back_to_erl0(struct se_session *se_sess) |
| 796 | { |
| 797 | return; |
| 798 | } |
| 799 | |
| 800 | static int tcm_loop_write_pending(struct se_cmd *se_cmd) |
| 801 | { |
| 802 | /* |
| 803 | * Since Linux/SCSI has already sent down a struct scsi_cmnd |
| 804 | * sc->sc_data_direction of DMA_TO_DEVICE with struct scatterlist array |
| 805 | * memory, and memory has already been mapped to struct se_cmd->t_mem_list |
| 806 | * format with transport_generic_map_mem_to_cmd(). |
| 807 | * |
| 808 | * We now tell TCM to add this WRITE CDB directly into the TCM storage |
| 809 | * object execution queue. |
| 810 | */ |
| 811 | transport_generic_process_write(se_cmd); |
| 812 | return 0; |
| 813 | } |
| 814 | |
| 815 | static int tcm_loop_write_pending_status(struct se_cmd *se_cmd) |
| 816 | { |
| 817 | return 0; |
| 818 | } |
| 819 | |
| 820 | static int tcm_loop_queue_data_in(struct se_cmd *se_cmd) |
| 821 | { |
| 822 | struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, |
| 823 | struct tcm_loop_cmd, tl_se_cmd); |
| 824 | struct scsi_cmnd *sc = tl_cmd->sc; |
| 825 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 826 | pr_debug("tcm_loop_queue_data_in() called for scsi_cmnd: %p" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 827 | " cdb: 0x%02x\n", sc, sc->cmnd[0]); |
| 828 | |
| 829 | sc->result = SAM_STAT_GOOD; |
| 830 | set_host_byte(sc, DID_OK); |
| 831 | sc->scsi_done(sc); |
| 832 | return 0; |
| 833 | } |
| 834 | |
| 835 | static int tcm_loop_queue_status(struct se_cmd *se_cmd) |
| 836 | { |
| 837 | struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, |
| 838 | struct tcm_loop_cmd, tl_se_cmd); |
| 839 | struct scsi_cmnd *sc = tl_cmd->sc; |
| 840 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 841 | pr_debug("tcm_loop_queue_status() called for scsi_cmnd: %p" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 842 | " cdb: 0x%02x\n", sc, sc->cmnd[0]); |
| 843 | |
| 844 | if (se_cmd->sense_buffer && |
| 845 | ((se_cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) || |
| 846 | (se_cmd->se_cmd_flags & SCF_EMULATED_TASK_SENSE))) { |
| 847 | |
Andy Grover | 5951146d | 2011-07-19 10:26:37 +0000 | [diff] [blame] | 848 | memcpy(sc->sense_buffer, se_cmd->sense_buffer, |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 849 | SCSI_SENSE_BUFFERSIZE); |
| 850 | sc->result = SAM_STAT_CHECK_CONDITION; |
| 851 | set_driver_byte(sc, DRIVER_SENSE); |
| 852 | } else |
| 853 | sc->result = se_cmd->scsi_status; |
| 854 | |
| 855 | set_host_byte(sc, DID_OK); |
| 856 | sc->scsi_done(sc); |
| 857 | return 0; |
| 858 | } |
| 859 | |
| 860 | static int tcm_loop_queue_tm_rsp(struct se_cmd *se_cmd) |
| 861 | { |
| 862 | struct se_tmr_req *se_tmr = se_cmd->se_tmr_req; |
| 863 | struct tcm_loop_tmr *tl_tmr = se_tmr->fabric_tmr_ptr; |
| 864 | /* |
| 865 | * The SCSI EH thread will be sleeping on se_tmr->tl_tmr_wait, go ahead |
| 866 | * and wake up the wait_queue_head_t in tcm_loop_device_reset() |
| 867 | */ |
| 868 | atomic_set(&tl_tmr->tmr_complete, 1); |
| 869 | wake_up(&tl_tmr->tl_tmr_wait); |
| 870 | return 0; |
| 871 | } |
| 872 | |
| 873 | static u16 tcm_loop_set_fabric_sense_len(struct se_cmd *se_cmd, u32 sense_length) |
| 874 | { |
| 875 | return 0; |
| 876 | } |
| 877 | |
| 878 | static u16 tcm_loop_get_fabric_sense_len(void) |
| 879 | { |
| 880 | return 0; |
| 881 | } |
| 882 | |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 883 | static char *tcm_loop_dump_proto_id(struct tcm_loop_hba *tl_hba) |
| 884 | { |
| 885 | switch (tl_hba->tl_proto_id) { |
| 886 | case SCSI_PROTOCOL_SAS: |
| 887 | return "SAS"; |
| 888 | case SCSI_PROTOCOL_FCP: |
| 889 | return "FCP"; |
| 890 | case SCSI_PROTOCOL_ISCSI: |
| 891 | return "iSCSI"; |
| 892 | default: |
| 893 | break; |
| 894 | } |
| 895 | |
| 896 | return "Unknown"; |
| 897 | } |
| 898 | |
| 899 | /* Start items for tcm_loop_port_cit */ |
| 900 | |
| 901 | static int tcm_loop_port_link( |
| 902 | struct se_portal_group *se_tpg, |
| 903 | struct se_lun *lun) |
| 904 | { |
| 905 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, |
| 906 | struct tcm_loop_tpg, tl_se_tpg); |
| 907 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
| 908 | |
| 909 | atomic_inc(&tl_tpg->tl_tpg_port_count); |
| 910 | smp_mb__after_atomic_inc(); |
| 911 | /* |
| 912 | * Add Linux/SCSI struct scsi_device by HCTL |
| 913 | */ |
| 914 | scsi_add_device(tl_hba->sh, 0, tl_tpg->tl_tpgt, lun->unpacked_lun); |
| 915 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 916 | pr_debug("TCM_Loop_ConfigFS: Port Link Successful\n"); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 917 | return 0; |
| 918 | } |
| 919 | |
| 920 | static void tcm_loop_port_unlink( |
| 921 | struct se_portal_group *se_tpg, |
| 922 | struct se_lun *se_lun) |
| 923 | { |
| 924 | struct scsi_device *sd; |
| 925 | struct tcm_loop_hba *tl_hba; |
| 926 | struct tcm_loop_tpg *tl_tpg; |
| 927 | |
| 928 | tl_tpg = container_of(se_tpg, struct tcm_loop_tpg, tl_se_tpg); |
| 929 | tl_hba = tl_tpg->tl_hba; |
| 930 | |
| 931 | sd = scsi_device_lookup(tl_hba->sh, 0, tl_tpg->tl_tpgt, |
| 932 | se_lun->unpacked_lun); |
| 933 | if (!sd) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 934 | pr_err("Unable to locate struct scsi_device for %d:%d:" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 935 | "%d\n", 0, tl_tpg->tl_tpgt, se_lun->unpacked_lun); |
| 936 | return; |
| 937 | } |
| 938 | /* |
| 939 | * Remove Linux/SCSI struct scsi_device by HCTL |
| 940 | */ |
| 941 | scsi_remove_device(sd); |
| 942 | scsi_device_put(sd); |
| 943 | |
| 944 | atomic_dec(&tl_tpg->tl_tpg_port_count); |
| 945 | smp_mb__after_atomic_dec(); |
| 946 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 947 | pr_debug("TCM_Loop_ConfigFS: Port Unlink Successful\n"); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 948 | } |
| 949 | |
| 950 | /* End items for tcm_loop_port_cit */ |
| 951 | |
| 952 | /* Start items for tcm_loop_nexus_cit */ |
| 953 | |
| 954 | static int tcm_loop_make_nexus( |
| 955 | struct tcm_loop_tpg *tl_tpg, |
| 956 | const char *name) |
| 957 | { |
| 958 | struct se_portal_group *se_tpg; |
| 959 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
| 960 | struct tcm_loop_nexus *tl_nexus; |
Dan Carpenter | 552523d | 2011-06-15 09:41:33 -0700 | [diff] [blame] | 961 | int ret = -ENOMEM; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 962 | |
| 963 | if (tl_tpg->tl_hba->tl_nexus) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 964 | pr_debug("tl_tpg->tl_hba->tl_nexus already exists\n"); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 965 | return -EEXIST; |
| 966 | } |
| 967 | se_tpg = &tl_tpg->tl_se_tpg; |
| 968 | |
| 969 | tl_nexus = kzalloc(sizeof(struct tcm_loop_nexus), GFP_KERNEL); |
| 970 | if (!tl_nexus) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 971 | pr_err("Unable to allocate struct tcm_loop_nexus\n"); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 972 | return -ENOMEM; |
| 973 | } |
| 974 | /* |
| 975 | * Initialize the struct se_session pointer |
| 976 | */ |
| 977 | tl_nexus->se_sess = transport_init_session(); |
Dan Carpenter | 552523d | 2011-06-15 09:41:33 -0700 | [diff] [blame] | 978 | if (IS_ERR(tl_nexus->se_sess)) { |
| 979 | ret = PTR_ERR(tl_nexus->se_sess); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 980 | goto out; |
Dan Carpenter | 552523d | 2011-06-15 09:41:33 -0700 | [diff] [blame] | 981 | } |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 982 | /* |
| 983 | * Since we are running in 'demo mode' this call with generate a |
| 984 | * struct se_node_acl for the tcm_loop struct se_portal_group with the SCSI |
| 985 | * Initiator port name of the passed configfs group 'name'. |
| 986 | */ |
| 987 | tl_nexus->se_sess->se_node_acl = core_tpg_check_initiator_node_acl( |
| 988 | se_tpg, (unsigned char *)name); |
| 989 | if (!tl_nexus->se_sess->se_node_acl) { |
| 990 | transport_free_session(tl_nexus->se_sess); |
| 991 | goto out; |
| 992 | } |
| 993 | /* |
| 994 | * Now, register the SAS I_T Nexus as active with the call to |
| 995 | * transport_register_session() |
| 996 | */ |
| 997 | __transport_register_session(se_tpg, tl_nexus->se_sess->se_node_acl, |
Andy Grover | 5951146d | 2011-07-19 10:26:37 +0000 | [diff] [blame] | 998 | tl_nexus->se_sess, tl_nexus); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 999 | tl_tpg->tl_hba->tl_nexus = tl_nexus; |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1000 | pr_debug("TCM_Loop_ConfigFS: Established I_T Nexus to emulated" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1001 | " %s Initiator Port: %s\n", tcm_loop_dump_proto_id(tl_hba), |
| 1002 | name); |
| 1003 | return 0; |
| 1004 | |
| 1005 | out: |
| 1006 | kfree(tl_nexus); |
Dan Carpenter | 552523d | 2011-06-15 09:41:33 -0700 | [diff] [blame] | 1007 | return ret; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1008 | } |
| 1009 | |
| 1010 | static int tcm_loop_drop_nexus( |
| 1011 | struct tcm_loop_tpg *tpg) |
| 1012 | { |
| 1013 | struct se_session *se_sess; |
| 1014 | struct tcm_loop_nexus *tl_nexus; |
| 1015 | struct tcm_loop_hba *tl_hba = tpg->tl_hba; |
| 1016 | |
| 1017 | tl_nexus = tpg->tl_hba->tl_nexus; |
| 1018 | if (!tl_nexus) |
| 1019 | return -ENODEV; |
| 1020 | |
| 1021 | se_sess = tl_nexus->se_sess; |
| 1022 | if (!se_sess) |
| 1023 | return -ENODEV; |
| 1024 | |
| 1025 | if (atomic_read(&tpg->tl_tpg_port_count)) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1026 | pr_err("Unable to remove TCM_Loop I_T Nexus with" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1027 | " active TPG port count: %d\n", |
| 1028 | atomic_read(&tpg->tl_tpg_port_count)); |
| 1029 | return -EPERM; |
| 1030 | } |
| 1031 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1032 | pr_debug("TCM_Loop_ConfigFS: Removing I_T Nexus to emulated" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1033 | " %s Initiator Port: %s\n", tcm_loop_dump_proto_id(tl_hba), |
| 1034 | tl_nexus->se_sess->se_node_acl->initiatorname); |
| 1035 | /* |
| 1036 | * Release the SCSI I_T Nexus to the emulated SAS Target Port |
| 1037 | */ |
| 1038 | transport_deregister_session(tl_nexus->se_sess); |
| 1039 | tpg->tl_hba->tl_nexus = NULL; |
| 1040 | kfree(tl_nexus); |
| 1041 | return 0; |
| 1042 | } |
| 1043 | |
| 1044 | /* End items for tcm_loop_nexus_cit */ |
| 1045 | |
| 1046 | static ssize_t tcm_loop_tpg_show_nexus( |
| 1047 | struct se_portal_group *se_tpg, |
| 1048 | char *page) |
| 1049 | { |
| 1050 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, |
| 1051 | struct tcm_loop_tpg, tl_se_tpg); |
| 1052 | struct tcm_loop_nexus *tl_nexus; |
| 1053 | ssize_t ret; |
| 1054 | |
| 1055 | tl_nexus = tl_tpg->tl_hba->tl_nexus; |
| 1056 | if (!tl_nexus) |
| 1057 | return -ENODEV; |
| 1058 | |
| 1059 | ret = snprintf(page, PAGE_SIZE, "%s\n", |
| 1060 | tl_nexus->se_sess->se_node_acl->initiatorname); |
| 1061 | |
| 1062 | return ret; |
| 1063 | } |
| 1064 | |
| 1065 | static ssize_t tcm_loop_tpg_store_nexus( |
| 1066 | struct se_portal_group *se_tpg, |
| 1067 | const char *page, |
| 1068 | size_t count) |
| 1069 | { |
| 1070 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, |
| 1071 | struct tcm_loop_tpg, tl_se_tpg); |
| 1072 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
| 1073 | unsigned char i_port[TL_WWN_ADDR_LEN], *ptr, *port_ptr; |
| 1074 | int ret; |
| 1075 | /* |
| 1076 | * Shutdown the active I_T nexus if 'NULL' is passed.. |
| 1077 | */ |
| 1078 | if (!strncmp(page, "NULL", 4)) { |
| 1079 | ret = tcm_loop_drop_nexus(tl_tpg); |
| 1080 | return (!ret) ? count : ret; |
| 1081 | } |
| 1082 | /* |
| 1083 | * Otherwise make sure the passed virtual Initiator port WWN matches |
| 1084 | * the fabric protocol_id set in tcm_loop_make_scsi_hba(), and call |
| 1085 | * tcm_loop_make_nexus() |
| 1086 | */ |
Dan Carpenter | 60d645a | 2011-06-15 10:03:05 -0700 | [diff] [blame] | 1087 | if (strlen(page) >= TL_WWN_ADDR_LEN) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1088 | pr_err("Emulated NAA Sas Address: %s, exceeds" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1089 | " max: %d\n", page, TL_WWN_ADDR_LEN); |
| 1090 | return -EINVAL; |
| 1091 | } |
| 1092 | snprintf(&i_port[0], TL_WWN_ADDR_LEN, "%s", page); |
| 1093 | |
| 1094 | ptr = strstr(i_port, "naa."); |
| 1095 | if (ptr) { |
| 1096 | if (tl_hba->tl_proto_id != SCSI_PROTOCOL_SAS) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1097 | pr_err("Passed SAS Initiator Port %s does not" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1098 | " match target port protoid: %s\n", i_port, |
| 1099 | tcm_loop_dump_proto_id(tl_hba)); |
| 1100 | return -EINVAL; |
| 1101 | } |
| 1102 | port_ptr = &i_port[0]; |
| 1103 | goto check_newline; |
| 1104 | } |
| 1105 | ptr = strstr(i_port, "fc."); |
| 1106 | if (ptr) { |
| 1107 | if (tl_hba->tl_proto_id != SCSI_PROTOCOL_FCP) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1108 | pr_err("Passed FCP Initiator Port %s does not" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1109 | " match target port protoid: %s\n", i_port, |
| 1110 | tcm_loop_dump_proto_id(tl_hba)); |
| 1111 | return -EINVAL; |
| 1112 | } |
| 1113 | port_ptr = &i_port[3]; /* Skip over "fc." */ |
| 1114 | goto check_newline; |
| 1115 | } |
| 1116 | ptr = strstr(i_port, "iqn."); |
| 1117 | if (ptr) { |
| 1118 | if (tl_hba->tl_proto_id != SCSI_PROTOCOL_ISCSI) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1119 | pr_err("Passed iSCSI Initiator Port %s does not" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1120 | " match target port protoid: %s\n", i_port, |
| 1121 | tcm_loop_dump_proto_id(tl_hba)); |
| 1122 | return -EINVAL; |
| 1123 | } |
| 1124 | port_ptr = &i_port[0]; |
| 1125 | goto check_newline; |
| 1126 | } |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1127 | pr_err("Unable to locate prefix for emulated Initiator Port:" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1128 | " %s\n", i_port); |
| 1129 | return -EINVAL; |
| 1130 | /* |
| 1131 | * Clear any trailing newline for the NAA WWN |
| 1132 | */ |
| 1133 | check_newline: |
| 1134 | if (i_port[strlen(i_port)-1] == '\n') |
| 1135 | i_port[strlen(i_port)-1] = '\0'; |
| 1136 | |
| 1137 | ret = tcm_loop_make_nexus(tl_tpg, port_ptr); |
| 1138 | if (ret < 0) |
| 1139 | return ret; |
| 1140 | |
| 1141 | return count; |
| 1142 | } |
| 1143 | |
| 1144 | TF_TPG_BASE_ATTR(tcm_loop, nexus, S_IRUGO | S_IWUSR); |
| 1145 | |
| 1146 | static struct configfs_attribute *tcm_loop_tpg_attrs[] = { |
| 1147 | &tcm_loop_tpg_nexus.attr, |
| 1148 | NULL, |
| 1149 | }; |
| 1150 | |
| 1151 | /* Start items for tcm_loop_naa_cit */ |
| 1152 | |
| 1153 | struct se_portal_group *tcm_loop_make_naa_tpg( |
| 1154 | struct se_wwn *wwn, |
| 1155 | struct config_group *group, |
| 1156 | const char *name) |
| 1157 | { |
| 1158 | struct tcm_loop_hba *tl_hba = container_of(wwn, |
| 1159 | struct tcm_loop_hba, tl_hba_wwn); |
| 1160 | struct tcm_loop_tpg *tl_tpg; |
| 1161 | char *tpgt_str, *end_ptr; |
| 1162 | int ret; |
| 1163 | unsigned short int tpgt; |
| 1164 | |
| 1165 | tpgt_str = strstr(name, "tpgt_"); |
| 1166 | if (!tpgt_str) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1167 | pr_err("Unable to locate \"tpgt_#\" directory" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1168 | " group\n"); |
| 1169 | return ERR_PTR(-EINVAL); |
| 1170 | } |
| 1171 | tpgt_str += 5; /* Skip ahead of "tpgt_" */ |
| 1172 | tpgt = (unsigned short int) simple_strtoul(tpgt_str, &end_ptr, 0); |
| 1173 | |
Dan Carpenter | 12f09cc | 2011-04-02 14:32:47 -0700 | [diff] [blame] | 1174 | if (tpgt >= TL_TPGS_PER_HBA) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1175 | pr_err("Passed tpgt: %hu exceeds TL_TPGS_PER_HBA:" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1176 | " %u\n", tpgt, TL_TPGS_PER_HBA); |
| 1177 | return ERR_PTR(-EINVAL); |
| 1178 | } |
| 1179 | tl_tpg = &tl_hba->tl_hba_tpgs[tpgt]; |
| 1180 | tl_tpg->tl_hba = tl_hba; |
| 1181 | tl_tpg->tl_tpgt = tpgt; |
| 1182 | /* |
| 1183 | * Register the tl_tpg as a emulated SAS TCM Target Endpoint |
| 1184 | */ |
| 1185 | ret = core_tpg_register(&tcm_loop_fabric_configfs->tf_ops, |
Andy Grover | 5951146d | 2011-07-19 10:26:37 +0000 | [diff] [blame] | 1186 | wwn, &tl_tpg->tl_se_tpg, tl_tpg, |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1187 | TRANSPORT_TPG_TYPE_NORMAL); |
| 1188 | if (ret < 0) |
| 1189 | return ERR_PTR(-ENOMEM); |
| 1190 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1191 | pr_debug("TCM_Loop_ConfigFS: Allocated Emulated %s" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1192 | " Target Port %s,t,0x%04x\n", tcm_loop_dump_proto_id(tl_hba), |
| 1193 | config_item_name(&wwn->wwn_group.cg_item), tpgt); |
| 1194 | |
| 1195 | return &tl_tpg->tl_se_tpg; |
| 1196 | } |
| 1197 | |
| 1198 | void tcm_loop_drop_naa_tpg( |
| 1199 | struct se_portal_group *se_tpg) |
| 1200 | { |
| 1201 | struct se_wwn *wwn = se_tpg->se_tpg_wwn; |
| 1202 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, |
| 1203 | struct tcm_loop_tpg, tl_se_tpg); |
| 1204 | struct tcm_loop_hba *tl_hba; |
| 1205 | unsigned short tpgt; |
| 1206 | |
| 1207 | tl_hba = tl_tpg->tl_hba; |
| 1208 | tpgt = tl_tpg->tl_tpgt; |
| 1209 | /* |
| 1210 | * Release the I_T Nexus for the Virtual SAS link if present |
| 1211 | */ |
| 1212 | tcm_loop_drop_nexus(tl_tpg); |
| 1213 | /* |
| 1214 | * Deregister the tl_tpg as a emulated SAS TCM Target Endpoint |
| 1215 | */ |
| 1216 | core_tpg_deregister(se_tpg); |
| 1217 | |
Nicholas Bellinger | 0a02043 | 2011-10-10 19:44:05 -0700 | [diff] [blame] | 1218 | tl_tpg->tl_hba = NULL; |
| 1219 | tl_tpg->tl_tpgt = 0; |
| 1220 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1221 | pr_debug("TCM_Loop_ConfigFS: Deallocated Emulated %s" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1222 | " Target Port %s,t,0x%04x\n", tcm_loop_dump_proto_id(tl_hba), |
| 1223 | config_item_name(&wwn->wwn_group.cg_item), tpgt); |
| 1224 | } |
| 1225 | |
| 1226 | /* End items for tcm_loop_naa_cit */ |
| 1227 | |
| 1228 | /* Start items for tcm_loop_cit */ |
| 1229 | |
| 1230 | struct se_wwn *tcm_loop_make_scsi_hba( |
| 1231 | struct target_fabric_configfs *tf, |
| 1232 | struct config_group *group, |
| 1233 | const char *name) |
| 1234 | { |
| 1235 | struct tcm_loop_hba *tl_hba; |
| 1236 | struct Scsi_Host *sh; |
| 1237 | char *ptr; |
| 1238 | int ret, off = 0; |
| 1239 | |
| 1240 | tl_hba = kzalloc(sizeof(struct tcm_loop_hba), GFP_KERNEL); |
| 1241 | if (!tl_hba) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1242 | pr_err("Unable to allocate struct tcm_loop_hba\n"); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1243 | return ERR_PTR(-ENOMEM); |
| 1244 | } |
| 1245 | /* |
| 1246 | * Determine the emulated Protocol Identifier and Target Port Name |
| 1247 | * based on the incoming configfs directory name. |
| 1248 | */ |
| 1249 | ptr = strstr(name, "naa."); |
| 1250 | if (ptr) { |
| 1251 | tl_hba->tl_proto_id = SCSI_PROTOCOL_SAS; |
| 1252 | goto check_len; |
| 1253 | } |
| 1254 | ptr = strstr(name, "fc."); |
| 1255 | if (ptr) { |
| 1256 | tl_hba->tl_proto_id = SCSI_PROTOCOL_FCP; |
| 1257 | off = 3; /* Skip over "fc." */ |
| 1258 | goto check_len; |
| 1259 | } |
| 1260 | ptr = strstr(name, "iqn."); |
Jesper Juhl | a57b5d3 | 2011-06-28 00:30:17 +0200 | [diff] [blame] | 1261 | if (!ptr) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1262 | pr_err("Unable to locate prefix for emulated Target " |
Jesper Juhl | a57b5d3 | 2011-06-28 00:30:17 +0200 | [diff] [blame] | 1263 | "Port: %s\n", name); |
| 1264 | ret = -EINVAL; |
| 1265 | goto out; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1266 | } |
Jesper Juhl | a57b5d3 | 2011-06-28 00:30:17 +0200 | [diff] [blame] | 1267 | tl_hba->tl_proto_id = SCSI_PROTOCOL_ISCSI; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1268 | |
| 1269 | check_len: |
Dan Carpenter | 60d645a | 2011-06-15 10:03:05 -0700 | [diff] [blame] | 1270 | if (strlen(name) >= TL_WWN_ADDR_LEN) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1271 | pr_err("Emulated NAA %s Address: %s, exceeds" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1272 | " max: %d\n", name, tcm_loop_dump_proto_id(tl_hba), |
| 1273 | TL_WWN_ADDR_LEN); |
Jesper Juhl | a57b5d3 | 2011-06-28 00:30:17 +0200 | [diff] [blame] | 1274 | ret = -EINVAL; |
| 1275 | goto out; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1276 | } |
| 1277 | snprintf(&tl_hba->tl_wwn_address[0], TL_WWN_ADDR_LEN, "%s", &name[off]); |
| 1278 | |
| 1279 | /* |
| 1280 | * Call device_register(tl_hba->dev) to register the emulated |
| 1281 | * Linux/SCSI LLD of type struct Scsi_Host at tl_hba->sh after |
| 1282 | * device_register() callbacks in tcm_loop_driver_probe() |
| 1283 | */ |
| 1284 | ret = tcm_loop_setup_hba_bus(tl_hba, tcm_loop_hba_no_cnt); |
| 1285 | if (ret) |
| 1286 | goto out; |
| 1287 | |
| 1288 | sh = tl_hba->sh; |
| 1289 | tcm_loop_hba_no_cnt++; |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1290 | pr_debug("TCM_Loop_ConfigFS: Allocated emulated Target" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1291 | " %s Address: %s at Linux/SCSI Host ID: %d\n", |
| 1292 | tcm_loop_dump_proto_id(tl_hba), name, sh->host_no); |
| 1293 | |
| 1294 | return &tl_hba->tl_hba_wwn; |
| 1295 | out: |
| 1296 | kfree(tl_hba); |
| 1297 | return ERR_PTR(ret); |
| 1298 | } |
| 1299 | |
| 1300 | void tcm_loop_drop_scsi_hba( |
| 1301 | struct se_wwn *wwn) |
| 1302 | { |
| 1303 | struct tcm_loop_hba *tl_hba = container_of(wwn, |
| 1304 | struct tcm_loop_hba, tl_hba_wwn); |
Nicholas Bellinger | 6297b07 | 2011-11-12 09:29:51 -0800 | [diff] [blame] | 1305 | |
| 1306 | pr_debug("TCM_Loop_ConfigFS: Deallocating emulated Target" |
| 1307 | " SAS Address: %s at Linux/SCSI Host ID: %d\n", |
| 1308 | tl_hba->tl_wwn_address, tl_hba->sh->host_no); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1309 | /* |
| 1310 | * Call device_unregister() on the original tl_hba->dev. |
| 1311 | * tcm_loop_fabric_scsi.c:tcm_loop_release_adapter() will |
| 1312 | * release *tl_hba; |
| 1313 | */ |
| 1314 | device_unregister(&tl_hba->dev); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1315 | } |
| 1316 | |
| 1317 | /* Start items for tcm_loop_cit */ |
| 1318 | static ssize_t tcm_loop_wwn_show_attr_version( |
| 1319 | struct target_fabric_configfs *tf, |
| 1320 | char *page) |
| 1321 | { |
| 1322 | return sprintf(page, "TCM Loopback Fabric module %s\n", TCM_LOOP_VERSION); |
| 1323 | } |
| 1324 | |
| 1325 | TF_WWN_ATTR_RO(tcm_loop, version); |
| 1326 | |
| 1327 | static struct configfs_attribute *tcm_loop_wwn_attrs[] = { |
| 1328 | &tcm_loop_wwn_version.attr, |
| 1329 | NULL, |
| 1330 | }; |
| 1331 | |
| 1332 | /* End items for tcm_loop_cit */ |
| 1333 | |
| 1334 | static int tcm_loop_register_configfs(void) |
| 1335 | { |
| 1336 | struct target_fabric_configfs *fabric; |
| 1337 | struct config_group *tf_cg; |
| 1338 | int ret; |
| 1339 | /* |
| 1340 | * Set the TCM Loop HBA counter to zero |
| 1341 | */ |
| 1342 | tcm_loop_hba_no_cnt = 0; |
| 1343 | /* |
| 1344 | * Register the top level struct config_item_type with TCM core |
| 1345 | */ |
| 1346 | fabric = target_fabric_configfs_init(THIS_MODULE, "loopback"); |
Andy Grover | e3d6f90 | 2011-07-19 08:55:10 +0000 | [diff] [blame] | 1347 | if (IS_ERR(fabric)) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1348 | pr_err("tcm_loop_register_configfs() failed!\n"); |
Andy Grover | e3d6f90 | 2011-07-19 08:55:10 +0000 | [diff] [blame] | 1349 | return PTR_ERR(fabric); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1350 | } |
| 1351 | /* |
| 1352 | * Setup the fabric API of function pointers used by target_core_mod |
| 1353 | */ |
| 1354 | fabric->tf_ops.get_fabric_name = &tcm_loop_get_fabric_name; |
| 1355 | fabric->tf_ops.get_fabric_proto_ident = &tcm_loop_get_fabric_proto_ident; |
| 1356 | fabric->tf_ops.tpg_get_wwn = &tcm_loop_get_endpoint_wwn; |
| 1357 | fabric->tf_ops.tpg_get_tag = &tcm_loop_get_tag; |
| 1358 | fabric->tf_ops.tpg_get_default_depth = &tcm_loop_get_default_depth; |
| 1359 | fabric->tf_ops.tpg_get_pr_transport_id = &tcm_loop_get_pr_transport_id; |
| 1360 | fabric->tf_ops.tpg_get_pr_transport_id_len = |
| 1361 | &tcm_loop_get_pr_transport_id_len; |
| 1362 | fabric->tf_ops.tpg_parse_pr_out_transport_id = |
| 1363 | &tcm_loop_parse_pr_out_transport_id; |
| 1364 | fabric->tf_ops.tpg_check_demo_mode = &tcm_loop_check_demo_mode; |
| 1365 | fabric->tf_ops.tpg_check_demo_mode_cache = |
| 1366 | &tcm_loop_check_demo_mode_cache; |
| 1367 | fabric->tf_ops.tpg_check_demo_mode_write_protect = |
| 1368 | &tcm_loop_check_demo_mode_write_protect; |
| 1369 | fabric->tf_ops.tpg_check_prod_mode_write_protect = |
| 1370 | &tcm_loop_check_prod_mode_write_protect; |
| 1371 | /* |
| 1372 | * The TCM loopback fabric module runs in demo-mode to a local |
| 1373 | * virtual SCSI device, so fabric dependent initator ACLs are |
| 1374 | * not required. |
| 1375 | */ |
| 1376 | fabric->tf_ops.tpg_alloc_fabric_acl = &tcm_loop_tpg_alloc_fabric_acl; |
| 1377 | fabric->tf_ops.tpg_release_fabric_acl = |
| 1378 | &tcm_loop_tpg_release_fabric_acl; |
| 1379 | fabric->tf_ops.tpg_get_inst_index = &tcm_loop_get_inst_index; |
| 1380 | /* |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1381 | * Used for setting up remaining TCM resources in process context |
| 1382 | */ |
| 1383 | fabric->tf_ops.new_cmd_map = &tcm_loop_new_cmd_map; |
| 1384 | fabric->tf_ops.check_stop_free = &tcm_loop_check_stop_free; |
Christoph Hellwig | 3546297 | 2011-05-31 23:56:57 -0400 | [diff] [blame] | 1385 | fabric->tf_ops.release_cmd = &tcm_loop_release_cmd; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1386 | fabric->tf_ops.shutdown_session = &tcm_loop_shutdown_session; |
| 1387 | fabric->tf_ops.close_session = &tcm_loop_close_session; |
| 1388 | fabric->tf_ops.stop_session = &tcm_loop_stop_session; |
| 1389 | fabric->tf_ops.fall_back_to_erl0 = &tcm_loop_fall_back_to_erl0; |
| 1390 | fabric->tf_ops.sess_logged_in = &tcm_loop_sess_logged_in; |
| 1391 | fabric->tf_ops.sess_get_index = &tcm_loop_sess_get_index; |
| 1392 | fabric->tf_ops.sess_get_initiator_sid = NULL; |
| 1393 | fabric->tf_ops.write_pending = &tcm_loop_write_pending; |
| 1394 | fabric->tf_ops.write_pending_status = &tcm_loop_write_pending_status; |
| 1395 | /* |
| 1396 | * Not used for TCM loopback |
| 1397 | */ |
| 1398 | fabric->tf_ops.set_default_node_attributes = |
| 1399 | &tcm_loop_set_default_node_attributes; |
| 1400 | fabric->tf_ops.get_task_tag = &tcm_loop_get_task_tag; |
| 1401 | fabric->tf_ops.get_cmd_state = &tcm_loop_get_cmd_state; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1402 | fabric->tf_ops.queue_data_in = &tcm_loop_queue_data_in; |
| 1403 | fabric->tf_ops.queue_status = &tcm_loop_queue_status; |
| 1404 | fabric->tf_ops.queue_tm_rsp = &tcm_loop_queue_tm_rsp; |
| 1405 | fabric->tf_ops.set_fabric_sense_len = &tcm_loop_set_fabric_sense_len; |
| 1406 | fabric->tf_ops.get_fabric_sense_len = &tcm_loop_get_fabric_sense_len; |
| 1407 | fabric->tf_ops.is_state_remove = &tcm_loop_is_state_remove; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1408 | |
| 1409 | tf_cg = &fabric->tf_group; |
| 1410 | /* |
| 1411 | * Setup function pointers for generic logic in target_core_fabric_configfs.c |
| 1412 | */ |
| 1413 | fabric->tf_ops.fabric_make_wwn = &tcm_loop_make_scsi_hba; |
| 1414 | fabric->tf_ops.fabric_drop_wwn = &tcm_loop_drop_scsi_hba; |
| 1415 | fabric->tf_ops.fabric_make_tpg = &tcm_loop_make_naa_tpg; |
| 1416 | fabric->tf_ops.fabric_drop_tpg = &tcm_loop_drop_naa_tpg; |
| 1417 | /* |
| 1418 | * fabric_post_link() and fabric_pre_unlink() are used for |
| 1419 | * registration and release of TCM Loop Virtual SCSI LUNs. |
| 1420 | */ |
| 1421 | fabric->tf_ops.fabric_post_link = &tcm_loop_port_link; |
| 1422 | fabric->tf_ops.fabric_pre_unlink = &tcm_loop_port_unlink; |
| 1423 | fabric->tf_ops.fabric_make_np = NULL; |
| 1424 | fabric->tf_ops.fabric_drop_np = NULL; |
| 1425 | /* |
| 1426 | * Setup default attribute lists for various fabric->tf_cit_tmpl |
| 1427 | */ |
| 1428 | TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = tcm_loop_wwn_attrs; |
| 1429 | TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = tcm_loop_tpg_attrs; |
| 1430 | TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = NULL; |
| 1431 | TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL; |
| 1432 | TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL; |
| 1433 | /* |
| 1434 | * Once fabric->tf_ops has been setup, now register the fabric for |
| 1435 | * use within TCM |
| 1436 | */ |
| 1437 | ret = target_fabric_configfs_register(fabric); |
| 1438 | if (ret < 0) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1439 | pr_err("target_fabric_configfs_register() for" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1440 | " TCM_Loop failed!\n"); |
| 1441 | target_fabric_configfs_free(fabric); |
| 1442 | return -1; |
| 1443 | } |
| 1444 | /* |
| 1445 | * Setup our local pointer to *fabric. |
| 1446 | */ |
| 1447 | tcm_loop_fabric_configfs = fabric; |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1448 | pr_debug("TCM_LOOP[0] - Set fabric ->" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1449 | " tcm_loop_fabric_configfs\n"); |
| 1450 | return 0; |
| 1451 | } |
| 1452 | |
| 1453 | static void tcm_loop_deregister_configfs(void) |
| 1454 | { |
| 1455 | if (!tcm_loop_fabric_configfs) |
| 1456 | return; |
| 1457 | |
| 1458 | target_fabric_configfs_deregister(tcm_loop_fabric_configfs); |
| 1459 | tcm_loop_fabric_configfs = NULL; |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1460 | pr_debug("TCM_LOOP[0] - Cleared" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1461 | " tcm_loop_fabric_configfs\n"); |
| 1462 | } |
| 1463 | |
| 1464 | static int __init tcm_loop_fabric_init(void) |
| 1465 | { |
Christoph Hellwig | afe2cb7 | 2012-02-02 17:04:41 -0500 | [diff] [blame^] | 1466 | int ret = -ENOMEM; |
| 1467 | |
| 1468 | tcm_loop_workqueue = alloc_workqueue("tcm_loop", 0, 0); |
| 1469 | if (!tcm_loop_workqueue) |
| 1470 | goto out; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1471 | |
| 1472 | tcm_loop_cmd_cache = kmem_cache_create("tcm_loop_cmd_cache", |
| 1473 | sizeof(struct tcm_loop_cmd), |
| 1474 | __alignof__(struct tcm_loop_cmd), |
| 1475 | 0, NULL); |
| 1476 | if (!tcm_loop_cmd_cache) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1477 | pr_debug("kmem_cache_create() for" |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1478 | " tcm_loop_cmd_cache failed\n"); |
Christoph Hellwig | afe2cb7 | 2012-02-02 17:04:41 -0500 | [diff] [blame^] | 1479 | goto out_destroy_workqueue; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1480 | } |
| 1481 | |
| 1482 | ret = tcm_loop_alloc_core_bus(); |
| 1483 | if (ret) |
Christoph Hellwig | afe2cb7 | 2012-02-02 17:04:41 -0500 | [diff] [blame^] | 1484 | goto out_destroy_cache; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1485 | |
| 1486 | ret = tcm_loop_register_configfs(); |
Christoph Hellwig | afe2cb7 | 2012-02-02 17:04:41 -0500 | [diff] [blame^] | 1487 | if (ret) |
| 1488 | goto out_release_core_bus; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1489 | |
| 1490 | return 0; |
Christoph Hellwig | afe2cb7 | 2012-02-02 17:04:41 -0500 | [diff] [blame^] | 1491 | |
| 1492 | out_release_core_bus: |
| 1493 | tcm_loop_release_core_bus(); |
| 1494 | out_destroy_cache: |
| 1495 | kmem_cache_destroy(tcm_loop_cmd_cache); |
| 1496 | out_destroy_workqueue: |
| 1497 | destroy_workqueue(tcm_loop_workqueue); |
| 1498 | out: |
| 1499 | return ret; |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1500 | } |
| 1501 | |
| 1502 | static void __exit tcm_loop_fabric_exit(void) |
| 1503 | { |
| 1504 | tcm_loop_deregister_configfs(); |
| 1505 | tcm_loop_release_core_bus(); |
| 1506 | kmem_cache_destroy(tcm_loop_cmd_cache); |
Christoph Hellwig | afe2cb7 | 2012-02-02 17:04:41 -0500 | [diff] [blame^] | 1507 | destroy_workqueue(tcm_loop_workqueue); |
Nicholas Bellinger | 3703b2c | 2011-03-18 15:39:17 -0700 | [diff] [blame] | 1508 | } |
| 1509 | |
| 1510 | MODULE_DESCRIPTION("TCM loopback virtual Linux/SCSI fabric module"); |
| 1511 | MODULE_AUTHOR("Nicholas A. Bellinger <nab@risingtidesystems.com>"); |
| 1512 | MODULE_LICENSE("GPL"); |
| 1513 | module_init(tcm_loop_fabric_init); |
| 1514 | module_exit(tcm_loop_fabric_exit); |