+ conn = list_entry (ctmp, kib_conn_t, ibc_list);
+ kibnal_conn_addref(conn);
+ read_unlock_irqrestore(&kibnal_data.kib_global_lock,
+ flags);
+ return (conn);
+ }
+ }
+ }
+
+ read_unlock_irqrestore(&kibnal_data.kib_global_lock, flags);
+ return (NULL);
+}
+
+int
+kibnal_conn_rts(kib_conn_t *conn,
+ __u32 qpn, __u8 resp_res, __u8 init_depth, __u32 psn)
+{
+ IB_PATH_RECORD *path = &conn->ibc_cvars->cv_path;
+ IB_HANDLE qp = conn->ibc_qp;
+ IB_QP_ATTRIBUTES_MODIFY modify_attr;
+ FSTATUS frc;
+ int rc;
+
+ if (resp_res > kibnal_data.kib_hca_attrs.MaxQPResponderResources)
+ resp_res = kibnal_data.kib_hca_attrs.MaxQPResponderResources;
+
+ if (init_depth > kibnal_data.kib_hca_attrs.MaxQPInitiatorDepth)
+ init_depth = kibnal_data.kib_hca_attrs.MaxQPInitiatorDepth;
+
+ modify_attr = (IB_QP_ATTRIBUTES_MODIFY) {
+ .RequestState = QPStateReadyToRecv,
+ .RecvPSN = IBNAL_STARTING_PSN,
+ .DestQPNumber = qpn,
+ .ResponderResources = resp_res,
+ .MinRnrTimer = UsecToRnrNakTimer(2000), /* 20 ms */
+ .Attrs = (IB_QP_ATTR_RECVPSN |
+ IB_QP_ATTR_DESTQPNUMBER |
+ IB_QP_ATTR_RESPONDERRESOURCES |
+ IB_QP_ATTR_DESTAV |
+ IB_QP_ATTR_PATHMTU |
+ IB_QP_ATTR_MINRNRTIMER),
+ };
+ GetAVFromPath(0, path, &modify_attr.PathMTU, NULL,
+ &modify_attr.DestAV);
+
+ frc = iba_modify_qp(qp, &modify_attr, NULL);
+ if (frc != FSUCCESS) {
+ CERROR("Can't set QP %s ready to receive: %d\n",
+ libcfs_nid2str(conn->ibc_peer->ibp_nid), frc);
+ return -EIO;
+ }
+
+ rc = kibnal_post_receives(conn);
+ if (rc != 0) {
+ CERROR("Can't post receives for %s: %d\n",
+ libcfs_nid2str(conn->ibc_peer->ibp_nid), rc);
+ return rc;
+ }
+
+ modify_attr = (IB_QP_ATTRIBUTES_MODIFY) {
+ .RequestState = QPStateReadyToSend,
+ .FlowControl = TRUE,
+ .InitiatorDepth = init_depth,
+ .SendPSN = psn,
+ .LocalAckTimeout = path->PktLifeTime + 2, /* 2 or 1? */
+ .RetryCount = IBNAL_RETRY,
+ .RnrRetryCount = IBNAL_RNR_RETRY,
+ .Attrs = (IB_QP_ATTR_FLOWCONTROL |
+ IB_QP_ATTR_INITIATORDEPTH |
+ IB_QP_ATTR_SENDPSN |
+ IB_QP_ATTR_LOCALACKTIMEOUT |
+ IB_QP_ATTR_RETRYCOUNT |
+ IB_QP_ATTR_RNRRETRYCOUNT),
+ };
+
+ frc = iba_modify_qp(qp, &modify_attr, NULL);
+ if (frc != FSUCCESS) {
+ CERROR("Can't set QP %s ready to send: %d\n",
+ libcfs_nid2str(conn->ibc_peer->ibp_nid), frc);
+ return -EIO;