Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tgt: removal

Now that the ibmvstgt driver as the only user of scsi_tgt is gone, the
scsi_tgt kernel module, the CONFIG_SCSI_TGT, CONFIG_SCSI_SRP_TGT_ATTRS and
CONFIG_SCSI_FC_TGT_ATTRS kbuild variable, the scsi_host_template
transfer_response method are no longer needed.

[hch: minor updates to the current tree, changelog update]

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>

authored by

Bart Van Assche and committed by
Christoph Hellwig
06646525 f6667938

-1333
-7
drivers/scsi/Kconfig
··· 304 304 If you wish to export transport-specific information about 305 305 each attached SRP device to sysfs, say Y. 306 306 307 - config SCSI_SRP_TGT_ATTRS 308 - bool "SCSI target support for SRP Transport Attributes" 309 - depends on SCSI_SRP_ATTRS 310 - depends on SCSI_TGT = y || SCSI_TGT = SCSI_SRP_ATTRS 311 - help 312 - If you want to use SCSI target mode drivers enable this option. 313 - 314 307 endmenu 315 308 316 309 menuconfig SCSI_LOWLEVEL
-3
drivers/scsi/Makefile
··· 20 20 obj-$(CONFIG_PCMCIA) += pcmcia/ 21 21 22 22 obj-$(CONFIG_SCSI) += scsi_mod.o 23 - obj-$(CONFIG_SCSI_TGT) += scsi_tgt.o 24 23 25 24 obj-$(CONFIG_RAID_ATTRS) += raid_class.o 26 25 ··· 169 170 scsi_mod-$(CONFIG_PM) += scsi_pm.o 170 171 171 172 hv_storvsc-y := storvsc_drv.o 172 - 173 - scsi_tgt-y += scsi_tgt_lib.o scsi_tgt_if.o 174 173 175 174 sd_mod-objs := sd.o 176 175 sd_mod-$(CONFIG_BLK_DEV_INTEGRITY) += sd_dif.o
-399
drivers/scsi/scsi_tgt_if.c
··· 1 - /* 2 - * SCSI target kernel/user interface functions 3 - * 4 - * Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org> 5 - * Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu> 6 - * 7 - * This program is free software; you can redistribute it and/or 8 - * modify it under the terms of the GNU General Public License as 9 - * published by the Free Software Foundation; either version 2 of the 10 - * License, or (at your option) any later version. 11 - * 12 - * This program is distributed in the hope that it will be useful, but 13 - * WITHOUT ANY WARRANTY; without even the implied warranty of 14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 - * General Public License for more details. 16 - * 17 - * You should have received a copy of the GNU General Public License 18 - * along with this program; if not, write to the Free Software 19 - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 20 - * 02110-1301 USA 21 - */ 22 - #include <linux/miscdevice.h> 23 - #include <linux/gfp.h> 24 - #include <linux/file.h> 25 - #include <linux/export.h> 26 - #include <net/tcp.h> 27 - #include <scsi/scsi.h> 28 - #include <scsi/scsi_cmnd.h> 29 - #include <scsi/scsi_device.h> 30 - #include <scsi/scsi_host.h> 31 - #include <scsi/scsi_tgt.h> 32 - #include <scsi/scsi_tgt_if.h> 33 - 34 - #include <asm/cacheflush.h> 35 - 36 - #include "scsi_tgt_priv.h" 37 - 38 - #if TGT_RING_SIZE < PAGE_SIZE 39 - # define TGT_RING_SIZE PAGE_SIZE 40 - #endif 41 - 42 - #define TGT_RING_PAGES (TGT_RING_SIZE >> PAGE_SHIFT) 43 - #define TGT_EVENT_PER_PAGE (PAGE_SIZE / sizeof(struct tgt_event)) 44 - #define TGT_MAX_EVENTS (TGT_EVENT_PER_PAGE * TGT_RING_PAGES) 45 - 46 - struct tgt_ring { 47 - u32 tr_idx; 48 - unsigned long tr_pages[TGT_RING_PAGES]; 49 - spinlock_t tr_lock; 50 - }; 51 - 52 - /* tx_ring : kernel->user, rx_ring : user->kernel */ 53 - static struct tgt_ring tx_ring, rx_ring; 54 - static DECLARE_WAIT_QUEUE_HEAD(tgt_poll_wait); 55 - 56 - static inline void tgt_ring_idx_inc(struct tgt_ring *ring) 57 - { 58 - if (ring->tr_idx == TGT_MAX_EVENTS - 1) 59 - ring->tr_idx = 0; 60 - else 61 - ring->tr_idx++; 62 - } 63 - 64 - static struct tgt_event *tgt_head_event(struct tgt_ring *ring, u32 idx) 65 - { 66 - u32 pidx, off; 67 - 68 - pidx = idx / TGT_EVENT_PER_PAGE; 69 - off = idx % TGT_EVENT_PER_PAGE; 70 - 71 - return (struct tgt_event *) 72 - (ring->tr_pages[pidx] + sizeof(struct tgt_event) * off); 73 - } 74 - 75 - static int tgt_uspace_send_event(u32 type, struct tgt_event *p) 76 - { 77 - struct tgt_event *ev; 78 - struct tgt_ring *ring = &tx_ring; 79 - unsigned long flags; 80 - int err = 0; 81 - 82 - spin_lock_irqsave(&ring->tr_lock, flags); 83 - 84 - ev = tgt_head_event(ring, ring->tr_idx); 85 - if (!ev->hdr.status) 86 - tgt_ring_idx_inc(ring); 87 - else 88 - err = -BUSY; 89 - 90 - spin_unlock_irqrestore(&ring->tr_lock, flags); 91 - 92 - if (err) 93 - return err; 94 - 95 - memcpy(ev, p, sizeof(*ev)); 96 - ev->hdr.type = type; 97 - mb(); 98 - ev->hdr.status = 1; 99 - 100 - flush_dcache_page(virt_to_page(ev)); 101 - 102 - wake_up_interruptible(&tgt_poll_wait); 103 - 104 - return 0; 105 - } 106 - 107 - int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, u64 itn_id, 108 - struct scsi_lun *lun, u64 tag) 109 - { 110 - struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd); 111 - struct tgt_event ev; 112 - int err; 113 - 114 - memset(&ev, 0, sizeof(ev)); 115 - ev.p.cmd_req.host_no = shost->host_no; 116 - ev.p.cmd_req.itn_id = itn_id; 117 - ev.p.cmd_req.data_len = scsi_bufflen(cmd); 118 - memcpy(ev.p.cmd_req.scb, cmd->cmnd, sizeof(ev.p.cmd_req.scb)); 119 - memcpy(ev.p.cmd_req.lun, lun, sizeof(ev.p.cmd_req.lun)); 120 - ev.p.cmd_req.attribute = cmd->tag; 121 - ev.p.cmd_req.tag = tag; 122 - 123 - dprintk("%p %d %u %x %llx\n", cmd, shost->host_no, 124 - ev.p.cmd_req.data_len, cmd->tag, 125 - (unsigned long long) ev.p.cmd_req.tag); 126 - 127 - err = tgt_uspace_send_event(TGT_KEVENT_CMD_REQ, &ev); 128 - if (err) 129 - eprintk("tx buf is full, could not send\n"); 130 - 131 - return err; 132 - } 133 - 134 - int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 itn_id, u64 tag) 135 - { 136 - struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd); 137 - struct tgt_event ev; 138 - int err; 139 - 140 - memset(&ev, 0, sizeof(ev)); 141 - ev.p.cmd_done.host_no = shost->host_no; 142 - ev.p.cmd_done.itn_id = itn_id; 143 - ev.p.cmd_done.tag = tag; 144 - ev.p.cmd_done.result = cmd->result; 145 - 146 - dprintk("%p %d %llu %u %x\n", cmd, shost->host_no, 147 - (unsigned long long) ev.p.cmd_req.tag, 148 - ev.p.cmd_req.data_len, cmd->tag); 149 - 150 - err = tgt_uspace_send_event(TGT_KEVENT_CMD_DONE, &ev); 151 - if (err) 152 - eprintk("tx buf is full, could not send\n"); 153 - 154 - return err; 155 - } 156 - 157 - int scsi_tgt_uspace_send_tsk_mgmt(int host_no, u64 itn_id, int function, 158 - u64 tag, struct scsi_lun *scsilun, void *data) 159 - { 160 - struct tgt_event ev; 161 - int err; 162 - 163 - memset(&ev, 0, sizeof(ev)); 164 - ev.p.tsk_mgmt_req.host_no = host_no; 165 - ev.p.tsk_mgmt_req.itn_id = itn_id; 166 - ev.p.tsk_mgmt_req.function = function; 167 - ev.p.tsk_mgmt_req.tag = tag; 168 - memcpy(ev.p.tsk_mgmt_req.lun, scsilun, sizeof(ev.p.tsk_mgmt_req.lun)); 169 - ev.p.tsk_mgmt_req.mid = (u64) (unsigned long) data; 170 - 171 - dprintk("%d %x %llx %llx\n", host_no, function, (unsigned long long) tag, 172 - (unsigned long long) ev.p.tsk_mgmt_req.mid); 173 - 174 - err = tgt_uspace_send_event(TGT_KEVENT_TSK_MGMT_REQ, &ev); 175 - if (err) 176 - eprintk("tx buf is full, could not send\n"); 177 - 178 - return err; 179 - } 180 - 181 - int scsi_tgt_uspace_send_it_nexus_request(int host_no, u64 itn_id, 182 - int function, char *initiator_id) 183 - { 184 - struct tgt_event ev; 185 - int err; 186 - 187 - memset(&ev, 0, sizeof(ev)); 188 - ev.p.it_nexus_req.host_no = host_no; 189 - ev.p.it_nexus_req.function = function; 190 - ev.p.it_nexus_req.itn_id = itn_id; 191 - if (initiator_id) 192 - strncpy(ev.p.it_nexus_req.initiator_id, initiator_id, 193 - sizeof(ev.p.it_nexus_req.initiator_id)); 194 - 195 - dprintk("%d %x %llx\n", host_no, function, (unsigned long long)itn_id); 196 - 197 - err = tgt_uspace_send_event(TGT_KEVENT_IT_NEXUS_REQ, &ev); 198 - if (err) 199 - eprintk("tx buf is full, could not send\n"); 200 - 201 - return err; 202 - } 203 - 204 - static int event_recv_msg(struct tgt_event *ev) 205 - { 206 - int err = 0; 207 - 208 - switch (ev->hdr.type) { 209 - case TGT_UEVENT_CMD_RSP: 210 - err = scsi_tgt_kspace_exec(ev->p.cmd_rsp.host_no, 211 - ev->p.cmd_rsp.itn_id, 212 - ev->p.cmd_rsp.result, 213 - ev->p.cmd_rsp.tag, 214 - ev->p.cmd_rsp.uaddr, 215 - ev->p.cmd_rsp.len, 216 - ev->p.cmd_rsp.sense_uaddr, 217 - ev->p.cmd_rsp.sense_len, 218 - ev->p.cmd_rsp.rw); 219 - break; 220 - case TGT_UEVENT_TSK_MGMT_RSP: 221 - err = scsi_tgt_kspace_tsk_mgmt(ev->p.tsk_mgmt_rsp.host_no, 222 - ev->p.tsk_mgmt_rsp.itn_id, 223 - ev->p.tsk_mgmt_rsp.mid, 224 - ev->p.tsk_mgmt_rsp.result); 225 - break; 226 - case TGT_UEVENT_IT_NEXUS_RSP: 227 - err = scsi_tgt_kspace_it_nexus_rsp(ev->p.it_nexus_rsp.host_no, 228 - ev->p.it_nexus_rsp.itn_id, 229 - ev->p.it_nexus_rsp.result); 230 - break; 231 - default: 232 - eprintk("unknown type %d\n", ev->hdr.type); 233 - err = -EINVAL; 234 - } 235 - 236 - return err; 237 - } 238 - 239 - static ssize_t tgt_write(struct file *file, const char __user * buffer, 240 - size_t count, loff_t * ppos) 241 - { 242 - struct tgt_event *ev; 243 - struct tgt_ring *ring = &rx_ring; 244 - 245 - while (1) { 246 - ev = tgt_head_event(ring, ring->tr_idx); 247 - /* do we need this? */ 248 - flush_dcache_page(virt_to_page(ev)); 249 - 250 - if (!ev->hdr.status) 251 - break; 252 - 253 - tgt_ring_idx_inc(ring); 254 - event_recv_msg(ev); 255 - ev->hdr.status = 0; 256 - }; 257 - 258 - return count; 259 - } 260 - 261 - static unsigned int tgt_poll(struct file * file, struct poll_table_struct *wait) 262 - { 263 - struct tgt_event *ev; 264 - struct tgt_ring *ring = &tx_ring; 265 - unsigned long flags; 266 - unsigned int mask = 0; 267 - u32 idx; 268 - 269 - poll_wait(file, &tgt_poll_wait, wait); 270 - 271 - spin_lock_irqsave(&ring->tr_lock, flags); 272 - 273 - idx = ring->tr_idx ? ring->tr_idx - 1 : TGT_MAX_EVENTS - 1; 274 - ev = tgt_head_event(ring, idx); 275 - if (ev->hdr.status) 276 - mask |= POLLIN | POLLRDNORM; 277 - 278 - spin_unlock_irqrestore(&ring->tr_lock, flags); 279 - 280 - return mask; 281 - } 282 - 283 - static int uspace_ring_map(struct vm_area_struct *vma, unsigned long addr, 284 - struct tgt_ring *ring) 285 - { 286 - int i, err; 287 - 288 - for (i = 0; i < TGT_RING_PAGES; i++) { 289 - struct page *page = virt_to_page(ring->tr_pages[i]); 290 - err = vm_insert_page(vma, addr, page); 291 - if (err) 292 - return err; 293 - addr += PAGE_SIZE; 294 - } 295 - 296 - return 0; 297 - } 298 - 299 - static int tgt_mmap(struct file *filp, struct vm_area_struct *vma) 300 - { 301 - unsigned long addr; 302 - int err; 303 - 304 - if (vma->vm_pgoff) 305 - return -EINVAL; 306 - 307 - if (vma->vm_end - vma->vm_start != TGT_RING_SIZE * 2) { 308 - eprintk("mmap size must be %lu, not %lu \n", 309 - TGT_RING_SIZE * 2, vma->vm_end - vma->vm_start); 310 - return -EINVAL; 311 - } 312 - 313 - addr = vma->vm_start; 314 - err = uspace_ring_map(vma, addr, &tx_ring); 315 - if (err) 316 - return err; 317 - err = uspace_ring_map(vma, addr + TGT_RING_SIZE, &rx_ring); 318 - 319 - return err; 320 - } 321 - 322 - static int tgt_open(struct inode *inode, struct file *file) 323 - { 324 - tx_ring.tr_idx = rx_ring.tr_idx = 0; 325 - 326 - return 0; 327 - } 328 - 329 - static const struct file_operations tgt_fops = { 330 - .owner = THIS_MODULE, 331 - .open = tgt_open, 332 - .poll = tgt_poll, 333 - .write = tgt_write, 334 - .mmap = tgt_mmap, 335 - .llseek = noop_llseek, 336 - }; 337 - 338 - static struct miscdevice tgt_miscdev = { 339 - .minor = MISC_DYNAMIC_MINOR, 340 - .name = "tgt", 341 - .fops = &tgt_fops, 342 - }; 343 - 344 - static void tgt_ring_exit(struct tgt_ring *ring) 345 - { 346 - int i; 347 - 348 - for (i = 0; i < TGT_RING_PAGES; i++) 349 - free_page(ring->tr_pages[i]); 350 - } 351 - 352 - static int tgt_ring_init(struct tgt_ring *ring) 353 - { 354 - int i; 355 - 356 - spin_lock_init(&ring->tr_lock); 357 - 358 - for (i = 0; i < TGT_RING_PAGES; i++) { 359 - ring->tr_pages[i] = get_zeroed_page(GFP_KERNEL); 360 - if (!ring->tr_pages[i]) { 361 - eprintk("out of memory\n"); 362 - return -ENOMEM; 363 - } 364 - } 365 - 366 - return 0; 367 - } 368 - 369 - void scsi_tgt_if_exit(void) 370 - { 371 - tgt_ring_exit(&tx_ring); 372 - tgt_ring_exit(&rx_ring); 373 - misc_deregister(&tgt_miscdev); 374 - } 375 - 376 - int scsi_tgt_if_init(void) 377 - { 378 - int err; 379 - 380 - err = tgt_ring_init(&tx_ring); 381 - if (err) 382 - return err; 383 - 384 - err = tgt_ring_init(&rx_ring); 385 - if (err) 386 - goto free_tx_ring; 387 - 388 - err = misc_register(&tgt_miscdev); 389 - if (err) 390 - goto free_rx_ring; 391 - 392 - return 0; 393 - free_rx_ring: 394 - tgt_ring_exit(&rx_ring); 395 - free_tx_ring: 396 - tgt_ring_exit(&tx_ring); 397 - 398 - return err; 399 - }
-661
drivers/scsi/scsi_tgt_lib.c
··· 1 - /* 2 - * SCSI target lib functions 3 - * 4 - * Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu> 5 - * Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org> 6 - * 7 - * This program is free software; you can redistribute it and/or 8 - * modify it under the terms of the GNU General Public License as 9 - * published by the Free Software Foundation; either version 2 of the 10 - * License, or (at your option) any later version. 11 - * 12 - * This program is distributed in the hope that it will be useful, but 13 - * WITHOUT ANY WARRANTY; without even the implied warranty of 14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 - * General Public License for more details. 16 - * 17 - * You should have received a copy of the GNU General Public License 18 - * along with this program; if not, write to the Free Software 19 - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 20 - * 02110-1301 USA 21 - */ 22 - #include <linux/blkdev.h> 23 - #include <linux/hash.h> 24 - #include <linux/module.h> 25 - #include <linux/pagemap.h> 26 - #include <linux/slab.h> 27 - #include <scsi/scsi.h> 28 - #include <scsi/scsi_cmnd.h> 29 - #include <scsi/scsi_device.h> 30 - #include <scsi/scsi_host.h> 31 - #include <scsi/scsi_transport.h> 32 - #include <scsi/scsi_tgt.h> 33 - 34 - #include "scsi_tgt_priv.h" 35 - 36 - static struct workqueue_struct *scsi_tgtd; 37 - static struct kmem_cache *scsi_tgt_cmd_cache; 38 - 39 - /* 40 - * TODO: this struct will be killed when the block layer supports large bios 41 - * and James's work struct code is in 42 - */ 43 - struct scsi_tgt_cmd { 44 - /* TODO replace work with James b's code */ 45 - struct work_struct work; 46 - /* TODO fix limits of some drivers */ 47 - struct bio *bio; 48 - 49 - struct list_head hash_list; 50 - struct request *rq; 51 - u64 itn_id; 52 - u64 tag; 53 - }; 54 - 55 - #define TGT_HASH_ORDER 4 56 - #define cmd_hashfn(tag) hash_long((unsigned long) (tag), TGT_HASH_ORDER) 57 - 58 - struct scsi_tgt_queuedata { 59 - struct Scsi_Host *shost; 60 - struct list_head cmd_hash[1 << TGT_HASH_ORDER]; 61 - spinlock_t cmd_hash_lock; 62 - }; 63 - 64 - /* 65 - * Function: scsi_host_get_command() 66 - * 67 - * Purpose: Allocate and setup a scsi command block and blk request 68 - * 69 - * Arguments: shost - scsi host 70 - * data_dir - dma data dir 71 - * gfp_mask- allocator flags 72 - * 73 - * Returns: The allocated scsi command structure. 74 - * 75 - * This should be called by target LLDs to get a command. 76 - */ 77 - struct scsi_cmnd *scsi_host_get_command(struct Scsi_Host *shost, 78 - enum dma_data_direction data_dir, 79 - gfp_t gfp_mask) 80 - { 81 - int write = (data_dir == DMA_TO_DEVICE); 82 - struct request *rq; 83 - struct scsi_cmnd *cmd; 84 - struct scsi_tgt_cmd *tcmd; 85 - 86 - /* Bail if we can't get a reference to the device */ 87 - if (!get_device(&shost->shost_gendev)) 88 - return NULL; 89 - 90 - tcmd = kmem_cache_alloc(scsi_tgt_cmd_cache, GFP_ATOMIC); 91 - if (!tcmd) 92 - goto put_dev; 93 - 94 - /* 95 - * The blk helpers are used to the READ/WRITE requests 96 - * transferring data from a initiator point of view. Since 97 - * we are in target mode we want the opposite. 98 - */ 99 - rq = blk_get_request(shost->uspace_req_q, !write, gfp_mask); 100 - if (!rq) 101 - goto free_tcmd; 102 - 103 - cmd = __scsi_get_command(shost, gfp_mask); 104 - if (!cmd) 105 - goto release_rq; 106 - 107 - cmd->sc_data_direction = data_dir; 108 - cmd->jiffies_at_alloc = jiffies; 109 - cmd->request = rq; 110 - 111 - cmd->cmnd = rq->cmd; 112 - 113 - rq->special = cmd; 114 - rq->cmd_type = REQ_TYPE_SPECIAL; 115 - rq->cmd_flags |= REQ_TYPE_BLOCK_PC; 116 - rq->end_io_data = tcmd; 117 - 118 - tcmd->rq = rq; 119 - 120 - return cmd; 121 - 122 - release_rq: 123 - blk_put_request(rq); 124 - free_tcmd: 125 - kmem_cache_free(scsi_tgt_cmd_cache, tcmd); 126 - put_dev: 127 - put_device(&shost->shost_gendev); 128 - return NULL; 129 - 130 - } 131 - EXPORT_SYMBOL_GPL(scsi_host_get_command); 132 - 133 - /* 134 - * Function: scsi_host_put_command() 135 - * 136 - * Purpose: Free a scsi command block 137 - * 138 - * Arguments: shost - scsi host 139 - * cmd - command block to free 140 - * 141 - * Returns: Nothing. 142 - * 143 - * Notes: The command must not belong to any lists. 144 - */ 145 - void scsi_host_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd) 146 - { 147 - struct request_queue *q = shost->uspace_req_q; 148 - struct request *rq = cmd->request; 149 - struct scsi_tgt_cmd *tcmd = rq->end_io_data; 150 - unsigned long flags; 151 - 152 - kmem_cache_free(scsi_tgt_cmd_cache, tcmd); 153 - 154 - spin_lock_irqsave(q->queue_lock, flags); 155 - __blk_put_request(q, rq); 156 - spin_unlock_irqrestore(q->queue_lock, flags); 157 - 158 - __scsi_put_command(shost, cmd); 159 - put_device(&shost->shost_gendev); 160 - } 161 - EXPORT_SYMBOL_GPL(scsi_host_put_command); 162 - 163 - static void cmd_hashlist_del(struct scsi_cmnd *cmd) 164 - { 165 - struct request_queue *q = cmd->request->q; 166 - struct scsi_tgt_queuedata *qdata = q->queuedata; 167 - unsigned long flags; 168 - struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data; 169 - 170 - spin_lock_irqsave(&qdata->cmd_hash_lock, flags); 171 - list_del(&tcmd->hash_list); 172 - spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags); 173 - } 174 - 175 - static void scsi_unmap_user_pages(struct scsi_tgt_cmd *tcmd) 176 - { 177 - blk_rq_unmap_user(tcmd->bio); 178 - } 179 - 180 - static void scsi_tgt_cmd_destroy(struct work_struct *work) 181 - { 182 - struct scsi_tgt_cmd *tcmd = 183 - container_of(work, struct scsi_tgt_cmd, work); 184 - struct scsi_cmnd *cmd = tcmd->rq->special; 185 - 186 - dprintk("cmd %p %d %u\n", cmd, cmd->sc_data_direction, 187 - rq_data_dir(cmd->request)); 188 - scsi_unmap_user_pages(tcmd); 189 - tcmd->rq->bio = NULL; 190 - scsi_host_put_command(scsi_tgt_cmd_to_host(cmd), cmd); 191 - } 192 - 193 - static void init_scsi_tgt_cmd(struct request *rq, struct scsi_tgt_cmd *tcmd, 194 - u64 itn_id, u64 tag) 195 - { 196 - struct scsi_tgt_queuedata *qdata = rq->q->queuedata; 197 - unsigned long flags; 198 - struct list_head *head; 199 - 200 - tcmd->itn_id = itn_id; 201 - tcmd->tag = tag; 202 - tcmd->bio = NULL; 203 - INIT_WORK(&tcmd->work, scsi_tgt_cmd_destroy); 204 - spin_lock_irqsave(&qdata->cmd_hash_lock, flags); 205 - head = &qdata->cmd_hash[cmd_hashfn(tag)]; 206 - list_add(&tcmd->hash_list, head); 207 - spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags); 208 - } 209 - 210 - /* 211 - * scsi_tgt_alloc_queue - setup queue used for message passing 212 - * shost: scsi host 213 - * 214 - * This should be called by the LLD after host allocation. 215 - * And will be released when the host is released. 216 - */ 217 - int scsi_tgt_alloc_queue(struct Scsi_Host *shost) 218 - { 219 - struct scsi_tgt_queuedata *queuedata; 220 - struct request_queue *q; 221 - int err, i; 222 - 223 - /* 224 - * Do we need to send a netlink event or should uspace 225 - * just respond to the hotplug event? 226 - */ 227 - q = __scsi_alloc_queue(shost, NULL); 228 - if (!q) 229 - return -ENOMEM; 230 - 231 - queuedata = kzalloc(sizeof(*queuedata), GFP_KERNEL); 232 - if (!queuedata) { 233 - err = -ENOMEM; 234 - goto cleanup_queue; 235 - } 236 - queuedata->shost = shost; 237 - q->queuedata = queuedata; 238 - 239 - /* 240 - * this is a silly hack. We should probably just queue as many 241 - * command as is recvd to userspace. uspace can then make 242 - * sure we do not overload the HBA 243 - */ 244 - q->nr_requests = shost->can_queue; 245 - /* 246 - * We currently only support software LLDs so this does 247 - * not matter for now. Do we need this for the cards we support? 248 - * If so we should make it a host template value. 249 - */ 250 - blk_queue_dma_alignment(q, 0); 251 - shost->uspace_req_q = q; 252 - 253 - for (i = 0; i < ARRAY_SIZE(queuedata->cmd_hash); i++) 254 - INIT_LIST_HEAD(&queuedata->cmd_hash[i]); 255 - spin_lock_init(&queuedata->cmd_hash_lock); 256 - 257 - return 0; 258 - 259 - cleanup_queue: 260 - blk_cleanup_queue(q); 261 - return err; 262 - } 263 - EXPORT_SYMBOL_GPL(scsi_tgt_alloc_queue); 264 - 265 - void scsi_tgt_free_queue(struct Scsi_Host *shost) 266 - { 267 - int i; 268 - unsigned long flags; 269 - struct request_queue *q = shost->uspace_req_q; 270 - struct scsi_cmnd *cmd; 271 - struct scsi_tgt_queuedata *qdata = q->queuedata; 272 - struct scsi_tgt_cmd *tcmd, *n; 273 - LIST_HEAD(cmds); 274 - 275 - spin_lock_irqsave(&qdata->cmd_hash_lock, flags); 276 - 277 - for (i = 0; i < ARRAY_SIZE(qdata->cmd_hash); i++) { 278 - list_for_each_entry_safe(tcmd, n, &qdata->cmd_hash[i], 279 - hash_list) 280 - list_move(&tcmd->hash_list, &cmds); 281 - } 282 - 283 - spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags); 284 - 285 - while (!list_empty(&cmds)) { 286 - tcmd = list_entry(cmds.next, struct scsi_tgt_cmd, hash_list); 287 - list_del(&tcmd->hash_list); 288 - cmd = tcmd->rq->special; 289 - 290 - shost->hostt->eh_abort_handler(cmd); 291 - scsi_tgt_cmd_destroy(&tcmd->work); 292 - } 293 - } 294 - EXPORT_SYMBOL_GPL(scsi_tgt_free_queue); 295 - 296 - struct Scsi_Host *scsi_tgt_cmd_to_host(struct scsi_cmnd *cmd) 297 - { 298 - struct scsi_tgt_queuedata *queue = cmd->request->q->queuedata; 299 - return queue->shost; 300 - } 301 - EXPORT_SYMBOL_GPL(scsi_tgt_cmd_to_host); 302 - 303 - /* 304 - * scsi_tgt_queue_command - queue command for userspace processing 305 - * @cmd: scsi command 306 - * @scsilun: scsi lun 307 - * @tag: unique value to identify this command for tmf 308 - */ 309 - int scsi_tgt_queue_command(struct scsi_cmnd *cmd, u64 itn_id, 310 - struct scsi_lun *scsilun, u64 tag) 311 - { 312 - struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data; 313 - int err; 314 - 315 - init_scsi_tgt_cmd(cmd->request, tcmd, itn_id, tag); 316 - err = scsi_tgt_uspace_send_cmd(cmd, itn_id, scsilun, tag); 317 - if (err) 318 - cmd_hashlist_del(cmd); 319 - 320 - return err; 321 - } 322 - EXPORT_SYMBOL_GPL(scsi_tgt_queue_command); 323 - 324 - /* 325 - * This is run from a interrupt handler normally and the unmap 326 - * needs process context so we must queue 327 - */ 328 - static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd) 329 - { 330 - struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data; 331 - 332 - dprintk("cmd %p %u\n", cmd, rq_data_dir(cmd->request)); 333 - 334 - scsi_tgt_uspace_send_status(cmd, tcmd->itn_id, tcmd->tag); 335 - 336 - scsi_release_buffers(cmd); 337 - 338 - queue_work(scsi_tgtd, &tcmd->work); 339 - } 340 - 341 - static int scsi_tgt_transfer_response(struct scsi_cmnd *cmd) 342 - { 343 - struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd); 344 - int err; 345 - 346 - dprintk("cmd %p %u\n", cmd, rq_data_dir(cmd->request)); 347 - 348 - err = shost->hostt->transfer_response(cmd, scsi_tgt_cmd_done); 349 - switch (err) { 350 - case SCSI_MLQUEUE_HOST_BUSY: 351 - case SCSI_MLQUEUE_DEVICE_BUSY: 352 - return -EAGAIN; 353 - } 354 - return 0; 355 - } 356 - 357 - /* TODO: test this crap and replace bio_map_user with new interface maybe */ 358 - static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd, 359 - unsigned long uaddr, unsigned int len, int rw) 360 - { 361 - struct request_queue *q = cmd->request->q; 362 - struct request *rq = cmd->request; 363 - int err; 364 - 365 - dprintk("%lx %u\n", uaddr, len); 366 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL); 367 - if (err) { 368 - /* 369 - * TODO: need to fixup sg_tablesize, max_segment_size, 370 - * max_sectors, etc for modern HW and software drivers 371 - * where this value is bogus. 372 - * 373 - * TODO2: we can alloc a reserve buffer of max size 374 - * we can handle and do the slow copy path for really large 375 - * IO. 376 - */ 377 - eprintk("Could not handle request of size %u.\n", len); 378 - return err; 379 - } 380 - 381 - tcmd->bio = rq->bio; 382 - err = scsi_init_io(cmd, GFP_KERNEL); 383 - if (err) { 384 - scsi_release_buffers(cmd); 385 - goto unmap_rq; 386 - } 387 - /* 388 - * we use REQ_TYPE_BLOCK_PC so scsi_init_io doesn't set the 389 - * length for us. 390 - */ 391 - cmd->sdb.length = blk_rq_bytes(rq); 392 - 393 - return 0; 394 - 395 - unmap_rq: 396 - scsi_unmap_user_pages(tcmd); 397 - return err; 398 - } 399 - 400 - static int scsi_tgt_copy_sense(struct scsi_cmnd *cmd, unsigned long uaddr, 401 - unsigned len) 402 - { 403 - char __user *p = (char __user *) uaddr; 404 - 405 - if (copy_from_user(cmd->sense_buffer, p, 406 - min_t(unsigned, SCSI_SENSE_BUFFERSIZE, len))) { 407 - printk(KERN_ERR "Could not copy the sense buffer\n"); 408 - return -EIO; 409 - } 410 - return 0; 411 - } 412 - 413 - static int scsi_tgt_abort_cmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd) 414 - { 415 - struct scsi_tgt_cmd *tcmd; 416 - int err; 417 - 418 - err = shost->hostt->eh_abort_handler(cmd); 419 - if (err) 420 - eprintk("fail to abort %p\n", cmd); 421 - 422 - tcmd = cmd->request->end_io_data; 423 - scsi_tgt_cmd_destroy(&tcmd->work); 424 - return err; 425 - } 426 - 427 - static struct request *tgt_cmd_hash_lookup(struct request_queue *q, u64 tag) 428 - { 429 - struct scsi_tgt_queuedata *qdata = q->queuedata; 430 - struct request *rq = NULL; 431 - struct list_head *head; 432 - struct scsi_tgt_cmd *tcmd; 433 - unsigned long flags; 434 - 435 - head = &qdata->cmd_hash[cmd_hashfn(tag)]; 436 - spin_lock_irqsave(&qdata->cmd_hash_lock, flags); 437 - list_for_each_entry(tcmd, head, hash_list) { 438 - if (tcmd->tag == tag) { 439 - rq = tcmd->rq; 440 - list_del(&tcmd->hash_list); 441 - break; 442 - } 443 - } 444 - spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags); 445 - 446 - return rq; 447 - } 448 - 449 - int scsi_tgt_kspace_exec(int host_no, u64 itn_id, int result, u64 tag, 450 - unsigned long uaddr, u32 len, unsigned long sense_uaddr, 451 - u32 sense_len, u8 rw) 452 - { 453 - struct Scsi_Host *shost; 454 - struct scsi_cmnd *cmd; 455 - struct request *rq; 456 - struct scsi_tgt_cmd *tcmd; 457 - int err = 0; 458 - 459 - dprintk("%d %llu %d %u %lx %u\n", host_no, (unsigned long long) tag, 460 - result, len, uaddr, rw); 461 - 462 - /* TODO: replace with a O(1) alg */ 463 - shost = scsi_host_lookup(host_no); 464 - if (!shost) { 465 - printk(KERN_ERR "Could not find host no %d\n", host_no); 466 - return -EINVAL; 467 - } 468 - 469 - if (!shost->uspace_req_q) { 470 - printk(KERN_ERR "Not target scsi host %d\n", host_no); 471 - goto done; 472 - } 473 - 474 - rq = tgt_cmd_hash_lookup(shost->uspace_req_q, tag); 475 - if (!rq) { 476 - printk(KERN_ERR "Could not find tag %llu\n", 477 - (unsigned long long) tag); 478 - err = -EINVAL; 479 - goto done; 480 - } 481 - cmd = rq->special; 482 - 483 - dprintk("cmd %p scb %x result %d len %d bufflen %u %u %x\n", 484 - cmd, cmd->cmnd[0], result, len, scsi_bufflen(cmd), 485 - rq_data_dir(rq), cmd->cmnd[0]); 486 - 487 - if (result == TASK_ABORTED) { 488 - scsi_tgt_abort_cmd(shost, cmd); 489 - goto done; 490 - } 491 - /* 492 - * store the userspace values here, the working values are 493 - * in the request_* values 494 - */ 495 - tcmd = cmd->request->end_io_data; 496 - cmd->result = result; 497 - 498 - if (cmd->result == SAM_STAT_CHECK_CONDITION) 499 - scsi_tgt_copy_sense(cmd, sense_uaddr, sense_len); 500 - 501 - if (len) { 502 - err = scsi_map_user_pages(rq->end_io_data, cmd, uaddr, len, rw); 503 - if (err) { 504 - /* 505 - * user-space daemon bugs or OOM 506 - * TODO: we can do better for OOM. 507 - */ 508 - struct scsi_tgt_queuedata *qdata; 509 - struct list_head *head; 510 - unsigned long flags; 511 - 512 - eprintk("cmd %p ret %d uaddr %lx len %d rw %d\n", 513 - cmd, err, uaddr, len, rw); 514 - 515 - qdata = shost->uspace_req_q->queuedata; 516 - head = &qdata->cmd_hash[cmd_hashfn(tcmd->tag)]; 517 - 518 - spin_lock_irqsave(&qdata->cmd_hash_lock, flags); 519 - list_add(&tcmd->hash_list, head); 520 - spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags); 521 - 522 - goto done; 523 - } 524 - } 525 - err = scsi_tgt_transfer_response(cmd); 526 - done: 527 - scsi_host_put(shost); 528 - return err; 529 - } 530 - 531 - int scsi_tgt_tsk_mgmt_request(struct Scsi_Host *shost, u64 itn_id, 532 - int function, u64 tag, struct scsi_lun *scsilun, 533 - void *data) 534 - { 535 - int err; 536 - 537 - /* TODO: need to retry if this fails. */ 538 - err = scsi_tgt_uspace_send_tsk_mgmt(shost->host_no, itn_id, 539 - function, tag, scsilun, data); 540 - if (err < 0) 541 - eprintk("The task management request lost!\n"); 542 - return err; 543 - } 544 - EXPORT_SYMBOL_GPL(scsi_tgt_tsk_mgmt_request); 545 - 546 - int scsi_tgt_kspace_tsk_mgmt(int host_no, u64 itn_id, u64 mid, int result) 547 - { 548 - struct Scsi_Host *shost; 549 - int err = -EINVAL; 550 - 551 - dprintk("%d %d %llx\n", host_no, result, (unsigned long long) mid); 552 - 553 - shost = scsi_host_lookup(host_no); 554 - if (!shost) { 555 - printk(KERN_ERR "Could not find host no %d\n", host_no); 556 - return err; 557 - } 558 - 559 - if (!shost->uspace_req_q) { 560 - printk(KERN_ERR "Not target scsi host %d\n", host_no); 561 - goto done; 562 - } 563 - 564 - err = shost->transportt->tsk_mgmt_response(shost, itn_id, mid, result); 565 - done: 566 - scsi_host_put(shost); 567 - return err; 568 - } 569 - 570 - int scsi_tgt_it_nexus_create(struct Scsi_Host *shost, u64 itn_id, 571 - char *initiator) 572 - { 573 - int err; 574 - 575 - /* TODO: need to retry if this fails. */ 576 - err = scsi_tgt_uspace_send_it_nexus_request(shost->host_no, itn_id, 0, 577 - initiator); 578 - if (err < 0) 579 - eprintk("The i_t_neuxs request lost, %d %llx!\n", 580 - shost->host_no, (unsigned long long)itn_id); 581 - return err; 582 - } 583 - EXPORT_SYMBOL_GPL(scsi_tgt_it_nexus_create); 584 - 585 - int scsi_tgt_it_nexus_destroy(struct Scsi_Host *shost, u64 itn_id) 586 - { 587 - int err; 588 - 589 - /* TODO: need to retry if this fails. */ 590 - err = scsi_tgt_uspace_send_it_nexus_request(shost->host_no, 591 - itn_id, 1, NULL); 592 - if (err < 0) 593 - eprintk("The i_t_neuxs request lost, %d %llx!\n", 594 - shost->host_no, (unsigned long long)itn_id); 595 - return err; 596 - } 597 - EXPORT_SYMBOL_GPL(scsi_tgt_it_nexus_destroy); 598 - 599 - int scsi_tgt_kspace_it_nexus_rsp(int host_no, u64 itn_id, int result) 600 - { 601 - struct Scsi_Host *shost; 602 - int err = -EINVAL; 603 - 604 - dprintk("%d %d%llx\n", host_no, result, (unsigned long long)itn_id); 605 - 606 - shost = scsi_host_lookup(host_no); 607 - if (!shost) { 608 - printk(KERN_ERR "Could not find host no %d\n", host_no); 609 - return err; 610 - } 611 - 612 - if (!shost->uspace_req_q) { 613 - printk(KERN_ERR "Not target scsi host %d\n", host_no); 614 - goto done; 615 - } 616 - 617 - err = shost->transportt->it_nexus_response(shost, itn_id, result); 618 - done: 619 - scsi_host_put(shost); 620 - return err; 621 - } 622 - 623 - static int __init scsi_tgt_init(void) 624 - { 625 - int err; 626 - 627 - scsi_tgt_cmd_cache = KMEM_CACHE(scsi_tgt_cmd, 0); 628 - if (!scsi_tgt_cmd_cache) 629 - return -ENOMEM; 630 - 631 - scsi_tgtd = alloc_workqueue("scsi_tgtd", 0, 1); 632 - if (!scsi_tgtd) { 633 - err = -ENOMEM; 634 - goto free_kmemcache; 635 - } 636 - 637 - err = scsi_tgt_if_init(); 638 - if (err) 639 - goto destroy_wq; 640 - 641 - return 0; 642 - 643 - destroy_wq: 644 - destroy_workqueue(scsi_tgtd); 645 - free_kmemcache: 646 - kmem_cache_destroy(scsi_tgt_cmd_cache); 647 - return err; 648 - } 649 - 650 - static void __exit scsi_tgt_exit(void) 651 - { 652 - destroy_workqueue(scsi_tgtd); 653 - scsi_tgt_if_exit(); 654 - kmem_cache_destroy(scsi_tgt_cmd_cache); 655 - } 656 - 657 - module_init(scsi_tgt_init); 658 - module_exit(scsi_tgt_exit); 659 - 660 - MODULE_DESCRIPTION("SCSI target core"); 661 - MODULE_LICENSE("GPL");
-32
drivers/scsi/scsi_tgt_priv.h
··· 1 - struct scsi_cmnd; 2 - struct scsi_lun; 3 - struct Scsi_Host; 4 - struct task_struct; 5 - 6 - /* tmp - will replace with SCSI logging stuff */ 7 - #define eprintk(fmt, args...) \ 8 - do { \ 9 - printk("%s(%d) " fmt, __func__, __LINE__, ##args); \ 10 - } while (0) 11 - 12 - #define dprintk(fmt, args...) 13 - /* #define dprintk eprintk */ 14 - 15 - extern void scsi_tgt_if_exit(void); 16 - extern int scsi_tgt_if_init(void); 17 - 18 - extern int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, u64 it_nexus_id, 19 - struct scsi_lun *lun, u64 tag); 20 - extern int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 it_nexus_id, 21 - u64 tag); 22 - extern int scsi_tgt_kspace_exec(int host_no, u64 it_nexus_id, int result, u64 tag, 23 - unsigned long uaddr, u32 len, 24 - unsigned long sense_uaddr, u32 sense_len, u8 rw); 25 - extern int scsi_tgt_uspace_send_tsk_mgmt(int host_no, u64 it_nexus_id, 26 - int function, u64 tag, 27 - struct scsi_lun *scsilun, void *data); 28 - extern int scsi_tgt_kspace_tsk_mgmt(int host_no, u64 it_nexus_id, 29 - u64 mid, int result); 30 - extern int scsi_tgt_uspace_send_it_nexus_request(int host_no, u64 it_nexus_id, 31 - int function, char *initiator); 32 - extern int scsi_tgt_kspace_it_nexus_rsp(int host_no, u64 it_nexus_id, int result);
-12
drivers/scsi/scsi_transport_fc.c
··· 39 39 #include <scsi/scsi_netlink_fc.h> 40 40 #include <scsi/scsi_bsg_fc.h> 41 41 #include "scsi_priv.h" 42 - #include "scsi_transport_fc_internal.h" 43 42 44 43 static int fc_queue_work(struct Scsi_Host *, struct work_struct *); 45 44 static void fc_vport_sched_delete(struct work_struct *work); ··· 3007 3008 3008 3009 spin_unlock_irqrestore(shost->host_lock, flags); 3009 3010 3010 - if (rport->roles & FC_PORT_ROLE_FCP_INITIATOR && 3011 - shost->active_mode & MODE_TARGET) 3012 - fc_tgt_it_nexus_destroy(shost, (unsigned long)rport); 3013 - 3014 3011 scsi_target_block(&rport->dev); 3015 3012 3016 3013 /* see if we need to kill io faster than waiting for device loss */ ··· 3047 3052 struct fc_host_attrs *fc_host = shost_to_fc_host(shost); 3048 3053 unsigned long flags; 3049 3054 int create = 0; 3050 - int ret; 3051 3055 3052 3056 spin_lock_irqsave(shost->host_lock, flags); 3053 3057 if (roles & FC_PORT_ROLE_FCP_TARGET) { ··· 3055 3061 create = 1; 3056 3062 } else if (!(rport->roles & FC_PORT_ROLE_FCP_TARGET)) 3057 3063 create = 1; 3058 - } else if (shost->active_mode & MODE_TARGET) { 3059 - ret = fc_tgt_it_nexus_create(shost, (unsigned long)rport, 3060 - (char *)&rport->node_name); 3061 - if (ret) 3062 - printk(KERN_ERR "FC Remore Port tgt nexus failed %d\n", 3063 - ret); 3064 3064 } 3065 3065 3066 3066 rport->roles = roles;
-26
drivers/scsi/scsi_transport_fc_internal.h
··· 1 - #include <scsi/scsi_tgt.h> 2 - 3 - #ifdef CONFIG_SCSI_FC_TGT_ATTRS 4 - static inline int fc_tgt_it_nexus_create(struct Scsi_Host *shost, u64 itn_id, 5 - char *initiator) 6 - { 7 - return scsi_tgt_it_nexus_create(shost, itn_id, initiator); 8 - } 9 - 10 - static inline int fc_tgt_it_nexus_destroy(struct Scsi_Host *shost, u64 itn_id) 11 - { 12 - return scsi_tgt_it_nexus_destroy(shost, itn_id); 13 - } 14 - #else 15 - static inline int fc_tgt_it_nexus_create(struct Scsi_Host *shost, u64 itn_id, 16 - char *initiator) 17 - { 18 - return 0; 19 - } 20 - 21 - static inline int fc_tgt_it_nexus_destroy(struct Scsi_Host *shost, u64 itn_id) 22 - { 23 - return 0; 24 - } 25 - 26 - #endif
-18
drivers/scsi/scsi_transport_srp.c
··· 33 33 #include <scsi/scsi_transport.h> 34 34 #include <scsi/scsi_transport_srp.h> 35 35 #include "scsi_priv.h" 36 - #include "scsi_transport_srp_internal.h" 37 36 38 37 struct srp_host_attrs { 39 38 atomic_t next_port_id; ··· 745 746 return ERR_PTR(ret); 746 747 } 747 748 748 - if (shost->active_mode & MODE_TARGET && 749 - ids->roles == SRP_RPORT_ROLE_INITIATOR) { 750 - ret = srp_tgt_it_nexus_create(shost, (unsigned long)rport, 751 - rport->port_id); 752 - if (ret) { 753 - device_del(&rport->dev); 754 - transport_destroy_device(&rport->dev); 755 - put_device(&rport->dev); 756 - return ERR_PTR(ret); 757 - } 758 - } 759 - 760 749 transport_add_device(&rport->dev); 761 750 transport_configure_device(&rport->dev); 762 751 ··· 761 774 void srp_rport_del(struct srp_rport *rport) 762 775 { 763 776 struct device *dev = &rport->dev; 764 - struct Scsi_Host *shost = dev_to_shost(dev->parent); 765 - 766 - if (shost->active_mode & MODE_TARGET && 767 - rport->roles == SRP_RPORT_ROLE_INITIATOR) 768 - srp_tgt_it_nexus_destroy(shost, (unsigned long)rport); 769 777 770 778 transport_remove_device(dev); 771 779 device_del(dev);
-25
drivers/scsi/scsi_transport_srp_internal.h
··· 1 - #include <scsi/scsi_tgt.h> 2 - 3 - #ifdef CONFIG_SCSI_SRP_TGT_ATTRS 4 - static inline int srp_tgt_it_nexus_create(struct Scsi_Host *shost, u64 itn_id, 5 - char *initiator) 6 - { 7 - return scsi_tgt_it_nexus_create(shost, itn_id, initiator); 8 - } 9 - 10 - static inline int srp_tgt_it_nexus_destroy(struct Scsi_Host *shost, u64 itn_id) 11 - { 12 - return scsi_tgt_it_nexus_destroy(shost, itn_id); 13 - } 14 - 15 - #else 16 - static inline int srp_tgt_it_nexus_create(struct Scsi_Host *shost, u64 itn_id, 17 - char *initiator) 18 - { 19 - return 0; 20 - } 21 - static inline int srp_tgt_it_nexus_destroy(struct Scsi_Host *shost, u64 itn_id) 22 - { 23 - return 0; 24 - } 25 - #endif
-21
include/scsi/scsi_host.h
··· 132 132 int (* queuecommand)(struct Scsi_Host *, struct scsi_cmnd *); 133 133 134 134 /* 135 - * The transfer functions are used to queue a scsi command to 136 - * the LLD. When the driver is finished processing the command 137 - * the done callback is invoked. 138 - * 139 - * This is called to inform the LLD to transfer 140 - * scsi_bufflen(cmd) bytes. scsi_sg_count(cmd) speciefies the 141 - * number of scatterlist entried in the command and 142 - * scsi_sglist(cmd) returns the scatterlist. 143 - * 144 - * return values: see queuecommand 145 - * 146 - * If the LLD accepts the cmd, it should set the result to an 147 - * appropriate value when completed before calling the done function. 148 - * 149 - * STATUS: REQUIRED FOR TARGET DRIVERS 150 - */ 151 - /* TODO: rename */ 152 - int (* transfer_response)(struct scsi_cmnd *, 153 - void (*done)(struct scsi_cmnd *)); 154 - 155 - /* 156 135 * This is an error handling strategy routine. You don't need to 157 136 * define one of these if you don't want to - there is a default 158 137 * routine that is present that should work in most cases. For those
-21
include/scsi/scsi_tgt.h
··· 1 - /* 2 - * SCSI target definitions 3 - */ 4 - 5 - #include <linux/dma-mapping.h> 6 - 7 - struct Scsi_Host; 8 - struct scsi_cmnd; 9 - struct scsi_lun; 10 - 11 - extern struct Scsi_Host *scsi_tgt_cmd_to_host(struct scsi_cmnd *); 12 - extern int scsi_tgt_alloc_queue(struct Scsi_Host *); 13 - extern void scsi_tgt_free_queue(struct Scsi_Host *); 14 - extern int scsi_tgt_queue_command(struct scsi_cmnd *, u64, struct scsi_lun *, u64); 15 - extern int scsi_tgt_tsk_mgmt_request(struct Scsi_Host *, u64, int, u64, 16 - struct scsi_lun *, void *); 17 - extern struct scsi_cmnd *scsi_host_get_command(struct Scsi_Host *, 18 - enum dma_data_direction, gfp_t); 19 - extern void scsi_host_put_command(struct Scsi_Host *, struct scsi_cmnd *); 20 - extern int scsi_tgt_it_nexus_create(struct Scsi_Host *, u64, char *); 21 - extern int scsi_tgt_it_nexus_destroy(struct Scsi_Host *, u64);
-108
include/scsi/scsi_tgt_if.h
··· 1 - /* 2 - * SCSI target kernel/user interface 3 - * 4 - * Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org> 5 - * Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu> 6 - * 7 - * This program is free software; you can redistribute it and/or 8 - * modify it under the terms of the GNU General Public License as 9 - * published by the Free Software Foundation; either version 2 of the 10 - * License, or (at your option) any later version. 11 - * 12 - * This program is distributed in the hope that it will be useful, but 13 - * WITHOUT ANY WARRANTY; without even the implied warranty of 14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 - * General Public License for more details. 16 - * 17 - * You should have received a copy of the GNU General Public License 18 - * along with this program; if not, write to the Free Software 19 - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 20 - * 02110-1301 USA 21 - */ 22 - #ifndef __SCSI_TARGET_IF_H 23 - #define __SCSI_TARGET_IF_H 24 - 25 - /* user -> kernel */ 26 - #define TGT_UEVENT_CMD_RSP 0x0001 27 - #define TGT_UEVENT_IT_NEXUS_RSP 0x0002 28 - #define TGT_UEVENT_TSK_MGMT_RSP 0x0003 29 - 30 - /* kernel -> user */ 31 - #define TGT_KEVENT_CMD_REQ 0x1001 32 - #define TGT_KEVENT_CMD_DONE 0x1002 33 - #define TGT_KEVENT_IT_NEXUS_REQ 0x1003 34 - #define TGT_KEVENT_TSK_MGMT_REQ 0x1004 35 - 36 - struct tgt_event_hdr { 37 - uint16_t version; 38 - uint16_t status; 39 - uint16_t type; 40 - uint16_t len; 41 - } __attribute__ ((aligned (sizeof(uint64_t)))); 42 - 43 - struct tgt_event { 44 - struct tgt_event_hdr hdr; 45 - 46 - union { 47 - /* user-> kernel */ 48 - struct { 49 - int host_no; 50 - int result; 51 - aligned_u64 itn_id; 52 - aligned_u64 tag; 53 - aligned_u64 uaddr; 54 - aligned_u64 sense_uaddr; 55 - uint32_t len; 56 - uint32_t sense_len; 57 - uint8_t rw; 58 - } cmd_rsp; 59 - struct { 60 - int host_no; 61 - int result; 62 - aligned_u64 itn_id; 63 - aligned_u64 mid; 64 - } tsk_mgmt_rsp; 65 - struct { 66 - __s32 host_no; 67 - __s32 result; 68 - aligned_u64 itn_id; 69 - __u32 function; 70 - } it_nexus_rsp; 71 - 72 - /* kernel -> user */ 73 - struct { 74 - int host_no; 75 - uint32_t data_len; 76 - aligned_u64 itn_id; 77 - uint8_t scb[16]; 78 - uint8_t lun[8]; 79 - int attribute; 80 - aligned_u64 tag; 81 - } cmd_req; 82 - struct { 83 - int host_no; 84 - int result; 85 - aligned_u64 itn_id; 86 - aligned_u64 tag; 87 - } cmd_done; 88 - struct { 89 - int host_no; 90 - int function; 91 - aligned_u64 itn_id; 92 - aligned_u64 tag; 93 - uint8_t lun[8]; 94 - aligned_u64 mid; 95 - } tsk_mgmt_req; 96 - struct { 97 - __s32 host_no; 98 - __u32 function; 99 - aligned_u64 itn_id; 100 - __u32 max_cmds; 101 - __u8 initiator_id[16]; 102 - } it_nexus_req; 103 - } p; 104 - } __attribute__ ((aligned (sizeof(uint64_t)))); 105 - 106 - #define TGT_RING_SIZE (1UL << 16) 107 - 108 - #endif