blob: ba615e4c1d7c324ee93e59c78c17f027c3fb3dd4 [file] [log] [blame]
FUJITA Tomonori26b14822006-12-01 03:00:50 +09001#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
FUJITA Tomonori17b0bcf2007-07-11 15:08:21 +090062extern int srp_cmd_queue(struct Scsi_Host *, struct srp_cmd *, void *, u64, u64);
FUJITA Tomonori26b14822006-12-01 03:00:50 +090063extern 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