of: MSI: Simplify irqdomain lookup
[linux/fpc-iii.git] / drivers / infiniband / ulp / isert / ib_isert.h
blob3d7fbc47c3434c32308136b7faec65590b74d439
1 #include <linux/socket.h>
2 #include <linux/in.h>
3 #include <linux/in6.h>
4 #include <rdma/ib_verbs.h>
5 #include <rdma/rdma_cm.h>
7 #define DRV_NAME "isert"
8 #define PFX DRV_NAME ": "
10 #define isert_dbg(fmt, arg...) \
11 do { \
12 if (unlikely(isert_debug_level > 2)) \
13 printk(KERN_DEBUG PFX "%s: " fmt,\
14 __func__ , ## arg); \
15 } while (0)
17 #define isert_warn(fmt, arg...) \
18 do { \
19 if (unlikely(isert_debug_level > 0)) \
20 pr_warn(PFX "%s: " fmt, \
21 __func__ , ## arg); \
22 } while (0)
24 #define isert_info(fmt, arg...) \
25 do { \
26 if (unlikely(isert_debug_level > 1)) \
27 pr_info(PFX "%s: " fmt, \
28 __func__ , ## arg); \
29 } while (0)
31 #define isert_err(fmt, arg...) \
32 pr_err(PFX "%s: " fmt, __func__ , ## arg)
34 #define ISCSI_ISER_SG_TABLESIZE 256
35 #define ISER_FASTREG_LI_WRID 0xffffffffffffffffULL
36 #define ISER_BEACON_WRID 0xfffffffffffffffeULL
38 enum isert_desc_type {
39 ISCSI_TX_CONTROL,
40 ISCSI_TX_DATAIN
43 enum iser_ib_op_code {
44 ISER_IB_RECV,
45 ISER_IB_SEND,
46 ISER_IB_RDMA_WRITE,
47 ISER_IB_RDMA_READ,
50 enum iser_conn_state {
51 ISER_CONN_INIT,
52 ISER_CONN_UP,
53 ISER_CONN_FULL_FEATURE,
54 ISER_CONN_TERMINATING,
55 ISER_CONN_DOWN,
58 struct iser_rx_desc {
59 struct iser_hdr iser_header;
60 struct iscsi_hdr iscsi_header;
61 char data[ISER_RECV_DATA_SEG_LEN];
62 u64 dma_addr;
63 struct ib_sge rx_sg;
64 char pad[ISER_RX_PAD_SIZE];
65 } __packed;
67 struct iser_tx_desc {
68 struct iser_hdr iser_header;
69 struct iscsi_hdr iscsi_header;
70 enum isert_desc_type type;
71 u64 dma_addr;
72 struct ib_sge tx_sg[2];
73 int num_sge;
74 struct isert_cmd *isert_cmd;
75 struct ib_send_wr send_wr;
76 } __packed;
78 enum isert_indicator {
79 ISERT_PROTECTED = 1 << 0,
80 ISERT_DATA_KEY_VALID = 1 << 1,
81 ISERT_PROT_KEY_VALID = 1 << 2,
82 ISERT_SIG_KEY_VALID = 1 << 3,
85 struct pi_context {
86 struct ib_mr *prot_mr;
87 struct ib_mr *sig_mr;
90 struct fast_reg_descriptor {
91 struct list_head list;
92 struct ib_mr *data_mr;
93 u8 ind;
94 struct pi_context *pi_ctx;
97 struct isert_data_buf {
98 struct scatterlist *sg;
99 int nents;
100 u32 sg_off;
101 u32 len; /* cur_rdma_length */
102 u32 offset;
103 unsigned int dma_nents;
104 enum dma_data_direction dma_dir;
107 enum {
108 DATA = 0,
109 PROT = 1,
110 SIG = 2,
113 struct isert_rdma_wr {
114 struct isert_cmd *isert_cmd;
115 enum iser_ib_op_code iser_ib_op;
116 struct ib_sge *ib_sge;
117 struct ib_sge s_ib_sge;
118 int rdma_wr_num;
119 struct ib_rdma_wr *rdma_wr;
120 struct ib_rdma_wr s_rdma_wr;
121 struct ib_sge ib_sg[3];
122 struct isert_data_buf data;
123 struct isert_data_buf prot;
124 struct fast_reg_descriptor *fr_desc;
127 struct isert_cmd {
128 uint32_t read_stag;
129 uint32_t write_stag;
130 uint64_t read_va;
131 uint64_t write_va;
132 u64 pdu_buf_dma;
133 u32 pdu_buf_len;
134 struct isert_conn *conn;
135 struct iscsi_cmd *iscsi_cmd;
136 struct iser_tx_desc tx_desc;
137 struct iser_rx_desc *rx_desc;
138 struct isert_rdma_wr rdma_wr;
139 struct work_struct comp_work;
140 struct scatterlist sg;
143 struct isert_device;
145 struct isert_conn {
146 enum iser_conn_state state;
147 int post_recv_buf_count;
148 u32 responder_resources;
149 u32 initiator_depth;
150 bool pi_support;
151 u32 max_sge;
152 char *login_buf;
153 char *login_req_buf;
154 char *login_rsp_buf;
155 u64 login_req_dma;
156 int login_req_len;
157 u64 login_rsp_dma;
158 struct iser_rx_desc *rx_descs;
159 struct ib_recv_wr rx_wr[ISERT_QP_MAX_RECV_DTOS];
160 struct iscsi_conn *conn;
161 struct list_head node;
162 struct completion login_comp;
163 struct completion login_req_comp;
164 struct iser_tx_desc login_tx_desc;
165 struct rdma_cm_id *cm_id;
166 struct ib_qp *qp;
167 struct isert_device *device;
168 struct mutex mutex;
169 struct completion wait;
170 struct completion wait_comp_err;
171 struct kref kref;
172 struct list_head fr_pool;
173 int fr_pool_size;
174 /* lock to protect fastreg pool */
175 spinlock_t pool_lock;
176 struct work_struct release_work;
177 struct ib_recv_wr beacon;
178 bool logout_posted;
181 #define ISERT_MAX_CQ 64
184 * struct isert_comp - iSER completion context
186 * @device: pointer to device handle
187 * @cq: completion queue
188 * @wcs: work completion array
189 * @active_qps: Number of active QPs attached
190 * to completion context
191 * @work: completion work handle
193 struct isert_comp {
194 struct isert_device *device;
195 struct ib_cq *cq;
196 struct ib_wc wcs[16];
197 int active_qps;
198 struct work_struct work;
201 struct isert_device {
202 int use_fastreg;
203 bool pi_capable;
204 int refcount;
205 struct ib_device *ib_device;
206 struct ib_pd *pd;
207 struct isert_comp *comps;
208 int comps_used;
209 struct list_head dev_node;
210 struct ib_device_attr dev_attr;
211 int (*reg_rdma_mem)(struct iscsi_conn *conn,
212 struct iscsi_cmd *cmd,
213 struct isert_rdma_wr *wr);
214 void (*unreg_rdma_mem)(struct isert_cmd *isert_cmd,
215 struct isert_conn *isert_conn);
218 struct isert_np {
219 struct iscsi_np *np;
220 struct semaphore sem;
221 struct rdma_cm_id *cm_id;
222 struct mutex mutex;
223 struct list_head accepted;
224 struct list_head pending;