]>
Commit | Line | Data |
---|---|---|
26b14823 FT |
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 |