1 #include <linux/socket.h>
4 #include <rdma/ib_verbs.h>
5 #include <rdma/rdma_cm.h>
7 #define ISERT_RDMA_LISTEN_BACKLOG 10
8 #define ISCSI_ISER_SG_TABLESIZE 256
9 #define ISER_FASTREG_LI_WRID 0xffffffffffffffffULL
10 #define ISER_BEACON_WRID 0xfffffffffffffffeULL
12 enum isert_desc_type {
17 enum iser_ib_op_code {
24 enum iser_conn_state {
27 ISER_CONN_FULL_FEATURE,
28 ISER_CONN_TERMINATING,
33 struct iser_hdr iser_header;
34 struct iscsi_hdr iscsi_header;
35 char data[ISER_RECV_DATA_SEG_LEN];
38 char pad[ISER_RX_PAD_SIZE];
42 struct iser_hdr iser_header;
43 struct iscsi_hdr iscsi_header;
44 enum isert_desc_type type;
46 struct ib_sge tx_sg[2];
48 struct isert_cmd *isert_cmd;
49 struct ib_send_wr send_wr;
52 enum isert_indicator {
53 ISERT_PROTECTED = 1 << 0,
54 ISERT_DATA_KEY_VALID = 1 << 1,
55 ISERT_PROT_KEY_VALID = 1 << 2,
56 ISERT_SIG_KEY_VALID = 1 << 3,
60 struct ib_mr *prot_mr;
61 struct ib_fast_reg_page_list *prot_frpl;
65 struct fast_reg_descriptor {
66 struct list_head list;
67 struct ib_mr *data_mr;
68 struct ib_fast_reg_page_list *data_frpl;
70 struct pi_context *pi_ctx;
73 struct isert_data_buf {
74 struct scatterlist *sg;
77 u32 len; /* cur_rdma_length */
79 unsigned int dma_nents;
80 enum dma_data_direction dma_dir;
89 struct isert_rdma_wr {
90 struct list_head wr_list;
91 struct isert_cmd *isert_cmd;
92 enum iser_ib_op_code iser_ib_op;
93 struct ib_sge *ib_sge;
94 struct ib_sge s_ib_sge;
96 struct ib_send_wr *send_wr;
97 struct ib_send_wr s_send_wr;
98 struct ib_sge ib_sg[3];
99 struct isert_data_buf data;
100 struct isert_data_buf prot;
101 struct fast_reg_descriptor *fr_desc;
114 struct isert_conn *conn;
115 struct iscsi_cmd *iscsi_cmd;
116 struct iser_tx_desc tx_desc;
117 struct isert_rdma_wr rdma_wr;
118 struct work_struct comp_work;
124 enum iser_conn_state state;
125 int post_recv_buf_count;
126 u32 responder_resources;
136 unsigned int conn_rx_desc_head;
137 struct iser_rx_desc *conn_rx_descs;
138 struct ib_recv_wr conn_rx_wr[ISERT_MIN_POSTED_RX];
139 struct iscsi_conn *conn;
140 struct list_head conn_accept_node;
141 struct completion conn_login_comp;
142 struct completion login_req_comp;
143 struct iser_tx_desc conn_login_tx_desc;
144 struct rdma_cm_id *conn_cm_id;
145 struct ib_pd *conn_pd;
146 struct ib_mr *conn_mr;
147 struct ib_qp *conn_qp;
148 struct isert_device *conn_device;
149 struct mutex conn_mutex;
150 struct completion conn_wait;
151 struct completion conn_wait_comp_err;
152 struct kref conn_kref;
153 struct list_head conn_fr_pool;
154 int conn_fr_pool_size;
155 /* lock to protect fastreg pool */
156 spinlock_t conn_lock;
157 struct work_struct release_work;
158 struct ib_recv_wr beacon;
161 #define ISERT_MAX_CQ 64
164 * struct isert_comp - iSER completion context
166 * @device: pointer to device handle
167 * @cq: completion queue
168 * @wcs: work completion array
169 * @active_qps: Number of active QPs attached
170 * to completion context
171 * @work: completion work handle
174 struct isert_device *device;
176 struct ib_wc wcs[16];
178 struct work_struct work;
181 struct isert_device {
185 struct ib_device *ib_device;
186 struct isert_comp *comps;
188 struct list_head dev_node;
189 struct ib_device_attr dev_attr;
190 int (*reg_rdma_mem)(struct iscsi_conn *conn,
191 struct iscsi_cmd *cmd,
192 struct isert_rdma_wr *wr);
193 void (*unreg_rdma_mem)(struct isert_cmd *isert_cmd,
194 struct isert_conn *isert_conn);
199 struct semaphore np_sem;
200 struct rdma_cm_id *np_cm_id;
201 struct mutex np_accept_mutex;
202 struct list_head np_accept_list;
203 struct completion np_login_comp;