aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2006-11-30 13:00:50 -0500
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-12-03 10:27:33 -0500
commit26b14823441382264e6f3dfd01b8687dc18196fe (patch)
treec965c5b5967f4485f433cf80db91d3d371d9cc8c /include/scsi
parentc603d04ef6826a29f50cb151cb992f256d0cf19d (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.h77
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
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