Commit 92b99f1a authored by Justin Tee's avatar Justin Tee Committed by Martin K. Petersen
Browse files

scsi: lpfc: Change lpfc_nodelist nlp_flag member into a bitmask



In attempt to reduce the amount of unnecessary ndlp->lock acquisitions
in the lpfc driver, change nlpa_flag into an unsigned long bitmask and
use clear_bit/test_bit bitwise atomic APIs instead of reliance on
ndlp->lock for synchronization.

Signed-off-by: default avatarJustin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20241031223219.152342-10-justintee8345@gmail.com


Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 32566a6f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -398,7 +398,11 @@ lpfc_bsg_send_mgmt_cmd(struct bsg_job *job)
	/* in case no data is transferred */
	bsg_reply->reply_payload_rcv_len = 0;

	if (ndlp->nlp_flag & NLP_ELS_SND_MASK)
	if (test_bit(NLP_PLOGI_SND, &ndlp->nlp_flag) ||
	    test_bit(NLP_PRLI_SND, &ndlp->nlp_flag) ||
	    test_bit(NLP_ADISC_SND, &ndlp->nlp_flag) ||
	    test_bit(NLP_LOGO_SND, &ndlp->nlp_flag) ||
	    test_bit(NLP_RNID_SND, &ndlp->nlp_flag))
		return -ENODEV;

	/* allocate our bsg tracking structure */
+7 −11
Original line number Diff line number Diff line
@@ -735,7 +735,7 @@ lpfc_prep_node_fc4type(struct lpfc_vport *vport, uint32_t Did, uint8_t fc4_type)

			lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
					 "0238 Process x%06x NameServer Rsp "
					 "Data: x%x x%x x%x x%lx x%x\n", Did,
					 "Data: x%lx x%x x%x x%lx x%x\n", Did,
					 ndlp->nlp_flag, ndlp->nlp_fc4_type,
					 ndlp->nlp_state, vport->fc_flag,
					 vport->fc_rscn_id_cnt);
@@ -744,7 +744,7 @@ lpfc_prep_node_fc4type(struct lpfc_vport *vport, uint32_t Did, uint8_t fc4_type)
			 * state of ndlp hit devloss, change state to
			 * allow rediscovery.
			 */
			if (ndlp->nlp_flag & NLP_NPR_2B_DISC &&
			if (test_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag) &&
			    ndlp->nlp_state == NLP_STE_UNUSED_NODE) {
				lpfc_nlp_set_state(vport, ndlp,
						   NLP_STE_NPR_NODE);
@@ -832,12 +832,10 @@ lpfc_ns_rsp_audit_did(struct lpfc_vport *vport, uint32_t Did, uint8_t fc4_type)
			if (ndlp->nlp_type != NLP_NVME_INITIATOR ||
			    ndlp->nlp_state != NLP_STE_UNMAPPED_NODE)
				continue;
			spin_lock_irq(&ndlp->lock);
			if (ndlp->nlp_DID == Did)
				ndlp->nlp_flag &= ~NLP_NVMET_RECOV;
				clear_bit(NLP_NVMET_RECOV, &ndlp->nlp_flag);
			else
				ndlp->nlp_flag |= NLP_NVMET_RECOV;
			spin_unlock_irq(&ndlp->lock);
				set_bit(NLP_NVMET_RECOV, &ndlp->nlp_flag);
		}
	}
}
@@ -894,13 +892,11 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint8_t fc4_type,
	 */
	if (vport->phba->nvmet_support) {
		list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
			if (!(ndlp->nlp_flag & NLP_NVMET_RECOV))
			if (!test_bit(NLP_NVMET_RECOV, &ndlp->nlp_flag))
				continue;
			lpfc_disc_state_machine(vport, ndlp, NULL,
						NLP_EVT_DEVICE_RECOVERY);
			spin_lock_irq(&ndlp->lock);
			ndlp->nlp_flag &= ~NLP_NVMET_RECOV;
			spin_unlock_irq(&ndlp->lock);
			clear_bit(NLP_NVMET_RECOV, &ndlp->nlp_flag);
		}
	}

@@ -1440,7 +1436,7 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
	if (ndlp) {
		lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
				 "0242 Process x%x GFF "
				 "NameServer Rsp Data: x%x x%lx x%x\n",
				 "NameServer Rsp Data: x%lx x%lx x%x\n",
				 did, ndlp->nlp_flag, vport->fc_flag,
				 vport->fc_rscn_id_cnt);
	} else {
+2 −2
Original line number Diff line number Diff line
@@ -870,7 +870,7 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
				wwn_to_u64(ndlp->nlp_nodename.u.wwn));
		len += scnprintf(buf+len, size-len, "RPI:x%04x ",
				 ndlp->nlp_rpi);
		len +=  scnprintf(buf+len, size-len, "flag:x%08x ",
		len += scnprintf(buf+len, size-len, "flag:x%08lx ",
				 ndlp->nlp_flag);
		if (!ndlp->nlp_type)
			len += scnprintf(buf+len, size-len, "UNKNOWN_TYPE ");
+30 −29
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ struct lpfc_nodelist {

	spinlock_t	lock;			/* Node management lock */

	uint32_t         nlp_flag;		/* entry flags */
	unsigned long    nlp_flag;		/* entry flags */
	uint32_t         nlp_DID;		/* FC D_ID of entry */
	uint32_t         nlp_last_elscmd;	/* Last ELS cmd sent */
	uint16_t         nlp_type;
@@ -182,36 +182,37 @@ struct lpfc_node_rrq {
#define lpfc_ndlp_check_qdepth(phba, ndlp) \
	(ndlp->cmd_qdepth < phba->sli4_hba.max_cfg_param.max_xri)

/* Defines for nlp_flag (uint32) */
#define NLP_IGNR_REG_CMPL  0x00000001 /* Rcvd rscn before we cmpl reg login */
#define NLP_REG_LOGIN_SEND 0x00000002   /* sent reglogin to adapter */
#define NLP_SUPPRESS_RSP   0x00000010	/* Remote NPort supports suppress rsp */
#define NLP_PLOGI_SND      0x00000020	/* sent PLOGI request for this entry */
#define NLP_PRLI_SND       0x00000040	/* sent PRLI request for this entry */
#define NLP_ADISC_SND      0x00000080	/* sent ADISC request for this entry */
#define NLP_LOGO_SND       0x00000100	/* sent LOGO request for this entry */
#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_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 */
#define NLP_NPR_2B_DISC    0x00040000	/* node is included in num_disc_nodes */
#define NLP_RCV_PLOGI      0x00080000	/* Rcv'ed PLOGI from remote system */
#define NLP_LOGO_ACC       0x00100000	/* Process LOGO after ACC completes */
#define NLP_TGT_NO_SCSIID  0x00200000	/* good PRLI but no binding for scsid */
#define NLP_ISSUE_LOGO     0x00400000	/* waiting to issue a LOGO */
#define NLP_IN_DEV_LOSS    0x00800000	/* devloss in progress */
#define NLP_ACC_REGLOGIN   0x01000000	/* Issue Reg Login after successful
/* nlp_flag mask bits */
enum lpfc_nlp_flag {
	NLP_IGNR_REG_CMPL  = 0,         /* Rcvd rscn before we cmpl reg login */
	NLP_REG_LOGIN_SEND = 1,         /* sent reglogin to adapter */
	NLP_SUPPRESS_RSP   = 4,         /* Remote NPort supports suppress rsp */
	NLP_PLOGI_SND      = 5,         /* sent PLOGI request for this entry */
	NLP_PRLI_SND       = 6,         /* sent PRLI request for this entry */
	NLP_ADISC_SND      = 7,         /* sent ADISC request for this entry */
	NLP_LOGO_SND       = 8,         /* sent LOGO request for this entry */
	NLP_RNID_SND       = 10,        /* sent RNID request for this entry */
	NLP_NVMET_RECOV    = 12,        /* NVMET auditing node for recovery. */
	NLP_UNREG_INP      = 15,        /* UNREG_RPI cmd is in progress */
	NLP_DROPPED        = 16,        /* Init ref count has been dropped */
	NLP_DELAY_TMO      = 17,        /* delay timeout is running for node */
	NLP_NPR_2B_DISC    = 18,        /* node is included in num_disc_nodes */
	NLP_RCV_PLOGI      = 19,        /* Rcv'ed PLOGI from remote system */
	NLP_LOGO_ACC       = 20,        /* Process LOGO after ACC completes */
	NLP_TGT_NO_SCSIID  = 21,        /* good PRLI but no binding for scsid */
	NLP_ISSUE_LOGO     = 22,        /* waiting to issue a LOGO */
	NLP_IN_DEV_LOSS    = 23,        /* devloss in progress */
	NLP_ACC_REGLOGIN   = 24,        /* Issue Reg Login after successful
					   ACC */
#define NLP_NPR_ADISC      0x02000000	/* Issue ADISC when dq'ed from
	NLP_NPR_ADISC      = 25,        /* Issue ADISC when dq'ed from
					   NPR list */
#define NLP_RM_DFLT_RPI    0x04000000	/* need to remove leftover dflt RPI */
#define NLP_NODEV_REMOVE   0x08000000	/* Defer removal till discovery ends */
#define NLP_TARGET_REMOVE  0x10000000   /* Target remove in process */
#define NLP_SC_REQ         0x20000000	/* Target requires authentication */
#define NLP_FIRSTBURST     0x40000000	/* Target supports FirstBurst */
#define NLP_RPI_REGISTERED 0x80000000	/* nlp_rpi is valid */
	NLP_RM_DFLT_RPI    = 26,        /* need to remove leftover dflt RPI */
	NLP_NODEV_REMOVE   = 27,        /* Defer removal till discovery ends */
	NLP_TARGET_REMOVE  = 28,        /* Target remove in process */
	NLP_SC_REQ         = 29,        /* Target requires authentication */
	NLP_FIRSTBURST     = 30,        /* Target supports FirstBurst */
	NLP_RPI_REGISTERED = 31         /* nlp_rpi is valid */
};

/* There are 4 different double linked lists nodelist entries can reside on.
 * The Port Login (PLOGI) list and Address Discovery (ADISC) list are used
+168 −237

File changed.

Preview size limit exceeded, changes collapsed.

Loading