Print this page
patch fix

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c
          +++ new/usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c
↓ open down ↓ 28 lines elided ↑ open up ↑
  29   29   * IB nexus driver will only be the client for the IBDM module.
  30   30   *
  31   31   * IBDM registers with IBTF for HCA arrival/removal notification.
  32   32   * IBDM registers with SA access to send DM MADs to discover the IOC's behind
  33   33   * the IOU's.
  34   34   *
  35   35   * IB nexus driver registers with IBDM to find the information about the
  36   36   * HCA's and IOC's (behind the IOU) present on the IB fabric.
  37   37   */
  38   38  
       39 +#include <sys/sysmacros.h>
  39   40  #include <sys/systm.h>
  40   41  #include <sys/taskq.h>
  41   42  #include <sys/ib/mgt/ibdm/ibdm_impl.h>
  42   43  #include <sys/ib/mgt/ibmf/ibmf_impl.h>
  43   44  #include <sys/ib/ibtl/impl/ibtl_ibnex.h>
  44   45  #include <sys/modctl.h>
  45   46  
  46   47  /* Function Prototype declarations */
  47   48  static int      ibdm_free_iou_info(ibdm_dp_gidinfo_t *, ibdm_iou_info_t **);
  48   49  static int      ibdm_fini(void);
↓ open down ↓ 915 lines elided ↑ open up ↑
 964  965                  kmem_free(hca_attr, sizeof (ibt_hca_attr_t));
 965  966                  (void) ibt_close_hca(hca_hdl);
 966  967                  return;
 967  968          }
 968  969          hca_list = (ibdm_hca_list_t *)
 969  970              kmem_zalloc((sizeof (ibdm_hca_list_t)), KM_SLEEP);
 970  971          hca_list->hl_port_attr = (ibdm_port_attr_t *)kmem_zalloc(
 971  972              (sizeof (ibdm_port_attr_t) * hca_attr->hca_nports), KM_SLEEP);
 972  973          hca_list->hl_hca_guid = hca_attr->hca_node_guid;
 973  974          hca_list->hl_nports = hca_attr->hca_nports;
 974      -        hca_list->hl_attach_time = ddi_get_time();
      975 +        hca_list->hl_attach_time = gethrtime();
 975  976          hca_list->hl_hca_hdl = hca_hdl;
 976  977  
 977  978          /*
 978  979           * Init a dummy port attribute for the HCA node
 979  980           * This is for Per-HCA Node. Initialize port_attr :
 980  981           *      hca_guid & port_guid -> hca_guid
 981  982           *      npkeys, pkey_tbl is NULL
 982  983           *      port_num, sn_prefix is 0
 983  984           *      vendorid, product_id, dev_version from HCA
 984  985           *      pa_state is IBT_PORT_ACTIVE
↓ open down ↓ 3699 lines elided ↑ open up ↑
4684 4685          IBTF_DPRINTF_L4("ibdm", "\tibnex_unregister_callbacks");
4685 4686          mutex_enter(&ibdm.ibdm_ibnex_mutex);
4686 4687          ibdm.ibdm_ibnex_callback = NULL;
4687 4688          mutex_exit(&ibdm.ibdm_ibnex_mutex);
4688 4689  }
4689 4690  
4690 4691  /*
4691 4692   * ibdm_get_waittime()
4692 4693   *      Calculates the wait time based on the last HCA attach time
4693 4694   */
4694      -static time_t
4695      -ibdm_get_waittime(ib_guid_t hca_guid, int dft_wait)
     4695 +static clock_t
     4696 +ibdm_get_waittime(ib_guid_t hca_guid, time_t dft_wait_sec)
4696 4697  {
4697      -        int             ii;
4698      -        time_t          temp, wait_time = 0;
     4698 +        const hrtime_t  dft_wait = dft_wait_sec * NANOSEC;
     4699 +        hrtime_t        temp, wait_time = 0;
     4700 +        clock_t         usecs;
     4701 +        int             i;
4699 4702          ibdm_hca_list_t *hca;
4700 4703  
4701 4704          IBTF_DPRINTF_L4("ibdm", "\tget_waittime hcaguid:%llx"
4702 4705              "\tport settling time %d", hca_guid, dft_wait);
4703 4706  
4704 4707          ASSERT(mutex_owned(&ibdm.ibdm_hl_mutex));
4705 4708  
4706 4709          hca = ibdm.ibdm_hca_list_head;
4707 4710  
4708      -        if (hca_guid) {
4709      -                for (ii = 0; ii < ibdm.ibdm_hca_count; ii++) {
4710      -                        if ((hca_guid == hca->hl_hca_guid) &&
4711      -                            (hca->hl_nports != hca->hl_nports_active)) {
4712      -                                wait_time =
4713      -                                    ddi_get_time() - hca->hl_attach_time;
4714      -                                wait_time = ((wait_time >= dft_wait) ?
4715      -                                    0 : (dft_wait - wait_time));
4716      -                                break;
4717      -                        }
4718      -                        hca = hca->hl_next;
     4711 +        for (i = 0; i < ibdm.ibdm_hca_count; i++, hca = hca->hl_next) {
     4712 +                if (hca->hl_nports == hca->hl_nports_active)
     4713 +                        continue;
     4714 +
     4715 +                if (hca_guid && (hca_guid != hca->hl_hca_guid))
     4716 +                        continue;
     4717 +
     4718 +                temp = gethrtime() - hca->hl_attach_time;
     4719 +                temp = MAX(0, (dft_wait - temp));
     4720 +
     4721 +                if (hca_guid) {
     4722 +                        wait_time = temp;
     4723 +                        break;
4719 4724                  }
4720      -                IBTF_DPRINTF_L2("ibdm", "\tget_waittime: wait_time = %ld secs",
4721      -                    (long)wait_time);
4722      -                return (wait_time);
     4725 +
     4726 +                wait_time = MAX(temp, wait_time);
4723 4727          }
4724 4728  
4725      -        for (ii = 0; ii < ibdm.ibdm_hca_count; ii++) {
4726      -                if (hca->hl_nports != hca->hl_nports_active) {
4727      -                        temp = ddi_get_time() - hca->hl_attach_time;
4728      -                        temp = ((temp >= dft_wait) ? 0 : (dft_wait - temp));
4729      -                        wait_time = (temp > wait_time) ? temp : wait_time;
4730      -                }
4731      -                hca = hca->hl_next;
4732      -        }
4733      -        IBTF_DPRINTF_L2("ibdm", "\tget_waittime: wait_time = %ld secs",
4734      -            (long)wait_time);
4735      -        return (wait_time);
     4729 +        /* convert to microseconds */
     4730 +        usecs = MIN(wait_time, dft_wait) / (NANOSEC / MICROSEC);
     4731 +
     4732 +        IBTF_DPRINTF_L2("ibdm", "\tget_waittime: wait_time = %ld usecs",
     4733 +            (long) usecs);
     4734 +
     4735 +        return (drv_usectohz(usecs));
4736 4736  }
4737 4737  
4738 4738  void
4739      -ibdm_ibnex_port_settle_wait(ib_guid_t hca_guid, int dft_wait)
     4739 +ibdm_ibnex_port_settle_wait(ib_guid_t hca_guid, time_t dft_wait)
4740 4740  {
4741      -        time_t wait_time;
4742      -        clock_t delta;
     4741 +        clock_t wait_time;
4743 4742  
4744 4743          mutex_enter(&ibdm.ibdm_hl_mutex);
4745 4744  
4746      -        while ((wait_time = ibdm_get_waittime(hca_guid, dft_wait)) > 0) {
4747      -                if (wait_time > dft_wait) {
4748      -                        IBTF_DPRINTF_L1("ibdm",
4749      -                            "\tibnex_port_settle_wait: wait_time = %ld secs; "
4750      -                            "Resetting to %d secs",
4751      -                            (long)wait_time, dft_wait);
4752      -                        wait_time = dft_wait;
4753      -                }
4754      -                delta = drv_usectohz(wait_time * 1000000);
     4745 +        while ((wait_time = ibdm_get_waittime(hca_guid, dft_wait)) > 0)
4755 4746                  (void) cv_reltimedwait(&ibdm.ibdm_port_settle_cv,
4756      -                    &ibdm.ibdm_hl_mutex, delta, TR_CLOCK_TICK);
4757      -        }
     4747 +                    &ibdm.ibdm_hl_mutex, wait_time, TR_CLOCK_TICK);
4758 4748  
4759 4749          mutex_exit(&ibdm.ibdm_hl_mutex);
4760 4750  }
4761 4751  
4762 4752  
4763 4753  /*
4764 4754   * ibdm_ibnex_probe_hcaport
4765 4755   *      Probes the presence of HCA port (with HCA dip and port number)
4766 4756   *      Returns port attributes structure on SUCCESS
4767 4757   */
↓ open down ↓ 2540 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX