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_qp.c
          +++ new/usr/src/uts/common/io/ib/adapters/hermon/hermon_qp.c
↓ open down ↓ 396 lines elided ↑ open up ↑
 397  397          attr_p->qp_sizes.cs_sq = max(attr_p->qp_sizes.cs_sq,
 398  398              HERMON_QP_MIN_SIZE);
 399  399          attr_p->qp_sizes.cs_rq = max(attr_p->qp_sizes.cs_rq,
 400  400              HERMON_QP_MIN_SIZE);
 401  401          /*
 402  402           * now, calculate the alloc size, taking into account
 403  403           * the headroom for the sq
 404  404           */
 405  405          log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes);
 406  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)    {
      407 +        if (ISP2(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes))  {
 409  408                  log_qp_sq_size = log_qp_sq_size - 1;
 410  409          }
 411  410  
 412  411          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) {
      412 +        if (ISP2(attr_p->qp_sizes.cs_rq)) {
 414  413                  log_qp_rq_size = log_qp_rq_size - 1;
 415  414          }
 416  415  
 417  416          /*
 418  417           * Next we verify that the rounded-up size is valid (i.e. consistent
 419  418           * with the device limits and/or software-configured limits).  If not,
 420  419           * then obviously we have a lot of cleanup to do before returning.
 421  420           *
 422  421           * NOTE: the first condition deals with the (test) case of cs_sq
 423  422           * being just less than 2^32.  In this case, the headroom addition
↓ open down ↓ 490 lines elided ↑ open up ↑
 914  913           * Calculate the appropriate size for the work queues.
 915  914           * Note:  All Hermon QP work queues must be a power-of-2 in size.  Also
 916  915           * they may not be any smaller than HERMON_QP_MIN_SIZE.  This step is
 917  916           * to round the requested size up to the next highest power-of-2
 918  917           */
 919  918          attr_p->qp_sizes.cs_sq =
 920  919              max(attr_p->qp_sizes.cs_sq, HERMON_QP_MIN_SIZE);
 921  920          attr_p->qp_sizes.cs_rq =
 922  921              max(attr_p->qp_sizes.cs_rq, HERMON_QP_MIN_SIZE);
 923  922          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) {
      923 +        if (ISP2(attr_p->qp_sizes.cs_sq)) {
 925  924                  log_qp_sq_size = log_qp_sq_size - 1;
 926  925          }
 927  926          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) {
      927 +        if (ISP2(attr_p->qp_sizes.cs_rq)) {
 929  928                  log_qp_rq_size = log_qp_rq_size - 1;
 930  929          }
 931  930  
 932  931          /*
 933  932           * Next we verify that the rounded-up size is valid (i.e. consistent
 934  933           * with the device limits and/or software-configured limits).  If not,
 935  934           * then obviously we have a bit of cleanup to do before returning.
 936  935           */
 937  936          if ((log_qp_sq_size > state->hs_cfg_profile->cp_log_max_qp_sz) ||
 938  937              (log_qp_rq_size > state->hs_cfg_profile->cp_log_max_qp_sz)) {
↓ open down ↓ 575 lines elided ↑ open up ↑
1514 1513          attr_p->qp_sizes.cs_sq = max(attr_p->qp_sizes.cs_sq,
1515 1514              HERMON_QP_MIN_SIZE);
1516 1515          attr_p->qp_sizes.cs_rq = max(attr_p->qp_sizes.cs_rq,
1517 1516              HERMON_QP_MIN_SIZE);
1518 1517          /*
1519 1518           * now, calculate the alloc size, taking into account
1520 1519           * the headroom for the sq
1521 1520           */
1522 1521          log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes);
1523 1522          /* 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)    {
     1523 +        if (ISP2(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes))  {
1526 1524                  log_qp_sq_size = log_qp_sq_size - 1;
1527 1525          }
1528 1526  
1529 1527          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) {
     1528 +        if (ISP2(attr_p->qp_sizes.cs_rq)) {
1531 1529                  log_qp_rq_size = log_qp_rq_size - 1;
1532 1530          }
1533 1531  
1534 1532          /*
1535 1533           * Next we verify that the rounded-up size is valid (i.e. consistent
1536 1534           * with the device limits and/or software-configured limits).  If not,
1537 1535           * then obviously we have a lot of cleanup to do before returning.
1538 1536           *
1539 1537           * NOTE: the first condition deals with the (test) case of cs_sq
1540 1538           * being just less than 2^32.  In this case, the headroom addition
↓ open down ↓ 1283 lines elided ↑ open up ↑
2824 2822  
2825 2823          switch (wq_type) {
2826 2824          case HERMON_QP_WQ_TYPE_SENDQ_UD:
2827 2825                  /*
2828 2826                   * Use requested maximum SGL to calculate max descriptor size
2829 2827                   * (while guaranteeing that the descriptor size is a
2830 2828                   * power-of-2 cachelines).
2831 2829                   */
2832 2830                  max_size = (HERMON_QP_WQE_MLX_SND_HDRS + (num_sgl << 4));
2833 2831                  log2 = highbit(max_size);
2834      -                if ((max_size & (max_size - 1)) == 0) {
     2832 +                if (ISP2(max_size)) {
2835 2833                          log2 = log2 - 1;
2836 2834                  }
2837 2835  
2838 2836                  /* Make sure descriptor is at least the minimum size */
2839 2837                  log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2840 2838  
2841 2839                  /* Calculate actual number of SGL (given WQE size) */
2842 2840                  actual_sgl = ((1 << log2) -
2843 2841                      sizeof (hermon_hw_snd_wqe_ctrl_t)) >> 4;
2844 2842                  break;
2845 2843  
2846 2844          case HERMON_QP_WQ_TYPE_SENDQ_CONN:
2847 2845                  /*
2848 2846                   * Use requested maximum SGL to calculate max descriptor size
2849 2847                   * (while guaranteeing that the descriptor size is a
2850 2848                   * power-of-2 cachelines).
2851 2849                   */
2852 2850                  max_size = (HERMON_QP_WQE_MLX_SND_HDRS + (num_sgl << 4));
2853 2851                  log2 = highbit(max_size);
2854      -                if ((max_size & (max_size - 1)) == 0) {
     2852 +                if (ISP2(max_size)) {
2855 2853                          log2 = log2 - 1;
2856 2854                  }
2857 2855  
2858 2856                  /* Make sure descriptor is at least the minimum size */
2859 2857                  log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2860 2858  
2861 2859                  /* Calculate actual number of SGL (given WQE size) */
2862 2860                  actual_sgl = ((1 << log2) - HERMON_QP_WQE_MLX_SND_HDRS) >> 4;
2863 2861                  break;
2864 2862  
2865 2863          case HERMON_QP_WQ_TYPE_RECVQ:
2866 2864                  /*
2867 2865                   * Same as above (except for Recv WQEs)
2868 2866                   */
2869 2867                  max_size = (HERMON_QP_WQE_MLX_RCV_HDRS + (num_sgl << 4));
2870 2868                  log2 = highbit(max_size);
2871      -                if ((max_size & (max_size - 1)) == 0) {
     2869 +                if (ISP2(max_size)) {
2872 2870                          log2 = log2 - 1;
2873 2871                  }
2874 2872  
2875 2873                  /* Make sure descriptor is at least the minimum size */
2876 2874                  log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2877 2875  
2878 2876                  /* Calculate actual number of SGL (given WQE size) */
2879 2877                  actual_sgl = ((1 << log2) - HERMON_QP_WQE_MLX_RCV_HDRS) >> 4;
2880 2878                  break;
2881 2879  
2882 2880          case HERMON_QP_WQ_TYPE_SENDMLX_QP0:
2883 2881                  /*
2884 2882                   * Same as above (except for MLX transport WQEs).  For these
2885 2883                   * WQEs we have to account for the space consumed by the
2886 2884                   * "inline" packet headers.  (This is smaller than for QP1
2887 2885                   * below because QP0 is not allowed to send packets with a GRH.
2888 2886                   */
2889 2887                  max_size = (HERMON_QP_WQE_MLX_QP0_HDRS + (num_sgl << 4));
2890 2888                  log2 = highbit(max_size);
2891      -                if ((max_size & (max_size - 1)) == 0) {
     2889 +                if (ISP2(max_size)) {
2892 2890                          log2 = log2 - 1;
2893 2891                  }
2894 2892  
2895 2893                  /* Make sure descriptor is at least the minimum size */
2896 2894                  log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2897 2895  
2898 2896                  /* Calculate actual number of SGL (given WQE size) */
2899 2897                  actual_sgl = ((1 << log2) - HERMON_QP_WQE_MLX_QP0_HDRS) >> 4;
2900 2898                  break;
2901 2899  
↓ open down ↓ 1 lines elided ↑ open up ↑
2903 2901                  /*
2904 2902                   * Same as above.  For these WQEs we again have to account for
2905 2903                   * the space consumed by the "inline" packet headers.  (This
2906 2904                   * is larger than for QP0 above because we have to account for
2907 2905                   * the possibility of a GRH in each packet - and this
2908 2906                   * introduces an alignment issue that causes us to consume
2909 2907                   * an additional 8 bytes).
2910 2908                   */
2911 2909                  max_size = (HERMON_QP_WQE_MLX_QP1_HDRS + (num_sgl << 4));
2912 2910                  log2 = highbit(max_size);
2913      -                if ((max_size & (max_size - 1)) == 0) {
     2911 +                if (ISP2(max_size)) {
2914 2912                          log2 = log2 - 1;
2915 2913                  }
2916 2914  
2917 2915                  /* Make sure descriptor is at least the minimum size */
2918 2916                  log2 = max(log2, HERMON_QP_WQE_LOG_MINIMUM);
2919 2917  
2920 2918                  /* Calculate actual number of SGL (given WQE size) */
2921 2919                  actual_sgl = ((1 << log2) - HERMON_QP_WQE_MLX_QP1_HDRS) >> 4;
2922 2920                  break;
2923 2921  
2924 2922          default:
2925 2923                  HERMON_WARNING(state, "unexpected work queue type");
2926 2924                  break;
2927 2925          }
2928 2926  
2929 2927          /* Fill in the return values */
2930 2928          *logwqesz = log2;
2931 2929          *max_sgl  = min(real_max_sgl, actual_sgl);
2932 2930  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX