conn→ibc_credits is set to the negotiated queue depthkiblnd_passive_connect()kiblnd_check_connreply()kiblnd_post_tx_locked() is passed a credit value.IBLND_MSG_PUT_NAK, IBLND_MSG_PUT_ACK, IBLND_MSG_PUT_DONE, IBLND_MSG_GET_DONE, IBLND_MSG_NOOP (for v2 protocol) require no creditsmsg→ibm_credits is set to conn→ibc_outstanding_credits ( conn→ibc_outstanding_credits is described below)kiblnd_handle_rx(), depending on the message we'll either increment conn→ibc_outstanding_credits or conn→ibc_reserved_credits by 1 after we call ib_post_recv() to receive buffers.ibc_reserved_credits is used to transfer messaged for the ibc_tx_queue_rsrved queue to to the ibc_tx_queue for sending.ibc_outstanding_credits is assigned to msg→ibm_credits and sent to the peeribc_outstanding_credits. This is passed in the next transmit to the peer. That takes us back to (2)The underlying assumption in the connection management algorithm is that both sides are exchanging messages. If there is a change in the call flow where one side simply sends events with the other side not responding using IMMEDIATE messages, the initiating side will run out of credits and will be stuck since none of the credits are being returned.
It might be better to return the credit on an IMMEDIATE message once the tx is completed. When receiving immediate message do not increment ibc_outstanding_credits.
Queue depth is negotiated as follows:
Patch https://review.whamcloud.com/#/c/28850/5 leverages this algorithm by decreasing the active's queue depth when attempting to create the qp, then sending the adjusted queue depth to the passive. The passive creates its connection structure and reduces the queue depth if necessary, then sends it back to the active, which uses that as the connection queue depth and credits.
Concurrent sends were intended to limit the maximum number of in-flight transfers for the entire system. However, we were multiplying the max_send_wr with concurrent sends which implied that it's per connection, which is not true.
It is better to remove concurrent sends tunable completely as that will simplify the code and instead rely on the queue depth to limit the in-flight transfers per connection.
The jury is still up on this change. It needs to be tested in the filed to see if it'll have a negative impact on performance.