aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-12-06 10:01:18 -0500
committerDavid Howells <dhowells@warthog.cambridge.redhat.com>2006-12-06 10:01:18 -0500
commit4796b71fbb907ce6b8a9acf1852d3646a80b4576 (patch)
tree6263f165446c581efdbb760205c1f85378fe6259 /include/scsi
parent6d5aefb8eaa38e44b5b8cf60c812aceafc02d924 (diff)
parentec0bf39a471bf6fcd01def2bd677128cea940b73 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: drivers/pcmcia/ds.c Fix up merge failures with Linus's head and fix new compile failures. Signed-Off-By: David Howells <dhowells@redhat.com>
Diffstat (limited to 'include/scsi')
-rw-r--r--include/scsi/libsas.h14
-rw-r--r--include/scsi/libsrp.h77
-rw-r--r--include/scsi/scsi_cmnd.h10
-rw-r--r--include/scsi/scsi_device.h30
-rw-r--r--include/scsi/scsi_host.h69
-rw-r--r--include/scsi/scsi_tgt.h19
-rw-r--r--include/scsi/scsi_tgt_if.h90
-rw-r--r--include/scsi/scsi_transport_sas.h2
8 files changed, 288 insertions, 23 deletions
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 1f989fb42c70..b09bdd8c3394 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -354,6 +354,8 @@ struct sas_ha_struct {
354 void (*notify_phy_event)(struct asd_sas_phy *, enum phy_event); 354 void (*notify_phy_event)(struct asd_sas_phy *, enum phy_event);
355 355
356 void *lldd_ha; /* not touched by sas class code */ 356 void *lldd_ha; /* not touched by sas class code */
357
358 struct list_head eh_done_q;
357}; 359};
358 360
359#define SHOST_TO_SAS_HA(_shost) (*(struct sas_ha_struct **)(_shost)->hostdata) 361#define SHOST_TO_SAS_HA(_shost) (*(struct sas_ha_struct **)(_shost)->hostdata)
@@ -542,13 +544,16 @@ struct sas_task {
542 544
543 void *lldd_task; /* for use by LLDDs */ 545 void *lldd_task; /* for use by LLDDs */
544 void *uldd_task; 546 void *uldd_task;
547
548 struct work_struct abort_work;
545}; 549};
546 550
547 551
548 552
549#define SAS_TASK_STATE_PENDING 1 553#define SAS_TASK_STATE_PENDING 1
550#define SAS_TASK_STATE_DONE 2 554#define SAS_TASK_STATE_DONE 2
551#define SAS_TASK_STATE_ABORTED 4 555#define SAS_TASK_STATE_ABORTED 4
556#define SAS_TASK_INITIATOR_ABORTED 8
552 557
553static inline struct sas_task *sas_alloc_task(gfp_t flags) 558static inline struct sas_task *sas_alloc_task(gfp_t flags)
554{ 559{
@@ -608,6 +613,7 @@ struct sas_domain_function_template {
608extern int sas_register_ha(struct sas_ha_struct *); 613extern int sas_register_ha(struct sas_ha_struct *);
609extern int sas_unregister_ha(struct sas_ha_struct *); 614extern int sas_unregister_ha(struct sas_ha_struct *);
610 615
616int sas_phy_reset(struct sas_phy *phy, int hard_reset);
611extern int sas_queuecommand(struct scsi_cmnd *, 617extern int sas_queuecommand(struct scsi_cmnd *,
612 void (*scsi_done)(struct scsi_cmnd *)); 618 void (*scsi_done)(struct scsi_cmnd *));
613extern int sas_target_alloc(struct scsi_target *); 619extern int sas_target_alloc(struct scsi_target *);
@@ -640,4 +646,6 @@ void sas_unregister_dev(struct domain_device *);
640 646
641void sas_init_dev(struct domain_device *); 647void sas_init_dev(struct domain_device *);
642 648
649void sas_task_abort(struct sas_task *task);
650
643#endif /* _SASLIB_H_ */ 651#endif /* _SASLIB_H_ */
diff --git a/include/scsi/libsrp.h b/include/scsi/libsrp.h
new file mode 100644
index 000000000000..d143171896ae
--- /dev/null
+++ b/include/scsi/libsrp.h
@@ -0,0 +1,77 @@
1#ifndef __LIBSRP_H__
2#define __LIBSRP_H__
3
4#include <linux/list.h>
5#include <scsi/scsi_cmnd.h>
6#include <scsi/scsi_host.h>
7#include <scsi/srp.h>
8
9enum iue_flags {
10 V_DIOVER,
11 V_WRITE,
12 V_LINKED,
13 V_FLYING,
14};
15
16struct srp_buf {
17 dma_addr_t dma;
18 void *buf;
19};
20
21struct srp_queue {
22 void *pool;
23 void *items;
24 struct kfifo *queue;
25 spinlock_t lock;
26};
27
28struct srp_target {
29 struct Scsi_Host *shost;
30 struct device *dev;
31
32 spinlock_t lock;
33 struct list_head cmd_queue;
34
35 size_t srp_iu_size;
36 struct srp_queue iu_queue;
37 size_t rx_ring_size;
38 struct srp_buf **rx_ring;
39
40 void *ldata;
41};
42
43struct iu_entry {
44 struct srp_target *target;
45
46 struct list_head ilist;
47 dma_addr_t remote_token;
48 unsigned long flags;
49
50 struct srp_buf *sbuf;
51};
52
53typedef int (srp_rdma_t)(struct scsi_cmnd *, struct scatterlist *, int,
54 struct srp_direct_buf *, int,
55 enum dma_data_direction, unsigned int);
56extern int srp_target_alloc(struct srp_target *, struct device *, size_t, size_t);
57extern void srp_target_free(struct srp_target *);
58
59extern struct iu_entry *srp_iu_get(struct srp_target *);
60extern void srp_iu_put(struct iu_entry *);
61
62extern int srp_cmd_queue(struct Scsi_Host *, struct srp_cmd *, void *, u64);
63extern int srp_transfer_data(struct scsi_cmnd *, struct srp_cmd *,
64 srp_rdma_t, int, int);
65
66
67static inline struct srp_target *host_to_srp_target(struct Scsi_Host *host)
68{
69 return (struct srp_target *) host->hostdata;
70}
71
72static inline int srp_cmd_direction(struct srp_cmd *cmd)
73{
74 return (cmd->buf_fmt >> 4) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
75}
76
77#endif
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index be117f812deb..d6948d0e8cdb 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -8,6 +8,7 @@
8 8
9struct request; 9struct request;
10struct scatterlist; 10struct scatterlist;
11struct Scsi_Host;
11struct scsi_device; 12struct scsi_device;
12 13
13 14
@@ -72,6 +73,9 @@ struct scsi_cmnd {
72 unsigned short use_sg; /* Number of pieces of scatter-gather */ 73 unsigned short use_sg; /* Number of pieces of scatter-gather */
73 unsigned short sglist_len; /* size of malloc'd scatter-gather list */ 74 unsigned short sglist_len; /* size of malloc'd scatter-gather list */
74 75
76 /* offset in cmd we are at (for multi-transfer tgt cmds) */
77 unsigned offset;
78
75 unsigned underflow; /* Return error if less than 79 unsigned underflow; /* Return error if less than
76 this amount is transferred */ 80 this amount is transferred */
77 81
@@ -119,7 +123,10 @@ struct scsi_cmnd {
119}; 123};
120 124
121extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t); 125extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t);
126extern struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *, gfp_t);
122extern void scsi_put_command(struct scsi_cmnd *); 127extern void scsi_put_command(struct scsi_cmnd *);
128extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *,
129 struct device *);
123extern void scsi_io_completion(struct scsi_cmnd *, unsigned int); 130extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
124extern void scsi_finish_command(struct scsi_cmnd *cmd); 131extern void scsi_finish_command(struct scsi_cmnd *cmd);
125extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd); 132extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd);
@@ -128,4 +135,7 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
128 size_t *offset, size_t *len); 135 size_t *offset, size_t *len);
129extern void scsi_kunmap_atomic_sg(void *virt); 136extern void scsi_kunmap_atomic_sg(void *virt);
130 137
138extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t);
139extern void scsi_free_sgtable(struct scatterlist *, int);
140
131#endif /* _SCSI_SCSI_CMND_H */ 141#endif /* _SCSI_SCSI_CMND_H */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index b401c82036be..ebf31b16dc49 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -223,13 +223,13 @@ extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *,
223 struct scsi_device *); 223 struct scsi_device *);
224 224
225/** 225/**
226 * shost_for_each_device - iterate over all devices of a host 226 * shost_for_each_device - iterate over all devices of a host
227 * @sdev: iterator 227 * @sdev: the &struct scsi_device to use as a cursor
228 * @host: host whiches devices we want to iterate over 228 * @shost: the &struct scsi_host to iterate over
229 * 229 *
230 * This traverses over each devices of @shost. The devices have 230 * Iterator that returns each device attached to @shost. This loop
231 * a reference that must be released by scsi_host_put when breaking 231 * takes a reference on each device and releases it at the end. If
232 * out of the loop. 232 * you break out of the loop, you must call scsi_device_put(sdev).
233 */ 233 */
234#define shost_for_each_device(sdev, shost) \ 234#define shost_for_each_device(sdev, shost) \
235 for ((sdev) = __scsi_iterate_devices((shost), NULL); \ 235 for ((sdev) = __scsi_iterate_devices((shost), NULL); \
@@ -237,17 +237,17 @@ extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *,
237 (sdev) = __scsi_iterate_devices((shost), (sdev))) 237 (sdev) = __scsi_iterate_devices((shost), (sdev)))
238 238
239/** 239/**
240 * __shost_for_each_device - iterate over all devices of a host (UNLOCKED) 240 * __shost_for_each_device - iterate over all devices of a host (UNLOCKED)
241 * @sdev: iterator 241 * @sdev: the &struct scsi_device to use as a cursor
242 * @host: host whiches devices we want to iterate over 242 * @shost: the &struct scsi_host to iterate over
243 * 243 *
244 * This traverses over each devices of @shost. It does _not_ take a 244 * Iterator that returns each device attached to @shost. It does _not_
245 * reference on the scsi_device, thus it the whole loop must be protected 245 * take a reference on the scsi_device, so the whole loop must be
246 * by shost->host_lock. 246 * protected by shost->host_lock.
247 * 247 *
248 * Note: The only reason why drivers would want to use this is because 248 * Note: The only reason to use this is because you need to access the
249 * they're need to access the device list in irq context. Otherwise you 249 * device list in interrupt context. Otherwise you really want to use
250 * really want to use shost_for_each_device instead. 250 * shost_for_each_device instead.
251 */ 251 */
252#define __shost_for_each_device(sdev, shost) \ 252#define __shost_for_each_device(sdev, shost) \
253 list_for_each_entry((sdev), &((shost)->__devices), siblings) 253 list_for_each_entry((sdev), &((shost)->__devices), siblings)
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 39c6f8cc20c3..7f1f411d07af 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -7,6 +7,7 @@
7#include <linux/workqueue.h> 7#include <linux/workqueue.h>
8#include <linux/mutex.h> 8#include <linux/mutex.h>
9 9
10struct request_queue;
10struct block_device; 11struct block_device;
11struct completion; 12struct completion;
12struct module; 13struct module;
@@ -124,6 +125,39 @@ struct scsi_host_template {
124 void (*done)(struct scsi_cmnd *)); 125 void (*done)(struct scsi_cmnd *));
125 126
126 /* 127 /*
128 * The transfer functions are used to queue a scsi command to
129 * the LLD. When the driver is finished processing the command
130 * the done callback is invoked.
131 *
132 * return values: see queuecommand
133 *
134 * If the LLD accepts the cmd, it should set the result to an
135 * appropriate value when completed before calling the done function.
136 *
137 * STATUS: REQUIRED FOR TARGET DRIVERS
138 */
139 /* TODO: rename */
140 int (* transfer_response)(struct scsi_cmnd *,
141 void (*done)(struct scsi_cmnd *));
142 /*
143 * This is called to inform the LLD to transfer cmd->request_bufflen
144 * bytes of the cmd at cmd->offset in the cmd. The cmd->use_sg
145 * speciefies the number of scatterlist entried in the command
146 * and cmd->request_buffer contains the scatterlist.
147 *
148 * If the command cannot be processed in one transfer_data call
149 * becuase a scatterlist within the LLD's limits cannot be
150 * created then transfer_data will be called multiple times.
151 * It is initially called from process context, and later
152 * calls are from the interrup context.
153 */
154 int (* transfer_data)(struct scsi_cmnd *,
155 void (*done)(struct scsi_cmnd *));
156
157 /* Used as callback for the completion of task management request. */
158 int (* tsk_mgmt_response)(u64 mid, int result);
159
160 /*
127 * This is an error handling strategy routine. You don't need to 161 * This is an error handling strategy routine. You don't need to
128 * define one of these if you don't want to - there is a default 162 * define one of these if you don't want to - there is a default
129 * routine that is present that should work in most cases. For those 163 * routine that is present that should work in most cases. For those
@@ -241,6 +275,24 @@ struct scsi_host_template {
241 void (* target_destroy)(struct scsi_target *); 275 void (* target_destroy)(struct scsi_target *);
242 276
243 /* 277 /*
278 * If a host has the ability to discover targets on its own instead
279 * of scanning the entire bus, it can fill in this function and
280 * call scsi_scan_host(). This function will be called periodically
281 * until it returns 1 with the scsi_host and the elapsed time of
282 * the scan in jiffies.
283 *
284 * Status: OPTIONAL
285 */
286 int (* scan_finished)(struct Scsi_Host *, unsigned long);
287
288 /*
289 * If the host wants to be called before the scan starts, but
290 * after the midlayer has set up ready for the scan, it can fill
291 * in this function.
292 */
293 void (* scan_start)(struct Scsi_Host *);
294
295 /*
244 * fill in this function to allow the queue depth of this host 296 * fill in this function to allow the queue depth of this host
245 * to be changeable (on a per device basis). returns either 297 * to be changeable (on a per device basis). returns either
246 * the current queue depth setting (may be different from what 298 * the current queue depth setting (may be different from what
@@ -552,6 +604,9 @@ struct Scsi_Host {
552 /* task mgmt function in progress */ 604 /* task mgmt function in progress */
553 unsigned tmf_in_progress:1; 605 unsigned tmf_in_progress:1;
554 606
607 /* Asynchronous scan in progress */
608 unsigned async_scan:1;
609
555 /* 610 /*
556 * Optional work queue to be utilized by the transport 611 * Optional work queue to be utilized by the transport
557 */ 612 */
@@ -568,6 +623,12 @@ struct Scsi_Host {
568 */ 623 */
569 unsigned int max_host_blocked; 624 unsigned int max_host_blocked;
570 625
626 /*
627 * q used for scsi_tgt msgs, async events or any other requests that
628 * need to be processed in userspace
629 */
630 struct request_queue *uspace_req_q;
631
571 /* legacy crap */ 632 /* legacy crap */
572 unsigned long base; 633 unsigned long base;
573 unsigned long io_port; 634 unsigned long io_port;
@@ -648,11 +709,6 @@ extern const char *scsi_host_state_name(enum scsi_host_state);
648 709
649extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *); 710extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *);
650 711
651static inline void scsi_assign_lock(struct Scsi_Host *shost, spinlock_t *lock)
652{
653 shost->host_lock = lock;
654}
655
656static inline struct device *scsi_get_device(struct Scsi_Host *shost) 712static inline struct device *scsi_get_device(struct Scsi_Host *shost)
657{ 713{
658 return shost->shost_gendev.parent; 714 return shost->shost_gendev.parent;
@@ -671,6 +727,9 @@ extern void scsi_unblock_requests(struct Scsi_Host *);
671extern void scsi_block_requests(struct Scsi_Host *); 727extern void scsi_block_requests(struct Scsi_Host *);
672 728
673struct class_container; 729struct class_container;
730
731extern struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,
732 void (*) (struct request_queue *));
674/* 733/*
675 * These two functions are used to allocate and free a pseudo device 734 * These two functions are used to allocate and free a pseudo device
676 * which will connect to the host adapter itself rather than any 735 * which will connect to the host adapter itself rather than any
diff --git a/include/scsi/scsi_tgt.h b/include/scsi/scsi_tgt.h
new file mode 100644
index 000000000000..4f4427937af2
--- /dev/null
+++ b/include/scsi/scsi_tgt.h
@@ -0,0 +1,19 @@
1/*
2 * SCSI target definitions
3 */
4
5#include <linux/dma-mapping.h>
6
7struct Scsi_Host;
8struct scsi_cmnd;
9struct scsi_lun;
10
11extern struct Scsi_Host *scsi_tgt_cmd_to_host(struct scsi_cmnd *);
12extern int scsi_tgt_alloc_queue(struct Scsi_Host *);
13extern void scsi_tgt_free_queue(struct Scsi_Host *);
14extern int scsi_tgt_queue_command(struct scsi_cmnd *, struct scsi_lun *, u64);
15extern int scsi_tgt_tsk_mgmt_request(struct Scsi_Host *, int, u64, struct scsi_lun *,
16 void *);
17extern struct scsi_cmnd *scsi_host_get_command(struct Scsi_Host *,
18 enum dma_data_direction, gfp_t);
19extern void scsi_host_put_command(struct Scsi_Host *, struct scsi_cmnd *);
diff --git a/include/scsi/scsi_tgt_if.h b/include/scsi/scsi_tgt_if.h
new file mode 100644
index 000000000000..46d5e70d7215
--- /dev/null
+++ b/include/scsi/scsi_tgt_if.h
@@ -0,0 +1,90 @@
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_TSK_MGMT_RSP 0x0002
28
29/* kernel -> user */
30#define TGT_KEVENT_CMD_REQ 0x1001
31#define TGT_KEVENT_CMD_DONE 0x1002
32#define TGT_KEVENT_TSK_MGMT_REQ 0x1003
33
34struct tgt_event_hdr {
35 uint16_t version;
36 uint16_t status;
37 uint16_t type;
38 uint16_t len;
39} __attribute__ ((aligned (sizeof(uint64_t))));
40
41struct tgt_event {
42 struct tgt_event_hdr hdr;
43
44 union {
45 /* user-> kernel */
46 struct {
47 int host_no;
48 uint32_t len;
49 int result;
50 aligned_u64 uaddr;
51 uint8_t rw;
52 aligned_u64 tag;
53 } cmd_rsp;
54 struct {
55 int host_no;
56 aligned_u64 mid;
57 int result;
58 } tsk_mgmt_rsp;
59
60
61 /* kernel -> user */
62 struct {
63 int host_no;
64 uint32_t data_len;
65 uint8_t scb[16];
66 uint8_t lun[8];
67 int attribute;
68 aligned_u64 tag;
69 } cmd_req;
70 struct {
71 int host_no;
72 aligned_u64 tag;
73 int result;
74 } cmd_done;
75 struct {
76 int host_no;
77 int function;
78 aligned_u64 tag;
79 uint8_t lun[8];
80 aligned_u64 mid;
81 } tsk_mgmt_req;
82 } p;
83} __attribute__ ((aligned (sizeof(uint64_t))));
84
85#define TGT_RING_SIZE (1UL << 16)
86#define TGT_RING_PAGES (TGT_RING_SIZE >> PAGE_SHIFT)
87#define TGT_EVENT_PER_PAGE (PAGE_SIZE / sizeof(struct tgt_event))
88#define TGT_MAX_EVENTS (TGT_EVENT_PER_PAGE * TGT_RING_PAGES)
89
90#endif
diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h
index 53024377f3b8..59633a82de47 100644
--- a/include/scsi/scsi_transport_sas.h
+++ b/include/scsi/scsi_transport_sas.h
@@ -73,6 +73,8 @@ struct sas_phy {
73 73
74 /* for the list of phys belonging to a port */ 74 /* for the list of phys belonging to a port */
75 struct list_head port_siblings; 75 struct list_head port_siblings;
76
77 struct work_struct reset_work;
76}; 78};
77 79
78#define dev_to_phy(d) \ 80#define dev_to_phy(d) \