diff options
Diffstat (limited to 'include/scsi')
-rw-r--r-- | include/scsi/libiscsi.h | 5 | ||||
-rw-r--r-- | include/scsi/libsas.h | 42 | ||||
-rw-r--r-- | include/scsi/libsrp.h | 77 | ||||
-rw-r--r-- | include/scsi/scsi.h | 5 | ||||
-rw-r--r-- | include/scsi/scsi_cmnd.h | 10 | ||||
-rw-r--r-- | include/scsi/scsi_device.h | 30 | ||||
-rw-r--r-- | include/scsi/scsi_host.h | 69 | ||||
-rw-r--r-- | include/scsi/scsi_tgt.h | 19 | ||||
-rw-r--r-- | include/scsi/scsi_tgt_if.h | 90 | ||||
-rw-r--r-- | include/scsi/scsi_transport_fc.h | 4 | ||||
-rw-r--r-- | include/scsi/scsi_transport_iscsi.h | 6 | ||||
-rw-r--r-- | include/scsi/scsi_transport_sas.h | 2 |
12 files changed, 319 insertions, 40 deletions
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 401192e56e50..ea0816d4904d 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h | |||
@@ -25,6 +25,8 @@ | |||
25 | 25 | ||
26 | #include <linux/types.h> | 26 | #include <linux/types.h> |
27 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
28 | #include <linux/timer.h> | ||
29 | #include <linux/workqueue.h> | ||
28 | #include <scsi/iscsi_proto.h> | 30 | #include <scsi/iscsi_proto.h> |
29 | #include <scsi/iscsi_if.h> | 31 | #include <scsi/iscsi_if.h> |
30 | 32 | ||
@@ -136,7 +138,6 @@ struct iscsi_conn { | |||
136 | 138 | ||
137 | /* control data */ | 139 | /* control data */ |
138 | int id; /* CID */ | 140 | int id; /* CID */ |
139 | struct list_head item; /* maintains list of conns */ | ||
140 | int c_stage; /* connection state */ | 141 | int c_stage; /* connection state */ |
141 | /* | 142 | /* |
142 | * Preallocated buffer for pdus that have data but do not | 143 | * Preallocated buffer for pdus that have data but do not |
@@ -235,10 +236,8 @@ struct iscsi_session { | |||
235 | * - mgmtpool, * | 236 | * - mgmtpool, * |
236 | * - r2tpool */ | 237 | * - r2tpool */ |
237 | int state; /* session state */ | 238 | int state; /* session state */ |
238 | struct list_head item; | ||
239 | int age; /* counts session re-opens */ | 239 | int age; /* counts session re-opens */ |
240 | 240 | ||
241 | struct list_head connections; /* list of connections */ | ||
242 | int cmds_max; /* size of cmds array */ | 241 | int cmds_max; /* size of cmds array */ |
243 | struct iscsi_cmd_task **cmds; /* Original Cmds arr */ | 242 | struct iscsi_cmd_task **cmds; /* Original Cmds arr */ |
244 | struct iscsi_queue cmdpool; /* PDU's pool */ | 243 | struct iscsi_queue cmdpool; /* PDU's pool */ |
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 9582e8401669..0c775fceb675 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <scsi/scsi_device.h> | 35 | #include <scsi/scsi_device.h> |
36 | #include <scsi/scsi_cmnd.h> | 36 | #include <scsi/scsi_cmnd.h> |
37 | #include <scsi/scsi_transport_sas.h> | 37 | #include <scsi/scsi_transport_sas.h> |
38 | #include <asm/scatterlist.h> | ||
38 | 39 | ||
39 | struct block_device; | 40 | struct block_device; |
40 | 41 | ||
@@ -200,9 +201,14 @@ struct domain_device { | |||
200 | void *lldd_dev; | 201 | void *lldd_dev; |
201 | }; | 202 | }; |
202 | 203 | ||
204 | struct sas_discovery_event { | ||
205 | struct work_struct work; | ||
206 | struct asd_sas_port *port; | ||
207 | }; | ||
208 | |||
203 | struct sas_discovery { | 209 | struct sas_discovery { |
204 | spinlock_t disc_event_lock; | 210 | spinlock_t disc_event_lock; |
205 | struct work_struct disc_work[DISC_NUM_EVENTS]; | 211 | struct sas_discovery_event disc_work[DISC_NUM_EVENTS]; |
206 | unsigned long pending; | 212 | unsigned long pending; |
207 | u8 fanout_sas_addr[8]; | 213 | u8 fanout_sas_addr[8]; |
208 | u8 eeds_a[8]; | 214 | u8 eeds_a[8]; |
@@ -248,14 +254,19 @@ struct asd_sas_port { | |||
248 | void *lldd_port; /* not touched by the sas class code */ | 254 | void *lldd_port; /* not touched by the sas class code */ |
249 | }; | 255 | }; |
250 | 256 | ||
257 | struct asd_sas_event { | ||
258 | struct work_struct work; | ||
259 | struct asd_sas_phy *phy; | ||
260 | }; | ||
261 | |||
251 | /* The phy pretty much is controlled by the LLDD. | 262 | /* The phy pretty much is controlled by the LLDD. |
252 | * The class only reads those fields. | 263 | * The class only reads those fields. |
253 | */ | 264 | */ |
254 | struct asd_sas_phy { | 265 | struct asd_sas_phy { |
255 | /* private: */ | 266 | /* private: */ |
256 | /* protected by ha->event_lock */ | 267 | /* protected by ha->event_lock */ |
257 | struct work_struct port_events[PORT_NUM_EVENTS]; | 268 | struct asd_sas_event port_events[PORT_NUM_EVENTS]; |
258 | struct work_struct phy_events[PHY_NUM_EVENTS]; | 269 | struct asd_sas_event phy_events[PHY_NUM_EVENTS]; |
259 | 270 | ||
260 | unsigned long port_events_pending; | 271 | unsigned long port_events_pending; |
261 | unsigned long phy_events_pending; | 272 | unsigned long phy_events_pending; |
@@ -307,10 +318,15 @@ struct scsi_core { | |||
307 | int queue_thread_kill; | 318 | int queue_thread_kill; |
308 | }; | 319 | }; |
309 | 320 | ||
321 | struct sas_ha_event { | ||
322 | struct work_struct work; | ||
323 | struct sas_ha_struct *ha; | ||
324 | }; | ||
325 | |||
310 | struct sas_ha_struct { | 326 | struct sas_ha_struct { |
311 | /* private: */ | 327 | /* private: */ |
312 | spinlock_t event_lock; | 328 | spinlock_t event_lock; |
313 | struct work_struct ha_events[HA_NUM_EVENTS]; | 329 | struct sas_ha_event ha_events[HA_NUM_EVENTS]; |
314 | unsigned long pending; | 330 | unsigned long pending; |
315 | 331 | ||
316 | struct scsi_core core; | 332 | struct scsi_core core; |
@@ -338,6 +354,8 @@ struct sas_ha_struct { | |||
338 | void (*notify_phy_event)(struct asd_sas_phy *, enum phy_event); | 354 | void (*notify_phy_event)(struct asd_sas_phy *, enum phy_event); |
339 | 355 | ||
340 | 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; | ||
341 | }; | 359 | }; |
342 | 360 | ||
343 | #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) |
@@ -526,17 +544,20 @@ struct sas_task { | |||
526 | 544 | ||
527 | void *lldd_task; /* for use by LLDDs */ | 545 | void *lldd_task; /* for use by LLDDs */ |
528 | void *uldd_task; | 546 | void *uldd_task; |
547 | |||
548 | struct work_struct abort_work; | ||
529 | }; | 549 | }; |
530 | 550 | ||
531 | 551 | ||
532 | 552 | ||
533 | #define SAS_TASK_STATE_PENDING 1 | 553 | #define SAS_TASK_STATE_PENDING 1 |
534 | #define SAS_TASK_STATE_DONE 2 | 554 | #define SAS_TASK_STATE_DONE 2 |
535 | #define SAS_TASK_STATE_ABORTED 4 | 555 | #define SAS_TASK_STATE_ABORTED 4 |
556 | #define SAS_TASK_INITIATOR_ABORTED 8 | ||
536 | 557 | ||
537 | static inline struct sas_task *sas_alloc_task(gfp_t flags) | 558 | static inline struct sas_task *sas_alloc_task(gfp_t flags) |
538 | { | 559 | { |
539 | extern kmem_cache_t *sas_task_cache; | 560 | extern struct kmem_cache *sas_task_cache; |
540 | struct sas_task *task = kmem_cache_alloc(sas_task_cache, flags); | 561 | struct sas_task *task = kmem_cache_alloc(sas_task_cache, flags); |
541 | 562 | ||
542 | if (task) { | 563 | if (task) { |
@@ -554,7 +575,7 @@ static inline struct sas_task *sas_alloc_task(gfp_t flags) | |||
554 | static inline void sas_free_task(struct sas_task *task) | 575 | static inline void sas_free_task(struct sas_task *task) |
555 | { | 576 | { |
556 | if (task) { | 577 | if (task) { |
557 | extern kmem_cache_t *sas_task_cache; | 578 | extern struct kmem_cache *sas_task_cache; |
558 | BUG_ON(!list_empty(&task->list)); | 579 | BUG_ON(!list_empty(&task->list)); |
559 | kmem_cache_free(sas_task_cache, task); | 580 | kmem_cache_free(sas_task_cache, task); |
560 | } | 581 | } |
@@ -592,6 +613,7 @@ struct sas_domain_function_template { | |||
592 | extern int sas_register_ha(struct sas_ha_struct *); | 613 | extern int sas_register_ha(struct sas_ha_struct *); |
593 | extern int sas_unregister_ha(struct sas_ha_struct *); | 614 | extern int sas_unregister_ha(struct sas_ha_struct *); |
594 | 615 | ||
616 | int sas_phy_reset(struct sas_phy *phy, int hard_reset); | ||
595 | extern int sas_queuecommand(struct scsi_cmnd *, | 617 | extern int sas_queuecommand(struct scsi_cmnd *, |
596 | void (*scsi_done)(struct scsi_cmnd *)); | 618 | void (*scsi_done)(struct scsi_cmnd *)); |
597 | extern int sas_target_alloc(struct scsi_target *); | 619 | extern int sas_target_alloc(struct scsi_target *); |
@@ -624,4 +646,6 @@ void sas_unregister_dev(struct domain_device *); | |||
624 | 646 | ||
625 | void sas_init_dev(struct domain_device *); | 647 | void sas_init_dev(struct domain_device *); |
626 | 648 | ||
649 | void sas_task_abort(struct work_struct *); | ||
650 | |||
627 | #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 | |||
9 | enum iue_flags { | ||
10 | V_DIOVER, | ||
11 | V_WRITE, | ||
12 | V_LINKED, | ||
13 | V_FLYING, | ||
14 | }; | ||
15 | |||
16 | struct srp_buf { | ||
17 | dma_addr_t dma; | ||
18 | void *buf; | ||
19 | }; | ||
20 | |||
21 | struct srp_queue { | ||
22 | void *pool; | ||
23 | void *items; | ||
24 | struct kfifo *queue; | ||
25 | spinlock_t lock; | ||
26 | }; | ||
27 | |||
28 | struct 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 | |||
43 | struct 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 | |||
53 | typedef int (srp_rdma_t)(struct scsi_cmnd *, struct scatterlist *, int, | ||
54 | struct srp_direct_buf *, int, | ||
55 | enum dma_data_direction, unsigned int); | ||
56 | extern int srp_target_alloc(struct srp_target *, struct device *, size_t, size_t); | ||
57 | extern void srp_target_free(struct srp_target *); | ||
58 | |||
59 | extern struct iu_entry *srp_iu_get(struct srp_target *); | ||
60 | extern void srp_iu_put(struct iu_entry *); | ||
61 | |||
62 | extern int srp_cmd_queue(struct Scsi_Host *, struct srp_cmd *, void *, u64); | ||
63 | extern int srp_transfer_data(struct scsi_cmnd *, struct srp_cmd *, | ||
64 | srp_rdma_t, int, int); | ||
65 | |||
66 | |||
67 | static inline struct srp_target *host_to_srp_target(struct Scsi_Host *host) | ||
68 | { | ||
69 | return (struct srp_target *) host->hostdata; | ||
70 | } | ||
71 | |||
72 | static 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.h b/include/scsi/scsi.h index 84a6d5fe0920..5c0e9791441c 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h | |||
@@ -97,6 +97,7 @@ extern const unsigned char scsi_command_size[8]; | |||
97 | #define PERSISTENT_RESERVE_IN 0x5e | 97 | #define PERSISTENT_RESERVE_IN 0x5e |
98 | #define PERSISTENT_RESERVE_OUT 0x5f | 98 | #define PERSISTENT_RESERVE_OUT 0x5f |
99 | #define REPORT_LUNS 0xa0 | 99 | #define REPORT_LUNS 0xa0 |
100 | #define MAINTENANCE_IN 0xa3 | ||
100 | #define MOVE_MEDIUM 0xa5 | 101 | #define MOVE_MEDIUM 0xa5 |
101 | #define EXCHANGE_MEDIUM 0xa6 | 102 | #define EXCHANGE_MEDIUM 0xa6 |
102 | #define READ_12 0xa8 | 103 | #define READ_12 0xa8 |
@@ -114,6 +115,8 @@ extern const unsigned char scsi_command_size[8]; | |||
114 | #define SERVICE_ACTION_IN 0x9e | 115 | #define SERVICE_ACTION_IN 0x9e |
115 | /* values for service action in */ | 116 | /* values for service action in */ |
116 | #define SAI_READ_CAPACITY_16 0x10 | 117 | #define SAI_READ_CAPACITY_16 0x10 |
118 | /* values for maintenance in */ | ||
119 | #define MI_REPORT_TARGET_PGS 0x0a | ||
117 | 120 | ||
118 | /* Values for T10/04-262r7 */ | 121 | /* Values for T10/04-262r7 */ |
119 | #define ATA_16 0x85 /* 16-byte pass-thru */ | 122 | #define ATA_16 0x85 /* 16-byte pass-thru */ |
@@ -430,7 +433,7 @@ struct scsi_lun { | |||
430 | #define SCSI_IOCTL_GET_PCI 0x5387 | 433 | #define SCSI_IOCTL_GET_PCI 0x5387 |
431 | 434 | ||
432 | /* Pull a u32 out of a SCSI message (using BE SCSI conventions) */ | 435 | /* Pull a u32 out of a SCSI message (using BE SCSI conventions) */ |
433 | static inline u32 scsi_to_u32(u8 *ptr) | 436 | static inline __u32 scsi_to_u32(__u8 *ptr) |
434 | { | 437 | { |
435 | return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3]; | 438 | return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3]; |
436 | } | 439 | } |
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 | ||
9 | struct request; | 9 | struct request; |
10 | struct scatterlist; | 10 | struct scatterlist; |
11 | struct Scsi_Host; | ||
11 | struct scsi_device; | 12 | struct 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 | ||
121 | extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t); | 125 | extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t); |
126 | extern struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *, gfp_t); | ||
122 | extern void scsi_put_command(struct scsi_cmnd *); | 127 | extern void scsi_put_command(struct scsi_cmnd *); |
128 | extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *, | ||
129 | struct device *); | ||
123 | extern void scsi_io_completion(struct scsi_cmnd *, unsigned int); | 130 | extern void scsi_io_completion(struct scsi_cmnd *, unsigned int); |
124 | extern void scsi_finish_command(struct scsi_cmnd *cmd); | 131 | extern void scsi_finish_command(struct scsi_cmnd *cmd); |
125 | extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd); | 132 | extern 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); |
129 | extern void scsi_kunmap_atomic_sg(void *virt); | 136 | extern void scsi_kunmap_atomic_sg(void *virt); |
130 | 137 | ||
138 | extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t); | ||
139 | extern 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 | ||
10 | struct request_queue; | ||
10 | struct block_device; | 11 | struct block_device; |
11 | struct completion; | 12 | struct completion; |
12 | struct module; | 13 | struct 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 | ||
649 | extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *); | 710 | extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *); |
650 | 711 | ||
651 | static inline void scsi_assign_lock(struct Scsi_Host *shost, spinlock_t *lock) | ||
652 | { | ||
653 | shost->host_lock = lock; | ||
654 | } | ||
655 | |||
656 | static inline struct device *scsi_get_device(struct Scsi_Host *shost) | 712 | static 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 *); | |||
671 | extern void scsi_block_requests(struct Scsi_Host *); | 727 | extern void scsi_block_requests(struct Scsi_Host *); |
672 | 728 | ||
673 | struct class_container; | 729 | struct class_container; |
730 | |||
731 | extern 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 | |||
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 *, struct scsi_lun *, u64); | ||
15 | extern int scsi_tgt_tsk_mgmt_request(struct Scsi_Host *, int, u64, struct scsi_lun *, | ||
16 | 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 *); | ||
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 | |||
34 | struct 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 | |||
41 | struct 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_fc.h b/include/scsi/scsi_transport_fc.h index fd352323378b..798f7c7ee426 100644 --- a/include/scsi/scsi_transport_fc.h +++ b/include/scsi/scsi_transport_fc.h | |||
@@ -206,9 +206,9 @@ struct fc_rport { /* aka fc_starget_attrs */ | |||
206 | u8 flags; | 206 | u8 flags; |
207 | struct list_head peers; | 207 | struct list_head peers; |
208 | struct device dev; | 208 | struct device dev; |
209 | struct work_struct dev_loss_work; | 209 | struct delayed_work dev_loss_work; |
210 | struct work_struct scan_work; | 210 | struct work_struct scan_work; |
211 | struct work_struct fail_io_work; | 211 | struct delayed_work fail_io_work; |
212 | struct work_struct stgt_delete_work; | 212 | struct work_struct stgt_delete_work; |
213 | struct work_struct rport_delete_work; | 213 | struct work_struct rport_delete_work; |
214 | } __attribute__((aligned(sizeof(unsigned long)))); | 214 | } __attribute__((aligned(sizeof(unsigned long)))); |
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index 39e833260bd0..d5c218ddc527 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h | |||
@@ -29,7 +29,6 @@ | |||
29 | struct scsi_transport_template; | 29 | struct scsi_transport_template; |
30 | struct iscsi_transport; | 30 | struct iscsi_transport; |
31 | struct Scsi_Host; | 31 | struct Scsi_Host; |
32 | struct mempool_zone; | ||
33 | struct iscsi_cls_conn; | 32 | struct iscsi_cls_conn; |
34 | struct iscsi_conn; | 33 | struct iscsi_conn; |
35 | struct iscsi_cmd_task; | 34 | struct iscsi_cmd_task; |
@@ -157,9 +156,6 @@ struct iscsi_cls_conn { | |||
157 | 156 | ||
158 | int active; /* must be accessed with the connlock */ | 157 | int active; /* must be accessed with the connlock */ |
159 | struct device dev; /* sysfs transport/container device */ | 158 | struct device dev; /* sysfs transport/container device */ |
160 | struct mempool_zone *z_error; | ||
161 | struct mempool_zone *z_pdu; | ||
162 | struct list_head freequeue; | ||
163 | }; | 159 | }; |
164 | 160 | ||
165 | #define iscsi_dev_to_conn(_dev) \ | 161 | #define iscsi_dev_to_conn(_dev) \ |
@@ -180,7 +176,7 @@ struct iscsi_cls_session { | |||
180 | 176 | ||
181 | /* recovery fields */ | 177 | /* recovery fields */ |
182 | int recovery_tmo; | 178 | int recovery_tmo; |
183 | struct work_struct recovery_work; | 179 | struct delayed_work recovery_work; |
184 | 180 | ||
185 | int target_id; | 181 | int target_id; |
186 | 182 | ||
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) \ |