lpfc: Update lpfc to revision 14.2.0.7
Subsystems (2)
cover lpfc: Update lpfc to revision 14.2.0.7
Update lpfc to revision 14.2.0.7
This patch set contains fixes and some code rework for tool warnings.
The patches were cut against Martin's 6.1/scsi-queue tree
James Smart (13):
lpfc: Fix prli_fc4_req checks in PRLI handling
lpfc: Fix FLOGI ACC with wrong SID in PT2PT topology
lpfc: Fix mbuf pool resource detected as busy at driver unload
lpfc: Add missing free iocb and nlp kref put for early return VMID
cases
lpfc: Fix multiple NVME remoteport registration calls for the same
NPort ID
lpfc: Move scsi_host_template outside dynamically allocated/freed phba
lpfc: Update congestion mode logging for Emulex San Manager
application
lpfc: Rename mp/bmp dma buffers to rq/rsp in lpfc_fdmi_cmd
lpfc: Rework lpfc_fdmi_cmd routine for cleanup and consistency
lpfc: Rework FDMI attribute registration for unintential padding
lpfc: Add reporting capability for Link Degrade Signaling
lpfc: Fix various issues reported by tools
lpfc: Update lpfc version to 14.2.0.7
drivers/scsi/lpfc/lpfc.h | 10 +- drivers/scsi/lpfc/lpfc_crtn.h | 2 + drivers/scsi/lpfc/lpfc_ct.c | 1085 +++++++++++------------------- drivers/scsi/lpfc/lpfc_debugfs.c | 2 +- drivers/scsi/lpfc/lpfc_disc.h | 1 - drivers/scsi/lpfc/lpfc_els.c | 234 ++++--- drivers/scsi/lpfc/lpfc_hbadisc.c | 23 +- drivers/scsi/lpfc/lpfc_hw.h | 59 +- drivers/scsi/lpfc/lpfc_hw4.h | 30 +- drivers/scsi/lpfc/lpfc_init.c | 353 +++++----- drivers/scsi/lpfc/lpfc_logmsg.h | 2 +- drivers/scsi/lpfc/lpfc_scsi.c | 27 + drivers/scsi/lpfc/lpfc_sli.c | 73 +- drivers/scsi/lpfc/lpfc_sli4.h | 4 +- drivers/scsi/lpfc/lpfc_version.h | 2 +- drivers/scsi/lpfc/lpfc_vmid.c | 4 +- 16 files changed, 914 insertions(+), 997 deletions(-)
Signature · 1 line
2.35.3
PATCH 1/13 lpfc: Fix prli_fc4_req checks in PRLI handling
The if statment check (prli_fc4_req & PRLI_NVME_TYPE) evaluates to true when receiving a PRLI request for bogus FC4 type codes that happen to have the 3rd or 5th bit set because PRLI_NVME_TYPE is 0x28. This leads to sending a PRLI_NVME_ACC even for bogus FC4 type codes.
Change the bitwise & check to an exact == type code check to ensure we send PRLI_NVME_ACC only for NVME type coded PRLI requests.
--- drivers/scsi/lpfc/lpfc_els.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +2 -2
@@ -6006,7 +6006,7 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,if (prli_fc4_req ==PRLI_FCP_TYPE ) { cmdsize =sizeof (uint32_t ) +sizeof (PRLI ); elsrspcmd = (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK )); - }else if (prli_fc4_req &PRLI_NVME_TYPE ) { + }else if (prli_fc4_req ==PRLI_NVME_TYPE ) { cmdsize =sizeof (uint32_t ) +sizeof (struct lpfc_nvme_prli ); elsrspcmd = (ELS_CMD_ACC | (ELS_CMD_NVMEPRLI & ~ELS_RSP_MASK )); }else {
@@ -6069,7 +6069,7 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, npr->ConfmComplAllowed =1 ; npr->prliType =PRLI_FCP_TYPE ; npr->initiatorFunc =1 ; - }else if (prli_fc4_req &PRLI_NVME_TYPE ) { + }else if (prli_fc4_req ==PRLI_NVME_TYPE ) {/* Respond with an NVME PRLI Type */ npr_nvme = (struct lpfc_nvme_prli *) pcmd;bf_set (prli_type_code, npr_nvme,PRLI_NVME_TYPE );
Signature · 1 line
2.35.3
PATCH 2/13 lpfc: Fix FLOGI ACC with wrong SID in PT2PT topology
In reply to James SmartWhen a FLOGI is received before we have issued our FLOGI, the ACC response to the received FLOGI is issued with SID 2 instead of the expected fabric controller SID. Certain target vendors ignore the malformed ACC with SID 2 and wait for a properly filled ACC with a fabric controller SID.
The lpfc_sli_prep_wqe routine depends on the FC_PT2PT flag to fill in the fabric controller SID when in PT2PT mode, but due to a previous commit the flag was getting cleared. Fix by adding a check for the defer_flogi_acc flag to know whether or not to clear the FC_PT2PT flag on link up.
--- drivers/scsi/lpfc/lpfc_hbadisc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_hbadisc.c +7 -2
@@ -1353,8 +1353,13 @@ lpfc_linkup_port(struct lpfc_vport *vport) FCH_EVT_LINKUP, 0);spin_lock_irq (shost->host_lock); - vport->fc_flag &= ~(FC_PT2PT |FC_PT2PT_PLOGI |FC_ABORT_DISCOVERY | -FC_RSCN_MODE |FC_NLP_MORE |FC_RSCN_DISCOVERY ); +if (phba->defer_flogi_acc_flag) + vport->fc_flag &= ~(FC_ABORT_DISCOVERY |FC_RSCN_MODE | +FC_NLP_MORE |FC_RSCN_DISCOVERY ); +else + vport->fc_flag &= ~(FC_PT2PT |FC_PT2PT_PLOGI | +FC_ABORT_DISCOVERY |FC_RSCN_MODE | +FC_NLP_MORE |FC_RSCN_DISCOVERY ); vport->fc_flag |=FC_NDISC_ACTIVE ; vport->fc_ns_retry =0 ;spin_unlock_irq (shost->host_lock);
Signature · 1 line
2.35.3
PATCH 3/13 lpfc: Fix mbuf pool resource detected as busy at driver unload
In reply to James SmartIn a situation where the node state changes while a REG_LOGIN is in progress, the LPFC_MBOXQ_t structure is cleared and reused for an UNREG_LOGIN command to release RPI resources without first freeing the mbuf pool resource allocated for REG_LOGIN.
Release mbuf pool resource prior to repurposing of the mailbox command structure from REG_LOGIN to UNREG_LOGIN.
--- drivers/scsi/lpfc/lpfc_sli.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/scsi/lpfc/lpfc_sli.c +7 -0
@@ -2856,6 +2856,7 @@ void lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) { struct lpfc_vport *vport = pmb->vport; +struct lpfc_dmabuf *mp;struct lpfc_nodelist *ndlp;struct Scsi_Host *shost;uint16_t rpi, vpi;
@@ -2868,6 +2869,12 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)if (!(phba->pport->load_flag &FC_UNLOADING ) && pmb->u.mb.mbxCommand ==MBX_REG_LOGIN64 && !pmb->u.mb.mbxStatus) { + mp = (struct lpfc_dmabuf *)pmb->ctx_buf; +if (mp) { + pmb->ctx_buf =NULL ; +lpfc_mbuf_free (phba, mp->virt, mp->phys); +kfree (mp); + } rpi = pmb->u.mb.un.varWords[0 ]; vpi = pmb->u.mb.un.varRegLogin.vpi;if (phba->sli_rev ==LPFC_SLI_REV4 )
Signature · 1 line
2.35.3
PATCH 4/13 lpfc: Add missing free iocb and nlp kref put for early return VMID cases
In reply to James SmartSometimes VMID targets are not getting rediscovered after a port reset.
The iocb is not freed in lpfc_cmpl_ct_cmd_vmid(), which is the completion function for the appid CT commands. So after a port reset, the count of sges is less than the expected count of 250. This causes post reset operation logic to fail and keep the port offline.
Fix by freeing the iocb and kref put for the lpfc_cmpl_ct_cmd_vmid() early return cases.
--- drivers/scsi/lpfc/lpfc_ct.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/scsi/lpfc/lpfc_ct.c +7 -3
@@ -3909,6 +3909,7 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,struct lpfc_sli_ct_request *ctrsp = outp->virt;u16 rsp = ctrsp->CommandResponse.bits.CmdRsp;struct app_id_object *app; +struct lpfc_nodelist *ndlp = cmdiocb->ndlp;u32 cmd, hash, bucket;struct lpfc_vmid *vmp, *cur;u8 *data = outp->virt;
@@ -3920,7 +3921,7 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,if (lpfc_els_chk_latt (vport) ||get_job_ulpstatus (phba, rspiocb)) {if (cmd !=SLI_CTAS_DALLAPP_ID ) -return ; + goto free_res; }/* Check for a CT LS_RJT response */ if (rsp ==be16_to_cpu (SLI_CT_RESPONSE_FS_RJT )) {
@@ -3935,7 +3936,7 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,/* If DALLAPP_ID failed retry later */ if (cmd ==SLI_CTAS_DALLAPP_ID ) vport->load_flag |=FC_DEREGISTER_ALL_APP_ID ; -return ; + goto free_res; } }
@@ -3949,7 +3950,7 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, app->obj.entity_id_len);if (app->obj.entity_id_len ==0 || app->port_id ==0 ) -return ; + goto free_res; hash =lpfc_vmid_hash_fn (app->obj.entity_id, app->obj.entity_id_len);
@@ -3996,6 +3997,9 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,lpfc_printf_vlog (vport,KERN_DEBUG ,LOG_DISCOVERY ,"8857 Invalid command code\n" ); } +free_res: +lpfc_ct_free_iocb (phba, cmdiocb); +lpfc_nlp_put (ndlp); }/**
Signature · 1 line
2.35.3
PATCH 5/13 lpfc: Fix multiple NVME remoteport registration calls for the same NPort ID
In reply to James SmartWhen a target makes the mistake of registering a FC4 type with the fabric, but then rejects a PRLI of that type, the lpfc driver incorrectly retries the PRLI causing multiple registrations with the transport. The driver needs to detect the reject reason data and stop any retry.
Rework the PRLI reject scenarios.
--- drivers/scsi/lpfc/lpfc_disc.h | 1 - drivers/scsi/lpfc/lpfc_els.c | 76 +++++++++++++++++------------------ drivers/scsi/lpfc/lpfc_hw.h | 1 + 3 files changed, 37 insertions(+), 41 deletions(-)
drivers/scsi/lpfc/lpfc_disc.h +0 -1
@@ -187,7 +187,6 @@ struct lpfc_node_rrq {#define NLP_RNID_SND 0x00000400/* sent RNID request for this entry */ #define NLP_ELS_SND_MASK 0x000007e0/* sent ELS request for this entry */ #define NLP_NVMET_RECOV 0x00001000/* NVMET auditing node for recovery. */ -#define NLP_FCP_PRLI_RJT 0x00002000/* Rport does not support FCP PRLI. */ #define NLP_UNREG_INP 0x00008000/* UNREG_RPI cmd is in progress */ #define NLP_DROPPED 0x00010000/* Init ref count has been dropped */ #define NLP_DELAY_TMO 0x00020000/* delay timeout is running for node */
drivers/scsi/lpfc/lpfc_els.c +36 -40
106 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_hw.h +1 -0
@@ -703,6 +703,7 @@ struct ls_rjt { /* Structure is in Big Endian format */#define LSEXP_OUT_OF_RESOURCE 0x29#define LSEXP_CANT_GIVE_DATA 0x2A#define LSEXP_REQ_UNSUPPORTED 0x2C +#define LSEXP_NO_RSRC_ASSIGN 0x52uint8_t vendorUnique;/* FC Word 0, bit 0: 7 */ } b; } un;
Signature · 1 line
2.35.3
PATCH 6/13 lpfc: Move scsi_host_template outside dynamically allocated/freed phba
In reply to James SmartOn a PCI hotplug capable system, it is possible for scsi_device_put to happen after lpfc_pci_remove_one is called. As a result, the sdev->host->hostt->module dereference is for a previously freed memory location because the phba structure containing the hostt template was already freed when lpfc_pci_remove_one returned.
Since the lpfc module is still loaded during power slot disable, all scsi_host_templates should be declared as part of the global data segment instead of inside the heap allocated phba structure. This way the sdev->host->hostt memory area is always valid as long as the module is loaded regardless if PCI hotplug dynamically allocates or frees phba structures.
Move all scsi_host_templates in the phba structure to global variables. Create a small helper routine to determine appropriate sg_tablesize during shost allocation.
--- drivers/scsi/lpfc/lpfc.h | 4 --- drivers/scsi/lpfc/lpfc_crtn.h | 1 + drivers/scsi/lpfc/lpfc_init.c | 50 ++++++++++++++--------------------- drivers/scsi/lpfc/lpfc_scsi.c | 27 +++++++++++++++++++ 4 files changed, 48 insertions(+), 34 deletions(-)
drivers/scsi/lpfc/lpfc.h +0 -4
@@ -1596,10 +1596,6 @@ struct lpfc_hba {char os_host_name[MAXHOSTNAMELEN ]; -/* SCSI host template information - for physical port */ -struct scsi_host_template port_template; -/* SCSI host template information - for all vports */ -struct scsi_host_template vport_template;atomic_t dbg_log_idx;atomic_t dbg_log_cnt;atomic_t dbg_log_dmping;
drivers/scsi/lpfc/lpfc_crtn.h +1 -0
@@ -462,6 +462,7 @@ extern const struct attribute_group *lpfc_hba_groups[];extern const struct attribute_group *lpfc_vport_groups[];extern struct scsi_host_template lpfc_template;extern struct scsi_host_template lpfc_template_nvme; +extern struct scsi_host_template lpfc_vport_template;extern struct fc_function_template lpfc_transport_functions;extern struct fc_function_template lpfc_vport_transport_functions;
drivers/scsi/lpfc/lpfc_init.c +20 -30
79 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_scsi.c +27 -0
@@ -6794,3 +6794,30 @@ struct scsi_host_template lpfc_template = { .change_queue_depth = scsi_change_queue_depth, .track_queue_depth = 1, }; + +struct scsi_host_template lpfc_vport_template = { + .module =THIS_MODULE , + .name =LPFC_DRIVER_NAME , + .proc_name =LPFC_DRIVER_NAME , + .info = lpfc_info, + .queuecommand = lpfc_queuecommand, + .eh_timed_out = fc_eh_timed_out, + .eh_should_retry_cmd = fc_eh_should_retry_cmd, + .eh_abort_handler = lpfc_abort_handler, + .eh_device_reset_handler = lpfc_device_reset_handler, + .eh_target_reset_handler = lpfc_target_reset_handler, + .eh_bus_reset_handler =NULL , + .eh_host_reset_handler =NULL , + .slave_alloc = lpfc_slave_alloc, + .slave_configure = lpfc_slave_configure, + .slave_destroy = lpfc_slave_destroy, + .scan_finished = lpfc_scan_finished, + .this_id =-1 , + .sg_tablesize =LPFC_DEFAULT_SG_SEG_CNT , + .cmd_per_lun =LPFC_CMD_PER_LUN , + .shost_groups = lpfc_vport_groups, + .max_sectors =0xFFFFFFFF , + .vendor_id =0 , + .change_queue_depth = scsi_change_queue_depth, + .track_queue_depth =1 , +};
Signature · 1 line
2.35.3
PATCH 7/13 lpfc: Update congestion mode logging for Emulex San Manager application
In reply to James SmartIf there is a congestion or automated congestion response mode change, then log the reported change to kmsg.
--- drivers/scsi/lpfc/lpfc_init.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +22 -6
@@ -7038,6 +7038,12 @@ lpfc_cgn_params_val(struct lpfc_hba *phba, struct lpfc_cgn_param *p_cfg_param)spin_unlock_irq (&phba->hbalock); } +static const char *const lpfc_cmf_mode_to_str[] = { +"OFF" , +"MANAGED" , +"MONITOR" , +}; +/** * lpfc_cgn_params_parse - Process a FW cong parm change event * @phba: pointer to lpfc hba data structure.
@@ -7057,6 +7063,7 @@ lpfc_cgn_params_parse(struct lpfc_hba *phba, {struct lpfc_cgn_info *cp;uint32_t crc, oldmode; +char acr_string[4 ] = {0 };/* Make sure the FW has encoded the correct magic number to * validate the congestion parameter in FW memory.
@@ -7133,9 +7140,6 @@ lpfc_cgn_params_parse(struct lpfc_hba *phba,lpfc_issue_els_edc (phba->pport,0 );break ;case LPFC_CFG_MONITOR : -lpfc_printf_log (phba,KERN_INFO ,LOG_CGN_MGMT , -"4661 Switch from MANAGED to " -"`MONITOR mode\n" ); phba->cmf_max_bytes_per_interval = phba->cmf_link_byte_count;
@@ -7154,14 +7158,26 @@ lpfc_cgn_params_parse(struct lpfc_hba *phba,lpfc_issue_els_edc (phba->pport,0 );break ;case LPFC_CFG_MANAGED : -lpfc_printf_log (phba,KERN_INFO ,LOG_CGN_MGMT , -"4662 Switch from MONITOR to " -"MANAGED mode\n" );lpfc_cmf_signal_init (phba);break ; }break ; } +if (oldmode !=LPFC_CFG_OFF || + oldmode != phba->cgn_p.cgn_param_mode) { +if (phba->cgn_p.cgn_param_mode ==LPFC_CFG_MANAGED ) +scnprintf (acr_string,sizeof (acr_string),"%u" , + phba->cgn_p.cgn_param_level0); +else +scnprintf (acr_string,sizeof (acr_string),"NA" ); + +dev_info (&phba->pcidev->dev,"%d: " +"4663 CMF: Mode %s acr %s\n" , + phba->brd_no, + lpfc_cmf_mode_to_str + [phba->cgn_p.cgn_param_mode], + acr_string); + } }else {lpfc_printf_log (phba,KERN_ERR ,LOG_CGN_MGMT |LOG_INIT , "4669 FW cgn parm buf wrong magic 0x%x "
Signature · 1 line
2.35.3
PATCH 8/13 lpfc: Rename mp/bmp dma buffers to rq/rsp in lpfc_fdmi_cmd
In reply to James SmartClarify naming of the mp/bmp dma buffers:
- Rename mp to rq as it is the request buffer
- Rename bmp to rsp as it is the response buffer
This reduces confusion about what the buffer content is based on their name.
--- drivers/scsi/lpfc/lpfc_ct.c | 63 +++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 31 deletions(-)
drivers/scsi/lpfc/lpfc_ct.c +32 -31
@@ -3524,9 +3524,9 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode, uint32_t new_mask) {struct lpfc_hba *phba = vport->phba; -struct lpfc_dmabuf *mp, *bmp; +struct lpfc_dmabuf *rq, *rsp;struct lpfc_sli_ct_request *CtReq; -struct ulp_bde64 *bpl; +struct ulp_bde64_le *bde;uint32_t bit_pos;uint32_t size;uint32_t rsp_size;
@@ -3546,25 +3546,25 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,/* fill in BDEs for command */ /* Allocate buffer for command payload */ - mp =kmalloc (sizeof (struct lpfc_dmabuf ),GFP_KERNEL ); -if (!mp) + rq =kmalloc (sizeof (*rq),GFP_KERNEL ); +if (!rq) goto fdmi_cmd_exit; - mp->virt =lpfc_mbuf_alloc (phba,0 , &(mp->phys)); -if (!mp->virt) - goto fdmi_cmd_free_mp; + rq->virt =lpfc_mbuf_alloc (phba,0 , &rq->phys); +if (!rq->virt) + goto fdmi_cmd_free_rq;/* Allocate buffer for Buffer ptr list */ - bmp =kmalloc (sizeof (struct lpfc_dmabuf ),GFP_KERNEL ); -if (!bmp) - goto fdmi_cmd_free_mpvirt; + rsp =kmalloc (sizeof (*rsp),GFP_KERNEL ); +if (!rsp) + goto fdmi_cmd_free_rqvirt; - bmp->virt =lpfc_mbuf_alloc (phba,0 , &(bmp->phys)); -if (!bmp->virt) - goto fdmi_cmd_free_bmp; + rsp->virt =lpfc_mbuf_alloc (phba,0 , &rsp->phys); +if (!rsp->virt) + goto fdmi_cmd_free_rsp; -INIT_LIST_HEAD (&mp->list); -INIT_LIST_HEAD (&bmp->list); +INIT_LIST_HEAD (&rq->list); +INIT_LIST_HEAD (&rsp->list);/* FDMI request */ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
@@ -3572,7 +3572,7 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, cmdcode, new_mask, vport->fdmi_port_mask, vport->fc_flag, vport->port_state); - CtReq = (struct lpfc_sli_ct_request *)mp->virt; + CtReq = (struct lpfc_sli_ct_request *)rq->virt;/* First populate the CT_IU preamble */ memset (CtReq,0 ,sizeof (struct lpfc_sli_ct_request ));
@@ -3730,31 +3730,32 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,lpfc_printf_vlog (vport,KERN_WARNING ,LOG_DISCOVERY ,"0298 FDMI cmdcode x%x not supported\n" , cmdcode); - goto fdmi_cmd_free_bmpvirt; + goto fdmi_cmd_free_rspvirt; } CtReq->CommandResponse.bits.Size =cpu_to_be16 (rsp_size); - bpl = (struct ulp_bde64 *)bmp->virt; - bpl->addrHigh =le32_to_cpu (putPaddrHigh (mp->phys)); - bpl->addrLow =le32_to_cpu (putPaddrLow (mp->phys)); - bpl->tus.f.bdeFlags =0 ; - bpl->tus.f.bdeSize = size; + bde = (struct ulp_bde64_le *)rsp->virt; + bde->addr_high =cpu_to_le32 (putPaddrHigh (rq->phys)); + bde->addr_low =cpu_to_le32 (putPaddrLow (rq->phys)); + bde->type_size =cpu_to_le32 (ULP_BDE64_TYPE_BDE_64 << +ULP_BDE64_TYPE_SHIFT ); + bde->type_size |=cpu_to_le32 (size);/* * The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count * to hold ndlp reference for the corresponding callback function. */ -if (!lpfc_ct_cmd (vport, mp, bmp, ndlp, cmpl, rsp_size,0 )) +if (!lpfc_ct_cmd (vport, rq, rsp, ndlp, cmpl, rsp_size,0 ))return 0 ; -fdmi_cmd_free_bmpvirt: -lpfc_mbuf_free (phba, bmp->virt, bmp->phys); -fdmi_cmd_free_bmp: -kfree (bmp); -fdmi_cmd_free_mpvirt: -lpfc_mbuf_free (phba, mp->virt, mp->phys); -fdmi_cmd_free_mp: -kfree (mp); +fdmi_cmd_free_rspvirt: +lpfc_mbuf_free (phba, rsp->virt, rsp->phys); +fdmi_cmd_free_rsp: +kfree (rsp); +fdmi_cmd_free_rqvirt: +lpfc_mbuf_free (phba, rq->virt, rq->phys); +fdmi_cmd_free_rq: +kfree (rq); fdmi_cmd_exit:/* Issue FDMI request failed */ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
Signature · 1 line
2.35.3
PATCH 9/13 lpfc: Rework lpfc_fdmi_cmd routine for cleanup and consistency
In reply to James SmartSwitch case logics are reworked so they appear more similar and consistent. This eliminates compiler errors indicating unaligned pointer values and packed members.
Added comments to explain previous size offset accumulations.
--- drivers/scsi/lpfc/lpfc_ct.c | 53 +++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 23 deletions(-)
drivers/scsi/lpfc/lpfc_ct.c +30 -23
@@ -3533,7 +3533,7 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,uint32_t mask;struct lpfc_fdmi_reg_hba *rh;struct lpfc_fdmi_port_entry *pe; -struct lpfc_fdmi_reg_portattr *pab =NULL ; +struct lpfc_fdmi_reg_portattr *pab =NULL , *base =NULL ;struct lpfc_fdmi_attr_block *ab =NULL ;int (*func)(struct lpfc_vport *vport,struct lpfc_fdmi_attr_def *ad); void (*cmpl)(struct lpfc_hba *, struct lpfc_iocbq *,
@@ -3566,6 +3566,10 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,INIT_LIST_HEAD (&rq->list);INIT_LIST_HEAD (&rsp->list); +/* mbuf buffers are 1K in length - aka LPFC_BPL_SIZE */ +memset (rq->virt,0 ,LPFC_BPL_SIZE ); + rsp_size =LPFC_BPL_SIZE ; +/* FDMI request */ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, "0218 FDMI Request x%x mask x%x Data: x%x x%x x%x\n",
@@ -3575,7 +3579,6 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, CtReq = (struct lpfc_sli_ct_request *)rq->virt;/* First populate the CT_IU preamble */ -memset (CtReq,0 ,sizeof (struct lpfc_sli_ct_request )); CtReq->RevisionId.bits.Revision =SLI_CT_REVISION ; CtReq->RevisionId.bits.InId =0 ;
@@ -3583,17 +3586,18 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, CtReq->FsSubType = SLI_CT_FDMI_Subtypes; CtReq->CommandResponse.bits.CmdRsp =cpu_to_be16 (cmdcode); - rsp_size =LPFC_BPL_SIZE ; + size =0 ;/* Next fill in the specific FDMI cmd information */ switch (cmdcode) {case SLI_MGMT_RHAT :case SLI_MGMT_RHBA : - rh = (struct lpfc_fdmi_reg_hba *)&CtReq->un.PortID; + rh = (struct lpfc_fdmi_reg_hba *)&CtReq->un;/* HBA Identifier */ memcpy (&rh->hi.PortName, &phba->pport->fc_sparam.portName,sizeof (struct lpfc_name )); + size +=sizeof (struct lpfc_fdmi_hba_ident );if (cmdcode ==SLI_MGMT_RHBA ) {/* Registered Port List */
@@ -3602,16 +3606,13 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,memcpy (&rh->rpl.pe.PortName, &phba->pport->fc_sparam.portName,sizeof (struct lpfc_name )); - -/* point to the HBA attribute block */ - size =2 *sizeof (struct lpfc_name ) + -FOURBYTES ; - }else { - size =sizeof (struct lpfc_name ); + size +=sizeof (struct lpfc_fdmi_reg_port_list ); } + ab = (struct lpfc_fdmi_attr_block *)((uint8_t *)rh + size); ab->EntryCnt =0 ; - size +=FOURBYTES ; + size +=FOURBYTES ;/* add length of EntryCnt field */ + bit_pos =0 ;if (new_mask) mask = new_mask;
@@ -3626,6 +3627,7 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, (struct lpfc_fdmi_attr_def *) ((uint8_t *)rh + size)); ab->EntryCnt++; +/* check if another attribute fits */ if ((size +256 ) > (LPFC_BPL_SIZE -LPFC_CT_PREAMBLE )) goto hba_out;
@@ -3636,7 +3638,7 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, hba_out: ab->EntryCnt =cpu_to_be32 (ab->EntryCnt);/* Total size */ - size =GID_REQUEST_SZ -4 + size; + size +=GID_REQUEST_SZ -4 ;break ;case SLI_MGMT_RPRT :
@@ -3647,22 +3649,29 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, } fallthrough;case SLI_MGMT_RPA : - pab = (struct lpfc_fdmi_reg_portattr *)&CtReq->un.PortID; +/* Store base ptr right after preamble */ + base = (struct lpfc_fdmi_reg_portattr *)&CtReq->un; +if (cmdcode ==SLI_MGMT_RPRT ) { - rh = (struct lpfc_fdmi_reg_hba *)pab; + rh = (struct lpfc_fdmi_reg_hba *)base;/* HBA Identifier */ memcpy (&rh->hi.PortName, &phba->pport->fc_sparam.portName,sizeof (struct lpfc_name )); pab = (struct lpfc_fdmi_reg_portattr *) - ((uint8_t *)pab +sizeof (struct lpfc_name )); + ((uint8_t *)base +sizeof (struct lpfc_name )); + size +=sizeof (struct lpfc_name ); + }else { + pab = base; }memcpy ((uint8_t *)&pab->PortName, (uint8_t *)&vport->fc_sparam.portName,sizeof (struct lpfc_name )); - size +=sizeof (struct lpfc_name ) +FOURBYTES ; pab->ab.EntryCnt =0 ; +/* add length of name and EntryCnt field */ + size +=sizeof (struct lpfc_name ) +FOURBYTES ; + bit_pos =0 ;if (new_mask) mask = new_mask;
@@ -3675,8 +3684,9 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, func = lpfc_fdmi_port_action[bit_pos]; size +=func (vport, (struct lpfc_fdmi_attr_def *) - ((uint8_t *)pab + size)); + ((uint8_t *)base + size)); pab->ab.EntryCnt++; +/* check if another attribute fits */ if ((size +256 ) > (LPFC_BPL_SIZE -LPFC_CT_PREAMBLE )) goto port_out;
@@ -3686,10 +3696,7 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, } port_out: pab->ab.EntryCnt =cpu_to_be32 (pab->ab.EntryCnt); -/* Total size */ -if (cmdcode ==SLI_MGMT_RPRT ) - size +=sizeof (struct lpfc_name ); - size =GID_REQUEST_SZ -4 + size; + size +=GID_REQUEST_SZ -4 ;break ;case SLI_MGMT_GHAT :
@@ -3698,7 +3705,7 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, fallthrough;case SLI_MGMT_DHBA :case SLI_MGMT_DHAT : - pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID; + pe = (struct lpfc_fdmi_port_entry *)&CtReq->un;memcpy ((uint8_t *)&pe->PortName, (uint8_t *)&vport->fc_sparam.portName,sizeof (struct lpfc_name ));
@@ -3717,7 +3724,7 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, } fallthrough;case SLI_MGMT_DPA : - pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID; + pe = (struct lpfc_fdmi_port_entry *)&CtReq->un;memcpy ((uint8_t *)&pe->PortName, (uint8_t *)&vport->fc_sparam.portName,sizeof (struct lpfc_name ));
Signature · 1 line
2.35.3
PATCH 10/13 lpfc: Rework FDMI attribute registration for unintential padding
In reply to James SmartRemoved the lpfc_fdmi_attr_entry and lpfc_fdmi_attr_def structures that had a union causing unintentional zero padding, which required the usage of __packed. They are replaced with explicit lpfc_fdmi_attr_u32, lpfc_fdmi_attr_wwn, lpfc_fdmi_attr_fc4types, and lpfc_fdmi_attr_string structure defines instead of living in a union. This rids of ambiguous compiler zero padding, and entailed cleaning up bitwise endian declarations.
As such, all FDMI attribute registration routines are replaced with generic void *arg and handlers for each of the newly defined attribute structure types.
--- drivers/scsi/lpfc/lpfc_ct.c | 961 ++++++++++++------------------------ drivers/scsi/lpfc/lpfc_hw.h | 58 ++- 2 files changed, 350 insertions(+), 669 deletions(-)
drivers/scsi/lpfc/lpfc_ct.c +308 -653
@@ -2501,420 +2501,298 @@ lpfc_fdmi_change_check(struct lpfc_vport *vport) } } -/* Routines for all individual HBA attributes */ -static int -lpfc_fdmi_hba_attr_wwnn (struct lpfc_vport *vport,struct lpfc_fdmi_attr_def *ad) +static inline int +lpfc_fdmi_set_attr_u32 (void *attr,uint16_t attrtype,uint32_t attrval) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; +struct lpfc_fdmi_attr_u32 *ae = attr; +int size =sizeof (*ae); - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); + ae->type =cpu_to_be16 (attrtype); + ae->len =cpu_to_be16 (size); + ae->value_u32 =cpu_to_be32 (attrval); -memcpy (&ae->un.AttrWWN, &vport->fc_sparam.nodeName, -sizeof (struct lpfc_name )); - size =FOURBYTES +sizeof (struct lpfc_name ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_NODENAME );return size; } -static int -lpfc_fdmi_hba_attr_manufacturer (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) + +static inline int +lpfc_fdmi_set_attr_wwn (void *attr,uint16_t attrtype,struct lpfc_name *wwn) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; +struct lpfc_fdmi_attr_wwn *ae = attr; +int size =sizeof (*ae); - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); + ae->type =cpu_to_be16 (attrtype); + ae->len =cpu_to_be16 (size); +/* WWN's assumed to be bytestreams - Big Endian presentation */ +memcpy (ae->name, wwn, +min_t (size_t,sizeof (struct lpfc_name ),sizeof (__be64))); -/* This string MUST be consistent with other FC platforms -* supported by Broadcom. -*/ -strncpy (ae->un.AttrString, -"Emulex Corporation" , -sizeof (ae->un.AttrString)); - len =strnlen (ae->un.AttrString, -sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_MANUFACTURER );return size; } -static int -lpfc_fdmi_hba_attr_sn (struct lpfc_vport *vport,struct lpfc_fdmi_attr_def *ad) +static inline int +lpfc_fdmi_set_attr_fullwwn (void *attr,uint16_t attrtype, +struct lpfc_name *wwnn,struct lpfc_name *wwpn) { -struct lpfc_hba *phba = vport->phba; -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; +struct lpfc_fdmi_attr_fullwwn *ae = attr; +u8 *nname = ae->nname; +u8 *pname = ae->pname; +int size =sizeof (*ae); - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); + ae->type =cpu_to_be16 (attrtype); + ae->len =cpu_to_be16 (size); +/* WWN's assumed to be bytestreams - Big Endian presentation */ +memcpy (nname, wwnn, +min_t (size_t,sizeof (struct lpfc_name ),sizeof (__be64))); +memcpy (pname, wwpn, +min_t (size_t,sizeof (struct lpfc_name ),sizeof (__be64))); -strncpy (ae->un.AttrString, phba->SerialNumber, -sizeof (ae->un.AttrString)); - len =strnlen (ae->un.AttrString, -sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_SERIAL_NUMBER );return size; } -static int -lpfc_fdmi_hba_attr_model (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +static inline int +lpfc_fdmi_set_attr_string (void *attr,uint16_t attrtype,char *attrstring) { -struct lpfc_hba *phba = vport->phba; -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; +struct lpfc_fdmi_attr_string *ae = attr; +int len, size; - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); +/* +* We are trusting the caller that if a fdmi string field +* is capped at 64 bytes, the caller passes in a string of +* 64 bytes or less. +*/ -strncpy (ae->un.AttrString, phba->ModelName, -sizeof (ae->un.AttrString)); - len =strnlen (ae->un.AttrString,sizeof (ae->un.AttrString)); +strncpy (ae->value_string, attrstring,sizeof (ae->value_string)); + len =strnlen (ae->value_string,sizeof (ae->value_string)); +/* round string length to a 32bit boundary. Ensure there's a NULL */ len += (len &3 ) ? (4 - (len &3 )) :4 ; +/* size is Type/Len (4 bytes) plus string length */ size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_MODEL ); + + ae->type =cpu_to_be16 (attrtype); + ae->len =cpu_to_be16 (size); +return size; } -static int -lpfc_fdmi_hba_attr_description (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +/* Bitfields for FC4 Types that can be reported */ +#define ATTR_FC4_CT 0x00000001 +#define ATTR_FC4_FCP 0x00000002 +#define ATTR_FC4_NVME 0x00000004 + +static inline int +lpfc_fdmi_set_attr_fc4types (void *attr,uint16_t attrtype,uint32_t typemask) { -struct lpfc_hba *phba = vport->phba; -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; +struct lpfc_fdmi_attr_fc4types *ae = attr; +int size =sizeof (*ae); - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); + ae->type =cpu_to_be16 (attrtype); + ae->len =cpu_to_be16 (size); + +if (typemask &ATTR_FC4_FCP ) + ae->value_types[2 ] =0x01 ;/* Type 0x8 - FCP */ + +if (typemask &ATTR_FC4_CT ) + ae->value_types[7 ] =0x01 ;/* Type 0x20 - CT */ + +if (typemask &ATTR_FC4_NVME ) + ae->value_types[6 ] =0x01 ;/* Type 0x28 - NVME */ -strncpy (ae->un.AttrString, phba->ModelDesc, -sizeof (ae->un.AttrString)); - len =strnlen (ae->un.AttrString, -sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_MODEL_DESCRIPTION );return size; } +/* Routines for all individual HBA attributes */ static int -lpfc_fdmi_hba_attr_hdw_ver (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_hba_attr_wwnn (struct lpfc_vport *vport,void *attr) { -struct lpfc_hba *phba = vport->phba; -lpfc_vpd_t *vp = &phba->vpd; -struct lpfc_fdmi_attr_entry *ae; -uint32_t i, j, incr, size; - - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); - -/* Convert JEDEC ID to ascii for hardware version */ - incr = vp->rev.biuRev; -for (i =0 ; i <8 ; i++) { - j = (incr &0xf ); -if (j <=9 ) - ae->un.AttrString[7 - i] = - (char )((uint8_t )0x30 + - (uint8_t ) j); -else - ae->un.AttrString[7 - i] = - (char )((uint8_t )0x61 + - (uint8_t ) (j -10 )); - incr = (incr >>4 ); - } - size =FOURBYTES +8 ; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_HARDWARE_VERSION ); -return size; +return lpfc_fdmi_set_attr_wwn (attr,RHBA_NODENAME , + &vport->fc_sparam.nodeName); }static int -lpfc_fdmi_hba_attr_drvr_ver (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_hba_attr_manufacturer (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; +/* This string MUST be consistent with other FC platforms +* supported by Broadcom. +*/ +return lpfc_fdmi_set_attr_string (attr,RHBA_MANUFACTURER , +"Emulex Corporation" ); +} - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); +static int +lpfc_fdmi_hba_attr_sn (struct lpfc_vport *vport,void *attr) +{ +struct lpfc_hba *phba = vport->phba; -strncpy (ae->un.AttrString, lpfc_release_version, -sizeof (ae->un.AttrString)); - len =strnlen (ae->un.AttrString, -sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_DRIVER_VERSION ); -return size; +return lpfc_fdmi_set_attr_string (attr,RHBA_SERIAL_NUMBER , + phba->SerialNumber); }static int -lpfc_fdmi_hba_attr_rom_ver (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_hba_attr_model (struct lpfc_vport *vport,void *attr) {struct lpfc_hba *phba = vport->phba; -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; - - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); -if (phba->sli_rev ==LPFC_SLI_REV4 ) -lpfc_decode_firmware_rev (phba, ae->un.AttrString,1 ); -else -strncpy (ae->un.AttrString, phba->OptionROMVersion, -sizeof (ae->un.AttrString)); - len =strnlen (ae->un.AttrString, -sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_OPTION_ROM_VERSION ); -return size; +return lpfc_fdmi_set_attr_string (attr,RHBA_MODEL , + phba->ModelName); }static int -lpfc_fdmi_hba_attr_fmw_ver (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_hba_attr_description (struct lpfc_vport *vport,void *attr) {struct lpfc_hba *phba = vport->phba; -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; - - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); -lpfc_decode_firmware_rev (phba, ae->un.AttrString,1 ); - len =strnlen (ae->un.AttrString, -sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_FIRMWARE_VERSION ); -return size; +return lpfc_fdmi_set_attr_string (attr,RHBA_MODEL_DESCRIPTION , + phba->ModelDesc); }static int -lpfc_fdmi_hba_attr_os_ver (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_hba_attr_hdw_ver (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; +struct lpfc_hba *phba = vport->phba; +lpfc_vpd_t *vp = &phba->vpd; +char buf[16 ] = {0 }; - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); +snprintf (buf,sizeof (buf),"%08x" , vp->rev.biuRev); -snprintf (ae->un.AttrString,sizeof (ae->un.AttrString),"%s %s %s" , -init_utsname ()->sysname, -init_utsname ()->release, -init_utsname ()->version); +return lpfc_fdmi_set_attr_string (attr,RHBA_HARDWARE_VERSION , buf); +} - len =strnlen (ae->un.AttrString,sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_OS_NAME_VERSION ); -return size; +static int +lpfc_fdmi_hba_attr_drvr_ver (struct lpfc_vport *vport,void *attr) +{ +return lpfc_fdmi_set_attr_string (attr,RHBA_DRIVER_VERSION , + lpfc_release_version); }static int -lpfc_fdmi_hba_attr_ct_len (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_hba_attr_rom_ver (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; +struct lpfc_hba *phba = vport->phba; +char buf[64 ] = {0 }; - ae = &ad->AttrValue; +if (phba->sli_rev ==LPFC_SLI_REV4 ) { +lpfc_decode_firmware_rev (phba, buf,1 ); - ae->un.AttrInt =cpu_to_be32 (LPFC_MAX_CT_SIZE ); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_MAX_CT_PAYLOAD_LEN ); -return size; +return lpfc_fdmi_set_attr_string (attr,RHBA_OPTION_ROM_VERSION , + buf); + } + +return lpfc_fdmi_set_attr_string (attr,RHBA_OPTION_ROM_VERSION , + phba->OptionROMVersion); }static int -lpfc_fdmi_hba_attr_symbolic_name (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_hba_attr_fmw_ver (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; +struct lpfc_hba *phba = vport->phba; +char buf[64 ] = {0 }; - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); +lpfc_decode_firmware_rev (phba, buf,1 ); - len =lpfc_vport_symbolic_node_name (vport, - ae->un.AttrString,256 ); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_SYM_NODENAME ); -return size; +return lpfc_fdmi_set_attr_string (attr,RHBA_FIRMWARE_VERSION , buf); }static int -lpfc_fdmi_hba_attr_vendor_info (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_hba_attr_os_ver (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; +char buf[256 ] = {0 }; + +snprintf (buf,sizeof (buf),"%s %s %s" , +init_utsname ()->sysname, +init_utsname ()->release, +init_utsname ()->version); - ae = &ad->AttrValue; +return lpfc_fdmi_set_attr_string (attr,RHBA_OS_NAME_VERSION , buf); +} -/* Nothing is defined for this currently */ - ae->un.AttrInt =cpu_to_be32 (0 ); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_VENDOR_INFO ); -return size; +static int +lpfc_fdmi_hba_attr_ct_len (struct lpfc_vport *vport,void *attr) +{ +return lpfc_fdmi_set_attr_u32 (attr,RHBA_MAX_CT_PAYLOAD_LEN , +LPFC_MAX_CT_SIZE ); }static int -lpfc_fdmi_hba_attr_num_ports (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_hba_attr_symbolic_name (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; +char buf[256 ] = {0 }; - ae = &ad->AttrValue; +lpfc_vport_symbolic_node_name (vport, buf,sizeof (buf)); -/* Each driver instance corresponds to a single port */ - ae->un.AttrInt =cpu_to_be32 (1 ); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_NUM_PORTS ); -return size; +return lpfc_fdmi_set_attr_string (attr,RHBA_SYM_NODENAME , buf); }static int -lpfc_fdmi_hba_attr_fabric_wwnn (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_hba_attr_vendor_info (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; +return lpfc_fdmi_set_attr_u32 (attr,RHBA_VENDOR_INFO ,0 ); +} - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); +static int +lpfc_fdmi_hba_attr_num_ports (struct lpfc_vport *vport,void *attr) +{ +/* Each driver instance corresponds to a single port */ +return lpfc_fdmi_set_attr_u32 (attr,RHBA_NUM_PORTS ,1 ); +} -memcpy (&ae->un.AttrWWN, &vport->fabric_nodename, -sizeof (struct lpfc_name )); - size =FOURBYTES +sizeof (struct lpfc_name ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_FABRIC_WWNN ); -return size; +static int +lpfc_fdmi_hba_attr_fabric_wwnn (struct lpfc_vport *vport,void *attr) +{ +return lpfc_fdmi_set_attr_wwn (attr,RHBA_FABRIC_WWNN , + &vport->fabric_nodename); }static int -lpfc_fdmi_hba_attr_bios_ver (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_hba_attr_bios_ver (struct lpfc_vport *vport,void *attr) {struct lpfc_hba *phba = vport->phba; -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; - - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); -strlcat (ae->un.AttrString, phba->BIOSVersion, -sizeof (ae->un.AttrString)); - len =strnlen (ae->un.AttrString, -sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_BIOS_VERSION ); -return size; +return lpfc_fdmi_set_attr_string (attr,RHBA_BIOS_VERSION , + phba->BIOSVersion); }static int -lpfc_fdmi_hba_attr_bios_state (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_hba_attr_bios_state (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; -/* Driver doesn't have access to this information */ - ae->un.AttrInt =cpu_to_be32 (0 ); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_BIOS_STATE ); -return size; +return lpfc_fdmi_set_attr_u32 (attr,RHBA_BIOS_STATE ,0 ); }static int -lpfc_fdmi_hba_attr_vendor_id (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_hba_attr_vendor_id (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; - - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); - -strncpy (ae->un.AttrString,"EMULEX" , -sizeof (ae->un.AttrString)); - len =strnlen (ae->un.AttrString, -sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RHBA_VENDOR_ID ); -return size; +return lpfc_fdmi_set_attr_string (attr,RHBA_VENDOR_ID ,"EMULEX" ); } -/* Routines for all individual PORT attributes */ +/* +* Routines for all individual PORT attributes +*/ +static int -lpfc_fdmi_port_attr_fc4type (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_fc4type (struct lpfc_vport *vport,void *attr) {struct lpfc_hba *phba = vport->phba; -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); +u32 fc4types; - ae->un.AttrTypes[2 ] =0x01 ;/* Type 0x8 - FCP */ - ae->un.AttrTypes[7 ] =0x01 ;/* Type 0x20 - CT */ + fc4types = (ATTR_FC4_CT |ATTR_FC4_FCP );/* Check to see if Firmware supports NVME and on physical port */ if ((phba->sli_rev ==LPFC_SLI_REV4 ) && (vport == phba->pport) && phba->sli4_hba.pc_sli4_params.nvme) - ae->un.AttrTypes[6 ] =0x01 ;/* Type 0x28 - NVME */ + fc4types |=ATTR_FC4_NVME ; - size =FOURBYTES +32 ; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_SUPPORTED_FC4_TYPES ); -return size; +return lpfc_fdmi_set_attr_fc4types (attr,RPRT_SUPPORTED_FC4_TYPES , + fc4types); }static int -lpfc_fdmi_port_attr_support_speed (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_support_speed (struct lpfc_vport *vport,void *attr) { -struct lpfc_hba *phba = vport->phba; -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; +struct lpfc_hba *phba = vport->phba; +u32 speeds =0 ;u32 tcfg;u8 i, cnt; - ae = &ad->AttrValue; - - ae->un.AttrInt =0 ;if (!(phba->hba_flag &HBA_FCOE_MODE )) { cnt =0 ;if (phba->sli_rev ==LPFC_SLI_REV4 ) {
@@ -2926,539 +2804,314 @@ lpfc_fdmi_port_attr_support_speed(struct lpfc_vport *vport,if (cnt >2 ) {/* 4 lane trunk group */ if (phba->lmt & LMT_64Gb) - ae->un.AttrInt |=HBA_PORTSPEED_256GFC ; + speeds |=HBA_PORTSPEED_256GFC ;if (phba->lmt & LMT_32Gb) - ae->un.AttrInt |=HBA_PORTSPEED_128GFC ; + speeds |=HBA_PORTSPEED_128GFC ;if (phba->lmt & LMT_16Gb) - ae->un.AttrInt |=HBA_PORTSPEED_64GFC ; + speeds |=HBA_PORTSPEED_64GFC ; }else if (cnt) {/* 2 lane trunk group */ if (phba->lmt & LMT_128Gb) - ae->un.AttrInt |=HBA_PORTSPEED_256GFC ; + speeds |=HBA_PORTSPEED_256GFC ;if (phba->lmt & LMT_64Gb) - ae->un.AttrInt |=HBA_PORTSPEED_128GFC ; + speeds |=HBA_PORTSPEED_128GFC ;if (phba->lmt & LMT_32Gb) - ae->un.AttrInt |=HBA_PORTSPEED_64GFC ; + speeds |=HBA_PORTSPEED_64GFC ;if (phba->lmt & LMT_16Gb) - ae->un.AttrInt |=HBA_PORTSPEED_32GFC ; + speeds |=HBA_PORTSPEED_32GFC ; }else {if (phba->lmt & LMT_256Gb) - ae->un.AttrInt |=HBA_PORTSPEED_256GFC ; + speeds |=HBA_PORTSPEED_256GFC ;if (phba->lmt & LMT_128Gb) - ae->un.AttrInt |=HBA_PORTSPEED_128GFC ; + speeds |=HBA_PORTSPEED_128GFC ;if (phba->lmt & LMT_64Gb) - ae->un.AttrInt |=HBA_PORTSPEED_64GFC ; + speeds |=HBA_PORTSPEED_64GFC ;if (phba->lmt & LMT_32Gb) - ae->un.AttrInt |=HBA_PORTSPEED_32GFC ; + speeds |=HBA_PORTSPEED_32GFC ;if (phba->lmt & LMT_16Gb) - ae->un.AttrInt |=HBA_PORTSPEED_16GFC ; + speeds |=HBA_PORTSPEED_16GFC ;if (phba->lmt & LMT_10Gb) - ae->un.AttrInt |=HBA_PORTSPEED_10GFC ; + speeds |=HBA_PORTSPEED_10GFC ;if (phba->lmt & LMT_8Gb) - ae->un.AttrInt |=HBA_PORTSPEED_8GFC ; + speeds |=HBA_PORTSPEED_8GFC ;if (phba->lmt & LMT_4Gb) - ae->un.AttrInt |=HBA_PORTSPEED_4GFC ; + speeds |=HBA_PORTSPEED_4GFC ;if (phba->lmt & LMT_2Gb) - ae->un.AttrInt |=HBA_PORTSPEED_2GFC ; + speeds |=HBA_PORTSPEED_2GFC ;if (phba->lmt & LMT_1Gb) - ae->un.AttrInt |=HBA_PORTSPEED_1GFC ; + speeds |=HBA_PORTSPEED_1GFC ; } }else {/* FCoE links support only one speed */ switch (phba->fc_linkspeed) {case LPFC_ASYNC_LINK_SPEED_10GBPS : - ae->un.AttrInt =HBA_PORTSPEED_10GE ; + speeds =HBA_PORTSPEED_10GE ;break ;case LPFC_ASYNC_LINK_SPEED_25GBPS : - ae->un.AttrInt =HBA_PORTSPEED_25GE ; + speeds =HBA_PORTSPEED_25GE ;break ;case LPFC_ASYNC_LINK_SPEED_40GBPS : - ae->un.AttrInt =HBA_PORTSPEED_40GE ; + speeds =HBA_PORTSPEED_40GE ;break ;case LPFC_ASYNC_LINK_SPEED_100GBPS : - ae->un.AttrInt =HBA_PORTSPEED_100GE ; + speeds =HBA_PORTSPEED_100GE ;break ; } } - ae->un.AttrInt =cpu_to_be32 (ae->un.AttrInt); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_SUPPORTED_SPEED ); -return size; + +return lpfc_fdmi_set_attr_u32 (attr,RPRT_SUPPORTED_SPEED , speeds); }static int -lpfc_fdmi_port_attr_speed (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_speed (struct lpfc_vport *vport,void *attr) {struct lpfc_hba *phba = vport->phba; -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; +u32 speeds =0 ;if (!(phba->hba_flag &HBA_FCOE_MODE )) {switch (phba->fc_linkspeed) {case LPFC_LINK_SPEED_1GHZ : - ae->un.AttrInt =HBA_PORTSPEED_1GFC ; + speeds =HBA_PORTSPEED_1GFC ;break ;case LPFC_LINK_SPEED_2GHZ : - ae->un.AttrInt =HBA_PORTSPEED_2GFC ; + speeds =HBA_PORTSPEED_2GFC ;break ;case LPFC_LINK_SPEED_4GHZ : - ae->un.AttrInt =HBA_PORTSPEED_4GFC ; + speeds =HBA_PORTSPEED_4GFC ;break ;case LPFC_LINK_SPEED_8GHZ : - ae->un.AttrInt =HBA_PORTSPEED_8GFC ; + speeds =HBA_PORTSPEED_8GFC ;break ;case LPFC_LINK_SPEED_10GHZ : - ae->un.AttrInt =HBA_PORTSPEED_10GFC ; + speeds =HBA_PORTSPEED_10GFC ;break ;case LPFC_LINK_SPEED_16GHZ : - ae->un.AttrInt =HBA_PORTSPEED_16GFC ; + speeds =HBA_PORTSPEED_16GFC ;break ;case LPFC_LINK_SPEED_32GHZ : - ae->un.AttrInt =HBA_PORTSPEED_32GFC ; + speeds =HBA_PORTSPEED_32GFC ;break ;case LPFC_LINK_SPEED_64GHZ : - ae->un.AttrInt =HBA_PORTSPEED_64GFC ; + speeds =HBA_PORTSPEED_64GFC ;break ;case LPFC_LINK_SPEED_128GHZ : - ae->un.AttrInt =HBA_PORTSPEED_128GFC ; + speeds =HBA_PORTSPEED_128GFC ;break ;case LPFC_LINK_SPEED_256GHZ : - ae->un.AttrInt =HBA_PORTSPEED_256GFC ; + speeds =HBA_PORTSPEED_256GFC ;break ;default : - ae->un.AttrInt =HBA_PORTSPEED_UNKNOWN ; + speeds =HBA_PORTSPEED_UNKNOWN ;break ; } }else {switch (phba->fc_linkspeed) {case LPFC_ASYNC_LINK_SPEED_10GBPS : - ae->un.AttrInt =HBA_PORTSPEED_10GE ; + speeds =HBA_PORTSPEED_10GE ;break ;case LPFC_ASYNC_LINK_SPEED_25GBPS : - ae->un.AttrInt =HBA_PORTSPEED_25GE ; + speeds =HBA_PORTSPEED_25GE ;break ;case LPFC_ASYNC_LINK_SPEED_40GBPS : - ae->un.AttrInt =HBA_PORTSPEED_40GE ; + speeds =HBA_PORTSPEED_40GE ;break ;case LPFC_ASYNC_LINK_SPEED_100GBPS : - ae->un.AttrInt =HBA_PORTSPEED_100GE ; + speeds =HBA_PORTSPEED_100GE ;break ;default : - ae->un.AttrInt =HBA_PORTSPEED_UNKNOWN ; + speeds =HBA_PORTSPEED_UNKNOWN ;break ; } } - ae->un.AttrInt =cpu_to_be32 (ae->un.AttrInt); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_PORT_SPEED ); -return size; +return lpfc_fdmi_set_attr_u32 (attr,RPRT_PORT_SPEED , speeds); }static int -lpfc_fdmi_port_attr_max_frame (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_max_frame (struct lpfc_vport *vport,void *attr) { -struct serv_parm *hsp; -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; +struct serv_parm *hsp = (struct serv_parm *)&vport->fc_sparam; - hsp = (struct serv_parm *)&vport->fc_sparam; - ae->un.AttrInt = (((uint32_t ) hsp->cmn.bbRcvSizeMsb &0x0F ) <<8 ) | - (uint32_t ) hsp->cmn.bbRcvSizeLsb; - ae->un.AttrInt =cpu_to_be32 (ae->un.AttrInt); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_MAX_FRAME_SIZE ); -return size; +return lpfc_fdmi_set_attr_u32 (attr,RPRT_MAX_FRAME_SIZE , + (((uint32_t )hsp->cmn.bbRcvSizeMsb &0x0F ) <<8 ) | + (uint32_t )hsp->cmn.bbRcvSizeLsb); }static int -lpfc_fdmi_port_attr_os_devname (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_os_devname (struct lpfc_vport *vport,void *attr) {struct Scsi_Host *shost =lpfc_shost_from_vport (vport); -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; +char buf[64 ] = {0 }; - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); +snprintf (buf,sizeof (buf),"/sys/class/scsi_host/host%d" , + shost->host_no); -snprintf (ae->un.AttrString,sizeof (ae->un.AttrString), -"/sys/class/scsi_host/host%d" , shost->host_no); - len =strnlen ((char *)ae->un.AttrString, -sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_OS_DEVICE_NAME ); -return size; +return lpfc_fdmi_set_attr_string (attr,RPRT_OS_DEVICE_NAME , buf); }static int -lpfc_fdmi_port_attr_host_name (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_host_name (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; +char buf[64 ] = {0 }; - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); +scnprintf (buf,sizeof (buf),"%s" , vport->phba->os_host_name); -scnprintf (ae->un.AttrString,sizeof (ae->un.AttrString),"%s" , - vport->phba->os_host_name); - - len =strnlen (ae->un.AttrString,sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_HOST_NAME ); -return size; +return lpfc_fdmi_set_attr_string (attr,RPRT_HOST_NAME , buf); }static int -lpfc_fdmi_port_attr_wwnn (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_wwnn (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); - -memcpy (&ae->un.AttrWWN, &vport->fc_sparam.nodeName, -sizeof (struct lpfc_name )); - size =FOURBYTES +sizeof (struct lpfc_name ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_NODENAME ); -return size; +return lpfc_fdmi_set_attr_wwn (attr,RPRT_NODENAME , + &vport->fc_sparam.nodeName); }static int -lpfc_fdmi_port_attr_wwpn (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_wwpn (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); - -memcpy (&ae->un.AttrWWN, &vport->fc_sparam.portName, -sizeof (struct lpfc_name )); - size =FOURBYTES +sizeof (struct lpfc_name ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_PORTNAME ); -return size; +return lpfc_fdmi_set_attr_wwn (attr,RPRT_PORTNAME , + &vport->fc_sparam.portName); }static int -lpfc_fdmi_port_attr_symbolic_name (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_symbolic_name (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; +char buf[256 ] = {0 }; - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); +lpfc_vport_symbolic_port_name (vport, buf,sizeof (buf)); - len =lpfc_vport_symbolic_port_name (vport, ae->un.AttrString,256 ); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_SYM_PORTNAME ); -return size; +return lpfc_fdmi_set_attr_string (attr,RPRT_SYM_PORTNAME , buf); }static int -lpfc_fdmi_port_attr_port_type (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_port_type (struct lpfc_vport *vport,void *attr) {struct lpfc_hba *phba = vport->phba; -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - ae = &ad->AttrValue; -if (phba->fc_topology ==LPFC_TOPOLOGY_LOOP ) - ae->un.AttrInt =cpu_to_be32 (LPFC_FDMI_PORTTYPE_NLPORT ); -else - ae->un.AttrInt =cpu_to_be32 (LPFC_FDMI_PORTTYPE_NPORT ); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_PORT_TYPE ); -return size; +return lpfc_fdmi_set_attr_u32 (attr,RPRT_PORT_TYPE , + (phba->fc_topology ==LPFC_TOPOLOGY_LOOP ) ? +LPFC_FDMI_PORTTYPE_NLPORT : +LPFC_FDMI_PORTTYPE_NPORT ); }static int -lpfc_fdmi_port_attr_class (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_class (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; - ae->un.AttrInt =cpu_to_be32 (FC_COS_CLASS2 |FC_COS_CLASS3 ); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_SUPPORTED_CLASS ); -return size; +return lpfc_fdmi_set_attr_u32 (attr,RPRT_SUPPORTED_CLASS , +FC_COS_CLASS2 |FC_COS_CLASS3 ); }static int -lpfc_fdmi_port_attr_fabric_wwpn (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_fabric_wwpn (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); - -memcpy (&ae->un.AttrWWN, &vport->fabric_portname, -sizeof (struct lpfc_name )); - size =FOURBYTES +sizeof (struct lpfc_name ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_FABRICNAME ); -return size; +return lpfc_fdmi_set_attr_wwn (attr,RPRT_FABRICNAME , + &vport->fabric_portname); }static int -lpfc_fdmi_port_attr_active_fc4type (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_active_fc4type (struct lpfc_vport *vport,void *attr) {struct lpfc_hba *phba = vport->phba; -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; +u32 fc4types; - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); - - ae->un.AttrTypes[2 ] =0x01 ;/* Type 0x8 - FCP */ - ae->un.AttrTypes[7 ] =0x01 ;/* Type 0x20 - CT */ + fc4types = (ATTR_FC4_CT |ATTR_FC4_FCP );/* Check to see if NVME is configured or not */ if (vport == phba->pport && phba->cfg_enable_fc4_type &LPFC_ENABLE_NVME ) - ae->un.AttrTypes[6 ] =0x1 ;/* Type 0x28 - NVME */ + fc4types |=ATTR_FC4_NVME ; - size =FOURBYTES +32 ; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_ACTIVE_FC4_TYPES ); -return size; +return lpfc_fdmi_set_attr_fc4types (attr,RPRT_ACTIVE_FC4_TYPES , + fc4types); }static int -lpfc_fdmi_port_attr_port_state (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_port_state (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; -/* Link Up - operational */ - ae->un.AttrInt =cpu_to_be32 (LPFC_FDMI_PORTSTATE_ONLINE ); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_PORT_STATE ); -return size; +return lpfc_fdmi_set_attr_u32 (attr,RPRT_PORT_STATE , +LPFC_FDMI_PORTSTATE_ONLINE ); }static int -lpfc_fdmi_port_attr_num_disc (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_num_disc (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; vport->fdmi_num_disc =lpfc_find_map_node (vport); - ae->un.AttrInt =cpu_to_be32 (vport->fdmi_num_disc); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_DISC_PORT ); -return size; + +return lpfc_fdmi_set_attr_u32 (attr,RPRT_DISC_PORT , + vport->fdmi_num_disc); }static int -lpfc_fdmi_port_attr_nportid (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_port_attr_nportid (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; - ae->un.AttrInt =cpu_to_be32 (vport->fc_myDID); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_PORT_ID ); -return size; +return lpfc_fdmi_set_attr_u32 (attr,RPRT_PORT_ID , vport->fc_myDID); }static int -lpfc_fdmi_smart_attr_service (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_smart_attr_service (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; - - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); - -strncpy (ae->un.AttrString,"Smart SAN Initiator" , -sizeof (ae->un.AttrString)); - len =strnlen (ae->un.AttrString, -sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_SMART_SERVICE ); -return size; +return lpfc_fdmi_set_attr_string (attr,RPRT_SMART_SERVICE , +"Smart SAN Initiator" ); }static int -lpfc_fdmi_smart_attr_guid (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_smart_attr_guid (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); - -memcpy (&ae->un.AttrString, &vport->fc_sparam.nodeName, -sizeof (struct lpfc_name )); -memcpy ((((uint8_t *)&ae->un.AttrString) + -sizeof (struct lpfc_name )), - &vport->fc_sparam.portName,sizeof (struct lpfc_name )); - size =FOURBYTES + (2 *sizeof (struct lpfc_name )); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_SMART_GUID ); -return size; +return lpfc_fdmi_set_attr_fullwwn (attr,RPRT_SMART_GUID , + &vport->fc_sparam.nodeName, + &vport->fc_sparam.portName); }static int -lpfc_fdmi_smart_attr_version (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_smart_attr_version (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; - - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); - -strncpy (ae->un.AttrString,"Smart SAN Version 2.0" , -sizeof (ae->un.AttrString)); - len =strnlen (ae->un.AttrString, -sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_SMART_VERSION ); -return size; +return lpfc_fdmi_set_attr_string (attr,RPRT_SMART_VERSION , +"Smart SAN Version 2.0" ); }static int -lpfc_fdmi_smart_attr_model (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_smart_attr_model (struct lpfc_vport *vport,void *attr) {struct lpfc_hba *phba = vport->phba; -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; - - ae = &ad->AttrValue; -memset (ae,0 ,sizeof (*ae)); -strncpy (ae->un.AttrString, phba->ModelName, -sizeof (ae->un.AttrString)); - len =strnlen (ae->un.AttrString,sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_SMART_MODEL ); -return size; +return lpfc_fdmi_set_attr_string (attr,RPRT_SMART_MODEL , + phba->ModelName); }static int -lpfc_fdmi_smart_attr_port_info (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_smart_attr_port_info (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; -/* SRIOV (type 3) is not supported */ -if (vport->vpi) - ae->un.AttrInt =cpu_to_be32 (2 );/* NPIV */ -else - ae->un.AttrInt =cpu_to_be32 (1 );/* Physical */ - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_SMART_PORT_INFO ); -return size; + +return lpfc_fdmi_set_attr_u32 (attr,RPRT_SMART_PORT_INFO , + (vport->vpi) ?2 /* NPIV */ :1 /* Physical */ ); }static int -lpfc_fdmi_smart_attr_qos (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_smart_attr_qos (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; - ae->un.AttrInt =cpu_to_be32 (0 ); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_SMART_QOS ); -return size; +return lpfc_fdmi_set_attr_u32 (attr,RPRT_SMART_QOS ,0 ); }static int -lpfc_fdmi_smart_attr_security (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_smart_attr_security (struct lpfc_vport *vport,void *attr) { -struct lpfc_fdmi_attr_entry *ae; -uint32_t size; - - ae = &ad->AttrValue; - ae->un.AttrInt =cpu_to_be32 (1 ); - size =FOURBYTES +sizeof (uint32_t ); - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_SMART_SECURITY ); -return size; +return lpfc_fdmi_set_attr_u32 (attr,RPRT_SMART_SECURITY ,1 ); }static int -lpfc_fdmi_vendor_attr_mi (struct lpfc_vport *vport, -struct lpfc_fdmi_attr_def *ad) +lpfc_fdmi_vendor_attr_mi (struct lpfc_vport *vport,void *attr) {struct lpfc_hba *phba = vport->phba; -struct lpfc_fdmi_attr_entry *ae; -uint32_t len, size; -char mibrevision[16 ]; - - ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; -memset (ae,0 ,256 ); -sprintf (mibrevision,"ELXE2EM:%04d" , - phba->sli4_hba.pc_sli4_params.mi_ver); -strncpy (ae->un.AttrString, &mibrevision[0 ],sizeof (ae->un.AttrString)); - len =strnlen (ae->un.AttrString,sizeof (ae->un.AttrString)); - len += (len &3 ) ? (4 - (len &3 )) :4 ; - size =FOURBYTES + len; - ad->AttrLen =cpu_to_be16 (size); - ad->AttrType =cpu_to_be16 (RPRT_VENDOR_MI ); -return size; +char buf[32 ] = {0 }; + +sprintf (buf,"ELXE2EM:%04d" , phba->sli4_hba.pc_sli4_params.mi_ver); + +return lpfc_fdmi_set_attr_string (attr,RPRT_VENDOR_MI , buf); }/* RHBA attribute jump table */ int (*lpfc_fdmi_hba_action[]) - (struct lpfc_vport *vport,struct lpfc_fdmi_attr_def *ad) = { + (struct lpfc_vport *vport,void *attrbuf) = {/* Action routine Mask bit Attribute type */ lpfc_fdmi_hba_attr_wwnn,/* bit0 RHBA_NODENAME */ lpfc_fdmi_hba_attr_manufacturer,/* bit1 RHBA_MANUFACTURER */
@@ -3482,7 +3135,7 @@ int (*lpfc_fdmi_hba_action[])/* RPA / RPRT attribute jump table */ int (*lpfc_fdmi_port_action[]) - (struct lpfc_vport *vport,struct lpfc_fdmi_attr_def *ad) = { + (struct lpfc_vport *vport,void *attrbuf) = {/* Action routine Mask bit Attribute type */ lpfc_fdmi_port_attr_fc4type,/* bit0 RPRT_SUPPORT_FC4_TYPES */ lpfc_fdmi_port_attr_support_speed,/* bit1 RPRT_SUPPORTED_SPEED */
@@ -3528,16 +3181,16 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,struct lpfc_sli_ct_request *CtReq;struct ulp_bde64_le *bde;uint32_t bit_pos; -uint32_t size; +uint32_t size, addsz;uint32_t rsp_size;uint32_t mask;struct lpfc_fdmi_reg_hba *rh;struct lpfc_fdmi_port_entry *pe;struct lpfc_fdmi_reg_portattr *pab =NULL , *base =NULL ;struct lpfc_fdmi_attr_block *ab =NULL ; -int (*func)(struct lpfc_vport *vport,struct lpfc_fdmi_attr_def *ad); -void (*cmpl)(struct lpfc_hba *,struct lpfc_iocbq *, -struct lpfc_iocbq *); +int (*func)(struct lpfc_vport *vport,void *attrbuf); +void (*cmpl)(struct lpfc_hba *phba,struct lpfc_iocbq *cmdiocb, +struct lpfc_iocbq *rspiocb);if (!ndlp)return 0 ;
@@ -3623,12 +3276,13 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,while (mask) {if (mask &0x1 ) { func = lpfc_fdmi_hba_action[bit_pos]; - size +=func (vport, - (struct lpfc_fdmi_attr_def *) - ((uint8_t *)rh + size)); - ab->EntryCnt++; + addsz =func (vport, ((uint8_t *)rh + size)); +if (addsz) { + ab->EntryCnt++; + size += addsz; + }/* check if another attribute fits */ -if ((size +256 ) > +if ((size +FDMI_MAX_ATTRLEN ) > (LPFC_BPL_SIZE -LPFC_CT_PREAMBLE )) goto hba_out; }
@@ -3682,12 +3336,13 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,while (mask) {if (mask &0x1 ) { func = lpfc_fdmi_port_action[bit_pos]; - size +=func (vport, - (struct lpfc_fdmi_attr_def *) - ((uint8_t *)base + size)); - pab->ab.EntryCnt++; + addsz =func (vport, ((uint8_t *)base + size)); +if (addsz) { + pab->ab.EntryCnt++; + size += addsz; + }/* check if another attribute fits */ -if ((size +256 ) > +if ((size +FDMI_MAX_ATTRLEN ) > (LPFC_BPL_SIZE -LPFC_CT_PREAMBLE )) goto port_out; }
drivers/scsi/lpfc/lpfc_hw.h +42 -16
72 lines not on this page · raw message
Signature · 1 line
2.35.3
PATCH 11/13 lpfc: Add reporting capability for Link Degrade Signaling
In reply to James SmartFirmware reports link degrade signaling via ACQES.
Handlers and new additions to the SET_FEATURES mbox command are implemented so that link degrade parameters for 64GB capable links are reported through EDC ELS frames.
--- drivers/scsi/lpfc/lpfc.h | 6 ++ drivers/scsi/lpfc/lpfc_crtn.h | 1 + drivers/scsi/lpfc/lpfc_els.c | 154 ++++++++++++++++++++++--------- drivers/scsi/lpfc/lpfc_hbadisc.c | 10 +- drivers/scsi/lpfc/lpfc_hw4.h | 30 +++--- drivers/scsi/lpfc/lpfc_init.c | 26 +++++- drivers/scsi/lpfc/lpfc_logmsg.h | 2 +- drivers/scsi/lpfc/lpfc_sli.c | 63 ++++++++++++- 8 files changed, 224 insertions(+), 68 deletions(-)
drivers/scsi/lpfc/lpfc.h +6 -0
@@ -403,6 +403,7 @@ struct lpfc_trunk_link { link1, link2, link3; +u32 phy_lnk_speed; };/* Format of congestion module parameters */
@@ -1596,6 +1597,11 @@ struct lpfc_hba {char os_host_name[MAXHOSTNAMELEN ]; +/* LD Signaling */ +u32 degrade_activate_threshold; +u32 degrade_deactivate_threshold; +u32 fec_degrade_interval; +atomic_t dbg_log_idx;atomic_t dbg_log_cnt;atomic_t dbg_log_dmping;
drivers/scsi/lpfc/lpfc_crtn.h +1 -0
@@ -78,6 +78,7 @@ int lpfc_init_iocb_list(struct lpfc_hba *phba, int cnt);void lpfc_free_iocb_list (struct lpfc_hba *phba);int lpfc_post_rq_buffer (struct lpfc_hba *phba,struct lpfc_queue *hrq,struct lpfc_queue *drq,int count,int idx); +int lpfc_read_lds_params (struct lpfc_hba *phba);uint32_t lpfc_calc_cmf_latency (struct lpfc_hba *phba);void lpfc_cmf_signal_init (struct lpfc_hba *phba);void lpfc_cmf_start (struct lpfc_hba *phba);
drivers/scsi/lpfc/lpfc_els.c +111 -43
269 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_hbadisc.c +9 -1
@@ -1242,6 +1242,8 @@ lpfc_linkdown(struct lpfc_hba *phba) phba->trunk_link.link1.state =0 ; phba->trunk_link.link2.state =0 ; phba->trunk_link.link3.state =0 ; + phba->trunk_link.phy_lnk_speed = +LPFC_LINK_SPEED_UNKNOWN ; phba->sli4_hba.link_state.logical_speed =LPFC_LINK_SPEED_UNKNOWN ; }
@@ -3794,6 +3796,9 @@ lpfc_mbx_cmpl_read_topology(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)if (phba->cmf_active_mode !=LPFC_CFG_OFF )lpfc_cmf_signal_init (phba); +if (phba->lmt & LMT_64Gb) +lpfc_read_lds_params (phba); + }else if (attn_type ==LPFC_ATT_LINK_DOWN || attn_type ==LPFC_ATT_UNEXP_WWPN ) { phba->fc_stat.LinkDown++;
@@ -4393,8 +4398,11 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) rc =lpfc_issue_els_edc (vport,0 );lpfc_printf_log (phba,KERN_INFO ,LOG_INIT |LOG_ELS |LOG_DISCOVERY , -"4220 EDC issue error x%x, Data: x%x\n" , +"4220 Issue EDC status x%x Data x%x\n" , rc, phba->cgn_init_reg_signal); + }else if (phba->lmt & LMT_64Gb) { +/* may send link fault capability descriptor */ +lpfc_issue_els_edc (vport,0 ); }else {lpfc_issue_els_rdf (vport,0 ); }
drivers/scsi/lpfc/lpfc_hw4.h +11 -19
@@ -3484,9 +3484,10 @@ struct lpfc_sli4_parameters {#define LPFC_SET_UE_RECOVERY 0x10#define LPFC_SET_MDS_DIAGS 0x12 -#define LPFC_SET_CGN_SIGNAL 0x1f#define LPFC_SET_DUAL_DUMP 0x1e +#define LPFC_SET_CGN_SIGNAL 0x1f#define LPFC_SET_ENABLE_MI 0x21 +#define LPFC_SET_LD_SIGNAL 0x23#define LPFC_SET_ENABLE_CMF 0x24struct lpfc_mbx_set_feature {struct mbox_header header;
@@ -3517,13 +3518,17 @@ struct lpfc_mbx_set_feature {#define lpfc_mbx_set_feature_cmf_SHIFT 0#define lpfc_mbx_set_feature_cmf_MASK 0x00000001#define lpfc_mbx_set_feature_cmf_WORD word6 +#define lpfc_mbx_set_feature_lds_qry_SHIFT 0 +#define lpfc_mbx_set_feature_lds_qry_MASK 0x00000001 +#define lpfc_mbx_set_feature_lds_qry_WORD word6 +#define LPFC_QUERY_LDS_OP 1#define lpfc_mbx_set_feature_mi_SHIFT 0#define lpfc_mbx_set_feature_mi_MASK 0x0000ffff#define lpfc_mbx_set_feature_mi_WORD word6#define lpfc_mbx_set_feature_milunq_SHIFT 16#define lpfc_mbx_set_feature_milunq_MASK 0x0000ffff#define lpfc_mbx_set_feature_milunq_WORD word6 -uint32_t word7; +u32 word7;#define lpfc_mbx_set_feature_UERP_SHIFT 0#define lpfc_mbx_set_feature_UERP_MASK 0x0000ffff#define lpfc_mbx_set_feature_UERP_WORD word7
@@ -3537,6 +3542,8 @@ struct lpfc_mbx_set_feature {#define lpfc_mbx_set_feature_CGN_acqe_freq_SHIFT 0#define lpfc_mbx_set_feature_CGN_acqe_freq_MASK 0x000000ff#define lpfc_mbx_set_feature_CGN_acqe_freq_WORD word8 +u32 word9; +u32 word10; };
@@ -4314,7 +4321,7 @@ struct lpfc_acqe_cgn_signal {struct lpfc_acqe_sli {uint32_t event_data1;uint32_t event_data2; -uint32_t reserved; +uint32_t event_data3;uint32_t trailer;#define LPFC_SLI_EVENT_TYPE_PORT_ERROR 0x1#define LPFC_SLI_EVENT_TYPE_OVER_TEMP 0x2
@@ -4327,6 +4334,7 @@ struct lpfc_acqe_sli {#define LPFC_SLI_EVENT_TYPE_MISCONF_FAWWN 0xF#define LPFC_SLI_EVENT_TYPE_EEPROM_FAILURE 0x10#define LPFC_SLI_EVENT_TYPE_CGN_SIGNAL 0x11 +#define LPFC_SLI_EVENT_TYPE_RD_SIGNAL 0x12 };/*
@@ -5050,22 +5058,6 @@ struct lpfc_grp_hdr { { FPIN_CONGN_SEVERITY_ERROR, "Alarm" }, \ } -/* EDC supports two descriptors. When allocated, it is the -* size of this structure plus each supported descriptor. -*/ -struct lpfc_els_edc_req { -struct fc_els_edc edc;/* hdr up to descriptors */ -struct fc_diag_cg_sig_desc cgn_desc;/* 1st descriptor */ -}; - -/* Minimum structure defines for the EDC response. -* Balance is in buffer. -*/ -struct lpfc_els_edc_rsp { -struct fc_els_edc_resp edc_rsp;/* hdr up to descriptors */ -struct fc_diag_cg_sig_desc cgn_desc;/* 1st descriptor */ -}; -/* Used for logging FPIN messages */ #define LPFC_FPIN_WWPN_LINE_SZ 128#define LPFC_FPIN_WWPN_LINE_CNT 6
drivers/scsi/lpfc/lpfc_init.c +23 -3
@@ -6185,6 +6185,7 @@ lpfc_update_trunk_link_status(struct lpfc_hba *phba, {uint8_t port_fault =bf_get (lpfc_acqe_fc_la_trunk_linkmask, acqe_fc);uint8_t err =bf_get (lpfc_acqe_fc_la_trunk_fault, acqe_fc); +u8 cnt =0 ; phba->sli4_hba.link_state.speed = lpfc_sli4_port_speed_parse(phba, LPFC_TRAILER_CODE_FC,
@@ -6203,26 +6204,36 @@ lpfc_update_trunk_link_status(struct lpfc_hba *phba,bf_get (lpfc_acqe_fc_la_trunk_link_status_port0, acqe_fc) ?LPFC_LINK_UP :LPFC_LINK_DOWN ; phba->trunk_link.link0.fault = port_fault &0x1 ? err :0 ; + cnt++; }if (bf_get (lpfc_acqe_fc_la_trunk_config_port1, acqe_fc)) { phba->trunk_link.link1.state =bf_get (lpfc_acqe_fc_la_trunk_link_status_port1, acqe_fc) ?LPFC_LINK_UP :LPFC_LINK_DOWN ; phba->trunk_link.link1.fault = port_fault &0x2 ? err :0 ; + cnt++; }if (bf_get (lpfc_acqe_fc_la_trunk_config_port2, acqe_fc)) { phba->trunk_link.link2.state =bf_get (lpfc_acqe_fc_la_trunk_link_status_port2, acqe_fc) ?LPFC_LINK_UP :LPFC_LINK_DOWN ; phba->trunk_link.link2.fault = port_fault &0x4 ? err :0 ; + cnt++; }if (bf_get (lpfc_acqe_fc_la_trunk_config_port3, acqe_fc)) { phba->trunk_link.link3.state =bf_get (lpfc_acqe_fc_la_trunk_link_status_port3, acqe_fc) ?LPFC_LINK_UP :LPFC_LINK_DOWN ; phba->trunk_link.link3.fault = port_fault &0x8 ? err :0 ; + cnt++; } +if (cnt) + phba->trunk_link.phy_lnk_speed = + phba->sli4_hba.link_state.logical_speed / (cnt *1000 ); +else + phba->trunk_link.phy_lnk_speed =LPFC_LINK_SPEED_UNKNOWN ; +lpfc_printf_log (phba,KERN_ERR ,LOG_TRACE_EVENT ,"2910 Async FC Trunking Event - Speed:%d\n" "\tLogical speed:%d "
@@ -6300,7 +6311,7 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc)if (bf_get (lpfc_acqe_fc_la_att_type, acqe_fc) ==LPFC_FC_LA_TYPE_LINK_DOWN ) phba->sli4_hba.link_state.logical_speed =0 ; -else if (!phba->sli4_hba.conf_trunk) +else if (!phba->sli4_hba.conf_trunk) phba->sli4_hba.link_state.logical_speed =bf_get (lpfc_acqe_fc_la_llink_spd, acqe_fc) *10 ;
@@ -6418,7 +6429,7 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli)"2901 Async SLI event - Type:%d, Event Data: x%08x " "x%08x x%08x x%08x\n" , evt_type, acqe_sli->event_data1, acqe_sli->event_data2, - acqe_sli->reserved, acqe_sli->trailer); + acqe_sli->event_data3, acqe_sli->trailer); port_name = phba->Port[0 ];if (port_name ==0x00 )
@@ -6447,7 +6458,7 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli) temp_event_data.event_code =LPFC_NORMAL_TEMP ; temp_event_data.data = (uint32_t )acqe_sli->event_data1; -lpfc_printf_log (phba,KERN_INFO ,LOG_SLI , +lpfc_printf_log (phba,KERN_INFO ,LOG_SLI |LOG_LDS_EVENT ,"3191 Normal Temperature:%d Celsius - Port Name %c\n" , acqe_sli->event_data1, port_name);
@@ -6625,6 +6636,15 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli) } }break ; +case LPFC_SLI_EVENT_TYPE_RD_SIGNAL : +/* May be accompanied by a temperature event */ +lpfc_printf_log (phba,KERN_INFO , +LOG_SLI |LOG_LINK_EVENT |LOG_LDS_EVENT , +"2902 Remote Degrade Signaling: x%08x x%08x " +"x%08x\n" , + acqe_sli->event_data1, acqe_sli->event_data2, + acqe_sli->event_data3); +break ;default : lpfc_printf_log(phba, KERN_INFO, LOG_SLI, "3193 Unrecognized SLI event, type: 0x%x",
drivers/scsi/lpfc/lpfc_logmsg.h +1 -1
@@ -35,7 +35,7 @@#define LOG_FCP_ERROR 0x00001000/* log errors, not underruns */ #define LOG_LIBDFC 0x00002000/* Libdfc events */ #define LOG_VPORT 0x00004000/* NPIV events */ -#define LOG_SECURITY 0x00008000/* Security events */ +#define LOG_LDS_EVENT 0x00008000/* Link Degrade Signaling events */ #define LOG_EVENT 0x00010000/* CT,TEMP,DUMP, logging */ #define LOG_FIP 0x00020000/* FIP events */ #define LOG_FCP_UNDER 0x00040000/* FCP underruns errors */
drivers/scsi/lpfc/lpfc_sli.c +62 -1
76 lines not on this page · raw message
Signature · 1 line
2.35.3
PATCH 12/13 lpfc: Fix various issues reported by tools
In reply to James SmartThis patch fixes below Smatch reported issues:
1. lpfc_hbadisc.c:3020 lpfc_mbx_cmpl_fcf_rr_read_fcf_rec()
error: uninitialized symbol 'vlan_id'.
2. lpfc_hbadisc.c:3121 lpfc_mbx_cmpl_read_fcf_rec()
error: uninitialized symbol 'vlan_id'.
3. lpfc_init.c:335 lpfc_dump_wakeup_param_cmpl()
warn: always true condition '(prg->dist < 4) => (0-3 < 4)'
4. lpfc_init.c:2419 lpfc_parse_vpd()
warn: inconsistent indenting.
5. lpfc_init.c:13248 lpfc_sli4_enable_msi()
warn: 'phba->pcidev->irq' 2147483648 can't fit into 65535 'eqhdl->irq'
6. lpfc_debugfs.c:5300 lpfc_idiag_extacc_avail_get()
error: uninitialized symbol 'ext_cnt'
7. lpfc_debugfs.c:5300 lpfc_idiag_extacc_avail_get()
error: uninitialized symbol 'ext_size'
8. lpfc_vmid.c:248 lpfc_vmid_get_appid()
warn: sleeping in atomic context.
9. lpfc_init.c:8342 lpfc_sli4_driver_resource_setup()
warn: missing error code 'rc'.
10. lpfc_init.c:13573 lpfc_sli4_hba_unset()
warn: variable dereferenced before check 'phba->pport' (see
line 13546)11. lpfc_auth.c:1923 lpfc_auth_handle_dhchap_reply()
error: double free of 'hash_value'
Fixes:
1. Initialize vlan_id to LPFC_FCOE_NULL_VID. 2. Initialize
vlan_id to LPFC_FCOE_NULL_VID. 3. prg->dist is a 2 bit field.
Its value can only be between 0-3.
Remove redundent check 'if (prg->dist < 4)'.
4. Fix inconsistent indenting. Moved logic into helper function
lpfc_fill_vpd(). 5. Define 'eqhdl->irq' as int value as pci_irq_vector() returns int. Also, check for return value of pci_irq_vector() and log message in case of failure.
6. Initialize 'ext_cnt' to 0. 7. Initialize 'ext_size' to 0.
8. Use alloc_percpu_gfp() with GFP_ATOMIC flag. 9. 'rc' was not updated when dma_pool_create() fails.
Update 'rc = -ENOMEM' when dma_pool_create() fails before calling goto statement.
10. Add check for 'phba->pport' in lpfc_cpuhp_remove().
11. Initialize 'hash_value' to NULL, same like 'aug_chal' variable.
--- drivers/scsi/lpfc/lpfc_debugfs.c | 2 +- drivers/scsi/lpfc/lpfc_hbadisc.c | 4 +- drivers/scsi/lpfc/lpfc_init.c | 249 +++++++++++++++++-------------- drivers/scsi/lpfc/lpfc_sli.c | 3 + drivers/scsi/lpfc/lpfc_sli4.h | 4 +- drivers/scsi/lpfc/lpfc_vmid.c | 4 +- 6 files changed, 148 insertions(+), 118 deletions(-)
drivers/scsi/lpfc/lpfc_debugfs.c +1 -1
@@ -5156,7 +5156,7 @@ lpfc_idiag_mbxacc_write(struct file *file, const char __user *buf,static int lpfc_idiag_extacc_avail_get (struct lpfc_hba *phba,char *pbuffer,int len) { -uint16_t ext_cnt, ext_size; +uint16_t ext_cnt =0 , ext_size =0 ; len +=scnprintf (pbuffer+len,LPFC_EXT_ACC_BUF_SIZE -len,"\nAvailable Extents Information:\n" );
drivers/scsi/lpfc/lpfc_hbadisc.c +2 -2
@@ -2970,7 +2970,7 @@ lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)uint32_t boot_flag, addr_mode;uint16_t next_fcf_index, fcf_index;uint16_t current_fcf_index; -uint16_t vlan_id; +uint16_t vlan_id =LPFC_FCOE_NULL_VID ;int rc;/* If link state is not up, stop the roundrobin failover process */
@@ -3075,7 +3075,7 @@ lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)struct fcf_record *new_fcf_record;uint32_t boot_flag, addr_mode;uint16_t fcf_index, next_fcf_index; -uint16_t vlan_id; +uint16_t vlan_id =LPFC_FCOE_NULL_VID ;int rc;/* If link state is not up, no need to proceed */
drivers/scsi/lpfc/lpfc_init.c +138 -111
329 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_sli.c +3 -0
@@ -6215,6 +6215,9 @@ lpfc_sli4_get_avail_extnt_rsrc(struct lpfc_hba *phba, uint16_t type,struct lpfc_mbx_get_rsrc_extent_info *rsrc_info;LPFC_MBOXQ_t *mbox; + *extnt_count =0 ; + *extnt_size =0 ; + mbox = (LPFC_MBOXQ_t *)mempool_alloc (phba->mbox_mem_pool,GFP_KERNEL );if (!mbox)return -ENOMEM ;
drivers/scsi/lpfc/lpfc_sli4.h +3 -1
@@ -489,7 +489,7 @@ struct lpfc_hba;#define LPFC_SLI4_HANDLER_NAME_SZ 16struct lpfc_hba_eq_hdl {uint32_t idx; -uint16_t irq; +int irq;char handler_name[LPFC_SLI4_HANDLER_NAME_SZ ];struct lpfc_hba *phba;struct lpfc_queue *eq;
@@ -611,6 +611,8 @@ struct lpfc_vector_map_info { };#define LPFC_VECTOR_MAP_EMPTY 0xffff +#define LPFC_IRQ_EMPTY 0xffffffff +/* Multi-XRI pool */ #define XRI_BATCH 8
drivers/scsi/lpfc/lpfc_vmid.c +1 -3
@@ -245,9 +245,7 @@ int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid,/* allocate the per cpu variable for holding */ /* the last access time stamp only if VMID is enabled */ if (!vmp->last_io_time) - vmp->last_io_time =__alloc_percpu (sizeof (u64), - __alignof__(struct -lpfc_vmid )); + vmp->last_io_time =alloc_percpu_gfp (u64,GFP_ATOMIC );if (!vmp->last_io_time) {hash_del (&vmp->hnode); vmp->flag =LPFC_VMID_SLOT_FREE ;
Signature · 1 line
2.35.3
PATCH 13/13 lpfc: Update lpfc version to 14.2.0.7
In reply to James SmartUpdate lpfc version to 14.2.0.7
--- drivers/scsi/lpfc/lpfc_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_version.h +1 -1
@@ -20,7 +20,7 @@* included with this package. * *******************************************************************/ -#define LPFC_DRIVER_VERSION "14.2.0.6" +#define LPFC_DRIVER_VERSION "14.2.0.7"#define LPFC_DRIVER_NAME "lpfc"/* Used for SLI 2/3 */
Signature · 1 line
2.35.3
Martin K. Petersen
AppliedJames,
Quoted 1 line
Update lpfc to revision 14.2.0.7
Applied to 6.1/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering