.. | .. |
---|
44 | 44 | #include <rdma/ib_verbs.h> |
---|
45 | 45 | #include <rdma/ib_sa.h> |
---|
46 | 46 | #include <rdma/ib_cm.h> |
---|
47 | | -#include <rdma/ib_fmr_pool.h> |
---|
48 | 47 | #include <rdma/rdma_cm.h> |
---|
49 | 48 | |
---|
50 | 49 | enum { |
---|
.. | .. |
---|
63 | 62 | SRP_DEFAULT_CMD_SQ_SIZE = SRP_DEFAULT_QUEUE_SIZE - SRP_RSP_SQ_SIZE - |
---|
64 | 63 | SRP_TSK_MGMT_SQ_SIZE, |
---|
65 | 64 | |
---|
66 | | - SRP_TAG_NO_REQ = ~0U, |
---|
67 | | - SRP_TAG_TSK_MGMT = 1U << 31, |
---|
68 | | - |
---|
69 | 65 | SRP_MAX_PAGES_PER_MR = 512, |
---|
| 66 | + |
---|
| 67 | + SRP_MAX_ADD_CDB_LEN = 16, |
---|
| 68 | + |
---|
| 69 | + SRP_MAX_IMM_SGE = 2, |
---|
| 70 | + SRP_MAX_SGE = SRP_MAX_IMM_SGE + 1, |
---|
| 71 | + /* |
---|
| 72 | + * Choose the immediate data offset such that a 32 byte CDB still fits. |
---|
| 73 | + */ |
---|
| 74 | + SRP_IMM_DATA_OFFSET = sizeof(struct srp_cmd) + |
---|
| 75 | + SRP_MAX_ADD_CDB_LEN + |
---|
| 76 | + sizeof(struct srp_imm_buf), |
---|
| 77 | +}; |
---|
| 78 | + |
---|
| 79 | +enum { |
---|
| 80 | + SRP_TAG_NO_REQ = ~0U, |
---|
| 81 | + SRP_TAG_TSK_MGMT = BIT(31), |
---|
70 | 82 | }; |
---|
71 | 83 | |
---|
72 | 84 | enum srp_target_state { |
---|
.. | .. |
---|
84 | 96 | /* |
---|
85 | 97 | * @mr_page_mask: HCA memory registration page mask. |
---|
86 | 98 | * @mr_page_size: HCA memory registration page size. |
---|
87 | | - * @mr_max_size: Maximum size in bytes of a single FMR / FR registration |
---|
88 | | - * request. |
---|
| 99 | + * @mr_max_size: Maximum size in bytes of a single FR registration request. |
---|
89 | 100 | */ |
---|
90 | 101 | struct srp_device { |
---|
91 | 102 | struct list_head dev_list; |
---|
.. | .. |
---|
96 | 107 | int mr_page_size; |
---|
97 | 108 | int mr_max_size; |
---|
98 | 109 | int max_pages_per_mr; |
---|
99 | | - bool has_fmr; |
---|
100 | 110 | bool has_fr; |
---|
101 | | - bool use_fmr; |
---|
102 | 111 | bool use_fast_reg; |
---|
103 | 112 | }; |
---|
104 | 113 | |
---|
.. | .. |
---|
116 | 125 | struct srp_request { |
---|
117 | 126 | struct scsi_cmnd *scmnd; |
---|
118 | 127 | struct srp_iu *cmd; |
---|
119 | | - union { |
---|
120 | | - struct ib_pool_fmr **fmr_list; |
---|
121 | | - struct srp_fr_desc **fr_list; |
---|
122 | | - }; |
---|
123 | | - u64 *map_page; |
---|
| 128 | + struct srp_fr_desc **fr_list; |
---|
124 | 129 | struct srp_direct_buf *indirect_desc; |
---|
125 | 130 | dma_addr_t indirect_dma_addr; |
---|
126 | 131 | short nmdesc; |
---|
.. | .. |
---|
130 | 135 | /** |
---|
131 | 136 | * struct srp_rdma_ch |
---|
132 | 137 | * @comp_vector: Completion vector used by this RDMA channel. |
---|
| 138 | + * @max_it_iu_len: Maximum initiator-to-target information unit length. |
---|
| 139 | + * @max_ti_iu_len: Maximum target-to-initiator information unit length. |
---|
133 | 140 | */ |
---|
134 | 141 | struct srp_rdma_ch { |
---|
135 | 142 | /* These are RW in the hot path, and commonly used together */ |
---|
.. | .. |
---|
142 | 149 | struct ib_cq *send_cq; |
---|
143 | 150 | struct ib_cq *recv_cq; |
---|
144 | 151 | struct ib_qp *qp; |
---|
145 | | - union { |
---|
146 | | - struct ib_fmr_pool *fmr_pool; |
---|
147 | | - struct srp_fr_pool *fr_pool; |
---|
148 | | - }; |
---|
| 152 | + struct srp_fr_pool *fr_pool; |
---|
| 153 | + uint32_t max_it_iu_len; |
---|
| 154 | + uint32_t max_ti_iu_len; |
---|
| 155 | + u8 max_imm_sge; |
---|
| 156 | + bool use_imm_data; |
---|
149 | 157 | |
---|
150 | 158 | /* Everything above this point is used in the hot path of |
---|
151 | 159 | * command processing. Try to keep them packed into cachelines. |
---|
.. | .. |
---|
169 | 177 | struct srp_iu **tx_ring; |
---|
170 | 178 | struct srp_iu **rx_ring; |
---|
171 | 179 | struct srp_request *req_ring; |
---|
172 | | - int max_ti_iu_len; |
---|
173 | 180 | int comp_vector; |
---|
174 | 181 | |
---|
175 | 182 | u64 tsk_mgmt_tag; |
---|
.. | .. |
---|
194 | 201 | u32 ch_count; |
---|
195 | 202 | u32 lkey; |
---|
196 | 203 | enum srp_target_state state; |
---|
197 | | - unsigned int max_iu_len; |
---|
| 204 | + uint32_t max_it_iu_size; |
---|
198 | 205 | unsigned int cmd_sg_cnt; |
---|
199 | 206 | unsigned int indirect_size; |
---|
200 | 207 | bool allow_ext_sg; |
---|
.. | .. |
---|
231 | 238 | union { |
---|
232 | 239 | struct sockaddr_in ip4; |
---|
233 | 240 | struct sockaddr_in6 ip6; |
---|
| 241 | + struct sockaddr sa; |
---|
234 | 242 | struct sockaddr_storage ss; |
---|
235 | 243 | } src; |
---|
236 | 244 | union { |
---|
237 | 245 | struct sockaddr_in ip4; |
---|
238 | 246 | struct sockaddr_in6 ip6; |
---|
| 247 | + struct sockaddr sa; |
---|
239 | 248 | struct sockaddr_storage ss; |
---|
240 | 249 | } dst; |
---|
241 | 250 | bool src_specified; |
---|
.. | .. |
---|
259 | 268 | void *buf; |
---|
260 | 269 | size_t size; |
---|
261 | 270 | enum dma_data_direction direction; |
---|
| 271 | + u32 num_sge; |
---|
| 272 | + struct ib_sge sge[SRP_MAX_SGE]; |
---|
262 | 273 | struct ib_cqe cqe; |
---|
263 | 274 | }; |
---|
264 | 275 | |
---|
.. | .. |
---|
289 | 300 | int max_page_list_len; |
---|
290 | 301 | spinlock_t lock; |
---|
291 | 302 | struct list_head free_list; |
---|
292 | | - struct srp_fr_desc desc[0]; |
---|
| 303 | + struct srp_fr_desc desc[]; |
---|
293 | 304 | }; |
---|
294 | 305 | |
---|
295 | 306 | /** |
---|
.. | .. |
---|
299 | 310 | * @pages: Array with DMA addresses of pages being considered for |
---|
300 | 311 | * memory registration. |
---|
301 | 312 | * @base_dma_addr: DMA address of the first page that has not yet been mapped. |
---|
302 | | - * @dma_len: Number of bytes that will be registered with the next |
---|
303 | | - * FMR or FR memory registration call. |
---|
| 313 | + * @dma_len: Number of bytes that will be registered with the next FR |
---|
| 314 | + * memory registration call. |
---|
304 | 315 | * @total_len: Total number of bytes in the sg-list being mapped. |
---|
305 | 316 | * @npages: Number of page addresses in the pages[] array. |
---|
306 | | - * @nmdesc: Number of FMR or FR memory descriptors used for mapping. |
---|
| 317 | + * @nmdesc: Number of FR memory descriptors used for mapping. |
---|
307 | 318 | * @ndesc: Number of SRP buffer descriptors that have been filled in. |
---|
308 | 319 | */ |
---|
309 | 320 | struct srp_map_state { |
---|
310 | 321 | union { |
---|
311 | | - struct { |
---|
312 | | - struct ib_pool_fmr **next; |
---|
313 | | - struct ib_pool_fmr **end; |
---|
314 | | - } fmr; |
---|
315 | 322 | struct { |
---|
316 | 323 | struct srp_fr_desc **next; |
---|
317 | 324 | struct srp_fr_desc **end; |
---|