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 struct fast_reg_descriptor
{
54 struct list_head list
;
55 struct ib_mr
*data_mr
;
56 struct ib_fast_reg_page_list
*data_frpl
;
60 struct isert_rdma_wr
{
61 struct list_head wr_list
;
62 struct isert_cmd
*isert_cmd
;
63 enum iser_ib_op_code iser_ib_op
;
64 struct ib_sge
*ib_sge
;
65 struct ib_sge s_ib_sge
;
67 struct scatterlist
*sge
;
69 struct ib_send_wr
*send_wr
;
70 struct ib_send_wr s_send_wr
;
72 struct fast_reg_descriptor
*fr_desc
;
85 struct isert_conn
*conn
;
86 struct iscsi_cmd
*iscsi_cmd
;
87 struct iser_tx_desc tx_desc
;
88 struct isert_rdma_wr rdma_wr
;
89 struct work_struct comp_work
;
95 enum iser_conn_state state
;
97 int post_recv_buf_count
;
98 atomic_t post_send_buf_count
;
99 u32 responder_resources
;
107 unsigned int conn_rx_desc_head
;
108 struct iser_rx_desc
*conn_rx_descs
;
109 struct ib_recv_wr conn_rx_wr
[ISERT_MIN_POSTED_RX
];
110 struct iscsi_conn
*conn
;
111 struct list_head conn_accept_node
;
112 struct completion conn_login_comp
;
113 struct iser_tx_desc conn_login_tx_desc
;
114 struct rdma_cm_id
*conn_cm_id
;
115 struct ib_pd
*conn_pd
;
116 struct ib_mr
*conn_mr
;
117 struct ib_qp
*conn_qp
;
118 struct isert_device
*conn_device
;
119 struct work_struct conn_logout_work
;
120 struct mutex conn_mutex
;
121 struct completion conn_wait
;
122 struct completion conn_wait_comp_err
;
123 struct kref conn_kref
;
124 struct list_head conn_fr_pool
;
125 int conn_fr_pool_size
;
126 /* lock to protect fastreg pool */
127 spinlock_t conn_lock
;
128 #define ISERT_COMP_BATCH_COUNT 8
130 struct llist_head conn_comp_llist
;
133 #define ISERT_MAX_CQ 64
135 struct isert_cq_desc
{
136 struct isert_device
*device
;
138 struct work_struct cq_rx_work
;
139 struct work_struct cq_tx_work
;
142 struct isert_device
{
146 int cq_active_qps
[ISERT_MAX_CQ
];
147 struct ib_device
*ib_device
;
148 struct ib_cq
*dev_rx_cq
[ISERT_MAX_CQ
];
149 struct ib_cq
*dev_tx_cq
[ISERT_MAX_CQ
];
150 struct isert_cq_desc
*cq_desc
;
151 struct list_head dev_node
;
152 struct ib_device_attr dev_attr
;
153 int (*reg_rdma_mem
)(struct iscsi_conn
*conn
,
154 struct iscsi_cmd
*cmd
,
155 struct isert_rdma_wr
*wr
);
156 void (*unreg_rdma_mem
)(struct isert_cmd
*isert_cmd
,
157 struct isert_conn
*isert_conn
);
161 wait_queue_head_t np_accept_wq
;
162 struct rdma_cm_id
*np_cm_id
;
163 struct mutex np_accept_mutex
;
164 struct list_head np_accept_list
;
165 struct completion np_login_comp
;