Print this page
XXXX introduce drv_sectohz


 116         int             ret;
 117 
 118         RDS_DPRINTF4("rds_free_recv_caches", "Enter");
 119 
 120         mutex_enter(&rds_dpool.pool_lock);
 121         if (rds_dpool.pool_memp == NULL) {
 122                 RDS_DPRINTF2("rds_free_recv_caches", "Caches are empty");
 123                 mutex_exit(&rds_dpool.pool_lock);
 124                 return;
 125         }
 126 
 127         /*
 128          * All buffers must have been freed as all sessions are closed
 129          * and destroyed
 130          */
 131         ASSERT(rds_dpool.pool_nbusy == 0);
 132         RDS_DPRINTF2("rds_free_recv_caches", "Data Pool has "
 133             "pending buffers: %d", rds_dpool.pool_nbusy);
 134         while (rds_dpool.pool_nbusy != 0) {
 135                 mutex_exit(&rds_dpool.pool_lock);
 136                 delay(drv_usectohz(1000000));
 137                 mutex_enter(&rds_dpool.pool_lock);
 138         }
 139 
 140         hcap = statep->rds_hcalistp;
 141         while (hcap != NULL) {
 142                 if (hcap->hca_mrhdl != NULL) {
 143                         ret = ibt_deregister_mr(hcap->hca_hdl,
 144                             hcap->hca_mrhdl);
 145                         if (ret == IBT_SUCCESS) {
 146                                 hcap->hca_mrhdl = NULL;
 147                                 hcap->hca_lkey = 0;
 148                                 hcap->hca_rkey = 0;
 149                         } else {
 150                                 RDS_DPRINTF2(LABEL, "ibt_deregister_mr "
 151                                     "failed: %d, mrhdl: 0x%p", ret,
 152                                     hcap->hca_mrhdl);
 153                         }
 154                 }
 155                 hcap = hcap->hca_nextp;
 156         }


 798 
 799         return (bp);
 800 }
 801 
 802 boolean_t
 803 rds_is_recvq_empty(rds_ep_t *ep, boolean_t wait)
 804 {
 805         rds_qp_t        *recvqp;
 806         rds_bufpool_t   *rpool;
 807         boolean_t ret = B_TRUE;
 808 
 809         recvqp = &ep->ep_recvqp;
 810         mutex_enter(&recvqp->qp_lock);
 811         RDS_DPRINTF2("rds_is_recvq_empty", "EP(%p): QP has %d WRs",
 812             ep, recvqp->qp_level);
 813         if (wait) {
 814                 /* wait until the RQ is empty */
 815                 while (recvqp->qp_level != 0) {
 816                         /* wait one second and try again */
 817                         mutex_exit(&recvqp->qp_lock);
 818                         delay(drv_usectohz(1000000));
 819                         mutex_enter(&recvqp->qp_lock);
 820                 }
 821         } else if (recvqp->qp_level != 0) {
 822                         ret = B_FALSE;
 823         }
 824         mutex_exit(&recvqp->qp_lock);
 825 
 826         rpool = &ep->ep_rcvpool;
 827         mutex_enter(&rpool->pool_lock);
 828 
 829         /*
 830          * During failovers/reconnects, the app may still have some buffers
 831          * on thier socket queues. Waiting here for those buffers may
 832          * cause a hang. It seems ok for those buffers to get freed later.
 833          */
 834         if (rpool->pool_nbusy != 0) {
 835                 RDS_DPRINTF2("rds_is_recvq_empty", "EP(%p): "
 836                     "There are %d pending buffers on sockqs", ep,
 837                     rpool->pool_nbusy);
 838                 ret = B_FALSE;


 841 
 842         return (ret);
 843 }
 844 
 845 boolean_t
 846 rds_is_sendq_empty(rds_ep_t *ep, uint_t wait)
 847 {
 848         rds_bufpool_t   *spool;
 849         rds_buf_t       *bp;
 850         boolean_t       ret1 = B_TRUE;
 851 
 852         /* check if all the sends completed */
 853         spool = &ep->ep_sndpool;
 854         mutex_enter(&spool->pool_lock);
 855         RDS_DPRINTF2("rds_is_sendq_empty", "EP(%p): "
 856             "Send Pool contains: %d", ep, spool->pool_nbusy);
 857         if (wait) {
 858                 while (spool->pool_nbusy != 0) {
 859                         if (rds_no_interrupts) {
 860                                 /* wait one second and try again */
 861                                 delay(drv_usectohz(1000000));
 862                                 rds_poll_send_completions(ep->ep_sendcq, ep,
 863                                     B_TRUE);
 864                         } else {
 865                                 /* wait one second and try again */
 866                                 mutex_exit(&spool->pool_lock);
 867                                 delay(drv_usectohz(1000000));
 868                                 mutex_enter(&spool->pool_lock);
 869                         }
 870                 }
 871 
 872                 if ((wait == 2) && (ep->ep_type == RDS_EP_TYPE_DATA)) {
 873                         rds_buf_t       *ackbp;
 874                         rds_buf_t       *prev_ackbp;
 875 
 876                         /*
 877                          * If the last one is acknowledged then everything
 878                          * is acknowledged
 879                          */
 880                         bp = spool->pool_tailp;
 881                         ackbp = *(rds_buf_t **)ep->ep_ack_addr;
 882                         prev_ackbp = ackbp;
 883                         RDS_DPRINTF2("rds_is_sendq_empty", "EP(%p): "
 884                             "Checking for acknowledgements", ep);
 885                         while (bp != ackbp) {
 886                                 RDS_DPRINTF2("rds_is_sendq_empty",
 887                                     "EP(%p) BP(0x%p/0x%p) last "
 888                                     "sent/acknowledged", ep, bp, ackbp);
 889                                 mutex_exit(&spool->pool_lock);
 890                                 delay(drv_usectohz(1000000));
 891                                 mutex_enter(&spool->pool_lock);
 892 
 893                                 bp = spool->pool_tailp;
 894                                 ackbp = *(rds_buf_t **)ep->ep_ack_addr;
 895                                 if (ackbp == prev_ackbp) {
 896                                         RDS_DPRINTF2("rds_is_sendq_empty",
 897                                             "There has been no progress,"
 898                                             "give up and proceed");
 899                                         break;
 900                                 }
 901                                 prev_ackbp = ackbp;
 902                         }
 903                 }
 904         } else if (spool->pool_nbusy != 0) {
 905                         ret1 = B_FALSE;
 906         }
 907         mutex_exit(&spool->pool_lock);
 908 
 909         /* check if all the rdma acks completed */
 910         mutex_enter(&ep->ep_lock);
 911         RDS_DPRINTF2("rds_is_sendq_empty", "EP(%p): "
 912             "Outstanding RDMA Acks: %d", ep, ep->ep_rdmacnt);
 913         if (wait) {
 914                 while (ep->ep_rdmacnt != 0) {
 915                         if (rds_no_interrupts) {
 916                                 /* wait one second and try again */
 917                                 delay(drv_usectohz(1000000));
 918                                 rds_poll_send_completions(ep->ep_sendcq, ep,
 919                                     B_FALSE);
 920                         } else {
 921                                 /* wait one second and try again */
 922                                 mutex_exit(&ep->ep_lock);
 923                                 delay(drv_usectohz(1000000));
 924                                 mutex_enter(&ep->ep_lock);
 925                         }
 926                 }
 927         } else if (ep->ep_rdmacnt != 0) {
 928                         ret1 = B_FALSE;
 929         }
 930         mutex_exit(&ep->ep_lock);
 931 
 932         return (ret1);
 933 }
 934 
 935 /* Get buffers from the send pool */
 936 rds_buf_t *
 937 rds_get_send_buf(rds_ep_t *ep, uint_t nbuf)
 938 {
 939         rds_buf_t       *bp = NULL, *bp1;
 940         rds_bufpool_t   *spool;
 941         uint_t          waittime = rds_waittime_ms * 1000;
 942         uint_t          ix;
 943         int             ret;




 116         int             ret;
 117 
 118         RDS_DPRINTF4("rds_free_recv_caches", "Enter");
 119 
 120         mutex_enter(&rds_dpool.pool_lock);
 121         if (rds_dpool.pool_memp == NULL) {
 122                 RDS_DPRINTF2("rds_free_recv_caches", "Caches are empty");
 123                 mutex_exit(&rds_dpool.pool_lock);
 124                 return;
 125         }
 126 
 127         /*
 128          * All buffers must have been freed as all sessions are closed
 129          * and destroyed
 130          */
 131         ASSERT(rds_dpool.pool_nbusy == 0);
 132         RDS_DPRINTF2("rds_free_recv_caches", "Data Pool has "
 133             "pending buffers: %d", rds_dpool.pool_nbusy);
 134         while (rds_dpool.pool_nbusy != 0) {
 135                 mutex_exit(&rds_dpool.pool_lock);
 136                 delay(drv_sectohz(1));
 137                 mutex_enter(&rds_dpool.pool_lock);
 138         }
 139 
 140         hcap = statep->rds_hcalistp;
 141         while (hcap != NULL) {
 142                 if (hcap->hca_mrhdl != NULL) {
 143                         ret = ibt_deregister_mr(hcap->hca_hdl,
 144                             hcap->hca_mrhdl);
 145                         if (ret == IBT_SUCCESS) {
 146                                 hcap->hca_mrhdl = NULL;
 147                                 hcap->hca_lkey = 0;
 148                                 hcap->hca_rkey = 0;
 149                         } else {
 150                                 RDS_DPRINTF2(LABEL, "ibt_deregister_mr "
 151                                     "failed: %d, mrhdl: 0x%p", ret,
 152                                     hcap->hca_mrhdl);
 153                         }
 154                 }
 155                 hcap = hcap->hca_nextp;
 156         }


 798 
 799         return (bp);
 800 }
 801 
 802 boolean_t
 803 rds_is_recvq_empty(rds_ep_t *ep, boolean_t wait)
 804 {
 805         rds_qp_t        *recvqp;
 806         rds_bufpool_t   *rpool;
 807         boolean_t ret = B_TRUE;
 808 
 809         recvqp = &ep->ep_recvqp;
 810         mutex_enter(&recvqp->qp_lock);
 811         RDS_DPRINTF2("rds_is_recvq_empty", "EP(%p): QP has %d WRs",
 812             ep, recvqp->qp_level);
 813         if (wait) {
 814                 /* wait until the RQ is empty */
 815                 while (recvqp->qp_level != 0) {
 816                         /* wait one second and try again */
 817                         mutex_exit(&recvqp->qp_lock);
 818                         delay(drv_sectohz(1));
 819                         mutex_enter(&recvqp->qp_lock);
 820                 }
 821         } else if (recvqp->qp_level != 0) {
 822                         ret = B_FALSE;
 823         }
 824         mutex_exit(&recvqp->qp_lock);
 825 
 826         rpool = &ep->ep_rcvpool;
 827         mutex_enter(&rpool->pool_lock);
 828 
 829         /*
 830          * During failovers/reconnects, the app may still have some buffers
 831          * on thier socket queues. Waiting here for those buffers may
 832          * cause a hang. It seems ok for those buffers to get freed later.
 833          */
 834         if (rpool->pool_nbusy != 0) {
 835                 RDS_DPRINTF2("rds_is_recvq_empty", "EP(%p): "
 836                     "There are %d pending buffers on sockqs", ep,
 837                     rpool->pool_nbusy);
 838                 ret = B_FALSE;


 841 
 842         return (ret);
 843 }
 844 
 845 boolean_t
 846 rds_is_sendq_empty(rds_ep_t *ep, uint_t wait)
 847 {
 848         rds_bufpool_t   *spool;
 849         rds_buf_t       *bp;
 850         boolean_t       ret1 = B_TRUE;
 851 
 852         /* check if all the sends completed */
 853         spool = &ep->ep_sndpool;
 854         mutex_enter(&spool->pool_lock);
 855         RDS_DPRINTF2("rds_is_sendq_empty", "EP(%p): "
 856             "Send Pool contains: %d", ep, spool->pool_nbusy);
 857         if (wait) {
 858                 while (spool->pool_nbusy != 0) {
 859                         if (rds_no_interrupts) {
 860                                 /* wait one second and try again */
 861                                 delay(drv_sectohz(1));
 862                                 rds_poll_send_completions(ep->ep_sendcq, ep,
 863                                     B_TRUE);
 864                         } else {
 865                                 /* wait one second and try again */
 866                                 mutex_exit(&spool->pool_lock);
 867                                 delay(drv_sectohz(1));
 868                                 mutex_enter(&spool->pool_lock);
 869                         }
 870                 }
 871 
 872                 if ((wait == 2) && (ep->ep_type == RDS_EP_TYPE_DATA)) {
 873                         rds_buf_t       *ackbp;
 874                         rds_buf_t       *prev_ackbp;
 875 
 876                         /*
 877                          * If the last one is acknowledged then everything
 878                          * is acknowledged
 879                          */
 880                         bp = spool->pool_tailp;
 881                         ackbp = *(rds_buf_t **)ep->ep_ack_addr;
 882                         prev_ackbp = ackbp;
 883                         RDS_DPRINTF2("rds_is_sendq_empty", "EP(%p): "
 884                             "Checking for acknowledgements", ep);
 885                         while (bp != ackbp) {
 886                                 RDS_DPRINTF2("rds_is_sendq_empty",
 887                                     "EP(%p) BP(0x%p/0x%p) last "
 888                                     "sent/acknowledged", ep, bp, ackbp);
 889                                 mutex_exit(&spool->pool_lock);
 890                                 delay(drv_sectohz(1));
 891                                 mutex_enter(&spool->pool_lock);
 892 
 893                                 bp = spool->pool_tailp;
 894                                 ackbp = *(rds_buf_t **)ep->ep_ack_addr;
 895                                 if (ackbp == prev_ackbp) {
 896                                         RDS_DPRINTF2("rds_is_sendq_empty",
 897                                             "There has been no progress,"
 898                                             "give up and proceed");
 899                                         break;
 900                                 }
 901                                 prev_ackbp = ackbp;
 902                         }
 903                 }
 904         } else if (spool->pool_nbusy != 0) {
 905                         ret1 = B_FALSE;
 906         }
 907         mutex_exit(&spool->pool_lock);
 908 
 909         /* check if all the rdma acks completed */
 910         mutex_enter(&ep->ep_lock);
 911         RDS_DPRINTF2("rds_is_sendq_empty", "EP(%p): "
 912             "Outstanding RDMA Acks: %d", ep, ep->ep_rdmacnt);
 913         if (wait) {
 914                 while (ep->ep_rdmacnt != 0) {
 915                         if (rds_no_interrupts) {
 916                                 /* wait one second and try again */
 917                                 delay(drv_sectohz(1));
 918                                 rds_poll_send_completions(ep->ep_sendcq, ep,
 919                                     B_FALSE);
 920                         } else {
 921                                 /* wait one second and try again */
 922                                 mutex_exit(&ep->ep_lock);
 923                                 delay(drv_sectohz(1));
 924                                 mutex_enter(&ep->ep_lock);
 925                         }
 926                 }
 927         } else if (ep->ep_rdmacnt != 0) {
 928                         ret1 = B_FALSE;
 929         }
 930         mutex_exit(&ep->ep_lock);
 931 
 932         return (ret1);
 933 }
 934 
 935 /* Get buffers from the send pool */
 936 rds_buf_t *
 937 rds_get_send_buf(rds_ep_t *ep, uint_t nbuf)
 938 {
 939         rds_buf_t       *bp = NULL, *bp1;
 940         rds_bufpool_t   *spool;
 941         uint_t          waittime = rds_waittime_ms * 1000;
 942         uint_t          ix;
 943         int             ret;