Add fc_fpin_set_marginal function to evaluate the FPIN LI TLV information and set the 'marginal' path status for all affected nvme rports. Then call set_rport_marginal() callback added to fc_function_template. The implementation of set_rport_marginal() is almost identical to set_rport_dev_loss_tmo implementation. Signed-off-by: Jesse Taube --- V10 -> V11: - New commit - Replaces scsi: scsi_transport_fc: add fc_host_fpin_set_nvme_rport_marginal() --- drivers/scsi/scsi_transport_fc.c | 20 ++++++++++++++++++++ include/scsi/scsi_transport_fc.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index 02c58f4591d8..df1edf3c23fa 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c @@ -737,6 +737,25 @@ fc_cn_stats_update(u16 event_type, struct fc_fpin_stats *stats) } } +static void fc_fpin_set_marginal(struct Scsi_Host *shost, struct fc_rport *rport) +{ + struct fc_internal *i = to_fc_internal(shost->transportt); + unsigned long flags; + + spin_lock_irqsave(shost->host_lock, flags); + + if (rport->port_state == FC_PORTSTATE_ONLINE && + rport->roles & FC_PORT_ROLE_NVME_TARGET) { + rport->port_state = FC_PORTSTATE_MARGINAL; + spin_unlock_irqrestore(shost->host_lock, flags); + if (i->f->set_rport_marginal) + i->f->set_rport_marginal(rport, true); + return; + } + + spin_unlock_irqrestore(shost->host_lock, flags); +} + static void fc_fpin_pname_stats_update(struct Scsi_Host *shost, struct fc_rport *attach_rport, u16 event_type, @@ -764,6 +783,7 @@ fc_fpin_pname_stats_update(struct Scsi_Host *shost, if (rport == attach_rport) continue; stats_update(event_type, &rport->fpin_stats); + fc_fpin_set_marginal(shost, rport); } } } diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h index 9f30625aa0d3..bc7c3f832399 100644 --- a/include/scsi/scsi_transport_fc.h +++ b/include/scsi/scsi_transport_fc.h @@ -684,6 +684,7 @@ struct fc_host_attrs { struct fc_function_template { void (*get_rport_dev_loss_tmo)(struct fc_rport *); void (*set_rport_dev_loss_tmo)(struct fc_rport *, u32); + void (*set_rport_marginal)(struct fc_rport *rport, bool marginal); void (*get_starget_node_name)(struct scsi_target *); void (*get_starget_port_name)(struct scsi_target *); -- 2.54.0