Lines Matching refs:ct

220 static int 		i_mdi_lba_lb(mdi_client_t *ct,
1229 mdi_client_t *ct = NULL;
1232 ct = (mdi_client_t *)DEVI(cdip)->devi_mdi_client;
1234 return (ct);
1275 i_mdi_client_lock(mdi_client_t *ct, mdi_pathinfo_t *pip)
1281 while (MDI_CLIENT_TRYLOCK(ct) == 0) {
1285 MDI_CLIENT_LOCK(ct);
1302 MDI_CLIENT_LOCK(ct);
1311 i_mdi_client_unlock(mdi_client_t *ct)
1313 MDI_CLIENT_UNLOCK(ct);
1327 mdi_client_t *ct;
1334 ct = kmem_zalloc(sizeof (*ct), KM_SLEEP);
1335 mutex_init(&ct->ct_mutex, NULL, MUTEX_DEFAULT, NULL);
1336 ct->ct_hnext = NULL;
1337 ct->ct_hprev = NULL;
1338 ct->ct_dip = NULL;
1339 ct->ct_vhci = vh;
1340 ct->ct_drvname = kmem_alloc(strlen(name) + 1, KM_SLEEP);
1341 (void) strcpy(ct->ct_drvname, name);
1342 ct->ct_guid = kmem_alloc(strlen(lguid) + 1, KM_SLEEP);
1343 (void) strcpy(ct->ct_guid, lguid);
1344 ct->ct_cprivate = NULL;
1345 ct->ct_vprivate = NULL;
1346 ct->ct_flags = 0;
1347 ct->ct_state = MDI_CLIENT_STATE_FAILED;
1348 MDI_CLIENT_LOCK(ct);
1349 MDI_CLIENT_SET_OFFLINE(ct);
1350 MDI_CLIENT_SET_DETACH(ct);
1351 MDI_CLIENT_SET_POWER_UP(ct);
1352 MDI_CLIENT_UNLOCK(ct);
1353 ct->ct_failover_flags = 0;
1354 ct->ct_failover_status = 0;
1355 cv_init(&ct->ct_failover_cv, NULL, CV_DRIVER, NULL);
1356 ct->ct_unstable = 0;
1357 cv_init(&ct->ct_unstable_cv, NULL, CV_DRIVER, NULL);
1358 cv_init(&ct->ct_powerchange_cv, NULL, CV_DRIVER, NULL);
1359 ct->ct_lb = vh->vh_lb;
1360 ct->ct_lb_args = kmem_zalloc(sizeof (client_lb_args_t), KM_SLEEP);
1361 ct->ct_lb_args->region_size = LOAD_BALANCE_DEFAULT_REGION_SIZE;
1362 ct->ct_path_count = 0;
1363 ct->ct_path_head = NULL;
1364 ct->ct_path_tail = NULL;
1365 ct->ct_path_last = NULL;
1370 i_mdi_client_enlist_table(vh, ct);
1371 return (ct);
1380 i_mdi_client_enlist_table(mdi_vhci_t *vh, mdi_client_t *ct)
1387 index = i_mdi_get_hash_key(ct->ct_guid);
1389 ct->ct_hnext = (mdi_client_t *)head->ct_hash_head;
1390 head->ct_hash_head = ct;
1401 i_mdi_client_delist_table(mdi_vhci_t *vh, mdi_client_t *ct)
1411 guid = ct->ct_guid;
1418 if (next == ct) {
1428 head->ct_hash_head = ct->ct_hnext;
1430 last->ct_hnext = ct->ct_hnext;
1432 ct->ct_hnext = NULL;
1443 i_mdi_client_free(mdi_vhci_t *vh, mdi_client_t *ct)
1446 int flags = ct->ct_flags;
1453 cdip = ct->ct_dip;
1462 ct->ct_dip = NULL;
1467 i_mdi_client_delist_table(vh, ct);
1472 kmem_free(ct->ct_drvname, strlen(ct->ct_drvname) + 1);
1473 kmem_free(ct->ct_guid, strlen(ct->ct_guid) + 1);
1474 kmem_free(ct->ct_lb_args, sizeof (client_lb_args_t));
1475 cv_destroy(&ct->ct_failover_cv);
1476 cv_destroy(&ct->ct_unstable_cv);
1477 cv_destroy(&ct->ct_powerchange_cv);
1478 mutex_destroy(&ct->ct_mutex);
1479 kmem_free(ct, sizeof (*ct));
1499 mdi_client_t *ct;
1506 ct = head->ct_hash_head;
1507 while (ct != NULL) {
1508 if (strcmp(ct->ct_guid, guid) == 0 &&
1509 (cname == NULL || strcmp(ct->ct_drvname, cname) == 0)) {
1512 ct = ct->ct_hnext;
1514 return (ct);
1532 i_mdi_client_update_state(mdi_client_t *ct)
1536 ASSERT(MDI_CLIENT_LOCKED(ct));
1537 state = i_mdi_client_compute_state(ct, NULL);
1538 MDI_CLIENT_SET_STATE(ct, state);
1551 i_mdi_client_compute_state(mdi_client_t *ct, mdi_phci_t *ph)
1558 ASSERT(MDI_CLIENT_LOCKED(ct));
1559 pip = ct->ct_path_head;
1582 MDI_DEBUG(2, (MDI_NOTE, ct->ct_dip,
1583 "client state failed: ct = %p", (void *)ct));
1606 i_mdi_client2devinfo(mdi_client_t *ct)
1608 return (ct->ct_dip);
1663 mdi_client_t *ct;
1666 ct = i_devi_get_client(cdip);
1667 if (ct != NULL) {
1668 count = ct->ct_path_count;
1700 mdi_client_t *ct;
1702 ct = i_devi_get_client(cdip);
1703 if (ct != NULL) {
1704 lb = ct->ct_lb;
1716 mdi_client_t *ct;
1719 ct = i_devi_get_client(cdip);
1720 if (ct != NULL && ct->ct_lb_args != NULL) {
1721 ct->ct_lb_args->region_size = region_size;
1734 mdi_client_t *ct;
1737 ct = i_devi_get_client(cdip);
1738 if (ct != NULL) {
1739 ct->ct_lb = lb;
1779 mdi_client_t *ct;
1781 ct = i_devi_get_client(cdip);
1782 ASSERT(ct != NULL);
1783 if (ct == NULL) {
1788 MDI_CLIENT_LOCK(ct);
1790 if (MDI_CLIENT_IS_PATH_FREE_IN_PROGRESS(ct)) {
1792 MDI_CLIENT_UNLOCK(ct);
1797 if (MDI_CLIENT_IS_FAILED(ct)) {
1801 MDI_CLIENT_UNLOCK(ct);
1805 if (MDI_CLIENT_IS_FAILOVER_IN_PROGRESS(ct)) {
1809 MDI_CLIENT_UNLOCK(ct);
1817 if (ct->ct_unstable) {
1819 MDI_CLIENT_UNLOCK(ct);
1822 while (ct->ct_unstable)
1823 cv_wait(&ct->ct_unstable_cv, &ct->ct_mutex);
1831 if ((MDI_CLIENT_IS_DETACHED(ct)) || (MDI_CLIENT_IS_FAILED(ct)) ||
1836 MDI_CLIENT_UNLOCK(ct);
1843 MDI_CLIENT_SET_FAILOVER_IN_PROGRESS(ct);
1844 ct->ct_failover_flags = flags;
1845 MDI_CLIENT_UNLOCK(ct);
1853 ct, KM_SLEEP);
1860 rv = i_mdi_failover(ct);
1878 mdi_client_t *ct = (mdi_client_t *)arg;
1879 mdi_vhci_t *vh = ct->ct_vhci;
1881 ASSERT(!MDI_CLIENT_LOCKED(ct));
1887 rv = (*vh->vh_ops->vo_failover)(vh->vh_dip, ct->ct_dip,
1888 ct->ct_failover_flags);
1891 MDI_CLIENT_LOCK(ct);
1892 MDI_CLIENT_CLEAR_FAILOVER_IN_PROGRESS(ct);
1897 ct->ct_failover_status = rv;
1904 i_mdi_client_update_state(ct);
1906 cv_broadcast(&ct->ct_failover_cv);
1907 MDI_CLIENT_UNLOCK(ct);
1921 i_mdi_lba_lb(mdi_client_t *ct, mdi_pathinfo_t **ret_pip, struct buf *bp)
1926 int region_size = ct->ct_lb_args->region_size;
1931 pip = ct->ct_path_head;
1958 pip = ct->ct_path_head;
1976 MDI_DEBUG(4, (MDI_NOTE, ct->ct_dip,
2044 mdi_client_t *ct;
2074 ct = i_devi_get_client(cdip);
2075 if (ct == NULL) {
2080 MDI_CLIENT_LOCK(ct);
2083 if (MDI_CLIENT_IS_FAILED(ct)) {
2089 "client state offline ct = %p", (void *)ct));
2090 MDI_CLIENT_UNLOCK(ct);
2094 if (MDI_CLIENT_IS_FAILOVER_IN_PROGRESS(ct)) {
2100 "client failover in progress ct = %p",
2101 (void *)ct));
2102 MDI_CLIENT_UNLOCK(ct);
2111 if (MDI_CLIENT_IS_DETACHED(ct) || !i_ddi_devi_attached(cdip)) {
2113 "devi is onlining ct = %p", (void *)ct));
2114 MDI_CLIENT_UNLOCK(ct);
2123 head = ct->ct_path_head;
2125 MDI_CLIENT_UNLOCK(ct);
2139 MDI_CLIENT_UNLOCK(ct);
2157 MDI_CLIENT_UNLOCK(ct);
2164 MDI_CLIENT_UNLOCK(ct);
2175 MDI_CLIENT_UNLOCK(ct);
2185 lbp = sb ? ct->ct_lb : LOAD_BALANCE_RR;
2195 pip = (mdi_pathinfo_t *)ct->ct_path_last;
2216 ct->ct_path_last = pip;
2218 MDI_CLIENT_UNLOCK(ct);
2252 if ((ct->ct_lb_args != NULL) &&
2253 (ct->ct_lb_args->region_size) && bp &&
2255 if (i_mdi_lba_lb(ct, ret_pip, bp)
2257 MDI_CLIENT_UNLOCK(ct);
2279 start = sb ? (mdi_pathinfo_t *)ct->ct_path_last : start_pip;
2289 MDI_CLIENT_UNLOCK(ct);
2301 MDI_CLIENT_UNLOCK(ct);
2385 ct->ct_path_last = pip;
2387 MDI_CLIENT_UNLOCK(ct);
2487 MDI_CLIENT_UNLOCK(ct);
2516 mdi_client_t *ct;
2524 ct = (mdi_client_t *)DEVI(ct_dip)->devi_mdi_client;
2525 ASSERT(ct != NULL);
2528 return ((mdi_pathinfo_t *)ct->ct_path_head);
2643 mdi_client_t *ct;
2715 ct = i_mdi_client_find(vh, NULL, caddr);
2716 if (ct == NULL) {
2731 MDI_CLIENT_LOCK(ct);
2739 pip = (mdi_pathinfo_t *)ct->ct_path_head;
2750 MDI_CLIENT_UNLOCK(ct);
2783 mdi_client_t *ct;
2843 ct = i_mdi_client_find(vh, cname, caddr);
2844 if (ct == NULL) {
2845 ct = i_mdi_client_alloc(vh, cname, caddr);
2846 ASSERT(ct != NULL);
2849 if (ct->ct_dip == NULL) {
2853 ct->ct_dip = i_mdi_devinfo_create(vh, cname, caddr,
2855 if (ct->ct_dip == NULL) {
2856 (void) i_mdi_client_free(vh, ct);
2860 cdip = ct->ct_dip;
2863 DEVI(cdip)->devi_mdi_client = (caddr_t)ct;
2865 MDI_CLIENT_LOCK(ct);
2866 pip = (mdi_pathinfo_t *)ct->ct_path_head;
2877 MDI_CLIENT_UNLOCK(ct);
2884 pip = i_mdi_pi_alloc(ph, paddr, ct);
2930 i_mdi_pi_alloc(mdi_phci_t *ph, char *paddr, mdi_client_t *ct)
2958 MDI_PI(pip)->pi_client = ct;
3021 ndi_devi_enter(ct->ct_dip, &ct_circular);
3025 i_mdi_client_add_path(ct, pip);
3028 ndi_devi_exit(ct->ct_dip, ct_circular);
3105 i_mdi_client_add_path(mdi_client_t *ct, mdi_pathinfo_t *pip)
3107 ASSERT(DEVI_BUSY_OWNED(ct->ct_dip));
3109 MDI_CLIENT_LOCK(ct);
3110 if (ct->ct_path_head == NULL) {
3111 ct->ct_path_head = pip;
3113 MDI_PI(ct->ct_path_tail)->pi_client_link = MDI_PI(pip);
3115 ct->ct_path_tail = pip;
3116 ct->ct_path_count++;
3117 MDI_CLIENT_UNLOCK(ct);
3136 mdi_client_t *ct;
3165 ct = MDI_PI(pip)->pi_client;
3166 ASSERT(ct != NULL);
3167 if (ct == NULL) {
3188 MDI_DEBUG(1, (MDI_WARN, ct->ct_dip,
3198 MDI_DEBUG(1, (MDI_NOTE, ct->ct_dip,
3209 MDI_DEBUG(1, (MDI_NOTE, ct->ct_dip,
3212 MDI_DEBUG(1, (MDI_NOTE, ct->ct_dip,
3227 MDI_CLIENT_LOCK(ct);
3230 MDI_CLIENT_SET_PATH_FREE_IN_PROGRESS(ct);
3235 while (MDI_CLIENT_IS_FAILOVER_IN_PROGRESS(ct))
3236 cv_wait(&ct->ct_failover_cv, &ct->ct_mutex);
3238 MDI_CLIENT_UNLOCK(ct);
3240 MDI_CLIENT_LOCK(ct);
3241 MDI_CLIENT_CLEAR_PATH_FREE_IN_PROGRESS(ct);
3256 MDI_DEBUG(4, (MDI_NOTE, ct->ct_dip,
3258 i_mdi_pm_rele_client(ct, 1);
3260 i_mdi_pi_free(ph, pip, ct);
3261 if (ct->ct_path_count == 0) {
3266 MDI_CLIENT_UNLOCK(ct);
3267 (void) i_mdi_client_free(ct->ct_vhci, ct);
3272 MDI_CLIENT_UNLOCK(ct);
3286 i_mdi_pi_free(mdi_phci_t *ph, mdi_pathinfo_t *pip, mdi_client_t *ct)
3291 ASSERT(MDI_CLIENT_LOCKED(ct));
3299 ndi_devi_enter(ct->ct_dip, &ct_circular);
3302 i_mdi_client_remove_path(ct, pip);
3306 ndi_devi_exit(ct->ct_dip, ct_circular);
3375 i_mdi_client_remove_path(mdi_client_t *ct, mdi_pathinfo_t *pip)
3380 ASSERT(DEVI_BUSY_OWNED(ct->ct_dip));
3382 ASSERT(MDI_CLIENT_LOCKED(ct));
3383 path = ct->ct_path_head;
3393 ct->ct_path_count--;
3398 ct->ct_path_head =
3401 if (ct->ct_path_tail == path) {
3402 ct->ct_path_tail = prev;
3404 if (ct->ct_path_last == path) {
3405 ct->ct_path_last = ct->ct_path_head;
3427 mdi_client_t *ct;
3459 ct = MDI_PI(pip)->pi_client;
3460 ASSERT(ct != NULL);
3461 if (ct == NULL) {
3483 MDI_DEBUG(1, (MDI_WARN, ct->ct_dip,
3500 MDI_DEBUG(1, (MDI_WARN, ct->ct_dip,
3525 i_mdi_client_lock(ct, pip);
3531 while (MDI_CLIENT_IS_FAILOVER_IN_PROGRESS(ct))
3532 cv_wait(&ct->ct_failover_cv, &ct->ct_mutex);
3557 * ndi_devi_offline() cannot hold pip or ct locks.
3566 cdip = ct->ct_dip;
3569 (MDI_CLIENT_STATE(ct) == MDI_CLIENT_STATE_DEGRADED)) {
3570 i_mdi_client_unlock(ct);
3586 i_mdi_client_lock(ct, NULL);
3597 MDI_CLIENT_UNSTABLE(ct);
3598 i_mdi_client_unlock(ct);
3604 MDI_CLIENT_LOCK(ct);
3607 MDI_CLIENT_SET_DEV_NOT_SUPPORTED(ct);
3610 MDI_DEBUG(2, (MDI_WARN, ct->ct_dip,
3630 MDI_CLIENT_STABLE(ct);
3632 if (ct->ct_unstable == 0) {
3633 cdip = ct->ct_dip;
3641 i_mdi_client_update_state(ct);
3642 switch (MDI_CLIENT_STATE(ct)) {
3654 MDI_CLIENT_UNLOCK(ct);
3656 MDI_CLIENT_LOCK(ct);
3658 (MDI_CLIENT_STATE(ct) ==
3676 MDI_CLIENT_UNLOCK(ct);
3679 MDI_CLIENT_LOCK(ct);
3691 MDI_CLIENT_SET_ONLINE(ct);
3701 MDI_CLIENT_SET_REPORT_DEV_NEEDED(ct);
3702 i_mdi_report_path_state(ct, pip);
3714 MDI_CLIENT_UNLOCK(ct);
3738 mdi_client_t *ct = MDI_PI(pip)->pi_client;
3742 ASSERT(ct != NULL);
3749 MDI_DEBUG(4, (MDI_NOTE, ct->ct_dip,
3757 MDI_CLIENT_LOCK(ct);
3758 if (ct->ct_power_cnt == 0) {
3759 rv = i_mdi_power_all_phci(ct);
3762 MDI_DEBUG(4, (MDI_NOTE, ct->ct_dip,
3763 "i_mdi_pm_hold_client %p", (void *)ct));
3764 i_mdi_pm_hold_client(ct, 1);
3765 MDI_CLIENT_UNLOCK(ct);
3809 mdi_client_t *ct;
3831 ct = MDI_PI(pip)->pi_client;
3832 MDI_CLIENT_LOCK(ct);
3833 MDI_DEBUG(4, (MDI_NOTE, ct->ct_dip,
3835 i_mdi_pm_rele_client(ct, 1);
3836 MDI_CLIENT_UNLOCK(ct);
3852 mdi_client_t *ct = NULL;
3857 ct = MDI_PI(pip)->pi_client;
3858 ASSERT(ct != NULL);
3864 MDI_DEBUG(1, (MDI_NOTE, ct->ct_dip,
3875 MDI_DEBUG(1, (MDI_NOTE, ct->ct_dip,
3878 MDI_DEBUG(1, (MDI_NOTE, ct->ct_dip,
3884 vh = ct->ct_vhci;
3897 MDI_DEBUG(1, (MDI_WARN, ct->ct_dip,
3912 MDI_CLIENT_LOCK(ct);
3914 if (ct->ct_unstable == 0) {
3915 dev_info_t *cdip = ct->ct_dip;
3922 i_mdi_client_update_state(ct);
3924 if (MDI_CLIENT_STATE(ct) == MDI_CLIENT_STATE_FAILED) {
3928 MDI_CLIENT_UNLOCK(ct);
3931 MDI_CLIENT_LOCK(ct);
3941 MDI_CLIENT_SET_ONLINE(ct);
3960 MDI_CLIENT_SET_REPORT_DEV_NEEDED(ct);
3961 i_mdi_report_path_state(ct, pip);
3964 MDI_CLIENT_UNLOCK(ct);
3969 MDI_DEBUG(2, (MDI_NOTE, ct->ct_dip,
3970 "ct = %p pip = %p", (void *)ct, (void *)pip));
3982 mdi_client_t *ct = NULL;
3990 ct = MDI_PI(pip)->pi_client;
3997 MDI_CLIENT_LOCK(ct);
4002 dev_info_t *cdip = ct->ct_dip;
4005 i_mdi_client_update_state(ct);
4006 if (MDI_CLIENT_STATE(ct) == MDI_CLIENT_STATE_OPTIMAL ||
4007 MDI_CLIENT_STATE(ct) == MDI_CLIENT_STATE_DEGRADED) {
4009 MDI_CLIENT_UNLOCK(ct);
4011 MDI_CLIENT_LOCK(ct);
4013 (MDI_CLIENT_STATE(ct) ==
4015 MDI_CLIENT_SET_OFFLINE(ct);
4028 MDI_CLIENT_SET_REPORT_DEV_NEEDED(ct);
4029 i_mdi_report_path_state(ct, pip);
4045 MDI_CLIENT_UNLOCK(ct);
4061 mdi_client_t *ct;
4065 ct = MDI_PI(pip)->pi_client;
4066 if ((ct == NULL) || (ct->ct_dip == NULL))
4068 return (ddi_node_name(ct->ct_dip));
4816 i_mdi_report_path_state(mdi_client_t *ct, mdi_pathinfo_t *pip)
4821 dev_info_t *cdip = ct->ct_dip;
4825 ASSERT(MDI_CLIENT_LOCKED(ct));
4827 (MDI_CLIENT_IS_REPORT_DEV_NEEDED(ct) == 0)) {
4830 if (MDI_CLIENT_STATE(ct) == MDI_CLIENT_STATE_OPTIMAL) {
4833 } else if (MDI_CLIENT_STATE(ct) == MDI_CLIENT_STATE_DEGRADED) {
4835 } else if (MDI_CLIENT_STATE(ct) == MDI_CLIENT_STATE_FAILED) {
4867 if (ct->ct_lb == LOAD_BALANCE_LBA) {
4870 ct->ct_lb_args->region_size);
4871 } else if (ct->ct_lb == LOAD_BALANCE_NONE) {
4897 MDI_CLIENT_CLEAR_REPORT_DEV_NEEDED(ct);
5008 mdi_client_t *ct;
5014 ct = i_devi_get_client(ct_dip);
5015 ASSERT(ct != NULL);
5016 MDI_CLIENT_LOCK(ct);
5017 MDI_CLIENT_SET_ONLINE(ct);
5019 ASSERT((ct->ct_dip == NULL) || (ct->ct_dip == ct_dip));
5020 ct->ct_dip = ct_dip;
5022 if (ct->ct_power_cnt == 0)
5023 (void) i_mdi_power_all_phci(ct);
5026 "i_mdi_pm_hold_client %p", (void *)ct));
5027 i_mdi_pm_hold_client(ct, 1);
5029 MDI_CLIENT_UNLOCK(ct);
5106 mdi_client_t *ct;
5157 ct = MDI_PI(pip)->pi_client;
5158 i_mdi_client_lock(ct, pip);
5159 if ((MDI_CLIENT_IS_FAILOVER_IN_PROGRESS(ct)) ||
5160 (ct->ct_unstable)) {
5169 i_mdi_client_unlock(ct);
5179 cdip = ct->ct_dip;
5181 (i_mdi_client_compute_state(ct, ph) ==
5183 i_mdi_client_unlock(ct);
5205 i_mdi_client_unlock(ct);
5215 ct = MDI_PI(pip)->pi_client;
5216 i_mdi_client_lock(ct, pip);
5217 cdip = ct->ct_dip;
5218 switch (MDI_CLIENT_STATE(ct)) {
5223 i_mdi_client_unlock(ct);
5235 i_mdi_client_unlock(ct);
5246 i_mdi_client_unlock(ct);
5280 ct = MDI_PI(pip)->pi_client;
5303 mdi_client_t *ct;
5329 ct = MDI_PI(pip)->pi_client;
5330 i_mdi_client_lock(ct, pip);
5333 cdip = ct->ct_dip;
5335 (i_mdi_client_compute_state(ct, ph) ==
5338 i_mdi_client_unlock(ct);
5344 i_mdi_client_unlock(ct);
5358 mdi_client_t *ct;
5394 ct = MDI_PI(pip)->pi_client;
5395 i_mdi_client_lock(ct, pip);
5396 if ((MDI_CLIENT_IS_FAILOVER_IN_PROGRESS(ct)) ||
5397 (ct->ct_unstable)) {
5402 i_mdi_client_unlock(ct);
5413 cdip = ct->ct_dip;
5415 (i_mdi_client_compute_state(ct, ph) ==
5417 i_mdi_client_unlock(ct);
5423 i_mdi_client_unlock(ct);
5447 mdi_client_t *ct;
5486 ct = MDI_PI(pip)->pi_client;
5487 i_mdi_client_lock(ct, pip);
5488 if ((MDI_CLIENT_IS_FAILOVER_IN_PROGRESS(ct)) ||
5489 (ct->ct_unstable)) {
5498 cdip = ct->ct_dip;
5501 (i_mdi_client_compute_state(ct, ph) ==
5503 i_mdi_client_unlock(ct);
5523 i_mdi_client_unlock(ct);
5571 ct = MDI_PI(pip)->pi_client;
5622 mdi_client_t *ct;
5629 ct = i_devi_get_client(dip);
5631 "called %p %p", (void *)dip, (void *)ct));
5632 if (ct != NULL) {
5633 MDI_CLIENT_LOCK(ct);
5634 if (ct->ct_unstable) {
5644 MDI_CLIENT_UNLOCK(ct);
5647 if (MDI_CLIENT_IS_FAILOVER_IN_PROGRESS(ct)) {
5656 MDI_CLIENT_UNLOCK(ct);
5659 MDI_CLIENT_SET_OFFLINE(ct);
5665 ct->ct_dip = NULL;
5667 MDI_CLIENT_UNLOCK(ct);
5697 mdi_client_t *ct;
5736 ct = i_devi_get_client(dip);
5737 ASSERT(ct != NULL);
5739 MDI_CLIENT_LOCK(ct);
5743 "client post_attach called %p", (void *)ct));
5748 MDI_CLIENT_SET_DETACH(ct);
5751 i_mdi_pm_reset_client(ct);
5759 vh = ct->ct_vhci;
5763 MDI_CLIENT_SET_ATTACH(ct);
5768 "client post_attach: called %p", (void *)ct));
5770 MDI_CLIENT_SET_RESUME(ct);
5775 MDI_CLIENT_SET_SUSPEND(ct);
5779 MDI_CLIENT_UNLOCK(ct);
5810 mdi_client_t *ct;
5858 ct = MDI_PI(pip)->pi_client;
5859 i_mdi_client_lock(ct, pip);
5860 cdip = ct->ct_dip;
5862 if ((MDI_CLIENT_IS_DETACHED(ct) == 0) &&
5863 MDI_CLIENT_IS_SUSPENDED(ct) == 0) {
5864 i_mdi_client_unlock(ct);
5879 i_mdi_client_unlock(ct);
5901 ct = MDI_PI(pip)->pi_client;
5902 i_mdi_client_lock(ct, pip);
5903 cdip = ct->ct_dip;
5905 if (MDI_CLIENT_IS_SUSPENDED(ct)) {
5906 i_mdi_client_unlock(ct);
5909 i_mdi_client_unlock(ct);
5929 mdi_client_t *ct;
5931 ct = i_devi_get_client(dip);
5932 if (ct == NULL) {
5936 MDI_CLIENT_LOCK(ct);
5941 (void *)ct));
5942 MDI_CLIENT_SET_DETACH(ct);
5948 (void *)ct));
5949 MDI_CLIENT_SET_SUSPEND(ct);
5956 MDI_CLIENT_UNLOCK(ct);
6023 mdi_client_t *ct;
6025 ct = i_devi_get_client(dip);
6026 if (ct == NULL) {
6029 MDI_CLIENT_LOCK(ct);
6037 "client post_detach: called %p", (void *)ct));
6041 i_mdi_pm_rele_client(ct, ct->ct_path_count);
6045 i_mdi_pm_reset_client(ct);
6048 MDI_CLIENT_SET_ATTACH(ct);
6053 "called %p", (void *)ct));
6055 MDI_CLIENT_SET_RESUME(ct);
6058 MDI_CLIENT_UNLOCK(ct);
6363 mdi_client_t *ct;
6434 ct = i_devi_get_client(cdip);
6435 if (ct == NULL) {
6437 "!failed: operation = %d: NULL ct", op));
6441 MDI_CLIENT_LOCK(ct);
6442 pip = ct->ct_path_head;
6457 MDI_CLIENT_UNLOCK(ct);
6541 i_mdi_pm_hold_client(mdi_client_t *ct, int incr)
6543 ASSERT(MDI_CLIENT_LOCKED(ct));
6545 ct->ct_power_cnt += incr;
6546 MDI_DEBUG(4, (MDI_NOTE, ct->ct_dip,
6548 (void *)ct, ct->ct_power_cnt, incr));
6549 ASSERT(ct->ct_power_cnt >= 0);
6553 i_mdi_rele_all_phci(mdi_client_t *ct)
6557 ASSERT(MDI_CLIENT_LOCKED(ct));
6558 pip = (mdi_pathinfo_t *)ct->ct_path_head;
6570 i_mdi_pm_rele_client(mdi_client_t *ct, int decr)
6572 ASSERT(MDI_CLIENT_LOCKED(ct));
6574 if (i_ddi_devi_attached(ct->ct_dip)) {
6575 ct->ct_power_cnt -= decr;
6576 MDI_DEBUG(4, (MDI_NOTE, ct->ct_dip,
6578 (void *)ct, ct->ct_power_cnt, decr));
6581 ASSERT(ct->ct_power_cnt >= 0);
6582 if (ct->ct_power_cnt == 0) {
6583 i_mdi_rele_all_phci(ct);
6589 i_mdi_pm_reset_client(mdi_client_t *ct)
6591 MDI_DEBUG(4, (MDI_NOTE, ct->ct_dip,
6592 "%p ct_power_cnt = %d", (void *)ct, ct->ct_power_cnt));
6593 ASSERT(MDI_CLIENT_LOCKED(ct));
6594 ct->ct_power_cnt = 0;
6595 i_mdi_rele_all_phci(ct);
6596 ct->ct_powercnt_config = 0;
6597 ct->ct_powercnt_unconfig = 0;
6598 ct->ct_powercnt_reset = 1;
6636 i_mdi_power_all_phci(mdi_client_t *ct)
6641 ASSERT(MDI_CLIENT_LOCKED(ct));
6642 pip = (mdi_pathinfo_t *)ct->ct_path_head;
6651 MDI_CLIENT_UNLOCK(ct);
6655 ASSERT(ct == MDI_PI(pip)->pi_client);
6656 MDI_CLIENT_LOCK(ct);
6680 mdi_client_t *ct;
6692 * return quickly to save cou cycles on the ct processing
6710 ct = i_devi_get_client(cdip);
6711 if (ct == NULL)
6717 MDI_CLIENT_LOCK(ct);
6727 while (MDI_CLIENT_IS_POWER_TRANSITION(ct))
6728 cv_wait(&ct->ct_powerchange_cv, &ct->ct_mutex);
6730 MDI_CLIENT_SET_POWER_TRANSITION(ct);
6732 if (ct->ct_power_cnt == 0) {
6733 ret = i_mdi_power_all_phci(ct);
6743 if (!DEVI_IS_ATTACHING(ct->ct_dip)) {
6746 i_mdi_pm_hold_client(ct, ct->ct_path_count);
6760 MDI_CLIENT_SET_POWER_UP(ct);
6762 MDI_CLIENT_SET_POWER_DOWN(ct);
6768 !DEVI_IS_ATTACHING(ct->ct_dip)) {
6771 i_mdi_pm_rele_client(ct, ct->ct_path_count);
6776 if (DEVI_IS_ATTACHING(ct->ct_dip)) {
6779 i_mdi_pm_rele_client(ct, ct->ct_path_count);
6781 } else if (!DEVI_IS_DETACHING(ct->ct_dip)) {
6784 i_mdi_pm_reset_client(ct);
6788 MDI_CLIENT_CLEAR_POWER_TRANSITION(ct);
6789 cv_broadcast(&ct->ct_powerchange_cv);
6803 if (ct->ct_power_cnt == 0) {
6804 ret = i_mdi_power_all_phci(ct);
6808 i_mdi_pm_hold_client(ct, ct->ct_path_count);
6814 i_mdi_pm_rele_client(ct, ct->ct_path_count);
6819 MDI_CLIENT_UNLOCK(ct);
6827 mdi_client_t *ct;
6829 ct = i_devi_get_client(child);
6830 if (ct == NULL)
6833 MDI_CLIENT_LOCK(ct);
6834 while (MDI_CLIENT_IS_POWER_TRANSITION(ct))
6835 cv_wait(&ct->ct_powerchange_cv, &ct->ct_mutex);
6837 if (!MDI_CLIENT_IS_FAILED(ct)) {
6838 MDI_CLIENT_UNLOCK(ct);
6843 if (ct->ct_powercnt_config) {
6844 MDI_CLIENT_UNLOCK(ct);
6849 if (ct->ct_power_cnt == 0) {
6850 ret = i_mdi_power_all_phci(ct);
6853 i_mdi_pm_hold_client(ct, ct->ct_path_count);
6854 ct->ct_powercnt_config = 1;
6855 ct->ct_powercnt_reset = 0;
6856 MDI_CLIENT_UNLOCK(ct);
6894 mdi_client_t *ct;
6896 ct = i_devi_get_client(child);
6897 if (ct == NULL)
6900 MDI_CLIENT_LOCK(ct);
6901 while (MDI_CLIENT_IS_POWER_TRANSITION(ct))
6902 cv_wait(&ct->ct_powerchange_cv, &ct->ct_mutex);
6906 MDI_CLIENT_UNLOCK(ct);
6910 if (MDI_CLIENT_IS_POWERED_DOWN(ct) &&
6913 MDI_CLIENT_UNLOCK(ct);
6917 if (ct->ct_powercnt_unconfig) {
6919 MDI_CLIENT_UNLOCK(ct);
6924 if (ct->ct_power_cnt == 0) {
6925 ret = i_mdi_power_all_phci(ct);
6928 i_mdi_pm_hold_client(ct, ct->ct_path_count);
6929 ct->ct_powercnt_unconfig = 1;
6930 ct->ct_powercnt_reset = 0;
6931 MDI_CLIENT_UNLOCK(ct);
6974 mdi_client_t *ct;
6976 ct = i_devi_get_client(child);
6977 if (ct == NULL)
6980 MDI_CLIENT_LOCK(ct);
6981 while (MDI_CLIENT_IS_POWER_TRANSITION(ct))
6982 cv_wait(&ct->ct_powerchange_cv, &ct->ct_mutex);
6984 if (ct->ct_powercnt_reset || !ct->ct_powercnt_config) {
6986 MDI_CLIENT_UNLOCK(ct);
6991 if (MDI_CLIENT_IS_FAILED(ct)) {
6993 MDI_CLIENT_UNLOCK(ct);
6998 if ((MDI_CLIENT_IS_POWERED_DOWN(ct) &&
7003 i_mdi_pm_reset_client(ct);
7009 pip = ct->ct_path_head;
7018 i_mdi_pm_rele_client(ct, valid_path_count);
7020 ct->ct_powercnt_config = 0;
7021 MDI_CLIENT_UNLOCK(ct);
7054 mdi_client_t *ct;
7056 ct = i_devi_get_client(child);
7057 if (ct == NULL)
7060 MDI_CLIENT_LOCK(ct);
7061 while (MDI_CLIENT_IS_POWER_TRANSITION(ct))
7062 cv_wait(&ct->ct_powerchange_cv, &ct->ct_mutex);
7064 if (!ct->ct_powercnt_unconfig || ct->ct_powercnt_reset) {
7066 MDI_CLIENT_UNLOCK(ct);
7071 if ((MDI_CLIENT_IS_POWERED_DOWN(ct) &&
7076 i_mdi_pm_reset_client(ct);
7082 pip = ct->ct_path_head;
7091 i_mdi_pm_rele_client(ct, valid_path_count);
7092 ct->ct_powercnt_unconfig = 0;
7095 MDI_CLIENT_UNLOCK(ct);
7133 mdi_client_t *ct;
7175 ct = i_devi_get_client(client_dip);
7176 MDI_CLIENT_LOCK(ct);
7179 if (ct->ct_power_cnt == 0) {
7180 (void) i_mdi_power_all_phci(ct);
7183 i_mdi_pm_hold_client(ct, ct->ct_path_count);
7189 i_mdi_pm_rele_client(ct, ct->ct_path_count);
7193 i_mdi_pm_reset_client(ct);
7197 MDI_CLIENT_UNLOCK(ct);
7266 mdi_client_t *ct;
7267 ct = i_devi_get_client(dip);
7268 return (ct->ct_vprivate);
7278 mdi_client_t *ct;
7279 ct = i_devi_get_client(dip);
7280 ct->ct_vprivate = data;
7356 i_mdi_client_all_devices_removed(mdi_client_t *ct)
7361 MDI_CLIENT_LOCK(ct);
7362 for (pip = ct->ct_path_head; pip;
7369 MDI_CLIENT_UNLOCK(ct);
7379 mdi_client_t *ct;
7394 ct = MDI_PI(pip)->pi_client;
7395 if (ct && ct->ct_dip && i_mdi_client_all_devices_removed(ct))
7396 (void) ndi_devi_device_remove(ct->ct_dip);
8200 mdi_client_t *ct = pip->pi_client;
8206 if ((cct = lookup_vhcache_client(vhcache, ct->ct_drvname, ct->ct_guid,
8209 cct->cct_name_addr = vhcache_mknameaddr(ct->ct_drvname,
8210 ct->ct_guid, NULL);
8254 mdi_client_t *ct = pip->pi_client;
8259 if ((cct = lookup_vhcache_client(vhcache, ct->ct_drvname, ct->ct_guid,
9504 mdi_client_t *ct;
9509 ct = i_devi_get_client(cdip);
9510 MDI_CLIENT_LOCK(ct);
9517 MDI_CLIENT_UNLOCK(ct);