Print this page
5255 uts shouldn't open-code ISP2


 387 
 388 
 389         /*
 390          * Calculate the appropriate size for the work queues.
 391          * For send queue, add in the headroom wqes to the calculation.
 392          * Note:  All Hermon QP work queues must be a power-of-2 in size.  Also
 393          * they may not be any smaller than HERMON_QP_MIN_SIZE.  This step is
 394          * to round the requested size up to the next highest power-of-2
 395          */
 396         /* first, adjust to a minimum and tell the caller the change */
 397         attr_p->qp_sizes.cs_sq = max(attr_p->qp_sizes.cs_sq,
 398             HERMON_QP_MIN_SIZE);
 399         attr_p->qp_sizes.cs_rq = max(attr_p->qp_sizes.cs_rq,
 400             HERMON_QP_MIN_SIZE);
 401         /*
 402          * now, calculate the alloc size, taking into account
 403          * the headroom for the sq
 404          */
 405         log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes);
 406         /* if the total is a power of two, reduce it */
 407         if (((attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes)  &
 408             (attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes - 1)) == 0)      {
 409                 log_qp_sq_size = log_qp_sq_size - 1;
 410         }
 411 
 412         log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq);
 413         if ((attr_p->qp_sizes.cs_rq & (attr_p->qp_sizes.cs_rq - 1)) == 0) {
 414                 log_qp_rq_size = log_qp_rq_size - 1;
 415         }
 416 
 417         /*
 418          * Next we verify that the rounded-up size is valid (i.e. consistent
 419          * with the device limits and/or software-configured limits).  If not,
 420          * then obviously we have a lot of cleanup to do before returning.
 421          *
 422          * NOTE: the first condition deals with the (test) case of cs_sq
 423          * being just less than 2^32.  In this case, the headroom addition
 424          * to the requested cs_sq will pass the test when it should not.
 425          * This test no longer lets that case slip through the check.
 426          */
 427         if ((attr_p->qp_sizes.cs_sq >
 428             (1 << state->hs_cfg_profile->cp_log_max_qp_sz)) ||
 429             (log_qp_sq_size > state->hs_cfg_profile->cp_log_max_qp_sz) ||
 430             (!qp_srq_en && (log_qp_rq_size >
 431             state->hs_cfg_profile->cp_log_max_qp_sz))) {
 432                 status = IBT_HCA_WR_EXCEEDED;
 433                 goto qpalloc_fail7;


 904          * alloc a qp doorbell, using uarpg (above) as the uar index
 905          */
 906 
 907         status = hermon_dbr_alloc(state, uarpg, &qp->qp_rq_dbr_acchdl,
 908             &qp->qp_rq_vdbr, &qp->qp_rq_pdbr, &qp->qp_rdbr_mapoffset);
 909         if (status != DDI_SUCCESS) {
 910                 status = IBT_INSUFF_RESOURCE;
 911                 goto spec_qpalloc_fail5;
 912         }
 913         /*
 914          * Calculate the appropriate size for the work queues.
 915          * Note:  All Hermon QP work queues must be a power-of-2 in size.  Also
 916          * they may not be any smaller than HERMON_QP_MIN_SIZE.  This step is
 917          * to round the requested size up to the next highest power-of-2
 918          */
 919         attr_p->qp_sizes.cs_sq =
 920             max(attr_p->qp_sizes.cs_sq, HERMON_QP_MIN_SIZE);
 921         attr_p->qp_sizes.cs_rq =
 922             max(attr_p->qp_sizes.cs_rq, HERMON_QP_MIN_SIZE);
 923         log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq);
 924         if ((attr_p->qp_sizes.cs_sq & (attr_p->qp_sizes.cs_sq - 1)) == 0) {
 925                 log_qp_sq_size = log_qp_sq_size - 1;
 926         }
 927         log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq);
 928         if ((attr_p->qp_sizes.cs_rq & (attr_p->qp_sizes.cs_rq - 1)) == 0) {
 929                 log_qp_rq_size = log_qp_rq_size - 1;
 930         }
 931 
 932         /*
 933          * Next we verify that the rounded-up size is valid (i.e. consistent
 934          * with the device limits and/or software-configured limits).  If not,
 935          * then obviously we have a bit of cleanup to do before returning.
 936          */
 937         if ((log_qp_sq_size > state->hs_cfg_profile->cp_log_max_qp_sz) ||
 938             (log_qp_rq_size > state->hs_cfg_profile->cp_log_max_qp_sz)) {
 939                 status = IBT_HCA_WR_EXCEEDED;
 940                 goto spec_qpalloc_fail5a;
 941         }
 942 
 943         /*
 944          * Next we verify that the requested number of SGL is valid (i.e.
 945          * consistent with the device limits and/or software-configured
 946          * limits).  If not, then obviously the same cleanup needs to be done.
 947          */
 948         max_sgl = state->hs_cfg_profile->cp_wqe_real_max_sgl;


1504 
1505 
1506         /*
1507          * Calculate the appropriate size for the work queues.
1508          * For send queue, add in the headroom wqes to the calculation.
1509          * Note:  All Hermon QP work queues must be a power-of-2 in size.  Also
1510          * they may not be any smaller than HERMON_QP_MIN_SIZE.  This step is
1511          * to round the requested size up to the next highest power-of-2
1512          */
1513         /* first, adjust to a minimum and tell the caller the change */
1514         attr_p->qp_sizes.cs_sq = max(attr_p->qp_sizes.cs_sq,
1515             HERMON_QP_MIN_SIZE);
1516         attr_p->qp_sizes.cs_rq = max(attr_p->qp_sizes.cs_rq,
1517             HERMON_QP_MIN_SIZE);
1518         /*
1519          * now, calculate the alloc size, taking into account
1520          * the headroom for the sq
1521          */
1522         log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes);
1523         /* if the total is a power of two, reduce it */
1524         if (((attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes)  &
1525             (attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes - 1)) == 0)      {
1526                 log_qp_sq_size = log_qp_sq_size - 1;
1527         }
1528 
1529         log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq);
1530         if ((attr_p->qp_sizes.cs_rq & (attr_p->qp_sizes.cs_rq - 1)) == 0) {
1531                 log_qp_rq_size = log_qp_rq_size - 1;
1532         }
1533 
1534         /*
1535          * Next we verify that the rounded-up size is valid (i.e. consistent
1536          * with the device limits and/or software-configured limits).  If not,
1537          * then obviously we have a lot of cleanup to do before returning.
1538          *
1539          * NOTE: the first condition deals with the (test) case of cs_sq
1540          * being just less than 2^32.  In this case, the headroom addition
1541          * to the requested cs_sq will pass the test when it should not.
1542          * This test no longer lets that case slip through the check.
1543          */
1544         if ((attr_p->qp_sizes.cs_sq >
1545             (1 << state->hs_cfg_profile->cp_log_max_qp_sz)) ||
1546             (log_qp_sq_size > state->hs_cfg_profile->cp_log_max_qp_sz) ||
1547             (!qp_srq_en && (log_qp_rq_size >
1548             state->hs_cfg_profile->cp_log_max_qp_sz))) {
1549                 status = IBT_HCA_WR_EXCEEDED;
1550                 goto qpalloc_fail7;


2814 /*
2815  * hermon_qp_sgl_to_logwqesz()
2816  *    Context: Can be called from interrupt or base context.
2817  */
2818 static void
2819 hermon_qp_sgl_to_logwqesz(hermon_state_t *state, uint_t num_sgl,
2820     uint_t real_max_sgl, hermon_qp_wq_type_t wq_type,
2821     uint_t *logwqesz, uint_t *max_sgl)
2822 {
2823         uint_t  max_size, log2, actual_sgl;
2824 
2825         switch (wq_type) {
2826         case HERMON_QP_WQ_TYPE_SENDQ_UD:
2827                 /*
2828                  * Use requested maximum SGL to calculate max descriptor size
2829                  * (while guaranteeing that the descriptor size is a
2830                  * power-of-2 cachelines).
2831                  */
2832                 max_size = (HERMON_QP_WQE_MLX_SND_HDRS + (num_sgl << 4));
2833                 log2 = highbit(max_size);
2834                 if ((max_size & (max_size - 1)) == 0) {
2835                         log2 = log2 - 1;
2836                 }
2837 
2838                 /* Make sure descriptor is at least the minimum size */
2839                 log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2840 
2841                 /* Calculate actual number of SGL (given WQE size) */
2842                 actual_sgl = ((1 << log2) -
2843                     sizeof (hermon_hw_snd_wqe_ctrl_t)) >> 4;
2844                 break;
2845 
2846         case HERMON_QP_WQ_TYPE_SENDQ_CONN:
2847                 /*
2848                  * Use requested maximum SGL to calculate max descriptor size
2849                  * (while guaranteeing that the descriptor size is a
2850                  * power-of-2 cachelines).
2851                  */
2852                 max_size = (HERMON_QP_WQE_MLX_SND_HDRS + (num_sgl << 4));
2853                 log2 = highbit(max_size);
2854                 if ((max_size & (max_size - 1)) == 0) {
2855                         log2 = log2 - 1;
2856                 }
2857 
2858                 /* Make sure descriptor is at least the minimum size */
2859                 log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2860 
2861                 /* Calculate actual number of SGL (given WQE size) */
2862                 actual_sgl = ((1 << log2) - HERMON_QP_WQE_MLX_SND_HDRS) >> 4;
2863                 break;
2864 
2865         case HERMON_QP_WQ_TYPE_RECVQ:
2866                 /*
2867                  * Same as above (except for Recv WQEs)
2868                  */
2869                 max_size = (HERMON_QP_WQE_MLX_RCV_HDRS + (num_sgl << 4));
2870                 log2 = highbit(max_size);
2871                 if ((max_size & (max_size - 1)) == 0) {
2872                         log2 = log2 - 1;
2873                 }
2874 
2875                 /* Make sure descriptor is at least the minimum size */
2876                 log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2877 
2878                 /* Calculate actual number of SGL (given WQE size) */
2879                 actual_sgl = ((1 << log2) - HERMON_QP_WQE_MLX_RCV_HDRS) >> 4;
2880                 break;
2881 
2882         case HERMON_QP_WQ_TYPE_SENDMLX_QP0:
2883                 /*
2884                  * Same as above (except for MLX transport WQEs).  For these
2885                  * WQEs we have to account for the space consumed by the
2886                  * "inline" packet headers.  (This is smaller than for QP1
2887                  * below because QP0 is not allowed to send packets with a GRH.
2888                  */
2889                 max_size = (HERMON_QP_WQE_MLX_QP0_HDRS + (num_sgl << 4));
2890                 log2 = highbit(max_size);
2891                 if ((max_size & (max_size - 1)) == 0) {
2892                         log2 = log2 - 1;
2893                 }
2894 
2895                 /* Make sure descriptor is at least the minimum size */
2896                 log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2897 
2898                 /* Calculate actual number of SGL (given WQE size) */
2899                 actual_sgl = ((1 << log2) - HERMON_QP_WQE_MLX_QP0_HDRS) >> 4;
2900                 break;
2901 
2902         case HERMON_QP_WQ_TYPE_SENDMLX_QP1:
2903                 /*
2904                  * Same as above.  For these WQEs we again have to account for
2905                  * the space consumed by the "inline" packet headers.  (This
2906                  * is larger than for QP0 above because we have to account for
2907                  * the possibility of a GRH in each packet - and this
2908                  * introduces an alignment issue that causes us to consume
2909                  * an additional 8 bytes).
2910                  */
2911                 max_size = (HERMON_QP_WQE_MLX_QP1_HDRS + (num_sgl << 4));
2912                 log2 = highbit(max_size);
2913                 if ((max_size & (max_size - 1)) == 0) {
2914                         log2 = log2 - 1;
2915                 }
2916 
2917                 /* Make sure descriptor is at least the minimum size */
2918                 log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2919 
2920                 /* Calculate actual number of SGL (given WQE size) */
2921                 actual_sgl = ((1 << log2) - HERMON_QP_WQE_MLX_QP1_HDRS) >> 4;
2922                 break;
2923 
2924         default:
2925                 HERMON_WARNING(state, "unexpected work queue type");
2926                 break;
2927         }
2928 
2929         /* Fill in the return values */
2930         *logwqesz = log2;
2931         *max_sgl  = min(real_max_sgl, actual_sgl);
2932 }


 387 
 388 
 389         /*
 390          * Calculate the appropriate size for the work queues.
 391          * For send queue, add in the headroom wqes to the calculation.
 392          * Note:  All Hermon QP work queues must be a power-of-2 in size.  Also
 393          * they may not be any smaller than HERMON_QP_MIN_SIZE.  This step is
 394          * to round the requested size up to the next highest power-of-2
 395          */
 396         /* first, adjust to a minimum and tell the caller the change */
 397         attr_p->qp_sizes.cs_sq = max(attr_p->qp_sizes.cs_sq,
 398             HERMON_QP_MIN_SIZE);
 399         attr_p->qp_sizes.cs_rq = max(attr_p->qp_sizes.cs_rq,
 400             HERMON_QP_MIN_SIZE);
 401         /*
 402          * now, calculate the alloc size, taking into account
 403          * the headroom for the sq
 404          */
 405         log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes);
 406         /* if the total is a power of two, reduce it */
 407         if (ISP2(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes))    {

 408                 log_qp_sq_size = log_qp_sq_size - 1;
 409         }
 410 
 411         log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq);
 412         if (ISP2(attr_p->qp_sizes.cs_rq)) {
 413                 log_qp_rq_size = log_qp_rq_size - 1;
 414         }
 415 
 416         /*
 417          * Next we verify that the rounded-up size is valid (i.e. consistent
 418          * with the device limits and/or software-configured limits).  If not,
 419          * then obviously we have a lot of cleanup to do before returning.
 420          *
 421          * NOTE: the first condition deals with the (test) case of cs_sq
 422          * being just less than 2^32.  In this case, the headroom addition
 423          * to the requested cs_sq will pass the test when it should not.
 424          * This test no longer lets that case slip through the check.
 425          */
 426         if ((attr_p->qp_sizes.cs_sq >
 427             (1 << state->hs_cfg_profile->cp_log_max_qp_sz)) ||
 428             (log_qp_sq_size > state->hs_cfg_profile->cp_log_max_qp_sz) ||
 429             (!qp_srq_en && (log_qp_rq_size >
 430             state->hs_cfg_profile->cp_log_max_qp_sz))) {
 431                 status = IBT_HCA_WR_EXCEEDED;
 432                 goto qpalloc_fail7;


 903          * alloc a qp doorbell, using uarpg (above) as the uar index
 904          */
 905 
 906         status = hermon_dbr_alloc(state, uarpg, &qp->qp_rq_dbr_acchdl,
 907             &qp->qp_rq_vdbr, &qp->qp_rq_pdbr, &qp->qp_rdbr_mapoffset);
 908         if (status != DDI_SUCCESS) {
 909                 status = IBT_INSUFF_RESOURCE;
 910                 goto spec_qpalloc_fail5;
 911         }
 912         /*
 913          * Calculate the appropriate size for the work queues.
 914          * Note:  All Hermon QP work queues must be a power-of-2 in size.  Also
 915          * they may not be any smaller than HERMON_QP_MIN_SIZE.  This step is
 916          * to round the requested size up to the next highest power-of-2
 917          */
 918         attr_p->qp_sizes.cs_sq =
 919             max(attr_p->qp_sizes.cs_sq, HERMON_QP_MIN_SIZE);
 920         attr_p->qp_sizes.cs_rq =
 921             max(attr_p->qp_sizes.cs_rq, HERMON_QP_MIN_SIZE);
 922         log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq);
 923         if (ISP2(attr_p->qp_sizes.cs_sq)) {
 924                 log_qp_sq_size = log_qp_sq_size - 1;
 925         }
 926         log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq);
 927         if (ISP2(attr_p->qp_sizes.cs_rq)) {
 928                 log_qp_rq_size = log_qp_rq_size - 1;
 929         }
 930 
 931         /*
 932          * Next we verify that the rounded-up size is valid (i.e. consistent
 933          * with the device limits and/or software-configured limits).  If not,
 934          * then obviously we have a bit of cleanup to do before returning.
 935          */
 936         if ((log_qp_sq_size > state->hs_cfg_profile->cp_log_max_qp_sz) ||
 937             (log_qp_rq_size > state->hs_cfg_profile->cp_log_max_qp_sz)) {
 938                 status = IBT_HCA_WR_EXCEEDED;
 939                 goto spec_qpalloc_fail5a;
 940         }
 941 
 942         /*
 943          * Next we verify that the requested number of SGL is valid (i.e.
 944          * consistent with the device limits and/or software-configured
 945          * limits).  If not, then obviously the same cleanup needs to be done.
 946          */
 947         max_sgl = state->hs_cfg_profile->cp_wqe_real_max_sgl;


1503 
1504 
1505         /*
1506          * Calculate the appropriate size for the work queues.
1507          * For send queue, add in the headroom wqes to the calculation.
1508          * Note:  All Hermon QP work queues must be a power-of-2 in size.  Also
1509          * they may not be any smaller than HERMON_QP_MIN_SIZE.  This step is
1510          * to round the requested size up to the next highest power-of-2
1511          */
1512         /* first, adjust to a minimum and tell the caller the change */
1513         attr_p->qp_sizes.cs_sq = max(attr_p->qp_sizes.cs_sq,
1514             HERMON_QP_MIN_SIZE);
1515         attr_p->qp_sizes.cs_rq = max(attr_p->qp_sizes.cs_rq,
1516             HERMON_QP_MIN_SIZE);
1517         /*
1518          * now, calculate the alloc size, taking into account
1519          * the headroom for the sq
1520          */
1521         log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes);
1522         /* if the total is a power of two, reduce it */
1523         if (ISP2(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes))    {

1524                 log_qp_sq_size = log_qp_sq_size - 1;
1525         }
1526 
1527         log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq);
1528         if (ISP2(attr_p->qp_sizes.cs_rq)) {
1529                 log_qp_rq_size = log_qp_rq_size - 1;
1530         }
1531 
1532         /*
1533          * Next we verify that the rounded-up size is valid (i.e. consistent
1534          * with the device limits and/or software-configured limits).  If not,
1535          * then obviously we have a lot of cleanup to do before returning.
1536          *
1537          * NOTE: the first condition deals with the (test) case of cs_sq
1538          * being just less than 2^32.  In this case, the headroom addition
1539          * to the requested cs_sq will pass the test when it should not.
1540          * This test no longer lets that case slip through the check.
1541          */
1542         if ((attr_p->qp_sizes.cs_sq >
1543             (1 << state->hs_cfg_profile->cp_log_max_qp_sz)) ||
1544             (log_qp_sq_size > state->hs_cfg_profile->cp_log_max_qp_sz) ||
1545             (!qp_srq_en && (log_qp_rq_size >
1546             state->hs_cfg_profile->cp_log_max_qp_sz))) {
1547                 status = IBT_HCA_WR_EXCEEDED;
1548                 goto qpalloc_fail7;


2812 /*
2813  * hermon_qp_sgl_to_logwqesz()
2814  *    Context: Can be called from interrupt or base context.
2815  */
2816 static void
2817 hermon_qp_sgl_to_logwqesz(hermon_state_t *state, uint_t num_sgl,
2818     uint_t real_max_sgl, hermon_qp_wq_type_t wq_type,
2819     uint_t *logwqesz, uint_t *max_sgl)
2820 {
2821         uint_t  max_size, log2, actual_sgl;
2822 
2823         switch (wq_type) {
2824         case HERMON_QP_WQ_TYPE_SENDQ_UD:
2825                 /*
2826                  * Use requested maximum SGL to calculate max descriptor size
2827                  * (while guaranteeing that the descriptor size is a
2828                  * power-of-2 cachelines).
2829                  */
2830                 max_size = (HERMON_QP_WQE_MLX_SND_HDRS + (num_sgl << 4));
2831                 log2 = highbit(max_size);
2832                 if (ISP2(max_size)) {
2833                         log2 = log2 - 1;
2834                 }
2835 
2836                 /* Make sure descriptor is at least the minimum size */
2837                 log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2838 
2839                 /* Calculate actual number of SGL (given WQE size) */
2840                 actual_sgl = ((1 << log2) -
2841                     sizeof (hermon_hw_snd_wqe_ctrl_t)) >> 4;
2842                 break;
2843 
2844         case HERMON_QP_WQ_TYPE_SENDQ_CONN:
2845                 /*
2846                  * Use requested maximum SGL to calculate max descriptor size
2847                  * (while guaranteeing that the descriptor size is a
2848                  * power-of-2 cachelines).
2849                  */
2850                 max_size = (HERMON_QP_WQE_MLX_SND_HDRS + (num_sgl << 4));
2851                 log2 = highbit(max_size);
2852                 if (ISP2(max_size)) {
2853                         log2 = log2 - 1;
2854                 }
2855 
2856                 /* Make sure descriptor is at least the minimum size */
2857                 log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2858 
2859                 /* Calculate actual number of SGL (given WQE size) */
2860                 actual_sgl = ((1 << log2) - HERMON_QP_WQE_MLX_SND_HDRS) >> 4;
2861                 break;
2862 
2863         case HERMON_QP_WQ_TYPE_RECVQ:
2864                 /*
2865                  * Same as above (except for Recv WQEs)
2866                  */
2867                 max_size = (HERMON_QP_WQE_MLX_RCV_HDRS + (num_sgl << 4));
2868                 log2 = highbit(max_size);
2869                 if (ISP2(max_size)) {
2870                         log2 = log2 - 1;
2871                 }
2872 
2873                 /* Make sure descriptor is at least the minimum size */
2874                 log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2875 
2876                 /* Calculate actual number of SGL (given WQE size) */
2877                 actual_sgl = ((1 << log2) - HERMON_QP_WQE_MLX_RCV_HDRS) >> 4;
2878                 break;
2879 
2880         case HERMON_QP_WQ_TYPE_SENDMLX_QP0:
2881                 /*
2882                  * Same as above (except for MLX transport WQEs).  For these
2883                  * WQEs we have to account for the space consumed by the
2884                  * "inline" packet headers.  (This is smaller than for QP1
2885                  * below because QP0 is not allowed to send packets with a GRH.
2886                  */
2887                 max_size = (HERMON_QP_WQE_MLX_QP0_HDRS + (num_sgl << 4));
2888                 log2 = highbit(max_size);
2889                 if (ISP2(max_size)) {
2890                         log2 = log2 - 1;
2891                 }
2892 
2893                 /* Make sure descriptor is at least the minimum size */
2894                 log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2895 
2896                 /* Calculate actual number of SGL (given WQE size) */
2897                 actual_sgl = ((1 << log2) - HERMON_QP_WQE_MLX_QP0_HDRS) >> 4;
2898                 break;
2899 
2900         case HERMON_QP_WQ_TYPE_SENDMLX_QP1:
2901                 /*
2902                  * Same as above.  For these WQEs we again have to account for
2903                  * the space consumed by the "inline" packet headers.  (This
2904                  * is larger than for QP0 above because we have to account for
2905                  * the possibility of a GRH in each packet - and this
2906                  * introduces an alignment issue that causes us to consume
2907                  * an additional 8 bytes).
2908                  */
2909                 max_size = (HERMON_QP_WQE_MLX_QP1_HDRS + (num_sgl << 4));
2910                 log2 = highbit(max_size);
2911                 if (ISP2(max_size)) {
2912                         log2 = log2 - 1;
2913                 }
2914 
2915                 /* Make sure descriptor is at least the minimum size */
2916                 log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2917 
2918                 /* Calculate actual number of SGL (given WQE size) */
2919                 actual_sgl = ((1 << log2) - HERMON_QP_WQE_MLX_QP1_HDRS) >> 4;
2920                 break;
2921 
2922         default:
2923                 HERMON_WARNING(state, "unexpected work queue type");
2924                 break;
2925         }
2926 
2927         /* Fill in the return values */
2928         *logwqesz = log2;
2929         *max_sgl  = min(real_max_sgl, actual_sgl);
2930 }