Lines Matching defs:pd

1805 	fc_remote_port_t	*pd;
1841 pd = head->pwwn_head;
1842 while (pd != NULL) {
1843 mutex_enter(&pd->pd_mutex);
1844 fp_remote_port_offline(pd);
1845 fctl_delist_did_table(port, pd);
1846 pd->pd_state = PORT_DEVICE_VALID;
1847 pd->pd_login_count = 0;
1848 mutex_exit(&pd->pd_mutex);
1849 pd = pd->pd_wwn_hnext;
1954 * fp_alloc_pkt() must be called with pd set to NULL.
1966 fc_remote_port_t *pd)
2006 pkt->pkt_pd = pd;
2257 fc_remote_port_t *pd;
2411 pd = fctl_get_remote_port_by_did(port, *d_id);
2413 if (pd) {
2414 mutex_enter(&pd->pd_mutex);
2415 if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
2416 pd->pd_login_count++;
2417 mutex_exit(&pd->pd_mutex);
2422 mutex_exit(&pd->pd_mutex);
2427 pd = fp_create_remote_port_by_ns(port,
2429 if (pd == NULL) {
2443 FP_CMD_PLOGI_RETAIN, KM_SLEEP, pd, NULL);
2457 fc_remote_port_t *pd;
2463 pd = (fc_remote_port_t *)job->job_ulp_pkts;
2465 mutex_enter(&pd->pd_mutex);
2466 if (pd->pd_state != PORT_DEVICE_LOGGED_IN) {
2467 mutex_exit(&pd->pd_mutex);
2473 if (pd->pd_login_count > 1) {
2474 pd->pd_login_count--;
2475 mutex_exit(&pd->pd_mutex);
2481 mutex_exit(&pd->pd_mutex);
2484 (void) fp_logout(port, pd, job);
2949 fc_remote_port_t *pd;
2977 pd = fctl_create_remote_port(port,
2983 " P2P port=%p pd=%p fp %x pd %x", port, pd,
3522 fc_remote_port_t *pd = cmd->cmd_pkt.pkt_pd;
3534 if (pd) {
3535 mutex_enter(&pd->pd_mutex);
3536 pd->pd_flags = PD_IDLE;
3537 mutex_exit(&pd->pd_mutex);
3541 if (pd && cmd->cmd_flags & FP_CMD_DELDEV_ON_ERROR &&
3548 mutex_enter(&pd->pd_mutex);
3549 pd->pd_state = PORT_DEVICE_INVALID;
3550 pd->pd_ref_count--;
3551 node = pd->pd_remote_nodep;
3552 mutex_exit(&pd->pd_mutex);
3557 if (fctl_destroy_remote_port(port, pd) == 0) {
3615 fc_remote_port_t *pd;
3670 pd = head->pwwn_head;
3671 while (pd != NULL) {
3672 mutex_enter(&pd->pd_mutex);
3673 if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
3676 mutex_exit(&pd->pd_mutex);
3677 pd = pd->pd_wwn_hnext;
3692 pd = head->pwwn_head;
3693 while (pd != NULL) {
3694 mutex_enter(&pd->pd_mutex);
3695 if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
3696 ASSERT(pd->pd_login_count > 0);
3701 pd->pd_login_count = 1;
3702 mutex_exit(&pd->pd_mutex);
3704 (void) fp_logout(port, pd, job);
3707 mutex_exit(&pd->pd_mutex);
3709 pd = pd->pd_wwn_hnext;
3754 fc_remote_port_t *pd;
3793 pd = fctl_get_remote_port_by_did(port, d_id);
3794 if (pd) {
3795 mutex_enter(&pd->pd_mutex);
3797 pd->pd_state == PORT_DEVICE_LOGGED_IN) {
3798 mutex_exit(&pd->pd_mutex);
3802 mutex_exit(&pd->pd_mutex);
3806 KM_SLEEP, pd, NULL);
3827 fc_remote_port_t *pd;
3857 pd = fctl_get_remote_port_by_did(port, d_id);
3858 if (pd != NULL) {
3860 mutex_enter(&pd->pd_mutex);
3861 if (pd->pd_recepient == PD_PLOGI_INITIATOR) {
3862 ASSERT(pd->pd_type != PORT_DEVICE_OLD);
3864 mutex_exit(&pd->pd_mutex);
3871 FP_CMD_PLOGI_DONT_CARE, KM_SLEEP, pd, NULL);
4049 int cmd_flag, int sleep, fc_remote_port_t *pd, fc_packet_t *ulp_pkt)
4059 if (pd == NULL) {
4115 sizeof (la_els_logi_t), sleep, pd);
4134 if (pd) {
4135 mutex_enter(&pd->pd_mutex);
4136 pd->pd_flags = PD_ELS_IN_PROGRESS;
4137 mutex_exit(&pd->pd_mutex);
4156 if (pd) {
4157 mutex_enter(&pd->pd_mutex);
4158 pd->pd_flags = PD_IDLE;
4159 mutex_exit(&pd->pd_mutex);
4182 fp_register_login(ddi_acc_handle_t *handle, fc_remote_port_t *pd,
4187 ASSERT(pd != NULL);
4189 mutex_enter(&pd->pd_mutex);
4190 node = pd->pd_remote_nodep;
4191 if (pd->pd_login_count == 0) {
4192 pd->pd_login_count++;
4196 FC_GET_RSP(pd->pd_port, *handle, (uint8_t *)&pd->pd_csp,
4199 FC_GET_RSP(pd->pd_port, *handle, (uint8_t *)&pd->pd_clsp1,
4202 FC_GET_RSP(pd->pd_port, *handle, (uint8_t *)&pd->pd_clsp2,
4205 FC_GET_RSP(pd->pd_port, *handle, (uint8_t *)&pd->pd_clsp3,
4209 pd->pd_csp = acc->common_service;
4210 pd->pd_clsp1 = acc->class_1;
4211 pd->pd_clsp2 = acc->class_2;
4212 pd->pd_clsp3 = acc->class_3;
4215 pd->pd_state = PORT_DEVICE_LOGGED_IN;
4216 pd->pd_login_class = class;
4217 mutex_exit(&pd->pd_mutex);
4220 ASSERT(fctl_get_remote_port_by_did(pd->pd_port,
4221 pd->pd_port_id.port_id) == pd);
4226 FC_GET_RSP(pd->pd_port, *handle, (uint8_t *)node->fd_vv,
4240 fp_remote_port_offline(fc_remote_port_t *pd)
4242 ASSERT(MUTEX_HELD(&pd->pd_mutex));
4243 if (pd->pd_login_count &&
4244 ((pd->pd_aux_flags & PD_DISABLE_RELOGIN) == 0)) {
4245 bzero((caddr_t)&pd->pd_csp, sizeof (struct common_service));
4246 bzero((caddr_t)&pd->pd_clsp1, sizeof (struct service_param));
4247 bzero((caddr_t)&pd->pd_clsp2, sizeof (struct service_param));
4248 bzero((caddr_t)&pd->pd_clsp3, sizeof (struct service_param));
4249 pd->pd_login_class = 0;
4251 pd->pd_type = PORT_DEVICE_OLD;
4252 pd->pd_flags = PD_IDLE;
4253 fctl_tc_reset(&pd->pd_logo_tc);
4261 fp_unregister_login(fc_remote_port_t *pd)
4265 ASSERT(pd != NULL);
4267 mutex_enter(&pd->pd_mutex);
4268 pd->pd_login_count = 0;
4269 bzero((caddr_t)&pd->pd_csp, sizeof (struct common_service));
4270 bzero((caddr_t)&pd->pd_clsp1, sizeof (struct service_param));
4271 bzero((caddr_t)&pd->pd_clsp2, sizeof (struct service_param));
4272 bzero((caddr_t)&pd->pd_clsp3, sizeof (struct service_param));
4274 pd->pd_state = PORT_DEVICE_VALID;
4275 pd->pd_login_class = 0;
4276 node = pd->pd_remote_nodep;
4277 mutex_exit(&pd->pd_mutex);
4295 fc_remote_port_t *pd;
4301 pd = head->pwwn_head;
4302 while (pd != NULL) {
4303 mutex_enter(&pd->pd_mutex);
4304 fp_remote_port_offline(pd);
4305 fctl_delist_did_table(port, pd);
4306 mutex_exit(&pd->pd_mutex);
4307 pd = pd->pd_wwn_hnext;
4463 fp_logo_init(fc_remote_port_t *pd, fp_cmd_t *cmd, job_request_t *job)
4469 port = pd->pd_port;
4472 ASSERT(MUTEX_HELD(&pd->pd_mutex));
4474 fp_els_init(cmd, port->fp_port_id.port_id, pd->pd_port_id.port_id,
4479 pkt->pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4500 fc_remote_port_t *pd;
4503 pd = pkt->pkt_pd;
4504 port = pd->pd_port;
4507 ASSERT(MUTEX_HELD(&pd->pd_mutex));
4509 fp_els_init(cmd, port->fp_port_id.port_id, pd->pd_port_id.port_id,
4513 pkt->pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4533 fc_remote_port_t *pd;
4536 pd = pkt->pkt_pd;
4537 port = pd->pd_port;
4540 ASSERT(MUTEX_HELD(&pd->pd_mutex));
4542 fp_els_init(cmd, port->fp_port_id.port_id, pd->pd_port_id.port_id,
4546 pkt->pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4567 fc_remote_port_t *pd;
4570 pd = pkt->pkt_pd;
4571 port = pd->pd_port;
4573 ASSERT(MUTEX_HELD(&pd->pd_mutex));
4574 ASSERT(MUTEX_HELD(&pd->pd_port->fp_mutex));
4576 fp_els_init(cmd, port->fp_port_id.port_id, pd->pd_port_id.port_id,
4580 pkt->pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4604 fc_remote_port_t *pd;
4633 pd = clist->clist_map[count].map_pd;
4635 if (pd != NULL) {
4636 mutex_enter(&pd->pd_mutex);
4637 ASSERT((pd->pd_ref_count >= 0) ||
4638 (pd->pd_aux_flags & PD_GIVEN_TO_ULPS));
4639 pd->pd_ref_count++;
4643 pd->pd_aux_flags |= PD_GIVEN_TO_ULPS;
4646 mutex_exit(&pd->pd_mutex);
4662 pd = clist->clist_map[count].map_pd;
4663 ASSERT(pd != NULL);
4665 mutex_enter(&pd->pd_mutex);
4666 pwwn = pd->pd_port_name;
4667 d_id = pd->pd_port_id;
4668 mutex_exit(&pd->pd_mutex);
4670 pd = fctl_get_remote_port_by_pwwn(port, &pwwn);
4671 ASSERT(pd != clist->clist_map[count].map_pd);
4673 pd = fctl_get_remote_port_by_did(port,
4675 ASSERT(pd != clist->clist_map[count].map_pd);
4733 fc_remote_port_t *pd;
4737 pd = clist->clist_map[count].map_pd;
4745 if (pd) {
4746 mutex_enter(&pd->pd_mutex);
4747 ASSERT((pd->pd_ref_count >= 0) ||
4748 (pd->pd_aux_flags & PD_GIVEN_TO_ULPS));
4749 pd->pd_ref_count++;
4750 mutex_exit(&pd->pd_mutex);
4800 mutex_enter(&pd->pd_mutex);
4801 pd->pd_aux_flags |= PD_GIVEN_TO_ULPS;
4802 mutex_exit(&pd->pd_mutex);
4809 if (pd && clist->clist_map[count].map_state ==
4814 mutex_enter(&pd->pd_mutex);
4815 pwwn = pd->pd_port_name;
4816 d_id = pd->pd_port_id;
4817 mutex_exit(&pd->pd_mutex);
4820 * This overwrites the 'pd' local variable.
4821 * Beware of this if 'pd' ever gets
4824 pd = fctl_get_remote_port_by_pwwn(port, &pwwn);
4825 ASSERT(pd != clist->clist_map[count].map_pd);
4827 pd = fctl_get_remote_port_by_did(port,
4829 ASSERT(pd != clist->clist_map[count].map_pd);
4882 fc_remote_port_t *pd;
4905 pd = ulp_pkt->pkt_pd;
4922 if (pd == NULL) {
4923 pd = fctl_get_remote_port_by_did(port, d_id);
4924 if (pd == NULL) {
4929 mutex_enter(&pd->pd_mutex);
4930 if (pd->pd_flags == PD_ELS_IN_PROGRESS) {
4931 mutex_exit(&pd->pd_mutex);
4939 mutex_exit(&pd->pd_mutex);
4959 * Validate the pd corresponding to the d_id passed
4963 if ((tmp_pd == NULL) || (pd != tmp_pd)) {
4975 "port=%p, pd=%p", port, pd);
4977 mutex_enter(&pd->pd_mutex);
4979 if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
4986 FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
4990 FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
4991 (uint8_t *)&pd->pd_csp,
4993 sizeof (pd->pd_csp), DDI_DEV_AUTOINCR);
4995 FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
4996 (uint8_t *)&pd->pd_port_name,
4998 sizeof (pd->pd_port_name), DDI_DEV_AUTOINCR);
5000 FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
5001 (uint8_t *)&pd->pd_clsp1,
5003 sizeof (pd->pd_clsp1), DDI_DEV_AUTOINCR);
5005 FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
5006 (uint8_t *)&pd->pd_clsp2,
5008 sizeof (pd->pd_clsp2), DDI_DEV_AUTOINCR);
5010 FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
5011 (uint8_t *)&pd->pd_clsp3,
5013 sizeof (pd->pd_clsp3), DDI_DEV_AUTOINCR);
5015 node = pd->pd_remote_nodep;
5016 pd->pd_login_count++;
5017 pd->pd_flags = PD_IDLE;
5018 ulp_pkt->pkt_pd = pd;
5019 mutex_exit(&pd->pd_mutex);
5022 FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
5027 FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
5037 mutex_exit(&pd->pd_mutex);
5069 pd = fctl_get_remote_port_by_did(port, d_id);
5073 * reference counter before we assign the pd
5076 if (pd != NULL && ulp_pkt->pkt_pd == NULL) {
5077 mutex_enter(&pd->pd_mutex);
5078 pd->pd_ref_count++;
5079 mutex_exit(&pd->pd_mutex);
5081 "fp_plogi_group: DID = 0x%x using new pd %p \
5082 old pd NULL\n", d_id, pd);
5083 } else if (pd != NULL && ulp_pkt->pkt_pd != NULL &&
5084 ulp_pkt->pkt_pd != pd) {
5085 mutex_enter(&pd->pd_mutex);
5086 pd->pd_ref_count++;
5087 mutex_exit(&pd->pd_mutex);
5092 "fp_plogi_group: DID = 0x%x pkt_pd %p != pd %p\n",
5093 d_id, ulp_pkt->pkt_pd, pd);
5094 } else if (pd == NULL && ulp_pkt->pkt_pd != NULL) {
5099 "fp_plogi_group: DID = 0x%x pd is NULL and \
5103 ulp_pkt->pkt_pd = pd;
5105 if (pd != NULL) {
5106 mutex_enter(&pd->pd_mutex);
5107 d_id = pd->pd_port_id.port_id;
5108 pd->pd_flags = PD_ELS_IN_PROGRESS;
5109 mutex_exit(&pd->pd_mutex);
5113 pd = fctl_get_remote_port_by_did(port, d_id);
5114 ASSERT(pd == NULL);
5125 pd = fp_create_remote_port_by_ns(port,
5127 if (pd) {
5130 mutex_enter(&pd->pd_mutex);
5131 pd->pd_flags = PD_ELS_IN_PROGRESS;
5132 mutex_exit(&pd->pd_mutex);
5137 " pd=%p", port, job, pd);
5142 if ((ulp_pkt->pkt_pd == NULL) && (pd != NULL)) {
5145 "ulp_pkt's pd is NULL, get a pd %p",
5146 pd);
5147 mutex_enter(&pd->pd_mutex);
5148 pd->pd_ref_count++;
5149 mutex_exit(&pd->pd_mutex);
5151 ulp_pkt->pkt_pd = pd;
5155 KM_SLEEP, pd, ulp_pkt);
5168 if (pd) {
5169 mutex_enter(&pd->pd_mutex);
5170 pd->pd_flags = PD_IDLE;
5171 mutex_exit(&pd->pd_mutex);
5175 ASSERT(pd != NULL);
5180 mutex_enter(&pd->pd_mutex);
5181 pd->pd_ref_count--;
5182 node = pd->pd_remote_nodep;
5183 mutex_exit(&pd->pd_mutex);
5187 if (fctl_destroy_remote_port(port, pd) == 0) {
5363 fp_ns_reg(fc_local_port_t *port, fc_remote_port_t *pd, uint16_t cmd_code,
5371 if (pd == NULL) {
5376 mutex_enter(&pd->pd_mutex);
5377 s_id = pd->pd_port_id;
5378 mutex_exit(&pd->pd_mutex);
5398 if (pd == NULL) {
5404 mutex_enter(&pd->pd_mutex);
5405 rxn.rxn_xname = pd->pd_port_name;
5406 mutex_exit(&pd->pd_mutex);
5410 mutex_enter(&pd->pd_mutex);
5411 node = pd->pd_remote_nodep;
5412 mutex_exit(&pd->pd_mutex);
5439 if (pd == NULL) {
5442 mutex_enter(&pd->pd_mutex);
5443 rcos.rcos_cos = pd->pd_cos;
5444 mutex_exit(&pd->pd_mutex);
5467 if (pd == NULL) {
5473 mutex_enter(&pd->pd_mutex);
5474 bcopy(pd->pd_fc4types, rfc.rfc_types,
5475 sizeof (pd->pd_fc4types));
5476 mutex_exit(&pd->pd_mutex);
5492 if (pd == NULL) {
5497 mutex_enter(&pd->pd_mutex);
5498 name_len = pd->pd_spn_len;
5499 mutex_exit(&pd->pd_mutex);
5523 if (pd == NULL) {
5531 mutex_enter(&pd->pd_mutex);
5533 (uint8_t *)pd->pd_spn,
5536 mutex_exit(&pd->pd_mutex);
5552 if (pd == NULL) {
5555 mutex_enter(&pd->pd_mutex);
5556 rpt.rpt_type = pd->pd_porttype;
5557 mutex_exit(&pd->pd_mutex);
5579 if (pd == NULL) {
5594 mutex_enter(&pd->pd_mutex);
5595 node = pd->pd_remote_nodep;
5596 bcopy(pd->pd_ip_addr, rip.rip_ip_addr,
5597 sizeof (pd->pd_ip_addr));
5598 mutex_exit(&pd->pd_mutex);
5623 if (pd == NULL) {
5631 mutex_enter(&pd->pd_mutex);
5632 node = pd->pd_remote_nodep;
5633 mutex_exit(&pd->pd_mutex);
5655 if (pd == NULL) {
5660 mutex_enter(&pd->pd_mutex);
5661 node = pd->pd_remote_nodep;
5662 mutex_exit(&pd->pd_mutex);
5683 if (pd == NULL) {
5859 fc_remote_port_t *pd;
5935 "pd %x", port->fp_port_id.port_id, d_id);
5936 pd = fctl_create_remote_port(port,
5939 if (pd == NULL) {
5956 (&cmd->cmd_pkt)->pkt_pd = pd;
5966 pd->pd_ref_count++;
5967 pd->pd_aux_flags |= PD_GIVEN_TO_ULPS;
6019 fc_remote_port_t *pd;
6075 * This pd is marked as plogi
6092 if ((pd = fctl_get_remote_port_by_did(port, d_id)) != NULL) {
6093 mutex_enter(&pd->pd_mutex);
6094 if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
6097 mutex_exit(&pd->pd_mutex);
6161 if ((pd = pkt->pkt_pd) == NULL) {
6162 pd = fctl_get_remote_port_by_pwwn(port, &pwwn);
6163 if (pd == NULL) {
6164 FP_TRACE(FP_NHEAD2(1, 0), "fp_plogi_intr: fp %x pd %x",
6166 pd = fctl_create_remote_port(port, &nwwn, &pwwn, d_id,
6168 if (pd == NULL) {
6185 mutex_enter(&pd->pd_mutex);
6186 if ((pd->pd_state == PORT_DEVICE_LOGGED_IN) ||
6187 (pd->pd_aux_flags & PD_LOGGED_OUT)) {
6191 if (pd->pd_type == PORT_DEVICE_OLD) {
6192 if (pd->pd_port_id.port_id != d_id) {
6193 fctl_delist_did_table(port, pd);
6194 pd->pd_type = PORT_DEVICE_CHANGED;
6195 pd->pd_port_id.port_id = d_id;
6197 pd->pd_type = PORT_DEVICE_NOCHANGE;
6201 if (pd->pd_aux_flags & PD_IN_DID_QUEUE) {
6204 fc_wwn_to_str(&pd->pd_port_name, ww_name);
6206 mutex_exit(&pd->pd_mutex);
6216 fctl_enlist_did_table(port, pd);
6217 pd->pd_aux_flags &= ~PD_LOGGED_OUT;
6218 mutex_exit(&pd->pd_mutex);
6228 mutex_enter(&pd->pd_mutex);
6229 if (fctl_wwn_cmp(&pd->pd_port_name, &pwwn) == 0) {
6231 " pd_state=%x pd_type=%x", d_id, pd->pd_state,
6232 pd->pd_type);
6233 if ((pd->pd_state == PORT_DEVICE_LOGGED_IN &&
6234 pd->pd_type == PORT_DEVICE_OLD) ||
6235 (pd->pd_aux_flags & PD_LOGGED_OUT)) {
6236 pd->pd_type = PORT_DEVICE_NOCHANGE;
6237 } else if (pd->pd_state != PORT_DEVICE_LOGGED_IN) {
6238 pd->pd_type = PORT_DEVICE_NEW;
6244 fc_wwn_to_str(&pd->pd_port_name, old_name);
6250 "pd:%p new_wwn_pd:%p, cmd_ulp_pkt:%p, bailout:0x%x",
6251 d_id, new_name, old_name, tmp_pd, pd, new_wwn_pd,
6266 fctl_delist_pwwn_table(port, pd);
6269 * Lets now check if there already is a pd with
6276 * There is another pd with in the pwwn
6280 * pd's state (fp_fillout_old_map does
6289 if (tmp_pd != pd) {
6331 * should not find that these two pd's
6334 if (tmp_pd != pd) {
6357 * Now add "pd" (not tmp_pd)
6361 * pd->pd_mutex is already held
6364 fctl_enlist_did_table(port, pd);
6373 fp_fillout_changed_map(listptr, pd, &d_id,
6375 fctl_enlist_pwwn_table(port, pd);
6377 mutex_exit(&pd->pd_mutex);
6389 if (pd->pd_porttype.port_type == FC_NS_PORT_NL) {
6392 if (pd->pd_aux_flags & PD_DISABLE_RELOGIN) {
6393 pd->pd_aux_flags &= ~PD_LOGGED_OUT;
6396 mutex_exit(&pd->pd_mutex);
6401 mutex_enter(&pd->pd_mutex);
6402 if (pd->pd_aux_flags & PD_IN_DID_QUEUE) {
6405 fc_wwn_to_str(&pd->pd_port_name, ww_name);
6406 mutex_exit(&pd->pd_mutex);
6416 fctl_enlist_did_table(port, pd);
6417 pd->pd_aux_flags &= ~PD_LOGGED_OUT;
6418 mutex_exit(&pd->pd_mutex);
6422 fp_register_login(&pkt->pkt_resp_acc, pd, acc,
6430 if (pd != NULL) {
6433 "ulp_pkt's pd is NULL, get a pd %p",
6434 pd);
6435 mutex_enter(&pd->pd_mutex);
6436 pd->pd_ref_count++;
6437 mutex_exit(&pd->pd_mutex);
6439 cmd->cmd_ulp_pkt->pkt_pd = pd;
6451 mutex_enter(&pd->pd_mutex);
6453 cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
6464 pkt->pkt_pd = pd;
6465 pd->pd_ref_count++; /* It's in use! */
6473 mutex_exit(&pd->pd_mutex);
6485 mutex_enter(&pd->pd_mutex);
6487 cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
6491 fp_logo_init(pd, cmd, cmd->cmd_job);
6496 mutex_exit(&pd->pd_mutex);
6518 fc_remote_port_t *pd;
6525 pd = pkt->pkt_pd;
6533 ASSERT(pd != NULL && port != NULL && cmd != NULL);
6565 mutex_enter(&pd->pd_mutex);
6566 if ((pd->pd_aux_flags & PD_IN_DID_QUEUE) == 0) {
6567 fctl_enlist_did_table(port, pd);
6569 mutex_exit(&pd->pd_mutex);
6573 mutex_enter(&pd->pd_mutex);
6574 if (pd->pd_type != PORT_DEVICE_NEW) {
6575 if (is_private && (pd->pd_hard_addr.hard_addr !=
6577 pd->pd_type = PORT_DEVICE_CHANGED;
6579 pd->pd_type = PORT_DEVICE_NOCHANGE;
6584 pd->pd_port_id.port_id != ha.hard_addr)) {
6587 fc_wwn_to_str(&pd->pd_port_name, ww_name);
6592 " WWN %s", pd->pd_port_id.port_id,
6595 pd->pd_hard_addr.hard_addr = 0;
6597 pd->pd_hard_addr.hard_addr = ha.hard_addr;
6599 mutex_exit(&pd->pd_mutex);
6635 sizeof (la_els_logi_t), KM_SLEEP, pd);
6656 if (pd) {
6657 mutex_enter(&pd->pd_mutex);
6658 pd->pd_flags = PD_ELS_IN_PROGRESS;
6659 mutex_exit(&pd->pd_mutex);
6686 cmd->cmd_ulp_pkt->pkt_pd = pd;
6689 "ulp_pkt's pd is NULL, get a pd %p",
6690 pd);
6708 mutex_enter(&pd->pd_mutex);
6710 cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
6714 fp_logo_init(pd, cmd, cmd->cmd_job);
6719 mutex_exit(&pd->pd_mutex);
6724 mutex_enter(&pd->pd_mutex);
6726 ((pd->pd_recepient == PD_PLOGI_INITIATOR) ? 1 : 0);
6727 pd->pd_state = PORT_DEVICE_VALID;
6728 pd->pd_aux_flags |= PD_LOGGED_OUT;
6729 if (pd->pd_aux_flags & PD_DISABLE_RELOGIN) {
6730 pd->pd_type = PORT_DEVICE_NEW;
6732 pd->pd_type = PORT_DEVICE_NOCHANGE;
6734 mutex_exit(&pd->pd_mutex);
6740 fp_unregister_login(pd);
6741 fctl_copy_portmap(changelist, pd);
6743 fp_fillout_old_map(changelist, pd, 0);
6748 "to ULP port=%p, pd=%p, map_type=%x map_state=%x "
6749 "map_flags=%x initiator=%d", port, pd,
8499 fc_remote_port_t *pd;
8525 pd = fctl_hold_remote_port_by_pwwn(port, &pwwn);
8526 if (pd == NULL) {
8543 mutex_enter(&pd->pd_mutex);
8545 params->common_service = pd->pd_csp;
8546 params->nport_ww_name = pd->pd_port_name;
8547 params->class_1 = pd->pd_clsp1;
8548 params->class_2 = pd->pd_clsp2;
8549 params->class_3 = pd->pd_clsp3;
8550 node = pd->pd_remote_nodep;
8551 mutex_exit(&pd->pd_mutex);
8561 fctl_release_remote_port(pd);
8660 fc_remote_port_t *pd;
8677 pd = fctl_hold_remote_port_by_pwwn(port, &pwwn);
8678 if (pd == NULL) {
8722 mutex_enter(&pd->pd_mutex);
8723 state = pd->pd_state;
8724 mutex_exit(&pd->pd_mutex);
8726 fctl_release_remote_port(pd);
8745 fc_remote_port_t *pd;
8758 pd = fctl_hold_remote_port_by_pwwn(port, &pwwn);
8759 if (pd == NULL) {
8768 mutex_enter(&pd->pd_mutex);
8769 if (pd->pd_ref_count > 1) {
8770 mutex_exit(&pd->pd_mutex);
8774 fctl_release_remote_port(pd);
8781 mutex_exit(&pd->pd_mutex);
8785 fctl_copy_portmap(changelist, pd);
8789 fctl_release_remote_port(pd);
9344 fc_remote_port_t *pd;
9428 * Following call to get "pd" will fail if dest is FPORT
9430 pd = fctl_hold_remote_port_by_did(port, dest);
9431 if (pd == NULL) {
9440 mutex_enter(&pd->pd_mutex);
9441 if (pd->pd_state != PORT_DEVICE_LOGGED_IN) {
9442 mutex_exit(&pd->pd_mutex);
9443 fctl_release_remote_port(pd);
9452 ASSERT(pd->pd_login_count >= 1);
9453 mutex_exit(&pd->pd_mutex);
9467 sizeof (la_els_rls_acc_t), KM_SLEEP, pd);
9472 fctl_release_remote_port(pd);
9485 mutex_enter(&pd->pd_mutex);
9487 cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
9497 pd_flags = pd->pd_flags;
9498 pd->pd_flags = PD_ELS_IN_PROGRESS;
9500 mutex_exit(&pd->pd_mutex);
9508 ASSERT(pd != NULL);
9534 mutex_enter(&pd->pd_mutex);
9535 if (pd->pd_flags == PD_ELS_IN_PROGRESS) {
9536 pd->pd_flags = pd_flags;
9538 mutex_exit(&pd->pd_mutex);
9542 fctl_release_remote_port(pd);
9838 fc_remote_port_t *pd;
9843 pd = fctl_get_remote_port_by_pwwn(port, pwwn);
9844 if (pd == NULL) {
9869 sizeof (la_els_rnid_acc_t), KM_SLEEP, pd);
9888 mutex_enter(&pd->pd_mutex);
9890 cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
9900 pd->pd_flags = PD_ELS_IN_PROGRESS;
9902 mutex_exit(&pd->pd_mutex);
9910 ASSERT(pd != NULL);
9939 if (pd) {
9940 mutex_enter(&pd->pd_mutex);
9941 pd->pd_flags = PD_IDLE;
9942 mutex_exit(&pd->pd_mutex);
10051 fc_remote_port_t *pd;
10061 pd = head->pwwn_head;
10062 while (pd != NULL) {
10063 mutex_enter(&pd->pd_mutex);
10064 if (pd->pd_state == PORT_DEVICE_INVALID) {
10065 mutex_exit(&pd->pd_mutex);
10066 pd = pd->pd_wwn_hnext;
10070 devlist[count].dev_state = pd->pd_state;
10071 devlist[count].dev_hard_addr = pd->pd_hard_addr;
10072 devlist[count].dev_did = pd->pd_port_id;
10075 bcopy((caddr_t)pd->pd_fc4types,
10077 sizeof (pd->pd_fc4types));
10079 bcopy((caddr_t)&pd->pd_port_name,
10083 node = pd->pd_remote_nodep;
10084 mutex_exit(&pd->pd_mutex);
10131 fc_remote_port_t *pd;
10174 pd = fp_create_remote_port_by_ns(port,
10177 if (pd != NULL) {
10199 mutex_enter(&pd->pd_mutex);
10200 pd->pd_flags = PD_ELS_MARK;
10202 mutex_exit(&pd->pd_mutex);
10247 while ((pd = npd) != NULL) {
10250 npd = pd->pd_wwn_hnext;
10257 mutex_enter(&pd->pd_mutex);
10260 if (pd->pd_type == PORT_DEVICE_NEW ||
10261 pd->pd_flags == PD_ELS_MARK ||
10262 pd->pd_recepient != PD_PLOGI_INITIATOR) {
10263 mutex_exit(&pd->pd_mutex);
10267 if (pd->pd_flags == PD_ELS_MARK ||
10268 pd->pd_recepient != PD_PLOGI_INITIATOR) {
10269 mutex_exit(&pd->pd_mutex);
10272 pd->pd_type = PORT_DEVICE_OLD;
10283 (ns_cmd->ns_cmd_buf))->pwwn = pd->pd_port_name;
10290 pwwn = &pd->pd_port_name;
10291 pd->pd_flags = PD_ELS_MARK;
10293 mutex_exit(&pd->pd_mutex);
10300 mutex_enter(&pd->pd_mutex);
10301 d_id = pd->pd_port_id.port_id;
10302 pd->pd_type = PORT_DEVICE_DELETE;
10303 mutex_exit(&pd->pd_mutex);
10322 mutex_enter(&pd->pd_mutex);
10323 if (d_id != pd->pd_port_id.port_id) {
10324 fctl_delist_did_table(port, pd);
10330 d_id, pd->pd_port_id.port_id);
10332 pd->pd_port_id.port_id = BE_32(d_id);
10333 pd->pd_type = PORT_DEVICE_CHANGED;
10334 fctl_enlist_did_table(port, pd);
10336 mutex_exit(&pd->pd_mutex);
10363 while ((pd = npd) != NULL) {
10364 npd = pd->pd_wwn_hnext;
10366 mutex_enter(&pd->pd_mutex);
10367 if (pd->pd_flags != PD_ELS_MARK) {
10368 mutex_exit(&pd->pd_mutex);
10378 if (pd->pd_type == PORT_DEVICE_DELETE) {
10379 pd->pd_type = PORT_DEVICE_OLD;
10381 mutex_exit(&pd->pd_mutex);
10393 if (pd->pd_type == PORT_DEVICE_NEW) {
10394 pd->pd_flags = PD_IDLE;
10396 mutex_exit(&pd->pd_mutex);
10404 pd->pd_flags = PD_IDLE;
10405 d_id = pd->pd_port_id.port_id;
10412 if (pd->pd_type != PORT_DEVICE_CHANGED) {
10413 pd->pd_type = PORT_DEVICE_OLD;
10416 mutex_exit(&pd->pd_mutex);
10420 FP_CMD_PLOGI_RETAIN, KM_SLEEP, pd, NULL);
10531 fc_remote_port_t *pd;
10536 pd = fctl_get_remote_port_by_did(port, d_id);
10539 if (pd != NULL) {
10540 mutex_enter(&pd->pd_mutex);
10542 if (pd->pd_state == PORT_DEVICE_INVALID) {
10543 mutex_exit(&pd->pd_mutex);
10547 devlist[count].dev_state = pd->pd_state;
10548 devlist[count].dev_hard_addr = pd->pd_hard_addr;
10549 devlist[count].dev_did = pd->pd_port_id;
10552 bcopy((caddr_t)pd->pd_fc4types,
10554 sizeof (pd->pd_fc4types));
10556 bcopy((caddr_t)&pd->pd_port_name,
10560 node = pd->pd_remote_nodep;
10561 mutex_exit(&pd->pd_mutex);
10682 fc_remote_port_t *pd;
10742 pd = fctl_get_remote_port_by_did(port, s_id);
10743 if (pd) {
10744 mutex_enter(&pd->pd_mutex);
10745 if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
10749 pd->pd_state = PORT_DEVICE_VALID;
10751 mutex_exit(&pd->pd_mutex);
10840 pd = fctl_get_remote_port_by_did(port, s_id);
10841 if (pd) {
10842 mutex_enter(&pd->pd_mutex);
10843 if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
10846 mutex_exit(&pd->pd_mutex);
10847 } else if ((pd == NULL) &&
10869 0, KM_NOSLEEP, pd);
10972 fc_remote_port_t *pd;
10989 pd = fctl_get_remote_port_by_did(port, s_id);
10990 if (pd == NULL) {
11020 fp_handle_unsol_logo(port, buf, pd, job);
11022 fp_handle_unsol_adisc(port, buf, pd, job);
11024 fp_handle_unsol_prlo(port, buf, pd, job);
11244 fp_prlo_acc_init(fc_local_port_t *port, fc_remote_port_t *pd,
11260 cmd = fp_alloc_pkt(port, (int)len, 0, sleep, pd);
11357 fc_remote_port_t *pd, job_request_t *job)
11393 mutex_enter(&pd->pd_mutex);
11394 tolerance = fctl_tc_increment(&pd->pd_logo_tc);
11396 if (pd->pd_state != PORT_DEVICE_LOGGED_IN ||
11397 pd->pd_state == PORT_DEVICE_INVALID ||
11398 pd->pd_flags == PD_ELS_IN_PROGRESS ||
11399 pd->pd_type == PORT_DEVICE_OLD) {
11405 mutex_exit(&pd->pd_mutex);
11408 "pd=%p - busy",
11409 pd->pd_port_id.port_id, pd);
11415 retain = (pd->pd_recepient == PD_PLOGI_INITIATOR) ? 1 : 0;
11418 fctl_tc_reset(&pd->pd_logo_tc);
11420 pd->pd_state = PORT_DEVICE_INVALID;
11423 FP_TRACE(FP_NHEAD1(5, 0), "Accepting LOGO; d_id=%x, pd=%p,"
11424 " tolerance=%d retain=%d", pd->pd_port_id.port_id, pd,
11427 pd->pd_aux_flags |= PD_LOGGED_OUT;
11428 mutex_exit(&pd->pd_mutex);
11430 cmd = fp_prlo_acc_init(port, pd, buf, job, KM_SLEEP);
11444 fp_unregister_login(pd);
11445 fctl_copy_portmap(listptr, pd);
11450 mutex_enter(&pd->pd_mutex);
11451 d_id = pd->pd_port_id.port_id;
11452 fc_wwn_to_str(&pd->pd_port_name, ww_name);
11453 mutex_exit(&pd->pd_mutex);
11461 fp_fillout_old_map(listptr, pd, 0);
11471 cmd = fp_alloc_pkt(port, sizeof (la_els_rjt_t), 0, KM_SLEEP, pd);
11487 fc_remote_port_t *pd, job_request_t *job)
11500 mutex_enter(&pd->pd_mutex);
11501 tolerance = fctl_tc_increment(&pd->pd_logo_tc);
11503 if (pd->pd_state != PORT_DEVICE_LOGGED_IN ||
11504 pd->pd_state == PORT_DEVICE_INVALID ||
11505 pd->pd_flags == PD_ELS_IN_PROGRESS ||
11506 pd->pd_type == PORT_DEVICE_OLD) {
11512 mutex_exit(&pd->pd_mutex);
11515 "pd=%p - busy",
11516 pd->pd_port_id.port_id, pd);
11520 0, KM_SLEEP, pd);
11533 retain = (pd->pd_recepient == PD_PLOGI_INITIATOR) ? 1 : 0;
11536 fctl_tc_reset(&pd->pd_logo_tc);
11538 pd->pd_state = PORT_DEVICE_INVALID;
11541 FP_TRACE(FP_NHEAD1(5, 0), "Accepting LOGO; d_id=%x, pd=%p,"
11542 " tolerance=%d retain=%d", pd->pd_port_id.port_id, pd,
11545 pd->pd_aux_flags |= PD_LOGGED_OUT;
11546 mutex_exit(&pd->pd_mutex);
11549 KM_SLEEP, pd);
11588 pd->pd_port_name;
11597 " delete pd");
11604 fp_unregister_login(pd);
11605 fctl_copy_portmap(listptr, pd);
11611 mutex_enter(&pd->pd_mutex);
11612 d_id = pd->pd_port_id.port_id;
11613 fc_wwn_to_str(&pd->pd_port_name, ww_name);
11614 mutex_exit(&pd->pd_mutex);
11622 fp_fillout_old_map(listptr, pd, 0);
11673 fc_remote_port_t *pd;
11695 pd = fctl_get_remote_port_by_pwwn(port,
11697 if (pd) {
11698 mutex_enter(&pd->pd_mutex);
11699 sent = (pd->pd_flags == PD_ELS_IN_PROGRESS) ? 1 : 0;
11705 if (pd->pd_type == PORT_DEVICE_OLD) {
11712 * Mark the pd as PD_PLOGI_RECEPIENT.
11715 pd->pd_recepient = PD_PLOGI_RECEPIENT;
11717 fc_wwn_to_str(&pd->pd_port_name, dww_name);
11719 mutex_exit(&pd->pd_mutex);
11723 "PWWN list. pd=%p PWWN=%s, sent=%x",
11724 pd, dww_name, sent);
11728 "fp_i_handle_unsol_els: Mark the pd"
11729 " as plogi recipient, pd=%p, PWWN=%s"
11731 pd, dww_name, sent);
11915 fc_remote_port_t *pd;
11935 pd = fctl_get_remote_port_by_pwwn(port, dwwn);
11936 if (pd) {
11937 mutex_enter(&pd->pd_mutex);
11938 sent = (pd->pd_flags == PD_ELS_IN_PROGRESS) ? 1 : 0;
11945 if (pd->pd_type == PORT_DEVICE_OLD) {
11952 * Mark the pd as PD_PLOGI_RECEPIENT.
11955 pd->pd_recepient = PD_PLOGI_RECEPIENT;
11957 fc_wwn_to_str(&pd->pd_port_name, dww_name);
11959 mutex_exit(&pd->pd_mutex);
11962 " received. PD still exists in the PWWN list. pd=%p "
11963 "PWWN=%s, sent=%x", pd, dww_name, sent);
11967 "fp_handle_unsol_plogi: Mark the pd"
11968 " as plogi recipient, pd=%p, PWWN=%s"
11970 pd, dww_name, sent);
12016 sizeof (la_els_logi_t), 0, sleep, pd);
12031 0, sleep, pd);
12071 0, sleep, pd);
12206 fc_remote_port_t *pd;
12217 FP_TRACE(FP_NHEAD1(3, 0), "fp_plogi_acc_init fp %x, pd %x",
12219 pd = fctl_create_remote_port(port, &req->node_ww_name,
12222 if (pd == NULL) {
12240 fp_register_login(NULL, pd, req, buf->ub_class);
12242 mutex_enter(&pd->pd_mutex);
12243 if (pd->pd_login_count == 0) {
12244 pd->pd_login_count++;
12246 pd->pd_state = PORT_DEVICE_LOGGED_IN;
12247 pd->pd_login_class = buf->ub_class;
12248 mutex_exit(&pd->pd_mutex);
12253 fctl_copy_portmap(listptr, pd);
12259 mutex_enter(&pd->pd_mutex);
12260 pd->pd_recepient = PD_PLOGI_INITIATOR;
12261 mutex_exit(&pd->pd_mutex);
12504 fp_fillout_old_map_held(fc_portmap_t *map, fc_remote_port_t *pd, uchar_t flag)
12510 port = pd->pd_port;
12515 ASSERT(MUTEX_HELD(&pd->pd_remote_nodep->fd_mutex));
12516 ASSERT(MUTEX_HELD(&pd->pd_mutex));
12518 pd->pd_state = PORT_DEVICE_INVALID;
12519 pd->pd_type = PORT_DEVICE_OLD;
12520 initiator = (pd->pd_recepient == PD_PLOGI_INITIATOR) ? 1 : 0;
12523 fctl_delist_did_table(port, pd);
12524 fctl_delist_pwwn_table(port, pd);
12528 port, pd->pd_port_id.port_id, pd);
12531 (void) fctl_add_orphan_held(port, pd);
12533 fctl_copy_portmap_held(map, pd);
12534 map->map_pd = pd;
12541 fp_fillout_old_map(fc_portmap_t *map, fc_remote_port_t *pd, uchar_t flag)
12547 mutex_enter(&pd->pd_mutex);
12548 port = pd->pd_port;
12549 mutex_exit(&pd->pd_mutex);
12552 mutex_enter(&pd->pd_mutex);
12554 pd->pd_state = PORT_DEVICE_INVALID;
12555 pd->pd_type = PORT_DEVICE_OLD;
12556 initiator = (pd->pd_recepient == PD_PLOGI_INITIATOR) ? 1 : 0;
12559 fctl_delist_did_table(port, pd);
12560 fctl_delist_pwwn_table(port, pd);
12564 port, pd->pd_port_id.port_id, pd);
12566 mutex_exit(&pd->pd_mutex);
12571 (void) fctl_add_orphan(port, pd, KM_NOSLEEP);
12573 fctl_copy_portmap(map, pd);
12574 map->map_pd = pd;
12582 fp_fillout_changed_map(fc_portmap_t *map, fc_remote_port_t *pd,
12585 ASSERT(MUTEX_HELD(&pd->pd_mutex));
12587 pd->pd_type = PORT_DEVICE_CHANGED;
12589 pd->pd_port_id.port_id = *new_did;
12592 pd->pd_port_name = *new_pwwn;
12594 mutex_exit(&pd->pd_mutex);
12596 fctl_copy_portmap(map, pd);
12598 mutex_enter(&pd->pd_mutex);
12599 pd->pd_type = PORT_DEVICE_NOCHANGE;
12662 fc_remote_port_t *pd;
12669 pd = fctl_get_remote_port_by_pwwn(port, pwwn);
12670 if (pd == NULL) {
12733 mutex_enter(&pd->pd_mutex);
12734 ptype = pd->pd_porttype;
12736 switch (pd->pd_porttype.port_type) {
12740 lfa = pd->pd_port_id.port_id & 0xFFFF00;
12744 mutex_exit(&pd->pd_mutex);
12747 mutex_exit(&pd->pd_mutex);
12756 sizeof (fc_linit_resp_t), sleep, pd);
12827 fp_stuff_device_with_gan(ddi_acc_handle_t *handle, fc_remote_port_t *pd,
12834 ASSERT(pd != NULL);
12837 port = pd->pd_port;
12839 FP_TRACE(FP_NHEAD1(1, 0), "GAN PD stuffing; pd=%p,"
12841 pd, gan_resp->gan_type_id.rsvd,
12844 mutex_enter(&pd->pd_mutex);
12849 pd->pd_porttype.port_type = type.port_type;
12850 pd->pd_porttype.rsvd = 0;
12852 pd->pd_spn_len = gan_resp->gan_spnlen;
12853 if (pd->pd_spn_len) {
12854 FC_GET_RSP(port, *handle, (uint8_t *)pd->pd_spn,
12855 (uint8_t *)gan_resp->gan_spname, pd->pd_spn_len,
12859 FC_GET_RSP(port, *handle, (uint8_t *)pd->pd_ip_addr,
12860 (uint8_t *)gan_resp->gan_ip, sizeof (pd->pd_ip_addr),
12862 FC_GET_RSP(port, *handle, (uint8_t *)&pd->pd_cos,
12863 (uint8_t *)&gan_resp->gan_cos, sizeof (pd->pd_cos),
12865 FC_GET_RSP(port, *handle, (uint8_t *)pd->pd_fc4types,
12866 (uint8_t *)gan_resp->gan_fc4types, sizeof (pd->pd_fc4types),
12869 node = pd->pd_remote_nodep;
12870 mutex_exit(&pd->pd_mutex);
12903 FP_TRACE(FP_NHEAD1(1, 0), "fp_ns_query GA_NXT fp %x pd %x",
13143 fc_remote_port_t *pd;
13165 pd = fctl_get_remote_port_by_did(port, d_id.port_id);
13182 FP_TRACE(FP_NHEAD1(1, 0), "GAN response; port=%p, fp %x pd %x", port,
13220 if (ns_cmd->ns_flags & FCTL_NS_CREATE_DEVICE && pd == NULL) {
13222 "pd %x", port->fp_port_id.port_id, d_id.port_id);
13223 pd = fctl_create_remote_port(port, &nwwn, &pwwn,
13226 if (pd != NULL) {
13228 pd, gan_resp);
13256 if (pd != NULL) {
13257 mutex_enter(&pd->pd_mutex);
13258 userbuf->dev_state = pd->pd_state;
13260 pd->pd_hard_addr;
13261 mutex_exit(&pd->pd_mutex);
13281 if (pd != NULL) {
13282 fctl_copy_portmap(map, pd);
13379 fc_remote_port_t *pd, job_request_t *job)
13384 FP_TRACE(FP_NHEAD1(5, 0), "ADISC; port=%p, D_ID=%x state=%x, pd=%p",
13385 port, pd->pd_port_id.port_id, pd->pd_state, pd);
13386 mutex_enter(&pd->pd_mutex);
13387 if (pd->pd_state != PORT_DEVICE_LOGGED_IN) {
13388 mutex_exit(&pd->pd_mutex);
13391 0, KM_SLEEP, pd);
13404 mutex_exit(&pd->pd_mutex);
13414 0, KM_SLEEP, pd);
13528 fp_logout(fc_local_port_t *port, fc_remote_port_t *pd, job_request_t *job)
13534 ASSERT(!MUTEX_HELD(&pd->pd_mutex));
13537 FP_PORT_IDENTIFIER_LEN, KM_SLEEP, pd);
13540 mutex_enter(&pd->pd_mutex);
13542 ASSERT(pd->pd_state == PORT_DEVICE_LOGGED_IN);
13543 ASSERT(pd->pd_login_count == 1);
13545 cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
13551 fp_logo_init(pd, cmd, job);
13553 mutex_exit(&pd->pd_mutex);
13677 fc_remote_port_t *pd;
13719 pd = fctl_get_remote_port_by_did(port, d_id);
13721 FP_TRACE(FP_NHEAD1(1, 0), "PD creation end; port=%p, d_id=%x, pd=%p",
13722 port, d_id, pd);
13724 return (pd);
14046 fc_remote_port_t *pd;
14080 pd = head->pwwn_head;
14081 while (pd != NULL) {
14082 mutex_enter(&pd->pd_mutex);
14083 if (pd->pd_flags != PD_ELS_IN_PROGRESS) {
14084 if ((pd->pd_port_id.port_id & mask) == id &&
14085 pd->pd_recepient == PD_PLOGI_INITIATOR) {
14087 pd->pd_type = PORT_DEVICE_OLD;
14088 pd->pd_flags = PD_ELS_MARK;
14091 mutex_exit(&pd->pd_mutex);
14092 pd = pd->pd_wwn_hnext;
14161 while ((pd = npd) != NULL) {
14162 npd = pd->pd_wwn_hnext;
14164 mutex_enter(&pd->pd_mutex);
14165 if ((pd->pd_port_id.port_id & mask) == id &&
14166 pd->pd_flags == PD_ELS_MARK) {
14173 pd->pd_port_name;
14175 pwwn = &pd->pd_port_name;
14176 d_id = pd->pd_port_id.port_id;
14178 mutex_exit(&pd->pd_mutex);
14196 pd, 1);
14199 pd);
14201 mutex_enter(&pd->pd_mutex);
14202 pd->pd_flags = PD_ELS_IN_PROGRESS;
14203 mutex_exit(&pd->pd_mutex);
14208 mutex_exit(&pd->pd_mutex);
14227 pd = list[index].map_pd;
14229 mutex_enter(&pd->pd_mutex);
14230 ASSERT((pd->pd_port_id.port_id & mask) == id);
14232 if (pd->pd_flags != PD_ELS_IN_PROGRESS) {
14233 ASSERT(pd->pd_type == PORT_DEVICE_OLD);
14234 mutex_exit(&pd->pd_mutex);
14239 login = (pd->pd_state == PORT_DEVICE_LOGGED_IN) ? 1 : 0;
14240 send = (pd->pd_recepient == PD_PLOGI_INITIATOR) ? 1 : 0;
14241 d_id = pd->pd_port_id.port_id;
14242 mutex_exit(&pd->pd_mutex);
14248 " pd=%p, job=%p d_id=%x, index=%d", pd,
14252 FP_CMD_PLOGI_RETAIN, sleep, pd, NULL);
14254 mutex_enter(&pd->pd_mutex);
14255 pd->pd_flags = PD_IDLE;
14256 mutex_exit(&pd->pd_mutex);
14268 " pd=%p, job=%p d_id=%x, index=%d", pd,
14271 rval = fp_ns_validate_device(port, pd, job,
14276 mutex_enter(&pd->pd_mutex);
14277 pd->pd_flags = PD_IDLE;
14278 mutex_exit(&pd->pd_mutex);
14282 "RSCN and NO request sent; pd=%p,"
14283 " d_id=%x, index=%d", pd, d_id, index);
14285 mutex_enter(&pd->pd_mutex);
14286 pd->pd_flags = PD_IDLE;
14287 mutex_exit(&pd->pd_mutex);
14320 pd = fp_create_remote_port_by_ns(port, d_id, KM_SLEEP);
14321 if (pd != NULL) {
14343 fctl_copy_portmap(list + listindex++, pd);
14360 pd = list[index].map_pd;
14361 ASSERT(pd != NULL);
14372 fctl_copy_portmap(list + index, pd);
14376 fctl_copy_portmap(list + index, pd);
14380 "results; pd=%p, d_id=%x pwwn=%x %x %x %x %x %x %x %x",
14381 pd, pd->pd_port_id.port_id,
14382 pd->pd_port_name.raw_wwn[0],
14383 pd->pd_port_name.raw_wwn[1],
14384 pd->pd_port_name.raw_wwn[2],
14385 pd->pd_port_name.raw_wwn[3],
14386 pd->pd_port_name.raw_wwn[4],
14387 pd->pd_port_name.raw_wwn[5],
14388 pd->pd_port_name.raw_wwn[6],
14389 pd->pd_port_name.raw_wwn[7]);
14392 "results continued, pd=%p type=%x, flags=%x, state=%x",
14393 pd, pd->pd_type, pd->pd_flags, pd->pd_state);
14395 mutex_enter(&pd->pd_mutex);
14396 if (pd->pd_type == PORT_DEVICE_OLD) {
14399 pd->pd_flags = PD_IDLE;
14400 initiator = (pd->pd_recepient ==
14403 mutex_exit(&pd->pd_mutex);
14406 mutex_enter(&pd->pd_mutex);
14408 pd->pd_state = PORT_DEVICE_INVALID;
14409 fctl_delist_did_table(port, pd);
14410 fctl_delist_pwwn_table(port, pd);
14412 mutex_exit(&pd->pd_mutex);
14416 (void) fctl_add_orphan(port, pd, sleep);
14418 list[index].map_pd = pd;
14420 ASSERT(pd->pd_flags == PD_IDLE);
14421 if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
14425 fctl_tc_reset(&pd->pd_logo_tc);
14427 mutex_exit(&pd->pd_mutex);
14466 "port=%p, d_id=%x, pd=%p, rscn_count:0x%x", port, page->aff_d_id,
14474 "PD is BUSY; port=%p, d_id=%x, pd=%p",
14533 "PD disappeared, pd=%p", page->aff_d_id, did_pd);
14608 "Case ONE, rval=%x, result=%x pd=%p", page->aff_d_id, rval,
14705 " Case THREE, pd=%p,"
14876 fp_ns_validate_device(fc_local_port_t *port, fc_remote_port_t *pd,
14891 mutex_enter(&pd->pd_mutex);
14892 pwwn = pd->pd_port_name;
14893 mutex_exit(&pd->pd_mutex);
14896 ns_cmd->ns_pd = pd;
15042 fc_remote_port_t *pd = NULL;
15086 pd = held_pd;
15088 mutex_enter(&pd->pd_mutex);
15089 d_id = pd->pd_port_id.port_id;
15090 mutex_exit(&pd->pd_mutex);
15095 pd = fctl_get_remote_port_by_did(port, d_id);
15097 if (pd) {
15098 mutex_enter(&pd->pd_mutex);
15099 if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
15100 pd->pd_login_count++;
15101 mutex_exit(&pd->pd_mutex);
15110 mutex_exit(&pd->pd_mutex);
15115 pd = fp_create_remote_port_by_ns(port, d_id, KM_SLEEP);
15116 if (pd == NULL) {
15132 KM_SLEEP, pd, NULL);
15153 pd = fctl_hold_remote_port_by_pwwn(port, &pwwn);
15154 if (pd == NULL) {
15161 fctl_copy_portmap(changelist, pd);
15166 mutex_enter(&pd->pd_mutex);
15167 pd->pd_type = PORT_DEVICE_NOCHANGE;
15168 mutex_exit(&pd->pd_mutex);
15170 fctl_release_remote_port(pd);
15182 fc_remote_port_t *pd;
15186 pd = fctl_hold_remote_port_by_pwwn(port, &pwwn);
15187 if (pd == NULL) {
15192 mutex_enter(&pd->pd_mutex);
15193 if (pd->pd_state != PORT_DEVICE_LOGGED_IN) {
15195 mutex_exit(&pd->pd_mutex);
15197 fctl_release_remote_port(pd);
15202 ASSERT(pd->pd_login_count >= 1);
15204 if (pd->pd_flags == PD_ELS_IN_PROGRESS) {
15206 mutex_exit(&pd->pd_mutex);
15208 fctl_release_remote_port(pd);
15213 if (pd->pd_login_count > 1) {
15214 pd->pd_login_count--;
15216 mutex_exit(&pd->pd_mutex);
15220 fctl_copy_portmap(changelist, pd);
15223 fctl_release_remote_port(pd);
15230 pd->pd_flags = PD_ELS_IN_PROGRESS;
15231 mutex_exit(&pd->pd_mutex);
15236 FP_PORT_IDENTIFIER_LEN, KM_SLEEP, pd);
15239 fctl_release_remote_port(pd);
15241 mutex_enter(&pd->pd_mutex);
15242 pd->pd_flags = PD_IDLE;
15243 mutex_exit(&pd->pd_mutex);
15249 mutex_enter(&pd->pd_mutex);
15251 cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
15257 fp_logo_init(pd, cmd, job);
15259 mutex_exit(&pd->pd_mutex);
15263 mutex_enter(&pd->pd_mutex);
15264 pd->pd_flags = PD_IDLE;
15265 mutex_exit(&pd->pd_mutex);
15268 fctl_release_remote_port(pd);
15277 mutex_enter(&pd->pd_mutex);
15278 pd->pd_flags = PD_IDLE;
15279 mutex_exit(&pd->pd_mutex);
15281 fctl_release_remote_port(pd);
15286 ASSERT(pd != NULL);
15290 fctl_copy_portmap(changelist, pd);
15295 mutex_enter(&pd->pd_mutex);
15297 fctl_delist_did_table(port, pd);
15298 fctl_delist_pwwn_table(port, pd);
15299 pd->pd_flags = PD_IDLE;
15301 mutex_exit(&pd->pd_mutex);
15306 fctl_release_remote_port(pd);