nvme-fc: FPIN link integrity handling
Subsystems (6)
v4 cover nvme-fc: FPIN link integrity handling
FPIN LI (link integrity) messages are received when the attached fabric detects hardware errors. In response to these messages I/O should be directed away from the affected ports, and only used if the 'optimized' paths are unavailable.
Upon port reset the paths should be put back in service as the affected hardware might have been replaced.
This patch adds a new controller flag 'NVME_CTRL_MARGINAL' which will be checked during multipath path selection, causing the path to be skipped when checking for 'optimized' paths. If no optimized paths are available the 'marginal' paths are considered for path selection alongside the 'non-optimized' paths. It also introduces a new nvme-fc callback 'nvme_fc_fpin_rcv()' to evaluate the FPIN LI TLV payload and set the 'marginal' state on all affected rports.
Changes to the original submission:
- Changed flag name to 'marginal'
- Do not block marginal path; influence path selection instead to de-prioritize marginal paths
Changes to v2:
- Split off driver-specific modifications
- Introduce 'union fc_tlv_desc' to avoid casts
Changes to v3:
- Include reviews from Justin Tee
- Split marginal path handling patch
Hannes Reinecke (5):
fc_els: use 'union fc_tlv_desc'
nvme-fc: marginal path handling
nvme-fc: nvme_fc_fpin_rcv() callback
lpfc: enable FPIN notification for NVMe
qla2xxx: enable FPIN notification for NVMe
drivers/nvme/host/core.c | 1 + drivers/nvme/host/fc.c | 99 +++++++++++++++++++ drivers/nvme/host/multipath.c | 17 ++-- drivers/nvme/host/nvme.h | 6 ++ drivers/scsi/lpfc/lpfc_els.c | 84 ++++++++-------- drivers/scsi/qla2xxx/qla_isr.c | 3 + drivers/scsi/scsi_transport_fc.c | 27 +++-- include/linux/nvme-fc-driver.h | 3 + include/uapi/scsi/fc/fc_els.h | 165 +++++++++++++++++-------------- 9 files changed, 266 insertions(+), 139 deletions(-)
Signature · 1 line
2.35.3
PATCH v4 1/5 fc_els: use 'union fc_tlv_desc'
Introduce 'union fc_tlv_desc' to have a common structure for all FC ELS TLV structures and avoid type casts.
--- drivers/scsi/lpfc/lpfc_els.c | 75 +++++++------- drivers/scsi/scsi_transport_fc.c | 27 +++-- include/uapi/scsi/fc/fc_els.h | 165 +++++++++++++++++-------------- 3 files changed, 135 insertions(+), 132 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +34 -41
@@ -3937,7 +3937,7 @@ lpfc_cmpl_els_edc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, {IOCB_t *irsp_iocb;struct fc_els_edc_resp *edc_rsp; -struct fc_tlv_desc *tlv; +union fc_tlv_desc *tlv;struct fc_diag_cg_sig_desc *pcgd;struct fc_diag_lnkflt_desc *plnkflt;struct lpfc_dmabuf *pcmd, *prsp;
@@ -4028,7 +4028,7 @@ lpfc_cmpl_els_edc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, goto out; } - dtag =be32_to_cpu (tlv->desc_tag); + dtag =be32_to_cpu (tlv->hdr.desc_tag);switch (dtag) {case ELS_DTAG_LNK_FAULT_CAP : if (bytes_remain < FC_TLV_DESC_SZ_FROM_LENGTH(tlv) ||
@@ -4043,7 +4043,7 @@ lpfc_cmpl_els_edc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, sizeof(struct fc_diag_lnkflt_desc)); goto out; } - plnkflt = (struct fc_diag_lnkflt_desc *)tlv; + plnkflt = &tlv->lnkflt;lpfc_printf_log (phba,KERN_INFO ,LOG_ELS |LOG_LDS_EVENT , "4617 Link Fault Desc Data: 0x%08x 0x%08x "
@@ -4070,7 +4070,7 @@ lpfc_cmpl_els_edc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, goto out; } - pcgd = (struct fc_diag_cg_sig_desc *)tlv; + pcgd = &tlv->cg_sig;lpfc_printf_log ( phba,KERN_INFO ,LOG_ELS |LOG_CGN_MGMT , "4616 CGN Desc Data: 0x%08x 0x%08x "
@@ -4125,10 +4125,8 @@ lpfc_cmpl_els_edc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, }static void -lpfc_format_edc_lft_desc (struct lpfc_hba *phba,struct fc_tlv_desc *tlv) +lpfc_format_edc_lft_desc (struct lpfc_hba *phba,struct fc_diag_lnkflt_desc *lft) { -struct fc_diag_lnkflt_desc *lft = (struct fc_diag_lnkflt_desc *)tlv; - lft->desc_tag =cpu_to_be32 (ELS_DTAG_LNK_FAULT_CAP ); lft->desc_len =cpu_to_be32 ( FC_TLV_DESC_LENGTH_FROM_SZ(struct fc_diag_lnkflt_desc));
@@ -4141,10 +4139,8 @@ lpfc_format_edc_lft_desc(struct lpfc_hba *phba, struct fc_tlv_desc *tlv) }static void -lpfc_format_edc_cgn_desc (struct lpfc_hba *phba,struct fc_tlv_desc *tlv) +lpfc_format_edc_cgn_desc (struct lpfc_hba *phba,struct fc_diag_cg_sig_desc *cgd) { -struct fc_diag_cg_sig_desc *cgd = (struct fc_diag_cg_sig_desc *)tlv; -/* We are assuming cgd was zero'ed before calling this routine */ /* Configure the congestion detection capability */
@@ -4233,7 +4229,7 @@ lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry)struct lpfc_hba *phba = vport->phba;struct lpfc_iocbq *elsiocb;struct fc_els_edc *edc_req; -struct fc_tlv_desc *tlv; +union fc_tlv_desc *tlv;u16 cmdsize;struct lpfc_nodelist *ndlp;u8 *pcmd =NULL ;
@@ -4272,13 +4268,13 @@ lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry) tlv = edc_req->desc;if (cgn_desc_size) { -lpfc_format_edc_cgn_desc (phba, tlv); +lpfc_format_edc_cgn_desc (phba, &tlv->cg_sig); phba->cgn_sig_freq = lpfc_fabric_cgn_frequency; tlv =fc_tlv_next_desc (tlv); }if (lft_desc_size) -lpfc_format_edc_lft_desc (phba, tlv); +lpfc_format_edc_lft_desc (phba, &tlv->lnkflt);lpfc_printf_vlog (vport,KERN_INFO ,LOG_ELS |LOG_CGN_MGMT , "4623 Xmit EDC to remote "
@@ -5823,7 +5819,7 @@ lpfc_issue_els_edc_rsp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, {struct lpfc_hba *phba = vport->phba;struct fc_els_edc_resp *edc_rsp; -struct fc_tlv_desc *tlv; +union fc_tlv_desc *tlv;struct lpfc_iocbq *elsiocb;IOCB_t *icmd, *cmd;union lpfc_wqe128 *wqe;
@@ -5867,10 +5863,10 @@ lpfc_issue_els_edc_rsp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, FC_TLV_DESC_LENGTH_FROM_SZ(struct fc_els_lsri_desc)); edc_rsp->lsri.rqst_w0.cmd =ELS_EDC ; tlv = edc_rsp->desc; -lpfc_format_edc_cgn_desc (phba, tlv); +lpfc_format_edc_cgn_desc (phba, &tlv->cg_sig); tlv =fc_tlv_next_desc (tlv);if (lft_desc_size) -lpfc_format_edc_lft_desc (phba, tlv); +lpfc_format_edc_lft_desc (phba, &tlv->lnkflt); lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, "Issue EDC ACC: did:x%x flg:x%lx refcnt %d",
@@ -9255,7 +9251,7 @@ lpfc_els_rcv_edc(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, {struct lpfc_hba *phba = vport->phba;struct fc_els_edc *edc_req; -struct fc_tlv_desc *tlv; +union fc_tlv_desc *tlv;uint8_t *payload;uint32_t *ptr, dtag;const char *dtag_nm;
@@ -9298,7 +9294,7 @@ lpfc_els_rcv_edc(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, goto out; } - dtag =be32_to_cpu (tlv->desc_tag); + dtag =be32_to_cpu (tlv->hdr.desc_tag);switch (dtag) {case ELS_DTAG_LNK_FAULT_CAP : if (bytes_remain < FC_TLV_DESC_SZ_FROM_LENGTH(tlv) ||
@@ -9313,7 +9309,7 @@ lpfc_els_rcv_edc(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, sizeof(struct fc_diag_lnkflt_desc)); goto out; } - plnkflt = (struct fc_diag_lnkflt_desc *)tlv; + plnkflt = &tlv->lnkflt;lpfc_printf_log (phba,KERN_INFO ,LOG_ELS |LOG_LDS_EVENT , "4626 Link Fault Desc Data: x%08x len x%x "
@@ -9350,7 +9346,7 @@ lpfc_els_rcv_edc(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, phba->cgn_sig_freq = lpfc_fabric_cgn_frequency;lpfc_least_capable_settings ( - phba, (struct fc_diag_cg_sig_desc *)tlv); + phba, &tlv->cg_sig);break ;default : dtag_nm =lpfc_get_tlv_dtag_nm (dtag);
@@ -9941,14 +9937,13 @@ lpfc_display_fpin_wwpn(struct lpfc_hba *phba, __be64 *wwnlist, u32 cnt)/** * lpfc_els_rcv_fpin_li - Process an FPIN Link Integrity Event. * @phba: Pointer to phba object. -* @tlv: Pointer to the Link Integrity Notification Descriptor. +* @li: Pointer to the Link Integrity Notification Descriptor. * * This function processes a Link Integrity FPIN event by logging a message. **/ static void -lpfc_els_rcv_fpin_li (struct lpfc_hba *phba,struct fc_tlv_desc *tlv) +lpfc_els_rcv_fpin_li (struct lpfc_hba *phba,struct fc_fn_li_desc *li) { -struct fc_fn_li_desc *li = (struct fc_fn_li_desc *)tlv;const char *li_evt_str;u32 li_evt, cnt;
@@ -9972,14 +9967,13 @@ lpfc_els_rcv_fpin_li(struct lpfc_hba *phba, struct fc_tlv_desc *tlv)/** * lpfc_els_rcv_fpin_del - Process an FPIN Delivery Event. * @phba: Pointer to hba object. -* @tlv: Pointer to the Delivery Notification Descriptor TLV +* @del: Pointer to the Delivery Notification Descriptor TLV * * This function processes a Delivery FPIN event by logging a message. **/ static void -lpfc_els_rcv_fpin_del (struct lpfc_hba *phba,struct fc_tlv_desc *tlv) +lpfc_els_rcv_fpin_del (struct lpfc_hba *phba,struct fc_fn_deli_desc *del) { -struct fc_fn_deli_desc *del = (struct fc_fn_deli_desc *)tlv;const char *del_rsn_str;u32 del_rsn;__be32 *frame;
@@ -10010,14 +10004,14 @@ lpfc_els_rcv_fpin_del(struct lpfc_hba *phba, struct fc_tlv_desc *tlv)/** * lpfc_els_rcv_fpin_peer_cgn - Process a FPIN Peer Congestion Event. * @phba: Pointer to hba object. -* @tlv: Pointer to the Peer Congestion Notification Descriptor TLV +* @pc: Pointer to the Peer Congestion Notification Descriptor TLV * * This function processes a Peer Congestion FPIN event by logging a message. **/ static void -lpfc_els_rcv_fpin_peer_cgn (struct lpfc_hba *phba,struct fc_tlv_desc *tlv) +lpfc_els_rcv_fpin_peer_cgn (struct lpfc_hba *phba, +struct fc_fn_peer_congn_desc *pc) { -struct fc_fn_peer_congn_desc *pc = (struct fc_fn_peer_congn_desc *)tlv;const char *pc_evt_str;u32 pc_evt, cnt;
@@ -10045,7 +10039,7 @@ lpfc_els_rcv_fpin_peer_cgn(struct lpfc_hba *phba, struct fc_tlv_desc *tlv)/** * lpfc_els_rcv_fpin_cgn - Process an FPIN Congestion notification * @phba: Pointer to hba object. -* @tlv: Pointer to the Congestion Notification Descriptor TLV +* @cgn: Pointer to the Congestion Notification Descriptor TLV * * This function processes an FPIN Congestion Notifiction. The notification * could be an Alarm or Warning. This routine feeds that data into driver's
@@ -10054,10 +10048,9 @@ lpfc_els_rcv_fpin_peer_cgn(struct lpfc_hba *phba, struct fc_tlv_desc *tlv)* to the upper layer or 0 to indicate don't deliver it. **/ static int -lpfc_els_rcv_fpin_cgn (struct lpfc_hba *phba,struct fc_tlv_desc *tlv) +lpfc_els_rcv_fpin_cgn (struct lpfc_hba *phba,struct fc_fn_congn_desc *cgn) {struct lpfc_cgn_info *cp; -struct fc_fn_congn_desc *cgn = (struct fc_fn_congn_desc *)tlv;const char *cgn_evt_str;u32 cgn_evt;const char *cgn_sev_str;
@@ -10160,7 +10153,7 @@ lpfc_els_rcv_fpin(struct lpfc_vport *vport, void *p, u32 fpin_length) {struct lpfc_hba *phba = vport->phba;struct fc_els_fpin *fpin = (struct fc_els_fpin *)p; -struct fc_tlv_desc *tlv, *first_tlv, *current_tlv; +union fc_tlv_desc *tlv, *first_tlv, *current_tlv;const char *dtag_nm;int desc_cnt =0 , bytes_remain, cnt;u32 dtag, deliver =0 ;
@@ -10185,7 +10178,7 @@ lpfc_els_rcv_fpin(struct lpfc_vport *vport, void *p, u32 fpin_length)return ; } - tlv = (struct fc_tlv_desc *)&fpin->fpin_desc[0 ]; + tlv = &fpin->fpin_desc[0 ]; first_tlv = tlv; bytes_remain = fpin_length - offsetof(struct fc_els_fpin , fpin_desc); bytes_remain =min_t (u32, bytes_remain,be32_to_cpu (fpin->desc_len));
@@ -10193,22 +10186,22 @@ lpfc_els_rcv_fpin(struct lpfc_vport *vport, void *p, u32 fpin_length)/* process each descriptor separately */ while (bytes_remain >=FC_TLV_DESC_HDR_SZ && bytes_remain >=FC_TLV_DESC_SZ_FROM_LENGTH (tlv)) { - dtag =be32_to_cpu (tlv->desc_tag); + dtag =be32_to_cpu (tlv->hdr.desc_tag);switch (dtag) {case ELS_DTAG_LNK_INTEGRITY : -lpfc_els_rcv_fpin_li (phba, tlv); +lpfc_els_rcv_fpin_li (phba, &tlv->li); deliver =1 ;break ;case ELS_DTAG_DELIVERY : -lpfc_els_rcv_fpin_del (phba, tlv); +lpfc_els_rcv_fpin_del (phba, &tlv->deli); deliver =1 ;break ;case ELS_DTAG_PEER_CONGEST : -lpfc_els_rcv_fpin_peer_cgn (phba, tlv); +lpfc_els_rcv_fpin_peer_cgn (phba, &tlv->peer_congn); deliver =1 ;break ;case ELS_DTAG_CONGESTION : - deliver =lpfc_els_rcv_fpin_cgn (phba, tlv); + deliver =lpfc_els_rcv_fpin_cgn (phba, &tlv->congn);break ;default : dtag_nm =lpfc_get_tlv_dtag_nm (dtag);
@@ -10221,12 +10214,12 @@ lpfc_els_rcv_fpin(struct lpfc_vport *vport, void *p, u32 fpin_length)return ; }lpfc_cgn_update_stat (phba, dtag); - cnt =be32_to_cpu (tlv->desc_len); + cnt =be32_to_cpu (tlv->hdr.desc_len);/* Sanity check descriptor length. The desc_len value does not * include space for the desc_tag and the desc_len fields. */ - len -= (cnt +sizeof (struct fc_tlv_desc )); + len -= (cnt +sizeof (struct fc_tlv_desc_hdr ));if (len <0 ) { dtag_nm =lpfc_get_tlv_dtag_nm (dtag); lpfc_printf_log(phba, KERN_WARNING, LOG_CGN_MGMT,
drivers/scsi/scsi_transport_fc.c +11 -16
@@ -750,13 +750,12 @@ fc_cn_stats_update(u16 event_type, struct fc_fpin_stats *stats)* */ static void -fc_fpin_li_stats_update (struct Scsi_Host *shost,struct fc_tlv_desc *tlv) +fc_fpin_li_stats_update (struct Scsi_Host *shost,struct fc_fn_li_desc *li_desc) {u8 i;struct fc_rport *rport =NULL ;struct fc_rport *attach_rport =NULL ;struct fc_host_attrs *fc_host =shost_to_fc_host (shost); -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;
@@ -799,12 +798,11 @@ fc_fpin_li_stats_update(struct Scsi_Host *shost, struct fc_tlv_desc *tlv)*/ static void fc_fpin_delivery_stats_update (struct Scsi_Host *shost, -struct fc_tlv_desc *tlv) +struct fc_fn_deli_desc *dn_desc) {struct fc_rport *rport =NULL ;struct fc_rport *attach_rport =NULL ;struct fc_host_attrs *fc_host =shost_to_fc_host (shost); -struct fc_fn_deli_desc *dn_desc = (struct fc_fn_deli_desc *)tlv;u32 reason_code =be32_to_cpu (dn_desc->deli_reason_code); rport = fc_find_rport_by_wwpn(shost,
@@ -830,13 +828,11 @@ fc_fpin_delivery_stats_update(struct Scsi_Host *shost,*/ static void fc_fpin_peer_congn_stats_update (struct Scsi_Host *shost, -struct fc_tlv_desc *tlv) +struct fc_fn_peer_congn_desc *pc_desc) {u8 i;struct fc_rport *rport =NULL ;struct fc_rport *attach_rport =NULL ; -struct fc_fn_peer_congn_desc *pc_desc = - (struct fc_fn_peer_congn_desc *)tlv;u16 event_type =be16_to_cpu (pc_desc->event_type);u64 wwpn;
@@ -876,10 +872,9 @@ fc_fpin_peer_congn_stats_update(struct Scsi_Host *shost,*/ static void fc_fpin_congn_stats_update (struct Scsi_Host *shost, -struct fc_tlv_desc *tlv) +struct fc_fn_congn_desc *congn) {struct fc_host_attrs *fc_host =shost_to_fc_host (shost); -struct fc_fn_congn_desc *congn = (struct fc_fn_congn_desc *)tlv;fc_cn_stats_update (be16_to_cpu (congn->event_type), &fc_host->fpin_stats);
@@ -899,32 +894,32 @@ fc_host_fpin_rcv(struct Scsi_Host *shost, u32 fpin_len, char *fpin_buf, u8 event_acknowledge) {struct fc_els_fpin *fpin = (struct fc_els_fpin *)fpin_buf; -struct fc_tlv_desc *tlv; +union fc_tlv_desc *tlv;u32 bytes_remain;u32 dtag;enum fc_host_event_code event_code = event_acknowledge ?FCH_EVT_LINK_FPIN_ACK :FCH_EVT_LINK_FPIN ;/* Update Statistics */ - tlv = (struct fc_tlv_desc *)&fpin->fpin_desc[0 ]; + tlv = &fpin->fpin_desc[0 ]; bytes_remain = fpin_len - offsetof(struct fc_els_fpin , fpin_desc); bytes_remain =min_t (u32, bytes_remain,be32_to_cpu (fpin->desc_len));while (bytes_remain >=FC_TLV_DESC_HDR_SZ && bytes_remain >=FC_TLV_DESC_SZ_FROM_LENGTH (tlv)) { - dtag =be32_to_cpu (tlv->desc_tag); + dtag =be32_to_cpu (tlv->hdr.desc_tag);switch (dtag) {case ELS_DTAG_LNK_INTEGRITY : -fc_fpin_li_stats_update (shost, tlv); +fc_fpin_li_stats_update (shost, &tlv->li);break ;case ELS_DTAG_DELIVERY : -fc_fpin_delivery_stats_update (shost, tlv); +fc_fpin_delivery_stats_update (shost, &tlv->deli);break ;case ELS_DTAG_PEER_CONGEST : -fc_fpin_peer_congn_stats_update (shost, tlv); +fc_fpin_peer_congn_stats_update (shost, &tlv->peer_congn);break ;case ELS_DTAG_CONGESTION : -fc_fpin_congn_stats_update (shost, tlv); +fc_fpin_congn_stats_update (shost, &tlv->congn); } bytes_remain -=FC_TLV_DESC_SZ_FROM_LENGTH (tlv);
include/uapi/scsi/fc/fc_els.h +90 -75
215 lines not on this page · raw message
Signature · 1 line
2.35.3
Re: [PATCH 1/5] fc_els: use 'union fc_tlv_desc'
Regards,
Justin
PATCH v4 2/5 nvme-fc: marginal path handling
In reply to Hannes ReineckeFPIN LI (link integrity) messages are received when the attached fabric detects hardware errors. In response to these messages I/O should be directed away from the affected ports, and only used if the 'optimized' paths are unavailable.
To handle this a new controller flag 'NVME_CTRL_MARGINAL' is added which will cause the multipath scheduler to skip these paths when checking for 'optimized' paths. They are, however, still eligible for non-optimized path selected. The flag is cleared upon reset as then the faulty hardware might be replaced.
--- drivers/nvme/host/core.c | 1 + drivers/nvme/host/fc.c | 4 ++++ drivers/nvme/host/multipath.c | 17 +++++++++++------ drivers/nvme/host/nvme.h | 6 ++++++ 4 files changed, 22 insertions(+), 6 deletions(-)
drivers/nvme/host/core.c +1 -0
@@ -4833,6 +4833,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,WRITE_ONCE (ctrl->state,NVME_CTRL_NEW ); ctrl->passthru_err_log_enabled = false;clear_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags); +clear_bit (NVME_CTRL_MARGINAL , &ctrl->flags);spin_lock_init (&ctrl->lock);mutex_init (&ctrl->namespaces_lock);
drivers/nvme/host/fc.c +4 -0
@@ -786,6 +786,10 @@ nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctrl) "Reconnect", ctrl->cnum);set_bit (ASSOC_FAILED , &ctrl->flags); + +/* clear 'marginal' flag as controller will be reset */ +clear_bit (NVME_CTRL_MARGINAL , &ctrl->flags); +nvme_reset_ctrl (&ctrl->ctrl); }
drivers/nvme/host/multipath.c +11 -6
@@ -273,11 +273,14 @@ static struct nvme_ns *__nvme_find_path(struct nvme_ns_head *head, int node)switch (ns->ana_state) {case NVME_ANA_OPTIMIZED : -if (distance < found_distance) { - found_distance = distance; - found = ns; +if (!nvme_ctrl_is_marginal (ns->ctrl)) { +if (distance < found_distance) { + found_distance = distance; + found = ns; + } +break ; } -break ; + fallthrough;case NVME_ANA_NONOPTIMIZED :if (distance < fallback_distance) { fallback_distance = distance;
@@ -330,7 +333,8 @@ static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head)if (ns->ana_state ==NVME_ANA_OPTIMIZED ) { found = ns; - goto out; +if (!nvme_ctrl_is_marginal (ns->ctrl)) + goto out; }if (ns->ana_state ==NVME_ANA_NONOPTIMIZED ) found = ns;
@@ -394,7 +398,8 @@ static struct nvme_ns *nvme_queue_depth_path(struct nvme_ns_head *head)static inline bool nvme_path_is_optimized (struct nvme_ns *ns) {return nvme_ctrl_state (ns->ctrl) ==NVME_CTRL_LIVE && - ns->ana_state ==NVME_ANA_OPTIMIZED ; + ns->ana_state ==NVME_ANA_OPTIMIZED && + !nvme_ctrl_is_marginal (ns->ctrl); }static struct nvme_ns *nvme_numa_path (struct nvme_ns_head *head)
drivers/nvme/host/nvme.h +6 -0
@@ -275,6 +275,7 @@ enum nvme_ctrl_flags {NVME_CTRL_SKIP_ID_CNS_CS =4 ,NVME_CTRL_DIRTY_CAPABILITY =5 ,NVME_CTRL_FROZEN =6 , + NVME_CTRL_MARGINAL = 7, }; struct nvme_ctrl {
@@ -417,6 +418,11 @@ static inline enum nvme_ctrl_state nvme_ctrl_state(struct nvme_ctrl *ctrl)return READ_ONCE (ctrl->state); } +static inline bool nvme_ctrl_is_marginal (struct nvme_ctrl *ctrl) +{ +return test_bit (NVME_CTRL_MARGINAL , &ctrl->flags); +} +enum nvme_iopolicy {NVME_IOPOLICY_NUMA ,NVME_IOPOLICY_RR ,
Signature · 1 line
2.35.3
PATCH v4 3/5 nvme-fc: nvme_fc_fpin_rcv() callback
In reply to Hannes ReineckeAdd a callback nvme_fc_fpin_rcv() to evaluate the FPIN LI TLV information and set the 'marginal' path status for all affected rports.
--- drivers/nvme/host/fc.c | 95 ++++++++++++++++++++++++++++++++++ include/linux/nvme-fc-driver.h | 3 ++ 2 files changed, 98 insertions(+)
drivers/nvme/host/fc.c +95 -0
@@ -3717,6 +3717,101 @@ static struct nvmf_transport_ops nvme_fc_transport = { .create_ctrl = nvme_fc_create_ctrl, }; +static struct nvme_fc_rport *nvme_fc_rport_from_wwpn (struct nvme_fc_lport *lport, +u64 rport_wwpn) +{ +struct nvme_fc_rport *rport; + +list_for_each_entry (rport, &lport->endp_list, endp_list) { +if (!nvme_fc_rport_get (rport)) +continue ; +if (rport->remoteport.port_name == rport_wwpn && + rport->remoteport.port_role &FC_PORT_ROLE_NVME_TARGET ) +return rport; +nvme_fc_rport_put (rport); + } +return NULL ; +} + +static void +nvme_fc_fpin_li_lport_update (struct nvme_fc_lport *lport,struct fc_fn_li_desc *li) +{ +unsigned int i, pname_count =be32_to_cpu (li->pname_count); +u64 attached_wwpn =be64_to_cpu (li->attached_wwpn); +struct nvme_fc_rport *attached_rport; + +for (i =0 ; i < pname_count; i++) { +struct nvme_fc_rport *rport; +u64 wwpn =be64_to_cpu (li->pname_list[i]); + + rport =nvme_fc_rport_from_wwpn (lport, wwpn); +if (!rport) +continue ; +if (wwpn != attached_wwpn) { +struct nvme_fc_ctrl *ctrl; + +spin_lock_irq (&rport->lock); +list_for_each_entry (ctrl, &rport->ctrl_list, ctrl_list) +set_bit (NVME_CTRL_MARGINAL , &ctrl->ctrl.flags); +spin_unlock_irq (&rport->lock); + } +nvme_fc_rport_put (rport); + } + + attached_rport =nvme_fc_rport_from_wwpn (lport, attached_wwpn); +if (attached_rport) { +struct nvme_fc_ctrl *ctrl; + +spin_lock_irq (&attached_rport->lock); +list_for_each_entry (ctrl, &attached_rport->ctrl_list, ctrl_list) +set_bit (NVME_CTRL_MARGINAL , &ctrl->ctrl.flags); +spin_unlock_irq (&attached_rport->lock); +nvme_fc_rport_put (attached_rport); + } +} + +/** +* fc_host_fpin_rcv() - Process a received FPIN. +* @localport: local port the FPIN was received on +* @fpin_len: length of FPIN payload, in bytes +* @fpin_buf: pointer to FPIN payload +* Notes: +* This routine assumes no locks are held on entry. +*/ +void +nvme_fc_fpin_rcv (struct nvme_fc_local_port *localport, +u32 fpin_len,char *fpin_buf) +{ +struct nvme_fc_lport *lport; +struct fc_els_fpin *fpin = (struct fc_els_fpin *)fpin_buf; +union fc_tlv_desc *tlv; +u32 bytes_remain; +u32 dtag; + +if (!localport) +return ; + lport =localport_to_lport (localport); + tlv = &fpin->fpin_desc[0 ]; + bytes_remain = fpin_len - offsetof(struct fc_els_fpin , fpin_desc); + bytes_remain =min_t (u32, bytes_remain,be32_to_cpu (fpin->desc_len)); + +while (bytes_remain >=FC_TLV_DESC_HDR_SZ && + bytes_remain >=FC_TLV_DESC_SZ_FROM_LENGTH (tlv)) { + dtag =be32_to_cpu (tlv->hdr.desc_tag); +switch (dtag) { +case ELS_DTAG_LNK_INTEGRITY : +nvme_fc_fpin_li_lport_update (lport, &tlv->li); +break ; +default : +break ; + } + + bytes_remain -=FC_TLV_DESC_SZ_FROM_LENGTH (tlv); + tlv =fc_tlv_next_desc (tlv); + } +} +EXPORT_SYMBOL (nvme_fc_fpin_rcv); +/* Arbitrary successive failures max. With lots of subsystems could be high */ #define DISCOVERY_MAX_FAIL 20
include/linux/nvme-fc-driver.h +3 -0
@@ -536,6 +536,9 @@ void nvme_fc_rescan_remoteport(struct nvme_fc_remote_port *remoteport);int nvme_fc_set_remoteport_devloss (struct nvme_fc_remote_port *remoteport,u32 dev_loss_tmo); +void nvme_fc_fpin_rcv (struct nvme_fc_local_port *localport, +u32 fpin_len,char *fpin_buf); +/* * Routine called to pass a NVME-FC LS request, received by the lldd, * to the nvme-fc transport.
Signature · 1 line
2.35.3
PATCH v4 4/5 lpfc: enable FPIN notification for NVMe
In reply to Hannes ReineckeCall 'nvme_fc_fpin_rcv()' to enble FPIN notifications for NVMe.
--- drivers/scsi/lpfc/lpfc_els.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_els.c +8 -1
@@ -33,6 +33,7 @@#include <scsi/scsi_transport_fc.h> #include <uapi/scsi/fc/fc_fs.h> #include <uapi/scsi/fc/fc_els.h> +#include <linux/nvme-fc-driver.h> #include "lpfc_hw4.h" #include "lpfc_hw.h"
@@ -10248,9 +10249,15 @@ lpfc_els_rcv_fpin(struct lpfc_vport *vport, void *p, u32 fpin_length) fpin_length +=sizeof (struct fc_els_fpin );/* the entire FPIN */ /* Send every descriptor individually to the upper layer */ -if (deliver) +if (deliver) {fc_host_fpin_rcv (lpfc_shost_from_vport (vport), fpin_length, (char *)fpin,0 ); +#if (IS_ENABLED (CONFIG_NVME_FC )) +if (vport->cfg_enable_fc4_type &LPFC_ENABLE_NVME ) +nvme_fc_fpin_rcv (vport->localport, + fpin_length, (char *)fpin); +#endif + } desc_cnt++; } }
Signature · 1 line
2.35.3
Re: [PATCH 4/5] lpfc: enable FPIN notification for NVMe
Hi Hannes,
Maybe the last tidbit from my previous email got lost. May we also exclude lpfc driver’s target mode from calling nvme_fc_fpin_rcv?
drivers/scsi/lpfc/lpfc_els.c +0 -0
@@ -10253,7 +10253,8 @@ lpfc_els_rcv_fpin(struct lpfc_vport *vport,
void *p, u32 fpin_length)
fc_host_fpin_rcv(lpfc_shost_from_vport(vport),
fpin_length, (char *)fpin, 0); #if (IS_ENABLED(CONFIG_NVME_FC))
- if (vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
+ if (vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME &&
+ !phba->nvmet_support)
nvme_fc_fpin_rcv(vport->localport,
fpin_length, (char *)fpin);#endif
Regards,
Justin
Hannes Reinecke
maintainerRe: [PATCH 4/5] lpfc: enable FPIN notification for NVMe
Quoted 19 lines · Justin Tee
Hi Hannes,
Maybe the last tidbit from my previous email got lost. May we also exclude lpfc driver’s target mode from calling
nvme_fc_fpin_rcv?drivers/scsi/lpfc/lpfc_els.c +2
-1@@ -10253,7 +10253,8 @@ lpfc_els_rcv_fpin(struct lpfc_vport *vport, void *p, u32 fpin_length)fc_host_fpin_rcv (lpfc_shost_from_vport (vport ), fpin_length, (char *)fpin, 0);#if (IS_ENABLED (CONFIG_NVME_FC )) -if (vport->cfg_enable_fc4_type &LPFC_ENABLE_NVME ) +if (vport->cfg_enable_fc4_type &LPFC_ENABLE_NVME && + !phba->nvmet_support)nvme_fc_fpin_rcv (vport->localport, fpin_length, (char *)fpin);
Quoted 2 lines
#endif
Sure we could. But it's not that the target mode does anything with the marginal ports, so actual effects would be negligible. Question, though: Why _should_ it be excluded? I would have thought that
the target would be interested in link integrity notifications, no?
(In general terms. Of course there is no code for it.)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Justin Tee
Reviewed-byRe: [PATCH 4/5] lpfc: enable FPIN notification for NVMe
Quoted 3 lines
Question, though: Why _should_ it be excluded? I would have thought that the target would be interested in link integrity notifications, no? (In general terms. Of course there is no code for it.)
Well, that’s along the lines of what I was thinking in that there’s no code for it. But conceptually, right, there’s no need to exclude target mode from upcalling an FPIN. Therefore, nevermind I’m fine with this version of the patch.
Regards,
Justin
PATCH v4 5/5 qla2xxx: enable FPIN notification for NVMe
In reply to Hannes ReineckeCall 'nvme_fc_fpin_rcv()' to enble FPIN notifications for NVMe.
--- drivers/scsi/qla2xxx/qla_isr.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/qla2xxx/qla_isr.c +3 -0
@@ -46,6 +46,9 @@ qla27xx_process_purex_fpin(struct scsi_qla_host *vha, struct purex_item *item) pkt, pkt_size);fc_host_fpin_rcv (vha->host, pkt_size, (char *)pkt,0 ); +#if (IS_ENABLED (CONFIG_NVME_FC )) +nvme_fc_fpin_rcv (vha->nvme_local_port, pkt_size, (char *)pkt); +#endif }const char *const port_state_str[] = {
Signature · 1 line
2.35.3