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 ib_send_wr send_wr
;
51 struct fast_reg_descriptor
{
52 struct list_head list
;
53 struct ib_mr
*data_mr
;
54 struct ib_fast_reg_page_list
*data_frpl
;
58 struct isert_rdma_wr
{
59 struct list_head wr_list
;
60 struct isert_cmd
*isert_cmd
;
61 enum iser_ib_op_code iser_ib_op
;
62 struct ib_sge
*ib_sge
;
63 struct ib_sge s_ib_sge
;
65 struct scatterlist
*sge
;
67 struct ib_send_wr
*send_wr
;
68 struct ib_send_wr s_send_wr
;
70 struct fast_reg_descriptor
*fr_desc
;
83 struct isert_conn
*conn
;
84 struct iscsi_cmd
*iscsi_cmd
;
85 struct iser_tx_desc tx_desc
;
86 struct isert_rdma_wr rdma_wr
;
87 struct work_struct comp_work
;
93 enum iser_conn_state state
;
94 int post_recv_buf_count
;
95 atomic_t post_send_buf_count
;
96 u32 responder_resources
;
105 unsigned int conn_rx_desc_head
;
106 struct iser_rx_desc
*conn_rx_descs
;
107 struct ib_recv_wr conn_rx_wr
[ISERT_MIN_POSTED_RX
];
108 struct iscsi_conn
*conn
;
109 struct list_head conn_accept_node
;
110 struct completion conn_login_comp
;
111 struct completion login_req_comp
;
112 struct iser_tx_desc conn_login_tx_desc
;
113 struct rdma_cm_id
*conn_cm_id
;
114 struct ib_pd
*conn_pd
;
115 struct ib_mr
*conn_mr
;
116 struct ib_qp
*conn_qp
;
117 struct isert_device
*conn_device
;
118 struct mutex conn_mutex
;
119 struct completion conn_wait
;
120 struct completion conn_wait_comp_err
;
121 struct kref conn_kref
;
122 struct list_head conn_frwr_pool
;
123 int conn_frwr_pool_size
;
124 /* lock to protect frwr_pool */
125 spinlock_t conn_lock
;
126 struct work_struct release_work
;
129 #define ISERT_MAX_CQ 64
131 struct isert_cq_desc
{
132 struct isert_device
*device
;
134 struct work_struct cq_rx_work
;
135 struct work_struct cq_tx_work
;
138 struct isert_device
{
142 int cq_active_qps
[ISERT_MAX_CQ
];
143 struct ib_device
*ib_device
;
144 struct ib_pd
*dev_pd
;
145 struct ib_mr
*dev_mr
;
146 struct ib_cq
*dev_rx_cq
[ISERT_MAX_CQ
];
147 struct ib_cq
*dev_tx_cq
[ISERT_MAX_CQ
];
148 struct isert_cq_desc
*cq_desc
;
149 struct list_head dev_node
;
150 struct ib_device_attr dev_attr
;
151 int (*reg_rdma_mem
)(struct iscsi_conn
*conn
,
152 struct iscsi_cmd
*cmd
,
153 struct isert_rdma_wr
*wr
);
154 void (*unreg_rdma_mem
)(struct isert_cmd
*isert_cmd
,
155 struct isert_conn
*isert_conn
);
160 struct semaphore np_sem
;
161 struct rdma_cm_id
*np_cm_id
;
162 struct mutex np_accept_mutex
;
163 struct list_head np_accept_list
;
164 struct completion np_login_comp
;