.. | .. |
---|
104 | 104 | SRP_CMD_ORDERED_Q = 0x2, |
---|
105 | 105 | SRP_CMD_ACA = 0x4, |
---|
106 | 106 | |
---|
107 | | - SRP_LOGIN_RSP_MULTICHAN_NO_CHAN = 0x0, |
---|
108 | | - SRP_LOGIN_RSP_MULTICHAN_TERMINATED = 0x1, |
---|
109 | | - SRP_LOGIN_RSP_MULTICHAN_MAINTAINED = 0x2, |
---|
110 | | - |
---|
111 | 107 | SRPT_DEF_SG_TABLESIZE = 128, |
---|
112 | | - /* |
---|
113 | | - * An experimentally determined value that avoids that QP creation |
---|
114 | | - * fails due to "swiotlb buffer is full" on systems using the swiotlb. |
---|
115 | | - */ |
---|
116 | | - SRPT_MAX_SG_PER_WQE = 16, |
---|
117 | 108 | |
---|
118 | 109 | MIN_SRPT_SQ_SIZE = 16, |
---|
119 | 110 | DEF_SRPT_SQ_SIZE = 4096, |
---|
.. | .. |
---|
124 | 115 | MAX_SRPT_RDMA_SIZE = 1U << 24, |
---|
125 | 116 | MAX_SRPT_RSP_SIZE = 1024, |
---|
126 | 117 | |
---|
| 118 | + SRP_MAX_ADD_CDB_LEN = 16, |
---|
| 119 | + SRP_MAX_IMM_DATA_OFFSET = 80, |
---|
| 120 | + SRP_MAX_IMM_DATA = 8 * 1024, |
---|
127 | 121 | MIN_MAX_REQ_SIZE = 996, |
---|
128 | | - DEFAULT_MAX_REQ_SIZE |
---|
129 | | - = sizeof(struct srp_cmd)/*48*/ |
---|
130 | | - + sizeof(struct srp_indirect_buf)/*20*/ |
---|
131 | | - + 128 * sizeof(struct srp_direct_buf)/*16*/, |
---|
| 122 | + DEFAULT_MAX_REQ_SIZE_1 = sizeof(struct srp_cmd)/*48*/ + |
---|
| 123 | + SRP_MAX_ADD_CDB_LEN + |
---|
| 124 | + sizeof(struct srp_indirect_buf)/*20*/ + |
---|
| 125 | + 128 * sizeof(struct srp_direct_buf)/*16*/, |
---|
| 126 | + DEFAULT_MAX_REQ_SIZE_2 = SRP_MAX_IMM_DATA_OFFSET + |
---|
| 127 | + sizeof(struct srp_imm_buf) + SRP_MAX_IMM_DATA, |
---|
| 128 | + DEFAULT_MAX_REQ_SIZE = DEFAULT_MAX_REQ_SIZE_1 > DEFAULT_MAX_REQ_SIZE_2 ? |
---|
| 129 | + DEFAULT_MAX_REQ_SIZE_1 : DEFAULT_MAX_REQ_SIZE_2, |
---|
132 | 130 | |
---|
133 | 131 | MIN_MAX_RSP_SIZE = sizeof(struct srp_rsp)/*36*/ + 4, |
---|
134 | 132 | DEFAULT_MAX_RSP_SIZE = 256, /* leaves 220 bytes for sense data */ |
---|
.. | .. |
---|
165 | 163 | * @cqe: Completion queue element. |
---|
166 | 164 | * @buf: Pointer to the buffer. |
---|
167 | 165 | * @dma: DMA address of the buffer. |
---|
| 166 | + * @offset: Offset of the first byte in @buf and @dma that is actually used. |
---|
168 | 167 | * @index: Index of the I/O context in its ioctx_ring array. |
---|
169 | 168 | */ |
---|
170 | 169 | struct srpt_ioctx { |
---|
171 | 170 | struct ib_cqe cqe; |
---|
172 | 171 | void *buf; |
---|
173 | 172 | dma_addr_t dma; |
---|
| 173 | + uint32_t offset; |
---|
174 | 174 | uint32_t index; |
---|
175 | 175 | }; |
---|
176 | 176 | |
---|
.. | .. |
---|
178 | 178 | * struct srpt_recv_ioctx - SRPT receive I/O context |
---|
179 | 179 | * @ioctx: See above. |
---|
180 | 180 | * @wait_list: Node for insertion in srpt_rdma_ch.cmd_wait_list. |
---|
| 181 | + * @byte_len: Number of bytes in @ioctx.buf. |
---|
181 | 182 | */ |
---|
182 | 183 | struct srpt_recv_ioctx { |
---|
183 | 184 | struct srpt_ioctx ioctx; |
---|
184 | 185 | struct list_head wait_list; |
---|
| 186 | + int byte_len; |
---|
185 | 187 | }; |
---|
186 | | - |
---|
| 188 | + |
---|
187 | 189 | struct srpt_rw_ctx { |
---|
188 | 190 | struct rdma_rw_ctx rw; |
---|
189 | 191 | struct scatterlist *sg; |
---|
.. | .. |
---|
194 | 196 | * struct srpt_send_ioctx - SRPT send I/O context |
---|
195 | 197 | * @ioctx: See above. |
---|
196 | 198 | * @ch: Channel pointer. |
---|
| 199 | + * @recv_ioctx: Receive I/O context associated with this send I/O context. |
---|
| 200 | + * Only used for processing immediate data. |
---|
197 | 201 | * @s_rw_ctx: @rw_ctxs points here if only a single rw_ctx is needed. |
---|
198 | 202 | * @rw_ctxs: RDMA read/write contexts. |
---|
| 203 | + * @imm_sg: Scatterlist for immediate data. |
---|
199 | 204 | * @rdma_cqe: RDMA completion queue element. |
---|
200 | | - * @free_list: Node in srpt_rdma_ch.free_list. |
---|
201 | 205 | * @state: I/O context state. |
---|
202 | 206 | * @cmd: Target core command data structure. |
---|
203 | 207 | * @sense_data: SCSI sense data. |
---|
.. | .. |
---|
209 | 213 | struct srpt_send_ioctx { |
---|
210 | 214 | struct srpt_ioctx ioctx; |
---|
211 | 215 | struct srpt_rdma_ch *ch; |
---|
| 216 | + struct srpt_recv_ioctx *recv_ioctx; |
---|
212 | 217 | |
---|
213 | 218 | struct srpt_rw_ctx s_rw_ctx; |
---|
214 | 219 | struct srpt_rw_ctx *rw_ctxs; |
---|
215 | 220 | |
---|
| 221 | + struct scatterlist imm_sg; |
---|
| 222 | + |
---|
216 | 223 | struct ib_cqe rdma_cqe; |
---|
217 | | - struct list_head free_list; |
---|
218 | 224 | enum srpt_command_state state; |
---|
219 | 225 | struct se_cmd cmd; |
---|
220 | 226 | u8 n_rdma; |
---|
.. | .. |
---|
245 | 251 | * struct srpt_rdma_ch - RDMA channel |
---|
246 | 252 | * @nexus: I_T nexus this channel is associated with. |
---|
247 | 253 | * @qp: IB queue pair used for communicating over this channel. |
---|
248 | | - * @cm_id: IB CM ID associated with the channel. |
---|
| 254 | + * @ib_cm: See below. |
---|
| 255 | + * @ib_cm.cm_id: IB CM ID associated with the channel. |
---|
| 256 | + * @rdma_cm: See below. |
---|
| 257 | + * @rdma_cm.cm_id: RDMA CM ID associated with the channel. |
---|
249 | 258 | * @cq: IB completion queue for this channel. |
---|
| 259 | + * @cq_size: Number of CQEs in @cq. |
---|
250 | 260 | * @zw_cqe: Zero-length write CQE. |
---|
251 | 261 | * @rcu: RCU head. |
---|
252 | 262 | * @kref: kref for this channel. |
---|
| 263 | + * @closed: Completion object that will be signaled as soon as a new |
---|
| 264 | + * channel object with the same identity can be created. |
---|
253 | 265 | * @rq_size: IB receive queue size. |
---|
254 | 266 | * @max_rsp_size: Maximum size of an RSP response message in bytes. |
---|
255 | 267 | * @sq_wr_avail: number of work requests available in the send queue. |
---|
.. | .. |
---|
259 | 271 | * @req_lim: request limit: maximum number of requests that may be sent |
---|
260 | 272 | * by the initiator without having received a response. |
---|
261 | 273 | * @req_lim_delta: Number of credits not yet sent back to the initiator. |
---|
| 274 | + * @imm_data_offset: Offset from start of SRP_CMD for immediate data. |
---|
262 | 275 | * @spinlock: Protects free_list and state. |
---|
263 | | - * @free_list: Head of list with free send I/O contexts. |
---|
264 | 276 | * @state: channel state. See also enum rdma_ch_state. |
---|
265 | 277 | * @using_rdma_cm: Whether the RDMA/CM or IB/CM is used for this channel. |
---|
266 | 278 | * @processing_wait_list: Whether or not cmd_wait_list is being processed. |
---|
| 279 | + * @rsp_buf_cache: kmem_cache for @ioctx_ring. |
---|
267 | 280 | * @ioctx_ring: Send ring. |
---|
| 281 | + * @req_buf_cache: kmem_cache for @ioctx_recv_ring. |
---|
268 | 282 | * @ioctx_recv_ring: Receive I/O context ring. |
---|
269 | 283 | * @list: Node in srpt_nexus.ch_list. |
---|
270 | 284 | * @cmd_wait_list: List of SCSI commands that arrived before the RTU event. This |
---|
.. | .. |
---|
287 | 301 | } rdma_cm; |
---|
288 | 302 | }; |
---|
289 | 303 | struct ib_cq *cq; |
---|
| 304 | + u32 cq_size; |
---|
290 | 305 | struct ib_cqe zw_cqe; |
---|
291 | 306 | struct rcu_head rcu; |
---|
292 | 307 | struct kref kref; |
---|
| 308 | + struct completion *closed; |
---|
293 | 309 | int rq_size; |
---|
294 | 310 | u32 max_rsp_size; |
---|
295 | 311 | atomic_t sq_wr_avail; |
---|
.. | .. |
---|
297 | 313 | int max_ti_iu_len; |
---|
298 | 314 | atomic_t req_lim; |
---|
299 | 315 | atomic_t req_lim_delta; |
---|
| 316 | + u16 imm_data_offset; |
---|
300 | 317 | spinlock_t spinlock; |
---|
301 | | - struct list_head free_list; |
---|
302 | 318 | enum rdma_ch_state state; |
---|
| 319 | + struct kmem_cache *rsp_buf_cache; |
---|
303 | 320 | struct srpt_send_ioctx **ioctx_ring; |
---|
| 321 | + struct kmem_cache *req_buf_cache; |
---|
304 | 322 | struct srpt_recv_ioctx **ioctx_recv_ring; |
---|
305 | 323 | struct list_head list; |
---|
306 | 324 | struct list_head cmd_wait_list; |
---|
.. | .. |
---|
343 | 361 | }; |
---|
344 | 362 | |
---|
345 | 363 | /** |
---|
346 | | - * struct srpt_port - information associated by SRPT with a single IB port |
---|
| 364 | + * struct srpt_tpg - information about a single "target portal group" |
---|
| 365 | + * @entry: Entry in @sport_id->tpg_list. |
---|
| 366 | + * @sport_id: Port name this TPG is associated with. |
---|
| 367 | + * @tpg: LIO TPG data structure. |
---|
| 368 | + * |
---|
| 369 | + * Zero or more target portal groups are associated with each port name |
---|
| 370 | + * (srpt_port_id). With each TPG an ACL list is associated. |
---|
| 371 | + */ |
---|
| 372 | +struct srpt_tpg { |
---|
| 373 | + struct list_head entry; |
---|
| 374 | + struct srpt_port_id *sport_id; |
---|
| 375 | + struct se_portal_group tpg; |
---|
| 376 | +}; |
---|
| 377 | + |
---|
| 378 | +/** |
---|
| 379 | + * struct srpt_port_id - LIO RDMA port information |
---|
| 380 | + * @mutex: Protects @tpg_list changes. |
---|
| 381 | + * @tpg_list: TPGs associated with the RDMA port name. |
---|
| 382 | + * @wwn: WWN associated with the RDMA port name. |
---|
| 383 | + * @name: ASCII representation of the port name. |
---|
| 384 | + * |
---|
| 385 | + * Multiple sysfs directories can be associated with a single RDMA port. This |
---|
| 386 | + * data structure represents a single (port, name) pair. |
---|
| 387 | + */ |
---|
| 388 | +struct srpt_port_id { |
---|
| 389 | + struct mutex mutex; |
---|
| 390 | + struct list_head tpg_list; |
---|
| 391 | + struct se_wwn wwn; |
---|
| 392 | + char name[64]; |
---|
| 393 | +}; |
---|
| 394 | + |
---|
| 395 | +/** |
---|
| 396 | + * struct srpt_port - SRPT RDMA port information |
---|
347 | 397 | * @sdev: backpointer to the HCA information. |
---|
348 | 398 | * @mad_agent: per-port management datagram processing information. |
---|
349 | 399 | * @enabled: Whether or not this target port is enabled. |
---|
350 | | - * @port_guid: ASCII representation of Port GUID |
---|
351 | | - * @port_gid: ASCII representation of Port GID |
---|
352 | 400 | * @port: one-based port number. |
---|
353 | 401 | * @sm_lid: cached value of the port's sm_lid. |
---|
354 | 402 | * @lid: cached value of the port's lid. |
---|
355 | 403 | * @gid: cached value of the port's gid. |
---|
356 | | - * @port_acl_lock spinlock for port_acl_list: |
---|
357 | 404 | * @work: work structure for refreshing the aforementioned cached values. |
---|
358 | | - * @port_guid_tpg: TPG associated with target port GUID. |
---|
359 | | - * @port_guid_wwn: WWN associated with target port GUID. |
---|
360 | | - * @port_gid_tpg: TPG associated with target port GID. |
---|
361 | | - * @port_gid_wwn: WWN associated with target port GID. |
---|
| 405 | + * @guid_name: port name in GUID format. |
---|
| 406 | + * @guid_id: LIO target port information for the port name in GUID format. |
---|
| 407 | + * @gid_name: port name in GID format. |
---|
| 408 | + * @gid_id: LIO target port information for the port name in GID format. |
---|
362 | 409 | * @port_attrib: Port attributes that can be accessed through configfs. |
---|
363 | | - * @ch_releaseQ: Enables waiting for removal from nexus_list. |
---|
| 410 | + * @refcount: Number of objects associated with this port. |
---|
| 411 | + * @freed_channels: Completion that will be signaled once @refcount becomes 0. |
---|
364 | 412 | * @mutex: Protects nexus_list. |
---|
365 | 413 | * @nexus_list: Nexus list. See also srpt_nexus.entry. |
---|
366 | 414 | */ |
---|
.. | .. |
---|
368 | 416 | struct srpt_device *sdev; |
---|
369 | 417 | struct ib_mad_agent *mad_agent; |
---|
370 | 418 | bool enabled; |
---|
371 | | - u8 port_guid[24]; |
---|
372 | | - u8 port_gid[64]; |
---|
373 | 419 | u8 port; |
---|
374 | 420 | u32 sm_lid; |
---|
375 | 421 | u32 lid; |
---|
376 | 422 | union ib_gid gid; |
---|
377 | 423 | struct work_struct work; |
---|
378 | | - struct se_portal_group port_guid_tpg; |
---|
379 | | - struct se_wwn port_guid_wwn; |
---|
380 | | - struct se_portal_group port_gid_tpg; |
---|
381 | | - struct se_wwn port_gid_wwn; |
---|
| 424 | + char guid_name[64]; |
---|
| 425 | + struct srpt_port_id *guid_id; |
---|
| 426 | + char gid_name[64]; |
---|
| 427 | + struct srpt_port_id *gid_id; |
---|
382 | 428 | struct srpt_port_attrib port_attrib; |
---|
383 | | - wait_queue_head_t ch_releaseQ; |
---|
| 429 | + atomic_t refcount; |
---|
| 430 | + struct completion *freed_channels; |
---|
384 | 431 | struct mutex mutex; |
---|
385 | 432 | struct list_head nexus_list; |
---|
386 | 433 | }; |
---|
387 | 434 | |
---|
388 | 435 | /** |
---|
389 | 436 | * struct srpt_device - information associated by SRPT with a single HCA |
---|
| 437 | + * @refcnt: Reference count for this device. |
---|
390 | 438 | * @device: Backpointer to the struct ib_device managed by the IB core. |
---|
391 | 439 | * @pd: IB protection domain. |
---|
392 | 440 | * @lkey: L_Key (local key) with write access to all local memory. |
---|
.. | .. |
---|
395 | 443 | * @srq_size: SRQ size. |
---|
396 | 444 | * @sdev_mutex: Serializes use_srq changes. |
---|
397 | 445 | * @use_srq: Whether or not to use SRQ. |
---|
| 446 | + * @req_buf_cache: kmem_cache for @ioctx_ring buffers. |
---|
398 | 447 | * @ioctx_ring: Per-HCA SRQ. |
---|
399 | 448 | * @event_handler: Per-HCA asynchronous IB event handler. |
---|
400 | 449 | * @list: Node in srpt_dev_list. |
---|
401 | 450 | * @port: Information about the ports owned by this HCA. |
---|
402 | 451 | */ |
---|
403 | 452 | struct srpt_device { |
---|
| 453 | + struct kref refcnt; |
---|
404 | 454 | struct ib_device *device; |
---|
405 | 455 | struct ib_pd *pd; |
---|
406 | 456 | u32 lkey; |
---|
.. | .. |
---|
409 | 459 | int srq_size; |
---|
410 | 460 | struct mutex sdev_mutex; |
---|
411 | 461 | bool use_srq; |
---|
| 462 | + struct kmem_cache *req_buf_cache; |
---|
412 | 463 | struct srpt_recv_ioctx **ioctx_ring; |
---|
413 | 464 | struct ib_event_handler event_handler; |
---|
414 | 465 | struct list_head list; |
---|