Skip to content

Commit 92b99f1

Browse files
Justin Teemartinkpetersen
authored andcommitted
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: Justin Tee <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 32566a6 commit 92b99f1

File tree

13 files changed

+476
-661
lines changed

13 files changed

+476
-661
lines changed

drivers/scsi/lpfc/lpfc_bsg.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,11 @@ lpfc_bsg_send_mgmt_cmd(struct bsg_job *job)
398398
/* in case no data is transferred */
399399
bsg_reply->reply_payload_rcv_len = 0;
400400

401-
if (ndlp->nlp_flag & NLP_ELS_SND_MASK)
401+
if (test_bit(NLP_PLOGI_SND, &ndlp->nlp_flag) ||
402+
test_bit(NLP_PRLI_SND, &ndlp->nlp_flag) ||
403+
test_bit(NLP_ADISC_SND, &ndlp->nlp_flag) ||
404+
test_bit(NLP_LOGO_SND, &ndlp->nlp_flag) ||
405+
test_bit(NLP_RNID_SND, &ndlp->nlp_flag))
402406
return -ENODEV;
403407

404408
/* allocate our bsg tracking structure */

drivers/scsi/lpfc/lpfc_ct.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ lpfc_prep_node_fc4type(struct lpfc_vport *vport, uint32_t Did, uint8_t fc4_type)
735735

736736
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
737737
"0238 Process x%06x NameServer Rsp "
738-
"Data: x%x x%x x%x x%lx x%x\n", Did,
738+
"Data: x%lx x%x x%x x%lx x%x\n", Did,
739739
ndlp->nlp_flag, ndlp->nlp_fc4_type,
740740
ndlp->nlp_state, vport->fc_flag,
741741
vport->fc_rscn_id_cnt);
@@ -744,7 +744,7 @@ lpfc_prep_node_fc4type(struct lpfc_vport *vport, uint32_t Did, uint8_t fc4_type)
744744
* state of ndlp hit devloss, change state to
745745
* allow rediscovery.
746746
*/
747-
if (ndlp->nlp_flag & NLP_NPR_2B_DISC &&
747+
if (test_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag) &&
748748
ndlp->nlp_state == NLP_STE_UNUSED_NODE) {
749749
lpfc_nlp_set_state(vport, ndlp,
750750
NLP_STE_NPR_NODE);
@@ -832,12 +832,10 @@ lpfc_ns_rsp_audit_did(struct lpfc_vport *vport, uint32_t Did, uint8_t fc4_type)
832832
if (ndlp->nlp_type != NLP_NVME_INITIATOR ||
833833
ndlp->nlp_state != NLP_STE_UNMAPPED_NODE)
834834
continue;
835-
spin_lock_irq(&ndlp->lock);
836835
if (ndlp->nlp_DID == Did)
837-
ndlp->nlp_flag &= ~NLP_NVMET_RECOV;
836+
clear_bit(NLP_NVMET_RECOV, &ndlp->nlp_flag);
838837
else
839-
ndlp->nlp_flag |= NLP_NVMET_RECOV;
840-
spin_unlock_irq(&ndlp->lock);
838+
set_bit(NLP_NVMET_RECOV, &ndlp->nlp_flag);
841839
}
842840
}
843841
}
@@ -894,13 +892,11 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint8_t fc4_type,
894892
*/
895893
if (vport->phba->nvmet_support) {
896894
list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
897-
if (!(ndlp->nlp_flag & NLP_NVMET_RECOV))
895+
if (!test_bit(NLP_NVMET_RECOV, &ndlp->nlp_flag))
898896
continue;
899897
lpfc_disc_state_machine(vport, ndlp, NULL,
900898
NLP_EVT_DEVICE_RECOVERY);
901-
spin_lock_irq(&ndlp->lock);
902-
ndlp->nlp_flag &= ~NLP_NVMET_RECOV;
903-
spin_unlock_irq(&ndlp->lock);
899+
clear_bit(NLP_NVMET_RECOV, &ndlp->nlp_flag);
904900
}
905901
}
906902

@@ -1440,7 +1436,7 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
14401436
if (ndlp) {
14411437
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
14421438
"0242 Process x%x GFF "
1443-
"NameServer Rsp Data: x%x x%lx x%x\n",
1439+
"NameServer Rsp Data: x%lx x%lx x%x\n",
14441440
did, ndlp->nlp_flag, vport->fc_flag,
14451441
vport->fc_rscn_id_cnt);
14461442
} else {

drivers/scsi/lpfc/lpfc_debugfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,8 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
870870
wwn_to_u64(ndlp->nlp_nodename.u.wwn));
871871
len += scnprintf(buf+len, size-len, "RPI:x%04x ",
872872
ndlp->nlp_rpi);
873-
len += scnprintf(buf+len, size-len, "flag:x%08x ",
874-
ndlp->nlp_flag);
873+
len += scnprintf(buf+len, size-len, "flag:x%08lx ",
874+
ndlp->nlp_flag);
875875
if (!ndlp->nlp_type)
876876
len += scnprintf(buf+len, size-len, "UNKNOWN_TYPE ");
877877
if (ndlp->nlp_type & NLP_FC_NODE)

drivers/scsi/lpfc/lpfc_disc.h

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct lpfc_nodelist {
102102

103103
spinlock_t lock; /* Node management lock */
104104

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

185-
/* Defines for nlp_flag (uint32) */
186-
#define NLP_IGNR_REG_CMPL 0x00000001 /* Rcvd rscn before we cmpl reg login */
187-
#define NLP_REG_LOGIN_SEND 0x00000002 /* sent reglogin to adapter */
188-
#define NLP_SUPPRESS_RSP 0x00000010 /* Remote NPort supports suppress rsp */
189-
#define NLP_PLOGI_SND 0x00000020 /* sent PLOGI request for this entry */
190-
#define NLP_PRLI_SND 0x00000040 /* sent PRLI request for this entry */
191-
#define NLP_ADISC_SND 0x00000080 /* sent ADISC request for this entry */
192-
#define NLP_LOGO_SND 0x00000100 /* sent LOGO request for this entry */
193-
#define NLP_RNID_SND 0x00000400 /* sent RNID request for this entry */
194-
#define NLP_ELS_SND_MASK 0x000007e0 /* sent ELS request for this entry */
195-
#define NLP_NVMET_RECOV 0x00001000 /* NVMET auditing node for recovery. */
196-
#define NLP_UNREG_INP 0x00008000 /* UNREG_RPI cmd is in progress */
197-
#define NLP_DROPPED 0x00010000 /* Init ref count has been dropped */
198-
#define NLP_DELAY_TMO 0x00020000 /* delay timeout is running for node */
199-
#define NLP_NPR_2B_DISC 0x00040000 /* node is included in num_disc_nodes */
200-
#define NLP_RCV_PLOGI 0x00080000 /* Rcv'ed PLOGI from remote system */
201-
#define NLP_LOGO_ACC 0x00100000 /* Process LOGO after ACC completes */
202-
#define NLP_TGT_NO_SCSIID 0x00200000 /* good PRLI but no binding for scsid */
203-
#define NLP_ISSUE_LOGO 0x00400000 /* waiting to issue a LOGO */
204-
#define NLP_IN_DEV_LOSS 0x00800000 /* devloss in progress */
205-
#define NLP_ACC_REGLOGIN 0x01000000 /* Issue Reg Login after successful
185+
/* nlp_flag mask bits */
186+
enum lpfc_nlp_flag {
187+
NLP_IGNR_REG_CMPL = 0, /* Rcvd rscn before we cmpl reg login */
188+
NLP_REG_LOGIN_SEND = 1, /* sent reglogin to adapter */
189+
NLP_SUPPRESS_RSP = 4, /* Remote NPort supports suppress rsp */
190+
NLP_PLOGI_SND = 5, /* sent PLOGI request for this entry */
191+
NLP_PRLI_SND = 6, /* sent PRLI request for this entry */
192+
NLP_ADISC_SND = 7, /* sent ADISC request for this entry */
193+
NLP_LOGO_SND = 8, /* sent LOGO request for this entry */
194+
NLP_RNID_SND = 10, /* sent RNID request for this entry */
195+
NLP_NVMET_RECOV = 12, /* NVMET auditing node for recovery. */
196+
NLP_UNREG_INP = 15, /* UNREG_RPI cmd is in progress */
197+
NLP_DROPPED = 16, /* Init ref count has been dropped */
198+
NLP_DELAY_TMO = 17, /* delay timeout is running for node */
199+
NLP_NPR_2B_DISC = 18, /* node is included in num_disc_nodes */
200+
NLP_RCV_PLOGI = 19, /* Rcv'ed PLOGI from remote system */
201+
NLP_LOGO_ACC = 20, /* Process LOGO after ACC completes */
202+
NLP_TGT_NO_SCSIID = 21, /* good PRLI but no binding for scsid */
203+
NLP_ISSUE_LOGO = 22, /* waiting to issue a LOGO */
204+
NLP_IN_DEV_LOSS = 23, /* devloss in progress */
205+
NLP_ACC_REGLOGIN = 24, /* Issue Reg Login after successful
206206
ACC */
207-
#define NLP_NPR_ADISC 0x02000000 /* Issue ADISC when dq'ed from
207+
NLP_NPR_ADISC = 25, /* Issue ADISC when dq'ed from
208208
NPR list */
209-
#define NLP_RM_DFLT_RPI 0x04000000 /* need to remove leftover dflt RPI */
210-
#define NLP_NODEV_REMOVE 0x08000000 /* Defer removal till discovery ends */
211-
#define NLP_TARGET_REMOVE 0x10000000 /* Target remove in process */
212-
#define NLP_SC_REQ 0x20000000 /* Target requires authentication */
213-
#define NLP_FIRSTBURST 0x40000000 /* Target supports FirstBurst */
214-
#define NLP_RPI_REGISTERED 0x80000000 /* nlp_rpi is valid */
209+
NLP_RM_DFLT_RPI = 26, /* need to remove leftover dflt RPI */
210+
NLP_NODEV_REMOVE = 27, /* Defer removal till discovery ends */
211+
NLP_TARGET_REMOVE = 28, /* Target remove in process */
212+
NLP_SC_REQ = 29, /* Target requires authentication */
213+
NLP_FIRSTBURST = 30, /* Target supports FirstBurst */
214+
NLP_RPI_REGISTERED = 31 /* nlp_rpi is valid */
215+
};
215216

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

0 commit comments

Comments
 (0)