blob: d5a4b88db18fe8f473f0e83a6d8cd2e352cdf455 [file] [log] [blame]
ib_srpt and session management
==============================
The following actions related to SRP sessions can all occur concurrently:
* The communication manager invokes either srpt_ib_cm_handler() or
srpt_rdma_cm_handler().
* HCA driver invokes the queue pair (QP) completion handler srpt_completion().
* HCA driver invokes the QP async event handler srpt_qp_event().
* HCA transfers data between initiator and target via RDMA.
* srpt_do_compl_work() polls the QP.
* SCST core invokes one of the callback functions defined in srpt_template.
The actions that occur over the lifetime of a session are as follows:
- A REQ message is received from the initiator.
- srpt_cm_req_recv() is invoked, allocates an I/O context ring and a queue pair
and creates an SCST session.
- If the connection request is not accepted, a REJ message is sent and
srpt_close_ch() is invoked. The srpt_close_ch() call causes the allocated
resources to be freed asynchronously.
- If the connection request is accepted a REP message is sent to the initiator.
- Once an RTU message is received from the initiator, srpt_cm_rtu_recv() is
invoked. That function changes the queue pair state into RTS, the channel
state into CH_LIVE and triggers processing of the wait list.
- RDMA communication starts and continues until either a DREQ message is
received or sent. A DREQ is sent either because a target port is disabled or
because the SCST core requested to close the session.
- After a DREQ has been sent either a DREP will be received or the TimeWait
state will be reached. Both trigger a srpt_close_ch() call.
- srpt_close_ch() changes the channel state into CH_DRAINING, the
queue pair state into IB_QPS_ERR and queues a zero-length write.
- Upon receipt of the zero-length write completion the channel state is
changed into CH_DISCONNECTED. This is the last work completion so once the
channel state has reached CH_DISCONNECTED it is guaranteed that the queue
pair completion handler won't be invoked again.
- scst_unregister_session() is called.
- Once scst_unregister_session() has finished srpt_unreg_sess() is invoked.
- srpt_unreg_sess() destroys the CM ID and decrements the channel refcount.
- Once the channel refcount drops to zero srpt_free_ch() is invoked which
frees the queue pair and other IB resources.