Commit 06646525 authored by Bart Van Assche's avatar Bart Van Assche Committed by Christoph Hellwig

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: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
parent f6667938
...@@ -304,13 +304,6 @@ config SCSI_SRP_ATTRS ...@@ -304,13 +304,6 @@ config SCSI_SRP_ATTRS
If you wish to export transport-specific information about If you wish to export transport-specific information about
each attached SRP device to sysfs, say Y. each attached SRP device to sysfs, say Y.
config SCSI_SRP_TGT_ATTRS
bool "SCSI target support for SRP Transport Attributes"
depends on SCSI_SRP_ATTRS
depends on SCSI_TGT = y || SCSI_TGT = SCSI_SRP_ATTRS
help
If you want to use SCSI target mode drivers enable this option.
endmenu endmenu
menuconfig SCSI_LOWLEVEL menuconfig SCSI_LOWLEVEL
......
...@@ -20,7 +20,6 @@ CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ -DGDTH_STATISTICS ...@@ -20,7 +20,6 @@ CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ -DGDTH_STATISTICS
obj-$(CONFIG_PCMCIA) += pcmcia/ obj-$(CONFIG_PCMCIA) += pcmcia/
obj-$(CONFIG_SCSI) += scsi_mod.o obj-$(CONFIG_SCSI) += scsi_mod.o
obj-$(CONFIG_SCSI_TGT) += scsi_tgt.o
obj-$(CONFIG_RAID_ATTRS) += raid_class.o obj-$(CONFIG_RAID_ATTRS) += raid_class.o
...@@ -171,8 +170,6 @@ scsi_mod-$(CONFIG_PM) += scsi_pm.o ...@@ -171,8 +170,6 @@ scsi_mod-$(CONFIG_PM) += scsi_pm.o
hv_storvsc-y := storvsc_drv.o hv_storvsc-y := storvsc_drv.o
scsi_tgt-y += scsi_tgt_lib.o scsi_tgt_if.o
sd_mod-objs := sd.o sd_mod-objs := sd.o
sd_mod-$(CONFIG_BLK_DEV_INTEGRITY) += sd_dif.o sd_mod-$(CONFIG_BLK_DEV_INTEGRITY) += sd_dif.o
......
/*
* SCSI target kernel/user interface functions
*
* Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include <linux/miscdevice.h>
#include <linux/gfp.h>
#include <linux/file.h>
#include <linux/export.h>
#include <net/tcp.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_tgt.h>
#include <scsi/scsi_tgt_if.h>
#include <asm/cacheflush.h>
#include "scsi_tgt_priv.h"
#if TGT_RING_SIZE < PAGE_SIZE
# define TGT_RING_SIZE PAGE_SIZE
#endif
#define TGT_RING_PAGES (TGT_RING_SIZE >> PAGE_SHIFT)
#define TGT_EVENT_PER_PAGE (PAGE_SIZE / sizeof(struct tgt_event))
#define TGT_MAX_EVENTS (TGT_EVENT_PER_PAGE * TGT_RING_PAGES)
struct tgt_ring {
u32 tr_idx;
unsigned long tr_pages[TGT_RING_PAGES];
spinlock_t tr_lock;
};
/* tx_ring : kernel->user, rx_ring : user->kernel */
static struct tgt_ring tx_ring, rx_ring;
static DECLARE_WAIT_QUEUE_HEAD(tgt_poll_wait);
static inline void tgt_ring_idx_inc(struct tgt_ring *ring)
{
if (ring->tr_idx == TGT_MAX_EVENTS - 1)
ring->tr_idx = 0;
else
ring->tr_idx++;
}
static struct tgt_event *tgt_head_event(struct tgt_ring *ring, u32 idx)
{
u32 pidx, off;
pidx = idx / TGT_EVENT_PER_PAGE;
off = idx % TGT_EVENT_PER_PAGE;
return (struct tgt_event *)
(ring->tr_pages[pidx] + sizeof(struct tgt_event) * off);
}
static int tgt_uspace_send_event(u32 type, struct tgt_event *p)
{
struct tgt_event *ev;
struct tgt_ring *ring = &tx_ring;
unsigned long flags;
int err = 0;
spin_lock_irqsave(&ring->tr_lock, flags);
ev = tgt_head_event(ring, ring->tr_idx);
if (!ev->hdr.status)
tgt_ring_idx_inc(ring);
else
err = -BUSY;
spin_unlock_irqrestore(&ring->tr_lock, flags);
if (err)
return err;
memcpy(ev, p, sizeof(*ev));
ev->hdr.type = type;
mb();
ev->hdr.status = 1;
flush_dcache_page(virt_to_page(ev));
wake_up_interruptible(&tgt_poll_wait);
return 0;
}
int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, u64 itn_id,
struct scsi_lun *lun, u64 tag)
{
struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd);
struct tgt_event ev;
int err;
memset(&ev, 0, sizeof(ev));
ev.p.cmd_req.host_no = shost->host_no;
ev.p.cmd_req.itn_id = itn_id;
ev.p.cmd_req.data_len = scsi_bufflen(cmd);
memcpy(ev.p.cmd_req.scb, cmd->cmnd, sizeof(ev.p.cmd_req.scb));
memcpy(ev.p.cmd_req.lun, lun, sizeof(ev.p.cmd_req.lun));
ev.p.cmd_req.attribute = cmd->tag;
ev.p.cmd_req.tag = tag;
dprintk("%p %d %u %x %llx\n", cmd, shost->host_no,
ev.p.cmd_req.data_len, cmd->tag,
(unsigned long long) ev.p.cmd_req.tag);
err = tgt_uspace_send_event(TGT_KEVENT_CMD_REQ, &ev);
if (err)
eprintk("tx buf is full, could not send\n");
return err;
}
int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 itn_id, u64 tag)
{
struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd);
struct tgt_event ev;
int err;
memset(&ev, 0, sizeof(ev));
ev.p.cmd_done.host_no = shost->host_no;
ev.p.cmd_done.itn_id = itn_id;
ev.p.cmd_done.tag = tag;
ev.p.cmd_done.result = cmd->result;
dprintk("%p %d %llu %u %x\n", cmd, shost->host_no,
(unsigned long long) ev.p.cmd_req.tag,
ev.p.cmd_req.data_len, cmd->tag);
err = tgt_uspace_send_event(TGT_KEVENT_CMD_DONE, &ev);
if (err)
eprintk("tx buf is full, could not send\n");
return err;
}
int scsi_tgt_uspace_send_tsk_mgmt(int host_no, u64 itn_id, int function,
u64 tag, struct scsi_lun *scsilun, void *data)
{
struct tgt_event ev;
int err;
memset(&ev, 0, sizeof(ev));
ev.p.tsk_mgmt_req.host_no = host_no;
ev.p.tsk_mgmt_req.itn_id = itn_id;
ev.p.tsk_mgmt_req.function = function;
ev.p.tsk_mgmt_req.tag = tag;
memcpy(ev.p.tsk_mgmt_req.lun, scsilun, sizeof(ev.p.tsk_mgmt_req.lun));
ev.p.tsk_mgmt_req.mid = (u64) (unsigned long) data;
dprintk("%d %x %llx %llx\n", host_no, function, (unsigned long long) tag,
(unsigned long long) ev.p.tsk_mgmt_req.mid);
err = tgt_uspace_send_event(TGT_KEVENT_TSK_MGMT_REQ, &ev);
if (err)
eprintk("tx buf is full, could not send\n");
return err;
}
int scsi_tgt_uspace_send_it_nexus_request(int host_no, u64 itn_id,
int function, char *initiator_id)
{
struct tgt_event ev;
int err;
memset(&ev, 0, sizeof(ev));
ev.p.it_nexus_req.host_no = host_no;
ev.p.it_nexus_req.function = function;
ev.p.it_nexus_req.itn_id = itn_id;
if (initiator_id)
strncpy(ev.p.it_nexus_req.initiator_id, initiator_id,
sizeof(ev.p.it_nexus_req.initiator_id));
dprintk("%d %x %llx\n", host_no, function, (unsigned long long)itn_id);
err = tgt_uspace_send_event(TGT_KEVENT_IT_NEXUS_REQ, &ev);
if (err)
eprintk("tx buf is full, could not send\n");
return err;
}
static int event_recv_msg(struct tgt_event *ev)
{
int err = 0;
switch (ev->hdr.type) {
case TGT_UEVENT_CMD_RSP:
err = scsi_tgt_kspace_exec(ev->p.cmd_rsp.host_no,
ev->p.cmd_rsp.itn_id,
ev->p.cmd_rsp.result,
ev->p.cmd_rsp.tag,
ev->p.cmd_rsp.uaddr,
ev->p.cmd_rsp.len,
ev->p.cmd_rsp.sense_uaddr,
ev->p.cmd_rsp.sense_len,
ev->p.cmd_rsp.rw);
break;
case TGT_UEVENT_TSK_MGMT_RSP:
err = scsi_tgt_kspace_tsk_mgmt(ev->p.tsk_mgmt_rsp.host_no,
ev->p.tsk_mgmt_rsp.itn_id,
ev->p.tsk_mgmt_rsp.mid,
ev->p.tsk_mgmt_rsp.result);
break;
case TGT_UEVENT_IT_NEXUS_RSP:
err = scsi_tgt_kspace_it_nexus_rsp(ev->p.it_nexus_rsp.host_no,
ev->p.it_nexus_rsp.itn_id,
ev->p.it_nexus_rsp.result);
break;
default:
eprintk("unknown type %d\n", ev->hdr.type);
err = -EINVAL;
}
return err;
}
static ssize_t tgt_write(struct file *file, const char __user * buffer,
size_t count, loff_t * ppos)
{
struct tgt_event *ev;
struct tgt_ring *ring = &rx_ring;
while (1) {
ev = tgt_head_event(ring, ring->tr_idx);
/* do we need this? */
flush_dcache_page(virt_to_page(ev));
if (!ev->hdr.status)
break;
tgt_ring_idx_inc(ring);
event_recv_msg(ev);
ev->hdr.status = 0;
};
return count;
}
static unsigned int tgt_poll(struct file * file, struct poll_table_struct *wait)
{
struct tgt_event *ev;
struct tgt_ring *ring = &tx_ring;
unsigned long flags;
unsigned int mask = 0;
u32 idx;
poll_wait(file, &tgt_poll_wait, wait);
spin_lock_irqsave(&ring->tr_lock, flags);
idx = ring->tr_idx ? ring->tr_idx - 1 : TGT_MAX_EVENTS - 1;
ev = tgt_head_event(ring, idx);
if (ev->hdr.status)
mask |= POLLIN | POLLRDNORM;
spin_unlock_irqrestore(&ring->tr_lock, flags);
return mask;
}
static int uspace_ring_map(struct vm_area_struct *vma, unsigned long addr,
struct tgt_ring *ring)
{
int i, err;
for (i = 0; i < TGT_RING_PAGES; i++) {
struct page *page = virt_to_page(ring->tr_pages[i]);
err = vm_insert_page(vma, addr, page);
if (err)
return err;
addr += PAGE_SIZE;
}
return 0;
}
static int tgt_mmap(struct file *filp, struct vm_area_struct *vma)
{
unsigned long addr;
int err;
if (vma->vm_pgoff)
return -EINVAL;
if (vma->vm_end - vma->vm_start != TGT_RING_SIZE * 2) {
eprintk("mmap size must be %lu, not %lu \n",
TGT_RING_SIZE * 2, vma->vm_end - vma->vm_start);
return -EINVAL;
}
addr = vma->vm_start;
err = uspace_ring_map(vma, addr, &tx_ring);
if (err)
return err;
err = uspace_ring_map(vma, addr + TGT_RING_SIZE, &rx_ring);
return err;
}
static int tgt_open(struct inode *inode, struct file *file)
{
tx_ring.tr_idx = rx_ring.tr_idx = 0;
return 0;
}
static const struct file_operations tgt_fops = {
.owner = THIS_MODULE,
.open = tgt_open,
.poll = tgt_poll,
.write = tgt_write,
.mmap = tgt_mmap,
.llseek = noop_llseek,
};
static struct miscdevice tgt_miscdev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "tgt",
.fops = &tgt_fops,
};
static void tgt_ring_exit(struct tgt_ring *ring)
{
int i;
for (i = 0; i < TGT_RING_PAGES; i++)
free_page(ring->tr_pages[i]);
}
static int tgt_ring_init(struct tgt_ring *ring)
{
int i;
spin_lock_init(&ring->tr_lock);
for (i = 0; i < TGT_RING_PAGES; i++) {
ring->tr_pages[i] = get_zeroed_page(GFP_KERNEL);
if (!ring->tr_pages[i]) {
eprintk("out of memory\n");
return -ENOMEM;
}
}
return 0;
}
void scsi_tgt_if_exit(void)
{
tgt_ring_exit(&tx_ring);
tgt_ring_exit(&rx_ring);
misc_deregister(&tgt_miscdev);
}
int scsi_tgt_if_init(void)
{
int err;
err = tgt_ring_init(&tx_ring);
if (err)
return err;
err = tgt_ring_init(&rx_ring);
if (err)
goto free_tx_ring;
err = misc_register(&tgt_miscdev);
if (err)
goto free_rx_ring;
return 0;
free_rx_ring:
tgt_ring_exit(&rx_ring);
free_tx_ring:
tgt_ring_exit(&tx_ring);
return err;
}
This diff is collapsed.
struct scsi_cmnd;
struct scsi_lun;
struct Scsi_Host;
struct task_struct;
/* tmp - will replace with SCSI logging stuff */
#define eprintk(fmt, args...) \
do { \
printk("%s(%d) " fmt, __func__, __LINE__, ##args); \
} while (0)
#define dprintk(fmt, args...)
/* #define dprintk eprintk */
extern void scsi_tgt_if_exit(void);
extern int scsi_tgt_if_init(void);
extern int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, u64 it_nexus_id,
struct scsi_lun *lun, u64 tag);
extern int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 it_nexus_id,
u64 tag);
extern int scsi_tgt_kspace_exec(int host_no, u64 it_nexus_id, int result, u64 tag,
unsigned long uaddr, u32 len,
unsigned long sense_uaddr, u32 sense_len, u8 rw);
extern int scsi_tgt_uspace_send_tsk_mgmt(int host_no, u64 it_nexus_id,
int function, u64 tag,
struct scsi_lun *scsilun, void *data);
extern int scsi_tgt_kspace_tsk_mgmt(int host_no, u64 it_nexus_id,
u64 mid, int result);
extern int scsi_tgt_uspace_send_it_nexus_request(int host_no, u64 it_nexus_id,
int function, char *initiator);
extern int scsi_tgt_kspace_it_nexus_rsp(int host_no, u64 it_nexus_id, int result);
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include <scsi/scsi_netlink_fc.h> #include <scsi/scsi_netlink_fc.h>
#include <scsi/scsi_bsg_fc.h> #include <scsi/scsi_bsg_fc.h>
#include "scsi_priv.h" #include "scsi_priv.h"
#include "scsi_transport_fc_internal.h"
static int fc_queue_work(struct Scsi_Host *, struct work_struct *); static int fc_queue_work(struct Scsi_Host *, struct work_struct *);
static void fc_vport_sched_delete(struct work_struct *work); static void fc_vport_sched_delete(struct work_struct *work);
...@@ -3008,10 +3007,6 @@ fc_remote_port_delete(struct fc_rport *rport) ...@@ -3008,10 +3007,6 @@ fc_remote_port_delete(struct fc_rport *rport)
spin_unlock_irqrestore(shost->host_lock, flags); spin_unlock_irqrestore(shost->host_lock, flags);
if (rport->roles & FC_PORT_ROLE_FCP_INITIATOR &&
shost->active_mode & MODE_TARGET)
fc_tgt_it_nexus_destroy(shost, (unsigned long)rport);
scsi_target_block(&rport->dev); scsi_target_block(&rport->dev);
/* see if we need to kill io faster than waiting for device loss */ /* see if we need to kill io faster than waiting for device loss */
...@@ -3052,7 +3047,6 @@ fc_remote_port_rolechg(struct fc_rport *rport, u32 roles) ...@@ -3052,7 +3047,6 @@ fc_remote_port_rolechg(struct fc_rport *rport, u32 roles)
struct fc_host_attrs *fc_host = shost_to_fc_host(shost); struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
unsigned long flags; unsigned long flags;
int create = 0; int create = 0;
int ret;
spin_lock_irqsave(shost->host_lock, flags); spin_lock_irqsave(shost->host_lock, flags);
if (roles & FC_PORT_ROLE_FCP_TARGET) { if (roles & FC_PORT_ROLE_FCP_TARGET) {
...@@ -3061,12 +3055,6 @@ fc_remote_port_rolechg(struct fc_rport *rport, u32 roles) ...@@ -3061,12 +3055,6 @@ fc_remote_port_rolechg(struct fc_rport *rport, u32 roles)
create = 1; create = 1;
} else if (!(rport->roles & FC_PORT_ROLE_FCP_TARGET)) } else if (!(rport->roles & FC_PORT_ROLE_FCP_TARGET))
create = 1; create = 1;
} else if (shost->active_mode & MODE_TARGET) {
ret = fc_tgt_it_nexus_create(shost, (unsigned long)rport,
(char *)&rport->node_name);
if (ret)
printk(KERN_ERR "FC Remore Port tgt nexus failed %d\n",
ret);
} }
rport->roles = roles; rport->roles = roles;
......
#include <scsi/scsi_tgt.h>
#ifdef CONFIG_SCSI_FC_TGT_ATTRS
static inline int fc_tgt_it_nexus_create(struct Scsi_Host *shost, u64 itn_id,
char *initiator)
{
return scsi_tgt_it_nexus_create(shost, itn_id, initiator);
}
static inline int fc_tgt_it_nexus_destroy(struct Scsi_Host *shost, u64 itn_id)
{
return scsi_tgt_it_nexus_destroy(shost, itn_id);
}
#else
static inline int fc_tgt_it_nexus_create(struct Scsi_Host *shost, u64 itn_id,
char *initiator)
{
return 0;
}
static inline int fc_tgt_it_nexus_destroy(struct Scsi_Host *shost, u64 itn_id)
{
return 0;
}
#endif
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include <scsi/scsi_transport.h> #include <scsi/scsi_transport.h>
#include <scsi/scsi_transport_srp.h> #include <scsi/scsi_transport_srp.h>
#include "scsi_priv.h" #include "scsi_priv.h"
#include "scsi_transport_srp_internal.h"
struct srp_host_attrs { struct srp_host_attrs {
atomic_t next_port_id; atomic_t next_port_id;
...@@ -746,18 +745,6 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost, ...@@ -746,18 +745,6 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
return ERR_PTR(ret); return ERR_PTR(ret);
} }
if (shost->active_mode & MODE_TARGET &&
ids->roles == SRP_RPORT_ROLE_INITIATOR) {
ret = srp_tgt_it_nexus_create(shost, (unsigned long)rport,
rport->port_id);
if (ret) {
device_del(&rport->dev);
transport_destroy_device(&rport->dev);
put_device(&rport->dev);
return ERR_PTR(ret);
}
}
transport_add_device(&rport->dev); transport_add_device(&rport->dev);
transport_configure_device(&rport->dev); transport_configure_device(&rport->dev);
...@@ -774,11 +761,6 @@ EXPORT_SYMBOL_GPL(srp_rport_add); ...@@ -774,11 +761,6 @@ EXPORT_SYMBOL_GPL(srp_rport_add);
void srp_rport_del(struct srp_rport *rport) void srp_rport_del(struct srp_rport *rport)
{ {
struct device *dev = &rport->dev; struct device *dev = &rport->dev;
struct Scsi_Host *shost = dev_to_shost(dev->parent);
if (shost->active_mode & MODE_TARGET &&
rport->roles == SRP_RPORT_ROLE_INITIATOR)
srp_tgt_it_nexus_destroy(shost, (unsigned long)rport);
transport_remove_device(dev); transport_remove_device(dev);
device_del(dev); device_del(dev);
......
#include <scsi/scsi_tgt.h>
#ifdef CONFIG_SCSI_SRP_TGT_ATTRS
static inline int srp_tgt_it_nexus_create(struct Scsi_Host *shost, u64 itn_id,
char *initiator)
{
return scsi_tgt_it_nexus_create(shost, itn_id, initiator);
}
static inline int srp_tgt_it_nexus_destroy(struct Scsi_Host *shost, u64 itn_id)
{
return scsi_tgt_it_nexus_destroy(shost, itn_id);
}
#else
static inline int srp_tgt_it_nexus_create(struct Scsi_Host *shost, u64 itn_id,
char *initiator)
{
return 0;
}
static inline int srp_tgt_it_nexus_destroy(struct Scsi_Host *shost, u64 itn_id)
{
return 0;
}
#endif
...@@ -131,27 +131,6 @@ struct scsi_host_template { ...@@ -131,27 +131,6 @@ struct scsi_host_template {
*/ */
int (* queuecommand)(struct Scsi_Host *, struct scsi_cmnd *); int (* queuecommand)(struct Scsi_Host *, struct scsi_cmnd *);
/*
* The transfer functions are used to queue a scsi command to
* the LLD. When the driver is finished processing the command
* the done callback is invoked.
*
* This is called to inform the LLD to transfer
* scsi_bufflen(cmd) bytes. scsi_sg_count(cmd) speciefies the
* number of scatterlist entried in the command and
* scsi_sglist(cmd) returns the scatterlist.
*
* return values: see queuecommand
*
* If the LLD accepts the cmd, it should set the result to an
* appropriate value when completed before calling the done function.
*
* STATUS: REQUIRED FOR TARGET DRIVERS
*/
/* TODO: rename */
int (* transfer_response)(struct scsi_cmnd *,
void (*done)(struct scsi_cmnd *));
/* /*
* This is an error handling strategy routine. You don't need to * This is an error handling strategy routine. You don't need to
* define one of these if you don't want to - there is a default * define one of these if you don't want to - there is a default
......
/*
* SCSI target definitions
*/
#include <linux/dma-mapping.h>
struct Scsi_Host;
struct scsi_cmnd;
struct scsi_lun;
extern struct Scsi_Host *scsi_tgt_cmd_to_host(struct scsi_cmnd *);
extern int scsi_tgt_alloc_queue(struct Scsi_Host *);
extern void scsi_tgt_free_queue(struct Scsi_Host *);
extern int scsi_tgt_queue_command(struct scsi_cmnd *, u64, struct scsi_lun *, u64);
extern int scsi_tgt_tsk_mgmt_request(struct Scsi_Host *, u64, int, u64,
struct scsi_lun *, void *);
extern struct scsi_cmnd *scsi_host_get_command(struct Scsi_Host *,
enum dma_data_direction, gfp_t);
extern void scsi_host_put_command(struct Scsi_Host *, struct scsi_cmnd *);
extern int scsi_tgt_it_nexus_create(struct Scsi_Host *, u64, char *);
extern int scsi_tgt_it_nexus_destroy(struct Scsi_Host *, u64);
/*
* SCSI target kernel/user interface
*
* Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef __SCSI_TARGET_IF_H
#define __SCSI_TARGET_IF_H
/* user -> kernel */
#define TGT_UEVENT_CMD_RSP 0x0001
#define TGT_UEVENT_IT_NEXUS_RSP 0x0002
#define TGT_UEVENT_TSK_MGMT_RSP 0x0003
/* kernel -> user */
#define TGT_KEVENT_CMD_REQ 0x1001
#define TGT_KEVENT_CMD_DONE 0x1002
#define TGT_KEVENT_IT_NEXUS_REQ 0x1003
#define TGT_KEVENT_TSK_MGMT_REQ 0x1004
struct tgt_event_hdr {
uint16_t version;
uint16_t status;
uint16_t type;
uint16_t len;
} __attribute__ ((aligned (sizeof(uint64_t))));
struct tgt_event {
struct tgt_event_hdr hdr;
union {
/* user-> kernel */
struct {
int host_no;
int result;
aligned_u64 itn_id;
aligned_u64 tag;
aligned_u64 uaddr;
aligned_u64 sense_uaddr;
uint32_t len;
uint32_t sense_len;
uint8_t rw;
} cmd_rsp;
struct {
int host_no;
int result;
aligned_u64 itn_id;
aligned_u64 mid;
} tsk_mgmt_rsp;
struct {
__s32 host_no;
__s32 result;
aligned_u64 itn_id;
__u32 function;
} it_nexus_rsp;
/* kernel -> user */
struct {
int host_no;
uint32_t data_len;
aligned_u64 itn_id;
uint8_t scb[16];
uint8_t lun[8];
int attribute;
aligned_u64 tag;
} cmd_req;
struct {
int host_no;
int result;
aligned_u64 itn_id;
aligned_u64 tag;
} cmd_done;
struct {
int host_no;
int function;
aligned_u64 itn_id;
aligned_u64 tag;
uint8_t lun[8];
aligned_u64 mid;
} tsk_mgmt_req;
struct {
__s32 host_no;
__u32 function;
aligned_u64 itn_id;
__u32 max_cmds;
__u8 initiator_id[16];
} it_nexus_req;
} p;
} __attribute__ ((aligned (sizeof(uint64_t))));
#define TGT_RING_SIZE (1UL << 16)
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment