Nicholas Bellinger | b8d26b3 | 2013-03-07 00:56:19 -0800 | [diff] [blame] | 1 | #include <linux/socket.h> |
| 2 | #include <linux/in.h> |
| 3 | #include <linux/in6.h> |
| 4 | #include <rdma/ib_verbs.h> |
| 5 | #include <rdma/rdma_cm.h> |
| 6 | |
| 7 | #define ISERT_RDMA_LISTEN_BACKLOG 10 |
| 8 | |
| 9 | enum isert_desc_type { |
| 10 | ISCSI_TX_CONTROL, |
| 11 | ISCSI_TX_DATAIN |
| 12 | }; |
| 13 | |
| 14 | enum iser_ib_op_code { |
| 15 | ISER_IB_RECV, |
| 16 | ISER_IB_SEND, |
| 17 | ISER_IB_RDMA_WRITE, |
| 18 | ISER_IB_RDMA_READ, |
| 19 | }; |
| 20 | |
| 21 | enum iser_conn_state { |
| 22 | ISER_CONN_INIT, |
| 23 | ISER_CONN_UP, |
Sagi Grimberg | dc0672f | 2015-01-30 22:17:26 +0000 | [diff] [blame] | 24 | ISER_CONN_FULL_FEATURE, |
Nicholas Bellinger | b8d26b3 | 2013-03-07 00:56:19 -0800 | [diff] [blame] | 25 | ISER_CONN_TERMINATING, |
| 26 | ISER_CONN_DOWN, |
| 27 | }; |
| 28 | |
| 29 | struct iser_rx_desc { |
| 30 | struct iser_hdr iser_header; |
| 31 | struct iscsi_hdr iscsi_header; |
| 32 | char data[ISER_RECV_DATA_SEG_LEN]; |
| 33 | u64 dma_addr; |
| 34 | struct ib_sge rx_sg; |
| 35 | char pad[ISER_RX_PAD_SIZE]; |
| 36 | } __packed; |
| 37 | |
| 38 | struct iser_tx_desc { |
| 39 | struct iser_hdr iser_header; |
| 40 | struct iscsi_hdr iscsi_header; |
| 41 | enum isert_desc_type type; |
| 42 | u64 dma_addr; |
| 43 | struct ib_sge tx_sg[2]; |
| 44 | int num_sge; |
| 45 | struct isert_cmd *isert_cmd; |
| 46 | struct ib_send_wr send_wr; |
| 47 | } __packed; |
| 48 | |
| 49 | struct isert_rdma_wr { |
| 50 | struct list_head wr_list; |
| 51 | struct isert_cmd *isert_cmd; |
| 52 | enum iser_ib_op_code iser_ib_op; |
| 53 | struct ib_sge *ib_sge; |
| 54 | int num_sge; |
| 55 | struct scatterlist *sge; |
| 56 | int send_wr_num; |
| 57 | struct ib_send_wr *send_wr; |
| 58 | }; |
| 59 | |
| 60 | struct isert_cmd { |
| 61 | uint32_t read_stag; |
| 62 | uint32_t write_stag; |
| 63 | uint64_t read_va; |
| 64 | uint64_t write_va; |
| 65 | u64 sense_buf_dma; |
| 66 | u32 sense_buf_len; |
| 67 | u32 read_va_off; |
| 68 | u32 write_va_off; |
| 69 | u32 rdma_wr_num; |
| 70 | struct isert_conn *conn; |
| 71 | struct iscsi_cmd iscsi_cmd; |
| 72 | struct ib_sge *ib_sge; |
| 73 | struct iser_tx_desc tx_desc; |
| 74 | struct isert_rdma_wr rdma_wr; |
| 75 | struct work_struct comp_work; |
| 76 | }; |
| 77 | |
| 78 | struct isert_device; |
| 79 | |
| 80 | struct isert_conn { |
| 81 | enum iser_conn_state state; |
Nicholas Bellinger | b8d26b3 | 2013-03-07 00:56:19 -0800 | [diff] [blame] | 82 | int post_recv_buf_count; |
| 83 | atomic_t post_send_buf_count; |
| 84 | u32 responder_resources; |
| 85 | u32 initiator_depth; |
| 86 | u32 max_sge; |
| 87 | char *login_buf; |
| 88 | char *login_req_buf; |
| 89 | char *login_rsp_buf; |
| 90 | u64 login_req_dma; |
Sagi Grimberg | 022ff2f | 2015-01-30 22:17:27 +0000 | [diff] [blame] | 91 | int login_req_len; |
Nicholas Bellinger | b8d26b3 | 2013-03-07 00:56:19 -0800 | [diff] [blame] | 92 | u64 login_rsp_dma; |
| 93 | unsigned int conn_rx_desc_head; |
| 94 | struct iser_rx_desc *conn_rx_descs; |
| 95 | struct ib_recv_wr conn_rx_wr[ISERT_MIN_POSTED_RX]; |
| 96 | struct iscsi_conn *conn; |
| 97 | struct list_head conn_accept_node; |
| 98 | struct completion conn_login_comp; |
Sagi Grimberg | 022ff2f | 2015-01-30 22:17:27 +0000 | [diff] [blame] | 99 | struct completion login_req_comp; |
Nicholas Bellinger | b8d26b3 | 2013-03-07 00:56:19 -0800 | [diff] [blame] | 100 | struct iser_tx_desc conn_login_tx_desc; |
| 101 | struct rdma_cm_id *conn_cm_id; |
| 102 | struct ib_pd *conn_pd; |
| 103 | struct ib_mr *conn_mr; |
| 104 | struct ib_qp *conn_qp; |
| 105 | struct isert_device *conn_device; |
Nicholas Bellinger | d9e507c | 2013-07-03 03:05:37 -0700 | [diff] [blame] | 106 | struct mutex conn_mutex; |
Nicholas Bellinger | d8bd97a0 | 2014-02-03 12:54:39 -0800 | [diff] [blame] | 107 | struct completion conn_wait; |
| 108 | struct completion conn_wait_comp_err; |
Nicholas Bellinger | b8d26b3 | 2013-03-07 00:56:19 -0800 | [diff] [blame] | 109 | struct kref conn_kref; |
Sagi Grimberg | a3ecefb | 2015-01-30 22:17:30 +0000 | [diff] [blame] | 110 | struct work_struct release_work; |
Nicholas Bellinger | b8d26b3 | 2013-03-07 00:56:19 -0800 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | #define ISERT_MAX_CQ 64 |
| 114 | |
| 115 | struct isert_cq_desc { |
| 116 | struct isert_device *device; |
| 117 | int cq_index; |
| 118 | struct work_struct cq_rx_work; |
| 119 | struct work_struct cq_tx_work; |
| 120 | }; |
| 121 | |
| 122 | struct isert_device { |
| 123 | int cqs_used; |
| 124 | int refcount; |
| 125 | int cq_active_qps[ISERT_MAX_CQ]; |
| 126 | struct ib_device *ib_device; |
| 127 | struct ib_pd *dev_pd; |
| 128 | struct ib_mr *dev_mr; |
| 129 | struct ib_cq *dev_rx_cq[ISERT_MAX_CQ]; |
| 130 | struct ib_cq *dev_tx_cq[ISERT_MAX_CQ]; |
| 131 | struct isert_cq_desc *cq_desc; |
| 132 | struct list_head dev_node; |
| 133 | }; |
| 134 | |
| 135 | struct isert_np { |
Sagi Grimberg | b80e6c5 | 2015-01-30 22:17:29 +0000 | [diff] [blame] | 136 | struct iscsi_np *np; |
Sagi Grimberg | 8a2629a | 2014-04-29 13:13:45 +0300 | [diff] [blame] | 137 | struct semaphore np_sem; |
Nicholas Bellinger | b8d26b3 | 2013-03-07 00:56:19 -0800 | [diff] [blame] | 138 | struct rdma_cm_id *np_cm_id; |
| 139 | struct mutex np_accept_mutex; |
| 140 | struct list_head np_accept_list; |
| 141 | struct completion np_login_comp; |
| 142 | }; |