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
;
90 struct fast_reg_descriptor
{
91 struct list_head list
;
92 struct ib_mr
*data_mr
;
94 struct pi_context
*pi_ctx
;
97 struct isert_data_buf
{
98 struct scatterlist
*sg
;
101 u32 len
; /* cur_rdma_length */
103 unsigned int dma_nents
;
104 enum dma_data_direction dma_dir
;
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
;
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
;
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
;
146 enum iser_conn_state state
;
147 int post_recv_buf_count
;
148 u32 responder_resources
;
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
;
167 struct isert_device
*device
;
169 struct completion wait
;
170 struct completion wait_comp_err
;
172 struct list_head fr_pool
;
174 /* lock to protect fastreg pool */
175 spinlock_t pool_lock
;
176 struct work_struct release_work
;
177 struct ib_recv_wr beacon
;
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
194 struct isert_device
*device
;
196 struct ib_wc wcs
[16];
198 struct work_struct work
;
201 struct isert_device
{
205 struct ib_device
*ib_device
;
207 struct isert_comp
*comps
;
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
);
220 struct semaphore sem
;
221 struct rdma_cm_id
*cm_id
;
223 struct list_head accepted
;
224 struct list_head pending
;