1 #include <linux/socket.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...) \
12 if (unlikely(isert_debug_level > 2)) \
13 printk(KERN_DEBUG PFX "%s: " fmt,\
17 #define isert_warn(fmt, arg...) \
19 if (unlikely(isert_debug_level > 0)) \
20 pr_warn(PFX "%s: " fmt, \
24 #define isert_info(fmt, arg...) \
26 if (unlikely(isert_debug_level > 1)) \
27 pr_info(PFX "%s: " fmt, \
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
{
43 enum iser_ib_op_code
{
50 enum iser_conn_state
{
53 ISER_CONN_FULL_FEATURE
,
54 ISER_CONN_TERMINATING
,
59 struct iser_hdr iser_header
;
60 struct iscsi_hdr iscsi_header
;
61 char data
[ISER_RECV_DATA_SEG_LEN
];
64 char pad
[ISER_RX_PAD_SIZE
];
68 struct iser_hdr iser_header
;
69 struct iscsi_hdr iscsi_header
;
70 enum isert_desc_type type
;
72 struct ib_sge tx_sg
[2];
74 struct isert_cmd
*isert_cmd
;
75 struct ib_send_wr send_wr
;
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,
86 struct ib_mr
*prot_mr
;
87 struct ib_fast_reg_page_list
*prot_frpl
;
91 struct fast_reg_descriptor
{
92 struct list_head list
;
93 struct ib_mr
*data_mr
;
94 struct ib_fast_reg_page_list
*data_frpl
;
96 struct pi_context
*pi_ctx
;
99 struct isert_data_buf
{
100 struct scatterlist
*sg
;
103 u32 len
; /* cur_rdma_length */
105 unsigned int dma_nents
;
106 enum dma_data_direction dma_dir
;
115 struct isert_rdma_wr
{
116 struct isert_cmd
*isert_cmd
;
117 enum iser_ib_op_code iser_ib_op
;
118 struct ib_sge
*ib_sge
;
119 struct ib_sge s_ib_sge
;
121 struct ib_rdma_wr
*rdma_wr
;
122 struct ib_rdma_wr s_rdma_wr
;
123 struct ib_sge ib_sg
[3];
124 struct isert_data_buf data
;
125 struct isert_data_buf prot
;
126 struct fast_reg_descriptor
*fr_desc
;
136 struct isert_conn
*conn
;
137 struct iscsi_cmd
*iscsi_cmd
;
138 struct iser_tx_desc tx_desc
;
139 struct iser_rx_desc
*rx_desc
;
140 struct isert_rdma_wr rdma_wr
;
141 struct work_struct comp_work
;
142 struct scatterlist sg
;
148 enum iser_conn_state state
;
149 int post_recv_buf_count
;
150 u32 responder_resources
;
160 struct iser_rx_desc
*rx_descs
;
161 struct ib_recv_wr rx_wr
[ISERT_QP_MAX_RECV_DTOS
];
162 struct iscsi_conn
*conn
;
163 struct list_head node
;
164 struct completion login_comp
;
165 struct completion login_req_comp
;
166 struct iser_tx_desc login_tx_desc
;
167 struct rdma_cm_id
*cm_id
;
169 struct isert_device
*device
;
171 struct completion wait
;
172 struct completion wait_comp_err
;
174 struct list_head fr_pool
;
176 /* lock to protect fastreg pool */
177 spinlock_t pool_lock
;
178 struct work_struct release_work
;
179 struct ib_recv_wr beacon
;
183 #define ISERT_MAX_CQ 64
186 * struct isert_comp - iSER completion context
188 * @device: pointer to device handle
189 * @cq: completion queue
190 * @wcs: work completion array
191 * @active_qps: Number of active QPs attached
192 * to completion context
193 * @work: completion work handle
196 struct isert_device
*device
;
198 struct ib_wc wcs
[16];
200 struct work_struct work
;
203 struct isert_device
{
207 struct ib_device
*ib_device
;
209 struct isert_comp
*comps
;
211 struct list_head dev_node
;
212 struct ib_device_attr dev_attr
;
213 int (*reg_rdma_mem
)(struct iscsi_conn
*conn
,
214 struct iscsi_cmd
*cmd
,
215 struct isert_rdma_wr
*wr
);
216 void (*unreg_rdma_mem
)(struct isert_cmd
*isert_cmd
,
217 struct isert_conn
*isert_conn
);
222 struct semaphore sem
;
223 struct rdma_cm_id
*cm_id
;
225 struct list_head accepted
;
226 struct list_head pending
;