]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - drivers/infiniband/ulp/isert/ib_isert.h
Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git...
[mirror_ubuntu-eoan-kernel.git] / drivers / infiniband / ulp / isert / ib_isert.h
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 #define ISCSI_ISER_SG_TABLESIZE 256
9 #define ISER_FASTREG_LI_WRID 0xffffffffffffffffULL
10
11 enum isert_desc_type {
12 ISCSI_TX_CONTROL,
13 ISCSI_TX_DATAIN
14 };
15
16 enum iser_ib_op_code {
17 ISER_IB_RECV,
18 ISER_IB_SEND,
19 ISER_IB_RDMA_WRITE,
20 ISER_IB_RDMA_READ,
21 };
22
23 enum iser_conn_state {
24 ISER_CONN_INIT,
25 ISER_CONN_UP,
26 ISER_CONN_TERMINATING,
27 ISER_CONN_DOWN,
28 };
29
30 struct iser_rx_desc {
31 struct iser_hdr iser_header;
32 struct iscsi_hdr iscsi_header;
33 char data[ISER_RECV_DATA_SEG_LEN];
34 u64 dma_addr;
35 struct ib_sge rx_sg;
36 char pad[ISER_RX_PAD_SIZE];
37 } __packed;
38
39 struct iser_tx_desc {
40 struct iser_hdr iser_header;
41 struct iscsi_hdr iscsi_header;
42 enum isert_desc_type type;
43 u64 dma_addr;
44 struct ib_sge tx_sg[2];
45 int num_sge;
46 struct isert_cmd *isert_cmd;
47 struct llist_node *comp_llnode_batch;
48 struct llist_node comp_llnode;
49 bool llnode_active;
50 struct ib_send_wr send_wr;
51 } __packed;
52
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;
57 bool valid;
58 };
59
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;
66 int num_sge;
67 struct scatterlist *sge;
68 int send_wr_num;
69 struct ib_send_wr *send_wr;
70 struct ib_send_wr s_send_wr;
71 u32 cur_rdma_length;
72 struct fast_reg_descriptor *fr_desc;
73 };
74
75 struct isert_cmd {
76 uint32_t read_stag;
77 uint32_t write_stag;
78 uint64_t read_va;
79 uint64_t write_va;
80 u64 pdu_buf_dma;
81 u32 pdu_buf_len;
82 u32 read_va_off;
83 u32 write_va_off;
84 u32 rdma_wr_num;
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;
90 };
91
92 struct isert_device;
93
94 struct isert_conn {
95 enum iser_conn_state state;
96 bool logout_posted;
97 int post_recv_buf_count;
98 atomic_t post_send_buf_count;
99 u32 responder_resources;
100 u32 initiator_depth;
101 u32 max_sge;
102 char *login_buf;
103 char *login_req_buf;
104 char *login_rsp_buf;
105 u64 login_req_dma;
106 u64 login_rsp_dma;
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
129 int conn_comp_batch;
130 struct llist_head conn_comp_llist;
131 };
132
133 #define ISERT_MAX_CQ 64
134
135 struct isert_cq_desc {
136 struct isert_device *device;
137 int cq_index;
138 struct work_struct cq_rx_work;
139 struct work_struct cq_tx_work;
140 };
141
142 struct isert_device {
143 int use_fastreg;
144 int cqs_used;
145 int refcount;
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);
158 };
159
160 struct isert_np {
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;
166 };