Commit 3d6776a3 authored by Martin K. Petersen's avatar Martin K. Petersen
Browse files

Merge patch series "Update lpfc to revision 14.4.0.0"

Justin Tee <justintee8345@gmail.com> says:

Update lpfc to revision 14.4.0.0

This patch set contains fixes identified by static code analyzers,
updates to log messaging, bug fixes related to discovery and
congestion management, and clean up patches regarding the abuse of
shost lock in the driver.

The patches were cut against Martin's 6.9/scsi-queue tree.

Link: https://lore.kernel.org/r/20240131185112.149731-1-justintee8345@gmail.com


Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parents 3f90ac71 ea4044e4
Loading
Loading
Loading
Loading
+51 −43
Original line number Diff line number Diff line
/*******************************************************************
 * This file is part of the Emulex Linux Device Driver for         *
 * Fibre Channel Host Bus Adapters.                                *
 * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term *
 * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term *
 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.     *
 * Copyright (C) 2004-2016 Emulex.  All rights reserved.           *
 * EMULEX and SLI are trademarks of Emulex.                        *
@@ -535,6 +535,44 @@ struct lpfc_cgn_acqe_stat {
	atomic64_t warn;
};

enum lpfc_fc_flag {
	/* Several of these flags are HBA centric and should be moved to
	 * phba->link_flag (e.g. FC_PTP, FC_PUBLIC_LOOP)
	 */
	FC_PT2PT,			/* pt2pt with no fabric */
	FC_PT2PT_PLOGI,			/* pt2pt initiate PLOGI */
	FC_DISC_TMO,			/* Discovery timer running */
	FC_PUBLIC_LOOP,			/* Public loop */
	FC_LBIT,			/* LOGIN bit in loopinit set */
	FC_RSCN_MODE,			/* RSCN cmd rcv'ed */
	FC_NLP_MORE,			/* More node to process in node tbl */
	FC_OFFLINE_MODE,		/* Interface is offline for diag */
	FC_FABRIC,			/* We are fabric attached */
	FC_VPORT_LOGO_RCVD,		/* LOGO received on vport */
	FC_RSCN_DISCOVERY,		/* Auth all devices after RSCN */
	FC_LOGO_RCVD_DID_CHNG,		/* FDISC on phys port detect DID chng */
	FC_PT2PT_NO_NVME,		/* Don't send NVME PRLI */
	FC_SCSI_SCAN_TMO,		/* scsi scan timer running */
	FC_ABORT_DISCOVERY,		/* we want to abort discovery */
	FC_NDISC_ACTIVE,		/* NPort discovery active */
	FC_BYPASSED_MODE,		/* NPort is in bypassed mode */
	FC_VPORT_NEEDS_REG_VPI,		/* Needs to have its vpi registered */
	FC_RSCN_DEFERRED,		/* A deferred RSCN being processed */
	FC_VPORT_NEEDS_INIT_VPI,	/* Need to INIT_VPI before FDISC */
	FC_VPORT_CVL_RCVD,		/* VLink failed due to CVL */
	FC_VFI_REGISTERED,		/* VFI is registered */
	FC_FDISC_COMPLETED,		/* FDISC completed */
	FC_DISC_DELAYED,		/* Delay NPort discovery */
};

enum lpfc_load_flag {
	FC_LOADING,			/* HBA in process of loading drvr */
	FC_UNLOADING,			/* HBA in process of unloading drvr */
	FC_ALLOW_FDMI,			/* port is ready for FDMI requests */
	FC_ALLOW_VMID,			/* Allow VMID I/Os */
	FC_DEREGISTER_ALL_APP_ID	/* Deregister all VMIDs */
};

struct lpfc_vport {
	struct lpfc_hba *phba;
	struct list_head listentry;
@@ -549,34 +587,7 @@ struct lpfc_vport {
	uint8_t vpi_state;
#define LPFC_VPI_REGISTERED	0x1

	uint32_t fc_flag;	/* FC flags */
/* Several of these flags are HBA centric and should be moved to
 * phba->link_flag (e.g. FC_PTP, FC_PUBLIC_LOOP)
 */
#define FC_PT2PT                0x1	 /* pt2pt with no fabric */
#define FC_PT2PT_PLOGI          0x2	 /* pt2pt initiate PLOGI */
#define FC_DISC_TMO             0x4	 /* Discovery timer running */
#define FC_PUBLIC_LOOP          0x8	 /* Public loop */
#define FC_LBIT                 0x10	 /* LOGIN bit in loopinit set */
#define FC_RSCN_MODE            0x20	 /* RSCN cmd rcv'ed */
#define FC_NLP_MORE             0x40	 /* More node to process in node tbl */
#define FC_OFFLINE_MODE         0x80	 /* Interface is offline for diag */
#define FC_FABRIC               0x100	 /* We are fabric attached */
#define FC_VPORT_LOGO_RCVD      0x200    /* LOGO received on vport */
#define FC_RSCN_DISCOVERY       0x400	 /* Auth all devices after RSCN */
#define FC_LOGO_RCVD_DID_CHNG   0x800    /* FDISC on phys port detect DID chng*/
#define FC_PT2PT_NO_NVME        0x1000   /* Don't send NVME PRLI */
#define FC_SCSI_SCAN_TMO        0x4000	 /* scsi scan timer running */
#define FC_ABORT_DISCOVERY      0x8000	 /* we want to abort discovery */
#define FC_NDISC_ACTIVE         0x10000	 /* NPort discovery active */
#define FC_BYPASSED_MODE        0x20000	 /* NPort is in bypassed mode */
#define FC_VPORT_NEEDS_REG_VPI	0x80000  /* Needs to have its vpi registered */
#define FC_RSCN_DEFERRED	0x100000 /* A deferred RSCN being processed */
#define FC_VPORT_NEEDS_INIT_VPI 0x200000 /* Need to INIT_VPI before FDISC */
#define FC_VPORT_CVL_RCVD	0x400000 /* VLink failed due to CVL	 */
#define FC_VFI_REGISTERED	0x800000 /* VFI is registered */
#define FC_FDISC_COMPLETED	0x1000000/* FDISC completed */
#define FC_DISC_DELAYED		0x2000000/* Delay NPort discovery */
	unsigned long fc_flag;	/* FC flags */

	uint32_t ct_flags;
#define FC_CT_RFF_ID		0x1	 /* RFF_ID accepted by switch */
@@ -587,16 +598,18 @@ struct lpfc_vport {
#define FC_CT_RPRT_DEFER	0x20	 /* Defer issuing FDMI RPRT */

	struct list_head fc_nodes;
	spinlock_t fc_nodes_list_lock; /* spinlock for fc_nodes list */

	/* Keep counters for the number of entries in each list. */
	uint16_t fc_plogi_cnt;
	uint16_t fc_adisc_cnt;
	uint16_t fc_reglogin_cnt;
	uint16_t fc_prli_cnt;
	uint16_t fc_unmap_cnt;
	uint16_t fc_map_cnt;
	uint16_t fc_npr_cnt;
	uint16_t fc_unused_cnt;
	atomic_t fc_plogi_cnt;
	atomic_t fc_adisc_cnt;
	atomic_t fc_reglogin_cnt;
	atomic_t fc_prli_cnt;
	atomic_t fc_unmap_cnt;
	atomic_t fc_map_cnt;
	atomic_t fc_npr_cnt;
	atomic_t fc_unused_cnt;

	struct serv_parm fc_sparam;	/* buffer for our service parameters */

	uint32_t fc_myDID;	/* fibre channel S_ID */
@@ -642,12 +655,7 @@ struct lpfc_vport {
	struct timer_list els_tmofunc;
	struct timer_list delayed_disc_tmo;

	uint8_t load_flag;
#define FC_LOADING		0x1	/* HBA in process of loading drvr */
#define FC_UNLOADING		0x2	/* HBA in process of unloading drvr */
#define FC_ALLOW_FDMI		0x4	/* port is ready for FDMI requests */
#define FC_ALLOW_VMID		0x8	/* Allow VMID I/Os */
#define FC_DEREGISTER_ALL_APP_ID	0x10	/* Deregister all VMIDs */
	unsigned long load_flag;
	/* Vport Config Parameters */
	uint32_t cfg_scan_down;
	uint32_t cfg_lun_queue_depth;
+47 −60
Original line number Diff line number Diff line
/*******************************************************************
 * This file is part of the Emulex Linux Device Driver for         *
 * Fibre Channel Host Bus Adapters.                                *
 * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term *
 * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term *
 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.  *
 * Copyright (C) 2004-2016 Emulex.  All rights reserved.           *
 * EMULEX and SLI are trademarks of Emulex.                        *
@@ -344,6 +344,7 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
	struct lpfc_fc4_ctrl_stat *cstat;
	uint64_t data1, data2, data3;
	uint64_t totin, totout, tot;
	unsigned long iflags;
	char *statep;
	int i;
	int len = 0;
@@ -543,7 +544,7 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
	if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
		goto buffer_done;

	spin_lock_irq(shost->host_lock);
	spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags);

	list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
		nrport = NULL;
@@ -617,7 +618,7 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
		if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
			goto unlock_buf_done;
	}
	spin_unlock_irq(shost->host_lock);
	spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags);

	if (!lport)
		goto buffer_done;
@@ -681,7 +682,7 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
	goto buffer_done;

 unlock_buf_done:
	spin_unlock_irq(shost->host_lock);
	spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags);

 buffer_done:
	len = strnlen(buf, PAGE_SIZE);
@@ -1091,14 +1092,14 @@ lpfc_link_state_show(struct device *dev, struct device_attribute *attr,
			break;
		}
		if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
			if (vport->fc_flag & FC_PUBLIC_LOOP)
			if (test_bit(FC_PUBLIC_LOOP, &vport->fc_flag))
				len += scnprintf(buf + len, PAGE_SIZE-len,
						"   Public Loop\n");
			else
				len += scnprintf(buf + len, PAGE_SIZE-len,
						"   Private Loop\n");
		} else {
			if (vport->fc_flag & FC_FABRIC) {
			if (test_bit(FC_FABRIC, &vport->fc_flag)) {
				if (phba->sli_rev == LPFC_SLI_REV4 &&
				    vport->port_type == LPFC_PHYSICAL_PORT &&
				    phba->sli4_hba.fawwpn_flag &
@@ -1260,7 +1261,8 @@ lpfc_num_discovered_ports_show(struct device *dev,
	struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;

	return scnprintf(buf, PAGE_SIZE, "%d\n",
			vport->fc_map_cnt + vport->fc_unmap_cnt);
			 atomic_read(&vport->fc_map_cnt) +
			 atomic_read(&vport->fc_unmap_cnt));
}

/**
@@ -1289,7 +1291,7 @@ lpfc_issue_lip(struct Scsi_Host *shost)
	 * If the link is offline, disabled or BLOCK_MGMT_IO
	 * it doesn't make any sense to allow issue_lip
	 */
	if ((vport->fc_flag & FC_OFFLINE_MODE) ||
	if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag) ||
	    (phba->hba_flag & LINK_DISABLED) ||
	    (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO))
		return -EPERM;
@@ -1303,8 +1305,8 @@ lpfc_issue_lip(struct Scsi_Host *shost)
	pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK;
	pmboxq->u.mb.mbxOwner = OWN_HOST;

	if ((vport->fc_flag & FC_PT2PT) && (vport->fc_flag & FC_PT2PT_NO_NVME))
		vport->fc_flag &= ~FC_PT2PT_NO_NVME;
	if (test_bit(FC_PT2PT, &vport->fc_flag))
		clear_bit(FC_PT2PT_NO_NVME, &vport->fc_flag);

	mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2);

@@ -1494,7 +1496,8 @@ lpfc_reset_pci_bus(struct lpfc_hba *phba)
		if (shost) {
			phba_other =
				((struct lpfc_vport *)shost->hostdata)->phba;
			if (!(phba_other->pport->fc_flag & FC_OFFLINE_MODE)) {
			if (!test_bit(FC_OFFLINE_MODE,
				      &phba_other->pport->fc_flag)) {
				lpfc_printf_log(phba_other, KERN_INFO, LOG_INIT,
						"8349 WWPN = 0x%02x%02x%02x%02x"
						"%02x%02x%02x%02x is not "
@@ -1549,7 +1552,7 @@ lpfc_selective_reset(struct lpfc_hba *phba)
	if (!phba->cfg_enable_hba_reset)
		return -EACCES;

	if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) {
	if (!test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) {
		status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);

		if (status != 0)
@@ -1688,7 +1691,7 @@ lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode)
{
	struct completion online_compl;
	struct pci_dev *pdev = phba->pcidev;
	uint32_t before_fc_flag;
	unsigned long before_fc_flag;
	uint32_t sriov_nr_virtfn;
	uint32_t reg_val;
	int status = 0, rc = 0;
@@ -1759,7 +1762,7 @@ lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode)
	}

	/* keep the original port state */
	if (before_fc_flag & FC_OFFLINE_MODE) {
	if (test_bit(FC_OFFLINE_MODE, &before_fc_flag)) {
		if (phba->fw_dump_cmpl)
			phba->fw_dump_cmpl = NULL;
		goto out;
@@ -2097,7 +2100,7 @@ lpfc_board_mode_store(struct device *dev, struct device_attribute *attr,
			*board_mode_str = '\0';
		lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
				 "3097 Failed \"%s\", status(%d), "
				 "fc_flag(x%x)\n",
				 "fc_flag(x%lx)\n",
				 buf, status, phba->pport->fc_flag);
		return status;
	}
@@ -2156,7 +2159,7 @@ lpfc_get_hba_info(struct lpfc_hba *phba,
	pmb->mbxOwner = OWN_HOST;
	pmboxq->ctx_buf = NULL;

	if (phba->pport->fc_flag & FC_OFFLINE_MODE)
	if (test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag))
		rc = MBX_NOT_FINISHED;
	else
		rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
@@ -3764,15 +3767,14 @@ lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val)
static void
lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport)
{
	struct Scsi_Host  *shost;
	struct lpfc_nodelist  *ndlp;
	unsigned long iflags;
#if (IS_ENABLED(CONFIG_NVME_FC))
	struct lpfc_nvme_rport *rport;
	struct nvme_fc_remote_port *remoteport = NULL;
#endif

	shost = lpfc_shost_from_vport(vport);
	spin_lock_irq(shost->host_lock);
	spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags);
	list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
		if (ndlp->rport)
			ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo;
@@ -3787,7 +3789,7 @@ lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport)
						       vport->cfg_devloss_tmo);
#endif
	}
	spin_unlock_irq(shost->host_lock);
	spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags);
}

/**
@@ -3973,8 +3975,8 @@ lpfc_vport_param_init(tgt_queue_depth, LPFC_MAX_TGT_QDEPTH,
static int
lpfc_tgt_queue_depth_set(struct lpfc_vport *vport, uint val)
{
	struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
	struct lpfc_nodelist *ndlp;
	unsigned long iflags;

	if (!lpfc_rangecheck(val, LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH))
		return -EINVAL;
@@ -3982,14 +3984,13 @@ lpfc_tgt_queue_depth_set(struct lpfc_vport *vport, uint val)
	if (val == vport->cfg_tgt_queue_depth)
		return 0;

	spin_lock_irq(shost->host_lock);
	vport->cfg_tgt_queue_depth = val;

	/* Next loop thru nodelist and change cmd_qdepth */
	spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags);
	list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp)
		ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth;

	spin_unlock_irq(shost->host_lock);
	spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags);
	return 0;
}

@@ -5235,8 +5236,8 @@ lpfc_vport_param_show(max_scsicmpl_time);
static int
lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val)
{
	struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
	struct lpfc_nodelist *ndlp, *next_ndlp;
	unsigned long iflags;

	if (val == vport->cfg_max_scsicmpl_time)
		return 0;
@@ -5244,13 +5245,13 @@ lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val)
		return -EINVAL;
	vport->cfg_max_scsicmpl_time = val;

	spin_lock_irq(shost->host_lock);
	spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags);
	list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
		if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
			continue;
		ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth;
	}
	spin_unlock_irq(shost->host_lock);
	spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags);
	return 0;
}
lpfc_vport_param_store(max_scsicmpl_time);
@@ -6200,7 +6201,7 @@ sysfs_ctlreg_write(struct file *filp, struct kobject *kobj,
	if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE))
		return -EINVAL;

	if (!(vport->fc_flag & FC_OFFLINE_MODE))
	if (!test_bit(FC_OFFLINE_MODE, &vport->fc_flag))
		return -EPERM;

	spin_lock_irq(&phba->hbalock);
@@ -6429,26 +6430,22 @@ lpfc_get_host_port_type(struct Scsi_Host *shost)
	struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
	struct lpfc_hba   *phba = vport->phba;

	spin_lock_irq(shost->host_lock);

	if (vport->port_type == LPFC_NPIV_PORT) {
		fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
	} else if (lpfc_is_link_up(phba)) {
		if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
			if (vport->fc_flag & FC_PUBLIC_LOOP)
			if (test_bit(FC_PUBLIC_LOOP, &vport->fc_flag))
				fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
			else
				fc_host_port_type(shost) = FC_PORTTYPE_LPORT;
		} else {
			if (vport->fc_flag & FC_FABRIC)
			if (test_bit(FC_FABRIC, &vport->fc_flag))
				fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
			else
				fc_host_port_type(shost) = FC_PORTTYPE_PTP;
		}
	} else
		fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;

	spin_unlock_irq(shost->host_lock);
}

/**
@@ -6461,9 +6458,7 @@ lpfc_get_host_port_state(struct Scsi_Host *shost)
	struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
	struct lpfc_hba   *phba = vport->phba;

	spin_lock_irq(shost->host_lock);

	if (vport->fc_flag & FC_OFFLINE_MODE)
	if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag))
		fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
	else {
		switch (phba->link_state) {
@@ -6490,8 +6485,6 @@ lpfc_get_host_port_state(struct Scsi_Host *shost)
			break;
		}
	}

	spin_unlock_irq(shost->host_lock);
}

/**
@@ -6504,8 +6497,6 @@ lpfc_get_host_speed(struct Scsi_Host *shost)
	struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
	struct lpfc_hba   *phba = vport->phba;

	spin_lock_irq(shost->host_lock);

	if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) {
		switch(phba->fc_linkspeed) {
		case LPFC_LINK_SPEED_1GHZ:
@@ -6568,8 +6559,6 @@ lpfc_get_host_speed(struct Scsi_Host *shost)
		}
	} else
		fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;

	spin_unlock_irq(shost->host_lock);
}

/**
@@ -6583,19 +6572,15 @@ lpfc_get_host_fabric_name (struct Scsi_Host *shost)
	struct lpfc_hba   *phba = vport->phba;
	u64 node_name;

	spin_lock_irq(shost->host_lock);

	if ((vport->port_state > LPFC_FLOGI) &&
	    ((vport->fc_flag & FC_FABRIC) ||
	     ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) &&
	      (vport->fc_flag & FC_PUBLIC_LOOP))))
	if (vport->port_state > LPFC_FLOGI &&
	    (test_bit(FC_FABRIC, &vport->fc_flag) ||
	     (phba->fc_topology == LPFC_TOPOLOGY_LOOP &&
	      test_bit(FC_PUBLIC_LOOP, &vport->fc_flag))))
		node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn);
	else
		/* fabric is local port if there is no F/FL_Port */
		node_name = 0;

	spin_unlock_irq(shost->host_lock);

	fc_host_fabric_name(shost) = node_name;
}

@@ -6646,7 +6631,7 @@ lpfc_get_stats(struct Scsi_Host *shost)
	pmboxq->ctx_buf = NULL;
	pmboxq->vport = vport;

	if (vport->fc_flag & FC_OFFLINE_MODE) {
	if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) {
		rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
		if (rc != MBX_SUCCESS) {
			mempool_free(pmboxq, phba->mbox_mem_pool);
@@ -6699,7 +6684,7 @@ lpfc_get_stats(struct Scsi_Host *shost)
	pmboxq->ctx_buf = NULL;
	pmboxq->vport = vport;

	if (vport->fc_flag & FC_OFFLINE_MODE) {
	if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) {
		rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
		if (rc != MBX_SUCCESS) {
			mempool_free(pmboxq, phba->mbox_mem_pool);
@@ -6786,8 +6771,8 @@ lpfc_reset_stats(struct Scsi_Host *shost)
	pmboxq->ctx_buf = NULL;
	pmboxq->vport = vport;

	if ((vport->fc_flag & FC_OFFLINE_MODE) ||
		(!(psli->sli_flag & LPFC_SLI_ACTIVE))) {
	if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag) ||
	    !(psli->sli_flag & LPFC_SLI_ACTIVE)) {
		rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
		if (rc != MBX_SUCCESS) {
			mempool_free(pmboxq, phba->mbox_mem_pool);
@@ -6808,8 +6793,8 @@ lpfc_reset_stats(struct Scsi_Host *shost)
	pmboxq->ctx_buf = NULL;
	pmboxq->vport = vport;

	if ((vport->fc_flag & FC_OFFLINE_MODE) ||
	    (!(psli->sli_flag & LPFC_SLI_ACTIVE))) {
	if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag) ||
	    !(psli->sli_flag & LPFC_SLI_ACTIVE)) {
		rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
		if (rc != MBX_SUCCESS) {
			mempool_free(pmboxq, phba->mbox_mem_pool);
@@ -6868,17 +6853,19 @@ lpfc_get_node_by_target(struct scsi_target *starget)
	struct Scsi_Host  *shost = dev_to_shost(starget->dev.parent);
	struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
	struct lpfc_nodelist *ndlp;
	unsigned long iflags;

	spin_lock_irq(shost->host_lock);
	spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags);
	/* Search for this, mapped, target ID */
	list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
		if (ndlp->nlp_state == NLP_STE_MAPPED_NODE &&
		    starget->id == ndlp->nlp_sid) {
			spin_unlock_irq(shost->host_lock);
			spin_unlock_irqrestore(&vport->fc_nodes_list_lock,
					       iflags);
			return ndlp;
		}
	}
	spin_unlock_irq(shost->host_lock);
	spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags);
	return NULL;
}

+4 −4
Original line number Diff line number Diff line
/*******************************************************************
 * This file is part of the Emulex Linux Device Driver for         *
 * Fibre Channel Host Bus Adapters.                                *
 * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term *
 * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term *
 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.     *
 * Copyright (C) 2009-2015 Emulex.  All rights reserved.           *
 * EMULEX and SLI are trademarks of Emulex.                        *
@@ -1977,7 +1977,7 @@ lpfc_sli4_bsg_set_loopback_mode(struct lpfc_hba *phba, int mode,
static int
lpfc_sli4_diag_fcport_reg_setup(struct lpfc_hba *phba)
{
	if (phba->pport->fc_flag & FC_VFI_REGISTERED) {
	if (test_bit(FC_VFI_REGISTERED, &phba->pport->fc_flag)) {
		lpfc_printf_log(phba, KERN_WARNING, LOG_LIBDFC,
				"3136 Port still had vfi registered: "
				"mydid:x%x, fcfi:%d, vfi:%d, vpi:%d\n",
@@ -3448,7 +3448,7 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba,
	case MBX_RUN_DIAGS:
	case MBX_RESTART:
	case MBX_SET_MASK:
		if (!(vport->fc_flag & FC_OFFLINE_MODE)) {
		if (!test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) {
			lpfc_printf_log(phba, KERN_WARNING, LOG_LIBDFC,
				"2743 Command 0x%x is illegal in on-line "
				"state\n",
@@ -4886,7 +4886,7 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct bsg_job *job,
	dd_data->context_un.mbox.outExtWLen = mbox_req->outExtWLen;
	job->dd_data = dd_data;

	if ((vport->fc_flag & FC_OFFLINE_MODE) ||
	if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag) ||
	    (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE))) {
		rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
		if (rc != MBX_SUCCESS) {
+66 −88

File changed.

Preview size limit exceeded, changes collapsed.

+6 −8
Original line number Diff line number Diff line
/*******************************************************************
 * This file is part of the Emulex Linux Device Driver for         *
 * Fibre Channel Host Bus Adapters.                                *
 * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term *
 * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term *
 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.  *
 * Copyright (C) 2007-2015 Emulex.  All rights reserved.           *
 * EMULEX and SLI are trademarks of Emulex.                        *
@@ -806,10 +806,10 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
{
	int len = 0;
	int i, iocnt, outio, cnt;
	struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
	struct lpfc_hba  *phba = vport->phba;
	struct lpfc_nodelist *ndlp;
	unsigned char *statep;
	unsigned long iflags;
	struct nvme_fc_local_port *localport;
	struct nvme_fc_remote_port *nrport = NULL;
	struct lpfc_nvme_rport *rport;
@@ -818,7 +818,7 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
	outio = 0;

	len += scnprintf(buf+len, size-len, "\nFCP Nodelist Entries ...\n");
	spin_lock_irq(shost->host_lock);
	spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags);
	list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
		iocnt = 0;
		if (!cnt) {
@@ -908,7 +908,7 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
					 ndlp->nlp_defer_did);
		len +=  scnprintf(buf+len, size-len, "\n");
	}
	spin_unlock_irq(shost->host_lock);
	spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags);

	len += scnprintf(buf + len, size - len,
			"\nOutstanding IO x%x\n",  outio);
@@ -940,8 +940,6 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
	if (!localport)
		goto out_exit;

	spin_lock_irq(shost->host_lock);

	/* Port state is only one of two values for now. */
	if (localport->port_id)
		statep = "ONLINE";
@@ -953,6 +951,7 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
			localport->port_id, statep);

	len += scnprintf(buf + len, size - len, "\tRport List:\n");
	spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags);
	list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
		/* local short-hand pointer. */
		spin_lock(&ndlp->lock);
@@ -1006,8 +1005,7 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
		/* Terminate the string. */
		len +=  scnprintf(buf + len, size - len, "\n");
	}

	spin_unlock_irq(shost->host_lock);
	spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags);
 out_exit:
	return len;
}
Loading