Print this page
XXXX introduce drv_sectohz


2170 }
2171 
2172 /*
2173  * Wait for send completion notification. Only on receiving a
2174  * notification be it a successful or error completion, free the
2175  * send_wid.
2176  */
2177 static rdma_stat
2178 rib_sendwait(rib_qp_t *qp, struct send_wid *wd)
2179 {
2180         clock_t timout, cv_wait_ret;
2181         rdma_stat error = RDMA_SUCCESS;
2182         int     i;
2183 
2184         /*
2185          * Wait for send to complete
2186          */
2187         ASSERT(wd != NULL);
2188         mutex_enter(&wd->sendwait_lock);
2189         if (wd->status == (uint_t)SEND_WAIT) {
2190                 timout = drv_usectohz(SEND_WAIT_TIME * 1000000) +
2191                     ddi_get_lbolt();
2192 
2193                 if (qp->mode == RIB_SERVER) {
2194                         while ((cv_wait_ret = cv_timedwait(&wd->wait_cv,
2195                             &wd->sendwait_lock, timout)) > 0 &&
2196                             wd->status == (uint_t)SEND_WAIT)
2197                                 ;
2198                         switch (cv_wait_ret) {
2199                         case -1:        /* timeout */
2200                                 DTRACE_PROBE(rpcib__i__srvsendwait__timeout);
2201 
2202                                 wd->cv_sig = 0;              /* no signal needed */
2203                                 error = RDMA_TIMEDOUT;
2204                                 break;
2205                         default:        /* got send completion */
2206                                 break;
2207                         }
2208                 } else {
2209                         while ((cv_wait_ret = cv_timedwait_sig(&wd->wait_cv,
2210                             &wd->sendwait_lock, timout)) > 0 &&


2421 {
2422         rdma_stat ret = RDMA_SUCCESS;
2423         struct rdma_done_list *rd;
2424         clock_t cv_wait_ret;
2425         caddr_t *wid = NULL;
2426         rib_qp_t *qp = ctoqp(conn);
2427 
2428         mutex_enter(&qp->rdlist_lock);
2429         rd = rdma_done_add(qp, msgid);
2430 
2431         /* No cv_signal (whether send-wait or no-send-wait) */
2432         ret = rib_send_and_wait(conn, cl, msgid, 1, 0, wid);
2433 
2434         if (ret != RDMA_SUCCESS) {
2435                 rdma_done_rm(qp, rd);
2436         } else {
2437                 /*
2438                  * Wait for RDMA_DONE from remote end
2439                  */
2440                 cv_wait_ret = cv_reltimedwait(&rd->rdma_done_cv,
2441                     &qp->rdlist_lock, drv_usectohz(REPLY_WAIT_TIME * 1000000),
2442                     TR_CLOCK_TICK);
2443 
2444                 rdma_done_rm(qp, rd);
2445 
2446                 if (cv_wait_ret < 0) {
2447                         ret = RDMA_TIMEDOUT;
2448                 }
2449         }
2450 
2451         mutex_exit(&qp->rdlist_lock);
2452         return (ret);
2453 }
2454 
2455 static struct recv_wid *
2456 rib_create_wid(rib_qp_t *qp, ibt_wr_ds_t *sgl, uint32_t msgid)
2457 {
2458         struct recv_wid *rwid;
2459 
2460         rwid = kmem_zalloc(sizeof (struct recv_wid), KM_SLEEP);
2461         rwid->xid = msgid;


2669         clock_t timout, cv_wait_ret;
2670         rdma_stat ret = RDMA_SUCCESS;
2671         rib_qp_t *qp = ctoqp(conn);
2672 
2673         /*
2674          * Find the reply structure for this msgid
2675          */
2676         mutex_enter(&qp->replylist_lock);
2677 
2678         for (rep = qp->replylist; rep != NULL; rep = rep->next) {
2679                 if (rep->xid == msgid)
2680                         break;
2681         }
2682 
2683         if (rep != NULL) {
2684                 /*
2685                  * If message not yet received, wait.
2686                  */
2687                 if (rep->status == (uint_t)REPLY_WAIT) {
2688                         timout = ddi_get_lbolt() +
2689                             drv_usectohz(REPLY_WAIT_TIME * 1000000);
2690 
2691                         while ((cv_wait_ret = cv_timedwait_sig(&rep->wait_cv,
2692                             &qp->replylist_lock, timout)) > 0 &&
2693                             rep->status == (uint_t)REPLY_WAIT)
2694                                 ;
2695 
2696                         switch (cv_wait_ret) {
2697                         case -1:        /* timeout */
2698                                 ret = RDMA_TIMEDOUT;
2699                                 break;
2700                         case 0:
2701                                 ret = RDMA_INTR;
2702                                 break;
2703                         default:
2704                                 break;
2705                         }
2706                 }
2707 
2708                 if (rep->status == RDMA_SUCCESS) {
2709                         struct clist *cl = NULL;


4264                     (bcmp(s_svcaddr->buf, cn->c_laddr.buf,
4265                     s_svcaddr->len) == 0)))) {
4266                         /*
4267                          * Our connection. Give up conn list lock
4268                          * as we are done traversing the list.
4269                          */
4270                         rw_exit(&hca->cl_conn_list.conn_lock);
4271                         if (cn->c_state == C_CONNECTED) {
4272                                 cn->c_ref++; /* sharing a conn */
4273                                 mutex_exit(&cn->c_lock);
4274                                 *conn = cn;
4275                                 return (RDMA_SUCCESS);
4276                         }
4277                         if (cn->c_state == C_CONN_PEND) {
4278                                 /*
4279                                  * Hold a reference to this conn before
4280                                  * we give up the lock.
4281                                  */
4282                                 cn->c_ref++;
4283                                 timout =  ddi_get_lbolt() +
4284                                     drv_usectohz(CONN_WAIT_TIME * 1000000);
4285                                 while ((cv_stat = cv_timedwait_sig(&cn->c_cv,
4286                                     &cn->c_lock, timout)) > 0 &&
4287                                     cn->c_state == C_CONN_PEND)
4288                                         ;
4289                                 if (cv_stat == 0) {
4290                                         (void) rib_conn_release_locked(cn);
4291                                         return (RDMA_INTR);
4292                                 }
4293                                 if (cv_stat < 0) {
4294                                         (void) rib_conn_release_locked(cn);
4295                                         return (RDMA_TIMEDOUT);
4296                                 }
4297                                 if (cn->c_state == C_CONNECTED) {
4298                                         *conn = cn;
4299                                         mutex_exit(&cn->c_lock);
4300                                         return (RDMA_SUCCESS);
4301                                 } else {
4302                                         (void) rib_conn_release_locked(cn);
4303                                         return (RDMA_TIMEDOUT);
4304                                 }




2170 }
2171 
2172 /*
2173  * Wait for send completion notification. Only on receiving a
2174  * notification be it a successful or error completion, free the
2175  * send_wid.
2176  */
2177 static rdma_stat
2178 rib_sendwait(rib_qp_t *qp, struct send_wid *wd)
2179 {
2180         clock_t timout, cv_wait_ret;
2181         rdma_stat error = RDMA_SUCCESS;
2182         int     i;
2183 
2184         /*
2185          * Wait for send to complete
2186          */
2187         ASSERT(wd != NULL);
2188         mutex_enter(&wd->sendwait_lock);
2189         if (wd->status == (uint_t)SEND_WAIT) {
2190                 timout = drv_sectohz(SEND_WAIT_TIME) +
2191                     ddi_get_lbolt();
2192 
2193                 if (qp->mode == RIB_SERVER) {
2194                         while ((cv_wait_ret = cv_timedwait(&wd->wait_cv,
2195                             &wd->sendwait_lock, timout)) > 0 &&
2196                             wd->status == (uint_t)SEND_WAIT)
2197                                 ;
2198                         switch (cv_wait_ret) {
2199                         case -1:        /* timeout */
2200                                 DTRACE_PROBE(rpcib__i__srvsendwait__timeout);
2201 
2202                                 wd->cv_sig = 0;              /* no signal needed */
2203                                 error = RDMA_TIMEDOUT;
2204                                 break;
2205                         default:        /* got send completion */
2206                                 break;
2207                         }
2208                 } else {
2209                         while ((cv_wait_ret = cv_timedwait_sig(&wd->wait_cv,
2210                             &wd->sendwait_lock, timout)) > 0 &&


2421 {
2422         rdma_stat ret = RDMA_SUCCESS;
2423         struct rdma_done_list *rd;
2424         clock_t cv_wait_ret;
2425         caddr_t *wid = NULL;
2426         rib_qp_t *qp = ctoqp(conn);
2427 
2428         mutex_enter(&qp->rdlist_lock);
2429         rd = rdma_done_add(qp, msgid);
2430 
2431         /* No cv_signal (whether send-wait or no-send-wait) */
2432         ret = rib_send_and_wait(conn, cl, msgid, 1, 0, wid);
2433 
2434         if (ret != RDMA_SUCCESS) {
2435                 rdma_done_rm(qp, rd);
2436         } else {
2437                 /*
2438                  * Wait for RDMA_DONE from remote end
2439                  */
2440                 cv_wait_ret = cv_reltimedwait(&rd->rdma_done_cv,
2441                     &qp->rdlist_lock, drv_sectohz(REPLY_WAIT_TIME),
2442                     TR_CLOCK_TICK);
2443 
2444                 rdma_done_rm(qp, rd);
2445 
2446                 if (cv_wait_ret < 0) {
2447                         ret = RDMA_TIMEDOUT;
2448                 }
2449         }
2450 
2451         mutex_exit(&qp->rdlist_lock);
2452         return (ret);
2453 }
2454 
2455 static struct recv_wid *
2456 rib_create_wid(rib_qp_t *qp, ibt_wr_ds_t *sgl, uint32_t msgid)
2457 {
2458         struct recv_wid *rwid;
2459 
2460         rwid = kmem_zalloc(sizeof (struct recv_wid), KM_SLEEP);
2461         rwid->xid = msgid;


2669         clock_t timout, cv_wait_ret;
2670         rdma_stat ret = RDMA_SUCCESS;
2671         rib_qp_t *qp = ctoqp(conn);
2672 
2673         /*
2674          * Find the reply structure for this msgid
2675          */
2676         mutex_enter(&qp->replylist_lock);
2677 
2678         for (rep = qp->replylist; rep != NULL; rep = rep->next) {
2679                 if (rep->xid == msgid)
2680                         break;
2681         }
2682 
2683         if (rep != NULL) {
2684                 /*
2685                  * If message not yet received, wait.
2686                  */
2687                 if (rep->status == (uint_t)REPLY_WAIT) {
2688                         timout = ddi_get_lbolt() +
2689                             drv_sectohz(REPLY_WAIT_TIME);
2690 
2691                         while ((cv_wait_ret = cv_timedwait_sig(&rep->wait_cv,
2692                             &qp->replylist_lock, timout)) > 0 &&
2693                             rep->status == (uint_t)REPLY_WAIT)
2694                                 ;
2695 
2696                         switch (cv_wait_ret) {
2697                         case -1:        /* timeout */
2698                                 ret = RDMA_TIMEDOUT;
2699                                 break;
2700                         case 0:
2701                                 ret = RDMA_INTR;
2702                                 break;
2703                         default:
2704                                 break;
2705                         }
2706                 }
2707 
2708                 if (rep->status == RDMA_SUCCESS) {
2709                         struct clist *cl = NULL;


4264                     (bcmp(s_svcaddr->buf, cn->c_laddr.buf,
4265                     s_svcaddr->len) == 0)))) {
4266                         /*
4267                          * Our connection. Give up conn list lock
4268                          * as we are done traversing the list.
4269                          */
4270                         rw_exit(&hca->cl_conn_list.conn_lock);
4271                         if (cn->c_state == C_CONNECTED) {
4272                                 cn->c_ref++; /* sharing a conn */
4273                                 mutex_exit(&cn->c_lock);
4274                                 *conn = cn;
4275                                 return (RDMA_SUCCESS);
4276                         }
4277                         if (cn->c_state == C_CONN_PEND) {
4278                                 /*
4279                                  * Hold a reference to this conn before
4280                                  * we give up the lock.
4281                                  */
4282                                 cn->c_ref++;
4283                                 timout =  ddi_get_lbolt() +
4284                                     drv_sectohz(CONN_WAIT_TIME);
4285                                 while ((cv_stat = cv_timedwait_sig(&cn->c_cv,
4286                                     &cn->c_lock, timout)) > 0 &&
4287                                     cn->c_state == C_CONN_PEND)
4288                                         ;
4289                                 if (cv_stat == 0) {
4290                                         (void) rib_conn_release_locked(cn);
4291                                         return (RDMA_INTR);
4292                                 }
4293                                 if (cv_stat < 0) {
4294                                         (void) rib_conn_release_locked(cn);
4295                                         return (RDMA_TIMEDOUT);
4296                                 }
4297                                 if (cn->c_state == C_CONNECTED) {
4298                                         *conn = cn;
4299                                         mutex_exit(&cn->c_lock);
4300                                         return (RDMA_SUCCESS);
4301                                 } else {
4302                                         (void) rib_conn_release_locked(cn);
4303                                         return (RDMA_TIMEDOUT);
4304                                 }