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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/ib/adapters/tavor/tavor_srq.c
          +++ new/usr/src/uts/common/io/ib/adapters/tavor/tavor_srq.c
↓ open down ↓ 24 lines elided ↑ open up ↑
  25   25   */
  26   26  
  27   27  /*
  28   28   * tavor_srq.c
  29   29   *    Tavor Shared Receive Queue Processing Routines
  30   30   *
  31   31   *    Implements all the routines necessary for allocating, freeing, querying,
  32   32   *    modifying and posting shared receive queues.
  33   33   */
  34   34  
       35 +#include <sys/sysmacros.h>
  35   36  #include <sys/types.h>
  36   37  #include <sys/conf.h>
  37   38  #include <sys/ddi.h>
  38   39  #include <sys/sunddi.h>
  39   40  #include <sys/modctl.h>
  40   41  #include <sys/bitmap.h>
  41   42  
  42   43  #include <sys/ib/adapters/tavor/tavor.h>
  43   44  
  44   45  static void tavor_srq_sgl_to_logwqesz(tavor_state_t *state, uint_t num_sgl,
↓ open down ↓ 120 lines elided ↑ open up ↑
 165  166          }
 166  167  
 167  168          /*
 168  169           * Calculate the appropriate size for the SRQ.
 169  170           * Note:  All Tavor SRQs must be a power-of-2 in size.  Also
 170  171           * they may not be any smaller than TAVOR_SRQ_MIN_SIZE.  This step
 171  172           * is to round the requested size up to the next highest power-of-2
 172  173           */
 173  174          sizes->srq_wr_sz = max(sizes->srq_wr_sz, TAVOR_SRQ_MIN_SIZE);
 174  175          log_srq_size = highbit(sizes->srq_wr_sz);
 175      -        if ((sizes->srq_wr_sz & (sizes->srq_wr_sz - 1)) == 0) {
      176 +        if (ISP2(sizes->srq_wr_sz)) {
 176  177                  log_srq_size = log_srq_size - 1;
 177  178          }
 178  179  
 179  180          /*
 180  181           * Next we verify that the rounded-up size is valid (i.e. consistent
 181  182           * with the device limits and/or software-configured limits).  If not,
 182  183           * then obviously we have a lot of cleanup to do before returning.
 183  184           */
 184  185          if (log_srq_size > state->ts_cfg_profile->cp_log_max_srq_sz) {
 185  186                  /* Set "status" and "errormsg" and goto failure */
↓ open down ↓ 493 lines elided ↑ open up ↑
 679  680          }
 680  681  
 681  682          /*
 682  683           * Calculate the appropriate size for the SRQ.
 683  684           * Note:  All Tavor SRQs must be a power-of-2 in size.  Also
 684  685           * they may not be any smaller than TAVOR_SRQ_MIN_SIZE.  This step
 685  686           * is to round the requested size up to the next highest power-of-2
 686  687           */
 687  688          size = max(size, TAVOR_SRQ_MIN_SIZE);
 688  689          log_srq_size = highbit(size);
 689      -        if ((size & (size - 1)) == 0) {
      690 +        if (ISP2(size)) {
 690  691                  log_srq_size = log_srq_size - 1;
 691  692          }
 692  693  
 693  694          /*
 694  695           * Next we verify that the rounded-up size is valid (i.e. consistent
 695  696           * with the device limits and/or software-configured limits).
 696  697           */
 697  698          if (log_srq_size > state->ts_cfg_profile->cp_log_max_srq_sz) {
 698  699                  /* Set "status" and "errormsg" and goto failure */
 699  700                  TAVOR_TNF_FAIL(IBT_HCA_WR_EXCEEDED, "max SRQ size");
↓ open down ↓ 392 lines elided ↑ open up ↑
1092 1093  
1093 1094          switch (wq_type) {
1094 1095          case TAVOR_QP_WQ_TYPE_RECVQ:
1095 1096                  /*
1096 1097                   * Use requested maximum SGL to calculate max descriptor size
1097 1098                   * (while guaranteeing that the descriptor size is a
1098 1099                   * power-of-2 cachelines).
1099 1100                   */
1100 1101                  max_size = (TAVOR_QP_WQE_MLX_RCV_HDRS + (num_sgl << 4));
1101 1102                  log2 = highbit(max_size);
1102      -                if ((max_size & (max_size - 1)) == 0) {
     1103 +                if (ISP2(max_size)) {
1103 1104                          log2 = log2 - 1;
1104 1105                  }
1105 1106  
1106 1107                  /* Make sure descriptor is at least the minimum size */
1107 1108                  log2 = max(log2, TAVOR_QP_WQE_LOG_MINIMUM);
1108 1109  
1109 1110                  /* Calculate actual number of SGL (given WQE size) */
1110 1111                  actual_sgl = ((1 << log2) - TAVOR_QP_WQE_MLX_RCV_HDRS) >> 4;
1111 1112                  break;
1112 1113  
↓ open down ↓ 13 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX