diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2006-11-30 13:00:50 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-12-03 10:27:33 -0500 |
commit | 26b14823441382264e6f3dfd01b8687dc18196fe (patch) | |
tree | c965c5b5967f4485f433cf80db91d3d371d9cc8c /include/scsi | |
parent | c603d04ef6826a29f50cb151cb992f256d0cf19d (diff) |
[SCSI] scsi tgt: SCSI RDMA Protocol library functions
libsrp provides helper functions for SRP target drivers.
Some SRP target drivers would be out of drivers/scsi/ so we added an
entry for libsrp in drivers/scsi/Kconfig.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: Santiago Leon <santil@us.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'include/scsi')
-rw-r--r-- | include/scsi/libsrp.h | 77 |
1 files changed, 77 insertions, 0 deletions
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 | ||