Lines Matching refs:rport

357 	struct fc_rport *rport = starget_to_rport(starget);
364 if (rport) {
365 fc_starget_node_name(starget) = rport->node_name;
366 fc_starget_port_name(starget) = rport->port_name;
367 fc_starget_port_id(starget) = rport->port_id;
703 struct fc_rport *rport = transport_class_to_rport(dev); \
704 struct Scsi_Host *shost = rport_to_shost(rport); \
707 !((rport->port_state == FC_PORTSTATE_BLOCKED) || \
708 (rport->port_state == FC_PORTSTATE_DELETED) || \
709 (rport->port_state == FC_PORTSTATE_NOTPRESENT))) \
710 i->f->get_rport_##field(rport); \
711 return snprintf(buf, sz, format_string, cast rport->field); \
721 struct fc_rport *rport = transport_class_to_rport(dev); \
722 struct Scsi_Host *shost = rport_to_shost(rport); \
725 if ((rport->port_state == FC_PORTSTATE_BLOCKED) || \
726 (rport->port_state == FC_PORTSTATE_DELETED) || \
727 (rport->port_state == FC_PORTSTATE_NOTPRESENT)) \
732 i->f->set_rport_##field(rport, val); \
738 static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
743 static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
749 static FC_DEVICE_ATTR(rport, field, S_IRUGO | S_IWUSR, \
759 struct fc_rport *rport = transport_class_to_rport(dev); \
760 return snprintf(buf, sz, format_string, cast rport->field); \
765 static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
770 static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
779 struct fc_rport *rport = transport_class_to_rport(dev); \
781 name = get_fc_##title##_name(rport->title); \
786 static FC_DEVICE_ATTR(rport, title, S_IRUGO, \
833 struct fc_rport *rport = transport_class_to_rport(dev);
834 if (rport->supported_classes == FC_COS_UNSPECIFIED)
836 return get_fc_cos_names(rport->supported_classes, buf);
838 static FC_DEVICE_ATTR(rport, supported_classes, S_IRUGO,
862 static int fc_rport_set_dev_loss_tmo(struct fc_rport *rport,
865 struct Scsi_Host *shost = rport_to_shost(rport);
868 if ((rport->port_state == FC_PORTSTATE_BLOCKED) ||
869 (rport->port_state == FC_PORTSTATE_DELETED) ||
870 (rport->port_state == FC_PORTSTATE_NOTPRESENT))
882 if (rport->fast_io_fail_tmo == -1 &&
886 i->f->set_rport_dev_loss_tmo(rport, val);
895 struct fc_rport *rport = transport_class_to_rport(dev);
903 rc = fc_rport_set_dev_loss_tmo(rport, val);
908 static FC_DEVICE_ATTR(rport, dev_loss_tmo, S_IRUGO | S_IWUSR,
922 struct fc_rport *rport = transport_class_to_rport(dev);
925 if ((rport->port_id != -1) &&
926 (rport->port_id & FC_WELLKNOWN_PORTID_MASK) ==
928 switch (rport->port_id & FC_WELLKNOWN_ROLE_MASK) {
943 if (rport->roles == FC_PORT_ROLE_UNKNOWN)
945 return get_fc_port_roles_names(rport->roles, buf);
948 static FC_DEVICE_ATTR(rport, roles, S_IRUGO,
961 struct fc_rport *rport = transport_class_to_rport(dev);
963 if (rport->fast_io_fail_tmo == -1)
965 return snprintf(buf, 20, "%d\n", rport->fast_io_fail_tmo);
975 struct fc_rport *rport = transport_class_to_rport(dev);
977 if ((rport->port_state == FC_PORTSTATE_BLOCKED) ||
978 (rport->port_state == FC_PORTSTATE_DELETED) ||
979 (rport->port_state == FC_PORTSTATE_NOTPRESENT))
982 rport->fast_io_fail_tmo = -1;
991 if ((val >= rport->dev_loss_tmo) ||
995 rport->fast_io_fail_tmo = val;
999 static FC_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR,
1021 struct fc_rport *rport = starget_to_rport(starget); \
1022 if (rport) \
1023 fc_starget_##field(starget) = rport->field; \
1610 struct fc_rport *rport;
1621 get_list_head_entry(rport,
1623 list_del(&rport->peers);
1624 rport->port_state = FC_PORTSTATE_DELETED;
1625 fc_queue_work(shost, &rport->rport_delete_work);
1665 struct fc_rport *rport;
1675 list_for_each_entry(rport, &fc_host->rports, peers)
1676 fc_rport_set_dev_loss_tmo(rport, val);
1991 struct fc_rport *rport = dev_to_rport(dev);
1993 kfree(rport);
2061 * rport is in a blocked state, typically due to a temporarily loss of
2069 * the underlying rport. If the rport is blocked, it returns
2073 * If the rport is not blocked, normal error handling continues.
2081 struct fc_rport *rport = starget_to_rport(scsi_target(scmd->device));
2083 if (rport->port_state == FC_PORTSTATE_BLOCKED)
2090 * Called by fc_user_scan to locate an rport on the shost that
2092 * on the rport.
2097 struct fc_rport *rport;
2102 list_for_each_entry(rport, &fc_host_rports(shost), peers) {
2103 if (rport->scsi_target_id == -1)
2106 if (rport->port_state != FC_PORTSTATE_ONLINE)
2109 if ((channel == rport->channel) &&
2110 (id == rport->scsi_target_id)) {
2112 scsi_scan_target(&rport->dev, channel, id, lun, 1);
2122 * wants to place all target objects below the rport object. So this
2123 * routine must invoke the scsi_scan_target() routine with the rport
2440 struct fc_rport *rport = NULL, *next_rport = NULL;
2452 list_for_each_entry_safe(rport, next_rport,
2454 list_del(&rport->peers);
2455 rport->port_state = FC_PORTSTATE_DELETED;
2456 fc_queue_work(shost, &rport->rport_delete_work);
2459 list_for_each_entry_safe(rport, next_rport,
2461 list_del(&rport->peers);
2462 rport->port_state = FC_PORTSTATE_DELETED;
2463 fc_queue_work(shost, &rport->rport_delete_work);
2471 /* flush all stgt delete, and rport delete work items, then kill it */
2487 static void fc_terminate_rport_io(struct fc_rport *rport)
2489 struct Scsi_Host *shost = rport_to_shost(rport);
2492 /* Involve the LLDD if possible to terminate all io on the rport. */
2494 i->f->terminate_rport_io(rport);
2499 scsi_target_unblock(&rport->dev, SDEV_TRANSPORT_OFFLINE);
2503 * fc_starget_delete - called to delete the scsi descendants of an rport
2511 struct fc_rport *rport =
2514 fc_terminate_rport_io(rport);
2515 scsi_remove_target(&rport->dev);
2520 * fc_rport_final_delete - finish rport termination and delete it.
2526 struct fc_rport *rport =
2528 struct device *dev = &rport->dev;
2529 struct Scsi_Host *shost = rport_to_shost(rport);
2534 fc_terminate_rport_io(rport);
2538 * that we can reclaim the rport scan work element.
2540 if (rport->flags & FC_RPORT_SCAN_PENDING)
2549 if (rport->flags & FC_RPORT_DEVLOSS_PENDING) {
2551 if (!cancel_delayed_work(&rport->fail_io_work))
2553 if (!cancel_delayed_work(&rport->dev_loss_work))
2555 cancel_work_sync(&rport->scan_work);
2557 rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
2562 if (rport->scsi_target_id != -1)
2563 fc_starget_delete(&rport->stgt_delete_work);
2566 * Notify the driver that the rport is now dead. The LLDD will
2567 * also guarantee that any communication to the rport is terminated
2570 * rport for the binding.
2573 if (!(rport->flags & FC_RPORT_DEVLOSS_CALLBK_DONE) &&
2575 rport->flags |= FC_RPORT_DEVLOSS_CALLBK_DONE;
2581 i->f->dev_loss_tmo_callbk(rport);
2583 fc_bsg_remove(rport->rqst_q);
2588 put_device(&shost->shost_gendev); /* for fc_host->rport list */
2612 struct fc_rport *rport;
2619 rport = kzalloc(size, GFP_KERNEL);
2620 if (unlikely(!rport)) {
2625 rport->maxframe_size = -1;
2626 rport->supported_classes = FC_COS_UNSPECIFIED;
2627 rport->dev_loss_tmo = fc_host->dev_loss_tmo;
2628 memcpy(&rport->node_name, &ids->node_name, sizeof(rport->node_name));
2629 memcpy(&rport->port_name, &ids->port_name, sizeof(rport->port_name));
2630 rport->port_id = ids->port_id;
2631 rport->roles = ids->roles;
2632 rport->port_state = FC_PORTSTATE_ONLINE;
2634 rport->dd_data = &rport[1];
2635 rport->channel = channel;
2636 rport->fast_io_fail_tmo = -1;
2638 INIT_DELAYED_WORK(&rport->dev_loss_work, fc_timeout_deleted_rport);
2639 INIT_DELAYED_WORK(&rport->fail_io_work, fc_timeout_fail_rport_io);
2640 INIT_WORK(&rport->scan_work, fc_scsi_scan_rport);
2641 INIT_WORK(&rport->stgt_delete_work, fc_starget_delete);
2642 INIT_WORK(&rport->rport_delete_work, fc_rport_final_delete);
2646 rport->number = fc_host->next_rport_number++;
2647 if (rport->roles & FC_PORT_ROLE_FCP_TARGET)
2648 rport->scsi_target_id = fc_host->next_target_id++;
2650 rport->scsi_target_id = -1;
2651 list_add_tail(&rport->peers, &fc_host->rports);
2652 get_device(&shost->shost_gendev); /* for fc_host->rport list */
2656 dev = &rport->dev;
2660 dev_set_name(dev, "rport-%d:%d-%d",
2661 shost->host_no, channel, rport->number);
2672 fc_bsg_rportadd(shost, rport);
2675 if (rport->roles & FC_PORT_ROLE_FCP_TARGET) {
2677 rport->flags |= FC_RPORT_SCAN_PENDING;
2678 scsi_queue_work(shost, &rport->scan_work);
2681 return rport;
2686 list_del(&rport->peers);
2687 put_device(&shost->shost_gendev); /* for fc_host->rport list */
2690 kfree(rport);
2738 struct fc_rport *rport;
2746 * Search the list of "active" rports, for an rport that has been
2752 list_for_each_entry(rport, &fc_host->rports, peers) {
2754 if ((rport->port_state == FC_PORTSTATE_BLOCKED) &&
2755 (rport->channel == channel)) {
2760 if (rport->port_name == ids->port_name)
2764 if (rport->node_name == ids->node_name)
2768 if (rport->port_id == ids->port_id)
2775 memcpy(&rport->node_name, &ids->node_name,
2776 sizeof(rport->node_name));
2777 memcpy(&rport->port_name, &ids->port_name,
2778 sizeof(rport->port_name));
2779 rport->port_id = ids->port_id;
2781 rport->port_state = FC_PORTSTATE_ONLINE;
2782 rport->roles = ids->roles;
2787 memset(rport->dd_data, 0,
2792 * io terminate and rport timers, and
2807 if ((rport->scsi_target_id != -1) &&
2809 return rport;
2816 if (!cancel_delayed_work(&rport->fail_io_work))
2818 if (!cancel_delayed_work(&rport->dev_loss_work))
2823 rport->flags &= ~(FC_RPORT_FAST_FAIL_TIMEDOUT |
2830 if (rport->scsi_target_id != -1) {
2831 scsi_target_unblock(&rport->dev,
2835 rport->flags |= FC_RPORT_SCAN_PENDING;
2837 &rport->scan_work);
2842 fc_bsg_goose_queue(rport);
2844 return rport;
2857 list_for_each_entry(rport, &fc_host->rport_bindings,
2859 if (rport->channel != channel)
2864 if (rport->port_name == ids->port_name)
2868 if (rport->node_name == ids->node_name)
2872 if (rport->port_id == ids->port_id)
2880 list_move_tail(&rport->peers, &fc_host->rports);
2886 memcpy(&rport->node_name, &ids->node_name,
2887 sizeof(rport->node_name));
2888 memcpy(&rport->port_name, &ids->port_name,
2889 sizeof(rport->port_name));
2890 rport->port_id = ids->port_id;
2891 rport->roles = ids->roles;
2892 rport->port_state = FC_PORTSTATE_ONLINE;
2893 rport->flags &= ~FC_RPORT_FAST_FAIL_TIMEDOUT;
2896 memset(rport->dd_data, 0,
2901 scsi_target_unblock(&rport->dev, SDEV_RUNNING);
2905 rport->flags |= FC_RPORT_SCAN_PENDING;
2906 scsi_queue_work(shost, &rport->scan_work);
2909 return rport;
2916 rport = fc_rport_create(shost, channel, ids);
2918 return rport;
2925 * @rport: The remote port that no longer exists
2946 * temporary blocked state. From the LLDD's perspective, the rport no
2974 fc_remote_port_delete(struct fc_rport *rport)
2976 struct Scsi_Host *shost = rport_to_shost(rport);
2977 unsigned long timeout = rport->dev_loss_tmo;
2983 * We do need to reclaim the rport scan work element, so eventually
2990 if (rport->port_state != FC_PORTSTATE_ONLINE) {
2997 * unconditionally just jump to deleting the rport.
2999 * and its not appropriate to just terminate the rport at the
3001 * send ELS traffic to re-validate the login. If the rport is
3005 * destroying an rport.
3008 rport->port_state = FC_PORTSTATE_BLOCKED;
3010 rport->flags |= FC_RPORT_DEVLOSS_PENDING;
3014 scsi_target_block(&rport->dev);
3017 if ((rport->fast_io_fail_tmo != -1) &&
3018 (rport->fast_io_fail_tmo < timeout))
3019 fc_queue_devloss_work(shost, &rport->fail_io_work,
3020 rport->fast_io_fail_tmo * HZ);
3023 fc_queue_devloss_work(shost, &rport->dev_loss_work, timeout * HZ);
3029 * @rport: The remote port that changed.
3048 fc_remote_port_rolechg(struct fc_rport *rport, u32 roles)
3050 struct Scsi_Host *shost = rport_to_shost(rport);
3057 if (rport->scsi_target_id == -1) {
3058 rport->scsi_target_id = fc_host->next_target_id++;
3060 } else if (!(rport->roles & FC_PORT_ROLE_FCP_TARGET))
3064 rport->roles = roles;
3073 * Note: we know the rport is exists and in an online
3074 * state as the LLDD would not have had an rport
3081 if (!cancel_delayed_work(&rport->fail_io_work))
3083 if (!cancel_delayed_work(&rport->dev_loss_work))
3087 rport->flags &= ~(FC_RPORT_FAST_FAIL_TIMEDOUT |
3095 scsi_target_unblock(&rport->dev, SDEV_RUNNING);
3098 rport->flags |= FC_RPORT_SCAN_PENDING;
3099 scsi_queue_work(shost, &rport->scan_work);
3107 * @work: rport target that failed to reappear in the allotted time.
3115 struct fc_rport *rport =
3117 struct Scsi_Host *shost = rport_to_shost(rport);
3125 rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
3132 if ((rport->port_state == FC_PORTSTATE_ONLINE) &&
3133 (rport->scsi_target_id != -1) &&
3134 !(rport->roles & FC_PORT_ROLE_FCP_TARGET)) {
3135 dev_printk(KERN_ERR, &rport->dev,
3139 scsi_target_unblock(&rport->dev, SDEV_TRANSPORT_OFFLINE);
3140 fc_queue_work(shost, &rport->stgt_delete_work);
3145 if (rport->port_state != FC_PORTSTATE_BLOCKED) {
3147 dev_printk(KERN_ERR, &rport->dev,
3149 " rport%s alone\n",
3150 (rport->scsi_target_id != -1) ? " and starget" : "");
3155 (rport->scsi_target_id == -1)) {
3156 list_del(&rport->peers);
3157 rport->port_state = FC_PORTSTATE_DELETED;
3158 dev_printk(KERN_ERR, &rport->dev,
3160 " rport%s\n",
3161 (rport->scsi_target_id != -1) ? " and starget" : "");
3162 fc_queue_work(shost, &rport->rport_delete_work);
3167 dev_printk(KERN_ERR, &rport->dev,
3171 list_move_tail(&rport->peers, &fc_host->rport_bindings);
3182 rport->maxframe_size = -1;
3183 rport->supported_classes = FC_COS_UNSPECIFIED;
3184 rport->roles = FC_PORT_ROLE_UNKNOWN;
3185 rport->port_state = FC_PORTSTATE_NOTPRESENT;
3186 rport->flags &= ~FC_RPORT_FAST_FAIL_TIMEDOUT;
3194 fc_terminate_rport_io(rport);
3198 if (rport->port_state == FC_PORTSTATE_NOTPRESENT) { /* still missing */
3203 rport->node_name = -1;
3204 rport->port_id = -1;
3207 rport->port_name = -1;
3208 rport->port_id = -1;
3211 rport->node_name = -1;
3212 rport->port_name = -1;
3223 rport->flags |= FC_RPORT_DEVLOSS_CALLBK_DONE;
3224 fc_queue_work(shost, &rport->stgt_delete_work);
3232 * Notify the driver that the rport is now dead. The LLDD will
3233 * also guarantee that any communication to the rport is terminated
3238 i->f->dev_loss_tmo_callbk(rport);
3244 * @work: rport to terminate io on.
3252 struct fc_rport *rport =
3255 if (rport->port_state != FC_PORTSTATE_BLOCKED)
3258 rport->flags |= FC_RPORT_FAST_FAIL_TIMEDOUT;
3259 fc_terminate_rport_io(rport);
3269 struct fc_rport *rport =
3271 struct Scsi_Host *shost = rport_to_shost(rport);
3275 if ((rport->port_state == FC_PORTSTATE_ONLINE) &&
3276 (rport->roles & FC_PORT_ROLE_FCP_TARGET) &&
3278 scsi_scan_target(&rport->dev, rport->channel,
3279 rport->scsi_target_id, SCAN_WILD_CARD, 1);
3283 rport->flags &= ~FC_RPORT_SCAN_PENDING;
3304 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
3308 while (rport->port_state == FC_PORTSTATE_BLOCKED &&
3309 !(rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT)) {
3316 if (rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT)
3643 if (job->rport && job->rport->port_state == FC_PORTSTATE_BLOCKED)
3692 * @rport: (optional) FC Remote Port corresponding to the bsg object
3696 fc_req_to_bsgjob(struct Scsi_Host *shost, struct fc_rport *rport,
3722 job->rport = rport;
3743 if (rport)
3744 job->dev = &rport->dev;
3772 * @shost: scsi host rport attached to
3850 * fc_bsg_goose_queue - restart rport queue in case it was stopped
3851 * @rport: rport to be restarted
3854 fc_bsg_goose_queue(struct fc_rport *rport)
3856 if (!rport->rqst_q)
3862 get_device(&rport->dev);
3863 blk_run_queue_async(rport->rqst_q);
3864 put_device(&rport->dev);
3868 * fc_bsg_rport_dispatch - process rport bsg requests and dispatch to LLDD
3869 * @q: rport request queue
3870 * @shost: scsi host rport attached to
3871 * @rport: rport request destined to
3876 struct fc_rport *rport, struct fc_bsg_job *job)
3882 /* Validate the rport command */
3928 * @rport: FC remote port related to the bsg object (optional)
3933 struct fc_rport *rport, struct device *dev)
3943 if (rport && (rport->port_state == FC_PORTSTATE_BLOCKED) &&
3944 !(rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT))
3951 if (rport && (rport->port_state != FC_PORTSTATE_ONLINE)) {
3961 ret = fc_req_to_bsgjob(shost, rport, req);
3983 if (rport)
3984 ret = fc_bsg_rport_dispatch(q, shost, rport, job);
4017 * fc_bsg_rport_handler - handler for bsg requests for a fc rport
4018 * @q: rport request queue
4023 struct fc_rport *rport = q->queuedata;
4024 struct Scsi_Host *shost = rport_to_shost(rport);
4026 fc_bsg_request_handler(q, shost, rport, &rport->dev);
4082 * @shost: shost that rport is attached to
4083 * @rport: rport that the bsg hooks are being attached to
4086 fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport)
4088 struct device *dev = &rport->dev;
4093 rport->rqst_q = NULL;
4106 q->queuedata = rport;
4121 rport->rqst_q = q;