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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/ib/adapters/hermon/hermon_srq.c
          +++ new/usr/src/uts/common/io/ib/adapters/hermon/hermon_srq.c
↓ open down ↓ 23 lines elided ↑ open up ↑
  24   24   */
  25   25  
  26   26  /*
  27   27   * hermon_srq.c
  28   28   *    Hermon Shared Receive Queue Processing Routines
  29   29   *
  30   30   *    Implements all the routines necessary for allocating, freeing, querying,
  31   31   *    modifying and posting shared receive queues.
  32   32   */
  33   33  
       34 +#include <sys/sysmacros.h>
  34   35  #include <sys/types.h>
  35   36  #include <sys/conf.h>
  36   37  #include <sys/ddi.h>
  37   38  #include <sys/sunddi.h>
  38   39  #include <sys/modctl.h>
  39   40  #include <sys/bitmap.h>
  40   41  
  41   42  #include <sys/ib/adapters/hermon/hermon.h>
  42   43  
  43   44  static void hermon_srq_sgl_to_logwqesz(hermon_state_t *state, uint_t num_sgl,
↓ open down ↓ 123 lines elided ↑ open up ↑
 167  168          }
 168  169  
 169  170          /*
 170  171           * Calculate the appropriate size for the SRQ.
 171  172           * Note:  All Hermon SRQs must be a power-of-2 in size.  Also
 172  173           * they may not be any smaller than HERMON_SRQ_MIN_SIZE.  This step
 173  174           * is to round the requested size up to the next highest power-of-2
 174  175           */
 175  176          srq_wr_sz = max(sizes->srq_wr_sz + 1, HERMON_SRQ_MIN_SIZE);
 176  177          log_srq_size = highbit(srq_wr_sz);
 177      -        if ((srq_wr_sz & (srq_wr_sz - 1)) == 0) {
      178 +        if (ISP2(srq_wr_sz)) {
 178  179                  log_srq_size = log_srq_size - 1;
 179  180          }
 180  181  
 181  182          /*
 182  183           * Next we verify that the rounded-up size is valid (i.e. consistent
 183  184           * with the device limits and/or software-configured limits).  If not,
 184  185           * then obviously we have a lot of cleanup to do before returning.
 185  186           */
 186  187          if (log_srq_size > state->hs_cfg_profile->cp_log_max_srq_sz) {
 187  188                  status = IBT_HCA_WR_EXCEEDED;
↓ open down ↓ 428 lines elided ↑ open up ↑
 616  617          }
 617  618  
 618  619          /*
 619  620           * Calculate the appropriate size for the SRQ.
 620  621           * Note:  All Hermon SRQs must be a power-of-2 in size.  Also
 621  622           * they may not be any smaller than HERMON_SRQ_MIN_SIZE.  This step
 622  623           * is to round the requested size up to the next highest power-of-2
 623  624           */
 624  625          size = max(size, HERMON_SRQ_MIN_SIZE);
 625  626          log_srq_size = highbit(size);
 626      -        if ((size & (size - 1)) == 0) {
      627 +        if (ISP2(size)) {
 627  628                  log_srq_size = log_srq_size - 1;
 628  629          }
 629  630  
 630  631          /*
 631  632           * Next we verify that the rounded-up size is valid (i.e. consistent
 632  633           * with the device limits and/or software-configured limits).
 633  634           */
 634  635          if (log_srq_size > state->hs_cfg_profile->cp_log_max_srq_sz) {
 635  636                  status = IBT_HCA_WR_EXCEEDED;
 636  637                  goto srqmodify_fail;
↓ open down ↓ 330 lines elided ↑ open up ↑
 967  968  
 968  969          switch (wq_type) {
 969  970          case HERMON_QP_WQ_TYPE_RECVQ:
 970  971                  /*
 971  972                   * Use requested maximum SGL to calculate max descriptor size
 972  973                   * (while guaranteeing that the descriptor size is a
 973  974                   * power-of-2 cachelines).
 974  975                   */
 975  976                  max_size = (HERMON_QP_WQE_MLX_SRQ_HDRS + (num_sgl << 4));
 976  977                  log2 = highbit(max_size);
 977      -                if ((max_size & (max_size - 1)) == 0) {
      978 +                if (ISP2(max_size)) {
 978  979                          log2 = log2 - 1;
 979  980                  }
 980  981  
 981  982                  /* Make sure descriptor is at least the minimum size */
 982  983                  log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
 983  984  
 984  985                  /* Calculate actual number of SGL (given WQE size) */
 985  986                  actual_sgl = ((1 << log2) - HERMON_QP_WQE_MLX_SRQ_HDRS) >> 4;
 986  987                  break;
 987  988  
 988  989          default:
 989  990                  HERMON_WARNING(state, "unexpected work queue type");
 990  991                  break;
 991  992          }
 992  993  
 993  994          /* Fill in the return values */
 994  995          *logwqesz = log2;
 995  996          *max_sgl  = min(state->hs_cfg_profile->cp_srq_max_sgl, actual_sgl);
 996  997  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX