1 /*******************************************************************************
2 * Filename: target_core_pscsi.c
4 * This file contains the generic target mode <-> Linux SCSI subsystem plugin.
6 * Copyright (c) 2003, 2004, 2005 PyX Technologies, Inc.
7 * Copyright (c) 2005, 2006, 2007 SBE, Inc.
8 * Copyright (c) 2007-2010 Rising Tide Systems
9 * Copyright (c) 2008-2010 Linux-iSCSI.org
11 * Nicholas A. Bellinger <nab@kernel.org>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ******************************************************************************/
29 #include <linux/version.h>
30 #include <linux/string.h>
31 #include <linux/parser.h>
32 #include <linux/timer.h>
33 #include <linux/blkdev.h>
34 #include <linux/blk_types.h>
35 #include <linux/slab.h>
36 #include <linux/spinlock.h>
37 #include <linux/genhd.h>
38 #include <linux/cdrom.h>
39 #include <linux/file.h>
40 #include <scsi/scsi.h>
41 #include <scsi/scsi_device.h>
42 #include <scsi/scsi_cmnd.h>
43 #include <scsi/scsi_host.h>
44 #include <scsi/libsas.h> /* For TASK_ATTR_* */
46 #include <target/target_core_base.h>
47 #include <target/target_core_device.h>
48 #include <target/target_core_transport.h>
50 #include "target_core_pscsi.h"
52 #define ISPRINT(a) ((a >= ' ') && (a <= '~'))
54 static struct se_subsystem_api pscsi_template
;
56 static void pscsi_req_done(struct request
*, int);
62 static struct Scsi_Host
*pscsi_get_sh(u32 host_no
)
64 struct Scsi_Host
*sh
= NULL
;
66 sh
= scsi_host_lookup(host_no
);
68 printk(KERN_ERR
"Unable to locate SCSI HBA with Host ID:"
76 /* pscsi_attach_hba():
78 * pscsi_get_sh() used scsi_host_lookup() to locate struct Scsi_Host.
79 * from the passed SCSI Host ID.
81 static int pscsi_attach_hba(struct se_hba
*hba
, u32 host_id
)
84 struct pscsi_hba_virt
*phv
;
86 phv
= kzalloc(sizeof(struct pscsi_hba_virt
), GFP_KERNEL
);
88 printk(KERN_ERR
"Unable to allocate struct pscsi_hba_virt\n");
91 phv
->phv_host_id
= host_id
;
92 phv
->phv_mode
= PHV_VIRUTAL_HOST_ID
;
93 hba_depth
= PSCSI_VIRTUAL_HBA_DEPTH
;
94 atomic_set(&hba
->left_queue_depth
, hba_depth
);
95 atomic_set(&hba
->max_queue_depth
, hba_depth
);
97 hba
->hba_ptr
= (void *)phv
;
99 printk(KERN_INFO
"CORE_HBA[%d] - TCM SCSI HBA Driver %s on"
100 " Generic Target Core Stack %s\n", hba
->hba_id
,
101 PSCSI_VERSION
, TARGET_CORE_MOD_VERSION
);
102 printk(KERN_INFO
"CORE_HBA[%d] - Attached SCSI HBA to Generic"
103 " Target Core with TCQ Depth: %d\n", hba
->hba_id
,
104 atomic_read(&hba
->max_queue_depth
));
109 static void pscsi_detach_hba(struct se_hba
*hba
)
111 struct pscsi_hba_virt
*phv
= hba
->hba_ptr
;
112 struct Scsi_Host
*scsi_host
= phv
->phv_lld_host
;
115 scsi_host_put(scsi_host
);
117 printk(KERN_INFO
"CORE_HBA[%d] - Detached SCSI HBA: %s from"
118 " Generic Target Core\n", hba
->hba_id
,
119 (scsi_host
->hostt
->name
) ? (scsi_host
->hostt
->name
) :
122 printk(KERN_INFO
"CORE_HBA[%d] - Detached Virtual SCSI HBA"
123 " from Generic Target Core\n", hba
->hba_id
);
129 static int pscsi_pmode_enable_hba(struct se_hba
*hba
, unsigned long mode_flag
)
131 struct pscsi_hba_virt
*phv
= (struct pscsi_hba_virt
*)hba
->hba_ptr
;
132 struct Scsi_Host
*sh
= phv
->phv_lld_host
;
133 int hba_depth
= PSCSI_VIRTUAL_HBA_DEPTH
;
135 * Release the struct Scsi_Host
141 phv
->phv_lld_host
= NULL
;
142 phv
->phv_mode
= PHV_VIRUTAL_HOST_ID
;
143 atomic_set(&hba
->left_queue_depth
, hba_depth
);
144 atomic_set(&hba
->max_queue_depth
, hba_depth
);
146 printk(KERN_INFO
"CORE_HBA[%d] - Disabled pSCSI HBA Passthrough"
147 " %s\n", hba
->hba_id
, (sh
->hostt
->name
) ?
148 (sh
->hostt
->name
) : "Unknown");
154 * Otherwise, locate struct Scsi_Host from the original passed
155 * pSCSI Host ID and enable for phba mode
157 sh
= pscsi_get_sh(phv
->phv_host_id
);
159 printk(KERN_ERR
"pSCSI: Unable to locate SCSI Host for"
160 " phv_host_id: %d\n", phv
->phv_host_id
);
164 * Usually the SCSI LLD will use the hostt->can_queue value to define
165 * its HBA TCQ depth. Some other drivers (like 2.6 megaraid) don't set
166 * this at all and set sh->can_queue at runtime.
168 hba_depth
= (sh
->hostt
->can_queue
> sh
->can_queue
) ?
169 sh
->hostt
->can_queue
: sh
->can_queue
;
171 atomic_set(&hba
->left_queue_depth
, hba_depth
);
172 atomic_set(&hba
->max_queue_depth
, hba_depth
);
174 phv
->phv_lld_host
= sh
;
175 phv
->phv_mode
= PHV_LLD_SCSI_HOST_NO
;
177 printk(KERN_INFO
"CORE_HBA[%d] - Enabled pSCSI HBA Passthrough %s\n",
178 hba
->hba_id
, (sh
->hostt
->name
) ? (sh
->hostt
->name
) : "Unknown");
183 static void pscsi_tape_read_blocksize(struct se_device
*dev
,
184 struct scsi_device
*sdev
)
186 unsigned char cdb
[MAX_COMMAND_SIZE
], *buf
;
189 buf
= kzalloc(12, GFP_KERNEL
);
193 memset(cdb
, 0, MAX_COMMAND_SIZE
);
195 cdb
[4] = 0x0c; /* 12 bytes */
197 ret
= scsi_execute_req(sdev
, cdb
, DMA_FROM_DEVICE
, buf
, 12, NULL
,
203 * If MODE_SENSE still returns zero, set the default value to 1024.
205 sdev
->sector_size
= (buf
[9] << 16) | (buf
[10] << 8) | (buf
[11]);
206 if (!sdev
->sector_size
)
207 sdev
->sector_size
= 1024;
213 pscsi_set_inquiry_info(struct scsi_device
*sdev
, struct t10_wwn
*wwn
)
217 if (sdev
->inquiry_len
< INQUIRY_LEN
)
224 * Use sdev->inquiry from drivers/scsi/scsi_scan.c:scsi_alloc_sdev()
226 memcpy(&wwn
->vendor
[0], &buf
[8], sizeof(wwn
->vendor
));
227 memcpy(&wwn
->model
[0], &buf
[16], sizeof(wwn
->model
));
228 memcpy(&wwn
->revision
[0], &buf
[32], sizeof(wwn
->revision
));
232 pscsi_get_inquiry_vpd_serial(struct scsi_device
*sdev
, struct t10_wwn
*wwn
)
234 unsigned char cdb
[MAX_COMMAND_SIZE
], *buf
;
237 buf
= kzalloc(INQUIRY_VPD_SERIAL_LEN
, GFP_KERNEL
);
241 memset(cdb
, 0, MAX_COMMAND_SIZE
);
243 cdb
[1] = 0x01; /* Query VPD */
244 cdb
[2] = 0x80; /* Unit Serial Number */
245 cdb
[3] = (INQUIRY_VPD_SERIAL_LEN
>> 8) & 0xff;
246 cdb
[4] = (INQUIRY_VPD_SERIAL_LEN
& 0xff);
248 ret
= scsi_execute_req(sdev
, cdb
, DMA_FROM_DEVICE
, buf
,
249 INQUIRY_VPD_SERIAL_LEN
, NULL
, HZ
, 1, NULL
);
253 snprintf(&wwn
->unit_serial
[0], INQUIRY_VPD_SERIAL_LEN
, "%s", &buf
[4]);
255 wwn
->t10_sub_dev
->su_dev_flags
|= SDF_FIRMWARE_VPD_UNIT_SERIAL
;
266 pscsi_get_inquiry_vpd_device_ident(struct scsi_device
*sdev
,
269 unsigned char cdb
[MAX_COMMAND_SIZE
], *buf
, *page_83
;
270 int ident_len
, page_len
, off
= 4, ret
;
273 buf
= kzalloc(INQUIRY_VPD_SERIAL_LEN
, GFP_KERNEL
);
277 memset(cdb
, 0, MAX_COMMAND_SIZE
);
279 cdb
[1] = 0x01; /* Query VPD */
280 cdb
[2] = 0x83; /* Device Identifier */
281 cdb
[3] = (INQUIRY_VPD_DEVICE_IDENTIFIER_LEN
>> 8) & 0xff;
282 cdb
[4] = (INQUIRY_VPD_DEVICE_IDENTIFIER_LEN
& 0xff);
284 ret
= scsi_execute_req(sdev
, cdb
, DMA_FROM_DEVICE
, buf
,
285 INQUIRY_VPD_DEVICE_IDENTIFIER_LEN
,
290 page_len
= (buf
[2] << 8) | buf
[3];
291 while (page_len
> 0) {
292 /* Grab a pointer to the Identification descriptor */
294 ident_len
= page_83
[3];
296 printk(KERN_ERR
"page_83[3]: identifier"
300 printk(KERN_INFO
"T10 VPD Identifer Length: %d\n", ident_len
);
302 vpd
= kzalloc(sizeof(struct t10_vpd
), GFP_KERNEL
);
304 printk(KERN_ERR
"Unable to allocate memory for"
305 " struct t10_vpd\n");
308 INIT_LIST_HEAD(&vpd
->vpd_list
);
310 transport_set_vpd_proto_id(vpd
, page_83
);
311 transport_set_vpd_assoc(vpd
, page_83
);
313 if (transport_set_vpd_ident_type(vpd
, page_83
) < 0) {
314 off
+= (ident_len
+ 4);
315 page_len
-= (ident_len
+ 4);
319 if (transport_set_vpd_ident(vpd
, page_83
) < 0) {
320 off
+= (ident_len
+ 4);
321 page_len
-= (ident_len
+ 4);
326 list_add_tail(&vpd
->vpd_list
, &wwn
->t10_vpd_list
);
327 off
+= (ident_len
+ 4);
328 page_len
-= (ident_len
+ 4);
335 /* pscsi_add_device_to_list():
339 static struct se_device
*pscsi_add_device_to_list(
341 struct se_subsystem_dev
*se_dev
,
342 struct pscsi_dev_virt
*pdv
,
343 struct scsi_device
*sd
,
346 struct se_device
*dev
;
347 struct se_dev_limits dev_limits
;
348 struct request_queue
*q
;
349 struct queue_limits
*limits
;
351 memset(&dev_limits
, 0, sizeof(struct se_dev_limits
));
353 if (!sd
->queue_depth
) {
354 sd
->queue_depth
= PSCSI_DEFAULT_QUEUEDEPTH
;
356 printk(KERN_ERR
"Set broken SCSI Device %d:%d:%d"
357 " queue_depth to %d\n", sd
->channel
, sd
->id
,
358 sd
->lun
, sd
->queue_depth
);
361 * Setup the local scope queue_limits from struct request_queue->limits
362 * to pass into transport_add_device_to_core_hba() as struct se_dev_limits.
364 q
= sd
->request_queue
;
365 limits
= &dev_limits
.limits
;
366 limits
->logical_block_size
= sd
->sector_size
;
367 limits
->max_hw_sectors
= (sd
->host
->max_sectors
> queue_max_hw_sectors(q
)) ?
368 queue_max_hw_sectors(q
) : sd
->host
->max_sectors
;
369 limits
->max_sectors
= (sd
->host
->max_sectors
> queue_max_sectors(q
)) ?
370 queue_max_sectors(q
) : sd
->host
->max_sectors
;
371 dev_limits
.hw_queue_depth
= sd
->queue_depth
;
372 dev_limits
.queue_depth
= sd
->queue_depth
;
374 * Setup our standard INQUIRY info into se_dev->t10_wwn
376 pscsi_set_inquiry_info(sd
, &se_dev
->t10_wwn
);
379 * Set the pointer pdv->pdv_sd to from passed struct scsi_device,
380 * which has already been referenced with Linux SCSI code with
381 * scsi_device_get() in this file's pscsi_create_virtdevice().
383 * The passthrough operations called by the transport_add_device_*
384 * function below will require this pointer to be set for passthroug
387 * For the shutdown case in pscsi_free_device(), this struct
388 * scsi_device reference is released with Linux SCSI code
389 * scsi_device_put() and the pdv->pdv_sd cleared.
393 dev
= transport_add_device_to_core_hba(hba
, &pscsi_template
,
394 se_dev
, dev_flags
, (void *)pdv
,
395 &dev_limits
, NULL
, NULL
);
402 * Locate VPD WWN Information used for various purposes within
403 * the Storage Engine.
405 if (!pscsi_get_inquiry_vpd_serial(sd
, &se_dev
->t10_wwn
)) {
407 * If VPD Unit Serial returned GOOD status, try
408 * VPD Device Identification page (0x83).
410 pscsi_get_inquiry_vpd_device_ident(sd
, &se_dev
->t10_wwn
);
414 * For TYPE_TAPE, attempt to determine blocksize with MODE_SENSE.
416 if (sd
->type
== TYPE_TAPE
)
417 pscsi_tape_read_blocksize(dev
, sd
);
421 static void *pscsi_allocate_virtdevice(struct se_hba
*hba
, const char *name
)
423 struct pscsi_dev_virt
*pdv
;
425 pdv
= kzalloc(sizeof(struct pscsi_dev_virt
), GFP_KERNEL
);
427 printk(KERN_ERR
"Unable to allocate memory for struct pscsi_dev_virt\n");
430 pdv
->pdv_se_hba
= hba
;
432 printk(KERN_INFO
"PSCSI: Allocated pdv: %p for %s\n", pdv
, name
);
437 * Called with struct Scsi_Host->host_lock called.
439 static struct se_device
*pscsi_create_type_disk(
440 struct scsi_device
*sd
,
441 struct pscsi_dev_virt
*pdv
,
442 struct se_subsystem_dev
*se_dev
,
445 struct se_device
*dev
;
446 struct pscsi_hba_virt
*phv
= (struct pscsi_hba_virt
*)pdv
->pdv_se_hba
->hba_ptr
;
447 struct Scsi_Host
*sh
= sd
->host
;
448 struct block_device
*bd
;
451 if (scsi_device_get(sd
)) {
452 printk(KERN_ERR
"scsi_device_get() failed for %d:%d:%d:%d\n",
453 sh
->host_no
, sd
->channel
, sd
->id
, sd
->lun
);
454 spin_unlock_irq(sh
->host_lock
);
457 spin_unlock_irq(sh
->host_lock
);
459 * Claim exclusive struct block_device access to struct scsi_device
460 * for TYPE_DISK using supplied udev_path
462 bd
= blkdev_get_by_path(se_dev
->se_dev_udev_path
,
463 FMODE_WRITE
|FMODE_READ
|FMODE_EXCL
, pdv
);
465 printk(KERN_ERR
"pSCSI: blkdev_get_by_path() failed\n");
471 dev
= pscsi_add_device_to_list(hba
, se_dev
, pdv
, sd
, dev_flags
);
473 blkdev_put(pdv
->pdv_bd
, FMODE_WRITE
|FMODE_READ
|FMODE_EXCL
);
477 printk(KERN_INFO
"CORE_PSCSI[%d] - Added TYPE_DISK for %d:%d:%d:%d\n",
478 phv
->phv_host_id
, sh
->host_no
, sd
->channel
, sd
->id
, sd
->lun
);
484 * Called with struct Scsi_Host->host_lock called.
486 static struct se_device
*pscsi_create_type_rom(
487 struct scsi_device
*sd
,
488 struct pscsi_dev_virt
*pdv
,
489 struct se_subsystem_dev
*se_dev
,
492 struct se_device
*dev
;
493 struct pscsi_hba_virt
*phv
= (struct pscsi_hba_virt
*)pdv
->pdv_se_hba
->hba_ptr
;
494 struct Scsi_Host
*sh
= sd
->host
;
497 if (scsi_device_get(sd
)) {
498 printk(KERN_ERR
"scsi_device_get() failed for %d:%d:%d:%d\n",
499 sh
->host_no
, sd
->channel
, sd
->id
, sd
->lun
);
500 spin_unlock_irq(sh
->host_lock
);
503 spin_unlock_irq(sh
->host_lock
);
505 dev
= pscsi_add_device_to_list(hba
, se_dev
, pdv
, sd
, dev_flags
);
510 printk(KERN_INFO
"CORE_PSCSI[%d] - Added Type: %s for %d:%d:%d:%d\n",
511 phv
->phv_host_id
, scsi_device_type(sd
->type
), sh
->host_no
,
512 sd
->channel
, sd
->id
, sd
->lun
);
518 *Called with struct Scsi_Host->host_lock called.
520 static struct se_device
*pscsi_create_type_other(
521 struct scsi_device
*sd
,
522 struct pscsi_dev_virt
*pdv
,
523 struct se_subsystem_dev
*se_dev
,
526 struct se_device
*dev
;
527 struct pscsi_hba_virt
*phv
= (struct pscsi_hba_virt
*)pdv
->pdv_se_hba
->hba_ptr
;
528 struct Scsi_Host
*sh
= sd
->host
;
531 spin_unlock_irq(sh
->host_lock
);
532 dev
= pscsi_add_device_to_list(hba
, se_dev
, pdv
, sd
, dev_flags
);
536 printk(KERN_INFO
"CORE_PSCSI[%d] - Added Type: %s for %d:%d:%d:%d\n",
537 phv
->phv_host_id
, scsi_device_type(sd
->type
), sh
->host_no
,
538 sd
->channel
, sd
->id
, sd
->lun
);
543 static struct se_device
*pscsi_create_virtdevice(
545 struct se_subsystem_dev
*se_dev
,
548 struct pscsi_dev_virt
*pdv
= (struct pscsi_dev_virt
*)p
;
549 struct se_device
*dev
;
550 struct scsi_device
*sd
;
551 struct pscsi_hba_virt
*phv
= (struct pscsi_hba_virt
*)hba
->hba_ptr
;
552 struct Scsi_Host
*sh
= phv
->phv_lld_host
;
553 int legacy_mode_enable
= 0;
556 printk(KERN_ERR
"Unable to locate struct pscsi_dev_virt"
561 * If not running in PHV_LLD_SCSI_HOST_NO mode, locate the
562 * struct Scsi_Host we will need to bring the TCM/pSCSI object online
565 if (phv
->phv_mode
== PHV_LLD_SCSI_HOST_NO
) {
566 printk(KERN_ERR
"pSCSI: Unable to locate struct"
567 " Scsi_Host for PHV_LLD_SCSI_HOST_NO\n");
571 * For the newer PHV_VIRUTAL_HOST_ID struct scsi_device
572 * reference, we enforce that udev_path has been set
574 if (!(se_dev
->su_dev_flags
& SDF_USING_UDEV_PATH
)) {
575 printk(KERN_ERR
"pSCSI: udev_path attribute has not"
576 " been set before ENABLE=1\n");
580 * If no scsi_host_id= was passed for PHV_VIRUTAL_HOST_ID,
581 * use the original TCM hba ID to reference Linux/SCSI Host No
582 * and enable for PHV_LLD_SCSI_HOST_NO mode.
584 if (!(pdv
->pdv_flags
& PDF_HAS_VIRT_HOST_ID
)) {
585 spin_lock(&hba
->device_lock
);
586 if (!(list_empty(&hba
->hba_dev_list
))) {
587 printk(KERN_ERR
"pSCSI: Unable to set hba_mode"
588 " with active devices\n");
589 spin_unlock(&hba
->device_lock
);
592 spin_unlock(&hba
->device_lock
);
594 if (pscsi_pmode_enable_hba(hba
, 1) != 1)
597 legacy_mode_enable
= 1;
598 hba
->hba_flags
|= HBA_FLAGS_PSCSI_MODE
;
599 sh
= phv
->phv_lld_host
;
601 sh
= pscsi_get_sh(pdv
->pdv_host_id
);
603 printk(KERN_ERR
"pSCSI: Unable to locate"
604 " pdv_host_id: %d\n", pdv
->pdv_host_id
);
609 if (phv
->phv_mode
== PHV_VIRUTAL_HOST_ID
) {
610 printk(KERN_ERR
"pSCSI: PHV_VIRUTAL_HOST_ID set while"
611 " struct Scsi_Host exists\n");
616 spin_lock_irq(sh
->host_lock
);
617 list_for_each_entry(sd
, &sh
->__devices
, siblings
) {
618 if ((pdv
->pdv_channel_id
!= sd
->channel
) ||
619 (pdv
->pdv_target_id
!= sd
->id
) ||
620 (pdv
->pdv_lun_id
!= sd
->lun
))
623 * Functions will release the held struct scsi_host->host_lock
624 * before calling calling pscsi_add_device_to_list() to register
625 * struct scsi_device with target_core_mod.
629 dev
= pscsi_create_type_disk(sd
, pdv
, se_dev
, hba
);
632 dev
= pscsi_create_type_rom(sd
, pdv
, se_dev
, hba
);
635 dev
= pscsi_create_type_other(sd
, pdv
, se_dev
, hba
);
640 if (phv
->phv_mode
== PHV_VIRUTAL_HOST_ID
)
642 else if (legacy_mode_enable
) {
643 pscsi_pmode_enable_hba(hba
, 0);
644 hba
->hba_flags
&= ~HBA_FLAGS_PSCSI_MODE
;
651 spin_unlock_irq(sh
->host_lock
);
653 printk(KERN_ERR
"pSCSI: Unable to locate %d:%d:%d:%d\n", sh
->host_no
,
654 pdv
->pdv_channel_id
, pdv
->pdv_target_id
, pdv
->pdv_lun_id
);
656 if (phv
->phv_mode
== PHV_VIRUTAL_HOST_ID
)
658 else if (legacy_mode_enable
) {
659 pscsi_pmode_enable_hba(hba
, 0);
660 hba
->hba_flags
&= ~HBA_FLAGS_PSCSI_MODE
;
666 /* pscsi_free_device(): (Part of se_subsystem_api_t template)
670 static void pscsi_free_device(void *p
)
672 struct pscsi_dev_virt
*pdv
= p
;
673 struct pscsi_hba_virt
*phv
= pdv
->pdv_se_hba
->hba_ptr
;
674 struct scsi_device
*sd
= pdv
->pdv_sd
;
678 * Release exclusive pSCSI internal struct block_device claim for
679 * struct scsi_device with TYPE_DISK from pscsi_create_type_disk()
681 if ((sd
->type
== TYPE_DISK
) && pdv
->pdv_bd
) {
682 blkdev_put(pdv
->pdv_bd
,
683 FMODE_WRITE
|FMODE_READ
|FMODE_EXCL
);
687 * For HBA mode PHV_LLD_SCSI_HOST_NO, release the reference
688 * to struct Scsi_Host now.
690 if ((phv
->phv_mode
== PHV_LLD_SCSI_HOST_NO
) &&
691 (phv
->phv_lld_host
!= NULL
))
692 scsi_host_put(phv
->phv_lld_host
);
694 if ((sd
->type
== TYPE_DISK
) || (sd
->type
== TYPE_ROM
))
703 static inline struct pscsi_plugin_task
*PSCSI_TASK(struct se_task
*task
)
705 return container_of(task
, struct pscsi_plugin_task
, pscsi_task
);
709 /* pscsi_transport_complete():
713 static int pscsi_transport_complete(struct se_task
*task
)
715 struct pscsi_dev_virt
*pdv
= task
->se_dev
->dev_ptr
;
716 struct scsi_device
*sd
= pdv
->pdv_sd
;
718 struct pscsi_plugin_task
*pt
= PSCSI_TASK(task
);
719 unsigned char *cdb
= &pt
->pscsi_cdb
[0];
721 result
= pt
->pscsi_result
;
723 * Hack to make sure that Write-Protect modepage is set if R/O mode is
726 if (((cdb
[0] == MODE_SENSE
) || (cdb
[0] == MODE_SENSE_10
)) &&
727 (status_byte(result
) << 1) == SAM_STAT_GOOD
) {
728 if (!TASK_CMD(task
)->se_deve
)
729 goto after_mode_sense
;
731 if (TASK_CMD(task
)->se_deve
->lun_flags
&
732 TRANSPORT_LUNFLAGS_READ_ONLY
) {
733 unsigned char *buf
= (unsigned char *)
734 T_TASK(task
->task_se_cmd
)->t_task_buf
;
736 if (cdb
[0] == MODE_SENSE_10
) {
737 if (!(buf
[3] & 0x80))
740 if (!(buf
[2] & 0x80))
747 if (sd
->type
!= TYPE_TAPE
)
748 goto after_mode_select
;
751 * Hack to correctly obtain the initiator requested blocksize for
752 * TYPE_TAPE. Since this value is dependent upon each tape media,
753 * struct scsi_device->sector_size will not contain the correct value
754 * by default, so we go ahead and set it so
755 * TRANSPORT(dev)->get_blockdev() returns the correct value to the
758 if (((cdb
[0] == MODE_SELECT
) || (cdb
[0] == MODE_SELECT_10
)) &&
759 (status_byte(result
) << 1) == SAM_STAT_GOOD
) {
761 struct scatterlist
*sg
= task
->task_sg
;
765 buf
= sg_virt(&sg
[0]);
767 printk(KERN_ERR
"Unable to get buf for scatterlist\n");
768 goto after_mode_select
;
771 if (cdb
[0] == MODE_SELECT
)
774 bdl
= (buf
[6] << 8) | (buf
[7]);
777 goto after_mode_select
;
779 if (cdb
[0] == MODE_SELECT
)
780 blocksize
= (buf
[9] << 16) | (buf
[10] << 8) |
783 blocksize
= (buf
[13] << 16) | (buf
[14] << 8) |
786 sd
->sector_size
= blocksize
;
790 if (status_byte(result
) & CHECK_CONDITION
)
796 static struct se_task
*
797 pscsi_alloc_task(struct se_cmd
*cmd
)
799 struct pscsi_plugin_task
*pt
;
800 unsigned char *cdb
= T_TASK(cmd
)->t_task_cdb
;
802 pt
= kzalloc(sizeof(struct pscsi_plugin_task
), GFP_KERNEL
);
804 printk(KERN_ERR
"Unable to allocate struct pscsi_plugin_task\n");
809 * If TCM Core is signaling a > TCM_MAX_COMMAND_SIZE allocation,
810 * allocate the extended CDB buffer for per struct se_task context
813 if (T_TASK(cmd
)->t_task_cdb
!= T_TASK(cmd
)->__t_task_cdb
) {
815 pt
->pscsi_cdb
= kzalloc(scsi_command_size(cdb
), GFP_KERNEL
);
816 if (!(pt
->pscsi_cdb
)) {
817 printk(KERN_ERR
"pSCSI: Unable to allocate extended"
822 pt
->pscsi_cdb
= &pt
->__pscsi_cdb
[0];
824 return &pt
->pscsi_task
;
827 static inline void pscsi_blk_init_request(
828 struct se_task
*task
,
829 struct pscsi_plugin_task
*pt
,
834 * Defined as "scsi command" in include/linux/blkdev.h.
836 req
->cmd_type
= REQ_TYPE_BLOCK_PC
;
838 * For the extra BIDI-COMMAND READ struct request we do not
839 * need to setup the remaining structure members
844 * Setup the done function pointer for struct request,
845 * also set the end_io_data pointer.to struct se_task.
847 req
->end_io
= pscsi_req_done
;
848 req
->end_io_data
= (void *)task
;
850 * Load the referenced struct se_task's SCSI CDB into
851 * include/linux/blkdev.h:struct request->cmd
853 req
->cmd_len
= scsi_command_size(pt
->pscsi_cdb
);
854 req
->cmd
= &pt
->pscsi_cdb
[0];
856 * Setup pointer for outgoing sense data.
858 req
->sense
= (void *)&pt
->pscsi_sense
[0];
863 * Used for pSCSI data payloads for all *NON* SCF_SCSI_DATA_SG_IO_CDB
865 static int pscsi_blk_get_request(struct se_task
*task
)
867 struct pscsi_plugin_task
*pt
= PSCSI_TASK(task
);
868 struct pscsi_dev_virt
*pdv
= task
->se_dev
->dev_ptr
;
870 pt
->pscsi_req
= blk_get_request(pdv
->pdv_sd
->request_queue
,
871 (task
->task_data_direction
== DMA_TO_DEVICE
),
873 if (!(pt
->pscsi_req
) || IS_ERR(pt
->pscsi_req
)) {
874 printk(KERN_ERR
"PSCSI: blk_get_request() failed: %ld\n",
875 IS_ERR(pt
->pscsi_req
));
876 return PYX_TRANSPORT_LU_COMM_FAILURE
;
879 * Setup the newly allocated struct request for REQ_TYPE_BLOCK_PC,
880 * and setup rq callback, CDB and sense.
882 pscsi_blk_init_request(task
, pt
, pt
->pscsi_req
, 0);
886 /* pscsi_do_task(): (Part of se_subsystem_api_t template)
890 static int pscsi_do_task(struct se_task
*task
)
892 struct pscsi_plugin_task
*pt
= PSCSI_TASK(task
);
893 struct pscsi_dev_virt
*pdv
= task
->se_dev
->dev_ptr
;
895 * Set the struct request->timeout value based on peripheral
896 * device type from SCSI.
898 if (pdv
->pdv_sd
->type
== TYPE_DISK
)
899 pt
->pscsi_req
->timeout
= PS_TIMEOUT_DISK
;
901 pt
->pscsi_req
->timeout
= PS_TIMEOUT_OTHER
;
903 pt
->pscsi_req
->retries
= PS_RETRY
;
905 * Queue the struct request into the struct scsi_device->request_queue.
906 * Also check for HEAD_OF_QUEUE SAM TASK attr from received se_cmd
909 blk_execute_rq_nowait(pdv
->pdv_sd
->request_queue
, NULL
, pt
->pscsi_req
,
910 (task
->task_se_cmd
->sam_task_attr
== TASK_ATTR_HOQ
),
913 return PYX_TRANSPORT_SENT_TO_TRANSPORT
;
916 static void pscsi_free_task(struct se_task
*task
)
918 struct pscsi_plugin_task
*pt
= PSCSI_TASK(task
);
919 struct se_cmd
*cmd
= task
->task_se_cmd
;
922 * Release the extended CDB allocation from pscsi_alloc_task()
925 if (T_TASK(cmd
)->t_task_cdb
!= T_TASK(cmd
)->__t_task_cdb
)
926 kfree(pt
->pscsi_cdb
);
928 * We do not release the bio(s) here associated with this task, as
929 * this is handled by bio_put() and pscsi_bi_endio().
935 Opt_scsi_host_id
, Opt_scsi_channel_id
, Opt_scsi_target_id
,
936 Opt_scsi_lun_id
, Opt_err
939 static match_table_t tokens
= {
940 {Opt_scsi_host_id
, "scsi_host_id=%d"},
941 {Opt_scsi_channel_id
, "scsi_channel_id=%d"},
942 {Opt_scsi_target_id
, "scsi_target_id=%d"},
943 {Opt_scsi_lun_id
, "scsi_lun_id=%d"},
947 static ssize_t
pscsi_set_configfs_dev_params(struct se_hba
*hba
,
948 struct se_subsystem_dev
*se_dev
,
952 struct pscsi_dev_virt
*pdv
= se_dev
->se_dev_su_ptr
;
953 struct pscsi_hba_virt
*phv
= hba
->hba_ptr
;
954 char *orig
, *ptr
, *opts
;
955 substring_t args
[MAX_OPT_ARGS
];
956 int ret
= 0, arg
, token
;
958 opts
= kstrdup(page
, GFP_KERNEL
);
964 while ((ptr
= strsep(&opts
, ",")) != NULL
) {
968 token
= match_token(ptr
, tokens
, args
);
970 case Opt_scsi_host_id
:
971 if (phv
->phv_mode
== PHV_LLD_SCSI_HOST_NO
) {
972 printk(KERN_ERR
"PSCSI[%d]: Unable to accept"
973 " scsi_host_id while phv_mode =="
974 " PHV_LLD_SCSI_HOST_NO\n",
979 match_int(args
, &arg
);
980 pdv
->pdv_host_id
= arg
;
981 printk(KERN_INFO
"PSCSI[%d]: Referencing SCSI Host ID:"
982 " %d\n", phv
->phv_host_id
, pdv
->pdv_host_id
);
983 pdv
->pdv_flags
|= PDF_HAS_VIRT_HOST_ID
;
985 case Opt_scsi_channel_id
:
986 match_int(args
, &arg
);
987 pdv
->pdv_channel_id
= arg
;
988 printk(KERN_INFO
"PSCSI[%d]: Referencing SCSI Channel"
989 " ID: %d\n", phv
->phv_host_id
,
990 pdv
->pdv_channel_id
);
991 pdv
->pdv_flags
|= PDF_HAS_CHANNEL_ID
;
993 case Opt_scsi_target_id
:
994 match_int(args
, &arg
);
995 pdv
->pdv_target_id
= arg
;
996 printk(KERN_INFO
"PSCSI[%d]: Referencing SCSI Target"
997 " ID: %d\n", phv
->phv_host_id
,
999 pdv
->pdv_flags
|= PDF_HAS_TARGET_ID
;
1001 case Opt_scsi_lun_id
:
1002 match_int(args
, &arg
);
1003 pdv
->pdv_lun_id
= arg
;
1004 printk(KERN_INFO
"PSCSI[%d]: Referencing SCSI LUN ID:"
1005 " %d\n", phv
->phv_host_id
, pdv
->pdv_lun_id
);
1006 pdv
->pdv_flags
|= PDF_HAS_LUN_ID
;
1015 return (!ret
) ? count
: ret
;
1018 static ssize_t
pscsi_check_configfs_dev_params(
1020 struct se_subsystem_dev
*se_dev
)
1022 struct pscsi_dev_virt
*pdv
= se_dev
->se_dev_su_ptr
;
1024 if (!(pdv
->pdv_flags
& PDF_HAS_CHANNEL_ID
) ||
1025 !(pdv
->pdv_flags
& PDF_HAS_TARGET_ID
) ||
1026 !(pdv
->pdv_flags
& PDF_HAS_LUN_ID
)) {
1027 printk(KERN_ERR
"Missing scsi_channel_id=, scsi_target_id= and"
1028 " scsi_lun_id= parameters\n");
1035 static ssize_t
pscsi_show_configfs_dev_params(struct se_hba
*hba
,
1036 struct se_subsystem_dev
*se_dev
,
1039 struct pscsi_hba_virt
*phv
= hba
->hba_ptr
;
1040 struct pscsi_dev_virt
*pdv
= se_dev
->se_dev_su_ptr
;
1041 struct scsi_device
*sd
= pdv
->pdv_sd
;
1042 unsigned char host_id
[16];
1046 if (phv
->phv_mode
== PHV_VIRUTAL_HOST_ID
)
1047 snprintf(host_id
, 16, "%d", pdv
->pdv_host_id
);
1049 snprintf(host_id
, 16, "PHBA Mode");
1051 bl
= sprintf(b
, "SCSI Device Bus Location:"
1052 " Channel ID: %d Target ID: %d LUN: %d Host ID: %s\n",
1053 pdv
->pdv_channel_id
, pdv
->pdv_target_id
, pdv
->pdv_lun_id
,
1057 bl
+= sprintf(b
+ bl
, " ");
1058 bl
+= sprintf(b
+ bl
, "Vendor: ");
1059 for (i
= 0; i
< 8; i
++) {
1060 if (ISPRINT(sd
->vendor
[i
])) /* printable character? */
1061 bl
+= sprintf(b
+ bl
, "%c", sd
->vendor
[i
]);
1063 bl
+= sprintf(b
+ bl
, " ");
1065 bl
+= sprintf(b
+ bl
, " Model: ");
1066 for (i
= 0; i
< 16; i
++) {
1067 if (ISPRINT(sd
->model
[i
])) /* printable character ? */
1068 bl
+= sprintf(b
+ bl
, "%c", sd
->model
[i
]);
1070 bl
+= sprintf(b
+ bl
, " ");
1072 bl
+= sprintf(b
+ bl
, " Rev: ");
1073 for (i
= 0; i
< 4; i
++) {
1074 if (ISPRINT(sd
->rev
[i
])) /* printable character ? */
1075 bl
+= sprintf(b
+ bl
, "%c", sd
->rev
[i
]);
1077 bl
+= sprintf(b
+ bl
, " ");
1079 bl
+= sprintf(b
+ bl
, "\n");
1084 static void pscsi_bi_endio(struct bio
*bio
, int error
)
1089 static inline struct bio
*pscsi_get_bio(struct pscsi_dev_virt
*pdv
, int sg_num
)
1093 * Use bio_malloc() following the comment in for bio -> struct request
1094 * in block/blk-core.c:blk_make_request()
1096 bio
= bio_kmalloc(GFP_KERNEL
, sg_num
);
1098 printk(KERN_ERR
"PSCSI: bio_kmalloc() failed\n");
1101 bio
->bi_end_io
= pscsi_bi_endio
;
1107 #define DEBUG_PSCSI(x...) printk(x)
1109 #define DEBUG_PSCSI(x...)
1112 static int __pscsi_map_task_SG(
1113 struct se_task
*task
,
1114 struct scatterlist
*task_sg
,
1118 struct pscsi_plugin_task
*pt
= PSCSI_TASK(task
);
1119 struct pscsi_dev_virt
*pdv
= task
->se_dev
->dev_ptr
;
1120 struct bio
*bio
= NULL
, *hbio
= NULL
, *tbio
= NULL
;
1122 struct scatterlist
*sg
;
1123 u32 data_len
= task
->task_size
, i
, len
, bytes
, off
;
1124 int nr_pages
= (task
->task_size
+ task_sg
[0].offset
+
1125 PAGE_SIZE
- 1) >> PAGE_SHIFT
;
1126 int nr_vecs
= 0, rc
, ret
= PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES
;
1127 int rw
= (task
->task_data_direction
== DMA_TO_DEVICE
);
1129 if (!task
->task_size
)
1132 * For SCF_SCSI_DATA_SG_IO_CDB, Use fs/bio.c:bio_add_page() to setup
1133 * the bio_vec maplist from TC< struct se_mem -> task->task_sg ->
1134 * struct scatterlist memory. The struct se_task->task_sg[] currently needs
1135 * to be attached to struct bios for submission to Linux/SCSI using
1136 * struct request to struct scsi_device->request_queue.
1138 * Note that this will be changing post v2.6.28 as Target_Core_Mod/pSCSI
1139 * is ported to upstream SCSI passthrough functionality that accepts
1140 * struct scatterlist->page_link or struct page as a paraemeter.
1142 DEBUG_PSCSI("PSCSI: nr_pages: %d\n", nr_pages
);
1144 for_each_sg(task_sg
, sg
, task_sg_num
, i
) {
1149 DEBUG_PSCSI("PSCSI: i: %d page: %p len: %d off: %d\n", i
,
1152 while (len
> 0 && data_len
> 0) {
1153 bytes
= min_t(unsigned int, len
, PAGE_SIZE
- off
);
1154 bytes
= min(bytes
, data_len
);
1157 nr_vecs
= min_t(int, BIO_MAX_PAGES
, nr_pages
);
1158 nr_pages
-= nr_vecs
;
1160 * Calls bio_kmalloc() and sets bio->bi_end_io()
1162 bio
= pscsi_get_bio(pdv
, nr_vecs
);
1167 bio
->bi_rw
|= REQ_WRITE
;
1169 DEBUG_PSCSI("PSCSI: Allocated bio: %p,"
1170 " dir: %s nr_vecs: %d\n", bio
,
1171 (rw
) ? "rw" : "r", nr_vecs
);
1173 * Set *hbio pointer to handle the case:
1174 * nr_pages > BIO_MAX_PAGES, where additional
1175 * bios need to be added to complete a given
1181 tbio
= tbio
->bi_next
= bio
;
1184 DEBUG_PSCSI("PSCSI: Calling bio_add_pc_page() i: %d"
1185 " bio: %p page: %p len: %d off: %d\n", i
, bio
,
1188 rc
= bio_add_pc_page(pdv
->pdv_sd
->request_queue
,
1189 bio
, page
, bytes
, off
);
1193 DEBUG_PSCSI("PSCSI: bio->bi_vcnt: %d nr_vecs: %d\n",
1194 bio
->bi_vcnt
, nr_vecs
);
1196 if (bio
->bi_vcnt
> nr_vecs
) {
1197 DEBUG_PSCSI("PSCSI: Reached bio->bi_vcnt max:"
1198 " %d i: %d bio: %p, allocating another"
1199 " bio\n", bio
->bi_vcnt
, i
, bio
);
1201 * Clear the pointer so that another bio will
1202 * be allocated with pscsi_get_bio() above, the
1203 * current bio has already been set *tbio and
1216 * Setup the primary pt->pscsi_req used for non BIDI and BIDI-COMMAND
1217 * primary SCSI WRITE poayload mapped for struct se_task->task_sg[]
1221 * Starting with v2.6.31, call blk_make_request() passing in *hbio to
1222 * allocate the pSCSI task a struct request.
1224 pt
->pscsi_req
= blk_make_request(pdv
->pdv_sd
->request_queue
,
1226 if (!(pt
->pscsi_req
)) {
1227 printk(KERN_ERR
"pSCSI: blk_make_request() failed\n");
1231 * Setup the newly allocated struct request for REQ_TYPE_BLOCK_PC,
1232 * and setup rq callback, CDB and sense.
1234 pscsi_blk_init_request(task
, pt
, pt
->pscsi_req
, 0);
1236 return task
->task_sg_num
;
1239 * Setup the secondary pt->pscsi_req->next_rq used for the extra BIDI-COMMAND
1240 * SCSI READ paylaod mapped for struct se_task->task_sg_bidi[]
1242 pt
->pscsi_req
->next_rq
= blk_make_request(pdv
->pdv_sd
->request_queue
,
1244 if (!(pt
->pscsi_req
->next_rq
)) {
1245 printk(KERN_ERR
"pSCSI: blk_make_request() failed for BIDI\n");
1248 pscsi_blk_init_request(task
, pt
, pt
->pscsi_req
->next_rq
, 1);
1250 return task
->task_sg_num
;
1254 hbio
= hbio
->bi_next
;
1255 bio
->bi_next
= NULL
;
1261 static int pscsi_map_task_SG(struct se_task
*task
)
1266 * Setup the main struct request for the task->task_sg[] payload
1269 ret
= __pscsi_map_task_SG(task
, task
->task_sg
, task
->task_sg_num
, 0);
1270 if (ret
>= 0 && task
->task_sg_bidi
) {
1272 * If present, set up the extra BIDI-COMMAND SCSI READ
1273 * struct request and payload.
1275 ret
= __pscsi_map_task_SG(task
, task
->task_sg_bidi
,
1276 task
->task_sg_num
, 1);
1280 return PYX_TRANSPORT_LU_COMM_FAILURE
;
1284 /* pscsi_map_task_non_SG():
1288 static int pscsi_map_task_non_SG(struct se_task
*task
)
1290 struct se_cmd
*cmd
= TASK_CMD(task
);
1291 struct pscsi_plugin_task
*pt
= PSCSI_TASK(task
);
1292 struct pscsi_dev_virt
*pdv
= task
->se_dev
->dev_ptr
;
1295 if (pscsi_blk_get_request(task
) < 0)
1296 return PYX_TRANSPORT_LU_COMM_FAILURE
;
1298 if (!task
->task_size
)
1301 ret
= blk_rq_map_kern(pdv
->pdv_sd
->request_queue
,
1302 pt
->pscsi_req
, T_TASK(cmd
)->t_task_buf
,
1303 task
->task_size
, GFP_KERNEL
);
1305 printk(KERN_ERR
"PSCSI: blk_rq_map_kern() failed: %d\n", ret
);
1306 return PYX_TRANSPORT_LU_COMM_FAILURE
;
1311 static int pscsi_CDB_none(struct se_task
*task
)
1313 return pscsi_blk_get_request(task
);
1320 static unsigned char *pscsi_get_cdb(struct se_task
*task
)
1322 struct pscsi_plugin_task
*pt
= PSCSI_TASK(task
);
1324 return pt
->pscsi_cdb
;
1327 /* pscsi_get_sense_buffer():
1331 static unsigned char *pscsi_get_sense_buffer(struct se_task
*task
)
1333 struct pscsi_plugin_task
*pt
= PSCSI_TASK(task
);
1335 return (unsigned char *)&pt
->pscsi_sense
[0];
1338 /* pscsi_get_device_rev():
1342 static u32
pscsi_get_device_rev(struct se_device
*dev
)
1344 struct pscsi_dev_virt
*pdv
= dev
->dev_ptr
;
1345 struct scsi_device
*sd
= pdv
->pdv_sd
;
1347 return (sd
->scsi_level
- 1) ? sd
->scsi_level
- 1 : 1;
1350 /* pscsi_get_device_type():
1354 static u32
pscsi_get_device_type(struct se_device
*dev
)
1356 struct pscsi_dev_virt
*pdv
= dev
->dev_ptr
;
1357 struct scsi_device
*sd
= pdv
->pdv_sd
;
1362 static sector_t
pscsi_get_blocks(struct se_device
*dev
)
1364 struct pscsi_dev_virt
*pdv
= dev
->dev_ptr
;
1366 if (pdv
->pdv_bd
&& pdv
->pdv_bd
->bd_part
)
1367 return pdv
->pdv_bd
->bd_part
->nr_sects
;
1373 /* pscsi_handle_SAM_STATUS_failures():
1377 static inline void pscsi_process_SAM_status(
1378 struct se_task
*task
,
1379 struct pscsi_plugin_task
*pt
)
1381 task
->task_scsi_status
= status_byte(pt
->pscsi_result
);
1382 if ((task
->task_scsi_status
)) {
1383 task
->task_scsi_status
<<= 1;
1384 printk(KERN_INFO
"PSCSI Status Byte exception at task: %p CDB:"
1385 " 0x%02x Result: 0x%08x\n", task
, pt
->pscsi_cdb
[0],
1389 switch (host_byte(pt
->pscsi_result
)) {
1391 transport_complete_task(task
, (!task
->task_scsi_status
));
1394 printk(KERN_INFO
"PSCSI Host Byte exception at task: %p CDB:"
1395 " 0x%02x Result: 0x%08x\n", task
, pt
->pscsi_cdb
[0],
1397 task
->task_scsi_status
= SAM_STAT_CHECK_CONDITION
;
1398 task
->task_error_status
= PYX_TRANSPORT_UNKNOWN_SAM_OPCODE
;
1399 TASK_CMD(task
)->transport_error_status
=
1400 PYX_TRANSPORT_UNKNOWN_SAM_OPCODE
;
1401 transport_complete_task(task
, 0);
1408 static void pscsi_req_done(struct request
*req
, int uptodate
)
1410 struct se_task
*task
= req
->end_io_data
;
1411 struct pscsi_plugin_task
*pt
= PSCSI_TASK(task
);
1413 pt
->pscsi_result
= req
->errors
;
1414 pt
->pscsi_resid
= req
->resid_len
;
1416 pscsi_process_SAM_status(task
, pt
);
1418 * Release BIDI-READ if present
1420 if (req
->next_rq
!= NULL
)
1421 __blk_put_request(req
->q
, req
->next_rq
);
1423 __blk_put_request(req
->q
, req
);
1424 pt
->pscsi_req
= NULL
;
1427 static struct se_subsystem_api pscsi_template
= {
1429 .owner
= THIS_MODULE
,
1430 .transport_type
= TRANSPORT_PLUGIN_PHBA_PDEV
,
1431 .cdb_none
= pscsi_CDB_none
,
1432 .map_task_non_SG
= pscsi_map_task_non_SG
,
1433 .map_task_SG
= pscsi_map_task_SG
,
1434 .attach_hba
= pscsi_attach_hba
,
1435 .detach_hba
= pscsi_detach_hba
,
1436 .pmode_enable_hba
= pscsi_pmode_enable_hba
,
1437 .allocate_virtdevice
= pscsi_allocate_virtdevice
,
1438 .create_virtdevice
= pscsi_create_virtdevice
,
1439 .free_device
= pscsi_free_device
,
1440 .transport_complete
= pscsi_transport_complete
,
1441 .alloc_task
= pscsi_alloc_task
,
1442 .do_task
= pscsi_do_task
,
1443 .free_task
= pscsi_free_task
,
1444 .check_configfs_dev_params
= pscsi_check_configfs_dev_params
,
1445 .set_configfs_dev_params
= pscsi_set_configfs_dev_params
,
1446 .show_configfs_dev_params
= pscsi_show_configfs_dev_params
,
1447 .get_cdb
= pscsi_get_cdb
,
1448 .get_sense_buffer
= pscsi_get_sense_buffer
,
1449 .get_device_rev
= pscsi_get_device_rev
,
1450 .get_device_type
= pscsi_get_device_type
,
1451 .get_blocks
= pscsi_get_blocks
,
1454 static int __init
pscsi_module_init(void)
1456 return transport_subsystem_register(&pscsi_template
);
1459 static void pscsi_module_exit(void)
1461 transport_subsystem_release(&pscsi_template
);
1464 MODULE_DESCRIPTION("TCM PSCSI subsystem plugin");
1465 MODULE_AUTHOR("nab@Linux-iSCSI.org");
1466 MODULE_LICENSE("GPL");
1468 module_init(pscsi_module_init
);
1469 module_exit(pscsi_module_exit
);