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


 300                         /* Set "status" and "errormsg" and goto failure */
 301                         TAVOR_TNF_FAIL(IBT_INSUFF_RESOURCE, "failed RDB");
 302                         goto qpalloc_fail7;
 303                 }
 304                 qp->qp_rdbrsrcp = rdb;
 305                 /* Calculate offset (into DDR memory) of RDB entries */
 306                 rsrc_pool = &state->ts_rsrc_hdl[TAVOR_RDB];
 307                 qp->qp_rdb_ddraddr = (uintptr_t)rsrc_pool->rsrc_ddr_offset +
 308                     (rdb->tr_indx << TAVOR_RDB_SIZE_SHIFT);
 309         }
 310 
 311         /*
 312          * Calculate the appropriate size for the work queues.
 313          * Note:  All Tavor QP work queues must be a power-of-2 in size.  Also
 314          * they may not be any smaller than TAVOR_QP_MIN_SIZE.  This step is
 315          * to round the requested size up to the next highest power-of-2
 316          */
 317         attr_p->qp_sizes.cs_sq = max(attr_p->qp_sizes.cs_sq, TAVOR_QP_MIN_SIZE);
 318         attr_p->qp_sizes.cs_rq = max(attr_p->qp_sizes.cs_rq, TAVOR_QP_MIN_SIZE);
 319         log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq);
 320         if ((attr_p->qp_sizes.cs_sq & (attr_p->qp_sizes.cs_sq - 1)) == 0) {
 321                 log_qp_sq_size = log_qp_sq_size - 1;
 322         }
 323         log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq);
 324         if ((attr_p->qp_sizes.cs_rq & (attr_p->qp_sizes.cs_rq - 1)) == 0) {
 325                 log_qp_rq_size = log_qp_rq_size - 1;
 326         }
 327 
 328         /*
 329          * Next we verify that the rounded-up size is valid (i.e. consistent
 330          * with the device limits and/or software-configured limits).  If not,
 331          * then obviously we have a lot of cleanup to do before returning.
 332          */
 333         if ((log_qp_sq_size > state->ts_cfg_profile->cp_log_max_qp_sz) ||
 334             (!qp_srq_en && (log_qp_rq_size >
 335             state->ts_cfg_profile->cp_log_max_qp_sz))) {
 336                 /* Set "status" and "errormsg" and goto failure */
 337                 TAVOR_TNF_FAIL(IBT_HCA_WR_EXCEEDED, "max QP size");
 338                 goto qpalloc_fail8;
 339         }
 340 
 341         /*
 342          * Next we verify that the requested number of SGL is valid (i.e.
 343          * consistent with the device limits and/or software-configured
 344          * limits).  If not, then obviously the same cleanup needs to be done.


 786         }
 787         qp = (tavor_qphdl_t)rsrc->tr_addr;
 788         _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*qp))
 789 
 790         /*
 791          * Actual QP number is a combination of the index of the QPC and
 792          * the port number.  This is because the special QP contexts must
 793          * be allocated two-at-a-time.
 794          */
 795         qp->qp_qpnum = qpc->tr_indx + port;
 796 
 797         /*
 798          * Calculate the appropriate size for the work queues.
 799          * Note:  All Tavor QP work queues must be a power-of-2 in size.  Also
 800          * they may not be any smaller than TAVOR_QP_MIN_SIZE.  This step is
 801          * to round the requested size up to the next highest power-of-2
 802          */
 803         attr_p->qp_sizes.cs_sq = max(attr_p->qp_sizes.cs_sq, TAVOR_QP_MIN_SIZE);
 804         attr_p->qp_sizes.cs_rq = max(attr_p->qp_sizes.cs_rq, TAVOR_QP_MIN_SIZE);
 805         log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq);
 806         if ((attr_p->qp_sizes.cs_sq & (attr_p->qp_sizes.cs_sq - 1)) == 0) {
 807                 log_qp_sq_size = log_qp_sq_size - 1;
 808         }
 809         log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq);
 810         if ((attr_p->qp_sizes.cs_rq & (attr_p->qp_sizes.cs_rq - 1)) == 0) {
 811                 log_qp_rq_size = log_qp_rq_size - 1;
 812         }
 813 
 814         /*
 815          * Next we verify that the rounded-up size is valid (i.e. consistent
 816          * with the device limits and/or software-configured limits).  If not,
 817          * then obviously we have a bit of cleanup to do before returning.
 818          */
 819         if ((log_qp_sq_size > state->ts_cfg_profile->cp_log_max_qp_sz) ||
 820             (log_qp_rq_size > state->ts_cfg_profile->cp_log_max_qp_sz)) {
 821                 /* Set "status" and "errormsg" and goto failure */
 822                 TAVOR_TNF_FAIL(IBT_HCA_WR_EXCEEDED, "max QP size");
 823                 goto spec_qpalloc_fail5;
 824         }
 825 
 826         /*
 827          * Next we verify that the requested number of SGL is valid (i.e.
 828          * consistent with the device limits and/or software-configured
 829          * limits).  If not, then obviously the same cleanup needs to be done.
 830          */


1974  * tavor_qp_sgl_to_logwqesz()
1975  *    Context: Can be called from interrupt or base context.
1976  */
1977 static void
1978 tavor_qp_sgl_to_logwqesz(tavor_state_t *state, uint_t num_sgl,
1979     tavor_qp_wq_type_t wq_type, uint_t *logwqesz, uint_t *max_sgl)
1980 {
1981         uint_t  max_size, log2, actual_sgl;
1982 
1983         TAVOR_TNF_ENTER(tavor_qp_sgl_to_logwqesz);
1984 
1985         switch (wq_type) {
1986         case TAVOR_QP_WQ_TYPE_SENDQ:
1987                 /*
1988                  * Use requested maximum SGL to calculate max descriptor size
1989                  * (while guaranteeing that the descriptor size is a
1990                  * power-of-2 cachelines).
1991                  */
1992                 max_size = (TAVOR_QP_WQE_MLX_SND_HDRS + (num_sgl << 4));
1993                 log2 = highbit(max_size);
1994                 if ((max_size & (max_size - 1)) == 0) {
1995                         log2 = log2 - 1;
1996                 }
1997 
1998                 /* Make sure descriptor is at least the minimum size */
1999                 log2 = max(log2, TAVOR_QP_WQE_LOG_MINIMUM);
2000 
2001                 /* Calculate actual number of SGL (given WQE size) */
2002                 actual_sgl = ((1 << log2) - TAVOR_QP_WQE_MLX_SND_HDRS) >> 4;
2003                 break;
2004 
2005         case TAVOR_QP_WQ_TYPE_RECVQ:
2006                 /*
2007                  * Same as above (except for Recv WQEs)
2008                  */
2009                 max_size = (TAVOR_QP_WQE_MLX_RCV_HDRS + (num_sgl << 4));
2010                 log2 = highbit(max_size);
2011                 if ((max_size & (max_size - 1)) == 0) {
2012                         log2 = log2 - 1;
2013                 }
2014 
2015                 /* Make sure descriptor is at least the minimum size */
2016                 log2 = max(log2, TAVOR_QP_WQE_LOG_MINIMUM);
2017 
2018                 /* Calculate actual number of SGL (given WQE size) */
2019                 actual_sgl = ((1 << log2) - TAVOR_QP_WQE_MLX_RCV_HDRS) >> 4;
2020                 break;
2021 
2022         case TAVOR_QP_WQ_TYPE_SENDMLX_QP0:
2023                 /*
2024                  * Same as above (except for MLX transport WQEs).  For these
2025                  * WQEs we have to account for the space consumed by the
2026                  * "inline" packet headers.  (This is smaller than for QP1
2027                  * below because QP0 is not allowed to send packets with a GRH.
2028                  */
2029                 max_size = (TAVOR_QP_WQE_MLX_QP0_HDRS + (num_sgl << 4));
2030                 log2 = highbit(max_size);
2031                 if ((max_size & (max_size - 1)) == 0) {
2032                         log2 = log2 - 1;
2033                 }
2034 
2035                 /* Make sure descriptor is at least the minimum size */
2036                 log2 = max(log2, TAVOR_QP_WQE_LOG_MINIMUM);
2037 
2038                 /* Calculate actual number of SGL (given WQE size) */
2039                 actual_sgl = ((1 << log2) - TAVOR_QP_WQE_MLX_QP0_HDRS) >> 4;
2040                 break;
2041 
2042         case TAVOR_QP_WQ_TYPE_SENDMLX_QP1:
2043                 /*
2044                  * Same as above.  For these WQEs we again have to account for
2045                  * the space consumed by the "inline" packet headers.  (This
2046                  * is larger than for QP0 above because we have to account for
2047                  * the possibility of a GRH in each packet - and this
2048                  * introduces an alignment issue that causes us to consume
2049                  * an additional 8 bytes).
2050                  */
2051                 max_size = (TAVOR_QP_WQE_MLX_QP1_HDRS + (num_sgl << 4));
2052                 log2 = highbit(max_size);
2053                 if ((max_size & (max_size - 1)) == 0) {
2054                         log2 = log2 - 1;
2055                 }
2056 
2057                 /* Make sure descriptor is at least the minimum size */
2058                 log2 = max(log2, TAVOR_QP_WQE_LOG_MINIMUM);
2059 
2060                 /* Calculate actual number of SGL (given WQE size) */
2061                 actual_sgl = ((1 << log2) - TAVOR_QP_WQE_MLX_QP1_HDRS) >> 4;
2062                 break;
2063 
2064         default:
2065                 TAVOR_WARNING(state, "unexpected work queue type");
2066                 TNF_PROBE_0(tavor_qp_sgl_to_logwqesz_inv_wqtype_fail,
2067                     TAVOR_TNF_ERROR, "");
2068                 break;
2069         }
2070 
2071         /* Fill in the return values */
2072         *logwqesz = log2;
2073         *max_sgl  = min(state->ts_cfg_profile->cp_wqe_real_max_sgl, actual_sgl);


 300                         /* Set "status" and "errormsg" and goto failure */
 301                         TAVOR_TNF_FAIL(IBT_INSUFF_RESOURCE, "failed RDB");
 302                         goto qpalloc_fail7;
 303                 }
 304                 qp->qp_rdbrsrcp = rdb;
 305                 /* Calculate offset (into DDR memory) of RDB entries */
 306                 rsrc_pool = &state->ts_rsrc_hdl[TAVOR_RDB];
 307                 qp->qp_rdb_ddraddr = (uintptr_t)rsrc_pool->rsrc_ddr_offset +
 308                     (rdb->tr_indx << TAVOR_RDB_SIZE_SHIFT);
 309         }
 310 
 311         /*
 312          * Calculate the appropriate size for the work queues.
 313          * Note:  All Tavor QP work queues must be a power-of-2 in size.  Also
 314          * they may not be any smaller than TAVOR_QP_MIN_SIZE.  This step is
 315          * to round the requested size up to the next highest power-of-2
 316          */
 317         attr_p->qp_sizes.cs_sq = max(attr_p->qp_sizes.cs_sq, TAVOR_QP_MIN_SIZE);
 318         attr_p->qp_sizes.cs_rq = max(attr_p->qp_sizes.cs_rq, TAVOR_QP_MIN_SIZE);
 319         log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq);
 320         if (ISP2(attr_p->qp_sizes.cs_sq)) {
 321                 log_qp_sq_size = log_qp_sq_size - 1;
 322         }
 323         log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq);
 324         if (ISP2(attr_p->qp_sizes.cs_rq)) {
 325                 log_qp_rq_size = log_qp_rq_size - 1;
 326         }
 327 
 328         /*
 329          * Next we verify that the rounded-up size is valid (i.e. consistent
 330          * with the device limits and/or software-configured limits).  If not,
 331          * then obviously we have a lot of cleanup to do before returning.
 332          */
 333         if ((log_qp_sq_size > state->ts_cfg_profile->cp_log_max_qp_sz) ||
 334             (!qp_srq_en && (log_qp_rq_size >
 335             state->ts_cfg_profile->cp_log_max_qp_sz))) {
 336                 /* Set "status" and "errormsg" and goto failure */
 337                 TAVOR_TNF_FAIL(IBT_HCA_WR_EXCEEDED, "max QP size");
 338                 goto qpalloc_fail8;
 339         }
 340 
 341         /*
 342          * Next we verify that the requested number of SGL is valid (i.e.
 343          * consistent with the device limits and/or software-configured
 344          * limits).  If not, then obviously the same cleanup needs to be done.


 786         }
 787         qp = (tavor_qphdl_t)rsrc->tr_addr;
 788         _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*qp))
 789 
 790         /*
 791          * Actual QP number is a combination of the index of the QPC and
 792          * the port number.  This is because the special QP contexts must
 793          * be allocated two-at-a-time.
 794          */
 795         qp->qp_qpnum = qpc->tr_indx + port;
 796 
 797         /*
 798          * Calculate the appropriate size for the work queues.
 799          * Note:  All Tavor QP work queues must be a power-of-2 in size.  Also
 800          * they may not be any smaller than TAVOR_QP_MIN_SIZE.  This step is
 801          * to round the requested size up to the next highest power-of-2
 802          */
 803         attr_p->qp_sizes.cs_sq = max(attr_p->qp_sizes.cs_sq, TAVOR_QP_MIN_SIZE);
 804         attr_p->qp_sizes.cs_rq = max(attr_p->qp_sizes.cs_rq, TAVOR_QP_MIN_SIZE);
 805         log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq);
 806         if (ISP2(attr_p->qp_sizes.cs_sq)) {
 807                 log_qp_sq_size = log_qp_sq_size - 1;
 808         }
 809         log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq);
 810         if (ISP2(attr_p->qp_sizes.cs_rq)) {
 811                 log_qp_rq_size = log_qp_rq_size - 1;
 812         }
 813 
 814         /*
 815          * Next we verify that the rounded-up size is valid (i.e. consistent
 816          * with the device limits and/or software-configured limits).  If not,
 817          * then obviously we have a bit of cleanup to do before returning.
 818          */
 819         if ((log_qp_sq_size > state->ts_cfg_profile->cp_log_max_qp_sz) ||
 820             (log_qp_rq_size > state->ts_cfg_profile->cp_log_max_qp_sz)) {
 821                 /* Set "status" and "errormsg" and goto failure */
 822                 TAVOR_TNF_FAIL(IBT_HCA_WR_EXCEEDED, "max QP size");
 823                 goto spec_qpalloc_fail5;
 824         }
 825 
 826         /*
 827          * Next we verify that the requested number of SGL is valid (i.e.
 828          * consistent with the device limits and/or software-configured
 829          * limits).  If not, then obviously the same cleanup needs to be done.
 830          */


1974  * tavor_qp_sgl_to_logwqesz()
1975  *    Context: Can be called from interrupt or base context.
1976  */
1977 static void
1978 tavor_qp_sgl_to_logwqesz(tavor_state_t *state, uint_t num_sgl,
1979     tavor_qp_wq_type_t wq_type, uint_t *logwqesz, uint_t *max_sgl)
1980 {
1981         uint_t  max_size, log2, actual_sgl;
1982 
1983         TAVOR_TNF_ENTER(tavor_qp_sgl_to_logwqesz);
1984 
1985         switch (wq_type) {
1986         case TAVOR_QP_WQ_TYPE_SENDQ:
1987                 /*
1988                  * Use requested maximum SGL to calculate max descriptor size
1989                  * (while guaranteeing that the descriptor size is a
1990                  * power-of-2 cachelines).
1991                  */
1992                 max_size = (TAVOR_QP_WQE_MLX_SND_HDRS + (num_sgl << 4));
1993                 log2 = highbit(max_size);
1994                 if (ISP2(max_size)) {
1995                         log2 = log2 - 1;
1996                 }
1997 
1998                 /* Make sure descriptor is at least the minimum size */
1999                 log2 = max(log2, TAVOR_QP_WQE_LOG_MINIMUM);
2000 
2001                 /* Calculate actual number of SGL (given WQE size) */
2002                 actual_sgl = ((1 << log2) - TAVOR_QP_WQE_MLX_SND_HDRS) >> 4;
2003                 break;
2004 
2005         case TAVOR_QP_WQ_TYPE_RECVQ:
2006                 /*
2007                  * Same as above (except for Recv WQEs)
2008                  */
2009                 max_size = (TAVOR_QP_WQE_MLX_RCV_HDRS + (num_sgl << 4));
2010                 log2 = highbit(max_size);
2011                 if (ISP2(max_size)) {
2012                         log2 = log2 - 1;
2013                 }
2014 
2015                 /* Make sure descriptor is at least the minimum size */
2016                 log2 = max(log2, TAVOR_QP_WQE_LOG_MINIMUM);
2017 
2018                 /* Calculate actual number of SGL (given WQE size) */
2019                 actual_sgl = ((1 << log2) - TAVOR_QP_WQE_MLX_RCV_HDRS) >> 4;
2020                 break;
2021 
2022         case TAVOR_QP_WQ_TYPE_SENDMLX_QP0:
2023                 /*
2024                  * Same as above (except for MLX transport WQEs).  For these
2025                  * WQEs we have to account for the space consumed by the
2026                  * "inline" packet headers.  (This is smaller than for QP1
2027                  * below because QP0 is not allowed to send packets with a GRH.
2028                  */
2029                 max_size = (TAVOR_QP_WQE_MLX_QP0_HDRS + (num_sgl << 4));
2030                 log2 = highbit(max_size);
2031                 if (ISP2(max_size)) {
2032                         log2 = log2 - 1;
2033                 }
2034 
2035                 /* Make sure descriptor is at least the minimum size */
2036                 log2 = max(log2, TAVOR_QP_WQE_LOG_MINIMUM);
2037 
2038                 /* Calculate actual number of SGL (given WQE size) */
2039                 actual_sgl = ((1 << log2) - TAVOR_QP_WQE_MLX_QP0_HDRS) >> 4;
2040                 break;
2041 
2042         case TAVOR_QP_WQ_TYPE_SENDMLX_QP1:
2043                 /*
2044                  * Same as above.  For these WQEs we again have to account for
2045                  * the space consumed by the "inline" packet headers.  (This
2046                  * is larger than for QP0 above because we have to account for
2047                  * the possibility of a GRH in each packet - and this
2048                  * introduces an alignment issue that causes us to consume
2049                  * an additional 8 bytes).
2050                  */
2051                 max_size = (TAVOR_QP_WQE_MLX_QP1_HDRS + (num_sgl << 4));
2052                 log2 = highbit(max_size);
2053                 if (ISP2(max_size)) {
2054                         log2 = log2 - 1;
2055                 }
2056 
2057                 /* Make sure descriptor is at least the minimum size */
2058                 log2 = max(log2, TAVOR_QP_WQE_LOG_MINIMUM);
2059 
2060                 /* Calculate actual number of SGL (given WQE size) */
2061                 actual_sgl = ((1 << log2) - TAVOR_QP_WQE_MLX_QP1_HDRS) >> 4;
2062                 break;
2063 
2064         default:
2065                 TAVOR_WARNING(state, "unexpected work queue type");
2066                 TNF_PROBE_0(tavor_qp_sgl_to_logwqesz_inv_wqtype_fail,
2067                     TAVOR_TNF_ERROR, "");
2068                 break;
2069         }
2070 
2071         /* Fill in the return values */
2072         *logwqesz = log2;
2073         *max_sgl  = min(state->ts_cfg_profile->cp_wqe_real_max_sgl, actual_sgl);