Print this page
8368 remove warlock leftovers from usr/src/uts

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/ib/clients/daplt/daplt.c
          +++ new/usr/src/uts/common/io/ib/clients/daplt/daplt.c
↓ open down ↓ 61 lines elided ↑ open up ↑
  62   62   */
  63   63  #ifdef  DEBUG
  64   64  static char daplka_dbgbuf[0x80000];
  65   65  #else /* DEBUG */
  66   66  static char daplka_dbgbuf[0x4000];
  67   67  #endif /* DEBUG */
  68   68  static int daplka_dbgsize = sizeof (daplka_dbgbuf);
  69   69  static size_t daplka_dbgnext;
  70   70  static int daplka_dbginit = 0;
  71   71  static kmutex_t daplka_dbglock;
  72      -_NOTE(MUTEX_PROTECTS_DATA(daplka_dbglock,
  73      -    daplka_dbgbuf
  74      -    daplka_dbgnext))
  75   72  
  76   73  static int daplka_dbg = 0x0103;
  77   74  static void daplka_console(const char *, ...);
  78   75  static void daplka_debug(const char *, ...);
  79   76  static int daplka_apm = 0x1;                    /* default enable */
  80   77  static int daplka_failback = 0x1;               /* default enable */
  81   78  static int daplka_query_aft_setaltpath = 10;
  82   79  
  83   80  #define DERR                            \
  84   81          if (daplka_dbg & 0x100)         \
↓ open down ↓ 467 lines elided ↑ open up ↑
 552  549   */
 553  550  static daplka_hash_table_t daplka_timer_info_htbl;
 554  551  static uint32_t daplka_timer_hkey = 0;
 555  552  
 556  553  /*
 557  554   * shared MR avl tree
 558  555   */
 559  556  static avl_tree_t daplka_shared_mr_tree;
 560  557  static kmutex_t daplka_shared_mr_lock;
 561  558  static int daplka_shared_mr_cmp(const void *, const void *);
 562      -_NOTE(MUTEX_PROTECTS_DATA(daplka_shared_mr_lock,
 563      -    daplka_shared_mr_tree))
 564  559  
 565  560  /*
 566  561   * default kmem flags used by this driver
 567  562   */
 568  563  static int daplka_km_flags = KM_SLEEP;
 569  564  
 570  565  /*
 571  566   * taskq used for handling background tasks
 572  567   */
 573  568  static taskq_t *daplka_taskq = NULL;
↓ open down ↓ 1631 lines elided ↑ open up ↑
2205 2200          priv_data = (void *)args.epc_priv;
2206 2201  
2207 2202          chan_args.oc_priv_data_len = args.epc_priv_sz;
2208 2203          chan_args.oc_priv_data = priv_data;
2209 2204  
2210 2205          /*
2211 2206           * calculate checksum value of hello message and
2212 2207           * put hello message in networking byte order
2213 2208           */
2214 2209          dp = (DAPL_PRIVATE *)priv_data;
2215      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*dp))
2216 2210          dp->hello_msg.hi_port = htons(dp->hello_msg.hi_port);
2217 2211          dp->hello_msg.hi_checksum = 0;
2218 2212          dp->hello_msg.hi_checksum = htons(daplka_hellomsg_cksum(dp));
2219      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*dp))
2220 2213  
2221 2214          if (args.epc_timeout > 0) {
2222 2215                  /*
2223 2216                   * increment refcnt before passing reference to
2224 2217                   * timer_info_alloc.
2225 2218                   */
2226 2219                  DAPLKA_RS_REF(ep_rp);
2227 2220                  timerp = daplka_timer_info_alloc(ep_rp);
2228 2221                  if (timerp == NULL) {
2229 2222                          DERR("ep_connect: cannot allocate timer\n");
↓ open down ↓ 369 lines elided ↑ open up ↑
2599 2592                  DERR("evd_create: copyin error %d", retval);
2600 2593                  return (EFAULT);
2601 2594          }
2602 2595          if ((args.evd_flags &
2603 2596              ~(DAT_EVD_DEFAULT_FLAG | DAT_EVD_SOFTWARE_FLAG)) != 0) {
2604 2597                  DERR("evd_create: invalid flags 0x%x\n", args.evd_flags);
2605 2598                  return (EINVAL);
2606 2599          }
2607 2600  
2608 2601          evd_rp = kmem_zalloc(sizeof (daplka_evd_resource_t), daplka_km_flags);
2609      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*evd_rp))
2610 2602          DAPLKA_RS_INIT(evd_rp, DAPL_TYPE_EVD,
2611 2603              DAPLKA_RS_RNUM(ia_rp), daplka_evd_destroy);
2612 2604  
2613 2605          mutex_init(&evd_rp->evd_lock, NULL, MUTEX_DRIVER, NULL);
2614 2606          cv_init(&evd_rp->evd_cv, NULL, CV_DRIVER, NULL);
2615 2607          evd_rp->evd_hca = ia_rp->ia_hca;
2616 2608          evd_rp->evd_flags = args.evd_flags;
2617 2609          evd_rp->evd_hca_hdl = ia_rp->ia_hca_hdl;
2618 2610          evd_rp->evd_cookie = args.evd_cookie;
2619 2611          evd_rp->evd_cno_res = NULL;
↓ open down ↓ 67 lines elided ↑ open up ↑
2687 2679                      (void *)evd_rp);
2688 2680          }
2689 2681  
2690 2682          retval = daplka_hash_insert(&ia_rp->ia_evd_htbl,
2691 2683              &evd_hkey, (void *)evd_rp);
2692 2684          if (retval != 0) {
2693 2685                  DERR("evd_ceate: cannot insert evd %d\n", retval);
2694 2686                  goto cleanup;
2695 2687          }
2696 2688          inserted = B_TRUE;
2697      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*evd_rp))
2698 2689  
2699 2690          /*
2700 2691           * If this evd handles async events need to add to the IA resource
2701 2692           * async evd list
2702 2693           */
2703 2694          if (evd_rp->evd_flags & DAT_EVD_ASYNC_FLAG) {
2704 2695                  async_evd = kmem_zalloc(sizeof (daplka_async_evd_hkey_t),
2705 2696                      daplka_km_flags);
2706 2697                  /* add the evd to the head of the list */
2707 2698                  mutex_enter(&ia_rp->ia_lock);
↓ open down ↓ 773 lines elided ↑ open up ↑
3481 3472   * called when refcnt drops to zero.
3482 3473   */
3483 3474  static int
3484 3475  daplka_evd_destroy(daplka_resource_t *gen_rp)
3485 3476  {
3486 3477          daplka_evd_resource_t   *evd_rp = (daplka_evd_resource_t *)gen_rp;
3487 3478          ibt_status_t            status;
3488 3479          daplka_evd_event_t      *evt;
3489 3480          ibt_priv_data_len_t     len;
3490 3481  
3491      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*evd_rp))
3492 3482          D3("evd_destroy: entering, evd_rp 0x%p, rnum %d\n",
3493 3483              evd_rp, DAPLKA_RS_RNUM(evd_rp));
3494 3484          /*
3495 3485           * free CQ
3496 3486           */
3497 3487          if (evd_rp->evd_cq_hdl) {
3498 3488                  ibt_set_cq_handler(evd_rp->evd_cq_hdl, NULL, NULL);
3499 3489                  mutex_enter(&daplka_dev->daplka_mutex);
3500 3490                  ibt_set_cq_private(evd_rp->evd_cq_hdl, NULL);
3501 3491                  mutex_exit(&daplka_dev->daplka_mutex);
↓ open down ↓ 204 lines elided ↑ open up ↑
3706 3696          daplka_cno_resource_t   *cno_rp = NULL;
3707 3697          uint64_t                cno_hkey = 0;
3708 3698          boolean_t               inserted = B_FALSE;
3709 3699          int                     retval = 0;
3710 3700  
3711 3701          cno_rp = kmem_zalloc(sizeof (*cno_rp), daplka_km_flags);
3712 3702          if (cno_rp == NULL) {
3713 3703                  DERR("cno_alloc: cannot allocate cno resource\n");
3714 3704                  return (ENOMEM);
3715 3705          }
3716      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*cno_rp))
3717 3706          DAPLKA_RS_INIT(cno_rp, DAPL_TYPE_CNO,
3718 3707              DAPLKA_RS_RNUM(ia_rp), daplka_cno_destroy);
3719 3708  
3720 3709          mutex_init(&cno_rp->cno_lock, NULL, MUTEX_DRIVER, NULL);
3721 3710          cv_init(&cno_rp->cno_cv, NULL, CV_DRIVER, NULL);
3722 3711          cno_rp->cno_evd_cookie = 0;
3723 3712  
3724 3713          /* insert into cno hash table */
3725 3714          retval = daplka_hash_insert(&ia_rp->ia_cno_htbl,
3726 3715              &cno_hkey, (void *)cno_rp);
3727 3716          if (retval != 0) {
3728 3717                  DERR("cno_alloc: cannot insert cno resource\n");
3729 3718                  goto cleanup;
3730 3719          }
3731 3720          inserted = B_TRUE;
3732      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*cno_rp))
3733 3721  
3734 3722          /* return hkey to library */
3735 3723          args.cno_hkey = cno_hkey;
3736 3724  
3737 3725          retval = ddi_copyout(&args, (void *)arg, sizeof (dapl_cno_alloc_t),
3738 3726              mode);
3739 3727          if (retval != 0) {
3740 3728                  DERR("cno_alloc: copyout error %d\n", retval);
3741 3729                  retval = EFAULT;
3742 3730                  goto cleanup;
↓ open down ↓ 448 lines elided ↑ open up ↑
4191 4179  }
4192 4180  
4193 4181  
4194 4182  /*
4195 4183   * daplka_sp_match is used by daplka_hash_walk for finding SPs
4196 4184   */
4197 4185  typedef struct daplka_sp_match_s {
4198 4186          uint64_t                spm_conn_qual;
4199 4187          daplka_sp_resource_t    *spm_sp_rp;
4200 4188  } daplka_sp_match_t;
4201      -_NOTE(SCHEME_PROTECTS_DATA("daplka", daplka_sp_match_s::spm_sp_rp))
4202 4189  
4203 4190  static int
4204 4191  daplka_sp_match(void *objp, void *arg)
4205 4192  {
4206 4193          daplka_sp_resource_t    *sp_rp = (daplka_sp_resource_t *)objp;
4207 4194  
4208 4195          ASSERT(DAPLKA_RS_TYPE(sp_rp) == DAPL_TYPE_SP);
4209 4196          if (sp_rp->sp_conn_qual ==
4210 4197              ((daplka_sp_match_t *)arg)->spm_conn_qual) {
4211 4198                  ((daplka_sp_match_t *)arg)->spm_sp_rp = sp_rp;
↓ open down ↓ 372 lines elided ↑ open up ↑
4584 4571              mode);
4585 4572          if (retval != 0) {
4586 4573                  DERR("mr_register: copyin error %d\n", retval);
4587 4574                  return (EINVAL);
4588 4575          }
4589 4576          mr_rp = kmem_zalloc(sizeof (daplka_mr_resource_t), daplka_km_flags);
4590 4577          if (mr_rp == NULL) {
4591 4578                  DERR("mr_register: cannot allocate mr resource\n");
4592 4579                  return (ENOMEM);
4593 4580          }
4594      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr_rp))
4595 4581          DAPLKA_RS_INIT(mr_rp, DAPL_TYPE_MR,
4596 4582              DAPLKA_RS_RNUM(ia_rp), daplka_mr_destroy);
4597 4583  
4598 4584          mutex_init(&mr_rp->mr_lock, NULL, MUTEX_DRIVER, NULL);
4599 4585          mr_rp->mr_hca = ia_rp->ia_hca;
4600 4586          mr_rp->mr_hca_hdl = ia_rp->ia_hca_hdl;
4601 4587          mr_rp->mr_next = NULL;
4602 4588          mr_rp->mr_shared_mr = NULL;
4603 4589  
4604 4590          /* get pd handle */
↓ open down ↓ 47 lines elided ↑ open up ↑
4652 4638          }
4653 4639  
4654 4640          /* insert into mr hash table */
4655 4641          retval = daplka_hash_insert(&ia_rp->ia_mr_htbl,
4656 4642              &mr_hkey, (void *)mr_rp);
4657 4643          if (retval != 0) {
4658 4644                  DERR("mr_register: cannot insert mr resource into mr_htbl\n");
4659 4645                  goto cleanup;
4660 4646          }
4661 4647          inserted = B_TRUE;
4662      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*mr_rp))
4663 4648  
4664 4649          args.mr_lkey = mr_rp->mr_desc.md_lkey;
4665 4650          args.mr_rkey = mr_rp->mr_desc.md_rkey;
4666 4651          args.mr_hkey = mr_hkey;
4667 4652  
4668 4653          retval = ddi_copyout((void *)&args, (void *)arg,
4669 4654              sizeof (dapl_mr_register_t), mode);
4670 4655          if (retval != 0) {
4671 4656                  DERR("mr_register: copyout error %d\n", retval);
4672 4657                  retval = EFAULT;
↓ open down ↓ 113 lines elided ↑ open up ↑
4786 4771                   * if we cannot find smrp, we need to create and
4787 4772                   * insert one into daplka_shared_mr_tree
4788 4773                   */
4789 4774                  smrp = kmem_zalloc(sizeof (daplka_shared_mr_t),
4790 4775                      daplka_km_flags);
4791 4776                  if (smrp == NULL) {
4792 4777                          retval = ENOMEM;
4793 4778                          mutex_exit(&daplka_shared_mr_lock);
4794 4779                          goto cleanup;
4795 4780                  }
4796      -                _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*smrp))
4797 4781                  smrp->smr_refcnt = 1;
4798 4782                  smrp->smr_cookie = args.mrs_shm_cookie;
4799 4783                  smrp->smr_state = DAPLKA_SMR_TRANSITIONING;
4800 4784                  smrp->smr_mr_list = NULL;
4801 4785                  cv_init(&smrp->smr_cv, NULL, CV_DRIVER, NULL);
4802 4786                  avl_insert(&daplka_shared_mr_tree, smrp, where);
4803      -                _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*smrp))
4804 4787          }
4805 4788          mutex_exit(&daplka_shared_mr_lock);
4806 4789  
4807 4790          mr_rp = kmem_zalloc(sizeof (daplka_mr_resource_t), daplka_km_flags);
4808 4791          if (mr_rp == NULL) {
4809 4792                  DERR("mr_register_shared: cannot allocate mr resource\n");
4810 4793                  goto cleanup;
4811 4794          }
4812      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr_rp))
4813 4795          DAPLKA_RS_INIT(mr_rp, DAPL_TYPE_MR,
4814 4796              DAPLKA_RS_RNUM(ia_rp), daplka_mr_destroy);
4815 4797  
4816 4798          mutex_init(&mr_rp->mr_lock, NULL, MUTEX_DRIVER, NULL);
4817 4799          mr_rp->mr_hca = ia_rp->ia_hca;
4818 4800          mr_rp->mr_hca_hdl = ia_rp->ia_hca_hdl;
4819 4801          mr_rp->mr_next = NULL;
4820 4802          mr_rp->mr_shared_mr = NULL;
4821 4803  
4822 4804          /* get pd handle */
↓ open down ↓ 93 lines elided ↑ open up ↑
4916 4898          mr_rp->mr_shared_mr = smrp;
4917 4899  
4918 4900          /* insert into mr hash table */
4919 4901          retval = daplka_hash_insert(&ia_rp->ia_mr_htbl,
4920 4902              &mr_hkey, (void *)mr_rp);
4921 4903          if (retval != 0) {
4922 4904                  DERR("mr_register_shared: cannot insert mr resource\n");
4923 4905                  goto cleanup;
4924 4906          }
4925 4907          inserted = B_TRUE;
4926      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*mr_rp))
4927 4908  
4928 4909          /*
4929 4910           * at this point, there are two references to our mr resource.
4930 4911           * one is kept in ia_mr_htbl. the other is kept in the list
4931 4912           * within this shared mr object (smrp). when we deregister this
4932 4913           * mr or when a callback invalidates this mr, the reference kept
4933 4914           * by this shared mr object will be removed.
4934 4915           */
4935 4916  
4936 4917          args.mrs_lkey = mr_rp->mr_desc.md_lkey;
↓ open down ↓ 34 lines elided ↑ open up ↑
4971 4952                  }
4972 4953          }
4973 4954          if (smrp != NULL) {
4974 4955                  mutex_enter(&daplka_shared_mr_lock);
4975 4956                  ASSERT(smrp->smr_refcnt > 0);
4976 4957                  smrp->smr_refcnt--;
4977 4958  
4978 4959                  if (smrp->smr_refcnt == 0) {
4979 4960                          DERR("mr_register_shared: freeing smrp 0x%p\n", smrp);
4980 4961                          avl_remove(&daplka_shared_mr_tree, smrp);
4981      -                        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*smrp))
4982 4962                          if (smrp->smr_mr_list != NULL) {
4983 4963                                  /*
4984 4964                                   * the refcnt is 0. if there is anything
4985 4965                                   * left on the list, it must be ours.
4986 4966                                   */
4987      -                                _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr_rp))
4988 4967                                  ASSERT(smrp->smr_mr_list == mr_rp);
4989 4968                                  DAPLKA_RS_UNREF(mr_rp);
4990 4969                                  smrp->smr_mr_list = NULL;
4991 4970                                  ASSERT(mr_rp->mr_shared_mr == smrp);
4992 4971                                  mr_rp->mr_shared_mr = NULL;
4993 4972                                  ASSERT(mr_rp->mr_next == NULL);
4994 4973                          }
4995 4974                          smrp->smr_state = DAPLKA_SMR_FREED;
4996 4975                          cv_destroy(&smrp->smr_cv);
4997 4976                          kmem_free(smrp, sizeof (daplka_shared_mr_t));
↓ open down ↓ 1 lines elided ↑ open up ↑
4999 4978                          DERR("mr_register_shared: resetting smr_state "
5000 4979                              "smrp 0x%p, %d waiters remain\n", smrp,
5001 4980                              smrp->smr_refcnt);
5002 4981                          ASSERT(smrp->smr_state == DAPLKA_SMR_TRANSITIONING);
5003 4982                          if (smrp->smr_mr_list != NULL && mr_rp != NULL) {
5004 4983                                  daplka_mr_resource_t    **mpp;
5005 4984  
5006 4985                                  /*
5007 4986                                   * search and remove mr_rp from smr_mr_list
5008 4987                                   */
5009      -                                _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr_rp))
5010 4988                                  mpp = &smrp->smr_mr_list;
5011 4989                                  while (*mpp != NULL) {
5012 4990                                          if (*mpp == mr_rp) {
5013 4991                                                  *mpp = (*mpp)->mr_next;
5014 4992                                                  DAPLKA_RS_UNREF(mr_rp);
5015 4993                                                  ASSERT(mr_rp->mr_shared_mr ==
5016 4994                                                      smrp);
5017 4995                                                  mr_rp->mr_shared_mr = NULL;
5018 4996                                                  mr_rp->mr_next = NULL;
5019 4997                                                  break;
↓ open down ↓ 51 lines elided ↑ open up ↑
5071 5049                  return (EINVAL);
5072 5050          }
5073 5051          ASSERT(DAPLKA_RS_TYPE(orig_mr_rp) == DAPL_TYPE_MR);
5074 5052  
5075 5053          mr_rp = kmem_zalloc(sizeof (daplka_mr_resource_t), daplka_km_flags);
5076 5054          if (mr_rp == NULL) {
5077 5055                  DERR("mr_register_lmr: cannot allocate mr resource\n");
5078 5056                  retval = ENOMEM;
5079 5057                  goto cleanup;
5080 5058          }
5081      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr_rp))
5082 5059          DAPLKA_RS_INIT(mr_rp, DAPL_TYPE_MR,
5083 5060              DAPLKA_RS_RNUM(ia_rp), daplka_mr_destroy);
5084 5061  
5085 5062          mutex_init(&mr_rp->mr_lock, NULL, MUTEX_DRIVER, NULL);
5086 5063          mr_rp->mr_hca = ia_rp->ia_hca;
5087 5064          mr_rp->mr_hca_hdl = ia_rp->ia_hca_hdl;
5088 5065          mr_rp->mr_next = NULL;
5089 5066          mr_rp->mr_shared_mr = NULL;
5090 5067  
5091 5068          DAPLKA_RS_REF(orig_mr_rp->mr_pd_res);
↓ open down ↓ 37 lines elided ↑ open up ↑
5129 5106          mr_rp->mr_attr.mr_flags = mem_sattr.mr_flags;
5130 5107  
5131 5108          /* insert into mr hash table */
5132 5109          retval = daplka_hash_insert(&ia_rp->ia_mr_htbl, &mr_hkey,
5133 5110              (void *)mr_rp);
5134 5111          if (retval != 0) {
5135 5112                  DERR("mr_register: cannot insert mr resource into mr_htbl\n");
5136 5113                  goto cleanup;
5137 5114          }
5138 5115          inserted = B_TRUE;
5139      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*mr_rp))
5140 5116  
5141 5117          args.mrl_lkey = mr_rp->mr_desc.md_lkey;
5142 5118          args.mrl_rkey = mr_rp->mr_desc.md_rkey;
5143 5119          args.mrl_hkey = mr_hkey;
5144 5120  
5145 5121          retval = ddi_copyout((void *)&args, (void *)arg,
5146 5122              sizeof (dapl_mr_register_lmr_t), mode);
5147 5123          if (retval != 0) {
5148 5124                  DERR("mr_register_lmr: copyout error %d\n", retval);
5149 5125                  retval = EFAULT;
↓ open down ↓ 210 lines elided ↑ open up ↑
5360 5336  /*
5361 5337   * destroys a memory region.
5362 5338   * called when refcnt drops to zero.
5363 5339   */
5364 5340  static int
5365 5341  daplka_mr_destroy(daplka_resource_t *gen_rp)
5366 5342  {
5367 5343          daplka_mr_resource_t    *mr_rp = (daplka_mr_resource_t *)gen_rp;
5368 5344          ibt_status_t            status;
5369 5345  
5370      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr_rp))
5371 5346          ASSERT(DAPLKA_RS_REFCNT(mr_rp) == 0);
5372 5347          ASSERT(mr_rp->mr_shared_mr == NULL);
5373 5348          D3("mr_destroy: entering, mr_rp 0x%p, rnum %d\n",
5374 5349              mr_rp, DAPLKA_RS_RNUM(mr_rp));
5375 5350  
5376 5351          /*
5377 5352           * deregister mr
5378 5353           */
5379 5354          if (mr_rp->mr_hdl) {
5380 5355                  status = daplka_ibt_deregister_mr(mr_rp, mr_rp->mr_hca_hdl,
↓ open down ↓ 71 lines elided ↑ open up ↑
5452 5427          ibt_status_t            status;
5453 5428          uint64_t                pd_hkey = 0;
5454 5429          boolean_t               inserted = B_FALSE;
5455 5430          int                     retval;
5456 5431  
5457 5432          pd_rp = kmem_zalloc(sizeof (*pd_rp), daplka_km_flags);
5458 5433          if (pd_rp == NULL) {
5459 5434                  DERR("pd_alloc: cannot allocate pd resource\n");
5460 5435                  return (ENOMEM);
5461 5436          }
5462      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*pd_rp))
5463 5437          DAPLKA_RS_INIT(pd_rp, DAPL_TYPE_PD,
5464 5438              DAPLKA_RS_RNUM(ia_rp), daplka_pd_destroy);
5465 5439  
5466 5440          pd_rp->pd_hca = ia_rp->ia_hca;
5467 5441          pd_rp->pd_hca_hdl = ia_rp->ia_hca_hdl;
5468 5442          status = daplka_ibt_alloc_pd(pd_rp, pd_rp->pd_hca_hdl,
5469 5443              IBT_PD_NO_FLAGS, &pd_rp->pd_hdl);
5470 5444          if (status != IBT_SUCCESS) {
5471 5445                  DERR("pd_alloc: ibt_alloc_pd returned %d\n", status);
5472 5446                  *rvalp = (int)status;
↓ open down ↓ 2 lines elided ↑ open up ↑
5475 5449          }
5476 5450  
5477 5451          /* insert into pd hash table */
5478 5452          retval = daplka_hash_insert(&ia_rp->ia_pd_htbl,
5479 5453              &pd_hkey, (void *)pd_rp);
5480 5454          if (retval != 0) {
5481 5455                  DERR("pd_alloc: cannot insert pd resource into pd_htbl\n");
5482 5456                  goto cleanup;
5483 5457          }
5484 5458          inserted = B_TRUE;
5485      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*pd_rp))
5486 5459  
5487 5460          /* return hkey to library */
5488 5461          args.pda_hkey = pd_hkey;
5489 5462  
5490 5463          retval = ddi_copyout(&args, (void *)arg, sizeof (dapl_pd_alloc_t),
5491 5464              mode);
5492 5465          if (retval != 0) {
5493 5466                  DERR("pd_alloc: copyout error %d\n", retval);
5494 5467                  retval = EFAULT;
5495 5468                  goto cleanup;
↓ open down ↓ 22 lines elided ↑ open up ↑
5518 5491  /*
5519 5492   * destroys a protection domain.
5520 5493   * called when refcnt drops to zero.
5521 5494   */
5522 5495  static int
5523 5496  daplka_pd_destroy(daplka_resource_t *gen_rp)
5524 5497  {
5525 5498          daplka_pd_resource_t *pd_rp = (daplka_pd_resource_t *)gen_rp;
5526 5499          ibt_status_t status;
5527 5500  
5528      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*pd_rp))
5529 5501          ASSERT(DAPLKA_RS_REFCNT(pd_rp) == 0);
5530 5502          D3("pd_destroy: entering, pd_rp %p, rnum %d\n",
5531 5503              pd_rp, DAPLKA_RS_RNUM(pd_rp));
5532 5504  
5533 5505          ASSERT(DAPLKA_RS_TYPE(pd_rp) == DAPL_TYPE_PD);
5534 5506          if (pd_rp->pd_hdl != NULL) {
5535 5507                  status = daplka_ibt_free_pd(pd_rp, pd_rp->pd_hca_hdl,
5536 5508                      pd_rp->pd_hdl);
5537 5509                  if (status != IBT_SUCCESS) {
5538 5510                          DERR("pd_destroy: ibt_free_pd returned %d\n", status);
↓ open down ↓ 71 lines elided ↑ open up ↑
5610 5582          }
5611 5583  
5612 5584          /*
5613 5585           * Allocate and initialize a MW resource
5614 5586           */
5615 5587          mw_rp = kmem_zalloc(sizeof (daplka_mw_resource_t), daplka_km_flags);
5616 5588          if (mw_rp == NULL) {
5617 5589                  DERR("mw_alloc: cannot allocate mw resource\n");
5618 5590                  return (ENOMEM);
5619 5591          }
5620      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mw_rp))
5621 5592          DAPLKA_RS_INIT(mw_rp, DAPL_TYPE_MW,
5622 5593              DAPLKA_RS_RNUM(ia_rp), daplka_mw_destroy);
5623 5594  
5624 5595          mutex_init(&mw_rp->mw_lock, NULL, MUTEX_DRIVER, NULL);
5625 5596          mw_rp->mw_hca = ia_rp->ia_hca;
5626 5597          mw_rp->mw_hca_hdl = ia_rp->ia_hca_hdl;
5627 5598  
5628 5599          /* get pd handle */
5629 5600          pd_rp = (daplka_pd_resource_t *)
5630 5601              daplka_hash_lookup(&ia_rp->ia_pd_htbl, args.mw_pd_hkey);
↓ open down ↓ 60 lines elided ↑ open up ↑
5691 5662                  ASSERT(ia_rp->ia_state == DAPLKA_IA_MW_ALLOC_IN_PROGRESS);
5692 5663                  ia_rp->ia_mw_alloccnt--;
5693 5664                  if (ia_rp->ia_mw_alloccnt == 0) {
5694 5665                          ia_rp->ia_state = DAPLKA_IA_INIT;
5695 5666                          cv_broadcast(&ia_rp->ia_cv);
5696 5667                  }
5697 5668                  mutex_exit(&ia_rp->ia_lock);
5698 5669                  goto cleanup;
5699 5670          }
5700 5671          inserted = B_TRUE;
5701      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*mw_rp))
5702 5672  
5703 5673          D3("mw_alloc: ibt_alloc_mw mw_hdl(%p) mw_rkey(0x%llx)\n",
5704 5674              mw_rp->mw_hdl, (longlong_t)mw_rkey);
5705 5675  
5706 5676          mutex_enter(&ia_rp->ia_lock);
5707 5677          /*
5708 5678           * We are done with mw_alloc if this was the last mw_alloc
5709 5679           * change state back to DAPLKA_IA_INIT and wake up waiters
5710 5680           * specifically the unlock callback.
5711 5681           */
↓ open down ↓ 74 lines elided ↑ open up ↑
5786 5756  /*
5787 5757   * destroys the memory window.
5788 5758   * called when refcnt drops to zero.
5789 5759   */
5790 5760  static int
5791 5761  daplka_mw_destroy(daplka_resource_t *gen_rp)
5792 5762  {
5793 5763          daplka_mw_resource_t    *mw_rp = (daplka_mw_resource_t *)gen_rp;
5794 5764          ibt_status_t            status;
5795 5765  
5796      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mw_rp))
5797 5766          ASSERT(DAPLKA_RS_REFCNT(mw_rp) == 0);
5798 5767          D3("mw_destroy: entering, mw_rp 0x%p, rnum %d\n",
5799 5768              mw_rp, DAPLKA_RS_RNUM(mw_rp));
5800 5769  
5801 5770          /*
5802 5771           * free memory window
5803 5772           */
5804 5773          if (mw_rp->mw_hdl) {
5805 5774                  status = daplka_ibt_free_mw(mw_rp, mw_rp->mw_hca_hdl,
5806 5775                      mw_rp->mw_hdl);
↓ open down ↓ 389 lines elided ↑ open up ↑
6196 6165          if (retval != 0) {
6197 6166                  DERR("service_register: copyin error %d\n", retval);
6198 6167                  return (EINVAL);
6199 6168          }
6200 6169  
6201 6170          sp_rp = kmem_zalloc(sizeof (*sp_rp), daplka_km_flags);
6202 6171          if (sp_rp == NULL) {
6203 6172                  DERR("service_register: cannot allocate sp resource\n");
6204 6173                  return (ENOMEM);
6205 6174          }
6206      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*sp_rp))
6207 6175          DAPLKA_RS_INIT(sp_rp, DAPL_TYPE_SP,
6208 6176              DAPLKA_RS_RNUM(ia_rp), daplka_sp_destroy);
6209 6177  
6210 6178          /* check if evd exists */
6211 6179          evd_rp = (daplka_evd_resource_t *)
6212 6180              daplka_hash_lookup(&ia_rp->ia_evd_htbl, args.sr_evd_hkey);
6213 6181          if (evd_rp == NULL) {
6214 6182                  DERR("service_register: evd resource not found\n");
6215 6183                  retval = EINVAL;
6216 6184                  goto cleanup;
↓ open down ↓ 73 lines elided ↑ open up ↑
6290 6258          bumped = B_TRUE;
6291 6259  
6292 6260          /* insert into global sp hash table */
6293 6261          sp_rp->sp_global_hkey = 0;
6294 6262          retval = daplka_hash_insert(&daplka_global_sp_htbl,
6295 6263              &sp_rp->sp_global_hkey, (void *)sp_rp);
6296 6264          if (retval != 0) {
6297 6265                  DERR("service_register: cannot insert sp resource\n");
6298 6266                  goto cleanup;
6299 6267          }
6300      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*sp_rp))
6301 6268  
6302 6269          /* insert into per-IA sp hash table */
6303 6270          retval = daplka_hash_insert(&ia_rp->ia_sp_htbl,
6304 6271              &sp_hkey, (void *)sp_rp);
6305 6272          if (retval != 0) {
6306 6273                  DERR("service_register: cannot insert sp resource\n");
6307 6274                  goto cleanup;
6308 6275          }
6309 6276  
6310 6277          /* pass index to application */
↓ open down ↓ 107 lines elided ↑ open up ↑
6418 6385  /*
6419 6386   * destroys a service point.
6420 6387   * called when the refcnt drops to zero.
6421 6388   */
6422 6389  static int
6423 6390  daplka_sp_destroy(daplka_resource_t *gen_rp)
6424 6391  {
6425 6392          daplka_sp_resource_t *sp_rp = (daplka_sp_resource_t *)gen_rp;
6426 6393          ibt_status_t status;
6427 6394  
6428      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*sp_rp))
6429 6395          ASSERT(DAPLKA_RS_REFCNT(sp_rp) == 0);
6430 6396          D3("sp_destroy: entering, sp_rp %p, rnum %d\n",
6431 6397              sp_rp, DAPLKA_RS_RNUM(sp_rp));
6432 6398  
6433 6399          /*
6434 6400           * it is possible for pending connections to remain
6435 6401           * on an SP. We need to clean them up here.
6436 6402           */
6437 6403          if (sp_rp->sp_backlog != NULL) {
6438 6404                  ibt_cm_proceed_reply_t proc_reply;
↓ open down ↓ 137 lines elided ↑ open up ↑
6576 6542          mutex_exit(&spp->sp_lock);
6577 6543  
6578 6544          /*
6579 6545           * too many pending connections
6580 6546           */
6581 6547          if (bkl_index == spp->sp_backlog_size) {
6582 6548                  DERR("service_req: connection pending exceeded %d limit\n",
6583 6549                      spp->sp_backlog_size);
6584 6550                  return (IBT_CM_NO_RESOURCE);
6585 6551          }
6586      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*conn))
6587 6552  
6588 6553          /*
6589 6554           * save data for cr_handoff
6590 6555           */
6591 6556          if (pr_data != NULL && pr_len > 0) {
6592 6557                  int trunc_len = pr_len;
6593 6558  
6594 6559                  if (trunc_len > DAPL_MAX_PRIVATE_DATA_SIZE) {
6595 6560                          DERR("service_req: private data truncated\n");
6596 6561                          trunc_len = DAPL_MAX_PRIVATE_DATA_SIZE;
↓ open down ↓ 67 lines elided ↑ open up ↑
6664 6629           */
6665 6630          D2("service_req: enqueue event(%p) evdp(%p) priv_data(%p) "
6666 6631              "priv_len(%d) psep(0x%llx)\n", cr_ev, spp->sp_evd_res,
6667 6632              cr_ev->ee_cmev.ec_cm_ev_priv_data,
6668 6633              (int)cr_ev->ee_cmev.ec_cm_ev_priv_data_len,
6669 6634              (longlong_t)cr_ev->ee_cmev.ec_cm_psep_cookie);
6670 6635  
6671 6636          daplka_evd_wakeup(spp->sp_evd_res,
6672 6637              &spp->sp_evd_res->evd_cr_events, cr_ev);
6673 6638  
6674      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*conn))
6675 6639          return (IBT_CM_DEFER);
6676 6640  
6677 6641  cleanup:;
6678 6642          /*
6679 6643           * free the cr event
6680 6644           */
6681 6645          if (cr_ev != NULL) {
6682 6646                  if (cr_ev->ee_cmev.ec_cm_ev_priv_data != NULL) {
6683 6647                          kmem_free(cr_ev->ee_cmev.ec_cm_ev_priv_data, pr_len);
6684 6648                          cr_ev->ee_cmev.ec_cm_ev_priv_data = NULL;
↓ open down ↓ 302 lines elided ↑ open up ↑
6987 6951          daplka_sp_resource_t    *sp_rp = (daplka_sp_resource_t *)cm_private;
6988 6952  
6989 6953          if (sp_rp == NULL) {
6990 6954                  DERR("service_handler: sp_rp == NULL\n");
6991 6955                  return (IBT_CM_NO_RESOURCE);
6992 6956          }
6993 6957          /*
6994 6958           * default is not to return priv data
6995 6959           */
6996 6960          if (ret_args != NULL) {
6997      -                _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*ret_args))
6998 6961                  ret_args->cm_ret_len = 0;
6999 6962          }
7000 6963  
7001 6964          switch (event->cm_type) {
7002 6965          case IBT_CM_EVENT_REQ_RCV:
7003 6966                  D2("service_handler: IBT_CM_EVENT_REQ_RCV\n");
7004 6967                  return (daplka_cm_service_req(sp_rp, event, ret_args,
7005 6968                      event->cm_priv_data, event->cm_priv_data_len));
7006 6969  
7007 6970          case IBT_CM_EVENT_REP_RCV:
↓ open down ↓ 408 lines elided ↑ open up ↑
7416 7379          daplka_ep_resource_t *ep_rp = (daplka_ep_resource_t *)cm_private;
7417 7380  
7418 7381          if (ep_rp == NULL) {
7419 7382                  DERR("rc_handler: ep_rp == NULL\n");
7420 7383                  return (IBT_CM_NO_CHANNEL);
7421 7384          }
7422 7385          /*
7423 7386           * default is not to return priv data
7424 7387           */
7425 7388          if (ret_args != NULL) {
7426      -                _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*ret_args))
7427 7389                  ret_args->cm_ret_len = 0;
7428 7390          }
7429 7391  
7430 7392          switch (event->cm_type) {
7431 7393          case IBT_CM_EVENT_REQ_RCV:
7432 7394                  /* active side should not receive this event */
7433 7395                  D2("rc_handler: IBT_CM_EVENT_REQ_RCV\n");
7434 7396                  break;
7435 7397  
7436 7398          case IBT_CM_EVENT_REP_RCV:
↓ open down ↓ 101 lines elided ↑ open up ↑
7538 7500          if (status != IBT_SUCCESS) {
7539 7501                  DERR("ia_create: ibt_query_hca_ports returned %d\n", status);
7540 7502                  *rvalp = (int)status;
7541 7503                  DAPLKA_RELE_HCA(daplka_dev, hca);
7542 7504                  return (0);
7543 7505          }
7544 7506          sgid = pinfop->p_sgid_tbl[0];
7545 7507          ibt_free_portinfo(pinfop, size);
7546 7508  
7547 7509          ia_rp = kmem_zalloc(sizeof (daplka_ia_resource_t), daplka_km_flags);
7548      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*ia_rp))
7549 7510          DAPLKA_RS_INIT(ia_rp, DAPL_TYPE_IA, rnum, daplka_ia_destroy);
7550 7511  
7551 7512          mutex_init(&ia_rp->ia_lock, NULL, MUTEX_DRIVER, NULL);
7552 7513          cv_init(&ia_rp->ia_cv, NULL, CV_DRIVER, NULL);
7553 7514          ia_rp->ia_hca_hdl = hca_hdl;
7554 7515          ia_rp->ia_hca_sgid = sgid;
7555 7516          ia_rp->ia_hca = hca;
7556 7517          ia_rp->ia_port_num = args.ia_port;
7557 7518          ia_rp->ia_port_pkey = args.ia_pkey;
7558 7519          ia_rp->ia_pid = ddi_get_pid();
↓ open down ↓ 71 lines elided ↑ open up ↑
7630 7591          }
7631 7592          /*
7632 7593           * insert ia_rp into the global resource table
7633 7594           */
7634 7595          retval = daplka_resource_insert(rnum, (daplka_resource_t *)ia_rp);
7635 7596          if (retval != 0) {
7636 7597                  DERR("ia_create: cannot insert resource\n");
7637 7598                  goto cleanup;
7638 7599          }
7639 7600          inserted = B_TRUE;
7640      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*ia_rp))
7641 7601  
7642 7602          args.ia_resnum = rnum;
7643 7603          retval = copyout(&args, (void *)arg, sizeof (dapl_ia_create_t));
7644 7604          if (retval != 0) {
7645 7605                  DERR("ia_create: copyout error %d\n", retval);
7646 7606                  retval = EFAULT;
7647 7607                  goto cleanup;
7648 7608          }
7649 7609          return (0);
7650 7610  
↓ open down ↓ 17 lines elided ↑ open up ↑
7668 7628   * destroys an IA resource
7669 7629   */
7670 7630  static int
7671 7631  daplka_ia_destroy(daplka_resource_t *gen_rp)
7672 7632  {
7673 7633          daplka_ia_resource_t    *ia_rp = (daplka_ia_resource_t *)gen_rp;
7674 7634          daplka_async_evd_hkey_t *hkp;
7675 7635          int                     cnt;
7676 7636          ibt_ar_t                ar_s;
7677 7637  
7678      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*ia_rp))
7679 7638          D3("ia_destroy: entering, ia_rp 0x%p\n", ia_rp);
7680 7639  
7681 7640          /* deregister Address Record */
7682 7641          if (ia_rp->ia_ar_registered) {
7683 7642                  ar_s.ar_gid = ia_rp->ia_hca_sgid;
7684 7643                  ar_s.ar_pkey = ia_rp->ia_port_pkey;
7685 7644                  bcopy(ia_rp->ia_sadata, ar_s.ar_data, DAPL_ATS_NBYTES);
7686 7645                  (void) ibt_deregister_ar(daplka_dev->daplka_clnt_hdl, &ar_s);
7687 7646                  ia_rp->ia_ar_registered = B_FALSE;
7688 7647          }
↓ open down ↓ 1387 lines elided ↑ open up ↑
9076 9035   *
9077 9036   * A resource blk is freed when its used count reaches zero.
9078 9037   */
9079 9038  
9080 9039  /*
9081 9040   * initializes the global resource table
9082 9041   */
9083 9042  static void
9084 9043  daplka_resource_init(void)
9085 9044  {
9086      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(daplka_resource))
9087 9045          rw_init(&daplka_resource.daplka_rct_lock, NULL, RW_DRIVER, NULL);
9088 9046          daplka_resource.daplka_rc_len = 0;
9089 9047          daplka_resource.daplka_rc_sz = 0;
9090 9048          daplka_resource.daplka_rc_cnt = 0;
9091 9049          daplka_resource.daplka_rc_flag = 0;
9092 9050          daplka_resource.daplka_rc_root = NULL;
9093      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(daplka_resource))
9094 9051  }
9095 9052  
9096 9053  /*
9097 9054   * destroys the global resource table
9098 9055   */
9099 9056  static void
9100 9057  daplka_resource_fini(void)
9101 9058  {
9102 9059          int     i;
9103 9060  
↓ open down ↓ 318 lines elided ↑ open up ↑
9422 9379  static int
9423 9380  daplka_hash_create(daplka_hash_table_t *htblp, uint_t nbuckets,
9424 9381          void (*free_func)(void *), void (*lookup_func)(void *))
9425 9382  {
9426 9383          int i;
9427 9384  
9428 9385          if ((nbuckets & ~(nbuckets - 1)) != nbuckets) {
9429 9386                  DERR("hash_create: nbuckets not power of 2\n");
9430 9387                  return (EINVAL);
9431 9388          }
9432      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*htblp))
9433 9389  
9434 9390          htblp->ht_buckets =
9435 9391              kmem_zalloc(sizeof (daplka_hash_bucket_t) * nbuckets,
9436 9392              daplka_km_flags);
9437 9393          if (htblp->ht_buckets == NULL) {
9438 9394                  DERR("hash_create: cannot allocate buckets\n");
9439 9395                  return (ENOMEM);
9440 9396          }
9441 9397          for (i = 0; i < nbuckets; i++) {
9442      -                _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(htblp->ht_buckets[i]))
9443 9398                  htblp->ht_buckets[i].hb_count = 0;
9444 9399                  htblp->ht_buckets[i].hb_entries = NULL;
9445      -                _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(htblp->ht_buckets[i]))
9446 9400          }
9447 9401          rw_init(&htblp->ht_table_lock, NULL, RW_DRIVER, NULL);
9448 9402          mutex_init(&htblp->ht_key_lock, NULL, MUTEX_DRIVER, NULL);
9449 9403  
9450 9404          htblp->ht_count = 0;
9451 9405          htblp->ht_next_hkey = (uint64_t)gethrtime();
9452 9406          htblp->ht_nbuckets = nbuckets;
9453 9407          htblp->ht_free_func = free_func;
9454 9408          htblp->ht_lookup_func = lookup_func;
9455 9409          htblp->ht_initialized = B_TRUE;
9456 9410          D3("hash_create: done, buckets = %d\n", nbuckets);
9457      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*htblp))
9458 9411          return (0);
9459 9412  }
9460 9413  
9461 9414  /*
9462 9415   * daplka_hash_insert:
9463 9416   *      inserts an object into a hash table
9464 9417   *
9465 9418   * input:
9466 9419   *      htblp                   pointer to hash table
9467 9420   *
↓ open down ↓ 173 lines elided ↑ open up ↑
9641 9594  static void
9642 9595  daplka_hash_walk(daplka_hash_table_t *htblp, int (*func)(void *, void *),
9643 9596          void *farg, krw_t lockmode)
9644 9597  {
9645 9598          daplka_hash_entry_t *curr_hep;
9646 9599          daplka_hash_bucket_t *hbp;
9647 9600          uint32_t bucket, retval = 0;
9648 9601  
9649 9602          ASSERT(lockmode == RW_WRITER || lockmode == RW_READER);
9650 9603  
9651      -        /* needed for warlock */
9652 9604          if (lockmode == RW_WRITER) {
9653 9605                  rw_enter(&htblp->ht_table_lock, RW_WRITER);
9654 9606          } else {
9655 9607                  rw_enter(&htblp->ht_table_lock, RW_READER);
9656 9608          }
9657 9609          for (bucket = 0; bucket < htblp->ht_nbuckets && retval == 0; bucket++) {
9658 9610                  hbp = &htblp->ht_buckets[bucket];
9659 9611                  curr_hep = hbp->hb_entries;
9660 9612                  while (curr_hep != NULL) {
9661 9613                          retval = (*func)(curr_hep->he_objp, farg);
↓ open down ↓ 278 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX