Lines Matching defs:phyp

1412 pmcs_deregister_devices(pmcs_hw_t *pwp, pmcs_phy_t *phyp)
1419 while (phyp) {
1420 if (phyp->children) {
1421 pmcs_deregister_devices(pwp, phyp->children);
1423 pmcs_lock_phy(phyp);
1424 if (phyp->valid_device_id) {
1425 pmcs_deregister_device(pwp, phyp);
1427 pmcs_unlock_phy(phyp);
1428 phyp = phyp->sibling;
2879 * Called with phyp (and all descendents) locked
2883 pmcs_phy_t *phyp)
2894 lphyp = phyp;
3166 pmcs_phy_t *pnext, *phyp;
3168 phyp = pptr;
3169 while (phyp) {
3170 if (IS_ROOT_PHY(phyp)) {
3171 pmcs_lock_phy(phyp);
3174 if ((phyp->dtype != EXPANDER) && phyp->dead) {
3175 pmcs_clear_phy(pwp, phyp);
3178 if (phyp->children) {
3179 pmcs_clear_phys(pwp, phyp->children);
3182 pnext = phyp->sibling;
3184 if (IS_ROOT_PHY(phyp)) {
3185 pmcs_unlock_phy(phyp);
3188 phyp = pnext;
4005 pmcs_phy_t *phyp, *pnext, *pchild;
4013 phyp = pptr;
4014 while (phyp) {
4015 pmcs_lock_phy(phyp);
4017 if ((phyp->dtype == EXPANDER) && phyp->changed &&
4018 !phyp->dead && !phyp->subsidiary &&
4019 phyp->configured) {
4020 pmcs_check_expander(pwp, phyp);
4023 pnext = phyp->sibling;
4024 pmcs_unlock_phy(phyp);
4025 phyp = pnext;
4031 phyp = pptr;
4032 while (phyp) {
4033 pmcs_lock_phy(phyp);
4034 pnext = phyp->sibling;
4035 pchild = phyp->children;
4036 pmcs_unlock_phy(phyp);
4042 phyp = pnext;
4715 pmcs_gwork(pmcs_hw_t *pwp, uint32_t tag_type, pmcs_phy_t *phyp)
4762 if (phyp) {
4763 p->phy = phyp;
4764 pmcs_inc_phy_ref_count(phyp);
4823 pmcs_phy_t *phyp;
4831 phyp = p->phy;
4832 if (phyp != NULL) {
4835 mutex_enter(&phyp->phy_lock);
4843 if (phyp != NULL) {
4845 mutex_exit(&phyp->phy_lock);
4847 pmcs_prt(pwp, PMCS_PRT_DEBUG, phyp, NULL, "%s: "
5718 pmcs_validate_devid(pmcs_phy_t *parent, pmcs_phy_t *phyp, uint32_t device_id)
5726 if (pptr->valid_device_id && (pptr != phyp) &&
5736 if ((phyp->parent == pptr->parent) &&
5737 (memcmp(phyp->sas_address,
5738 pptr->sas_address, 8) == 0) && (phyp->width > 1)) {
5744 phyp->children = pptr->children;
5745 pchild = phyp->children;
5747 pchild->parent = phyp;
5750 phyp->subsidiary = 0;
5751 phyp->ncphy = pptr->ncphy;
5763 phyp->path);
5768 "device id 0x%x", __func__, phyp->path,
5774 rval = pmcs_validate_devid(pptr->children, phyp,
5792 pmcs_find_phy_by_wwn_impl(pmcs_phy_t *phyp, uint8_t *wwn)
5796 ASSERT(!mutex_owned(&phyp->phy_lock));
5798 while (phyp) {
5799 pmcs_lock_phy(phyp);
5801 if (phyp->valid_device_id) {
5802 if (memcmp(phyp->sas_address, wwn, 8) == 0) {
5803 return (phyp);
5807 if (phyp->children) {
5808 cphyp = phyp->children;
5809 pmcs_unlock_phy(phyp);
5815 pmcs_lock_phy(phyp);
5821 if (IS_ROOT_PHY(phyp)) {
5822 pmcs_unlock_phy(phyp);
5823 phyp = NULL;
5825 nphyp = phyp->sibling;
5826 pmcs_unlock_phy(phyp);
5827 phyp = nphyp;
5964 * If phyp == NULL we're being called from the worker thread, in which
5967 * If phyp is non-NULL, just issue the spinup release for the specified PHY
5971 pmcs_spinup_release(pmcs_hw_t *pwp, pmcs_phy_t *phyp)
5977 if (phyp != NULL) {
5978 ASSERT(mutex_owned(&phyp->phy_lock));
5979 pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, NULL,
5981 phyp->path);
5991 phyp->spinup_hold = 0;
5997 msg[2] = LE_32((0x10 << 8) | phyp->phynum);
5999 pwrk->dtype = phyp->dtype;
6001 pwrk->xp = phyp->target;
6055 pmcs_kill_devices(pmcs_hw_t *pwp, pmcs_phy_t *phyp)
6061 while (phyp) {
6062 pmcs_lock_phy(phyp);
6063 pchild = phyp->children;
6064 pnext = phyp->sibling;
6065 pmcs_unlock_phy(phyp);
6075 pmcs_lock_phy(phyp);
6076 if (phyp->dead && phyp->valid_device_id) {
6083 pmcs_remove_device(pwp, phyp);
6086 rval = pmcs_kill_device(pwp, phyp);
6088 pmcs_unlock_phy(phyp);
6095 pmcs_unlock_phy(phyp);
6096 phyp = pnext;
7245 * lock all PHYs from phyp down in a top-down fashion.
7260 pmcs_lock_phy_impl(pmcs_phy_t *phyp, int level)
7264 ASSERT((phyp->dtype == SAS) || (phyp->dtype == SATA) ||
7265 (phyp->dtype == EXPANDER) || (phyp->dtype == NOTHING));
7270 tphyp = phyp;
7276 if ((level > 0) || (tphyp == phyp)) {
7302 pmcs_lock_phy(pmcs_phy_t *phyp)
7308 ASSERT(phyp != NULL);
7313 pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING, phyp, NULL,
7315 (void *)phyp, phyp->path);
7317 pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING, phyp, NULL,
7319 (void *)phyp, phyp->path, callername, off);
7322 pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING, phyp, NULL,
7323 "%s: PHY 0x%p path %s", __func__, (void *)phyp, phyp->path);
7325 pmcs_lock_phy_impl(phyp, 0);
7331 * Unlock all PHYs from phyp down in a bottom-up fashion.
7334 pmcs_unlock_phy_impl(pmcs_phy_t *phyp, int level)
7338 ASSERT((phyp->dtype == SAS) || (phyp->dtype == SATA) ||
7339 (phyp->dtype == EXPANDER) || (phyp->dtype == NOTHING));
7345 if (phyp->children) {
7346 pmcs_unlock_phy_impl(phyp->children, level + 1);
7349 phy_next = phyp;
7362 phy_next = phyp;
7364 if ((level > 0) || (phy_next == phyp)) {
7387 pmcs_unlock_phy(pmcs_phy_t *phyp)
7393 ASSERT(phyp != NULL);
7398 pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING, phyp, NULL,
7400 (void *)phyp, phyp->path);
7402 pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING, phyp, NULL,
7404 (void *)phyp, phyp->path, callername, off);
7407 pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING, phyp, NULL,
7408 "%s: PHY 0x%p path %s", __func__, (void *)phyp, phyp->path);
7410 pmcs_unlock_phy_impl(phyp, 0);
7418 * the chain of PHYs from phyp up to the root PHY doesn't change.
7421 pmcs_get_root_phy(pmcs_phy_t *phyp)
7423 ASSERT(phyp);
7425 while (phyp) {
7426 if (IS_ROOT_PHY(phyp)) {
7429 phyp = phyp->parent;
7432 return (phyp);
7467 pmcs_phy_t *phyp = (pmcs_phy_t *)buf;
7469 mutex_init(&phyp->phy_lock, NULL, MUTEX_DRIVER,
7471 cv_init(&phyp->abort_all_cv, NULL, CV_DRIVER, NULL);
7479 pmcs_phy_t *phyp = (pmcs_phy_t *)buf;
7481 cv_destroy(&phyp->abort_all_cv);
7482 mutex_destroy(&phyp->phy_lock);
7486 * Free all PHYs from the kmem_cache starting at phyp as well as everything
7496 pmcs_free_all_phys(pmcs_hw_t *pwp, pmcs_phy_t *phyp)
7500 if (phyp == NULL) {
7504 for (tphyp = phyp; tphyp; tphyp = nphyp) {
7535 pmcs_free_phys(pmcs_hw_t *pwp, pmcs_phy_t *phyp)
7539 while (phyp) {
7540 next_phy = phyp->sibling;
7541 ASSERT(!mutex_owned(&phyp->phy_lock));
7542 phyp->target_addr = NULL;
7543 kmem_cache_free(pwp->phy_cache, phyp);
7544 phyp = next_phy;
7705 pmcs_phy_t *phyp, *nphyp, *pphyp;
7720 phyp = pwp->dead_phys;
7723 while (phyp != NULL) {
7724 pmcs_lock_phy(phyp);
7725 ASSERT(phyp->dead);
7727 nphyp = phyp->dead_next;
7732 if (phyp->ref_count > 0) {
7733 pmcs_unlock_phy(phyp);
7734 pphyp = phyp; /* This PHY becomes "previous" */
7735 } else if (phyp->target) {
7736 pmcs_unlock_phy(phyp);
7737 pmcs_prt(pwp, PMCS_PRT_DEBUG1, phyp, phyp->target,
7739 __func__, (void *)phyp, (void *)phyp->target);
7740 pphyp = phyp;
7746 pmcs_prt(pwp, PMCS_PRT_DEBUG, phyp, phyp->target,
7748 "target = 0x%p", __func__, (void *)phyp,
7749 phyp->path, (void *)phyp->target);
7751 * If pphyp is NULL, then phyp was the head of the list,
7764 if (phyp->target) {
7765 mutex_enter(&phyp->target->statlock);
7766 if (phyp->target->phy == phyp) {
7767 phyp->target->phy = NULL;
7769 mutex_exit(&phyp->target->statlock);
7771 pmcs_unlock_phy(phyp);
7772 phyp->target_addr = NULL;
7773 kmem_cache_free(pwp->phy_cache, phyp);
7776 phyp = nphyp;
7785 pmcs_inc_phy_ref_count(pmcs_phy_t *phyp)
7787 atomic_inc_32(&phyp->ref_count);
7791 pmcs_dec_phy_ref_count(pmcs_phy_t *phyp)
7793 ASSERT(phyp->ref_count != 0);
7794 atomic_dec_32(&phyp->ref_count);
7810 pmcs_reap_dead_phy(pmcs_phy_t *phyp)
7812 pmcs_hw_t *pwp = phyp->pwp;
7816 ASSERT(mutex_owned(&phyp->phy_lock));
7833 if ((iport_cmp != phyp->iport) ||
7835 (void *)&phyp->sas_address[0], 8))) {
7846 if ((strnlen(phyp->path, 5) >= 5) &&
7848 if (memcmp((void *)&phyp->path[5],
7850 strnlen(phyp->path, 32) - 5) == 0) {
7867 __func__, (void *)ctmp, phyp->path);
7874 phyp->target = ctmp->target;
7877 pmcs_inc_phy_ref_count(phyp);
7883 phyp->target->phy = phyp;
7884 phyp->target->dtype = phyp->dtype;
7886 mutex_exit(&phyp->target->statlock);
7895 pmcs_add_phy_to_iport(pmcs_iport_t *iport, pmcs_phy_t *phyp)
7898 ASSERT(phyp);
7899 ASSERT(!list_link_active(&phyp->list_node));
7902 list_insert_tail(&iport->phys, phyp);
7905 mutex_enter(&phyp->phy_lock);
7906 pmcs_create_one_phy_stats(iport, phyp);
7907 mutex_exit(&phyp->phy_lock);
7915 pmcs_remove_phy_from_iport(pmcs_iport_t *iport, pmcs_phy_t *phyp)
7922 * If phyp is NULL, remove all PHYs from the iport
7924 if (phyp == NULL) {
7946 ASSERT(phyp);
7948 ASSERT(list_link_active(&phyp->list_node));
7950 list_remove(&iport->phys, phyp);
7951 pmcs_update_phy_pm_props(phyp, phyp->att_port_pm_tmp,
7952 phyp->tgt_port_pm_tmp, B_FALSE);
7959 * This function checks to see if the target pointed to by phyp is still
7961 * SAS address in phyp.
7966 pmcs_phy_target_match(pmcs_phy_t *phyp)
7972 ASSERT(phyp);
7973 ASSERT(phyp->target);
7974 ASSERT(mutex_owned(&phyp->phy_lock));
7975 ASSERT(mutex_owned(&phyp->target->statlock));
7977 wwn = pmcs_barray2wwn(phyp->sas_address);
7980 if (memcmp((void *)unit_address, (void *)phyp->target->unit_address,
7981 strnlen(phyp->target->unit_address, PMCS_MAX_UA_SIZE)) == 0) {
8044 * phyp: PHY whose properties are to be updated
8057 pmcs_update_phy_pm_props(pmcs_phy_t *phyp, uint64_t att_bv, uint64_t tgt_bv,
8067 if (phyp->att_port_pm_tmp == 0) {
8068 phyp->att_port_pm = att_bv;
8069 phyp->tgt_port_pm = tgt_bv;
8071 phyp->att_port_pm_tmp |= att_bv;
8072 phyp->tgt_port_pm_tmp |= tgt_bv;
8073 (void) snprintf(phyp->att_port_pm_str, PMCS_PM_MAX_NAMELEN,
8074 "%"PRIx64, phyp->att_port_pm_tmp);
8075 (void) snprintf(phyp->tgt_port_pm_str, PMCS_PM_MAX_NAMELEN,
8076 "%"PRIx64, phyp->tgt_port_pm_tmp);
8078 phyp->att_port_pm_tmp &= ~att_bv;
8079 phyp->tgt_port_pm_tmp &= ~tgt_bv;
8080 if (phyp->att_port_pm_tmp) {
8081 (void) snprintf(phyp->att_port_pm_str,
8083 phyp->att_port_pm_tmp);
8085 phyp->att_port_pm_str[0] = '\0';
8086 phyp->att_port_pm = 0;
8088 if (phyp->tgt_port_pm_tmp) {
8089 (void) snprintf(phyp->tgt_port_pm_str,
8091 phyp->tgt_port_pm_tmp);
8093 phyp->tgt_port_pm_str[0] = '\0';
8094 phyp->tgt_port_pm = 0;
8098 if ((phyp->target_addr) && (*phyp->target_addr != NULL)) {
8099 tgt = *phyp->target_addr;
8100 } else if (phyp->target != NULL) {
8101 tgt = phyp->target;
8115 phyp->att_port_pm_str);
8119 phyp->tgt_port_pm_str);
8125 phyp->att_port_pm_str);
8128 phyp->tgt_port_pm_str);
8135 pmcs_deregister_device_work(pmcs_hw_t *pwp, pmcs_phy_t *phyp)
8206 pmcs_phy_t *phyp;
8211 phyp = pmcs_find_phy_by_sas_address(iport->pwp, iport, NULL, tgt_addr);
8212 if (phyp == NULL) {
8217 /* phyp is locked */
8219 if (!phyp->reenumerate && phyp->configured) {
8220 pmcs_prt(iport->pwp, PMCS_PRT_DEBUG_CONFIG, phyp, phyp->target,
8223 phyp->reenumerate = 1;
8230 if (phyp->reenumerate) {
8231 if (phyp->enum_attempts == PMCS_MAX_REENUMERATE) {
8232 pmcs_prt(iport->pwp, PMCS_PRT_DEBUG_CONFIG, phyp,
8233 phyp->target,
8237 pmcs_prt(iport->pwp, PMCS_PRT_DEBUG_CONFIG, phyp,
8238 phyp->target, "%s: Re-attempt enumeration for %s",
8240 ++phyp->enum_attempts;
8244 phyp->reenumerate = 0;
8247 pmcs_unlock_phy(phyp);
8270 pmcs_status_disposition(pmcs_phy_t *phyp, uint32_t status)
8272 ASSERT(phyp);
8273 ASSERT(!mutex_owned(&phyp->phy_lock));
8275 if (phyp == NULL) {
8279 pmcs_lock_phy(phyp);
8306 pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG, phyp, phyp->target,
8308 __func__, status, SAS_ADDR_PRT(phyp->sas_address));
8309 phyp->reenumerate = 1;
8313 pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG, phyp, phyp->target,
8315 __func__, status, SAS_ADDR_PRT(phyp->sas_address));
8319 pmcs_unlock_phy(phyp);
8323 * Add the list of PHYs pointed to by phyp to the dead_phys_list
8328 pmcs_add_dead_phys(pmcs_hw_t *pwp, pmcs_phy_t *phyp)
8331 while (phyp) {
8332 pmcs_phy_t *nxt = phyp->sibling;
8333 ASSERT(phyp->dead);
8334 pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, NULL,
8336 (void *)phyp, phyp->path, phyp->ref_count);
8341 phyp->dead_next = pwp->dead_phys;
8342 pwp->dead_phys = phyp;
8343 pmcs_unlock_phy(phyp);
8344 phyp = nxt;