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_TERMINATING,
31 struct iser_hdr iser_header;
32 struct iscsi_hdr iscsi_header;
33 char data[ISER_RECV_DATA_SEG_LEN];
36 char pad[ISER_RX_PAD_SIZE];
40 struct iser_hdr iser_header;
41 struct iscsi_hdr iscsi_header;
42 enum isert_desc_type type;
44 struct ib_sge tx_sg[2];
46 struct isert_cmd *isert_cmd;
47 struct llist_node *comp_llnode_batch;
48 struct llist_node comp_llnode;
50 struct ib_send_wr send_wr;
53 enum isert_indicator {
54 ISERT_PROTECTED = 1 << 0,
55 ISERT_DATA_KEY_VALID = 1 << 1,
56 ISERT_PROT_KEY_VALID = 1 << 2,
57 ISERT_SIG_KEY_VALID = 1 << 3,
61 struct ib_mr *prot_mr;
62 struct ib_fast_reg_page_list *prot_frpl;
66 struct fast_reg_descriptor {
67 struct list_head list;
68 struct ib_mr *data_mr;
69 struct ib_fast_reg_page_list *data_frpl;
71 struct pi_context *pi_ctx;
74 struct isert_data_buf {
75 struct scatterlist *sg;
78 u32 len; /* cur_rdma_length */
80 unsigned int dma_nents;
81 enum dma_data_direction dma_dir;
84 struct isert_rdma_wr {
85 struct list_head wr_list;
86 struct isert_cmd *isert_cmd;
87 enum iser_ib_op_code iser_ib_op;
88 struct ib_sge *ib_sge;
89 struct ib_sge s_ib_sge;
91 struct ib_send_wr *send_wr;
92 struct ib_send_wr s_send_wr;
93 struct isert_data_buf data;
94 struct isert_data_buf prot;
95 struct fast_reg_descriptor *fr_desc;
108 struct isert_conn *conn;
109 struct iscsi_cmd *iscsi_cmd;
110 struct iser_tx_desc tx_desc;
111 struct isert_rdma_wr rdma_wr;
112 struct work_struct comp_work;
118 enum iser_conn_state state;
119 int post_recv_buf_count;
120 atomic_t post_send_buf_count;
121 u32 responder_resources;
129 unsigned int conn_rx_desc_head;
130 struct iser_rx_desc *conn_rx_descs;
131 struct ib_recv_wr conn_rx_wr[ISERT_MIN_POSTED_RX];
132 struct iscsi_conn *conn;
133 struct list_head conn_accept_node;
134 struct completion conn_login_comp;
135 struct iser_tx_desc conn_login_tx_desc;
136 struct rdma_cm_id *conn_cm_id;
137 struct ib_pd *conn_pd;
138 struct ib_mr *conn_mr;
139 struct ib_qp *conn_qp;
140 struct isert_device *conn_device;
141 struct work_struct conn_logout_work;
142 struct mutex conn_mutex;
143 struct completion conn_wait;
144 struct completion conn_wait_comp_err;
145 struct kref conn_kref;
146 struct list_head conn_fr_pool;
147 int conn_fr_pool_size;
148 /* lock to protect fastreg pool */
149 spinlock_t conn_lock;
150 #define ISERT_COMP_BATCH_COUNT 8
152 struct llist_head conn_comp_llist;
156 #define ISERT_MAX_CQ 64
158 struct isert_cq_desc {
159 struct isert_device *device;
161 struct work_struct cq_rx_work;
162 struct work_struct cq_tx_work;
165 struct isert_device {
170 int cq_active_qps[ISERT_MAX_CQ];
171 struct ib_device *ib_device;
172 struct ib_cq *dev_rx_cq[ISERT_MAX_CQ];
173 struct ib_cq *dev_tx_cq[ISERT_MAX_CQ];
174 struct isert_cq_desc *cq_desc;
175 struct list_head dev_node;
176 struct ib_device_attr dev_attr;
177 int (*reg_rdma_mem)(struct iscsi_conn *conn,
178 struct iscsi_cmd *cmd,
179 struct isert_rdma_wr *wr);
180 void (*unreg_rdma_mem)(struct isert_cmd *isert_cmd,
181 struct isert_conn *isert_conn);
185 struct semaphore np_sem;
186 struct rdma_cm_id *np_cm_id;
187 struct mutex np_accept_mutex;
188 struct list_head np_accept_list;
189 struct completion np_login_comp;