Commit 07e0984b authored by James Smart's avatar James Smart Committed by Martin K. Petersen

scsi: scsi_transport_fc: Fix FPIN Link Integrity statistics counters

In the original FPIN commit, stats were incremented by the event_count.
Event_count is the minimum # of events that must occur before an FPIN is
sent. Thus, its not the actual number of events, and could be significantly
off (too low) as it doesn't reflect anything not reported.  Rather than
attempt to count events, have the statistic count how many FPINS cross the
threshold and were reported.

Link: https://lore.kernel.org/r/20220301175536.60250-1-jsmart2021@gmail.com
Fixes: 3dcfe0de ("scsi: fc: Parse FPIN packets and update statistics")
Cc: <stable@vger.kernel.org> # v5.11+
Cc: Shyam Sundar <ssundar@marvell.com>
Cc: Nilesh Javali <njavali@marvell.com>
Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: default avatarJames Smart <jsmart2021@gmail.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 32698c95
...@@ -34,7 +34,7 @@ static int fc_bsg_hostadd(struct Scsi_Host *, struct fc_host_attrs *); ...@@ -34,7 +34,7 @@ static int fc_bsg_hostadd(struct Scsi_Host *, struct fc_host_attrs *);
static int fc_bsg_rportadd(struct Scsi_Host *, struct fc_rport *); static int fc_bsg_rportadd(struct Scsi_Host *, struct fc_rport *);
static void fc_bsg_remove(struct request_queue *); static void fc_bsg_remove(struct request_queue *);
static void fc_bsg_goose_queue(struct fc_rport *); static void fc_bsg_goose_queue(struct fc_rport *);
static void fc_li_stats_update(struct fc_fn_li_desc *li_desc, static void fc_li_stats_update(u16 event_type,
struct fc_fpin_stats *stats); struct fc_fpin_stats *stats);
static void fc_delivery_stats_update(u32 reason_code, static void fc_delivery_stats_update(u32 reason_code,
struct fc_fpin_stats *stats); struct fc_fpin_stats *stats);
...@@ -670,42 +670,34 @@ fc_find_rport_by_wwpn(struct Scsi_Host *shost, u64 wwpn) ...@@ -670,42 +670,34 @@ fc_find_rport_by_wwpn(struct Scsi_Host *shost, u64 wwpn)
EXPORT_SYMBOL(fc_find_rport_by_wwpn); EXPORT_SYMBOL(fc_find_rport_by_wwpn);
static void static void
fc_li_stats_update(struct fc_fn_li_desc *li_desc, fc_li_stats_update(u16 event_type,
struct fc_fpin_stats *stats) struct fc_fpin_stats *stats)
{ {
stats->li += be32_to_cpu(li_desc->event_count); stats->li++;
switch (be16_to_cpu(li_desc->event_type)) { switch (event_type) {
case FPIN_LI_UNKNOWN: case FPIN_LI_UNKNOWN:
stats->li_failure_unknown += stats->li_failure_unknown++;
be32_to_cpu(li_desc->event_count);
break; break;
case FPIN_LI_LINK_FAILURE: case FPIN_LI_LINK_FAILURE:
stats->li_link_failure_count += stats->li_link_failure_count++;
be32_to_cpu(li_desc->event_count);
break; break;
case FPIN_LI_LOSS_OF_SYNC: case FPIN_LI_LOSS_OF_SYNC:
stats->li_loss_of_sync_count += stats->li_loss_of_sync_count++;
be32_to_cpu(li_desc->event_count);
break; break;
case FPIN_LI_LOSS_OF_SIG: case FPIN_LI_LOSS_OF_SIG:
stats->li_loss_of_signals_count += stats->li_loss_of_signals_count++;
be32_to_cpu(li_desc->event_count);
break; break;
case FPIN_LI_PRIM_SEQ_ERR: case FPIN_LI_PRIM_SEQ_ERR:
stats->li_prim_seq_err_count += stats->li_prim_seq_err_count++;
be32_to_cpu(li_desc->event_count);
break; break;
case FPIN_LI_INVALID_TX_WD: case FPIN_LI_INVALID_TX_WD:
stats->li_invalid_tx_word_count += stats->li_invalid_tx_word_count++;
be32_to_cpu(li_desc->event_count);
break; break;
case FPIN_LI_INVALID_CRC: case FPIN_LI_INVALID_CRC:
stats->li_invalid_crc_count += stats->li_invalid_crc_count++;
be32_to_cpu(li_desc->event_count);
break; break;
case FPIN_LI_DEVICE_SPEC: case FPIN_LI_DEVICE_SPEC:
stats->li_device_specific += stats->li_device_specific++;
be32_to_cpu(li_desc->event_count);
break; break;
} }
} }
...@@ -767,6 +759,7 @@ fc_fpin_li_stats_update(struct Scsi_Host *shost, struct fc_tlv_desc *tlv) ...@@ -767,6 +759,7 @@ fc_fpin_li_stats_update(struct Scsi_Host *shost, struct fc_tlv_desc *tlv)
struct fc_rport *attach_rport = NULL; struct fc_rport *attach_rport = NULL;
struct fc_host_attrs *fc_host = shost_to_fc_host(shost); struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
struct fc_fn_li_desc *li_desc = (struct fc_fn_li_desc *)tlv; struct fc_fn_li_desc *li_desc = (struct fc_fn_li_desc *)tlv;
u16 event_type = be16_to_cpu(li_desc->event_type);
u64 wwpn; u64 wwpn;
rport = fc_find_rport_by_wwpn(shost, rport = fc_find_rport_by_wwpn(shost,
...@@ -775,7 +768,7 @@ fc_fpin_li_stats_update(struct Scsi_Host *shost, struct fc_tlv_desc *tlv) ...@@ -775,7 +768,7 @@ fc_fpin_li_stats_update(struct Scsi_Host *shost, struct fc_tlv_desc *tlv)
(rport->roles & FC_PORT_ROLE_FCP_TARGET || (rport->roles & FC_PORT_ROLE_FCP_TARGET ||
rport->roles & FC_PORT_ROLE_NVME_TARGET)) { rport->roles & FC_PORT_ROLE_NVME_TARGET)) {
attach_rport = rport; attach_rport = rport;
fc_li_stats_update(li_desc, &attach_rport->fpin_stats); fc_li_stats_update(event_type, &attach_rport->fpin_stats);
} }
if (be32_to_cpu(li_desc->pname_count) > 0) { if (be32_to_cpu(li_desc->pname_count) > 0) {
...@@ -789,14 +782,14 @@ fc_fpin_li_stats_update(struct Scsi_Host *shost, struct fc_tlv_desc *tlv) ...@@ -789,14 +782,14 @@ fc_fpin_li_stats_update(struct Scsi_Host *shost, struct fc_tlv_desc *tlv)
rport->roles & FC_PORT_ROLE_NVME_TARGET)) { rport->roles & FC_PORT_ROLE_NVME_TARGET)) {
if (rport == attach_rport) if (rport == attach_rport)
continue; continue;
fc_li_stats_update(li_desc, fc_li_stats_update(event_type,
&rport->fpin_stats); &rport->fpin_stats);
} }
} }
} }
if (fc_host->port_name == be64_to_cpu(li_desc->attached_wwpn)) if (fc_host->port_name == be64_to_cpu(li_desc->attached_wwpn))
fc_li_stats_update(li_desc, &fc_host->fpin_stats); fc_li_stats_update(event_type, &fc_host->fpin_stats);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment