Lines Matching refs:rport

360 	struct fc_rport *rport = starget_to_rport(starget);
367 if (rport) {
368 fc_starget_node_name(starget) = rport->node_name;
369 fc_starget_port_name(starget) = rport->port_name;
370 fc_starget_port_id(starget) = rport->port_id;
655 struct fc_rport *rport;
660 list_for_each_entry(rport, &fc_host_rports(shost), peers) {
661 if (rport->port_state != FC_PORTSTATE_ONLINE)
664 if (rport->port_name == wwpn) {
666 return rport;
761 struct fc_rport *rport = NULL;
768 rport = fc_find_rport_by_wwpn(shost,
770 if (rport &&
771 (rport->roles & FC_PORT_ROLE_FCP_TARGET ||
772 rport->roles & FC_PORT_ROLE_NVME_TARGET)) {
773 attach_rport = rport;
782 rport = fc_find_rport_by_wwpn(shost, wwpn);
783 if (rport &&
784 (rport->roles & FC_PORT_ROLE_FCP_TARGET ||
785 rport->roles & FC_PORT_ROLE_NVME_TARGET)) {
786 if (rport == attach_rport)
789 &rport->fpin_stats);
809 struct fc_rport *rport = NULL;
815 rport = fc_find_rport_by_wwpn(shost,
817 if (rport &&
818 (rport->roles & FC_PORT_ROLE_FCP_TARGET ||
819 rport->roles & FC_PORT_ROLE_NVME_TARGET)) {
820 attach_rport = rport;
841 struct fc_rport *rport = NULL;
848 rport = fc_find_rport_by_wwpn(shost,
850 if (rport &&
851 (rport->roles & FC_PORT_ROLE_FCP_TARGET ||
852 rport->roles & FC_PORT_ROLE_NVME_TARGET)) {
853 attach_rport = rport;
862 rport = fc_find_rport_by_wwpn(shost, wwpn);
863 if (rport &&
864 (rport->roles & FC_PORT_ROLE_FCP_TARGET ||
865 rport->roles & FC_PORT_ROLE_NVME_TARGET)) {
866 if (rport == attach_rport)
869 &rport->fpin_stats);
991 struct fc_rport *rport = transport_class_to_rport(dev); \
992 struct Scsi_Host *shost = rport_to_shost(rport); \
995 !((rport->port_state == FC_PORTSTATE_BLOCKED) || \
996 (rport->port_state == FC_PORTSTATE_DELETED) || \
997 (rport->port_state == FC_PORTSTATE_NOTPRESENT))) \
998 i->f->get_rport_##field(rport); \
999 return snprintf(buf, sz, format_string, cast rport->field); \
1009 struct fc_rport *rport = transport_class_to_rport(dev); \
1010 struct Scsi_Host *shost = rport_to_shost(rport); \
1013 if ((rport->port_state == FC_PORTSTATE_BLOCKED) || \
1014 (rport->port_state == FC_PORTSTATE_DELETED) || \
1015 (rport->port_state == FC_PORTSTATE_NOTPRESENT)) \
1020 i->f->set_rport_##field(rport, val); \
1026 static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
1031 static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
1037 static FC_DEVICE_ATTR(rport, field, S_IRUGO | S_IWUSR, \
1047 struct fc_rport *rport = transport_class_to_rport(dev); \
1048 return snprintf(buf, sz, format_string, cast rport->field); \
1053 static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
1058 static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
1067 struct fc_rport *rport = transport_class_to_rport(dev); \
1069 name = get_fc_##title##_name(rport->title); \
1074 static FC_DEVICE_ATTR(rport, title, S_IRUGO, \
1121 struct fc_rport *rport = transport_class_to_rport(dev);
1122 if (rport->supported_classes == FC_COS_UNSPECIFIED)
1124 return get_fc_cos_names(rport->supported_classes, buf);
1126 static FC_DEVICE_ATTR(rport, supported_classes, S_IRUGO,
1150 static int fc_rport_set_dev_loss_tmo(struct fc_rport *rport,
1153 struct Scsi_Host *shost = rport_to_shost(rport);
1156 if ((rport->port_state == FC_PORTSTATE_BLOCKED) ||
1157 (rport->port_state == FC_PORTSTATE_DELETED) ||
1158 (rport->port_state == FC_PORTSTATE_NOTPRESENT))
1170 if (rport->fast_io_fail_tmo == -1 &&
1174 i->f->set_rport_dev_loss_tmo(rport, val);
1183 struct fc_rport *rport = transport_class_to_rport(dev);
1191 rc = fc_rport_set_dev_loss_tmo(rport, val);
1196 static FC_DEVICE_ATTR(rport, dev_loss_tmo, S_IRUGO | S_IWUSR,
1210 struct fc_rport *rport = transport_class_to_rport(dev);
1213 if ((rport->port_id != -1) &&
1214 (rport->port_id & FC_WELLKNOWN_PORTID_MASK) ==
1216 switch (rport->port_id & FC_WELLKNOWN_ROLE_MASK) {
1231 if (rport->roles == FC_PORT_ROLE_UNKNOWN)
1233 return get_fc_port_roles_names(rport->roles, buf);
1236 static FC_DEVICE_ATTR(rport, roles, S_IRUGO,
1243 struct fc_rport *rport = transport_class_to_rport(dev);
1253 * current rport state is Online
1256 if (rport->port_state == FC_PORTSTATE_ONLINE)
1257 rport->port_state = port_state;
1263 * current rport state is Marginal
1266 if (rport->port_state == FC_PORTSTATE_MARGINAL)
1267 rport->port_state = port_state;
1280 struct fc_rport *rport = transport_class_to_rport(dev);
1282 name = get_fc_port_state_name(rport->port_state);
1289 static FC_DEVICE_ATTR(rport, port_state, 0444 | 0200,
1301 struct fc_rport *rport = transport_class_to_rport(dev);
1303 if (rport->fast_io_fail_tmo == -1)
1305 return snprintf(buf, 20, "%d\n", rport->fast_io_fail_tmo);
1315 struct fc_rport *rport = transport_class_to_rport(dev);
1317 if ((rport->port_state == FC_PORTSTATE_BLOCKED) ||
1318 (rport->port_state == FC_PORTSTATE_DELETED) ||
1319 (rport->port_state == FC_PORTSTATE_NOTPRESENT))
1322 rport->fast_io_fail_tmo = -1;
1331 if ((val >= rport->dev_loss_tmo) ||
1335 rport->fast_io_fail_tmo = val;
1339 static FC_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR,
1347 struct fc_rport *rport = transport_class_to_rport(cd); \
1349 return snprintf(buf, 20, "0x%llx\n", rport->fpin_stats.name); \
1351 static FC_DEVICE_ATTR(rport, fpin_##name, 0444, fc_rport_fpinstat_##name, NULL)
1422 struct fc_rport *rport = starget_to_rport(starget); \
1423 if (rport) \
1424 fc_starget_##field(starget) = rport->field; \
2011 struct fc_rport *rport;
2022 get_list_head_entry(rport,
2024 list_del(&rport->peers);
2025 rport->port_state = FC_PORTSTATE_DELETED;
2026 fc_queue_work(shost, &rport->rport_delete_work);
2066 struct fc_rport *rport;
2076 list_for_each_entry(rport, &fc_host->rports, peers)
2077 fc_rport_set_dev_loss_tmo(rport, val);
2450 struct fc_rport *rport = dev_to_rport(dev);
2452 kfree(rport);
2519 * rport is in a blocked state, typically due to a temporarily loss of
2527 * the underlying rport. If the rport is blocked, it returns
2531 * If the rport is not blocked, normal error handling continues.
2538 struct fc_rport *rport = starget_to_rport(scsi_target(scmd->device));
2540 if (rport->port_state == FC_PORTSTATE_BLOCKED)
2548 * Called by fc_user_scan to locate an rport on the shost that
2550 * on the rport.
2555 struct fc_rport *rport;
2560 list_for_each_entry(rport, &fc_host_rports(shost), peers) {
2561 if (rport->scsi_target_id == -1)
2564 if ((rport->port_state != FC_PORTSTATE_ONLINE) &&
2565 (rport->port_state != FC_PORTSTATE_MARGINAL))
2568 if ((channel == rport->channel) &&
2569 (id == rport->scsi_target_id)) {
2571 scsi_scan_target(&rport->dev, channel, id, lun,
2582 * wants to place all target objects below the rport object. So this
2583 * routine must invoke the scsi_scan_target() routine with the rport
2882 struct fc_rport *rport = NULL, *next_rport = NULL;
2896 list_for_each_entry_safe(rport, next_rport,
2898 list_del(&rport->peers);
2899 rport->port_state = FC_PORTSTATE_DELETED;
2900 fc_queue_work(shost, &rport->rport_delete_work);
2903 list_for_each_entry_safe(rport, next_rport,
2905 list_del(&rport->peers);
2906 rport->port_state = FC_PORTSTATE_DELETED;
2907 fc_queue_work(shost, &rport->rport_delete_work);
2915 /* flush all stgt delete, and rport delete work items, then kill it */
2931 static void fc_terminate_rport_io(struct fc_rport *rport)
2933 struct Scsi_Host *shost = rport_to_shost(rport);
2936 /* Involve the LLDD if possible to terminate all io on the rport. */
2938 i->f->terminate_rport_io(rport);
2943 scsi_target_unblock(&rport->dev, SDEV_TRANSPORT_OFFLINE);
2947 * fc_starget_delete - called to delete the scsi descendants of an rport
2955 struct fc_rport *rport =
2958 fc_terminate_rport_io(rport);
2959 scsi_remove_target(&rport->dev);
2964 * fc_rport_final_delete - finish rport termination and delete it.
2970 struct fc_rport *rport =
2972 struct device *dev = &rport->dev;
2973 struct Scsi_Host *shost = rport_to_shost(rport);
2978 fc_terminate_rport_io(rport);
2982 * that we can reclaim the rport scan work element.
2984 if (rport->flags & FC_RPORT_SCAN_PENDING)
2993 if (rport->flags & FC_RPORT_DEVLOSS_PENDING) {
2995 if (!cancel_delayed_work(&rport->fail_io_work))
2997 if (!cancel_delayed_work(&rport->dev_loss_work))
2999 cancel_work_sync(&rport->scan_work);
3001 rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
3006 if (rport->scsi_target_id != -1)
3007 fc_starget_delete(&rport->stgt_delete_work);
3010 * Notify the driver that the rport is now dead. The LLDD will
3011 * also guarantee that any communication to the rport is terminated
3014 * rport for the binding.
3017 if (!(rport->flags & FC_RPORT_DEVLOSS_CALLBK_DONE) &&
3019 rport->flags |= FC_RPORT_DEVLOSS_CALLBK_DONE;
3025 i->f->dev_loss_tmo_callbk(rport);
3027 fc_bsg_remove(rport->rqst_q);
3032 scsi_host_put(shost); /* for fc_host->rport list */
3056 struct fc_rport *rport;
3063 rport = kzalloc(size, GFP_KERNEL);
3064 if (unlikely(!rport)) {
3069 rport->maxframe_size = -1;
3070 rport->supported_classes = FC_COS_UNSPECIFIED;
3071 rport->dev_loss_tmo = fc_host->dev_loss_tmo;
3072 memcpy(&rport->node_name, &ids->node_name, sizeof(rport->node_name));
3073 memcpy(&rport->port_name, &ids->port_name, sizeof(rport->port_name));
3074 rport->port_id = ids->port_id;
3075 rport->roles = ids->roles;
3076 rport->port_state = FC_PORTSTATE_ONLINE;
3078 rport->dd_data = &rport[1];
3079 rport->channel = channel;
3080 rport->fast_io_fail_tmo = -1;
3082 INIT_DELAYED_WORK(&rport->dev_loss_work, fc_timeout_deleted_rport);
3083 INIT_DELAYED_WORK(&rport->fail_io_work, fc_timeout_fail_rport_io);
3084 INIT_WORK(&rport->scan_work, fc_scsi_scan_rport);
3085 INIT_WORK(&rport->stgt_delete_work, fc_starget_delete);
3086 INIT_WORK(&rport->rport_delete_work, fc_rport_final_delete);
3090 rport->number = fc_host->next_rport_number++;
3091 if ((rport->roles & FC_PORT_ROLE_FCP_TARGET) ||
3092 (rport->roles & FC_PORT_ROLE_FCP_DUMMY_INITIATOR))
3093 rport->scsi_target_id = fc_host->next_target_id++;
3095 rport->scsi_target_id = -1;
3096 list_add_tail(&rport->peers, &fc_host->rports);
3097 scsi_host_get(shost); /* for fc_host->rport list */
3101 dev = &rport->dev;
3105 dev_set_name(dev, "rport-%d:%d-%d",
3106 shost->host_no, channel, rport->number);
3117 fc_bsg_rportadd(shost, rport);
3120 if (rport->roles & FC_PORT_ROLE_FCP_TARGET) {
3122 rport->flags |= FC_RPORT_SCAN_PENDING;
3123 scsi_queue_work(shost, &rport->scan_work);
3126 return rport;
3131 list_del(&rport->peers);
3132 scsi_host_put(shost); /* for fc_host->rport list */
3135 kfree(rport);
3183 struct fc_rport *rport;
3191 * Search the list of "active" rports, for an rport that has been
3197 list_for_each_entry(rport, &fc_host->rports, peers) {
3199 if ((rport->port_state == FC_PORTSTATE_BLOCKED ||
3200 rport->port_state == FC_PORTSTATE_NOTPRESENT) &&
3201 (rport->channel == channel)) {
3206 if (rport->port_name == ids->port_name)
3210 if (rport->node_name == ids->node_name)
3214 if (rport->port_id == ids->port_id)
3221 memcpy(&rport->node_name, &ids->node_name,
3222 sizeof(rport->node_name));
3223 memcpy(&rport->port_name, &ids->port_name,
3224 sizeof(rport->port_name));
3225 rport->port_id = ids->port_id;
3227 rport->port_state = FC_PORTSTATE_ONLINE;
3228 rport->roles = ids->roles;
3233 memset(rport->dd_data, 0,
3238 * io terminate and rport timers, and
3253 if ((rport->scsi_target_id != -1) &&
3255 return rport;
3262 if (!cancel_delayed_work(&rport->fail_io_work))
3264 if (!cancel_delayed_work(&rport->dev_loss_work))
3269 rport->flags &= ~(FC_RPORT_FAST_FAIL_TIMEDOUT |
3276 if (rport->scsi_target_id != -1) {
3277 scsi_target_unblock(&rport->dev,
3281 rport->flags |= FC_RPORT_SCAN_PENDING;
3283 &rport->scan_work);
3288 fc_bsg_goose_queue(rport);
3290 return rport;
3303 list_for_each_entry(rport, &fc_host->rport_bindings,
3305 if (rport->channel != channel)
3310 if (rport->port_name == ids->port_name)
3314 if (rport->node_name == ids->node_name)
3318 if (rport->port_id == ids->port_id)
3326 list_move_tail(&rport->peers, &fc_host->rports);
3332 memcpy(&rport->node_name, &ids->node_name,
3333 sizeof(rport->node_name));
3334 memcpy(&rport->port_name, &ids->port_name,
3335 sizeof(rport->port_name));
3336 rport->port_id = ids->port_id;
3337 rport->port_state = FC_PORTSTATE_ONLINE;
3338 rport->flags &= ~FC_RPORT_FAST_FAIL_TIMEDOUT;
3341 memset(rport->dd_data, 0,
3345 fc_remote_port_rolechg(rport, ids->roles);
3346 return rport;
3353 rport = fc_remote_port_create(shost, channel, ids);
3355 return rport;
3362 * @rport: The remote port that no longer exists
3385 * temporary blocked state. From the LLDD's perspective, the rport no
3413 fc_remote_port_delete(struct fc_rport *rport)
3415 struct Scsi_Host *shost = rport_to_shost(rport);
3416 unsigned long timeout = rport->dev_loss_tmo;
3422 * We do need to reclaim the rport scan work element, so eventually
3429 if ((rport->port_state != FC_PORTSTATE_ONLINE) &&
3430 (rport->port_state != FC_PORTSTATE_MARGINAL)) {
3437 * unconditionally just jump to deleting the rport.
3439 * and its not appropriate to just terminate the rport at the
3441 * send ELS traffic to re-validate the login. If the rport is
3445 * destroying an rport.
3448 rport->port_state = FC_PORTSTATE_BLOCKED;
3450 rport->flags |= FC_RPORT_DEVLOSS_PENDING;
3454 scsi_block_targets(shost, &rport->dev);
3457 if ((rport->fast_io_fail_tmo != -1) &&
3458 (rport->fast_io_fail_tmo < timeout))
3459 fc_queue_devloss_work(shost, &rport->fail_io_work,
3460 rport->fast_io_fail_tmo * HZ);
3463 fc_queue_devloss_work(shost, &rport->dev_loss_work, timeout * HZ);
3469 * @rport: The remote port that changed.
3488 fc_remote_port_rolechg(struct fc_rport *rport, u32 roles)
3490 struct Scsi_Host *shost = rport_to_shost(rport);
3497 if (rport->scsi_target_id == -1) {
3498 rport->scsi_target_id = fc_host->next_target_id++;
3500 } else if (!(rport->roles & FC_PORT_ROLE_FCP_TARGET))
3504 rport->roles = roles;
3513 * Note: we know the rport exists and is in an online
3514 * state as the LLDD would not have had an rport
3521 if (!cancel_delayed_work(&rport->fail_io_work))
3523 if (!cancel_delayed_work(&rport->dev_loss_work))
3527 rport->flags &= ~(FC_RPORT_FAST_FAIL_TIMEDOUT |
3535 scsi_target_unblock(&rport->dev, SDEV_RUNNING);
3538 rport->flags |= FC_RPORT_SCAN_PENDING;
3539 scsi_queue_work(shost, &rport->scan_work);
3547 * @work: rport target that failed to reappear in the allotted time.
3555 struct fc_rport *rport =
3557 struct Scsi_Host *shost = rport_to_shost(rport);
3565 rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
3572 if (((rport->port_state == FC_PORTSTATE_ONLINE) ||
3573 (rport->port_state == FC_PORTSTATE_MARGINAL)) &&
3574 (rport->scsi_target_id != -1) &&
3575 !(rport->roles & FC_PORT_ROLE_FCP_TARGET)) {
3576 dev_printk(KERN_ERR, &rport->dev,
3580 scsi_target_unblock(&rport->dev, SDEV_TRANSPORT_OFFLINE);
3581 fc_queue_work(shost, &rport->stgt_delete_work);
3586 if (rport->port_state != FC_PORTSTATE_BLOCKED) {
3588 dev_printk(KERN_ERR, &rport->dev,
3590 " rport%s alone\n",
3591 (rport->scsi_target_id != -1) ? " and starget" : "");
3596 (rport->scsi_target_id == -1)) {
3597 list_del(&rport->peers);
3598 rport->port_state = FC_PORTSTATE_DELETED;
3599 dev_printk(KERN_ERR, &rport->dev,
3601 " rport%s\n",
3602 (rport->scsi_target_id != -1) ? " and starget" : "");
3603 fc_queue_work(shost, &rport->rport_delete_work);
3608 dev_printk(KERN_ERR, &rport->dev,
3612 list_move_tail(&rport->peers, &fc_host->rport_bindings);
3623 rport->maxframe_size = -1;
3624 rport->supported_classes = FC_COS_UNSPECIFIED;
3625 rport->roles = FC_PORT_ROLE_UNKNOWN;
3626 rport->port_state = FC_PORTSTATE_NOTPRESENT;
3627 rport->flags &= ~FC_RPORT_FAST_FAIL_TIMEDOUT;
3635 fc_terminate_rport_io(rport);
3639 if (rport->port_state == FC_PORTSTATE_NOTPRESENT) { /* still missing */
3644 rport->node_name = -1;
3645 rport->port_id = -1;
3648 rport->port_name = -1;
3649 rport->port_id = -1;
3652 rport->node_name = -1;
3653 rport->port_name = -1;
3664 rport->flags |= FC_RPORT_DEVLOSS_CALLBK_DONE;
3665 fc_queue_work(shost, &rport->stgt_delete_work);
3673 * Notify the driver that the rport is now dead. The LLDD will
3674 * also guarantee that any communication to the rport is terminated
3679 i->f->dev_loss_tmo_callbk(rport);
3685 * @work: rport to terminate io on.
3693 struct fc_rport *rport =
3696 if (rport->port_state != FC_PORTSTATE_BLOCKED)
3699 rport->flags |= FC_RPORT_FAST_FAIL_TIMEDOUT;
3700 fc_terminate_rport_io(rport);
3710 struct fc_rport *rport =
3712 struct Scsi_Host *shost = rport_to_shost(rport);
3716 if (((rport->port_state == FC_PORTSTATE_ONLINE) ||
3717 (rport->port_state == FC_PORTSTATE_MARGINAL)) &&
3718 (rport->roles & FC_PORT_ROLE_FCP_TARGET) &&
3720 scsi_scan_target(&rport->dev, rport->channel,
3721 rport->scsi_target_id, SCAN_WILD_CARD,
3726 rport->flags &= ~FC_RPORT_SCAN_PENDING;
3732 * @rport: Remote port that scsi_eh is trying to recover.
3744 int fc_block_rport(struct fc_rport *rport)
3746 struct Scsi_Host *shost = rport_to_shost(rport);
3750 while (rport->port_state == FC_PORTSTATE_BLOCKED &&
3751 !(rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT)) {
3758 if (rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT)
3781 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
3783 if (WARN_ON_ONCE(!rport))
3786 return fc_block_rport(rport);
3794 * This checks the rport state to decide if a cmd is
3797 * Returns: true if the rport state is not in marginal state.
3801 struct fc_rport *rport = starget_to_rport(scsi_target(scmd->device));
3803 if ((rport->port_state != FC_PORTSTATE_ONLINE) &&
4053 struct fc_rport *rport = fc_bsg_to_rport(job);
4057 if (rport && rport->port_state == FC_PORTSTATE_BLOCKED)
4081 * @shost: scsi host rport attached to
4160 * fc_bsg_goose_queue - restart rport queue in case it was stopped
4161 * @rport: rport to be restarted
4164 fc_bsg_goose_queue(struct fc_rport *rport)
4166 struct request_queue *q = rport->rqst_q;
4173 * fc_bsg_rport_dispatch - process rport bsg requests and dispatch to LLDD
4174 * @shost: scsi host rport attached to
4191 /* Validate the rport command */
4237 static blk_status_t fc_bsg_rport_prep(struct fc_rport *rport)
4239 if (rport->port_state == FC_PORTSTATE_BLOCKED &&
4240 !(rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT))
4243 if ((rport->port_state != FC_PORTSTATE_ONLINE) &&
4244 (rport->port_state != FC_PORTSTATE_MARGINAL))
4253 struct fc_rport *rport = fc_bsg_to_rport(job);
4256 ret = fc_bsg_rport_prep(rport);
4306 * @shost: shost that rport is attached to
4307 * @rport: rport that the bsg hooks are being attached to
4310 fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport)
4312 struct device *dev = &rport->dev;
4316 rport->rqst_q = NULL;
4329 rport->rqst_q = q;