Skip to content

Commit 18f7fe4

Browse files
Justin Teemartinkpetersen
authored andcommitted
scsi: lpfc: Define lpfc_nodelist type for ctx_ndlp ptr
In LPFC_MBOXQ_t data structure, the ctx_ndlp ptr shouldn't be defined as a generic void *ptr. It is named ctx_ndlp and it should only be used as an lpfc_nodelist *ptr. Due to the void* declaration, there have been abuses of ctx_ndlp for things not related to ndlp. So, set the ptr type for *ctx_ndlp as lpfc_nodelist. Remove all type casts on ctx_ndlp because it is no longer a void *ptr. Convert the abuse of ctx_ndlp for things not related to ndlps to use the void *context3 ptr. 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 f733a76 commit 18f7fe4

File tree

7 files changed

+36
-39
lines changed

7 files changed

+36
-39
lines changed

drivers/scsi/lpfc/lpfc_bsg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,7 +3376,7 @@ lpfc_bsg_issue_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
33763376
unsigned long flags;
33773377
uint8_t *pmb, *pmb_buf;
33783378

3379-
dd_data = pmboxq->ctx_ndlp;
3379+
dd_data = pmboxq->context3;
33803380

33813381
/*
33823382
* The outgoing buffer is readily referred from the dma buffer,
@@ -4875,7 +4875,7 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct bsg_job *job,
48754875
pmboxq->mbox_cmpl = lpfc_bsg_issue_mbox_cmpl;
48764876

48774877
/* setup context field to pass wait_queue pointer to wake function */
4878-
pmboxq->ctx_ndlp = dd_data;
4878+
pmboxq->context3 = dd_data;
48794879
dd_data->type = TYPE_MBOX;
48804880
dd_data->set_job = job;
48814881
dd_data->context_un.mbox.pmboxq = pmboxq;

drivers/scsi/lpfc/lpfc_els.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7238,7 +7238,7 @@ lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context)
72387238
goto rdp_fail;
72397239
mbox->vport = rdp_context->ndlp->vport;
72407240
mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a0;
7241-
mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
7241+
mbox->context3 = (struct lpfc_rdp_context *)rdp_context;
72427242
rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
72437243
if (rc == MBX_NOT_FINISHED) {
72447244
lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
@@ -7298,7 +7298,6 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba,
72987298
mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys);
72997299
}
73007300
mbox->vport = phba->pport;
7301-
mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
73027301

73037302
rc = lpfc_sli_issue_mbox_wait(phba, mbox, 30);
73047303
if (rc == MBX_NOT_FINISHED) {
@@ -7358,7 +7357,6 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba,
73587357
mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys);
73597358
}
73607359

7361-
mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
73627360
rc = lpfc_sli_issue_mbox_wait(phba, mbox, 30);
73637361
if (bf_get(lpfc_mqe_status, &mbox->u.mqe)) {
73647362
rc = 1;
@@ -7500,9 +7498,9 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
75007498
int rc;
75017499

75027500
mb = &pmb->u.mb;
7503-
lcb_context = (struct lpfc_lcb_context *)pmb->ctx_ndlp;
7501+
lcb_context = (struct lpfc_lcb_context *)pmb->context3;
75047502
ndlp = lcb_context->ndlp;
7505-
pmb->ctx_ndlp = NULL;
7503+
pmb->context3 = NULL;
75067504
pmb->ctx_buf = NULL;
75077505

75087506
shdr = (union lpfc_sli4_cfg_shdr *)
@@ -7642,7 +7640,7 @@ lpfc_sli4_set_beacon(struct lpfc_vport *vport,
76427640
lpfc_sli4_config(phba, mbox, LPFC_MBOX_SUBSYSTEM_COMMON,
76437641
LPFC_MBOX_OPCODE_SET_BEACON_CONFIG, len,
76447642
LPFC_SLI4_MBX_EMBED);
7645-
mbox->ctx_ndlp = (void *)lcb_context;
7643+
mbox->context3 = (void *)lcb_context;
76467644
mbox->vport = phba->pport;
76477645
mbox->mbox_cmpl = lpfc_els_lcb_rsp;
76487646
bf_set(lpfc_mbx_set_beacon_port_num, &mbox->u.mqe.un.beacon_config,

drivers/scsi/lpfc/lpfc_hbadisc.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3851,7 +3851,7 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
38513851
{
38523852
struct lpfc_vport *vport = pmb->vport;
38533853
struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
3854-
struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
3854+
struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
38553855

38563856
/* The driver calls the state machine with the pmb pointer
38573857
* but wants to make sure a stale ctx_buf isn't acted on.
@@ -4168,7 +4168,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
41684168
{
41694169
struct lpfc_vport *vport = pmb->vport;
41704170
MAILBOX_t *mb = &pmb->u.mb;
4171-
struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
4171+
struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
41724172

41734173
pmb->ctx_ndlp = NULL;
41744174

@@ -4306,7 +4306,7 @@ void
43064306
lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
43074307
{
43084308
MAILBOX_t *mb = &pmb->u.mb;
4309-
struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
4309+
struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
43104310
struct lpfc_vport *vport = pmb->vport;
43114311
int rc;
43124312

@@ -4430,7 +4430,7 @@ lpfc_mbx_cmpl_fc_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
44304430
{
44314431
struct lpfc_vport *vport = pmb->vport;
44324432
MAILBOX_t *mb = &pmb->u.mb;
4433-
struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
4433+
struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
44344434

44354435
pmb->ctx_ndlp = NULL;
44364436
if (mb->mbxStatus) {
@@ -5173,7 +5173,7 @@ lpfc_nlp_logo_unreg(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
51735173
struct lpfc_vport *vport = pmb->vport;
51745174
struct lpfc_nodelist *ndlp;
51755175

5176-
ndlp = (struct lpfc_nodelist *)(pmb->ctx_ndlp);
5176+
ndlp = pmb->ctx_ndlp;
51775177
if (!ndlp)
51785178
return;
51795179
lpfc_issue_els_logo(vport, ndlp, 0);
@@ -5495,7 +5495,7 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
54955495
if ((mb = phba->sli.mbox_active)) {
54965496
if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
54975497
!(mb->mbox_flag & LPFC_MBX_IMED_UNREG) &&
5498-
(ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
5498+
(ndlp == mb->ctx_ndlp)) {
54995499
mb->ctx_ndlp = NULL;
55005500
mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
55015501
}
@@ -5506,7 +5506,7 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
55065506
list_for_each_entry(mb, &phba->sli.mboxq_cmpl, list) {
55075507
if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) ||
55085508
(mb->mbox_flag & LPFC_MBX_IMED_UNREG) ||
5509-
(ndlp != (struct lpfc_nodelist *)mb->ctx_ndlp))
5509+
(ndlp != mb->ctx_ndlp))
55105510
continue;
55115511

55125512
mb->ctx_ndlp = NULL;
@@ -5516,7 +5516,7 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
55165516
list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
55175517
if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
55185518
!(mb->mbox_flag & LPFC_MBX_IMED_UNREG) &&
5519-
(ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
5519+
(ndlp == mb->ctx_ndlp)) {
55205520
list_del(&mb->list);
55215521
lpfc_mbox_rsrc_cleanup(phba, mb, MBOX_THD_LOCKED);
55225522

@@ -6356,7 +6356,7 @@ void
63566356
lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
63576357
{
63586358
MAILBOX_t *mb = &pmb->u.mb;
6359-
struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
6359+
struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
63606360
struct lpfc_vport *vport = pmb->vport;
63616361

63626362
pmb->ctx_ndlp = NULL;

drivers/scsi/lpfc/lpfc_mbox.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,7 +2367,7 @@ lpfc_mbx_cmpl_rdp_link_stat(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
23672367
MAILBOX_t *mb;
23682368
int rc = FAILURE;
23692369
struct lpfc_rdp_context *rdp_context =
2370-
(struct lpfc_rdp_context *)(mboxq->ctx_ndlp);
2370+
(struct lpfc_rdp_context *)(mboxq->context3);
23712371

23722372
mb = &mboxq->u.mb;
23732373
if (mb->mbxStatus)
@@ -2387,7 +2387,7 @@ lpfc_mbx_cmpl_rdp_page_a2(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
23872387
{
23882388
struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
23892389
struct lpfc_rdp_context *rdp_context =
2390-
(struct lpfc_rdp_context *)(mbox->ctx_ndlp);
2390+
(struct lpfc_rdp_context *)(mbox->context3);
23912391

23922392
if (bf_get(lpfc_mqe_status, &mbox->u.mqe))
23932393
goto error_mbox_free;
@@ -2401,7 +2401,7 @@ lpfc_mbx_cmpl_rdp_page_a2(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
24012401
/* Save the dma buffer for cleanup in the final completion. */
24022402
mbox->ctx_buf = mp;
24032403
mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_link_stat;
2404-
mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
2404+
mbox->context3 = (struct lpfc_rdp_context *)rdp_context;
24052405
if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) == MBX_NOT_FINISHED)
24062406
goto error_mbox_free;
24072407

@@ -2418,7 +2418,7 @@ lpfc_mbx_cmpl_rdp_page_a0(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
24182418
int rc;
24192419
struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(mbox->ctx_buf);
24202420
struct lpfc_rdp_context *rdp_context =
2421-
(struct lpfc_rdp_context *)(mbox->ctx_ndlp);
2421+
(struct lpfc_rdp_context *)(mbox->context3);
24222422

24232423
if (bf_get(lpfc_mqe_status, &mbox->u.mqe))
24242424
goto error;
@@ -2448,7 +2448,7 @@ lpfc_mbx_cmpl_rdp_page_a0(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
24482448
mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys);
24492449

24502450
mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a2;
2451-
mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
2451+
mbox->context3 = (struct lpfc_rdp_context *)rdp_context;
24522452
rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
24532453
if (rc == MBX_NOT_FINISHED)
24542454
goto error;

drivers/scsi/lpfc/lpfc_nportdisc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ lpfc_mbx_cmpl_resume_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
683683
uint32_t cmd;
684684

685685
elsiocb = (struct lpfc_iocbq *)mboxq->ctx_buf;
686-
ndlp = (struct lpfc_nodelist *)mboxq->ctx_ndlp;
686+
ndlp = mboxq->ctx_ndlp;
687687
vport = mboxq->vport;
688688
cmd = elsiocb->drvrTimeout;
689689

@@ -1875,7 +1875,7 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport,
18751875
/* cleanup any ndlp on mbox q waiting for reglogin cmpl */
18761876
if ((mb = phba->sli.mbox_active)) {
18771877
if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
1878-
(ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
1878+
(ndlp == mb->ctx_ndlp)) {
18791879
ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
18801880
lpfc_nlp_put(ndlp);
18811881
mb->ctx_ndlp = NULL;
@@ -1886,7 +1886,7 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport,
18861886
spin_lock_irq(&phba->hbalock);
18871887
list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
18881888
if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
1889-
(ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
1889+
(ndlp == mb->ctx_ndlp)) {
18901890
ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
18911891
lpfc_nlp_put(ndlp);
18921892
list_del(&mb->list);

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,12 +2914,12 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
29142914
}
29152915

29162916
if (pmb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
2917-
ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
2917+
ndlp = pmb->ctx_ndlp;
29182918
lpfc_nlp_put(ndlp);
29192919
}
29202920

29212921
if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) {
2922-
ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
2922+
ndlp = pmb->ctx_ndlp;
29232923

29242924
/* Check to see if there are any deferred events to process */
29252925
if (ndlp) {
@@ -2952,7 +2952,7 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
29522952

29532953
/* This nlp_put pairs with lpfc_sli4_resume_rpi */
29542954
if (pmb->u.mb.mbxCommand == MBX_RESUME_RPI) {
2955-
ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
2955+
ndlp = pmb->ctx_ndlp;
29562956
lpfc_nlp_put(ndlp);
29572957
}
29582958

@@ -13832,8 +13832,7 @@ lpfc_sli_sp_intr_handler(int irq, void *dev_id)
1383213832
if (!pmbox->mbxStatus) {
1383313833
mp = (struct lpfc_dmabuf *)
1383413834
(pmb->ctx_buf);
13835-
ndlp = (struct lpfc_nodelist *)
13836-
pmb->ctx_ndlp;
13835+
ndlp = pmb->ctx_ndlp;
1383713836

1383813837
/* Reg_LOGIN of dflt RPI was
1383913838
* successful. new lets get
@@ -14341,7 +14340,7 @@ lpfc_sli4_sp_handle_mbox_event(struct lpfc_hba *phba, struct lpfc_mcqe *mcqe)
1434114340
pmbox->un.varWords[0], 0);
1434214341
if (mcqe_status == MB_CQE_STATUS_SUCCESS) {
1434314342
mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
14344-
ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
14343+
ndlp = pmb->ctx_ndlp;
1434514344

1434614345
/* Reg_LOGIN of dflt RPI was successful. Mark the
1434714346
* node as having an UNREG_LOGIN in progress to stop
@@ -21035,7 +21034,7 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport)
2103521034
(mb->u.mb.mbxCommand == MBX_REG_VPI))
2103621035
mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
2103721036
if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
21038-
act_mbx_ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp;
21037+
act_mbx_ndlp = mb->ctx_ndlp;
2103921038

2104021039
/* This reference is local to this routine. The
2104121040
* reference is removed at routine exit.
@@ -21064,7 +21063,7 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport)
2106421063

2106521064
mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
2106621065
if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
21067-
ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp;
21066+
ndlp = mb->ctx_ndlp;
2106821067
/* Unregister the RPI when mailbox complete */
2106921068
mb->mbox_flag |= LPFC_MBX_IMED_UNREG;
2107021069
restart_loop = 1;
@@ -21084,7 +21083,7 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport)
2108421083
while (!list_empty(&mbox_cmd_list)) {
2108521084
list_remove_head(&mbox_cmd_list, mb, LPFC_MBOXQ_t, list);
2108621085
if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
21087-
ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp;
21086+
ndlp = mb->ctx_ndlp;
2108821087
mb->ctx_ndlp = NULL;
2108921088
if (ndlp) {
2109021089
spin_lock(&ndlp->lock);

drivers/scsi/lpfc/lpfc_sli.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ typedef struct lpfcMboxq {
182182
struct lpfc_mqe mqe;
183183
} u;
184184
struct lpfc_vport *vport; /* virtual port pointer */
185-
void *ctx_ndlp; /* an lpfc_nodelist pointer */
186-
void *ctx_buf; /* an lpfc_dmabuf pointer */
187-
void *context3; /* a generic pointer. Code must
188-
* accommodate the actual datatype.
189-
*/
185+
struct lpfc_nodelist *ctx_ndlp; /* caller ndlp pointer */
186+
void *ctx_buf; /* caller buffer information */
187+
void *context3; /* a generic pointer. Code must
188+
* accommodate the actual datatype.
189+
*/
190190

191191
void (*mbox_cmpl) (struct lpfc_hba *, struct lpfcMboxq *);
192192
uint8_t mbox_flag;

0 commit comments

Comments
 (0)