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
11 enum isert_desc_type {
16 enum iser_ib_op_code {
23 enum iser_conn_state {
26 ISER_CONN_FULL_FEATURE,
27 ISER_CONN_TERMINATING,
32 struct iser_hdr iser_header;
33 struct iscsi_hdr iscsi_header;
34 char data[ISER_RECV_DATA_SEG_LEN];
37 char pad[ISER_RX_PAD_SIZE];
41 struct iser_hdr iser_header;
42 struct iscsi_hdr iscsi_header;
43 enum isert_desc_type type;
45 struct ib_sge tx_sg[2];
47 struct isert_cmd *isert_cmd;
48 struct llist_node *comp_llnode_batch;
49 struct llist_node comp_llnode;
51 struct ib_send_wr send_wr;
54 enum isert_indicator {
55 ISERT_PROTECTED = 1 << 0,
56 ISERT_DATA_KEY_VALID = 1 << 1,
57 ISERT_PROT_KEY_VALID = 1 << 2,
58 ISERT_SIG_KEY_VALID = 1 << 3,
62 struct ib_mr *prot_mr;
63 struct ib_fast_reg_page_list *prot_frpl;
67 struct fast_reg_descriptor {
68 struct list_head list;
69 struct ib_mr *data_mr;
70 struct ib_fast_reg_page_list *data_frpl;
72 struct pi_context *pi_ctx;
75 struct isert_data_buf {
76 struct scatterlist *sg;
79 u32 len; /* cur_rdma_length */
81 unsigned int dma_nents;
82 enum dma_data_direction dma_dir;
85 struct isert_rdma_wr {
86 struct list_head wr_list;
87 struct isert_cmd *isert_cmd;
88 enum iser_ib_op_code iser_ib_op;
89 struct ib_sge *ib_sge;
90 struct ib_sge s_ib_sge;
92 struct ib_send_wr *send_wr;
93 struct ib_send_wr s_send_wr;
94 struct isert_data_buf data;
95 struct isert_data_buf prot;
96 struct fast_reg_descriptor *fr_desc;
109 struct isert_conn *conn;
110 struct iscsi_cmd *iscsi_cmd;
111 struct iser_tx_desc tx_desc;
112 struct isert_rdma_wr rdma_wr;
113 struct work_struct comp_work;
119 enum iser_conn_state state;
120 int post_recv_buf_count;
121 atomic_t post_send_buf_count;
122 u32 responder_resources;
131 unsigned int conn_rx_desc_head;
132 struct iser_rx_desc *conn_rx_descs;
133 struct ib_recv_wr conn_rx_wr[ISERT_MIN_POSTED_RX];
134 struct iscsi_conn *conn;
135 struct list_head conn_accept_node;
136 struct completion conn_login_comp;
137 struct completion login_req_comp;
138 struct iser_tx_desc conn_login_tx_desc;
139 struct rdma_cm_id *conn_cm_id;
140 struct ib_pd *conn_pd;
141 struct ib_mr *conn_mr;
142 struct ib_qp *conn_qp;
143 struct isert_device *conn_device;
144 struct mutex conn_mutex;
145 struct completion conn_wait;
146 struct completion conn_wait_comp_err;
147 struct kref conn_kref;
148 struct list_head conn_fr_pool;
149 int conn_fr_pool_size;
150 /* lock to protect fastreg pool */
151 spinlock_t conn_lock;
152 struct work_struct release_work;
153 #define ISERT_COMP_BATCH_COUNT 8
155 struct llist_head conn_comp_llist;
158 #define ISERT_MAX_CQ 64
160 struct isert_cq_desc {
161 struct isert_device *device;
163 struct work_struct cq_rx_work;
164 struct work_struct cq_tx_work;
167 struct isert_device {
172 int cq_active_qps[ISERT_MAX_CQ];
173 struct ib_device *ib_device;
174 struct ib_cq *dev_rx_cq[ISERT_MAX_CQ];
175 struct ib_cq *dev_tx_cq[ISERT_MAX_CQ];
176 struct isert_cq_desc *cq_desc;
177 struct list_head dev_node;
178 struct ib_device_attr dev_attr;
179 int (*reg_rdma_mem)(struct iscsi_conn *conn,
180 struct iscsi_cmd *cmd,
181 struct isert_rdma_wr *wr);
182 void (*unreg_rdma_mem)(struct isert_cmd *isert_cmd,
183 struct isert_conn *isert_conn);
188 struct semaphore np_sem;
189 struct rdma_cm_id *np_cm_id;
190 struct mutex np_accept_mutex;
191 struct list_head np_accept_list;
192 struct completion np_login_comp;