Introduce functionality for NVMe initiator
Subsystems (2)
Karan Tilak Kumar
maintainerv6 cover Introduce functionality for NVMe initiator
Hi Martin, reviewers,
This series adds functionality for NVMe initiator to the fnic driver.
The changes enable the fnic driver to act as an NVMe initiator over Fibre Channel (FC-NVMe), allowing the host to discover and communicate with NVMe targets using the existing fnic infrastructure. The patches prepare the driver for full FC-NVMe initiator operation while maintaining existing SCSI/FC functionality.
These are some of the salient patches:
o. Make fnic debug logging usable by SCSI and NVMe initiator roles. o. Use fnic instance numbers for non-SCSI-facing identifiers. o. Decode firmware roles for FCP, NVMe, and unsupported targets. o. Advertise NVMe initiator service parameters during FC discovery. o. Add FDLS role handling for NVMe initiator discovery flows. o. Add the NVMe/FC transport path and port registration. o. Route completions, resets, and LS frames by initiator role. o. Add NVMe LS timeouts, statistics, and debugfs state reporting.
Even though the patches have been made into a series, some patches are heavier than others. But, every effort has been made to keep the purpose of each patch as a single-purpose, and to compile cleanly. All the individual patches compile cleanly. The compiler used is GCC 14.2.
This patch set has been tested as a whole. Therefore, the tested-by fields have been added only to one patch in the set.
I've refrained from adding tested-by to most of the patches, so as to not mislead the reviewer/reader.
A brief note on the unit tests:
o. Configure multipathing, and run link flaps on single link. IOs drop
briefly, but pick up as expected.
o. Configure multipathing, and run link flaps on two links, with a 30
second delay in between. IOs drop briefly, but pick up as expected.
o. Repeat the above tests with 1 queue and 64 queues.
o. Perform tests with Netapp and Pure targets.
All tests were successful.
This set of patches was reviewed before submitting upstream, and the following review comments were incorporated.
Incorporate review comments from Hannes Reinecke:
Decode target roles explicitly and report unsupported roles. Remove the empty line before the FLOGI completion else block. Add a short comment for the NVMe ERSP completion case.
Incorporate review comments from Lee Duncan:
Replace the NVMe LS OXID switch with a direct frame-type check. Rename the NVMe frame helper to follow fnic function naming style. Convert the NVMe opcode stats helper to a switch statement. Share NVMe completion stats accounting and compute duration once.
Changes between v1 and v2:
Incorporate review comments from Marco Crivellari:
Explicitly use WQ_PERCPU for the fnic completion workqueue.
Changes between v2 and v3:
Fix issues reported by kernel bot.
Add the active OXID to the tport timeout debug print. Guard NVMe I/O and LS request debug logs when tport is NULL. Validate ERSP response length before copying the response. Validate LS response frame and payload lengths before copying. Limit nvmef_info debugfs output to the allocated buffer.
Changes between v3 and v4:
Incorporate review comments from Sashiko:
Keep role strings private and const.
Clear NVMe SGL DMA address on map failure.
Drop fnic lock around NVMe tport registration.
Unlink unregistered NVMe tports before freeing them. Clear NVMe unload completion pointer on exit.
Take fnic lock before NVMe tport cleanup tag lookup. Clear NVMe tport delete completion pointer on unregister failure. Arm NVMe LS request timer before exposing the request. Free LS ABTS frame when send fails.
Reuse NVMe LS request cleanup for abort failure. Decrement NVMe completion wait queue counter when draining completions. Preserve jiffies wrap when computing NVMe abort stats.
Changes between v4 and v5:
Incorporate review comments from Sashiko:
Set NVMe wait timestamp before queueing completions Use async timer delete for NVMe LS responses Complete failed NVMe ITMF aborts
Track NVMe SGL DMA mapping state
Detach NVMe LS cleanup before callbacks Defer NVMe table frees until cleanup
Lock NVMe tport IO termination lookup Count NVMe ERSP completions as firmware completions Gate NVMe completions by initiator role Check cleaned buffers before dereferencing them Drain OXID reclaim state on reset
Avoid NVMe LS request send races
Arm NVMe LS abort timer after send succeeds Clean up NVMe debugfs on probe errors
Clarify that FC-NVMe PRLI must not set Establish Image Pair.
Changes between v5 and v6:
Synchronize the tport retry timer before remote-port delete completes. Avoid requeueing FDLS tport delete from the NVMe remote-port callback. Drop the unnecessary else after the tport delete timeout return. Name the tport cleanup retry limit instead of using a literal. Publish can-free before completion and set cleanup-pending on timeout. Incorporate review comments from Sashiko:
Flush NVMe completions after copy WQ cleanup Reset NVMe SGL state before each I/O
Claim tport I/O before aborting it
Synchronize LS response timer before done Preserve LS requests during abort start
Drain LS requests on rport unregister failure Defer tport free after rport timeout
Avoid extra PCI device reference for lport
Thanks,
Karan
Karan Tilak Kumar (13):
scsi: fnic: Make debug logging protocol independent
scsi: fnic: Use fnic_num for non-SCSI identifiers
scsi: fnic: Decode firmware role configuration
scsi: fnic: Advertise NVMe initiator service parameters
scsi: fnic: Add FDLS role handling for NVMe initiators
scsi: fnic: Add the NVMe/FC transport path
scsi: fnic: Route completions and resets by initiator role
scsi: fnic: Handle NVMe LS frames in FDLS
scsi: fnic: Send NVMe LS requests through FDLS
scsi: fnic: Abort timed-out NVMe LS requests
scsi: fnic: Track NVMe transport statistics
scsi: fnic: Expose NVMe transport state in debugfs
scsi: fnic: Bump up version number
drivers/scsi/fnic/Makefile | 1 + drivers/scsi/fnic/fcpio.h | 35 + drivers/scsi/fnic/fdls_disc.c | 978 +++++++------ drivers/scsi/fnic/fdls_fc.h | 7 + drivers/scsi/fnic/fip.c | 117 +- drivers/scsi/fnic/fip.h | 2 +- drivers/scsi/fnic/fnic.h | 104 +- drivers/scsi/fnic/fnic_debugfs.c | 99 +- drivers/scsi/fnic/fnic_fcs.c | 199 +-- drivers/scsi/fnic/fnic_fdls.h | 48 +- drivers/scsi/fnic/fnic_io.h | 24 +- drivers/scsi/fnic/fnic_isr.c | 28 +- drivers/scsi/fnic/fnic_main.c | 214 ++- drivers/scsi/fnic/fnic_nvme.c | 2268 ++++++++++++++++++++++++++++++ drivers/scsi/fnic/fnic_nvme.h | 214 +++ drivers/scsi/fnic/fnic_res.c | 31 +- drivers/scsi/fnic/fnic_res.h | 32 +- drivers/scsi/fnic/fnic_scsi.c | 251 ++-- drivers/scsi/fnic/fnic_stats.h | 28 + drivers/scsi/fnic/fnic_trace.c | 3 +- drivers/scsi/fnic/vnic_devcmd.h | 2 +- 21 files changed, 3906 insertions(+), 779 deletions(-) create mode 100644 drivers/scsi/fnic/fnic_nvme.c create mode 100644 drivers/scsi/fnic/fnic_nvme.h
Signature · 1 line
2.47.1
Karan Tilak Kumar
maintainerPATCH v6 1/13 scsi: fnic: Make debug logging protocol independent
Make the fnic debug macros take struct fnic instead of struct Scsi_Host so FCP and NVMe initiator roles can share the same logging interface.
Add fnic_printk() to route FCP initiator messages through shost_printk() and non-SCSI role messages through printk(). Add role and non-SCSI role messages through printk(). Add role predicates and separate FDLS, FIP, and NVMe logging masks.
Convert FCS, FIP, SCSI, ISR, and main debug call sites to pass the fnic instance directly, and keep FIP VLAN MAC descriptors skipped while reporting unexpected descriptor types.
---
Changes between v2 and v3:
Add the active OXID to the tport timeout debug print.
--- drivers/scsi/fnic/fdls_disc.c | 726 +++++++++++++++++----------------- drivers/scsi/fnic/fip.c | 117 +++--- drivers/scsi/fnic/fip.h | 2 +- drivers/scsi/fnic/fnic.h | 76 ++-- drivers/scsi/fnic/fnic_fcs.c | 126 +++--- drivers/scsi/fnic/fnic_isr.c | 28 +- drivers/scsi/fnic/fnic_main.c | 56 +-- drivers/scsi/fnic/fnic_scsi.c | 210 +++++----- 8 files changed, 676 insertions(+), 665 deletions(-)
drivers/scsi/fnic/fdls_disc.c +369 -357
@@ -104,7 +104,7 @@ uint8_t *fdls_alloc_frame(struct fnic_iport_s *iport) frame =mempool_alloc (fnic->frame_pool,GFP_ATOMIC );if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame" );return NULL ; }
@@ -136,7 +136,7 @@ uint16_t fdls_alloc_oxid(struct fnic_iport_s *iport, int oxid_frame_type,*/ idx =find_next_zero_bit (oxid_pool->bitmap,FNIC_OXID_POOL_SZ , oxid_pool->next_idx);if (idx ==FNIC_OXID_POOL_SZ ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Alloc oxid: all oxid slots are busy iport state:%d\n" , iport->state);return FNIC_UNASSIGNED_OXID ;
@@ -148,7 +148,7 @@ uint16_t fdls_alloc_oxid(struct fnic_iport_s *iport, int oxid_frame_type, oxid =FNIC_OXID_ENCODE (idx, oxid_frame_type); *active_oxid = oxid; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"alloc oxid: 0x%x, iport state: %d\n" , oxid, iport->state);return oxid;
@@ -169,7 +169,7 @@ static void fdls_free_oxid_idx(struct fnic_iport_s *iport, uint16_t oxid_idx)lockdep_assert_held (&fnic->fnic_lock); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"free oxid idx: 0x%x\n" , oxid_idx);WARN_ON (!test_and_clear_bit (oxid_idx, oxid_pool->bitmap));
@@ -194,7 +194,7 @@ void fdls_reclaim_oxid_handler(struct work_struct *work)struct reclaim_entry_s *reclaim_entry, *next;unsigned long delay_j, cur_jiffies; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Reclaim oxid callback\n" );spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags);
@@ -223,7 +223,7 @@ void fdls_reclaim_oxid_handler(struct work_struct *work) delay_j = reclaim_entry->expires - cur_jiffies;schedule_delayed_work (&oxid_pool->oxid_reclaim_work, delay_j); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Scheduling next callback at:%ld jiffies\n" , delay_j); }
@@ -266,7 +266,7 @@ void fdls_schedule_oxid_free(struct fnic_iport_s *iport, uint16_t *active_oxid)lockdep_assert_held (&fnic->fnic_lock); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Schedule oxid free. oxid: 0x%x\n" , *active_oxid); *active_oxid =FNIC_UNASSIGNED_OXID ;
@@ -275,7 +275,7 @@ void fdls_schedule_oxid_free(struct fnic_iport_s *iport, uint16_t *active_oxid) kzalloc_obj(struct reclaim_entry_s, GFP_ATOMIC);if (!reclaim_entry) { -FNIC_FCS_DBG (KERN_WARNING , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_WARNING , fnic,"Failed to allocate memory for reclaim struct for oxid idx: %d\n" , oxid_idx);
@@ -313,7 +313,7 @@ void fdls_schedule_oxid_free_retry_work(struct work_struct *work)for_each_set_bit (idx, oxid_pool->pending_schedule_free,FNIC_OXID_POOL_SZ ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Schedule oxid free. oxid idx: %d\n" , idx); reclaim_entry =kzalloc_obj (*reclaim_entry);
@@ -416,7 +416,7 @@ fdls_start_fabric_timer(struct fnic_iport_s *iport, int timeout)struct fnic *fnic = iport->fnic;if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport fcid: 0x%x: Canceling fabric disc timer\n" , iport->fcid);fnic_del_fabric_timer_sync (fnic);
@@ -429,7 +429,7 @@ fdls_start_fabric_timer(struct fnic_iport_s *iport, int timeout) fabric_tov = jiffies +msecs_to_jiffies (timeout);mod_timer (&iport->fabric.retry_timer,round_jiffies (fabric_tov)); iport->fabric.timer_pending =1 ; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"fabric timer is %d " , timeout); }
@@ -441,7 +441,7 @@ fdls_start_tport_timer(struct fnic_iport_s *iport,struct fnic *fnic = iport->fnic;if (tport->timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport fcid 0x%x: Canceling disc timer\n" , tport->fcid);fnic_del_tport_timer_sync (fnic, tport);
@@ -575,7 +575,7 @@ fdls_send_rscn_resp(struct fnic_iport_s *iport, frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send RSCN response" );return ; }
@@ -588,7 +588,7 @@ fdls_send_rscn_resp(struct fnic_iport_s *iport, oxid =FNIC_STD_GET_OX_ID (rscn_fchdr);FNIC_STD_SET_OX_ID (pels_acc->fchdr, oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send RSCN response with oxid: 0x%x" , iport->fcid, oxid);
@@ -608,7 +608,7 @@ fdls_send_logo_resp(struct fnic_iport_s *iport, frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send LOGO response" );return ; }
@@ -621,7 +621,7 @@ fdls_send_logo_resp(struct fnic_iport_s *iport, oxid =FNIC_STD_GET_OX_ID (req_fchdr);FNIC_STD_SET_OX_ID (plogo_resp->fchdr, oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send LOGO response with oxid: 0x%x" , iport->fcid, oxid);
@@ -642,7 +642,7 @@ fdls_send_tport_abts(struct fnic_iport_s *iport, frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send tport ABTS" );return ; }
@@ -665,7 +665,7 @@ fdls_send_tport_abts(struct fnic_iport_s *iport,FNIC_STD_SET_OX_ID (*ptport_abts, tport->active_oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send tport abts: tport->state: %d " , iport->fcid, tport->state);
@@ -687,7 +687,7 @@ static void fdls_send_fabric_abts(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send fabric ABTS" );return ; }
@@ -750,7 +750,7 @@ static void fdls_send_fabric_abts(struct fnic_iport_s *iport) oxid = iport->active_oxid_fabric_req;FNIC_STD_SET_OX_ID (*pfabric_abts, oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send fabric abts. iport->fabric.state: %d oxid: 0x%x" , iport->fcid, iport->fabric.state, oxid);
@@ -773,7 +773,7 @@ static uint8_t *fdls_alloc_init_fdmi_abts_frame(struct fnic_iport_s *iport, frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send FDMI ABTS" );return NULL ; }
@@ -802,7 +802,7 @@ static void fdls_send_fdmi_abts(struct fnic_iport_s *iport)if (frame ==NULL )return ; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send FDMI PLOGI abts. iport->fabric.state: %d oxid: 0x%x" , iport->fcid, iport->fabric.state, iport->active_oxid_fdmi_plogi);fnic_send_fcoe_frame (iport, frame, frame_size);
@@ -813,7 +813,7 @@ static void fdls_send_fdmi_abts(struct fnic_iport_s *iport)if (frame ==NULL )return ; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send FDMI RHBA abts. iport->fabric.state: %d oxid: 0x%x" , iport->fcid, iport->fabric.state, iport->active_oxid_fdmi_rhba);fnic_send_fcoe_frame (iport, frame, frame_size);
@@ -828,7 +828,7 @@ static void fdls_send_fdmi_abts(struct fnic_iport_s *iport)return ; } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send FDMI RPA abts. iport->fabric.state: %d oxid: 0x%x" , iport->fcid, iport->fabric.state, iport->active_oxid_fdmi_rpa);fnic_send_fcoe_frame (iport, frame, frame_size);
@@ -840,7 +840,7 @@ static void fdls_send_fdmi_abts(struct fnic_iport_s *iport)mod_timer (&iport->fabric.fdmi_timer,round_jiffies (fdmi_tov)); iport->fabric.fdmi_pending |=FDLS_FDMI_ABORT_PENDING ; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: iport->fabric.fdmi_pending: 0x%x" , iport->fcid, iport->fabric.fdmi_pending); }
@@ -856,7 +856,7 @@ static void fdls_send_fabric_flogi(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send FLOGI" ); iport->fabric.flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -885,7 +885,7 @@ static void fdls_send_fabric_flogi(struct fnic_iport_s *iport) &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate OXID to send FLOGI" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -894,7 +894,7 @@ static void fdls_send_fabric_flogi(struct fnic_iport_s *iport) }FNIC_STD_SET_OX_ID (pflogi->fchdr, oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send fabric FLOGI with oxid: 0x%x" , iport->fcid, oxid);
@@ -916,7 +916,7 @@ static void fdls_send_fabric_plogi(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send PLOGI" ); iport->fabric.flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -928,7 +928,7 @@ static void fdls_send_fabric_plogi(struct fnic_iport_s *iport) oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_FABRIC_PLOGI , &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate OXID to send fabric PLOGI" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -937,7 +937,7 @@ static void fdls_send_fabric_plogi(struct fnic_iport_s *iport) }FNIC_STD_SET_OX_ID (pplogi->fchdr, oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send fabric PLOGI with oxid: 0x%x" , iport->fcid, oxid);
@@ -962,7 +962,7 @@ static void fdls_send_fdmi_plogi(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send FDMI PLOGI" ); goto err_out; }
@@ -974,7 +974,7 @@ static void fdls_send_fdmi_plogi(struct fnic_iport_s *iport) &iport->active_oxid_fdmi_plogi);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate OXID to send FDMI PLOGI" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -985,7 +985,7 @@ static void fdls_send_fdmi_plogi(struct fnic_iport_s *iport)hton24 (d_id,FC_FID_MGMT_SERV );FNIC_STD_SET_D_ID (pplogi->fchdr, d_id); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send FDMI PLOGI with oxid: 0x%x" , iport->fcid, oxid);
@@ -1009,7 +1009,7 @@ static void fdls_send_rpn_id(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send RPN_ID" ); iport->fabric.flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -1036,7 +1036,7 @@ static void fdls_send_rpn_id(struct fnic_iport_s *iport) &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate OXID to send RPN_ID" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1045,7 +1045,7 @@ static void fdls_send_rpn_id(struct fnic_iport_s *iport) }FNIC_STD_SET_OX_ID (prpn_id->fchdr, oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send RPN ID with oxid: 0x%x" , iport->fcid, oxid);
@@ -1068,7 +1068,7 @@ static void fdls_send_scr(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send SCR" ); iport->fabric.flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -1090,7 +1090,7 @@ static void fdls_send_scr(struct fnic_iport_s *iport) oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_FABRIC_SCR , &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate OXID to send SCR" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1099,7 +1099,7 @@ static void fdls_send_scr(struct fnic_iport_s *iport) }FNIC_STD_SET_OX_ID (pscr->fchdr, oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send SCR with oxid: 0x%x" , iport->fcid, oxid);
@@ -1123,7 +1123,7 @@ static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send GPN FT" ); iport->fabric.flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -1148,7 +1148,7 @@ static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state) &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate OXID to send GPN FT" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1157,7 +1157,7 @@ static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state) }FNIC_STD_SET_OX_ID (pgpn_ft->fchdr, oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send GPN FT with oxid: 0x%x" , iport->fcid, oxid);
@@ -1183,7 +1183,7 @@ fdls_send_tgt_adisc(struct fnic_iport_s *iport, struct fnic_tport_s *tport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send TGT ADISC" ); tport->flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -1203,7 +1203,7 @@ fdls_send_tgt_adisc(struct fnic_iport_s *iport, struct fnic_tport_s *tport) oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_TGT_ADISC , &tport->active_oxid);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate OXID to send TGT ADISC" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1222,7 +1222,7 @@ fdls_send_tgt_adisc(struct fnic_iport_s *iport, struct fnic_tport_s *tport) padisc->els.adisc_cmd =ELS_ADISC ; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send ADISC to tgt fcid: 0x%x" , iport->fcid, tport->fcid);
@@ -1242,7 +1242,7 @@ bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport)if ((tport->state ==FDLS_TGT_STATE_OFFLINING ) || (tport->state ==FDLS_TGT_STATE_OFFLINE )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport fcid 0x%x: tport state is offlining/offline\n" , tport->fcid);return false;
@@ -1257,7 +1257,7 @@ bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport) tport->flags |=FNIC_FDLS_TPORT_TERMINATING ;if (tport->timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport fcid 0x%x: Canceling disc timer\n" , tport->fcid);fnic_del_tport_timer_sync (fnic, tport);
@@ -1272,9 +1272,9 @@ bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport) tport_del_evt = kzalloc_obj(struct fnic_tport_event_s, GFP_ATOMIC);if (!tport_del_evt) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, -"Failed to allocate memory for tport fcid: 0x%0x\n" , - tport->fcid); +FNIC_FCS_DBG (KERN_INFO , fnic, +"iport: 0x%x tport 0x%x: Failed to allocate memory\n" , + iport->fcid, tport->fcid);return false; } tport_del_evt->event =TGT_EV_RPORT_DEL ;
@@ -1282,9 +1282,9 @@ bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport)list_add_tail (&tport_del_evt->links, &fnic->tport_event_list);queue_work (fnic_event_queue, &fnic->tport_work); }else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, -"tport 0x%x not reg with scsi_transport. Freeing locally" , - tport->fcid); +FNIC_FCS_DBG (KERN_INFO , fnic, +"tport 0x%x not registered, freeing locally\n" , + tport->fcid);list_del (&tport->links);kfree (tport); }
@@ -1305,7 +1305,7 @@ fdls_send_tgt_plogi(struct fnic_iport_s *iport, struct fnic_tport_s *tport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send TGT PLOGI" ); tport->flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -1316,7 +1316,7 @@ fdls_send_tgt_plogi(struct fnic_iport_s *iport, struct fnic_tport_s *tport) oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_TGT_PLOGI , &tport->active_oxid);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate oxid to send PLOGI to fcid: 0x%x" , iport->fcid, tport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1330,7 +1330,7 @@ fdls_send_tgt_plogi(struct fnic_iport_s *iport, struct fnic_tport_s *tport)hton24 (d_id, tport->fcid);FNIC_STD_SET_D_ID (pplogi->fchdr, d_id); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send tgt PLOGI to tgt: 0x%x with oxid: 0x%x" , iport->fcid, tport->fcid, oxid);
@@ -1353,7 +1353,7 @@ fnic_fc_plogi_rsp_rdf(struct fnic_iport_s *iport,be16_to_cpu (plogi_rsp->els.fl_cssp[2 ].cp_rdfs) &FNIC_FC_C3_RDF ;struct fnic *fnic = iport->fnic; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"MFS: b2b_rdf_size: 0x%x spc3_rdf_size: 0x%x" , b2b_rdf_size, spc3_rdf_size);
@@ -1372,7 +1372,7 @@ static void fdls_send_register_fc4_types(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send RFT" );return ; }
@@ -1396,7 +1396,7 @@ static void fdls_send_register_fc4_types(struct fnic_iport_s *iport) &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate OXID to send RFT" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1404,15 +1404,18 @@ static void fdls_send_register_fc4_types(struct fnic_iport_s *iport) }FNIC_STD_SET_OX_ID (prft_id->fchdr, oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, -"0x%x: FDLS send RFT with oxid: 0x%x" , iport->fcid, - oxid); prft_id->rft_id.fr_fts.ff_type_map[0 ] =cpu_to_be32 (1 <<FC_TYPE_FCP ); prft_id->rft_id.fr_fts.ff_type_map[1 ] =cpu_to_be32 (1 << (FC_TYPE_CT %FC_NS_BPW )); +FNIC_FCS_DBG (KERN_INFO , fnic, +"0x%x: FDLS send RFT 0x%08x 0x%08x 0x%08x with oxid: 0x%x" , + iport->fcid, prft_id->rft_id.fr_fts.ff_type_map[0 ], + prft_id->rft_id.fr_fts.ff_type_map[1 ], + prft_id->rft_id.fr_fts.ff_type_map[2 ], + oxid);fnic_send_fcoe_frame (iport, frame, frame_size);
@@ -1432,7 +1435,7 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send RFF" );return ; }
@@ -1458,7 +1461,7 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport) &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate OXID to send RFF" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1466,12 +1469,13 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport) }FNIC_STD_SET_OX_ID (prff_id->fchdr, oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, -"0x%x: FDLS send RFF with oxid: 0x%x" , iport->fcid, - oxid); - prff_id->rff_id.fr_type =FC_TYPE_FCP ; +FNIC_FCS_DBG (KERN_INFO , fnic, +"0x%x: FDLS send RFF with oxid: 0x%x type 0%x feat 0%x" , + iport->fcid, oxid, prff_id->rff_id.fr_type, + prff_id->rff_id.fr_feat); +fnic_send_fcoe_frame (iport, frame, frame_size);/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */
@@ -1493,7 +1497,7 @@ fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send TGT PRLI" ); tport->flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -1513,7 +1517,7 @@ fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport) oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_TGT_PRLI , &tport->active_oxid);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"0x%x: Failed to allocate OXID to send TGT PRLI to 0x%x" , iport->fcid, tport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1530,7 +1534,7 @@ fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport)FNIC_STD_SET_S_ID (pprli->fchdr, s_id);FNIC_STD_SET_D_ID (pprli->fchdr, d_id); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send PRLI to tgt: 0x%x with oxid: 0x%x" , iport->fcid, tport->fcid, oxid);
@@ -1564,7 +1568,7 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send fabric LOGO" );return ; }
@@ -1576,7 +1580,7 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport) &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate OXID to send fabric LOGO" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1589,7 +1593,7 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport) iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED ; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send fabric LOGO with oxid: 0x%x" , iport->fcid, oxid);
@@ -1621,7 +1625,7 @@ void fdls_tgt_logout(struct fnic_iport_s *iport, struct fnic_tport_s *tport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send fabric LOGO" );return ; }
@@ -1631,7 +1635,7 @@ void fdls_tgt_logout(struct fnic_iport_s *iport, struct fnic_tport_s *tport) oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_TGT_LOGO , &tport->active_oxid);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate OXID to send tgt LOGO" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1642,7 +1646,7 @@ void fdls_tgt_logout(struct fnic_iport_s *iport, struct fnic_tport_s *tport)hton24 (d_id, tport->fcid);FNIC_STD_SET_D_ID (plogo->fchdr, d_id); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send tgt LOGO with oxid: 0x%x" , iport->fcid, oxid);
@@ -1657,7 +1661,7 @@ static void fdls_tgt_discovery_start(struct fnic_iport_s *iport)u32 old_link_down_cnt = iport->fnic->link_down_cnt;struct fnic *fnic = iport->fnic; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Starting FDLS target discovery" , iport->fcid);list_for_each_entry_safe (tport, next, &iport->tport_list, links) {
@@ -1711,7 +1715,7 @@ static void fdls_target_restart_nexus(struct fnic_tport_s *tport)struct fnic *fnic = iport->fnic;bool retval = true; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport fcid: 0x%x state: %d restart_count: %d" , tport->fcid, tport->state, tport->nexus_restart_count);
@@ -1721,13 +1725,13 @@ static void fdls_target_restart_nexus(struct fnic_tport_s *tport) retval =fdls_delete_tport (iport, tport);if (retval != true) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Error deleting tport: 0x%x" , fcid);return ; }if (nexus_restart_count >=FNIC_TPORT_MAX_NEXUS_RESTART ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Exceeded nexus restart retries tport: 0x%x" , fcid);return ;
@@ -1744,7 +1748,7 @@ static void fdls_target_restart_nexus(struct fnic_tport_s *tport)*/ new_tport =fdls_create_tport (iport, fcid, wwpn);if (!new_tport) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Error creating new tport: 0x%x" , fcid);return ; }
@@ -1773,12 +1777,12 @@ static struct fnic_tport_s *fdls_create_tport(struct fnic_iport_s *iport,struct fnic_tport_s *tport;struct fnic *fnic = iport->fnic; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FDLS create tport: fcid: 0x%x wwpn: 0x%llx" , fcid, wwpn); tport = kzalloc_obj(struct fnic_tport_s, GFP_ATOMIC);if (!tport) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Memory allocation failure while creating tport: 0x%x\n" , fcid);return NULL ;
@@ -1791,12 +1795,12 @@ static struct fnic_tport_s *fdls_create_tport(struct fnic_iport_s *iport, tport->wwpn = wwpn; tport->iport = iport; -FNIC_FCS_DBG (KERN_DEBUG , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_DEBUG , fnic,"Need to setup tport timer callback" );timer_setup (&tport->retry_timer, fdls_tport_timer_callback,0 ); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Added tport 0x%x" , tport->fcid);fdls_set_tport_state (tport,FDLS_TGT_STATE_INIT );list_add_tail (&tport->links, &iport->tport_list);
@@ -1847,7 +1851,7 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send FDMI RHBA" );return ; }
@@ -1875,7 +1879,7 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport) &iport->active_oxid_fdmi_rhba);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate OXID to send FDMI RHBA" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1896,14 +1900,14 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport)fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_NODE_NAME ,FNIC_FDMI_NN_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"NN set, off=%d" , attr_off_bytes);strscpy_pad (data,FNIC_FDMI_MANUFACTURER ,FNIC_FDMI_MANU_LEN );fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_MANUFACTURER ,FNIC_FDMI_MANU_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"MFG set <%s>, off=%d" , data, attr_off_bytes); err =vnic_dev_fw_info (fnic->vdev, &fw_info);
@@ -1912,7 +1916,7 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport) FNIC_FDMI_SERIAL_LEN);fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_SERIAL_NUMBER ,FNIC_FDMI_SERIAL_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"SERIAL set <%s>, off=%d" , data, attr_off_bytes); }
@@ -1923,21 +1927,21 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport)fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_MODEL ,FNIC_FDMI_MODEL_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"MODEL set <%s>, off=%d" , data, attr_off_bytes);strscpy_pad (data,FNIC_FDMI_MODEL_DESCRIPTION ,FNIC_FDMI_MODEL_DES_LEN );fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_MODEL_DES ,FNIC_FDMI_MODEL_DES_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"MODEL_DESC set <%s>, off=%d" , data, attr_off_bytes);if (!err) {strscpy_pad (data, fw_info->hw_version,FNIC_FDMI_HW_VER_LEN );fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_HARDWARE_VERSION ,FNIC_FDMI_HW_VER_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"HW_VER set <%s>, off=%d" , data, attr_off_bytes); }
@@ -1946,14 +1950,14 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport)fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_DRIVER_VERSION ,FNIC_FDMI_DR_VER_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"DRV_VER set <%s>, off=%d" , data, attr_off_bytes);strscpy_pad (data,"N/A" ,FNIC_FDMI_ROM_VER_LEN );fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_ROM_VERSION ,FNIC_FDMI_ROM_VER_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"ROM_VER set <%s>, off=%d" , data, attr_off_bytes);if (!err) {
@@ -1961,14 +1965,14 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport)fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_FIRMWARE_VERSION ,FNIC_FDMI_FW_VER_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FW_VER set <%s>, off=%d" , data, attr_off_bytes); } len =sizeof (struct fc_std_fdmi_rhba ) + attr_off_bytes; frame_size += len; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send FDMI RHBA with oxid: 0x%x fs: %d" , iport->fcid, oxid, frame_size);
@@ -1992,7 +1996,7 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send FDMI RPA" );return ; }
@@ -2020,7 +2024,7 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport) &iport->active_oxid_fdmi_rpa);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Failed to allocate OXID to send FDMI RPA" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -2085,7 +2089,7 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport)fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_OS_NAME ,FNIC_FDMI_OS_NAME_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"OS name set <%s>, off=%d" , data, attr_off_bytes);sprintf (fc_host_system_hostname (fnic->host),"%s" ,utsname ()->nodename);
@@ -2094,13 +2098,13 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport)fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_HOST_NAME ,FNIC_FDMI_HN_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Host name set <%s>, off=%d" , data, attr_off_bytes); len =sizeof (struct fc_std_fdmi_rpa ) + attr_off_bytes; frame_size += len; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send FDMI RPA with oxid: 0x%x fs: %d" , iport->fcid, oxid, frame_size);
@@ -2117,7 +2121,7 @@ void fdls_fabric_timer_callback(struct timer_list *t)struct fnic *fnic = iport->fnic;unsigned long flags; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tp: %d fab state: %d fab retry counter: %d max_flogi_retries: %d" , iport->fabric.timer_pending, iport->fabric.state, iport->fabric.retry_counter, iport->max_flogi_retries);
@@ -2132,7 +2136,7 @@ void fdls_fabric_timer_callback(struct timer_list *t)if (iport->fabric.del_timer_inprogress) { iport->fabric.del_timer_inprogress =0 ;spin_unlock_irqrestore (&fnic->fnic_lock, flags); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"fabric_del_timer inprogress(%d). Skip timer cb" , iport->fabric.del_timer_inprogress);return ;
@@ -2160,7 +2164,7 @@ void fdls_fabric_timer_callback(struct timer_list *t) iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED ;fdls_send_fabric_flogi (iport); }else -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Exceeded max FLOGI retries" ); }break ;
@@ -2182,7 +2186,7 @@ void fdls_fabric_timer_callback(struct timer_list *t) iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED ;fdls_send_fabric_plogi (iport); }else -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Exceeded max PLOGI retries" ); }break ;
@@ -2213,7 +2217,7 @@ void fdls_fabric_timer_callback(struct timer_list *t)else {/* ABTS has timed out */ fdls_schedule_oxid_free (iport, &iport->active_oxid_fabric_req); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"ABTS timed out. Starting PLOGI: %p" , iport);fnic_fdls_start_plogi (iport); }
@@ -2230,7 +2234,7 @@ void fdls_fabric_timer_callback(struct timer_list *t) }else {/* ABTS has timed out */ fdls_schedule_oxid_free (iport, &iport->active_oxid_fabric_req); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"ABTS timed out. Starting PLOGI: %p" , iport);fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ }
@@ -2247,7 +2251,7 @@ void fdls_fabric_timer_callback(struct timer_list *t)else {/* ABTS has timed out */ fdls_schedule_oxid_free (iport, &iport->active_oxid_fabric_req); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"ABTS timed out. Starting PLOGI %p" , iport);fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ }
@@ -2269,7 +2273,7 @@ void fdls_fabric_timer_callback(struct timer_list *t)if (iport->fabric.retry_counter <FDLS_RETRY_COUNT ) {fdls_send_gpn_ft (iport, iport->fabric.state); }else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"ABTS timeout for fabric GPN_FT. Check name server: %p" , iport); }
@@ -2289,7 +2293,7 @@ void fdls_fdmi_retry_plogi(struct fnic_iport_s *iport)/* If max retries not exhausted, start over from fdmi plogi */ if (iport->fabric.fdmi_retry <FDLS_FDMI_MAX_RETRY ) { iport->fabric.fdmi_retry++; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Retry FDMI PLOGI. FDMI retry: %d" , iport->fabric.fdmi_retry);fdls_send_fdmi_plogi (iport);
@@ -2307,7 +2311,7 @@ void fdls_fdmi_timer_callback(struct timer_list *t)spin_lock_irqsave (&fnic->fnic_lock, flags); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport->fabric.fdmi_pending: 0x%x\n" , iport->fabric.fdmi_pending);if (!iport->fabric.fdmi_pending) {
@@ -2315,7 +2319,7 @@ void fdls_fdmi_timer_callback(struct timer_list *t)spin_unlock_irqrestore (&fnic->fnic_lock, flags);return ; } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport->fabric.fdmi_pending: 0x%x\n" , iport->fabric.fdmi_pending);/* if not abort pending, send an abort */
@@ -2324,7 +2328,7 @@ void fdls_fdmi_timer_callback(struct timer_list *t)spin_unlock_irqrestore (&fnic->fnic_lock, flags);return ; } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport->fabric.fdmi_pending: 0x%x\n" , iport->fabric.fdmi_pending);/* ABTS pending for an active fdmi request that is pending.
@@ -2332,29 +2336,36 @@ void fdls_fdmi_timer_callback(struct timer_list *t)* Schedule to free the OXID after 2*r_a_tov and proceed */ if (iport->fabric.fdmi_pending &FDLS_FDMI_PLOGI_PENDING ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FDMI PLOGI ABTS timed out. Schedule oxid free: 0x%x\n" , iport->active_oxid_fdmi_plogi);fdls_schedule_oxid_free (iport, &iport->active_oxid_fdmi_plogi); }else {if (iport->fabric.fdmi_pending &FDLS_FDMI_REG_HBA_PENDING ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FDMI RHBA ABTS timed out. Schedule oxid free: 0x%x\n" , iport->active_oxid_fdmi_rhba);fdls_schedule_oxid_free (iport, &iport->active_oxid_fdmi_rhba); }if (iport->fabric.fdmi_pending &FDLS_FDMI_RPA_PENDING ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FDMI RPA ABTS timed out. Schedule oxid free: 0x%x\n" , iport->active_oxid_fdmi_rpa);fdls_schedule_oxid_free (iport, &iport->active_oxid_fdmi_rpa); } } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport->fabric.fdmi_pending: 0x%x\n" , iport->fabric.fdmi_pending); -fdls_fdmi_retry_plogi (iport); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, + iport->fabric.fdmi_pending =0 ; +/* If max retries not exhaused, start over from fdmi plogi */ +if (iport->fabric.fdmi_retry <FDLS_FDMI_MAX_RETRY ) { + iport->fabric.fdmi_retry++; +FNIC_FCS_DBG (KERN_INFO , fnic, +"retry fdmi timer %d" , iport->fabric.fdmi_retry); +fdls_send_fdmi_plogi (iport); + } +FNIC_FCS_DBG (KERN_INFO , fnic,"iport->fabric.fdmi_pending: 0x%x\n" , iport->fabric.fdmi_pending);spin_unlock_irqrestore (&fnic->fnic_lock, flags); }
@@ -2367,7 +2378,7 @@ static void fdls_send_delete_tport_msg(struct fnic_tport_s *tport) tport_del_evt = kzalloc_obj(struct fnic_tport_event_s, GFP_ATOMIC);if (!tport_del_evt) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Failed to allocate memory for tport event fcid: 0x%x" , tport->fcid);return ;
@@ -2400,13 +2411,13 @@ static void fdls_tport_timer_callback(struct timer_list *t)if (tport->del_timer_inprogress) { tport->del_timer_inprogress =0 ;spin_unlock_irqrestore (&fnic->fnic_lock, flags); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport_del_timer inprogress. Skip timer cb tport fcid: 0x%x\n" , tport->fcid);return ; } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport fcid: 0x%x timer pending: %d state: %d retry counter: %d" , tport->fcid, tport->timer_pending, tport->state, tport->retry_counter);
@@ -2467,15 +2478,16 @@ static void fdls_tport_timer_callback(struct timer_list *t) }else {/* exceeded retry count */ fdls_schedule_oxid_free (iport, &tport->active_oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"ADISC not responding. Deleting target port: 0x%x" , tport->fcid);fdls_send_delete_tport_msg (tport); }break ;default : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, -"oxid: 0x%x Unknown tport state: 0x%x" , oxid, tport->state); +FNIC_FCS_DBG (KERN_INFO , fnic, +"0x%x timeout tport 0x%x oxid 0x%x state %d\n" , + iport->fcid, tport->fcid, oxid, tport->state);break ; }spin_unlock_irqrestore (&fnic->fnic_lock, flags);
@@ -2524,26 +2536,26 @@ fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport, tport =fnic_find_tport_by_fcid (iport, tgt_fcid);if (!tport) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Tgt ADISC response tport not found: 0x%x" , tgt_fcid);return ; }if ((iport->state !=FNIC_IPORT_STATE_READY ) || (tport->state !=FDLS_TGT_STATE_ADISC ) || (tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Dropping this ADISC response" ); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport state: %d tport state: %d Is abort issued on PRLI? %d" , iport->state, tport->state, (tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED ));return ; }if (FNIC_STD_GET_OX_ID (fchdr) != tport->active_oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Dropping frame from target: 0x%x" , tgt_fcid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Reason: Stale ADISC/Aborted ADISC/OOO frame delivery" );return ; }
@@ -2555,7 +2567,7 @@ fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport,case ELS_LS_ACC :atomic64_inc (&iport->iport_stats.tport_adisc_ls_accepts);if (tport->timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport 0x%p Canceling fabric disc timer\n" , tport);fnic_del_tport_timer_sync (fnic, tport);
@@ -2565,12 +2577,12 @@ fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport, frame_wwnn =get_unaligned_be64 (&adisc_rsp->els.adisc_wwnn); frame_wwpn =get_unaligned_be64 (&adisc_rsp->els.adisc_wwpn);if ((frame_wwnn == tport->wwnn) && (frame_wwpn == tport->wwpn)) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"ADISC accepted from target: 0x%x. Target logged in" , tgt_fcid);fdls_set_tport_state (tport,FDLS_TGT_STATE_READY ); }else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Error mismatch frame: ADISC" ); }break ;
@@ -2580,14 +2592,14 @@ fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport,if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) || (els_rjt->rej.er_reason ==ELS_RJT_UNAB )) && (tport->retry_counter <FDLS_RETRY_COUNT )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"ADISC ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x" , tgt_fcid);/* Retry ADISC again from the timer routine. */ tport->flags |=FNIC_FDLS_RETRY_FRAME ; }else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"ADISC returned ELS_LS_RJT from target: 0x%x" , tgt_fcid);fdls_delete_tport (iport, tport);
@@ -2611,33 +2623,33 @@ fdls_process_tgt_plogi_rsp(struct fnic_iport_s *iport, fcid =FNIC_STD_GET_S_ID (fchdr); tgt_fcid =ntoh24 (fcid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FDLS processing target PLOGI response: tgt_fcid: 0x%x" , tgt_fcid); tport =fnic_find_tport_by_fcid (iport, tgt_fcid);if (!tport) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport not found: 0x%x" , tgt_fcid);return ; }if ((iport->state !=FNIC_IPORT_STATE_READY ) || (tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Dropping frame! iport state: %d tport state: %d" , iport->state, tport->state);return ; }if (tport->state !=FDLS_TGT_STATE_PLOGI ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PLOGI rsp recvd in wrong state. Drop the frame and restart nexus" );fdls_target_restart_nexus (tport);return ; }if (FNIC_STD_GET_OX_ID (fchdr) != tport->active_oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PLOGI response from target: 0x%x. Dropping frame" , tgt_fcid);return ;
@@ -2649,7 +2661,7 @@ fdls_process_tgt_plogi_rsp(struct fnic_iport_s *iport,switch (plogi_rsp->els.fl_cmd) {case ELS_LS_ACC :atomic64_inc (&iport->iport_stats.tport_plogi_ls_accepts); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PLOGI accepted by target: 0x%x" , tgt_fcid);break ;
@@ -2658,14 +2670,14 @@ fdls_process_tgt_plogi_rsp(struct fnic_iport_s *iport,if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) || (els_rjt->rej.er_reason ==ELS_RJT_UNAB )) && (tport->retry_counter < iport->max_plogi_retries)) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PLOGI ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x" , tgt_fcid);/* Retry plogi again from the timer routine. */ tport->flags |=FNIC_FDLS_RETRY_FRAME ;return ; } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PLOGI returned ELS_LS_RJT from target: 0x%x" , tgt_fcid);fdls_delete_tport (iport, tport);
@@ -2673,18 +2685,18 @@ fdls_process_tgt_plogi_rsp(struct fnic_iport_s *iport,default :atomic64_inc (&iport->iport_stats.tport_plogi_misc_rejects); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PLOGI not accepted from target fcid: 0x%x" , tgt_fcid);return ; } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Found the PLOGI target: 0x%x and state: %d" , (unsigned int ) tgt_fcid, tport->state);if (tport->timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport fcid 0x%x: Canceling disc timer\n" , tport->fcid);fnic_del_tport_timer_sync (fnic, tport);
@@ -2702,13 +2714,13 @@ fdls_process_tgt_plogi_rsp(struct fnic_iport_s *iport,min (max_payload_size, iport->max_payload_size);if (tport->max_payload_size <FNIC_MIN_DATA_FIELD_SIZE ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"MFS: tport max frame size below spec bounds: %d" , tport->max_payload_size); tport->max_payload_size =FNIC_MIN_DATA_FIELD_SIZE ; } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"MAX frame size: %u iport max_payload_size: %d tport mfs: %d" , max_payload_size, iport->max_payload_size, tport->max_payload_size);
@@ -2736,12 +2748,12 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, fcid =FNIC_STD_GET_S_ID (fchdr); tgt_fcid =ntoh24 (fcid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FDLS process tgt PRLI response: 0x%x" , tgt_fcid); tport =fnic_find_tport_by_fcid (iport, tgt_fcid);if (!tport) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport not found: 0x%x" , tgt_fcid);/* Handle or just drop? */ return ;
@@ -2749,24 +2761,24 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport,if ((iport->state !=FNIC_IPORT_STATE_READY ) || (tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Dropping frame! iport st: %d tport st: %d tport fcid: 0x%x" , iport->state, tport->state, tport->fcid);return ; }if (tport->state !=FDLS_TGT_STATE_PRLI ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PRLI rsp recvd in wrong state. Drop frame. Restarting nexus" );fdls_target_restart_nexus (tport);return ; }if (FNIC_STD_GET_OX_ID (fchdr) != tport->active_oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Dropping PRLI response from target: 0x%x " , tgt_fcid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Reason: Stale PRLI response/Aborted PDISC/OOO frame delivery" );return ; }
@@ -2777,11 +2789,11 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport,switch (prli_rsp->els_prli.prli_cmd) {case ELS_LS_ACC :atomic64_inc (&iport->iport_stats.tport_prli_ls_accepts); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PRLI accepted from target: 0x%x" , tgt_fcid);if (prli_rsp->sp.spp_type !=FC_FC4_TYPE_SCSI ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"mismatched target zoned with FC SCSI initiator: 0x%x" , tgt_fcid); mismatched_tgt = true;
@@ -2798,7 +2810,7 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, || (els_rjt->rej.er_reason == ELS_RJT_UNAB)) && (tport->retry_counter < FDLS_RETRY_COUNT)) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PRLI ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x" , tgt_fcid);
@@ -2806,7 +2818,7 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, tport->flags |=FNIC_FDLS_RETRY_FRAME ;return ; } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PRLI returned ELS_LS_RJT from target: 0x%x" , tgt_fcid);
@@ -2815,17 +2827,17 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport,return ;default :atomic64_inc (&iport->iport_stats.tport_prli_misc_rejects); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PRLI not accepted from target: 0x%x" , tgt_fcid);return ; } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Found the PRLI target: 0x%x and state: %d" , (unsigned int ) tgt_fcid, tport->state);if (tport->timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport fcid 0x%x: Canceling disc timer\n" , tport->fcid);fnic_del_tport_timer_sync (fnic, tport);
@@ -2841,7 +2853,7 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport,/* Check if the device plays Target Mode Function */ if (!(tport->fcp_csp &FCP_PRLI_FUNC_TARGET )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Remote port(0x%x): no target support. Deleting it\n" , tgt_fcid);fdls_tgt_logout (iport, tport);
@@ -2854,16 +2866,16 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport,/* Inform the driver about new target added */ tport_add_evt = kzalloc_obj(struct fnic_tport_event_s, GFP_ATOMIC);if (!tport_add_evt) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, -"tport event memory allocation failure: 0x%0x\n" , - tport->fcid); +FNIC_FCS_DBG (KERN_INFO , fnic, +"iport fcid: 0x%x tport event memory allocation failure: 0x%0x\n" , + iport->fcid, tport->fcid);return ; } tport_add_evt->event =TGT_EV_RPORT_ADD ; tport_add_evt->arg1 = (void *) tport; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, -"iport fcid: 0x%x add tport event fcid: 0x%x\n" , - tport->fcid, iport->fcid); +FNIC_FCS_DBG (KERN_INFO , fnic, +"iport fcid: 0x%x add tport event fcid: 0x%x\n" , + tport->fcid, iport->fcid);list_add_tail (&tport_add_evt->links, &fnic->tport_event_list);queue_work (fnic_event_queue, &fnic->tport_work); }
@@ -2881,21 +2893,21 @@ fdls_process_rff_id_rsp(struct fnic_iport_s *iport,uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);if (fdls_get_state (fdls) !=FDLS_STATE_REGISTER_FC4_FEATURES ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RFF_ID resp recvd in state(%d). Dropping." ,fdls_get_state (fdls));return ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req);return ; } rsp =FNIC_STD_GET_FC_CT_CMD ((&rff_rsp->fc_std_ct_hdr)); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS process RFF ID response: 0x%04x" , iport->fcid, (uint32_t ) rsp);
@@ -2904,7 +2916,7 @@ fdls_process_rff_id_rsp(struct fnic_iport_s *iport,switch (rsp) {case FC_FS_ACC :if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Canceling fabric disc timer %p\n" , iport);fnic_del_fabric_timer_sync (fnic); }
@@ -2918,18 +2930,18 @@ fdls_process_rff_id_rsp(struct fnic_iport_s *iport,if (((reason_code ==FC_FS_RJT_BSY ) || (reason_code ==FC_FS_RJT_UNABL )) && (fdls->retry_counter <FDLS_RETRY_COUNT )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RFF_ID ret ELS_LS_RJT BUSY. Retry from timer routine %p" , iport);/* Retry again from the timer routine */ fdls->flags |=FNIC_FDLS_RETRY_FRAME ; }else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RFF_ID returned ELS_LS_RJT. Halting discovery %p" , iport);if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Canceling fabric disc timer %p\n" , iport);fnic_del_fabric_timer_sync (fnic); }
@@ -2954,14 +2966,14 @@ fdls_process_rft_id_rsp(struct fnic_iport_s *iport,uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);if (fdls_get_state (fdls) !=FDLS_STATE_REGISTER_FC4_TYPES ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RFT_ID resp recvd in state(%d). Dropping." ,fdls_get_state (fdls));return ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req);return ;
@@ -2969,7 +2981,7 @@ fdls_process_rft_id_rsp(struct fnic_iport_s *iport, rsp =FNIC_STD_GET_FC_CT_CMD ((&rft_rsp->fc_std_ct_hdr)); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS process RFT ID response: 0x%04x" , iport->fcid, (uint32_t ) rsp);
@@ -2978,7 +2990,7 @@ fdls_process_rft_id_rsp(struct fnic_iport_s *iport,switch (rsp) {case FC_FS_ACC :if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Canceling fabric disc timer %p\n" , iport);fnic_del_fabric_timer_sync (fnic); }
@@ -2992,19 +3004,19 @@ fdls_process_rft_id_rsp(struct fnic_iport_s *iport,if (((reason_code ==FC_FS_RJT_BSY ) || (reason_code ==FC_FS_RJT_UNABL )) && (fdls->retry_counter <FDLS_RETRY_COUNT )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: RFT_ID ret ELS_LS_RJT BUSY. Retry from timer routine" , iport->fcid);/* Retry again from the timer routine */ fdls->flags |=FNIC_FDLS_RETRY_FRAME ; }else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: RFT_ID REJ. Halting discovery reason %d expl %d" , iport->fcid, reason_code, rft_rsp->fc_std_ct_hdr.ct_explan);if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Canceling fabric disc timer %p\n" , iport);fnic_del_fabric_timer_sync (fnic); }
@@ -3029,20 +3041,20 @@ fdls_process_rpn_id_rsp(struct fnic_iport_s *iport,uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);if (fdls_get_state (fdls) !=FDLS_STATE_RPN_ID ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RPN_ID resp recvd in state(%d). Dropping." ,fdls_get_state (fdls));return ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req);return ; } rsp =FNIC_STD_GET_FC_CT_CMD ((&rpn_rsp->fc_std_ct_hdr)); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS process RPN ID response: 0x%04x" , iport->fcid, (uint32_t ) rsp);fdls_free_oxid (iport, oxid, &iport->active_oxid_fabric_req);
@@ -3050,7 +3062,7 @@ fdls_process_rpn_id_rsp(struct fnic_iport_s *iport,switch (rsp) {case FC_FS_ACC :if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Canceling fabric disc timer %p\n" , iport);fnic_del_fabric_timer_sync (fnic); }
@@ -3064,17 +3076,17 @@ fdls_process_rpn_id_rsp(struct fnic_iport_s *iport,if (((reason_code ==FC_FS_RJT_BSY ) || (reason_code ==FC_FS_RJT_UNABL )) && (fdls->retry_counter <FDLS_RETRY_COUNT )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RPN_ID returned REJ BUSY. Retry from timer routine %p" , iport);/* Retry again from the timer routine */ fdls->flags |=FNIC_FDLS_RETRY_FRAME ; }else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RPN_ID ELS_LS_RJT. Halting discovery %p" , iport);if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Canceling fabric disc timer %p\n" , iport);fnic_del_fabric_timer_sync (fnic); }
@@ -3097,18 +3109,18 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport,struct fnic *fnic = iport->fnic;uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FDLS process SCR response: 0x%04x" , (uint32_t ) scr_rsp->scr.scr_cmd);if (fdls_get_state (fdls) !=FDLS_STATE_SCR ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"SCR resp recvd in state(%d). Dropping." ,fdls_get_state (fdls));return ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req); }
@@ -3119,7 +3131,7 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport,case ELS_LS_ACC :atomic64_inc (&iport->iport_stats.fabric_scr_ls_accepts);if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Canceling fabric disc timer %p\n" , iport);fnic_del_fabric_timer_sync (fnic); }
@@ -3133,17 +3145,17 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport,if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) || (els_rjt->rej.er_reason ==ELS_RJT_UNAB )) && (fdls->retry_counter <FDLS_RETRY_COUNT )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"SCR ELS_LS_RJT BUSY. Retry from timer routine %p" , iport);/* Retry again from the timer routine */ fdls->flags |=FNIC_FDLS_RETRY_FRAME ; }else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"SCR returned ELS_LS_RJT. Halting discovery %p" , iport);if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Canceling fabric disc timer %p\n" , iport);fnic_del_fabric_timer_sync (fnic);
@@ -3171,7 +3183,7 @@ fdls_process_gpn_ft_tgt_list(struct fnic_iport_s *iport,u32 old_link_down_cnt = iport->fnic->link_down_cnt;struct fnic *fnic = iport->fnic; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS process GPN_FT tgt list" , iport->fcid); gpn_ft_tgt =
@@ -3185,7 +3197,7 @@ fdls_process_gpn_ft_tgt_list(struct fnic_iport_s *iport, fcid =ntoh24 (gpn_ft_tgt->fcid); wwpn =be64_to_cpu (gpn_ft_tgt->wwpn); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport: 0x%x: ctrl:0x%x" , fcid, gpn_ft_tgt->ctrl);if (fcid == iport->fcid) {
@@ -3232,7 +3244,7 @@ fdls_process_gpn_ft_tgt_list(struct fnic_iport_s *iport, rem_len -=sizeof (struct fc_gpn_ft_rsp_iu ); }if (rem_len <=0 ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"GPN_FT response: malformed/corrupt frame rxlen: %d remlen: %d" , len, rem_len); }
@@ -3242,7 +3254,7 @@ fdls_process_gpn_ft_tgt_list(struct fnic_iport_s *iport,list_for_each_entry_safe (tport, next, &iport->tport_list, links) {if (!(tport->flags &FNIC_FDLS_TPORT_IN_GPN_FT_LIST )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Remove port: 0x%x not found in GPN_FT list" , tport->fcid);fdls_delete_tport (iport, tport);
@@ -3271,7 +3283,7 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport,struct fnic *fnic = iport->fnic;uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FDLS process GPN_FT response: iport state: %d len: %d" , iport->state, len);
@@ -3291,14 +3303,14 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, && ((fdls_get_state(fdls) == FDLS_STATE_RSCN_GPN_FT) || (fdls_get_state(fdls) == FDLS_STATE_SEND_GPNFT) || (fdls_get_state(fdls) == FDLS_STATE_TGT_DISCOVERY))))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"GPNFT resp recvd in fab state(%d) iport_state(%d). Dropping." ,fdls_get_state (fdls), iport->state);return ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req); }
@@ -3311,10 +3323,10 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport,switch (rsp) {case FC_FS_ACC : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: GPNFT_RSP accept" , iport->fcid);if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Canceling fabric disc timer\n" , iport->fcid);fnic_del_fabric_timer_sync (fnic);
@@ -3329,7 +3341,7 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport,* that will be taken care in next link up event */ if (iport->state !=FNIC_IPORT_STATE_READY ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Halting target discovery: fab st: %d iport st: %d " ,fdls_get_state (fdls), iport->state);break ;
@@ -3339,22 +3351,22 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport,case FC_FS_RJT : reason_code = gpn_ft_rsp->fc_std_ct_hdr.ct_reason; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: GPNFT_RSP Reject reason: %d" , iport->fcid, reason_code);if (((reason_code ==FC_FS_RJT_BSY ) || (reason_code ==FC_FS_RJT_UNABL )) && (fdls->retry_counter <FDLS_RETRY_COUNT )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: GPNFT_RSP ret REJ/BSY. Retry from timer routine" , iport->fcid);/* Retry again from the timer routine */ fdls->flags |=FNIC_FDLS_RETRY_FRAME ; }else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: GPNFT_RSP reject" , iport->fcid);if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Canceling fabric disc timer\n" , iport->fcid);fnic_del_fabric_timer_sync (fnic);
@@ -3368,7 +3380,7 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, count =0 ;list_for_each_entry_safe (tport, next, &iport->tport_list, links) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"GPN_FT_REJECT: Remove port: 0x%x" , tport->fcid);fdls_delete_tport (iport, tport);
@@ -3378,7 +3390,7 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, } count++; } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"GPN_FT_REJECT: Removed (0x%x) ports" , count); }break ;
@@ -3403,7 +3415,7 @@ fdls_process_fabric_logo_rsp(struct fnic_iport_s *iport,uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req); }
@@ -3412,7 +3424,7 @@ fdls_process_fabric_logo_rsp(struct fnic_iport_s *iport,switch (flogo_rsp->els.fl_cmd) {case ELS_LS_ACC :if (iport->fabric.state !=FDLS_STATE_FABRIC_LOGO ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Flogo response. Fabric not in LOGO state. Dropping! %p" , iport);return ;
@@ -3422,25 +3434,25 @@ fdls_process_fabric_logo_rsp(struct fnic_iport_s *iport, iport->state =FNIC_IPORT_STATE_LINK_WAIT ;if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport 0x%p Canceling fabric disc timer\n" , iport);fnic_del_fabric_timer_sync (fnic); } iport->fabric.timer_pending =0 ; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Flogo response from Fabric for did: 0x%x" ,ntoh24 (fchdr->fh_d_id));return ;case ELS_LS_RJT : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Flogo response from Fabric for did: 0x%x returned ELS_LS_RJT" ,ntoh24 (fchdr->fh_d_id));return ;default : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FLOGO response not accepted or rejected: 0x%x" , flogo_rsp->els.fl_cmd); }
@@ -3458,17 +3470,17 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,struct fnic *fnic = iport->fnic;uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS processing FLOGI response" , iport->fcid);if (fdls_get_state (fabric) !=FDLS_STATE_FABRIC_FLOGI ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FLOGI response received in state (%d). Dropping frame" ,fdls_get_state (fabric));return ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fabric), oxid, iport->active_oxid_fabric_req);return ;
@@ -3480,7 +3492,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,case ELS_LS_ACC :atomic64_inc (&iport->iport_stats.fabric_flogi_ls_accepts);if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport fcid: 0x%x Canceling fabric disc timer\n" , iport->fcid);fnic_del_fabric_timer_sync (fnic);
@@ -3490,7 +3502,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport, iport->fabric.retry_counter =0 ; fcid =FNIC_STD_GET_D_ID (fchdr); iport->fcid =ntoh24 (fcid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FLOGI response accepted" , iport->fcid);/* Learn the Service Params */
@@ -3500,7 +3512,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport, iport->max_payload_size =min (rdf_size, iport->max_payload_size); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"max_payload_size from fabric: %u set: %d" , rdf_size, iport->max_payload_size);
@@ -3510,7 +3522,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,if (FNIC_LOGI_FEATURES (flogi_rsp->els) &FNIC_FC_EDTOV_NSEC ) iport->e_d_tov = iport->e_d_tov /FNIC_NSEC_TO_MSEC ; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"From fabric: R_A_TOV: %d E_D_TOV: %d" , iport->r_a_tov, iport->e_d_tov);
@@ -3521,13 +3533,13 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,fnic_fdls_learn_fcoe_macs (iport, rx_frame, fcid);if (fnic_fdls_register_portid (iport, iport->fcid, rx_frame) !=0 ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FLOGI registration failed" , iport->fcid);break ; }memcpy (&fcmac[3 ], fcid,3 ); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Adding vNIC device MAC addr: %02x:%02x:%02x:%02x:%02x:%02x" , fcmac[0 ], fcmac[1 ], fcmac[2 ], fcmac[3 ], fcmac[4 ], fcmac[5 ]);
@@ -3535,7 +3547,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,if (fdls_get_state (fabric) ==FDLS_STATE_FABRIC_FLOGI ) {fnic_fdls_start_plogi (iport); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FLOGI response received. Starting PLOGI" ); }else {/* From FDLS_STATE_FABRIC_FLOGI state fabric can only go to
@@ -3543,7 +3555,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,* state, hence we don't have to worry about undoing: * the fnic_fdls_register_portid and vnic_dev_add_addr */ -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FLOGI response received in state (%d). Dropping frame" ,fdls_get_state (fabric)); }
@@ -3552,7 +3564,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,case ELS_LS_RJT :atomic64_inc (&iport->iport_stats.fabric_flogi_ls_rejects);if (fabric->retry_counter < iport->max_flogi_retries) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FLOGI returned ELS_LS_RJT BUSY. Retry from timer routine %p" , iport);
@@ -3560,11 +3572,11 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport, fabric->flags |=FNIC_FDLS_RETRY_FRAME ; }else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FLOGI returned ELS_LS_RJT. Halting discovery %p" , iport);if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport 0x%p Canceling fabric disc timer\n" , iport);fnic_del_fabric_timer_sync (fnic);
@@ -3575,7 +3587,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,break ;default : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FLOGI response not accepted: 0x%x" , flogi_rsp->els.fl_cmd);atomic64_inc (&iport->iport_stats.fabric_flogi_misc_rejects);
@@ -3594,13 +3606,13 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport,uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);if (fdls_get_state ((&iport->fabric)) !=FDLS_STATE_FABRIC_PLOGI ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Fabric PLOGI response received in state (%d). Dropping frame" ,fdls_get_state (&iport->fabric));return ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req);return ;
@@ -3611,7 +3623,7 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport,case ELS_LS_ACC :atomic64_inc (&iport->iport_stats.fabric_plogi_ls_accepts);if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport fcid: 0x%x fabric PLOGI response: Accepted\n" , iport->fcid);fnic_del_fabric_timer_sync (fnic);
@@ -3626,15 +3638,15 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport,if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) || (els_rjt->rej.er_reason ==ELS_RJT_UNAB )) && (iport->fabric.retry_counter < iport->max_plogi_retries)) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Fabric PLOGI ELS_LS_RJT BUSY. Retry from timer routine" , iport->fcid); }else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Fabric PLOGI ELS_LS_RJT. Halting discovery" , iport->fcid);if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport fcid: 0x%x Canceling fabric disc timer\n" , iport->fcid);fnic_del_fabric_timer_sync (fnic);
@@ -3645,7 +3657,7 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport, }break ;default : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PLOGI response not accepted: 0x%x" , plogi_rsp->els.fl_cmd);atomic64_inc (&iport->iport_stats.fabric_plogi_misc_rejects);
@@ -3664,7 +3676,7 @@ static void fdls_process_fdmi_plogi_rsp(struct fnic_iport_s *iport,uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);if (iport->active_oxid_fdmi_plogi != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fdmi_plogi);return ;
@@ -3678,9 +3690,9 @@ static void fdls_process_fdmi_plogi_rsp(struct fnic_iport_s *iport, iport->fabric.fdmi_pending =0 ;switch (plogi_rsp->els.fl_cmd) {case ELS_LS_ACC : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FDLS process fdmi PLOGI response status: ELS_LS_ACC\n" ); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Sending fdmi registration for port 0x%x\n" , iport->fcid);
@@ -3691,7 +3703,7 @@ static void fdls_process_fdmi_plogi_rsp(struct fnic_iport_s *iport, round_jiffies(fdmi_tov));break ;case ELS_LS_RJT : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Fabric FDMI PLOGI returned ELS_LS_RJT reason: 0x%x" , els_rjt->rej.er_reason);
@@ -3715,7 +3727,7 @@ static void fdls_process_fdmi_reg_ack(struct fnic_iport_s *iport,uint16_t oxid;if (!iport->fabric.fdmi_pending) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Received FDMI ack while not waiting: 0x%x\n" ,FNIC_STD_GET_OX_ID (fchdr));return ;
@@ -3725,7 +3737,7 @@ static void fdls_process_fdmi_reg_ack(struct fnic_iport_s *iport,if ((iport->active_oxid_fdmi_rhba != oxid) && (iport->active_oxid_fdmi_rpa != oxid)) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Incorrect OXID in response. oxid recvd: 0x%x, active oxids(rhba,rpa): 0x%x, 0x%x\n" , oxid, iport->active_oxid_fdmi_rhba, iport->active_oxid_fdmi_rpa);return ;
@@ -3738,13 +3750,13 @@ static void fdls_process_fdmi_reg_ack(struct fnic_iport_s *iport,fdls_free_oxid (iport, oxid, &iport->active_oxid_fdmi_rpa); } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport fcid: 0x%x: Received FDMI registration ack\n" , iport->fcid);if (!iport->fabric.fdmi_pending) {timer_delete_sync (&iport->fabric.fdmi_timer); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport fcid: 0x%x: Canceling FDMI timer\n" , iport->fcid); }
@@ -3760,7 +3772,7 @@ static void fdls_process_fdmi_abts_rsp(struct fnic_iport_s *iport, s_id =ntoh24 (FNIC_STD_GET_S_ID (fchdr));if (!(s_id !=FC_FID_MGMT_SERV )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received abts rsp with invalid SID: 0x%x. Dropping frame" , s_id);return ;
@@ -3770,23 +3782,23 @@ static void fdls_process_fdmi_abts_rsp(struct fnic_iport_s *iport,switch (FNIC_FRAME_TYPE (oxid)) {case FNIC_FRAME_TYPE_FDMI_PLOGI : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received FDMI PLOGI ABTS rsp with oxid: 0x%x" , oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: iport->fabric.fdmi_pending: 0x%x" , iport->fcid, iport->fabric.fdmi_pending);fdls_free_oxid (iport, oxid, &iport->active_oxid_fdmi_plogi); iport->fabric.fdmi_pending &= ~FDLS_FDMI_PLOGI_PENDING ; iport->fabric.fdmi_pending &= ~FDLS_FDMI_ABORT_PENDING ; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: iport->fabric.fdmi_pending: 0x%x" , iport->fcid, iport->fabric.fdmi_pending);break ;case FNIC_FRAME_TYPE_FDMI_RHBA : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received FDMI RHBA ABTS rsp with oxid: 0x%x" , oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: iport->fabric.fdmi_pending: 0x%x" , iport->fcid, iport->fabric.fdmi_pending);
@@ -3800,14 +3812,14 @@ static void fdls_process_fdmi_abts_rsp(struct fnic_iport_s *iport, iport->fabric.fdmi_pending &= ~FDLS_FDMI_ABORT_PENDING ;fdls_free_oxid (iport, oxid, &iport->active_oxid_fdmi_rhba); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: iport->fabric.fdmi_pending: 0x%x" , iport->fcid, iport->fabric.fdmi_pending);break ;case FNIC_FRAME_TYPE_FDMI_RPA : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received FDMI RPA ABTS rsp with oxid: 0x%x" , oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: iport->fabric.fdmi_pending: 0x%x" , iport->fcid, iport->fabric.fdmi_pending);
@@ -3821,12 +3833,12 @@ static void fdls_process_fdmi_abts_rsp(struct fnic_iport_s *iport, iport->fabric.fdmi_pending &= ~FDLS_FDMI_ABORT_PENDING ;fdls_free_oxid (iport, oxid, &iport->active_oxid_fdmi_rpa); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: iport->fabric.fdmi_pending: 0x%x" , iport->fcid, iport->fabric.fdmi_pending);break ;default : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received abts rsp with invalid oxid: 0x%x. Dropping frame" , oxid);break ;
@@ -3861,7 +3873,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport,if (!((s_id ==FC_FID_DIR_SERV ) || (s_id ==FC_FID_FLOGI ) || (s_id ==FC_FID_FCTRL ))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received abts rsp with invalid SID: 0x%x. Dropping frame" , s_id);return ;
@@ -3869,14 +3881,14 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, oxid =FNIC_STD_GET_OX_ID (fchdr);if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received abts rsp with invalid oxid: 0x%x. Dropping frame" , oxid);return ; }if (iport->fabric.timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Canceling fabric disc timer %p\n" , iport);fnic_del_fabric_timer_sync (fnic); }
@@ -3884,11 +3896,11 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED ;if (fchdr->fh_r_ctl ==FC_RCTL_BA_ACC ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received abts rsp BA_ACC for fabric_state: %d OX_ID: 0x%x" , fabric_state,be16_to_cpu (ba_acc->acc.ba_ox_id)); }else if (fchdr->fh_r_ctl ==FC_RCTL_BA_RJT ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"BA_RJT fs: %d OX_ID: 0x%x rc: 0x%x rce: 0x%x" , fabric_state,FNIC_STD_GET_OX_ID (&ba_rjt->fchdr), ba_rjt->rjt.br_reason, ba_rjt->rjt.br_explan);
@@ -3903,7 +3915,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport,if (iport->fabric.retry_counter < iport->max_flogi_retries)fdls_send_fabric_flogi (iport);else -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Exceeded max FLOGI retries" );break ;case FNIC_FRAME_TYPE_FABRIC_LOGO :
@@ -3914,7 +3926,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport,if (iport->fabric.retry_counter < iport->max_plogi_retries)fdls_send_fabric_plogi (iport);else -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Exceeded max PLOGI retries" );break ;case FNIC_FRAME_TYPE_FABRIC_RPN :
@@ -3928,7 +3940,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport,if (iport->fabric.retry_counter <FDLS_RETRY_COUNT )fdls_send_scr (iport);else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"SCR exhausted retries. Start fabric PLOGI %p" , iport);fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */
@@ -3938,7 +3950,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport,if (iport->fabric.retry_counter <FDLS_RETRY_COUNT )fdls_send_register_fc4_types (iport);else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RFT exhausted retries. Start fabric PLOGI %p" , iport);fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */
@@ -3948,7 +3960,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport,if (iport->fabric.retry_counter <FDLS_RETRY_COUNT )fdls_send_register_fc4_features (iport);else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RFF exhausted retries. Start fabric PLOGI %p" , iport);fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */
@@ -3958,7 +3970,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport,if (iport->fabric.retry_counter <=FDLS_RETRY_COUNT )fdls_send_gpn_ft (iport, fabric_state);else -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"GPN FT exhausted retries. Start fabric PLOGI %p" , iport);break ;
@@ -3967,7 +3979,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport,* We should not be here since we already validated rx oxid with * our active_oxid_fabric_req */ -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Invalid OXID/active oxid 0x%x\n" , oxid);WARN_ON (true);return ;
@@ -3987,7 +3999,7 @@ fdls_process_abts_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)sizeof (struct fc_std_abts_ba_acc ); nport_id =ntoh24 (fchdr->fh_s_id); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received abort from SID 0x%8x" , nport_id); tport =fnic_find_tport_by_fcid (iport, nport_id);
@@ -4000,7 +4012,7 @@ fdls_process_abts_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"0x%x: Failed to allocate frame to send response for ABTS req" , iport->fcid);return ;
@@ -4021,7 +4033,7 @@ fdls_process_abts_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) pba_acc->acc.ba_rx_id =cpu_to_be16 (FNIC_STD_GET_RX_ID (fchdr)); pba_acc->acc.ba_ox_id =cpu_to_be16 (FNIC_STD_GET_OX_ID (fchdr)); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS send BA ACC with oxid: 0x%x" , iport->fcid, oxid);
@@ -4041,7 +4053,7 @@ fdls_process_unsupported_els_req(struct fnic_iport_s *iport,sizeof (struct fc_std_els_rjt_rsp );if (iport->fcid != d_id) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Dropping unsupported ELS with illegal frame bits 0x%x\n" , d_id);atomic64_inc (&iport->iport_stats.unsupported_frames_dropped);
@@ -4050,7 +4062,7 @@ fdls_process_unsupported_els_req(struct fnic_iport_s *iport,if ((iport->state !=FNIC_IPORT_STATE_READY ) && (iport->state !=FNIC_IPORT_STATE_FABRIC_DISC )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Dropping unsupported ELS request in iport state: %d" , iport->state);atomic64_inc (&iport->iport_stats.unsupported_frames_dropped);
@@ -4059,7 +4071,7 @@ fdls_process_unsupported_els_req(struct fnic_iport_s *iport, frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send response to unsupported ELS request" );return ; }
@@ -4067,7 +4079,7 @@ fdls_process_unsupported_els_req(struct fnic_iport_s *iport, pls_rsp = (struct fc_std_els_rjt_rsp *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET );fdls_init_els_rjt_frame (frame, iport); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Process unsupported ELS request from SID: 0x%x" , iport->fcid,ntoh24 (fchdr->fh_s_id));
@@ -4094,12 +4106,12 @@ fdls_process_rls_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET +sizeof (struct fc_std_rls_acc ); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Process RLS request %d" , iport->fnic->fnic_num);if ((iport->state !=FNIC_IPORT_STATE_READY ) && (iport->state !=FNIC_IPORT_STATE_FABRIC_DISC )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received RLS req in iport state: %d. Dropping the frame." , iport->state);return ;
@@ -4107,7 +4119,7 @@ fdls_process_rls_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send RLS accept" );return ; }
@@ -4148,33 +4160,33 @@ fdls_process_els_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr,if ((iport->state !=FNIC_IPORT_STATE_READY ) && (iport->state !=FNIC_IPORT_STATE_FABRIC_DISC )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Dropping ELS frame type: 0x%x in iport state: %d" , type, iport->state);return ; }switch (type) {case ELS_ECHO : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"sending LS_ACC for ECHO request %d\n" , iport->fnic->fnic_num);break ;case ELS_RRQ : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"sending LS_ACC for RRQ request %d\n" , iport->fnic->fnic_num);break ;default : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"sending LS_ACC for 0x%x ELS frame\n" , type);break ; } frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send ELS response for 0x%x" , type);return ;
@@ -4220,17 +4232,17 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, tport =fnic_find_tport_by_fcid (iport, s_id);if (!tport) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Received tgt abts rsp with invalid SID: 0x%x" , s_id);return ; }if (tport->timer_pending) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"tport 0x%p Canceling fabric disc timer\n" , tport);fnic_del_tport_timer_sync (fnic, tport); }if (iport->state !=FNIC_IPORT_STATE_READY ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Received tgt abts rsp in iport state(%d). Dropping." , iport->state);return ;
@@ -4245,15 +4257,15 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport,switch (frame_type) {case FNIC_FRAME_TYPE_TGT_ADISC :if (fchdr->fh_r_ctl ==FC_RCTL_BA_ACC ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"OX_ID: 0x%x tgt_fcid: 0x%x rcvd tgt adisc abts resp BA_ACC" ,be16_to_cpu (ba_acc->acc.ba_ox_id), tport->fcid); }else if (fchdr->fh_r_ctl ==FC_RCTL_BA_RJT ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"ADISC BA_RJT rcvd tport_fcid: 0x%x tport_state: %d " , tport->fcid, tport_state); -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"reason code: 0x%x reason code explanation:0x%x " , ba_rjt->rjt.br_reason, ba_rjt->rjt.br_explan);
@@ -4265,7 +4277,7 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport,return ; }fdls_free_oxid (iport, oxid, &tport->active_oxid); -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"ADISC not responding. Deleting target port: 0x%x" , tport->fcid);fdls_delete_tport (iport, tport);
@@ -4278,14 +4290,14 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport,break ;case FNIC_FRAME_TYPE_TGT_PLOGI :if (fchdr->fh_r_ctl ==FC_RCTL_BA_ACC ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Received tgt PLOGI abts response BA_ACC tgt_fcid: 0x%x" , tport->fcid); }else if (fchdr->fh_r_ctl ==FC_RCTL_BA_RJT ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PLOGI BA_RJT received for tport_fcid: 0x%x OX_ID: 0x%x" , tport->fcid,FNIC_STD_GET_OX_ID (fchdr)); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"reason code: 0x%x reason code explanation: 0x%x" , ba_rjt->rjt.br_reason, ba_rjt->rjt.br_explan);
@@ -4308,14 +4320,14 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport,break ;case FNIC_FRAME_TYPE_TGT_PRLI :if (fchdr->fh_r_ctl ==FC_RCTL_BA_ACC ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Received tgt PRLI abts response BA_ACC" , tport->fcid); }else if (fchdr->fh_r_ctl ==FC_RCTL_BA_RJT ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PRLI BA_RJT received for tport_fcid: 0x%x OX_ID: 0x%x " , tport->fcid,FNIC_STD_GET_OX_ID (fchdr)); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"reason code: 0x%x reason code explanation: 0x%x" , ba_rjt->rjt.br_reason, ba_rjt->rjt.br_explan);
@@ -4331,7 +4343,7 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport,fdls_set_tport_state (tport,FDLS_TGT_STATE_PLOGI );break ;default : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received ABTS response for unknown frame %p" , iport);break ; }
@@ -4351,14 +4363,14 @@ fdls_process_plogi_req(struct fnic_iport_s *iport,sizeof (struct fc_std_els_rjt_rsp );if (iport->fcid != d_id) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received PLOGI with illegal frame bits. Dropping frame from 0x%x" , d_id);return ; }if (iport->state !=FNIC_IPORT_STATE_READY ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received PLOGI request in iport state: %d Dropping frame" , iport->state);return ;
@@ -4366,7 +4378,7 @@ fdls_process_plogi_req(struct fnic_iport_s *iport, frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send response to PLOGI request" );return ; }
@@ -4374,7 +4386,7 @@ fdls_process_plogi_req(struct fnic_iport_s *iport, pplogi_rsp = (struct fc_std_els_rjt_rsp *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET );fdls_init_els_rjt_frame (frame, iport); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: Process PLOGI request from SID: 0x%x" , iport->fcid,ntoh24 (fchdr->fh_s_id));
@@ -4404,11 +4416,11 @@ fdls_process_logo_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) nport_id =ntoh24 (logo->els.fl_n_port_id); nport_name =be64_to_cpu (logo->els.fl_n_port_wwn); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Process LOGO request from fcid: 0x%x" , nport_id);if (iport->state !=FNIC_IPORT_STATE_READY ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Dropping LOGO req from 0x%x in iport state: %d" , nport_id, iport->state);return ;
@@ -4418,19 +4430,19 @@ fdls_process_logo_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)if (!tport) {/* We are not logged in with the nport, log and drop... */ -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Received LOGO from an nport not logged in: 0x%x(0x%llx)" , nport_id, nport_name);return ; }if (tport->fcid != nport_id) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Received LOGO with invalid target port fcid: 0x%x(0x%llx)" , nport_id, nport_name);return ; }if (tport->timer_pending) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"tport fcid 0x%x: Canceling disc timer\n" , tport->fcid);fnic_del_tport_timer_sync (fnic, tport);
@@ -4447,7 +4459,7 @@ fdls_process_logo_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)if ((iport->state ==FNIC_IPORT_STATE_READY ) && (fdls_get_state (&iport->fabric) !=FDLS_STATE_SEND_GPNFT ) && (fdls_get_state (&iport->fabric) !=FDLS_STATE_RSCN_GPN_FT )) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Sending GPNFT in response to LOGO from Target:0x%x" , nport_id);fdls_send_gpn_ft (iport,FDLS_STATE_SEND_GPNFT );
@@ -4460,7 +4472,7 @@ fdls_process_logo_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)fdls_send_logo_resp (iport, &logo->fchdr);if ((fdls_get_state (&iport->fabric) !=FDLS_STATE_SEND_GPNFT ) && (fdls_get_state (&iport->fabric) !=FDLS_STATE_RSCN_GPN_FT )) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Sending GPNFT in response to LOGO from Target:0x%x" , nport_id);fdls_send_gpn_ft (iport,FDLS_STATE_SEND_GPNFT );
@@ -4487,11 +4499,11 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)atomic64_inc (&iport->iport_stats.num_rscns); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FDLS process RSCN %p" , iport);if (iport->state !=FNIC_IPORT_STATE_READY ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FDLS RSCN received in state(%d). Dropping" ,fdls_get_state (fdls));return ;
@@ -4508,18 +4520,18 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)if ((rscn_payload_len ==0xFFFF ) && (sid ==FC_FID_FCTRL )) { rscn_type =PC_RSCN ; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"pcrscn: PCRSCN received. sid: 0x%x payload len: 0x%x" , sid, rscn_payload_len); }else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RSCN payload_len: 0x%x page_len: 0x%x" , rscn_payload_len, rscn->els.rscn_page_len);/* if this happens then we need to send ADISC to all the tports. */ list_for_each_entry_safe (tport, next, &iport->tport_list, links) {if (tport->state ==FDLS_TGT_STATE_READY ) tport->flags |=FNIC_FDLS_TPORT_SEND_ADISC ; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RSCN for port id: 0x%x" , tport->fcid); } }/* end else */
@@ -4527,7 +4539,7 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) num_ports = (rscn_payload_len -4 ) / rscn->els.rscn_page_len; rscn_port = (struct fc_els_rscn_page *)(rscn +1 ); } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RSCN received for num_ports: %d payload_len: %d page_len: %d " , num_ports, rscn_payload_len, rscn->els.rscn_page_len);
@@ -4551,14 +4563,14 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)if (tport->state ==FDLS_TGT_STATE_READY ) tport->flags |=FNIC_FDLS_TPORT_SEND_ADISC ; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RSCN for port id: 0x%x" , tport->fcid); }break ; } tport =fnic_find_tport_by_fcid (iport, nport_id); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"RSCN port id list: 0x%x" , nport_id);if (!tport) {
@@ -4573,13 +4585,13 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) rscn_type == PC_RSCN && fnic->role == FNIC_ROLE_FCP_INITIATOR) {if (fnic->pc_rscn_handling_status ==PC_RSCN_HANDLING_IN_PROGRESS ) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"PCRSCN handling already in progress. Skip host reset: %d" , iport->fnic->fnic_num);return ; } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Processing PCRSCN. Queuing fnic for host reset: %d" , iport->fnic->fnic_num); fnic->pc_rscn_handling_status =PC_RSCN_HANDLING_IN_PROGRESS ;
@@ -4595,7 +4607,7 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)queue_work (reset_fnic_work_queue, &reset_fnic_work);spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); }else { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"FDLS process RSCN sending GPN_FT: newports: %d" , newports);fdls_send_gpn_ft (iport,FDLS_STATE_RSCN_GPN_FT );fdls_send_rscn_resp (iport, fchdr);
@@ -4644,20 +4656,20 @@ fdls_process_adisc_req(struct fnic_iport_s *iport,uint16_t acc_frame_size =FNIC_ETH_FCOE_HDRS_OFFSET +sizeof (struct fc_std_els_adisc ); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Process ADISC request %d" , iport->fnic->fnic_num); fcid =FNIC_STD_GET_S_ID (fchdr); tgt_fcid =ntoh24 (fcid); tport =fnic_find_tport_by_fcid (iport, tgt_fcid);if (!tport) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"tport for fcid: 0x%x not found. Dropping ADISC req." , tgt_fcid);return ; }if (iport->state !=FNIC_IPORT_STATE_READY ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Dropping ADISC req from fcid: 0x%x in iport state: %d" , tgt_fcid, iport->state);return ;
@@ -4668,16 +4680,16 @@ fdls_process_adisc_req(struct fnic_iport_s *iport,if ((frame_wwnn != tport->wwnn) || (frame_wwpn != tport->wwpn)) {/* send reject */ -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"ADISC req from fcid: 0x%x mismatch wwpn: 0x%llx wwnn: 0x%llx" , tgt_fcid, frame_wwpn, frame_wwnn); -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"local tport wwpn: 0x%llx wwnn: 0x%llx. Sending RJT" , tport->wwpn, tport->wwnn); rjt_frame =fdls_alloc_frame (iport);if (rjt_frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate rjt_frame to send response to ADISC request" );return ; }
@@ -4700,7 +4712,7 @@ fdls_process_adisc_req(struct fnic_iport_s *iport, acc_frame =fdls_alloc_frame (iport);if (acc_frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send ADISC accept" );return ; }
@@ -4754,7 +4766,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,/* some common validation */ if (fdls_get_state (fabric) >FDLS_STATE_FABRIC_FLOGI ) {if (iport->fcid != d_id || (!FNIC_FC_FRAME_CS_CTL (fchdr))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"invalid frame received. Dropping frame" );return -1 ; }
@@ -4764,14 +4776,14 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,if ((fchdr->fh_r_ctl ==FC_RCTL_BA_ACC ) || (fchdr->fh_r_ctl ==FC_RCTL_BA_RJT )) {if (!(FNIC_FC_FRAME_TYPE_BLS (fchdr))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received ABTS invalid frame. Dropping frame" );return -1 ; }if (fdls_is_oxid_fabric_req (oxid)) {if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received unexpected ABTS RSP(oxid:0x%x) from 0x%x. Dropping frame" , oxid, s_id);return -1 ;
@@ -4782,7 +4794,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, }else if (fdls_is_oxid_tgt_req (oxid)) {return FNIC_TPORT_BLS_ABTS_RSP ; } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received ABTS rsp with unknown oxid(0x%x) from 0x%x. Dropping frame" , oxid, s_id);return -1 ;
@@ -4791,7 +4803,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,/* BLS ABTS Req */ if ((fchdr->fh_r_ctl ==FC_RCTL_BA_ABTS ) && (FNIC_FC_FRAME_TYPE_BLS (fchdr))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Receiving Abort Request from s_id: 0x%x" , s_id);return FNIC_BLS_ABTS_REQ ; }
@@ -4803,7 +4815,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,if ((!FNIC_FC_FRAME_FCTL_FIRST_LAST_SEQINIT (fchdr)) || (!FNIC_FC_FRAME_UNSOLICITED (fchdr)) || (!FNIC_FC_FRAME_TYPE_ELS (fchdr))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received LOGO invalid frame. Dropping frame" );return -1 ; }
@@ -4812,12 +4824,12 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,if ((!FNIC_FC_FRAME_FCTL_FIRST_LAST_SEQINIT (fchdr)) || (!FNIC_FC_FRAME_TYPE_ELS (fchdr)) || (!FNIC_FC_FRAME_UNSOLICITED (fchdr))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received RSCN invalid FCTL. Dropping frame" );return -1 ; }if (s_id !=FC_FID_FCTRL ) -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received RSCN from target FCTL: 0x%x type: 0x%x s_id: 0x%x." , fchdr->fh_f_ctl[0 ], fchdr->fh_type, s_id);return FNIC_ELS_RSCN_REQ ;
@@ -4832,7 +4844,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,case ELS_RRQ :return FNIC_ELS_RRQ ;default : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Unsupported frame (type:0x%02x) from fcid: 0x%x" , type, s_id);return FNIC_ELS_UNSUPPORTED_REQ ;
@@ -4841,14 +4853,14 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,/* solicited response from fabric or target */ oxid_frame_type =FNIC_FRAME_TYPE (oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"oxid frame code: 0x%x, oxid: 0x%x\n" , oxid_frame_type, oxid);switch (oxid_frame_type) {case FNIC_FRAME_TYPE_FABRIC_FLOGI :if (type ==ELS_LS_ACC ) {if ((s_id !=FC_FID_FLOGI ) || (!FNIC_FC_FRAME_TYPE_ELS (fchdr))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received unknown frame. Dropping frame" );return -1 ; }
@@ -4859,7 +4871,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,if (type ==ELS_LS_ACC ) {if ((s_id !=FC_FID_DIR_SERV ) || (!FNIC_FC_FRAME_TYPE_ELS (fchdr))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received unknown frame. Dropping frame" );return -1 ; }
@@ -4870,7 +4882,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,if (type ==ELS_LS_ACC ) {if ((s_id !=FC_FID_FCTRL ) || (!FNIC_FC_FRAME_TYPE_ELS (fchdr))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received unknown frame. Dropping frame" );return -1 ; }
@@ -4879,7 +4891,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,case FNIC_FRAME_TYPE_FABRIC_RPN :if ((s_id !=FC_FID_DIR_SERV ) || (!FNIC_FC_FRAME_TYPE_FC_GS (fchdr))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received unknown frame. Dropping frame" );return -1 ; }
@@ -4887,7 +4899,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,case FNIC_FRAME_TYPE_FABRIC_RFT :if ((s_id !=FC_FID_DIR_SERV ) || (!FNIC_FC_FRAME_TYPE_FC_GS (fchdr))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received unknown frame. Dropping frame" );return -1 ; }
@@ -4895,7 +4907,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,case FNIC_FRAME_TYPE_FABRIC_RFF :if ((s_id !=FC_FID_DIR_SERV ) || (!FNIC_FC_FRAME_TYPE_FC_GS (fchdr))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received unknown frame. Dropping frame" );return -1 ; }
@@ -4903,7 +4915,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,case FNIC_FRAME_TYPE_FABRIC_GPN_FT :if ((s_id !=FC_FID_DIR_SERV ) || (!FNIC_FC_FRAME_TYPE_FC_GS (fchdr))) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received unknown frame. Dropping frame" );return -1 ; }
@@ -4925,7 +4937,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,return FNIC_TPORT_ADISC_RSP ;case FNIC_FRAME_TYPE_TGT_LOGO :if (!FNIC_FC_FRAME_TYPE_ELS (fchdr)) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Dropping Unknown frame in tport solicited exchange range type: 0x%x." , fchdr->fh_type);return -1 ;
@@ -4933,7 +4945,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,return FNIC_TPORT_LOGO_RSP ;default :/* Drop the Rx frame and log/stats it */ -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Solicited response: unknown OXID: 0x%x" , oxid);return -1 ; }
@@ -5003,7 +5015,7 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,break ;case FNIC_TPORT_LOGO_RSP :/* Logo response from tgt which we have deleted */ -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Logo response from tgt: 0x%x" ,ntoh24 (fchdr->fh_s_id));break ;
@@ -5046,9 +5058,9 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,fdls_process_fdmi_reg_ack (iport, fchdr, frame_type);break ;default : -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"s_id: 0x%x d_did: 0x%x" , s_id, d_id); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Received unknown FCoE frame of len: %d. Dropping frame" , len);break ; }
@@ -5065,7 +5077,7 @@ void fnic_fdls_link_down(struct fnic_iport_s *iport)struct fnic_tport_s *tport, *next;struct fnic *fnic = iport->fnic; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS processing link down" , iport->fcid);fdls_set_state ((&iport->fabric),FDLS_STATE_LINKDOWN );
@@ -5075,7 +5087,7 @@ void fnic_fdls_link_down(struct fnic_iport_s *iport)fnic_fcpio_reset (iport->fnic);spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags);list_for_each_entry_safe (tport, next, &iport->tport_list, links) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"removing rport: 0x%x" , tport->fcid);fdls_delete_tport (iport, tport); }
@@ -5088,6 +5100,6 @@ void fnic_fdls_link_down(struct fnic_iport_s *iport) iport->flags &= ~FNIC_FDMI_ACTIVE ; } -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x: FDLS finish processing link down" , iport->fcid); }
drivers/scsi/fnic/fip.c +54 -63
379 lines not on this page · raw message
drivers/scsi/fnic/fip.h +1 -1
@@ -142,7 +142,7 @@ fnic_debug_dump_fip_frame(struct fnic *fnic, struct ethhdr *eth,u16 op =be16_to_cpu (fiph->fip_op);u8 sub = fiph->fip_subcode; -FNIC_FCS_DBG (KERN_DEBUG , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_DEBUG , fnic,"FIP %s packet contents: op: 0x%x sub: 0x%x (len = %d)" , pfx, op, sub, len);
drivers/scsi/fnic/fnic.h +42 -34
2 lines not on this page · raw message
drivers/scsi/fnic/fnic_fcs.c +63 -63
126 lines not on this page · raw message
drivers/scsi/fnic/fnic_main.c +29 -27
56 lines not on this page · raw message
drivers/scsi/fnic/fnic_scsi.c +104 -106
210 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.47.1
Part of the diff is not shown here. View the raw message.
[email protected]
AI reviewRe: [PATCH v6 01/13] scsi: fnic: Make debug logging protocol independent
Thank you for your contribution! Sashiko AI review found 12 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 12 potential issue(s) to consider:
New issues:
- [Critical] Shared FCP/NVMe completion paths dereference fnic->host unconditionally, causing a panic in NVMe mode where the SCSI host is not instantiated.
- [Low] Type mismatch in the fnic_printk macro's conditional expression causes a hard compiler error.
Pre-existing issues:
- [High] Calling timer_delete_sync() on fdmi_timer while holding fnic->fnic_lock causes an AB-BA deadlock with the timer callback.
- [High] Dropping fnic->fnic_lock inside fnic_del_tport_timer_sync() exposes tport to concurrent deletion and freeing, leading to Use-After-Free.
- [High] Processing a crafted FIP VLAN response with a 0-length descriptor triggers an infinite loop.
- [High] Missing packet size validation allows a malicious fip_dl_len to cause out-of-bounds heap reads.
- [High] Concurrent modification of fnic->tx_queue causes linked list corruption.
- [High] If frame allocation fails in ABTS or FDMI send paths, the retry timer is not armed, causing discovery state machines to stall permanently.
- [High] Use-After-Free during tport_list iteration due to dropping list-protecting lock inside list_for_each_entry_safe().
- [High] Data race on shared struct member fnic->lock_flags during spin_lock_irqsave(), leading to incorrect IRQ restoration.
- [High] Buffer over-read in fdls_process_gpn_ft_tgt_list due to an unadjusted loop boundary.
- [High] Missing bounds check on rscn_plen in fdls_process_rscn allows reading past the end of the packet buffer.
--
--- Patch [1]: [PATCH v6 01/13] scsi: fnic: Make debug logging protocol independent --- commit 6ab638cfc2207fddc47d1f2bf78b1c2631f3d96a
Author: Karan Tilak Kumar <[email protected]>
scsi: fnic: Make debug logging protocol independent
This commit makes fnic debug macros take struct fnic instead of struct Scsi_Host so that FCP and NVMe initiator roles can share the logging interface. It adds fnic_printk() to handle routing the messages correctly depending on the role.
Quoted 4 lines
drivers/scsi/fnic/fnic.h +0
-0
[ ... ]
Quoted 10 lines
drivers/scsi/fnic/fnic.h +0
-6@@ -249,38 +255,39 @@ do { \ }while (0 ); \ }while (0 ) -#define FNIC_MAIN_DBG(kern_level, host, fnic_num, fmt, args...) \ - FNIC_CHECK_LOGGING(FNIC_MAIN_LOGGING, \ - shost_printk(kern_level, host, \ - "fnic<%d>: %s: %d: " fmt, fnic_num,\ - __func__, __LINE__, ##args);) -
[ ... ]
drivers/scsi/fnic/fnic.h do { \ · line 263
Quoted 6 lines
drivers/scsi/fnic/fnic.h +6
-0+#define fnic_printk (kern_level, fnic, fmt, ...) \ + (IS_FNIC_FCP_INITIATOR(fnic) ? \ + shost_printk(kern_level, fnic->host, "fnic<%d>: %s: %d: " fmt, \ + fnic->fnic_num, __func__, __LINE__, ##__VA_ARGS__) : \ + printk(kern_level "fnic<%d>: %s: %d: " fmt, fnic->fnic_num, \ + __func__, __LINE__, ##__VA_ARGS__))
[Severity: Low]
Does this ternary operator in fnic_printk cause a compiler error?
The true branch evaluates to shost_printk() which returns void (via dev_printk), while the false branch evaluates to printk() which returns int. C standards require both branches of a conditional operator to have compatible types. Could the printk branch be cast to (void) to fix this?
[ ... ]
drivers/scsi/fnic/fnic.h enum fnic_state { · line 336
Quoted 6 lines
drivers/scsi/fnic/fnic.h +1
-0@@ -325,6 +332,7 @@ enum fnic_state {enum fnic_role_e {FNIC_ROLE_FCP_INITIATOR =0 , +FNIC_ROLE_NVME_INITIATOR , };
[Severity: Critical]
With the introduction of the NVMe initiator role, fnic->host can be NULL. However, shared completion paths like fnic_fcpio_fw_reset_cmpl_handler() unconditionally call fnic_cleanup_io(), which then calls scsi_host_busy_iter(fnic->host, ...) and fnic_count_all_ioreqs().
Could this unconditionally dereference the NULL fnic->host pointer when running in NVMe mode, leading to a kernel panic?
drivers/scsi/fnic/fdls_disc.c void fdls_reclaim_oxid_handler(struct work_struct *work) · line 200
Quoted 13 lines
drivers/scsi/fnic/fdls_disc.c +1
-1@@ -194,7 +194,7 @@ void fdls_reclaim_oxid_handler(struct work_struct *work)struct reclaim_entry_s *reclaim_entry, *next;unsigned long delay_j, cur_jiffies; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Reclaim oxid callback\n" );spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags);
[Severity: High]
This isn't a bug introduced by this patch, but using the shared struct member fnic->lock_flags for spin_lock_irqsave() could result in a data race.
If two CPUs execute this concurrently, they will overwrite each other's saved interrupt state. Could this cause spin_unlock_irqrestore() to restore incorrect interrupt states, potentially leaving IRQs disabled incorrectly? It might be safer to use a local stack variable for the flags instead.
[ ... ]
drivers/scsi/fnic/fdls_disc.c static void fdls_send_fabric_abts(struct fnic_iport_s *iport) · line 693
Quoted 9 lines
drivers/scsi/fnic/fdls_disc.c +1
-1@@ -687,7 +687,7 @@ static void fdls_send_fabric_abts(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic,"Failed to allocate frame to send fabric ABTS" );return ; }
[Severity: High]
This is a pre-existing issue, but if fdls_alloc_frame() fails here and returns immediately, it skips arming the retry timer for the ABTS.
Will this cause the discovery state machine to stall permanently since no further events will drive it forward?
[ ... ]
drivers/scsi/fnic/fdls_disc.c
Quoted 11 lines
drivers/scsi/fnic/fdls_disc.c +1
-1@@ -2555,7 +2567,7 @@ fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport,case ELS_LS_ACC :atomic64_inc (&iport->iport_stats.tport_adisc_ls_accepts);if (tport->timer_pending) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport 0x%p Canceling fabric disc timer\n" , tport);fnic_del_tport_timer_sync (fnic, tport);drivers/scsi/fnic/fdls_disc.c +0
-0} tport->timer_pending =0 ;
[Severity: High]
This isn't a bug introduced by this patch, but dropping the fnic->fnic_lock inside fnic_del_tport_timer_sync() seems to expose tport to concurrent freeing.
If another thread (e.g. handling a link down) invokes fdls_delete_tport(), the tport could be freed before fnic_del_tport_timer_sync() returns. When the caller accesses tport->timer_pending = 0 upon return, could this lead to a use-after-free crash?
[ ... ]
drivers/scsi/fnic/fdls_disc.c fdls_process_gpn_ft_tgt_list(struct fnic_iport_s *iport, · line 3245
Quoted 12 lines
drivers/scsi/fnic/fdls_disc.c +1
-1@@ -3185,7 +3197,7 @@ fdls_process_gpn_ft_tgt_list(struct fnic_iport_s *iport, fcid =ntoh24 (gpn_ft_tgt->fcid); wwpn =be64_to_cpu (gpn_ft_tgt->wwpn); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"tport: 0x%x: ctrl:0x%x" , fcid, gpn_ft_tgt->ctrl);if (fcid == iport->fcid) {@@ -3232,7 +3244,7 @@ fdls_process_gpn_ft_tgt_list(struct fnic_iport_s *iport, rem_len -=sizeof (struct fc_gpn_ft_rsp_iu ); }
[Severity: High]
This is a pre-existing issue, but is the bounds check for rem_len correct?
In fdls_process_gpn_ft_tgt_list(), rem_len is initialized to the total length but is not reduced by the size of the FC and CT headers (40 bytes) when the pointer is advanced past them. Could the while (rem_len > 0) loop process memory past the physical buffer, leading to an out-of-bounds read if the list is not naturally terminated by the FC_NS_FID_LAST bit?
[ ... ]
drivers/scsi/fnic/fdls_disc.c fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, · line 3386
Quoted 9 lines
drivers/scsi/fnic/fdls_disc.c +1
-1@@ -3368,7 +3380,7 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, count =0 ;list_for_each_entry_safe (tport, next, &iport->tport_list, links) { -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"GPN_FT_REJECT: Remove port: 0x%x" , tport->fcid);fdls_delete_tport (iport, tport);
[Severity: High]
This is a pre-existing issue, but is there a use-after-free risk during this list iteration?
The loop uses list_for_each_entry_safe() and calls fdls_delete_tport(). Inside fdls_delete_tport(), fnic_lock is temporarily dropped to execute fnic_rport_exch_reset(). Since the lock is dropped, concurrent threads could remove and free the 'next' element. When the lock is reacquired and the loop continues, dereferencing 'next' might trigger a use-after-free.
[ ... ]
Quoted 6 lines
drivers/scsi/fnic/fdls_disc.c +1
-1@@ -3738,13 +3750,13 @@ static void fdls_process_fdmi_reg_ack(struct fnic_iport_s *iport,fdls_free_oxid (iport, oxid, &iport->active_oxid_fdmi_rpa); } - FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic,
drivers/scsi/fnic/fdls_disc.c static void fdls_process_fdmi_reg_ack(struct fnic_iport_s *iport, · line 3762
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +1
-1"iport fcid: 0x%x: Received FDMI registration ack\n" , iport->fcid);if (!iport->fabric.fdmi_pending) {timer_delete_sync (&iport->fabric.fdmi_timer); -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"iport fcid: 0x%x: Canceling FDMI timer\n" , iport->fcid); }
[Severity: High]
This is a pre-existing issue, but can calling timer_delete_sync() while holding the fnic->fnic_lock cause a deadlock here?
If the fdmi_timer expires concurrently, its callback fdls_fdmi_timer_callback() will spin waiting for fnic->fnic_lock, while timer_delete_sync() spins waiting for the callback to finish.
[ ... ]
drivers/scsi/fnic/fdls_disc.c fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) · line 4525
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c +1
-1@@ -4508,18 +4520,18 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)if ((rscn_payload_len ==0xFFFF ) && (sid ==FC_FID_FCTRL )) { rscn_type =PC_RSCN ; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"pcrscn: PCRSCN received. sid: 0x%x payload len: 0x%x" , sid, rscn_payload_len);
[Severity: High]
This is a pre-existing issue, but could an artificially large rscn_plen cause out-of-bounds memory reads?
The rscn_payload_len is trusted to calculate num_ports, but it doesn't appear to be cross-referenced against the actual length of the received Ethernet frame. Could a maliciously crafted short frame with a large rscn_plen trigger an out-of-bounds read?
Quoted 15 lines
drivers/scsi/fnic/fip.c +0
-6@@ -155,14 +152,14 @@ void fnic_fcoe_process_vlan_resp(struct fnic *fnic, struct fip_header *fiph)list_add_tail (&vlan->list, &fnic->vlan_list);break ; } -FNIC_FIP_DBG (KERN_INFO , fnic->host, - fnic->fnic_num, -"Invalid descriptor type(%x) in VLan response\n" , - vlan_desc->fd_desc.fip_dtype);/* -* Note : received a type=2 descriptor here i.e. FIP -* MAC Address Descriptor
drivers/scsi/fnic/fip.c void fnic_fcoe_process_vlan_resp(struct fnic *fnic, struct fip_header *fiph) · line 165
Quoted 10 lines
drivers/scsi/fnic/fip.c +6
-0+* Note : skip any type=2 descriptor here +* (i.e. FIP MAC Address Descriptor) */ +if (vlan_desc->fd_desc.fip_dtype !=FIP_DT_MAC ) +FNIC_FIP_DBG (KERN_INFO , fnic, +"Invalid descriptor type(0x%x) in vlan response\n" , + vlan_desc->fd_desc.fip_dtype); cur_desc += vlan_desc->fd_desc.fip_dlen; desc_len -= vlan_desc->fd_desc.fip_dlen; }
[Severity: High]
This isn't a bug introduced by this patch, but does the parser handle 0-length descriptors safely?
If a malicious FIP packet contains a descriptor where fip_dlen is 0, cur_desc and desc_len will remain unchanged when advancing. Could this lead to an infinite loop while holding the fnic->vlans_lock spinlock?
[ ... ]
Quoted 10 lines
drivers/scsi/fnic/fip.c +1
-1@@ -617,7 +609,7 @@ void fnic_fcoe_process_cvl(struct fnic *fnic, struct fip_header *fiph) || !((cvl_msg->name_desc.fd_desc.fip_dtype == 4) && (cvl_msg->name_desc.fd_desc.fip_dlen == 3))) { - FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic, "invalid mix: ft %x fl %x ndt %x ndl %x", cvl_msg->fcf_mac_desc.fd_desc.fip_dtype, cvl_msg->fcf_mac_desc.fd_desc.fip_dlen,
drivers/scsi/fnic/fip.c void fnic_fcoe_process_cvl(struct fnic *fnic, struct fip_header *fiph) · line 638
Quoted 9 lines
drivers/scsi/fnic/fip.c +1
-2@@ -640,8 +632,7 @@ void fnic_fcoe_process_cvl(struct fnic *fnic, struct fip_header *fiph)if (!((cvl_msg->vn_ports_desc[i].fd_desc.fip_dtype ==11 ) && (cvl_msg->vn_ports_desc[i].fd_desc.fip_dlen ==5 ))) { -FNIC_FIP_DBG (KERN_INFO , fnic->host, - fnic->fnic_num, +FNIC_FIP_DBG (KERN_INFO , fnic,"Invalid type and len mix type: %d len: %d\n" , cvl_msg->vn_ports_desc[i].fd_desc.fip_dtype, cvl_msg->vn_ports_desc[i].fd_desc.fip_dlen);
[Severity: High]
This is a pre-existing issue, but could the unvalidated fip_dl_len allow out-of-bounds heap reads?
The loop iterates based on the fip_dl_len field from the untrusted remote packet header, without verifying it against the actual received buffer size. An inflated length could cause the loop to read past the end of the packet buffer when accessing cvl_msg->vn_ports_desc[i].fd_mac.
drivers/scsi/fnic/fnic_fcs.c void fnic_flush_tx(struct work_struct *work) · line 784
Quoted 13 lines
drivers/scsi/fnic/fnic_fcs.c +1
-1@@ -778,7 +778,7 @@ void fnic_flush_tx(struct work_struct *work)struct fc_frame *fp;struct fnic_frame_list *cur_frame, *next; -FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic,"Flush queued frames" );list_for_each_entry_safe (cur_frame, next, &fnic->tx_queue, links) {
[Severity: High]
This is a pre-existing issue, but is it safe to iterate and modify fnic->tx_queue without acquiring any locks here?
Concurrently, fdls_send_fcoe_frame() adds new frames to tx_queue. If these run at the same time, could it corrupt the linked list?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Karan Tilak Kumar
maintainerPATCH v6 2/13 scsi: fnic: Use fnic_num for non-SCSI identifiers
In reply to Karan Tilak KumarUse SCSI host numbers only for FCP initiator paths.
Name NVMe-facing FDMI and debugfs entries with fnic_num, and record trace events with the driver instance number.
--- drivers/scsi/fnic/fdls_disc.c | 8 ++++++-- drivers/scsi/fnic/fnic_debugfs.c | 5 ++++- drivers/scsi/fnic/fnic_scsi.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-)
drivers/scsi/fnic/fdls_disc.c +6 -2
@@ -2083,8 +2083,12 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport)fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_MAX_FRAME_SIZE ,FNIC_FDMI_MFS_LEN , data, &attr_off_bytes); -snprintf (tmp_data,FNIC_FDMI_OS_NAME_LEN -1 ,"host%d" , - fnic->host->host_no); +if (IS_FNIC_FCP_INITIATOR (fnic)) +snprintf (tmp_data,FNIC_FDMI_OS_NAME_LEN -1 ,"host%d" , + fnic->host->host_no); +else if (IS_FNIC_NVME_INITIATOR (fnic)) +snprintf (tmp_data,FNIC_FDMI_OS_NAME_LEN -1 ,"nvfnic%d" , + fnic->fnic_num);strscpy_pad (data, tmp_data,FNIC_FDMI_OS_NAME_LEN );fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_OS_NAME ,FNIC_FDMI_OS_NAME_LEN , data, &attr_off_bytes);
drivers/scsi/fnic/fnic_debugfs.c +4 -1
@@ -681,7 +681,10 @@ int fnic_stats_debugfs_init(struct fnic *fnic) {char name[16 ]; -snprintf (name,sizeof (name),"host%d" , fnic->host->host_no); +if (IS_FNIC_FCP_INITIATOR (fnic)) +snprintf (name,sizeof (name),"host%d" , fnic->host->host_no); +else if (IS_FNIC_NVME_INITIATOR (fnic)) +snprintf (name,sizeof (name),"nvfnic%d" , fnic->fnic_num); fnic->fnic_stats_debugfs_host =debugfs_create_dir (name, fnic_stats_debugfs_root);
drivers/scsi/fnic/fnic_scsi.c +1 -1
@@ -894,7 +894,7 @@ static inline void fnic_fcpio_ack_handler(struct fnic *fnic,spin_unlock_irqrestore (&fnic->wq_copy_lock[wq_index], flags);FNIC_TRACE (fnic_fcpio_ack_handler, - fnic->host->host_no,0 ,0 , ox_id_tag[2 ], ox_id_tag[3 ], + fnic->fnic_num,0 ,0 , ox_id_tag[2 ], ox_id_tag[3 ], ox_id_tag[4 ], ox_id_tag[5 ]); }
Signature · 1 line
2.47.1
[email protected]
AI reviewRe: [PATCH v6 02/13] scsi: fnic: Use fnic_num for non-SCSI identifiers
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Unconditional use of `fnic_num` in `fnic_fcpio_ack_handler` trace breaks FCP trace event…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Unconditional use of fnic_num in fnic_fcpio_ack_handler trace breaks FCP trace event correlation because other FCP events still use host_no. --
--- Patch [2]: [PATCH v6 02/13] scsi: fnic: Use fnic_num for non-SCSI identifiers --- commit 475f57f36329cdc1feb8aebc23e707d1a0bd9828
Author: Karan Tilak Kumar <[email protected]>
scsi: fnic: Use fnic_num for non-SCSI identifiers
This commit replaces the use of SCSI host numbers with driver instance numbers (fnic_num) for NVMe-facing entries and trace events. It explicitly updates the fnic_fcpio_ack_handler trace event to use the fnic_num.
[ ... ]
drivers/scsi/fnic/fnic_scsi.c static inline void fnic_fcpio_ack_handler(struct fnic *fnic, · line 897
Quoted 10 lines
drivers/scsi/fnic/fnic_scsi.c +1
-1@@ -894,7 +894,7 @@ static inline void fnic_fcpio_ack_handler(struct fnic *fnic,spin_unlock_irqrestore (&fnic->wq_copy_lock[wq_index], flags); FNIC_TRACE(fnic_fcpio_ack_handler, - fnic->host->host_no, 0, 0, ox_id_tag[2], ox_id_tag[3], + fnic->fnic_num, 0, 0, ox_id_tag[2], ox_id_tag[3],
[Severity: Medium]
Does changing this trace to unconditionally use fnic->fnic_num break FCP trace event correlation?
Other FCP trace events, such as the one in fnic_queuecommand(), still use the SCSI host number (sc->device->host->host_no). Because host_index_ida and fnic_ida are independent ID allocators, these numbers will differ on systems with other SCSI controllers.
If a user or tool filters FCP IO traces by host number, will they see the IO submission and completion events, but miss this firmware ACK event because it is now logged under the driver instance number instead?
Quoted 3 lines
drivers/scsi/fnic/fnic_scsi.c +0
-0ox_id_tag[4], ox_id_tag[5]); }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Karan Tilak Kumar
maintainerPATCH v6 3/13 scsi: fnic: Decode firmware role configuration
In reply to Karan Tilak KumarAdd FNIC_ROLE_CONFIG_MASK and use it to decode firmware role bits when reading vNIC configuration and probing the PCI device.
Accept FCP and NVMe initiator roles, report FC target and FC-NVMe target
roles explicitly as unsupported, and keep truly undefined role settings on the existing FC initiator default path.
Log the configured role flags and expose role names for trace output.
---
Incorporate review comments from Hannes:
Decode target roles explicitly and report unsupported roles.
Changes between v3 and v4:
Incorporate review comments from Sashiko:
Keep role strings private and const
--- drivers/scsi/fnic/fnic.h | 1 + drivers/scsi/fnic/fnic_main.c | 23 +++++++++++++++++++++-- drivers/scsi/fnic/fnic_res.c | 29 +++++++++++++++++++++++++++-- drivers/scsi/fnic/fnic_trace.c | 3 ++- 4 files changed, 51 insertions(+), 5 deletions(-)
drivers/scsi/fnic/fnic.h +1 -0
@@ -43,6 +43,7 @@#define FNIC_DFLT_QUEUE_DEPTH 256#define FNIC_STATS_RATE_LIMIT 4/* limit rate at which stats are pulled up */ #define LUN0_DELAY_TIME 9 +#define FNIC_ROLE_CONFIG_MASK (0xFF0)/* * Tag bits used for special requests.
drivers/scsi/fnic/fnic_main.c +21 -2
@@ -844,7 +844,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_out_fnic_get_config; } -switch (fnic->config.flags &0xff0 ) { +switch (fnic->config.flags &FNIC_ROLE_CONFIG_MASK ) {case VFCF_FC_INITIATOR : { host =
@@ -863,8 +863,27 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) fnic->fnic_num); }break ; +case VFCF_FC_TARGET : +dev_info (&fnic->pdev->dev, +"fnic: %d is scsi target\n" , + fnic->fnic_num); + err = -EOPNOTSUPP ; + goto err_out_fnic_role; +case VFCF_FC_NVME_INITIATOR : + fnic->role =FNIC_ROLE_NVME_INITIATOR ; +dev_info (&fnic->pdev->dev,"fnic: %d is NVME initiator\n" , + fnic->fnic_num); +break ; +case VFCF_FC_NVME_TARGET : +dev_info (&fnic->pdev->dev, +"fnic: %d is NVME target\n" , + fnic->fnic_num); + err = -EOPNOTSUPP ; + goto err_out_fnic_role;default : -dev_info (&fnic->pdev->dev,"fnic: %d has no role defined\n" , fnic->fnic_num); +dev_info (&fnic->pdev->dev, +"fnic: %d has no role defined (0x%x)\n" , + fnic->fnic_num, fnic->config.flags &FNIC_ROLE_CONFIG_MASK ); err = -EINVAL ; goto err_out_fnic_role; }
drivers/scsi/fnic/fnic_res.c +27 -2
@@ -22,6 +22,7 @@int fnic_get_vnic_config (struct fnic *fnic) {struct vnic_fc_config *c = &fnic->config; +u32 role;int err;#define GET_CONFIG (m) \
@@ -58,9 +59,31 @@ int fnic_get_vnic_config(struct fnic *fnic)GET_CONFIG (intr_mode);GET_CONFIG (wq_copy_count); -if ((c->flags & (VFCF_FC_INITIATOR )) ==0 ) { -dev_info (&fnic->pdev->dev,"vNIC role not defined (def role: FC Init)\n" ); + role = c->flags &FNIC_ROLE_CONFIG_MASK ; +switch (role) { +case 0 : +dev_info (&fnic->pdev->dev, +"vNIC role not defined (def role: FC Init)\n" ); c->flags |=VFCF_FC_INITIATOR ; +break ; +case VFCF_FC_INITIATOR : +case VFCF_FC_NVME_INITIATOR : +break ; +case VFCF_FC_TARGET : +dev_info (&fnic->pdev->dev, +"vNIC role is FC Target (unsupported)\n" ); +break ; +case VFCF_FC_NVME_TARGET : +dev_info (&fnic->pdev->dev, +"vNIC role is FC-NVMe Target (unsupported)\n" ); +break ; +default : +dev_info (&fnic->pdev->dev, +"vNIC role not supported (0x%x), defaulting to FC Init\n" , + role); + c->flags &= ~FNIC_ROLE_CONFIG_MASK ; + c->flags |=VFCF_FC_INITIATOR ; +break ; } c->wq_enet_desc_count =
@@ -163,6 +186,8 @@ int fnic_get_vnic_config(struct fnic *fnic) c->port_down_io_retries, c->port_down_timeout);dev_info (&fnic->pdev->dev,"fNIC wq_copy_count: %d\n" , c->wq_copy_count);dev_info (&fnic->pdev->dev,"fNIC intr mode: %d\n" , c->intr_mode); +dev_info (&fnic->pdev->dev,"fNIC role flags: 0x%x\n" , + (c->flags &FNIC_ROLE_CONFIG_MASK ));return 0 ; }
drivers/scsi/fnic/fnic_trace.c +2 -1
@@ -31,7 +31,8 @@ int fnic_fc_trace_cleared = 1;static DEFINE_SPINLOCK (fnic_fc_trace_lock);static const char *const fnic_role_str[] = { - [FNIC_ROLE_FCP_INITIATOR ] ="FCP_Initiator" , + [FNIC_ROLE_FCP_INITIATOR ] ="FCP_Initiator" , + [FNIC_ROLE_NVME_INITIATOR ] ="NVMeF_Initiator" , };const char *fnic_role_to_str (unsigned int role)
Signature · 1 line
2.47.1
[email protected]
AI reviewRe: [PATCH v6 03/13] scsi: fnic: Decode firmware role configuration
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Probing a device configured as an NVMe initiator causes guaranteed NULL/invalid pointer…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Probing a device configured as an NVMe initiator causes guaranteed NULL/invalid pointer dereferences because fnic->host is never allocated. --
--- Patch [3]: [PATCH v6 03/13] scsi: fnic: Decode firmware role configuration --- commit 59ee4f0111b49617d84eeb07cca8bec4e3b8d757
Author: Karan Tilak Kumar <[email protected]>
scsi: fnic: Decode firmware role configuration
This commit adds FNIC_ROLE_CONFIG_MASK to decode firmware role bits when reading vNIC configuration. It accepts FCP and NVMe initiator roles, reports target roles as unsupported, and logs the configured role flags.
Quoted 4 lines
drivers/scsi/fnic/fnic_main.c +0
-0
[ ... ]
Quoted 5 lines
drivers/scsi/fnic/fnic_main.c +1
-0@@ -863,8 +863,27 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) fnic->fnic_num); }break ; +case VFCF_FC_TARGET :
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 876
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +10
-0+dev_info (&fnic->pdev->dev, +"fnic: %d is scsi target\n" , + fnic->fnic_num); + err = -EOPNOTSUPP ; + goto err_out_fnic_role; +case VFCF_FC_NVME_INITIATOR : + fnic->role =FNIC_ROLE_NVME_INITIATOR ; +dev_info (&fnic->pdev->dev,"fnic: %d is NVME initiator\n" , + fnic->fnic_num); +break ;
[Severity: High]
If a device is configured as an NVMe initiator, this case breaks out of the switch block without allocating fnic->host (unlike the VFCF_FC_INITIATOR case). Could this cause a NULL pointer dereference later on?
For example, if an error occurs shortly after this in fnic_probe(), the teardown path unconditionally calls:
err_out_fnic_set_intr_mode:
scsi_host_put(fnic->host);
Since scsi_host_put() resolves the host pointer internally, passing NULL results in an invalid offset pointer passed to put_device(), crashing the kernel.
Additionally, does the success path unconditionally dereference the unallocated host in fnic_scsi_drv_init()?
fnic_probe() -> fnic_scsi_drv_init() {
...
if (fnic->config.io_throttle_count != FNIC_UCSM_DFLT_THROTTLE_CNT_BLD)
host->can_queue = min_t(u32, FNIC_MAX_IO_REQ, ...);
...
}Quoted 7 lines
drivers/scsi/fnic/fnic_main.c +6
-0+case VFCF_FC_NVME_TARGET : +dev_info (&fnic->pdev->dev, +"fnic: %d is NVME target\n" , + fnic->fnic_num); + err = -EOPNOTSUPP ; + goto err_out_fnic_role;default :
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Karan Tilak Kumar
maintainerPATCH v6 4/13 scsi: fnic: Advertise NVMe initiator service parameters
In reply to Karan Tilak KumarSet FC service parameters according to the selected initiator role.
Keep FCP retry and confirmation bits for FCP initiators, and advertise NVMe initiator and SLER bits for NVMe initiators.
--- drivers/scsi/fnic/fdls_fc.h | 3 +++ drivers/scsi/fnic/fnic_main.c | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-)
drivers/scsi/fnic/fdls_fc.h +3 -0
@@ -39,6 +39,9 @@#define FNIC_FCP_SP_CONF_CMPL 0x00000080#define FNIC_FCP_SP_RETRY 0x00000100 +#define FNIC_NVME_SP_INITIATOR 0x00000020 +#define FNIC_NVME_SP_SLER 0x00000100 +#define FNIC_FC_CONCUR_SEQS (0xFF)#define FNIC_FC_RO_INFO (0x1F)
drivers/scsi/fnic/fnic_main.c +10 -5
@@ -1016,11 +1016,16 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) iport->max_flogi_retries = fnic->config.flogi_retries; iport->max_plogi_retries = fnic->config.plogi_retries; iport->plogi_timeout = fnic->config.plogi_timeout; - iport->service_params = - (FNIC_FCP_SP_INITIATOR |FNIC_FCP_SP_RD_XRDY_DIS | -FNIC_FCP_SP_CONF_CMPL ); -if (fnic->config.flags &VFCF_FCP_SEQ_LVL_ERR ) - iport->service_params |=FNIC_FCP_SP_RETRY ; +if (IS_FNIC_FCP_INITIATOR (fnic)) { + iport->service_params = (FNIC_FCP_SP_INITIATOR | +FNIC_FCP_SP_RD_XRDY_DIS |FNIC_FCP_SP_CONF_CMPL ); +if (fnic->config.flags &VFCF_FCP_SEQ_LVL_ERR ) + iport->service_params |=FNIC_FCP_SP_RETRY ; + }else if (IS_FNIC_NVME_INITIATOR (fnic)) { + iport->service_params = (FNIC_NVME_SP_INITIATOR ); +if (fnic->config.flags &VFCF_FCP_SEQ_LVL_ERR ) + iport->service_params |=FNIC_NVME_SP_SLER ; + } iport->boot_time = jiffies; iport->e_d_tov = fnic->config.ed_tov;
Signature · 1 line
2.47.1
[email protected]
AI reviewRe: [PATCH v6 04/13] scsi: fnic: Advertise NVMe initiator service parameters
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The commit sets `iport->service_params` to advertise NVMe initiator service parameters, but this…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The commit sets iport->service_params to advertise NVMe initiator service parameters, but this field is never read. The actual PRLI frame is hardcoded to advertise FCP capabilities instead. --
--- Patch [4]: [PATCH v6 04/13] scsi: fnic: Advertise NVMe initiator service parameters --- commit ed8174a20b4f25dad8815dfbe2e3def2feb4906c
Author: Karan Tilak Kumar <[email protected]>
scsi: fnic: Advertise NVMe initiator service parameters
This commit sets FC service parameters according to the selected initiator role. It keeps FCP retry and confirmation bits for FCP initiators, and advertises NVMe initiator and SLER bits for NVMe initiators.
Quoted 13 lines
drivers/scsi/fnic/fnic_main.c +0
-5@@ -1016,11 +1016,16 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) iport->max_flogi_retries = fnic->config.flogi_retries; iport->max_plogi_retries = fnic->config.plogi_retries; iport->plogi_timeout = fnic->config.plogi_timeout; - iport->service_params = - (FNIC_FCP_SP_INITIATOR |FNIC_FCP_SP_RD_XRDY_DIS | -FNIC_FCP_SP_CONF_CMPL ); -if (fnic->config.flags &VFCF_FCP_SEQ_LVL_ERR ) - iport->service_params |=FNIC_FCP_SP_RETRY ;
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 1028
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +10
-0+if (IS_FNIC_FCP_INITIATOR (fnic)) { + iport->service_params = (FNIC_FCP_SP_INITIATOR | +FNIC_FCP_SP_RD_XRDY_DIS |FNIC_FCP_SP_CONF_CMPL ); +if (fnic->config.flags &VFCF_FCP_SEQ_LVL_ERR ) + iport->service_params |=FNIC_FCP_SP_RETRY ; + }else if (IS_FNIC_NVME_INITIATOR (fnic)) { + iport->service_params = (FNIC_NVME_SP_INITIATOR ); +if (fnic->config.flags &VFCF_FCP_SEQ_LVL_ERR ) + iport->service_params |=FNIC_NVME_SP_SLER ; + }
[Severity: High]
Is iport->service_params actually used when sending the PRLI request?
Looking at fdls_send_tgt_prli() in drivers/scsi/fnic/fdls_disc.c, it appears the PRLI payload hardcodes the FCP parameters directly:
.sp = {.spp_type = 0x08, .spp_flags = 0x0020,
.spp_params = cpu_to_be32(0xA2)}If the service_params field is ignored, will the NVMe initiator feature fall back to advertising FCP capabilities (type 0x08) instead of NVMe, preventing successful discovery and login for NVMe targets?
Quoted 3 lines
drivers/scsi/fnic/fnic_main.c +0
-0iport->boot_time = jiffies; iport->e_d_tov = fnic->config.ed_tov;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Karan Tilak Kumar
maintainerPATCH v6 5/13 scsi: fnic: Add FDLS role handling for NVMe initiators
In reply to Karan Tilak KumarModify FDLS registration and discovery flows to use NVMe FC-4 type, features, PRLI service parameters, and FDMI attributes when the adapter runs as an NVMe initiator.
Limit SCSI host setup, teardown, rport reset, and FC host notifications to FCP initiators while keeping target-port events available to both FCP
and NVMe roles.
--- drivers/scsi/fnic/fcpio.h | 23 +++++ drivers/scsi/fnic/fdls_disc.c | 160 +++++++++++++++++++++++----------- drivers/scsi/fnic/fdls_fc.h | 1 + drivers/scsi/fnic/fnic_fcs.c | 26 +++--- drivers/scsi/fnic/fnic_fdls.h | 19 ++-- drivers/scsi/fnic/fnic_main.c | 23 +++-- drivers/scsi/fnic/fnic_scsi.c | 3 +- 7 files changed, 177 insertions(+), 78 deletions(-)
drivers/scsi/fnic/fcpio.h +23 -0
@@ -33,6 +33,9 @@ enum fcpio_type {FCPIO_ICMND_CMPL ,FCPIO_ITMF ,FCPIO_ITMF_CMPL , +FCPIO_NVME_CMD , +FCPIO_NVME_ERSP_HW_CMPL , +FCPIO_NVME_ERSP_FW_CMPL ,/* * Target request types
@@ -179,10 +182,22 @@ fcpio_header_dec(struct fcpio_header *hdr, *tag = hdr->tag; } +#define NVME_CMD_SZ 96#define CDB_16 16#define CDB_32 32#define LUN_ADDRESS 8 +struct fcpio_nvme_cmnd { +uint8_t d_id[3 ]; +u_int8_t flags;/* command flags */ +u_int32_t sgl_cnt;/* scatter-gather list count */ +u_int64_t sgl_addr;/* scatter-gather list addr */ +u_int16_t cmd_len; +u_int16_t _resvd1;/* reserved: should be 0 */ +u_int32_t data_len;/* length of data expected */ +u_int8_t nvme_cmnd[NVME_CMD_SZ ];/* NVME command */ +}; +/* * fcpio_icmnd_16: host -> firmware request *
@@ -458,6 +473,7 @@ struct fcpio_host_req {/* * Initiator host requests */ +struct fcpio_nvme_cmnd nvcmnd;struct fcpio_icmnd_16 icmnd_16;struct fcpio_icmnd_32 icmnd_32;struct fcpio_itmf itmf;
@@ -482,6 +498,12 @@ struct fcpio_host_req { } u; }; +struct fcpio_nvme_cmpl { +uint8_t resp_size; +uint8_t resvd[3 ]; +uint8_t resp_bytes[32 ]; +}; +/* * fcpio_icmnd_cmpl: firmware -> host response *
@@ -682,6 +704,7 @@ struct fcpio_fw_req {* Initiator firmware responses */ struct fcpio_icmnd_cmpl icmnd_cmpl; +struct fcpio_nvme_cmpl nvme_cmpl;struct fcpio_itmf_cmpl itmf_cmpl;/*
drivers/scsi/fnic/fdls_disc.c +110 -50
281 lines not on this page · raw message
drivers/scsi/fnic/fdls_fc.h +1 -0
@@ -53,6 +53,7 @@#define FNIC_FCP_RSP_FCTL (0x000099)#define FNIC_REQ_ABTS_FCTL (0x000009) +#define FNIC_NVME_LS_REQ_FCTL (0x000029)#define FNIC_FC_PH_VER_HI (0x20)#define FNIC_FC_PH_VER_LO (0x20)
drivers/scsi/fnic/fnic_fcs.c +15 -11
@@ -1018,7 +1018,8 @@ void fnic_delete_fcp_tports(struct fnic *fnic) "removing fcp rport fcid: 0x%x", tport->fcid);fdls_set_tport_state (tport,FDLS_TGT_STATE_OFFLINING );fnic_del_tport_timer_sync (fnic, tport); -fnic_fdls_remove_tport (&fnic->iport, tport, flags); +if (IS_FNIC_FCP_INITIATOR (fnic)) +fnic_fdls_remove_tport (&fnic->iport, tport, flags); }spin_unlock_irqrestore (&fnic->fnic_lock, flags); }
@@ -1044,8 +1045,8 @@ void fnic_tport_event_handler(struct work_struct *work)FNIC_FCS_DBG (KERN_INFO , fnic,"Add rport event" );if (tport->state ==FDLS_TGT_STATE_READY ) { -fnic_fdls_add_tport (&fnic->iport, - (struct fnic_tport_s *) cur_evt->arg1, flags); +if (IS_FNIC_FCP_INITIATOR (fnic)) +fnic_fdls_add_tport (&fnic->iport, tport, flags); }else { FNIC_FCS_DBG(KERN_INFO, fnic, "Target not ready. Add rport event dropped: 0x%x",
@@ -1056,8 +1057,8 @@ void fnic_tport_event_handler(struct work_struct *work)FNIC_FCS_DBG (KERN_INFO , fnic,"Remove rport event" );if (tport->state ==FDLS_TGT_STATE_OFFLINING ) { -fnic_fdls_remove_tport (&fnic->iport, - (struct fnic_tport_s *) cur_evt->arg1, flags); +if (IS_FNIC_FCP_INITIATOR (fnic)) +fnic_fdls_remove_tport (&fnic->iport, tport, flags); }else { FNIC_FCS_DBG(KERN_INFO, fnic, "remove rport event dropped tport fcid: 0x%x",
@@ -1110,12 +1111,15 @@ void fnic_reset_work_handler(struct work_struct *work)spin_unlock_irqrestore (&reset_fnic_list_lock, reset_fnic_list_lock_flags); -dev_err (&cur_fnic->pdev->dev,"fnic: <%d>: issuing a host reset\n" , - cur_fnic->fnic_num); - host_reset_ret_code =fnic_host_reset (cur_fnic->host); -dev_err (&cur_fnic->pdev->dev, -"fnic: <%d>: returned from host reset with status: %d\n" , - cur_fnic->fnic_num, host_reset_ret_code); +if (IS_FNIC_FCP_INITIATOR (cur_fnic)) { +dev_err (&cur_fnic->pdev->dev, +"fnic: <%d>: issuing a host reset\n" , + cur_fnic->fnic_num); + host_reset_ret_code =fnic_host_reset (cur_fnic->host); +dev_err (&cur_fnic->pdev->dev, +"fnic: <%d>: returned from host reset with status: %d\n" , + cur_fnic->fnic_num, host_reset_ret_code); + }spin_lock_irqsave (&cur_fnic->fnic_lock, cur_fnic->lock_flags); cur_fnic->pc_rscn_handling_status =
drivers/scsi/fnic/fnic_fdls.h +11 -8
@@ -78,14 +78,17 @@#define FNIC_FDLS_FPMA_LEARNT 0x2/* tport flags */ -#define FNIC_FDLS_TPORT_IN_GPN_FT_LIST 0x1 -#define FNIC_FDLS_TGT_ABORT_ISSUED 0x2 -#define FNIC_FDLS_TPORT_SEND_ADISC 0x4 -#define FNIC_FDLS_RETRY_FRAME 0x8 -#define FNIC_FDLS_TPORT_BUSY 0x10 -#define FNIC_FDLS_TPORT_TERMINATING 0x20 -#define FNIC_FDLS_TPORT_DELETED 0x40 -#define FNIC_FDLS_SCSI_REGISTERED 0x200 +#define FNIC_FDLS_TPORT_IN_GPN_FT_LIST 0x1 +#define FNIC_FDLS_TGT_ABORT_ISSUED 0x2 +#define FNIC_FDLS_TPORT_SEND_ADISC 0x4 +#define FNIC_FDLS_RETRY_FRAME 0x8 +#define FNIC_FDLS_TPORT_BUSY 0x10 +#define FNIC_FDLS_TPORT_TERMINATING 0x20 +#define FNIC_FDLS_TPORT_DELETED 0x40 +#define FNIC_FDLS_NVME_REGISTERED 0x80 +#define FNIC_FDLS_NVME_TPORT_CLEANUP_PENDING 0x100 +#define FNIC_FDLS_SCSI_REGISTERED 0x200 +#define FNIC_TPORT_CAN_BE_FREED 0x400/* Retry supported by rport(returned by prli service parameters) */ #define FDLS_FC_RP_FLAGS_RETRY 0x1
drivers/scsi/fnic/fnic_main.c +15 -8
@@ -1087,9 +1087,11 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)fnic_fdls_init (fnic, (fnic->config.flags &VFCF_FIP_CAPABLE )); - err =fnic_scsi_drv_init (fnic); -if (err) - goto err_out_scsi_drv_init; +if (IS_FNIC_FCP_INITIATOR (fnic)) { + err =fnic_scsi_drv_init (fnic); +if (err) + goto err_out_scsi_drv_init; + } err =fnic_stats_debugfs_init (fnic);if (err) {
@@ -1109,7 +1111,8 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_out_free_stats_debugfs:fnic_stats_debugfs_remove (fnic);fnic_free_ioreq_tables_mq (fnic); -scsi_remove_host (fnic->host); +if (IS_FNIC_FCP_INITIATOR (fnic)) +scsi_remove_host (fnic->host); err_out_scsi_drv_init:fnic_free_intr (fnic); err_out_fnic_request_intr:
@@ -1135,7 +1138,8 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_out_fnic_alloc_vnic_res:fnic_clear_intr_mode (fnic); err_out_fnic_set_intr_mode: -scsi_host_put (fnic->host); +if (IS_FNIC_FCP_INITIATOR (fnic)) +scsi_host_put (fnic->host); err_out_fnic_role: err_out_scsi_host_alloc: err_out_fnic_get_config:
@@ -1184,7 +1188,8 @@ static void fnic_remove(struct pci_dev *pdev)*/ flush_workqueue (fnic_event_queue); -fnic_scsi_unload (fnic); +if (IS_FNIC_FCP_INITIATOR (fnic)) +fnic_scsi_unload (fnic);if (vnic_dev_get_intr_mode (fnic->vdev) ==VNIC_DEV_INTR_MODE_MSI )timer_delete_sync (&fnic->notify_timer);
@@ -1228,8 +1233,10 @@ static void fnic_remove(struct pci_dev *pdev)pci_disable_device (pdev);pci_set_drvdata (pdev,NULL );ida_free (&fnic_ida, fnic->fnic_num); -fnic_scsi_unload_cleanup (fnic); -scsi_host_put (fnic->host); +if (IS_FNIC_FCP_INITIATOR (fnic)) { +fnic_scsi_unload_cleanup (fnic); +scsi_host_put (fnic->host); + }kfree (fnic); }
drivers/scsi/fnic/fnic_scsi.c +2 -1
@@ -732,7 +732,8 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic,atomic64_inc (&reset_stats->fw_reset_completions);/* Clean up all outstanding io requests */ -fnic_cleanup_io (fnic,SCSI_NO_TAG ); +if (IS_FNIC_FCP_INITIATOR (fnic)) +fnic_cleanup_io (fnic,SCSI_NO_TAG );atomic64_set (&fnic->fnic_stats.fw_stats.active_fw_reqs,0 );atomic64_set (&fnic->fnic_stats.io_stats.active_ios,0 );
Signature · 1 line
2.47.1
[email protected]
AI reviewRe: [PATCH v6 05/13] scsi: fnic: Add FDLS role handling for NVMe initiators
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
New issues:
- [Critical] Skipping teardown steps for NVMe initiators in fnic_remove leaks all target-ports and their retry timers, leading to a Use-After-Free.
- [Critical] Target-port ADD and DEL events are queued for NVMe initiators but are silently dropped by the worker thread, preventing target registration.
- [High] NVMe target capability check incorrectly uses the FCP target mode bit, rejecting valid NVMe Discovery Controllers.
- [High] FC-NVMe PRLI request FCoE frames are truncated by 4 bytes, causing a payload length mismatch.
Pre-existing issues:
- [High] Target ports are permanently leaked as zombies if memory allocation fails in fdls_delete_tport.
- [High] Dropping the list lock inside a list_for_each_entry_safe loop creates a Use-After-Free race condition if the next element is removed.
- [High] Missing length validation on untrusted incoming FCoE ELS frames leads to out-of-bounds reads on uninitialized or stale DMA memory. --
--- Patch [5]: [PATCH v6 05/13] scsi: fnic: Add FDLS role handling for NVMe initiators --- commit 293db6e248353f1832c4c547c9d5f992bf5f84e6
Author: Karan Tilak Kumar <[email protected]>
scsi: fnic: Add FDLS role handling for NVMe initiators
Modify FDLS registration and discovery flows to use NVMe FC-4 type, features, PRLI service parameters, and FDMI attributes when the adapter runs as an NVMe initiator. Limit SCSI host setup, teardown, rport reset, and FC host notifications to FCP initiators while keeping target-port events available to both FCP and NVMe roles.
Quoted 4 lines
drivers/scsi/fnic/fdls_disc.c +0
-0
[ ... ]
Quoted 9 lines
drivers/scsi/fnic/fdls_disc.c +2
-3@@ -1264,11 +1284,14 @@ bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport) tport->timer_pending =0 ; } -spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); -fnic_rport_exch_reset (iport->fnic, tport->fcid); -spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); +if (IS_FNIC_FCP_INITIATOR (fnic)) { +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags);
drivers/scsi/fnic/fdls_disc.c bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport) · line 1297
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +5
-1+fnic_rport_exch_reset (iport->fnic, tport->fcid); +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); + } -if (tport->flags &FNIC_FDLS_SCSI_REGISTERED ) { +if ((tport->flags &FNIC_FDLS_SCSI_REGISTERED ) || + (tport->flags &FNIC_FDLS_NVME_REGISTERED )) { tport_del_evt = kzalloc_obj(struct fnic_tport_event_s, GFP_ATOMIC);if (!tport_del_evt) {
[Severity: High]
This isn't a bug introduced by this patch, but are target ports permanently leaked as zombies if this memory allocation fails?
In fdls_delete_tport(), the state is changed to FDLS_TGT_STATE_OFFLINING prior to this allocation. If kzalloc_obj() returns NULL, the function bails out early without freeing the structure or unlinking it. Because the state is now offline, will future calls return early and never clean it up?
[ ... ]
Quoted 14 lines
drivers/scsi/fnic/fdls_disc.c +3
-5@@ -1508,13 +1535,21 @@ fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport) .fchdr = {.fh_r_ctl = FC_RCTL_ELS_REQ, .fh_type = FC_TYPE_ELS, .fh_f_ctl = {FNIC_ELS_REQ_FCTL, 0, 0}, .fh_rx_id = cpu_to_be16(FNIC_UNASSIGNED_RXID)}, - .els_prli = {.prli_cmd = ELS_PRLI, - .prli_spp_len = 16, - .prli_len = cpu_to_be16(0x14)}, - .sp = {.spp_type = 0x08, .spp_flags = 0x0020, - .spp_params = cpu_to_be32(0xA2)} + .els_prli = {.prli_cmd = ELS_PRLI}, + .sp = {.spp_params = cpu_to_be32(iport->service_params)} }; +fdls_set_frame_type (fnic, &pprli->sp.spp_type);
drivers/scsi/fnic/fdls_disc.c fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport) · line 1552
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+if (IS_FNIC_FCP_INITIATOR (fnic)) { + pprli->els_prli.prli_spp_len =16 ; + pprli->els_prli.prli_len =cpu_to_be16 (0x14 ); + pprli->sp.spp_flags =FC_SPP_EST_IMG_PAIR ; + }else if (IS_FNIC_NVME_INITIATOR (fnic)) { +/* Per FC-NVMe, Establish Image Pair must not be set for NVMe PRLI. */ + pprli->els_prli.prli_spp_len =20 ; + pprli->els_prli.prli_len =cpu_to_be16 (0x18 ); + } +
[Severity: High]
Will this payload length mismatch cause the target to reject the frame as malformed?
In fdls_send_tgt_prli(), the FCoE frame_size is calculated statically at the start of the function using sizeof(struct fc_std_els_prli), which assigns 16 bytes for the Service Parameter Page. For NVMe initiators, prli_spp_len is set to 20 bytes here, making the required payload 24 bytes. Will this result in the transmitted frame being 4 bytes shorter than the stated payload length?
[ ... ]
Quoted 18 lines
drivers/scsi/fnic/fdls_disc.c +9
-3@@ -2852,14 +2893,22 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, tport->fcp_csp =be32_to_cpu (prli_rsp->sp.spp_params); tport->retry_counter =0 ; -if (tport->fcp_csp &FCP_SPPF_RETRY ) - tport->tgt_flags |=FNIC_FC_RP_FLAGS_RETRY ; +if (IS_FNIC_FCP_INITIATOR (fnic)) { +if (tport->fcp_csp &FCP_SPPF_RETRY ) + tport->tgt_flags |=FNIC_FC_RP_FLAGS_RETRY ; + }else if (IS_FNIC_NVME_INITIATOR (fnic)) { +if (tport->fcp_csp &FNIC_NVME_SP_SLER ) + tport->tgt_flags |=FNIC_FC_RP_FLAGS_RETRY ; + }/* Check if the device plays Target Mode Function */ -if (!(tport->fcp_csp &FCP_PRLI_FUNC_TARGET )) { + if ((IS_FNIC_FCP_INITIATOR(fnic) && + !(tport->fcp_csp & FCP_PRLI_FUNC_TARGET)) ||
drivers/scsi/fnic/fdls_disc.c fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, · line 2914
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +4
-2+ (IS_FNIC_NVME_INITIATOR(fnic) && + !(tport->fcp_csp & FCP_PRLI_FUNC_TARGET))) {FNIC_FCS_DBG (KERN_INFO , fnic, -"Remote port(0x%x): no target support. Deleting it\n" , - tgt_fcid); +"Remote port(0x%x): no target support. Deleting it\n" , + tgt_fcid);fdls_tgt_logout (iport, tport);fdls_delete_tport (iport, tport);return ;
[Severity: High]
Does this target capability check inappropriately reject valid NVMe Discovery Controllers?
In fdls_process_tgt_prli_rsp(), validating target mode support checks !(tport->fcp_csp & FCP_PRLI_FUNC_TARGET), which masks bit 4. The NVMe Discovery Service uses bit 3. Will an NVMe Discovery Service target asserting only bit 3 unconditionally trigger this rejection and logout?
[ ... ]
Quoted 11 lines
drivers/scsi/fnic/fdls_disc.c +2
-5@@ -5087,14 +5143,18 @@ void fnic_fdls_link_down(struct fnic_iport_s *iport)fdls_set_state ((&iport->fabric),FDLS_STATE_LINKDOWN ); iport->fabric.flags =0 ; -spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); -fnic_fcpio_reset (iport->fnic); -spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); -list_for_each_entry_safe (tport, next, &iport->tport_list, links) { - FNIC_FCS_DBG(KERN_INFO, fnic, +if (IS_FNIC_FCP_INITIATOR (fnic) || +IS_FNIC_NVME_INITIATOR (fnic)) {
drivers/scsi/fnic/fdls_disc.c void fnic_fdls_link_down(struct fnic_iport_s *iport) · line 5156
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +7
-1+spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +fnic_fcpio_reset (iport->fnic); +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); +list_for_each_entry_safe (tport, next, &iport->tport_list, links) { +FNIC_FCS_DBG (KERN_INFO , fnic,"removing rport: 0x%x" , tport->fcid); -fdls_delete_tport (iport, tport); +fdls_delete_tport (iport, tport); + } }
[Severity: High]
This is a pre-existing issue, but does dropping the list lock inside a list_for_each_entry_safe() loop create a use-after-free race condition?
In fnic_fdls_link_down(), we iterate over tport_list using list_for_each_entry_safe() while holding fnic_lock. Inside the loop, fdls_delete_tport() is called, which temporarily drops the lock for FCP initiators. If a concurrent thread processing an ELS frame or RSCN removes and frees the next element in the list while the lock is dropped, will the iterator advance into freed memory when the lock is reacquired?
[Severity: High]
This is also a pre-existing issue in this file, but does the lack of length validation on FCoE ELS frames lead to out-of-bounds reads?
In fdls_process_rscn(), the loop limit num_ports is derived from the packet's internal rscn_payload_len field. The driver doesn't appear to verify if this claimed length fits within the physical size of the received network buffer. If a malformed frame claims a large length, could this copy uninitialized memory into local structures?
Quoted 4 lines
drivers/scsi/fnic/fnic_fcs.c +0
-0
[ ... ]
drivers/scsi/fnic/fnic_fcs.c void fnic_tport_event_handler(struct work_struct *work) · line 1051
Quoted 10 lines
drivers/scsi/fnic/fnic_fcs.c +2
-2@@ -1044,8 +1045,8 @@ void fnic_tport_event_handler(struct work_struct *work)FNIC_FCS_DBG (KERN_INFO , fnic,"Add rport event" );if (tport->state ==FDLS_TGT_STATE_READY ) { -fnic_fdls_add_tport (&fnic->iport, - (struct fnic_tport_s *) cur_evt->arg1, flags); +if (IS_FNIC_FCP_INITIATOR (fnic)) +fnic_fdls_add_tport (&fnic->iport, tport, flags); }else { FNIC_FCS_DBG(KERN_INFO, fnic,
[Severity: Critical]
Are target-port ADD and DEL events silently dropped by the worker thread for NVMe initiators?
In fnic_tport_event_handler(), TGT_EV_RPORT_ADD events are only processed if IS_FNIC_FCP_INITIATOR(fnic) is true. Because there is no logic branch for NVMe initiators, will these events be discarded without the target ever being registered?
Quoted 4 lines
drivers/scsi/fnic/fnic_main.c +0
-0
[ ... ]
Quoted 12 lines
drivers/scsi/fnic/fnic_main.c +2
-1@@ -1184,7 +1188,8 @@ static void fnic_remove(struct pci_dev *pdev)*/ flush_workqueue (fnic_event_queue); -fnic_scsi_unload (fnic); +if (IS_FNIC_FCP_INITIATOR (fnic)) +fnic_scsi_unload (fnic);if (vnic_dev_get_intr_mode (fnic->vdev) ==VNIC_DEV_INTR_MODE_MSI )timer_delete_sync (&fnic->notify_timer);@@ -1228,8 +1233,10 @@ static void fnic_remove(struct pci_dev *pdev)pci_disable_device (pdev);
drivers/scsi/fnic/fnic_main.c static void fnic_remove(struct pci_dev *pdev) · line 1241
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +4
-2pci_set_drvdata (pdev,NULL );ida_free (&fnic_ida, fnic->fnic_num); -fnic_scsi_unload_cleanup (fnic); -scsi_host_put (fnic->host); +if (IS_FNIC_FCP_INITIATOR (fnic)) { +fnic_scsi_unload_cleanup (fnic); +scsi_host_put (fnic->host); + }kfree (fnic); }
[Severity: Critical]
Does skipping these teardown steps for NVMe initiators leak target ports and their timers, leading to a use-after-free?
In fnic_remove(), fnic_scsi_unload() and fnic_scsi_unload_cleanup() are restricted to FCP initiators. These functions handle cancelling timers and freeing targets. If an NVMe initiator skips this cleanup, will retry timers remain active and access the fnic context after it is freed by kfree(fnic)?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Karan Tilak Kumar
maintainerPATCH v6 6/13 scsi: fnic: Add the NVMe/FC transport path
In reply to Karan Tilak KumarBuild fnic_nvme.c and fnic_nvme.h into the driver.
Add NVMe local-port and remote-port registration, I/O submission, DMA mapping, tag management, completion and abort handling, LS response handling, and tport/lport cleanup.
Update shared fnic structures, FCPIO descriptors, FDLS state, and device-command definitions needed by the NVMe transport path.
---
Changes between v1 and v2:
Incorporate review comments from Marco Crivellari:
Explicitly use WQ_PERCPU for the fnic completion workqueue.
Changes between v2 and v3:
Fix issues reported by kernel bot.
Guard tport logging when NVMe I/O send has no tport. Validate ERSP response length before copying the response. Validate LS response length before copying the response.
Changes between v3 and v4:
Incorporate review comments from Sashiko:
Clear NVMe SGL DMA address on map failure
Drop fnic lock around NVMe tport registration
Unlink unregistered NVMe tports before freeing them Clear NVMe unload completion pointer on exit
Take fnic lock before NVMe tport cleanup tag lookup Clear NVMe tport delete completion pointer on unregister failure
Changes between v4 and v5:
Incorporate review comments from Sashiko:
Set NVMe wait timestamp before queueing completions Use async timer delete for NVMe LS responses Complete failed NVMe ITMF aborts
Track NVMe SGL DMA mapping state
Detach NVMe LS cleanup before callbacks Defer NVMe table frees until cleanup
Lock NVMe tport IO termination lookup
Changes between v5 and v6:
Synchronize the tport retry timer before remote-port delete completes. Avoid requeueing FDLS tport delete from the NVMe remote-port callback. Drop the unnecessary else after the tport delete timeout return. Name the tport cleanup retry limit instead of using a literal. Publish can-free before completion and set cleanup-pending on timeout.
Incorporate review comments from Sashiko:
Flush NVMe completions after copy WQ cleanup
Reset NVMe SGL state before each I/O
Claim tport I/O before aborting it
Synchronize LS response timer before done
Preserve LS requests during abort start
Drain LS requests on rport unregister failure
Defer tport free after rport timeout
Avoid extra PCI device reference for lport
--- drivers/scsi/fnic/Makefile | 1 + drivers/scsi/fnic/fcpio.h | 12 + drivers/scsi/fnic/fnic.h | 20 +- drivers/scsi/fnic/fnic_fcs.c | 13 +- drivers/scsi/fnic/fnic_fdls.h | 27 +- drivers/scsi/fnic/fnic_io.h | 24 +- drivers/scsi/fnic/fnic_main.c | 93 +- drivers/scsi/fnic/fnic_nvme.c | 1890 +++++++++++++++++++++++++++++++ drivers/scsi/fnic/fnic_nvme.h | 210 ++++ drivers/scsi/fnic/fnic_res.h | 32 +- drivers/scsi/fnic/fnic_scsi.c | 4 +- drivers/scsi/fnic/vnic_devcmd.h | 2 +- 12 files changed, 2315 insertions(+), 13 deletions(-) create mode 100644 drivers/scsi/fnic/fnic_nvme.c create mode 100644 drivers/scsi/fnic/fnic_nvme.h
drivers/scsi/fnic/Makefile +1 -0
@@ -6,6 +6,7 @@ fnic-y := \ fnic_attrs.o \ fnic_isr.o \ fnic_main.o \ + fnic_nvme.o \ fnic_res.o \ fnic_fcs.o \ fdls_disc.o \
drivers/scsi/fnic/fcpio.h +12 -0
@@ -21,6 +21,18 @@#define FCPIO_HOST_SEQ_ID_RANGE_START 0x80#define FCPIO_HOST_SEQ_ID_RANGE_END 0xff +struct fnic_nvme_io_event { +struct list_head links; +struct work_struct io_work; +void *arg1; +}; + +struct fnic_io_event_s { +struct list_head links; +struct work_struct io_work; +void *arg1; +}; +/* * Command entry type */
drivers/scsi/fnic/fnic.h +19 -1
@@ -27,6 +27,7 @@#include "vnic_stats.h" #include "vnic_scsi.h" #include "fnic_fdls.h" +#include "fnic_nvme.h" #define DRV_NAME "fnic"#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
@@ -80,6 +81,8 @@#define FNIC_DEV_RST_ABTS_DONE BIT(19)#define FNIC_DEV_RST_TERM_DONE BIT(20)#define FNIC_DEV_RST_ABTS_PENDING BIT(21) +#define FNIC_NVME_ADMIN_IO_TIMER_PENDING BIT(22) +#define FNIC_NVME_ADMIN_IO BIT(23)#define FNIC_FW_RESET_TIMEOUT 60000/* mSec */ #define FNIC_FCOE_MAX_CMD_LEN 16
@@ -238,7 +241,7 @@ extern spinlock_t reset_fnic_list_lock;extern struct list_head reset_fnic_list;extern struct workqueue_struct *reset_fnic_work_queue;extern struct work_struct reset_fnic_work; - +extern struct workqueue_struct *fnic_cmpl_queue;#define FNIC_MAIN_LOGGING 0x01#define FNIC_FCS_LOGGING 0x02
@@ -352,6 +355,11 @@ struct fnic_frame_list {int rx_ethhdr_stripped; }; +struct fnic_tag_t { +struct list_head free_list; +int tag_id; +}; +struct fnic_event {struct list_head list;struct fnic *fnic;
@@ -469,6 +477,13 @@ struct fnic {struct list_head vlan_list;/*** FIP related data members -- end ***/ +/* NVME data members */ +struct sbitmap nvfnic_tag_map; +struct work_struct nvme_io_cmpl_work; +atomic_t nvme_io_event_queued; +struct llist_head nvme_io_event_llist; +struct completion *nvme_lport_unreg_done; +/* copy work queue cache line section */ ____cacheline_aligned struct vnic_wq_copy hw_copy_wq[FNIC_WQ_COPY_MAX ];____cacheline_aligned struct fnic_cpy_wq sw_copy_wq[FNIC_WQ_COPY_MAX ];
@@ -522,6 +537,7 @@ int fnic_host_reset(struct Scsi_Host *shost);void fnic_reset (struct Scsi_Host *shost);int fnic_issue_fc_host_lip (struct Scsi_Host *shost);void fnic_get_host_port_state (struct Scsi_Host *shost); +void fnic_fcpio_reset (struct fnic *fnic);int fnic_wq_copy_cmpl_handler (struct fnic *fnic,int copy_work_to_do,unsigned int cq_index);int fnic_wq_cmpl_handler (struct fnic *fnic,int );int fnic_flogi_reg_handler (struct fnic *fnic,u32 );
@@ -568,6 +584,8 @@ void fnic_scsi_unload(struct fnic *fnic);void fnic_scsi_unload_cleanup (struct fnic *fnic);int fnic_get_debug_info (struct stats_debug_info *info,struct fnic *fnic); +int free_wq_copy_descs (struct fnic *fnic,struct vnic_wq_copy *wq, +unsigned int hwq);struct fnic_scsi_iter_data {struct fnic *fnic;
drivers/scsi/fnic/fnic_fcs.c +9 -4
@@ -155,7 +155,6 @@ void fnic_fdls_init(struct fnic *fnic, int usefip) iport->hwmac[3], iport->hwmac[4], iport->hwmac[5]);INIT_LIST_HEAD (&iport->tport_list); -INIT_LIST_HEAD (&iport->tport_list_pending_del);fnic_fdls_disc_init (iport); }
@@ -728,7 +727,7 @@ fdls_send_fcoe_frame(struct fnic *fnic, void *frame, int frame_size,return ret; } -void fnic_send_fcoe_frame (struct fnic_iport_s *iport,void *frame, +int fnic_send_fcoe_frame (struct fnic_iport_s *iport,void *frame,int frame_size) {struct fnic *fnic = iport->fnic;
@@ -736,7 +735,7 @@ void fnic_send_fcoe_frame(struct fnic_iport_s *iport, void *frame,/* If module unload is in-progress, don't send */ if (fnic->in_remove) -return ; +return -ESHUTDOWN ;if (iport->fabric.flags &FNIC_FDLS_FPMA_LEARNT ) { srcmac = iport->fpma;
@@ -746,7 +745,7 @@ void fnic_send_fcoe_frame(struct fnic_iport_s *iport, void *frame, dstmac =FCOE_ALL_FCF_MAC ; } -fdls_send_fcoe_frame (fnic, frame, frame_size, srcmac, dstmac); +return fdls_send_fcoe_frame (fnic, frame, frame_size, srcmac, dstmac); }int
@@ -1020,6 +1019,8 @@ void fnic_delete_fcp_tports(struct fnic *fnic)fnic_del_tport_timer_sync (fnic, tport);if (IS_FNIC_FCP_INITIATOR (fnic))fnic_fdls_remove_tport (&fnic->iport, tport, flags); +else if (IS_FNIC_NVME_INITIATOR (fnic)) +nvfnic_delete_tport (&fnic->iport, tport, flags); }spin_unlock_irqrestore (&fnic->fnic_lock, flags); }
@@ -1047,6 +1048,8 @@ void fnic_tport_event_handler(struct work_struct *work)if (tport->state ==FDLS_TGT_STATE_READY ) {if (IS_FNIC_FCP_INITIATOR (fnic))fnic_fdls_add_tport (&fnic->iport, tport, flags); +else if (IS_FNIC_NVME_INITIATOR (fnic)) +nvfnic_add_tport (fnic, tport, flags); }else { FNIC_FCS_DBG(KERN_INFO, fnic, "Target not ready. Add rport event dropped: 0x%x",
@@ -1059,6 +1062,8 @@ void fnic_tport_event_handler(struct work_struct *work)if (tport->state ==FDLS_TGT_STATE_OFFLINING ) {if (IS_FNIC_FCP_INITIATOR (fnic))fnic_fdls_remove_tport (&fnic->iport, tport, flags); +else if (IS_FNIC_NVME_INITIATOR (fnic)) +nvfnic_delete_tport (&fnic->iport, tport, flags); }else { FNIC_FCS_DBG(KERN_INFO, fnic, "remove rport event dropped tport fcid: 0x%x",
drivers/scsi/fnic/fnic_fdls.h +25 -2
@@ -97,6 +97,7 @@#define fdls_get_state (_fdls_fabric) ((_fdls_fabric)->state)#define FNIC_FDMI_ACTIVE 0x8 +#define FNIC_LPORT_NVME_REGISTERED 0x4#define FNIC_FIRST_LINK_UP 0x2#define fdls_set_tport_state (_tport, _state) (_tport->state = _state)
@@ -122,6 +123,13 @@#define FNIC_FRAME_TYPE_TGT_PRLI 0x2800#define FNIC_FRAME_TYPE_TGT_ADISC 0x2A00#define FNIC_FRAME_TYPE_TGT_LOGO 0x2C00 +#define FNIC_FRAME_TYPE_NVME_LS 0x3000 + +#define NVFNIC_FCPIO_TAG_POOL_SZ (2048) +#define NVFNIC_LS_REQ_OXID_POOL_SZ (64) +#define NVFNIC_LS_REQ_OXID_BASE (0x2500) +#define FNIC_LPORT_NVME_REGISTERED 0x4 +struct fnic_fip_fcf_s {uint16_t vlan_id;
@@ -223,6 +231,8 @@ struct fnic_tport_s {struct fc_rport *rport;char str_wwpn[20 ];char str_wwnn[20 ]; +struct list_head ls_req_list; +struct nvme_fc_remote_port *nv_rport; };/* OXID pool related structures */
@@ -291,7 +301,6 @@ struct fnic_iport_s {struct fnic_fdls_fip_s fip;struct fnic_fdls_fabric_s fabric;struct list_head tport_list; -struct list_head tport_list_pending_del;/* list of tports for which we are yet to send PLOGO */ struct list_head inprocess_tport_list;struct list_head deleted_tport_list;
@@ -311,6 +320,13 @@ struct fnic_iport_s {struct fnic_iport_stats iport_stats;char str_wwpn[20 ];char str_wwnn[20 ]; + +/* nvme */ ; +void *nvfnic_fcpio_tag[NVFNIC_FCPIO_TAG_POOL_SZ ]; +struct nvme_fc_local_port *nv_lport; +struct nvme_fc_port_template *nv_tmpl; +struct fnic_oxid_pool_s ls_req_oxid_pool; +struct list_head fcpio_list; };struct rport_dd_data_s {
@@ -339,6 +355,7 @@ enum fnic_recv_frame_type_e {FNIC_TPORT_ADISC_RSP ,FNIC_TPORT_BLS_ABTS_RSP ,FNIC_TPORT_LOGO_RSP , +FNIC_LS_REQ_ABTS_RSP ,/* unsolicited requests */ FNIC_BLS_ABTS_REQ,
@@ -371,6 +388,12 @@ enum fnic_port_speeds { DCEM_PORTSPEED_128G = 128000, }; +static inline bool fdls_tport_is_offline (struct fnic_tport_s *tport) +{ +return (tport->state ==FDLS_TGT_STATE_OFFLINING || + tport->state ==FDLS_TGT_STATE_OFFLINE ); +} +/* Function Declarations */ /* fdls_disc.c */ void fnic_fdls_disc_init (struct fnic_iport_s *iport);
@@ -401,7 +424,7 @@ void fdls_fdmi_retry_plogi(struct fnic_iport_s *iport);/* fnic_fcs.c */ void fnic_fdls_init (struct fnic *fnic,int usefip); -void fnic_send_fcoe_frame (struct fnic_iport_s *iport,void *frame, +int fnic_send_fcoe_frame (struct fnic_iport_s *iport,void *frame,int frame_size);void fnic_fcoe_send_vlan_req (struct fnic *fnic); int fnic_send_fip_frame(struct fnic_iport_s *iport,
drivers/scsi/fnic/fnic_io.h +23 -1
@@ -6,13 +6,19 @@ #ifndef _FNIC_IO_H_ #define _FNIC_IO_H_ +#include <scsi/fc/fc_fs.h> #include <scsi/fc/fc_fcp.h> #include "fnic_fdls.h" +#include "fcpio.h" +#include <linux/nvme-fc-driver.h> #define FNIC_DFLT_SG_DESC_CNT 32 #define FNIC_MAX_SG_DESC_CNT 256 /* Maximum descriptors per sgl */ #define FNIC_SG_DESC_ALIGN 16 /* Descriptor address alignment */ +#define NVME_STAT_ERROR 0x2 +#define NVME_STAT_TASK_SET_FULL 0x3 + struct host_sg_desc { __le64 addr; __le32 len;
@@ -39,6 +45,7 @@ enum fnic_ioreq_state {FNIC_IOREQ_ABTS_PENDING ,FNIC_IOREQ_ABTS_COMPLETE ,FNIC_IOREQ_CMD_COMPLETE , + FNIC_IOREQ_RESET_TERM, }; struct fnic_io_req {
@@ -50,12 +57,27 @@ struct fnic_io_req {dma_addr_t sgl_list_pa;/* dma address for sgl list */ u16 sgl_cnt;u8 sgl_type;/* device DMA descriptor list type */ + u8 sgl_mapped:1; /* set when sgl_list_pa is a valid DMA mapping */ u8 io_completed:1; /* set to 1 when fw completes IO */u32 port_id;/* remote port DID */ unsigned long start_time;/* in jiffies */ +u32 tag; +enum fnic_ioreq_state cmd_state; +u32 cmd_flags; +u32 abts_state;struct completion *abts_done;/* completion for abts */ struct completion *dr_done;/* completion for device reset */ -unsigned int tag;struct scsi_cmnd *sc;/* midlayer's cmd pointer */ + +struct vnic_wq_copy *wq; +struct llist_node nvfnic_io_cmpl; +struct nvmefc_fcp_req *fcp_req; +void (*done)(struct fnic_io_req *io_req); +unsigned long waitq_start_time;/* in jiffies */ + +struct timer_list admin_io_timer; +uint32_t status; +struct fnic_tag_t *tag_data; + struct fnic_io_event_s io_evt; };#endif /* _FNIC_IO_H_ */
drivers/scsi/fnic/fnic_main.c +92 -1
176 lines not on this page · raw message
drivers/scsi/fnic/fnic_nvme.c new file +1890 -0
1,890 lines not on this page · raw message
drivers/scsi/fnic/fnic_nvme.h new file +210 -0
210 lines not on this page · raw message
drivers/scsi/fnic/fnic_res.h +31 -1
@@ -126,7 +126,8 @@ static inline void fnic_queue_wq_copy_desc_itmf(struct vnic_wq_copy *wq, desc->u.itmf.tm_req = tm_req;/* SCSI Task Management request */ desc->u.itmf.t_tag = tm_id;/* tag of fcpio to be aborted */ desc->u.itmf._resvd =0 ; -memcpy (desc->u.itmf.lun, lun,LUN_ADDRESS );/* LUN address */ +if (lun) +memcpy (desc->u.itmf.lun, lun,LUN_ADDRESS );/* LUN address */ desc->u.itmf._resvd1 =0 ;hton24 (desc->u.itmf.d_id, d_id);/* FC vNIC only: Target D_ID */ desc->u.itmf.r_a_tov = r_a_tov;/* FC vNIC only: R_A_TOV in msec */
@@ -222,6 +223,35 @@ static inline void fnic_queue_rq_desc(struct vnic_rq *rq,vnic_rq_post (rq, os_buf,0 , dma_addr, len); } +static inline void fnic_queue_wq_copy_desc_nvme_io (struct vnic_wq_copy *wq, +u32 req_id, +u8 spl_flags, +u32 sgl_cnt, +u64 sgl_addr, +u8 flags,u8 *nvme_cmd_iu, +u16 cmd_len, +u32 data_len, +u32 d_id,u32 mss, +u32 ratov,u32 edtov) +{ +struct fcpio_host_req *desc =vnic_wq_copy_next_desc (wq); + + desc->hdr.type =FCPIO_NVME_CMD ;/* enum fcpio_type */ + desc->hdr.status =0 ;/* header status entry */ + desc->hdr._resvd =0 ;/* reserved */ + desc->hdr.tag.u.req_id = req_id;/* id for this request */ + desc->u.nvcmnd.sgl_cnt = sgl_cnt;/* scatter-gather list count */ + desc->u.nvcmnd.sgl_addr = sgl_addr;/* scatter-gather list addr */ + desc->u.nvcmnd._resvd1 =0 ;/* reserved: should be 0 */ + desc->u.nvcmnd.flags = flags;/* command flags */ +memset (desc->u.nvcmnd.nvme_cmnd,0 ,NVME_CMD_SZ ); +memcpy (desc->u.nvcmnd.nvme_cmnd, nvme_cmd_iu, cmd_len);/* SCSI CDB */ + desc->u.nvcmnd.cmd_len = cmd_len; + desc->u.nvcmnd.data_len = data_len;/* length of data expected */ +hton24 (desc->u.nvcmnd.d_id, d_id);/* FC vNIC only: Target D_ID */ + +vnic_wq_copy_post (wq); +}struct fnic ;
drivers/scsi/fnic/fnic_scsi.c +2 -2
@@ -96,7 +96,7 @@ static const char *fnic_ioreq_state_to_str(unsigned int state)return fnic_ioreq_state_str[state]; } -static const char *fnic_fcpio_status_to_str (unsigned int status) +const char *fnic_fcpio_status_to_str (unsigned int status) {if (status >=ARRAY_SIZE (fcpio_status_str) || !fcpio_status_str[status])return "unknown" ;
@@ -186,7 +186,7 @@ fnic_count_lun_ioreqs(struct fnic *fnic, struct scsi_device *scsi_device) }/* Free up Copy Wq descriptors. Called with copy_wq lock held */ -static int free_wq_copy_descs (struct fnic *fnic,struct vnic_wq_copy *wq,unsigned int hwq) +int free_wq_copy_descs (struct fnic *fnic,struct vnic_wq_copy *wq,unsigned int hwq) {/* if no Ack received from firmware, then nothing to clean */ if (!fnic->fw_ack_recd[hwq])
drivers/scsi/fnic/vnic_devcmd.h +1 -1
@@ -430,7 +430,7 @@ struct vnic_devcmd_notify {struct vnic_devcmd_provinfo {u8 oui[3 ];u8 type; -u8 data[]; +u8 data[0 ]; };/*
Signature · 1 line
2.47.1
[email protected]
AI reviewRe: [PATCH v6 06/13] scsi: fnic: Add the NVMe/FC transport path
Thank you for your contribution! Sashiko AI review found 11 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 11 potential issue(s) to consider:
New issues:
- [High] The NVMe FC transport template nvfnic_port omits the mandatory .ls_req callback, causing nvme_fc_register_localport() to unconditionally fail and preventing NVMe initialization.
- [High] NVMe I/O completion and ITMF handlers are completely disconnected from the CQ polling loop, causing all NVMe I/Os to hang indefinitely.
- [High] The ls_req_timer in struct nvfnic_ls_req is armed without ever being initialized.
- [High] Concurrent execution of nvfnic_delete_tport results in stack corruption, double free, and use-after-free of the tport structure.
- [High] A TOCTOU race between abort WQ enqueue and fast completions causes IO requests to permanently hang.
- [High] tport->ls_req_list is not initialized with INIT_LIST_HEAD(), causing a kernel panic when iterated.
- [High] ls_req is left on tport->ls_req_list during abort, leading to Use-After-Free and list corruption when tport is freed.
- [High] Timeout during local port unregistration leads to a use-after-free of the nv_tmpl and fnic structures.
- [Medium] fnic_queue_wq_copy_desc_itmf leaks uninitialized descriptor memory to firmware when lun is NULL.
Pre-existing issues:
- [High] Dropping a spinlock inside a list_for_each_entry_safe loop invalidates the safe iteration, leading to list corruption and kernel panic.
- [High] The driver incorrectly uses a shared struct member (fnic->lock_flags) for saving CPU-local IRQ state during spin_lock_irqsave. --
--- Patch [6]: [PATCH v6 06/13] scsi: fnic: Add the NVMe/FC transport path --- commit 320b83a04180e41753d3bc332a151c194da1ab86
Author: Karan Tilak Kumar <[email protected]>
Subject: scsi: fnic: Add the NVMe/FC transport path
This commit introduces the NVMe over FC transport path for the fnic driver. It adds logic for local-port and remote-port registration, I/O submission, tag management, completion handling, and cleanup operations.
Quoted 3 lines
drivers/scsi/fnic/fnic_fcs.c +0
-0
[ ... ]
drivers/scsi/fnic/fnic_fcs.c void fnic_delete_fcp_tports(struct fnic *fnic) · line 1023
Quoted 6 lines
drivers/scsi/fnic/fnic_fcs.c +2
-0@@ -1020,6 +1019,8 @@ void fnic_delete_fcp_tports(struct fnic *fnic)fnic_del_tport_timer_sync (fnic, tport);if (IS_FNIC_FCP_INITIATOR (fnic))fnic_fdls_remove_tport (&fnic->iport, tport, flags); +else if (IS_FNIC_NVME_INITIATOR (fnic)) +nvfnic_delete_tport (&fnic->iport, tport, flags);
[Severity: High]
This is a pre-existing issue, but does dropping the spinlock inside the list_for_each_entry_safe() loop corrupt the list?
In fnic_delete_fcp_tports(), the loop holds fnic_lock and calls nvfnic_delete_tport(), which explicitly drops fnic_lock. If a concurrent task frees the cached next pointer while the lock is dropped, the loop will dereference freed memory when it resumes.
[ ... ]
Quoted 4 lines
drivers/scsi/fnic/fnic_nvme.c new file +0
-0
[ ... ]
Quoted 3 lines
drivers/scsi/fnic/fnic_nvme.c new file +3
-0+void nvfnic_fcpio_nvme_fast_cmpl_handler (struct fnic *fnic, +struct fcpio_fw_req *desc) +{
[ ... ]
drivers/scsi/fnic/fnic_nvme.c line 437
Quoted 7 lines
drivers/scsi/fnic/fnic_nvme.c new file +7
-0+if (io_req->cmd_state ==FNIC_IOREQ_ABTS_PENDING ) { +/* +* set the FNIC_IO_DONE so that this doesn't get +* flagged as 'out of order' if it was not aborted +*/ + io_req->cmd_flags |=FNIC_IO_DONE ; + io_req->cmd_flags |=FNIC_IO_ABTS_PENDING ;
[Severity: High]
Will this sequence cause an I/O request to hang permanently?
In nvfnic_fcpio_nvme_fast_cmpl_handler(), if the IO state is FNIC_IOREQ_ABTS_PENDING, the completion is discarded. If nvfnic_fcpio_abort() then fails to enqueue the abort (for example, if the WQ is full), it restores the state back to FNIC_IOREQ_CMD_PENDING and returns. Since the hardware completion was already dropped, the I/O would remain pending forever.
[ ... ]
drivers/scsi/fnic/fnic_nvme.c line 1349
Quoted 10 lines
drivers/scsi/fnic/fnic_nvme.c new file +10
-0+void nvfnic_local_port_delete (struct nvme_fc_local_port *lport) +{ +struct fnic_iport_s *iport = (struct fnic_iport_s *) lport->private; +struct fnic *fnic = iport->fnic; +unsigned long flags =0 ; + +FNIC_NVME_DBG (KERN_INFO , fnic,"lport delete 0x%x\n" , + iport->fcid); + +spin_lock_irqsave (&fnic->fnic_lock, flags);
[Severity: High]
Could a timeout during unload lead to a use-after-free here?
If the wait_for_completion_timeout() in nvfnic_nvme_unload() expires, the driver frees iport->nv_tmpl and eventually the fnic structure. However, if the NVMe midlayer later invokes the localport_delete callback (nvfnic_local_port_delete()), it will dereference the freed iport and fnic memory and attempt to acquire the freed fnic_lock.
[ ... ]
Quoted 13 lines
drivers/scsi/fnic/fnic_nvme.c new file +13
-0+void +nvfnic_cleanup_tport_io (struct fnic *fnic,struct fnic_tport_s *tport) +{ +unsigned long flags; +struct nvfnic_ls_req *nvfnic_ls_req, *next; +struct nvmefc_ls_req *lsreq; +uint16_t oxid; +LIST_HEAD (done_reqs); + +spin_lock_irqsave (&fnic->fnic_lock, flags); +list_for_each_entry_safe (nvfnic_ls_req, next, + &(tport->ls_req_list), list) { + lsreq = nvfnic_ls_req->ls_req;
drivers/scsi/fnic/fnic_nvme.c line 857
Quoted 10 lines
drivers/scsi/fnic/fnic_nvme.c new file +10
-0+if (!lsreq || (lsreq->private ==NULL )) { +FNIC_NVME_DBG (KERN_INFO , fnic, +"fnic_cleanup_tport_io lsreq NULL\n" ); +continue ; + } +if (nvfnic_ls_req->state ==FNIC_LS_REQ_CMD_ABTS_STARTED ) { +FNIC_NVME_DBG (KERN_INFO , fnic, +"fnic_cleanup_tport_io lsreq abort started\n" ); +continue ; + }
[Severity: High]
Does skipping list_del_init() for aborting requests lead to a use-after-free of the tport?
If the request state is FNIC_LS_REQ_CMD_ABTS_STARTED, the continue statement skips removing the request from tport->ls_req_list. Once the tport is freed, the subsequent abort completion or timeout callback will call list_del() on nvfnic_ls_req->list, corrupting the freed tport memory.
[ ... ]
drivers/scsi/fnic/fnic_nvme.c line 890
Quoted 10 lines
drivers/scsi/fnic/fnic_nvme.c new file +10
-0+void +nvfnic_terminate_tport_ls_reqs (struct fnic *fnic,struct fnic_tport_s *tport) +{ +struct nvmefc_ls_req *lsreq; +struct nvfnic_ls_req *nvfnic_ls_req, *next; +int count =0 ; +uint16_t oxid; +LIST_HEAD (done_reqs); + +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags);
[Severity: High]
This is a pre-existing issue, but does using the shared fnic->lock_flags corrupt CPU-local IRQ state?
Calling spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags) overwrites the shared structure member. If multiple CPUs contend for this lock, they will overwrite each other's saved IRQ states, leading to an incorrect state restoration upon unlock.
drivers/scsi/fnic/fnic_nvme.c
Quoted 2 lines
drivers/scsi/fnic/fnic_nvme.c new file +2
-0+list_for_each_entry_safe (nvfnic_ls_req, next, + &(tport->ls_req_list), list) {
[Severity: High]
Will iterating this list trigger a kernel panic?
The tport structure is allocated with kzalloc(), but tport->ls_req_list is never initialized with INIT_LIST_HEAD(). When list_for_each_entry_safe() executes, it will dereference a NULL next pointer.
[ ... ]
drivers/scsi/fnic/fnic_nvme.c line 1665
Quoted 7 lines
drivers/scsi/fnic/fnic_nvme.c new file +7
-0+struct +nvme_fc_port_template nvfnic_port = { + .localport_delete = nvfnic_local_port_delete, + .remoteport_delete = nvfnic_remote_port_delete, + .create_queue = nvfnic_create_queue, + .delete_queue =NULL , + .ls_req =NULL ,
[Severity: High]
Does the omitted ls_req callback cause the local port registration to always fail?
The nvfnic_port template explicitly sets .ls_req to NULL. When nvfnic_add_lport() calls nvme_fc_register_localport(), the NVMe transport validates the presence of the ls_req callback and will unconditionally return -EINVAL if it is missing. This prevents NVMe initialization entirely.
[ ... ]
Quoted 8 lines
drivers/scsi/fnic/fnic_nvme.c new file +8
-0+void nvfnic_nvme_unload (struct fnic *fnic) +{ +int ret =0 ; +struct fnic_iport_s *iport = &fnic->iport; +unsigned long flags; +unsigned int time_wait =FNIC_NVME_LPORT_REMOVE_WAIT ; +unsigned int time_remain; +DECLARE_COMPLETION_ONSTACK (nvme_lport_unreg_done);
[ ... ]
drivers/scsi/fnic/fnic_nvme.c line 1087
Quoted 10 lines
drivers/scsi/fnic/fnic_nvme.c new file +10
-0+ time_remain =wait_for_completion_timeout ( + fnic->nvme_lport_unreg_done, +msecs_to_jiffies (time_wait)); +if (!time_remain) { +FNIC_NVME_DBG (KERN_ERR , fnic, +"Local port removal timed out\n" ); +WARN_ON (1 ); + } + iport->flags &= ~FNIC_LPORT_NVME_REGISTERED ; +kfree (iport->nv_tmpl);
[Severity: High]
Could a timeout here lead to a use-after-free?
If the wait_for_completion_timeout() in nvfnic_nvme_unload() expires, the driver frees iport->nv_tmpl and eventually the fnic structure. However, if the NVMe midlayer later invokes the localport_delete callback (nvfnic_local_port_delete()), it will dereference the freed iport and fnic memory and attempt to acquire the freed fnic_lock.
[ ... ]
Quoted 4 lines
drivers/scsi/fnic/fnic_nvme.c new file +4
-0+void nvfnic_ls_req_abort (struct nvme_fc_local_port *lport, +struct nvme_fc_remote_port *rport, +struct nvmefc_ls_req *lsreq) +{
[ ... ]
drivers/scsi/fnic/fnic_nvme.c line 1530
Quoted 5 lines
drivers/scsi/fnic/fnic_nvme.c new file +5
-0+/* Mark the state and flags */ + nvfnic_ls_req->state =FNIC_LS_REQ_CMD_ABTS_PENDING ; + timeout =FNIC_LS_REQ_TMO_MSECS (lsreq->timeout); +mod_timer (&nvfnic_ls_req->ls_req_timer, +round_jiffies (jiffies +msecs_to_jiffies (timeout)));
[Severity: High]
Could arming this timer trigger a kernel panic?
In nvfnic_ls_req_abort(), mod_timer() is called on nvfnic_ls_req->ls_req_timer. However, timer_setup() is never called for this timer during the request's lifecycle. Calling mod_timer() on an uninitialized timer structure leads to list corruption.
[ ... ]
Quoted 4 lines
drivers/scsi/fnic/fnic_nvme.c new file +4
-0+void nvfnic_delete_tport (struct fnic_iport_s *iport, +struct fnic_tport_s *tport, +unsigned long flags) +{
[ ... ]
drivers/scsi/fnic/fnic_nvme.c line 1739
Quoted 10 lines
drivers/scsi/fnic/fnic_nvme.c new file +10
-0+if (!(tport->flags &FNIC_FDLS_NVME_REGISTERED )) { +FNIC_NVME_DBG (KERN_ERR , fnic, +"0x%x: tport: 0x%x not registered. Freeing\n" , + iport->fcid, tport->fcid); +list_del (&tport->links); +kfree (tport); +return ; + } + + tport->tport_del_done = &tm_done;
[Severity: High]
Is it possible for concurrent teardown paths to corrupt the stack and double-free the tport?
The FNIC_FDLS_NVME_REGISTERED flag is checked but never cleared. If called concurrently, both threads will assign their local stack address of tm_done to tport->tport_del_done. If the second thread fails in nvme_fc_unregister_remoteport(), it will free the tport and return, while the first thread is still waiting on the completion using the freed tport.
drivers/scsi/fnic/fnic_nvme.c line 1743
Quoted 4 lines
drivers/scsi/fnic/fnic_nvme.c new file +4
-0+ + tport->flags |=FNIC_FDLS_TPORT_DELETED ; +spin_unlock_irqrestore (&fnic->fnic_lock, flags); + ret =nvme_fc_unregister_remoteport (tport->nv_rport);
[Severity: High]
This is a pre-existing issue, but does dropping the spinlock here corrupt the list iteration in the caller?
In fnic_delete_fcp_tports(), a list_for_each_entry_safe() loop holds fnic_lock and calls nvfnic_delete_tport(). By explicitly dropping fnic_lock here, if a concurrent task frees the cached next pointer while the lock is dropped, the loop will dereference freed memory when it resumes.
[ ... ]
drivers/scsi/fnic/fnic_res.h static inline void fnic_queue_wq_copy_desc_itmf(struct vnic_wq_copy *wq, · line 132
Quoted 12 lines
drivers/scsi/fnic/fnic_res.h +2
-1@@ -126,7 +126,8 @@ static inline void fnic_queue_wq_copy_desc_itmf(struct vnic_wq_copy *wq, desc->u.itmf.tm_req = tm_req;/* SCSI Task Management request */ desc->u.itmf.t_tag = tm_id;/* tag of fcpio to be aborted */ desc->u.itmf._resvd =0 ; -memcpy (desc->u.itmf.lun, lun,LUN_ADDRESS );/* LUN address */ +if (lun) +memcpy (desc->u.itmf.lun, lun,LUN_ADDRESS );/* LUN address */ desc->u.itmf._resvd1 =0 ;hton24 (desc->u.itmf.d_id, d_id);/* FC vNIC only: Target D_ID */
[Severity: Medium]
Does skipping the memcpy when lun is NULL leak uninitialized memory to the firmware?
If lun is NULL, the 8-byte lun array in the descriptor is not zeroed. Because vnic_wq_copy_next_desc() returns memory directly from the ring buffer, this leaks whatever residual data was previously in the descriptor.
[ ... ]
drivers/scsi/fnic/fnic_scsi.c
Quoted 3 lines
drivers/scsi/fnic/fnic_scsi.c +0
-0
[Severity: High]
Are the newly added NVMe completion handlers unreachable from the completion queue polling loop?
When the hardware completes an NVMe I/O, fnic_fcpio_cmpl_handler() processes the CQ entry. Because there are no switch cases for FCPIO_NVME_ERSP_HW_CMPL or FCPIO_NVME_ERSP_FW_CMPL, they hit the default case and are discarded. Consequently, NVMe commands are never completed back to the midlayer, causing I/Os to hang indefinitely.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Karan Tilak Kumar
maintainerPATCH v6 7/13 scsi: fnic: Route completions and resets by initiator role
In reply to Karan Tilak KumarDispatch FCPIO command, response, and ITMF completions to the FCP or NVMe handlers based on the configured role.
Read the NVMe queue-depth and timeout retry fields from firmware config,
clean up NVMe I/O on firmware reset, and skip SCSI-only cleanup for initiator roles that already reset firmware-owned requests.
---
Incorporate review comments from Hannes:
Remove the empty line before the FLOGI completion else block. Add a short comment for the NVMe ERSP completion case.
Changes between v4 and v5:
Incorporate review comments from Sashiko:
Count NVMe ERSP completions as firmware completions Gate NVMe completions by initiator role
--- drivers/scsi/fnic/fnic_res.c | 2 ++ drivers/scsi/fnic/fnic_scsi.c | 32 ++++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-)
drivers/scsi/fnic/fnic_res.c +2 -0
@@ -57,6 +57,8 @@ int fnic_get_vnic_config(struct fnic *fnic)GET_CONFIG (port_down_io_retries);GET_CONFIG (luns_per_tgt);GET_CONFIG (intr_mode); +GET_CONFIG (lun_queue_depth); +GET_CONFIG (io_timeout_retry);GET_CONFIG (wq_copy_count); role = c->flags &FNIC_ROLE_CONFIG_MASK ;
drivers/scsi/fnic/fnic_scsi.c +28 -4
@@ -145,8 +145,9 @@ unsigned int fnic_count_ioreqs(struct fnic *fnic, u32 portid) {unsigned int count =0 ; -fnic_scsi_io_iter (fnic, fnic_count_portid_ioreqs_iter, - &portid, &count); +if (IS_FNIC_FCP_INITIATOR (fnic)) +fnic_scsi_io_iter (fnic, fnic_count_portid_ioreqs_iter, + &portid, &count);FNIC_SCSI_DBG (KERN_DEBUG , fnic,"portid = 0x%x count = %u\n" , portid, count);
@@ -734,6 +735,8 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic,/* Clean up all outstanding io requests */ if (IS_FNIC_FCP_INITIATOR (fnic))fnic_cleanup_io (fnic,SCSI_NO_TAG ); +else if (IS_FNIC_NVME_INITIATOR (fnic)) +nvfnic_cleanup_all_nvme_ios (fnic);atomic64_set (&fnic->fnic_stats.fw_stats.active_fw_reqs,0 );atomic64_set (&fnic->fnic_stats.io_stats.active_ios,0 );
@@ -1443,6 +1446,7 @@ static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev,case FCPIO_FLOGI_REG_CMPL :/* fw completed flogi_reg */ case FCPIO_FLOGI_FIP_REG_CMPL :/* fw completed flogi_fip_reg */ case FCPIO_RESET_CMPL :/* fw completed reset */ +case FCPIO_NVME_ERSP_HW_CMPL :/* fw completed NVMe ERSP */ atomic64_dec (&fnic->fnic_stats.fw_stats.active_fw_reqs);break ;default :
@@ -1457,11 +1461,22 @@ static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev,break ;case FCPIO_ICMND_CMPL :/* fw completed a command */ -fnic_fcpio_icmnd_cmpl_handler (fnic, cq_index, desc); +if (IS_FNIC_FCP_INITIATOR (fnic)) +fnic_fcpio_icmnd_cmpl_handler (fnic, cq_index, desc); +else if (IS_FNIC_NVME_INITIATOR (fnic)) +nvfnic_fcpio_nvme_fast_cmpl_handler (fnic, desc); +break ; + +case FCPIO_NVME_ERSP_HW_CMPL :/* fw completed NVMe ERSP */ +if (IS_FNIC_NVME_INITIATOR (fnic)) +nvfnic_fcpio_ersp_cmpl_handler (fnic, desc,1 );break ;case FCPIO_ITMF_CMPL :/* fw completed itmf (abort cmd, lun reset)*/ -fnic_fcpio_itmf_cmpl_handler (fnic, cq_index, desc); +if (IS_FNIC_FCP_INITIATOR (fnic)) +fnic_fcpio_itmf_cmpl_handler (fnic, cq_index, desc); +else if (IS_FNIC_NVME_INITIATOR (fnic)) +nvfnic_fcpio_nvme_itmf_cmpl_handler (fnic, desc);break ;case FCPIO_FLOGI_REG_CMPL :/* fw completed flogi_reg */
@@ -1650,6 +1665,15 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,unsigned long start_time =0 ;uint16_t hwq; +/* +* Clean up outstanding NVMe requests if firmware reset did not +* complete them before WQ copy cleanup. +*/ +if (IS_FNIC_NVME_INITIATOR (fnic)) { +nvfnic_cleanup_all_nvme_ios (fnic); +return ; + } +/* get the tag reference */ fcpio_tag_id_dec (&desc->hdr.tag, &id); id &=FNIC_TAG_MASK ;
Signature · 1 line
2.47.1
[email protected]
AI reviewRe: [PATCH v6 07/13] scsi: fnic: Route completions and resets by initiator role
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
New issues:
- [High] Missing cleanup for NVMe initiator resources in fnic_probe error path.
- [Medium] The active_fw_reqs atomic counter will underflow for NVMe I/O operations.
- [Medium] The active_ios atomic counter will underflow when NVMe ITMF (abort) completions are received.
- [Low] nvfnic_cleanup_all_nvme_ios is redundantly called for every pending descriptor during WQ cleanup.
- [Low] The variables lun_queue_depth and io_timeout_retry are fetched from the firmware config but are never used.
Pre-existing issues:
- [High] fnic_cleanup_io() calls schedule_timeout() from a hardirq context. --
--- Patch [7]: [PATCH v6 07/13] scsi: fnic: Route completions and resets by initiator role --- commit f5bb58906d74d7095d6b139507d49072e46f3946
Author: Karan Tilak Kumar <[email protected]>
scsi: fnic: Route completions and resets by initiator role
This patch dispatches FCPIO command, response, and ITMF completions to the FCP or NVMe handlers based on the configured role. It reads the NVMe queue depth and timeout retry fields from the firmware config and performs NVMe I/O cleanup on firmware reset.
drivers/scsi/fnic/fnic_res.c int fnic_get_vnic_config(struct fnic *fnic) · line 61
Quoted 9 lines
drivers/scsi/fnic/fnic_res.c +2
-0@@ -57,6 +57,8 @@ int fnic_get_vnic_config(struct fnic *fnic)GET_CONFIG (port_down_io_retries);GET_CONFIG (luns_per_tgt);GET_CONFIG (intr_mode); +GET_CONFIG (lun_queue_depth); +GET_CONFIG (io_timeout_retry);
[Severity: Low]
Are these variables used anywhere in the driver?
They are fetched from the firmware config and stored, but do not appear to be read or used anywhere else.
Quoted 7 lines
drivers/scsi/fnic/fnic_res.c +0
-0GET_CONFIG (wq_copy_count); role = c->flags &FNIC_ROLE_CONFIG_MASK ;drivers/scsi/fnic/fnic_scsi.c +0
-0
[ ... ]
drivers/scsi/fnic/fnic_scsi.c static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic, · line 737
Quoted 4 lines
drivers/scsi/fnic/fnic_scsi.c +0
-0@@ -734,6 +735,8 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic,/* Clean up all outstanding io requests */ if (IS_FNIC_FCP_INITIATOR (fnic))fnic_cleanup_io (fnic,SCSI_NO_TAG );
[Severity: High]
This is a pre-existing issue, but does fnic_cleanup_io() sleep in a hardirq context?
When a firmware reset completes, the hardware raises an interrupt on the copy work queue, which is serviced by the hardirq handler fnic_isr_msix_wq_copy().
The call chain executes fnic_wq_copy_cmpl_handler() -> vnic_cq_copy_service() -> fnic_fcpio_cmpl_handler() -> fnic_fcpio_fw_reset_cmpl_handler().
For FCP initiators, this unconditionally calls fnic_cleanup_io(), which enters a while loop and calls schedule_timeout(msecs_to_jiffies(100)).
Can calling a sleeping function from a hardirq context trigger a scheduling while atomic panic?
Quoted 5 lines
drivers/scsi/fnic/fnic_scsi.c +2
-0+else if (IS_FNIC_NVME_INITIATOR (fnic)) +nvfnic_cleanup_all_nvme_ios (fnic);atomic64_set (&fnic->fnic_stats.fw_stats.active_fw_reqs,0 );atomic64_set (&fnic->fnic_stats.io_stats.active_ios,0 );
[ ... ]
drivers/scsi/fnic/fnic_scsi.c static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev, · line 1451
Quoted 7 lines
drivers/scsi/fnic/fnic_scsi.c +1
-0@@ -1443,6 +1446,7 @@ static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev,case FCPIO_FLOGI_REG_CMPL :/* fw completed flogi_reg */ case FCPIO_FLOGI_FIP_REG_CMPL :/* fw completed flogi_fip_reg */ case FCPIO_RESET_CMPL :/* fw completed reset */ +case FCPIO_NVME_ERSP_HW_CMPL :/* fw completed NVMe ERSP */ atomic64_dec (&fnic->fnic_stats.fw_stats.active_fw_reqs);break ;
[Severity: Medium]
Will the active_fw_reqs atomic counter underflow for NVMe I/O operations?
The FCPIO_NVME_ERSP_HW_CMPL and fast FCPIO_ICMND_CMPL NVMe completion paths in fnic_fcpio_cmpl_handler() decrement the active_fw_reqs atomic counter.
However, looking at the NVMe submission path in nvfnic_queue_wq_nvme_copy_desc(), it does not appear to increment this counter (unlike the FCP submission path).
Does this imbalance cause the counter to underflow, corrupting the driver statistics?
Quoted 1 line
drivers/scsi/fnic/fnic_scsi.c +0
-0default :
[ ... ]
Quoted 12 lines
drivers/scsi/fnic/fnic_scsi.c +7
-1@@ -1457,11 +1461,22 @@ static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev,break ;case FCPIO_ICMND_CMPL :/* fw completed a command */ -fnic_fcpio_icmnd_cmpl_handler (fnic, cq_index, desc); +if (IS_FNIC_FCP_INITIATOR (fnic)) +fnic_fcpio_icmnd_cmpl_handler (fnic, cq_index, desc); +else if (IS_FNIC_NVME_INITIATOR (fnic)) +nvfnic_fcpio_nvme_fast_cmpl_handler (fnic, desc); +break ; + +case FCPIO_NVME_ERSP_HW_CMPL :/* fw completed NVMe ERSP */
drivers/scsi/fnic/fnic_scsi.c static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev, · line 1479
Quoted 10 lines
drivers/scsi/fnic/fnic_scsi.c +6
-1+if (IS_FNIC_NVME_INITIATOR (fnic)) +nvfnic_fcpio_ersp_cmpl_handler (fnic, desc,1 );break ;case FCPIO_ITMF_CMPL :/* fw completed itmf (abort cmd, lun reset)*/ -fnic_fcpio_itmf_cmpl_handler (fnic, cq_index, desc); +if (IS_FNIC_FCP_INITIATOR (fnic)) +fnic_fcpio_itmf_cmpl_handler (fnic, cq_index, desc); +else if (IS_FNIC_NVME_INITIATOR (fnic)) +nvfnic_fcpio_nvme_itmf_cmpl_handler (fnic, desc);
[Severity: Medium]
Does the active_ios atomic counter underflow when NVMe ITMF (abort) completions are received?
This patch routes FCPIO_ITMF_CMPL completions to nvfnic_fcpio_nvme_itmf_cmpl_handler() for NVMe initiators. This handler decrements the active_ios atomic counter.
However, active_ios does not seem to be incremented during NVMe I/O submission in nvfnic_queuecommand().
Will this imbalance cause the active_ios counter to underflow when an ITMF completion is received?
Quoted 3 lines
drivers/scsi/fnic/fnic_scsi.c +0
-0break ;case FCPIO_FLOGI_REG_CMPL :/* fw completed flogi_reg */
[ ... ]
drivers/scsi/fnic/fnic_scsi.c void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, · line 1675
Quoted 12 lines
drivers/scsi/fnic/fnic_scsi.c +8
-0@@ -1650,6 +1665,15 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,unsigned long start_time =0 ;uint16_t hwq; +/* +* Clean up outstanding NVMe requests if firmware reset did not +* complete them before WQ copy cleanup. +*/ +if (IS_FNIC_NVME_INITIATOR (fnic)) { +nvfnic_cleanup_all_nvme_ios (fnic); +return ; + }
[Severity: Low]
Is nvfnic_cleanup_all_nvme_ios() redundantly called for every pending descriptor during work queue cleanup?
vnic_wq_copy_clean() iterates over all pending descriptors in the work queue and calls fnic_wq_copy_cleanup_handler() for each one sequentially.
If the role is an NVMe initiator, fnic_wq_copy_cleanup_handler() immediately calls nvfnic_cleanup_all_nvme_ios(fnic). This function locks the driver and iterates over the entire nvfnic_tag_map sbitmap to clean up all IOs.
Will a full global cleanup run redundantly N times (where N is the number of pending descriptors), causing an inefficient operation?
drivers/scsi/fnic/fnic_scsi.c void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, · line 1678
Quoted 2 lines
drivers/scsi/fnic/fnic_scsi.c +0
-0/* get the tag reference */ fcpio_tag_id_dec (&desc->hdr.tag, &id);
Looking at the error handling for fnic_probe() in drivers/scsi/fnic/fnic_main.c:
Quoted 8 lines
err_out_free_stats_debugfs:fnic_stats_debugfs_remove(fnic); fnic_free_ioreq_tables_mq(fnic); if (IS_FNIC_FCP_INITIATOR(fnic)) scsi_remove_host(fnic->host); err_out_nvme_drv_init: err_out_scsi_drv_init: fnic_free_intr(fnic);
[Severity: High]
Does this error path miss cleanup for NVMe initiator resources?
If fnic_stats_debugfs_init() fails in fnic_probe(), the code jumps to err_out_free_stats_debugfs. For an NVMe initiator, the error path skips FCP cleanup and falls through to err_out_nvme_drv_init, which merely calls fnic_free_intr(fnic).
It appears to entirely fail to unregister the NVMe local port (e.g., via nvme_fc_unregister_localport), and leaks fnic->nvfnic_tag_map and fnic->io_req_pool.
Because the NVMe-FC midlayer retains the nv_lport pointer, could subsequent accesses to this unregistered local port cause a use-after-free or system crash when the fnic structure is ultimately freed?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Karan Tilak Kumar
maintainerPATCH v6 8/13 scsi: fnic: Handle NVMe LS frames in FDLS
In reply to Karan Tilak KumarClassify NVMe LS request OXIDs, route NVMe LS responses and ABTS frames through the FCS receive path, and reset NVMe exchanges when FDLS tears down target ports.
Extend FDLS link-down and frame-processing paths so NVMe LS traffic follows the same discovery and cleanup state machine as FCP traffic.
---
Incorporate review comments from Lee Duncan:
Replace the NVMe LS OXID switch with a direct frame-type check. Rename the NVMe frame helper to follow fnic function naming style.
Changes between v4 and v5:
Incorporate review comments from Sashiko:
Check cleaned buffers before dereferencing them Drain OXID reclaim state on reset
Changes between v5 and v6:
Incorporate review comments from Sashiko:
Avoid stale OXID reclaim after pool reset
--- drivers/scsi/fnic/fdls_disc.c | 48 ++++++++++++++++++++++++++++++++++- drivers/scsi/fnic/fnic_fcs.c | 34 ++++++++++++++++++++----- 2 files changed, 74 insertions(+), 8 deletions(-)
drivers/scsi/fnic/fdls_disc.c +47 -1
@@ -327,12 +327,19 @@ void fdls_schedule_oxid_free_retry_work(struct work_struct *work)return ; } -clear_bit (idx, oxid_pool->pending_schedule_free); reclaim_entry->oxid_idx = idx; reclaim_entry->expires =round_jiffies (jiffies + delay_j); +spin_lock_irqsave (&fnic->fnic_lock, flags); +/* Reset may have cleared this bit while this worker allocated. */ +if (!test_and_clear_bit (idx, oxid_pool->pending_schedule_free)) { +spin_unlock_irqrestore (&fnic->fnic_lock, flags); +kfree (reclaim_entry); +continue ; + }list_add_tail (&reclaim_entry->links, &oxid_pool->oxid_reclaim_list);spin_unlock_irqrestore (&fnic->fnic_lock, flags); +schedule_delayed_work (&oxid_pool->oxid_reclaim_work, delay_j); } }
@@ -387,10 +394,25 @@ static bool fdls_is_oxid_tgt_req(uint16_t oxid)return true; } +static inline bool fdls_is_oxid_nvme_req (uint16_t oxid) +{ +return FNIC_FRAME_TYPE (oxid) ==FNIC_FRAME_TYPE_NVME_LS ; +} +static void fdls_reset_oxid_pool (struct fnic_iport_s *iport) {struct fnic_oxid_pool_s *oxid_pool = &iport->oxid_pool; +struct reclaim_entry_s *reclaim_entry, *next; +cancel_delayed_work (&oxid_pool->oxid_reclaim_work); +cancel_delayed_work (&oxid_pool->schedule_oxid_free_retry); +list_for_each_entry_safe (reclaim_entry, next, + &oxid_pool->oxid_reclaim_list, links) { +list_del (&reclaim_entry->links); +kfree (reclaim_entry); + } +bitmap_clear (oxid_pool->pending_schedule_free,0 ,FNIC_OXID_POOL_SZ ); +bitmap_clear (oxid_pool->bitmap,0 ,FNIC_OXID_POOL_SZ ); oxid_pool->next_idx =0 ; }
@@ -1288,6 +1310,10 @@ bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport)spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags);fnic_rport_exch_reset (iport->fnic, tport->fcid);spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); + }else if (IS_FNIC_NVME_INITIATOR (fnic)) { +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +nvfnic_exch_reset (iport, tport); +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); } if ((tport->flags & FNIC_FDLS_SCSI_REGISTERED) ||
@@ -1829,6 +1855,7 @@ static struct fnic_tport_s *fdls_create_tport(struct fnic_iport_s *iport, tport->fcid = fcid; tport->wwpn = wwpn; tport->iport = iport; +INIT_LIST_HEAD (&tport->ls_req_list);FNIC_FCS_DBG (KERN_DEBUG , fnic,"Need to setup tport timer callback" );
@@ -2440,6 +2467,8 @@ static void fdls_tport_timer_callback(struct timer_list *t)struct fnic *fnic = iport->fnic;uint16_t oxid;unsigned long flags; +struct fc_frame_header fchdr = {0 }; +uint8_t fcid[3 ];spin_lock_irqsave (&fnic->fnic_lock, flags);if (!tport->timer_pending) {
@@ -2532,6 +2561,12 @@ static void fdls_tport_timer_callback(struct timer_list *t)FNIC_FCS_DBG (KERN_INFO , fnic,"0x%x timeout tport 0x%x oxid 0x%x state %d\n" , iport->fcid, tport->fcid, oxid, tport->state); +if (IS_FNIC_NVME_INITIATOR (fnic)) { +hton24 (fcid, tport->fcid); +FNIC_STD_SET_S_ID (fchdr, fcid); +FNIC_STD_SET_OX_ID (fchdr, oxid); +nvfnic_process_ls_abts_rsp (iport, &fchdr); + }break ; }spin_unlock_irqrestore (&fnic->fnic_lock, flags);
@@ -2842,6 +2877,12 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport,"mismatched target zoned with FC SCSI initiator: 0x%x" , tgt_fcid); mismatched_tgt = true; + }else if (IS_FNIC_NVME_INITIATOR (fnic) && + prli_rsp->sp.spp_type !=FC_TYPE_NVME ) { +FNIC_FCS_DBG (KERN_ERR , fnic, +"mismatched target zoned with NVME initiator: 0x%x" , + tgt_fcid); + mismatched_tgt = true; }if (mismatched_tgt) {fdls_tgt_logout (iport, tport);
@@ -4853,6 +4894,8 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,return FNIC_FDMI_BLS_ABTS_RSP ; }else if (fdls_is_oxid_tgt_req (oxid)) {return FNIC_TPORT_BLS_ABTS_RSP ; + }else if (fdls_is_oxid_nvme_req (oxid)) { +return FNIC_LS_REQ_ABTS_RSP ; } FNIC_FCS_DBG(KERN_INFO, fnic, "Received ABTS rsp with unknown oxid(0x%x) from 0x%x. Dropping frame",
@@ -5085,6 +5128,9 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,case FNIC_FABRIC_BLS_ABTS_RSP :fdls_process_fabric_abts_rsp (iport, fchdr);break ; +case FNIC_LS_REQ_ABTS_RSP : +nvfnic_process_ls_abts_rsp (iport, fchdr); +break ;case FNIC_FDMI_BLS_ABTS_RSP :fdls_process_fdmi_abts_rsp (iport, fchdr);break ;
drivers/scsi/fnic/fnic_fcs.c +27 -7
@@ -31,6 +31,11 @@ struct workqueue_struct *fnic_event_queue;static uint8_t FCOE_ALL_FCF_MAC [6 ] =FC_FCOE_FLOGI_MAC ; +static inline bool fnic_is_nvme_frame (struct fc_frame_header *fchdr) +{ +return (fchdr->fh_type ==FC_TYPE_NVME ); +} +/* * Internal Functions * This function will initialize the src_mac address to be
@@ -284,6 +289,7 @@ void fnic_handle_frame(struct work_struct *work) struct fnic *fnic = container_of(work, struct fnic, frame_work);struct fnic_frame_list *cur_frame, *next;int fchdr_offset =0 ; +struct fc_frame_header *fchdr;spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags);list_for_each_entry_safe (cur_frame, next, &fnic->frame_queue, links) {
@@ -313,8 +319,14 @@ void fnic_handle_frame(struct work_struct *work) fchdr_offset = (cur_frame->rx_ethhdr_stripped) ?0 :FNIC_ETH_FCOE_HDRS_OFFSET ; -fnic_fdls_recv_frame (&fnic->iport, cur_frame->fp, - cur_frame->frame_len, fchdr_offset); + fchdr = (struct fc_frame_header *)((u8 *)cur_frame->fp + fchdr_offset); +if (IS_FNIC_NVME_INITIATOR (fnic) &&fnic_is_nvme_frame (fchdr)) { +nvfnic_ls_rsp_recv (&fnic->iport, fchdr, + cur_frame->frame_len - fchdr_offset); + }else { +fnic_fdls_recv_frame (&fnic->iport, cur_frame->fp, + cur_frame->frame_len, fchdr_offset); + }mempool_free (cur_frame->fp, fnic->frame_recv_pool);mempool_free (cur_frame, fnic->frame_elem_pool);
@@ -614,9 +626,13 @@ int fnic_alloc_rq_frame(struct vnic_rq *rq)void fnic_free_rq_buf (struct vnic_rq *rq,struct vnic_rq_buf *buf) { -void *rq_buf = buf->os_buf; +void *rq_buf;struct fnic *fnic =vnic_dev_priv (rq->vdev); +if (WARN_ON (!buf)) +return ; + + rq_buf = buf->os_buf;dma_unmap_single (&fnic->pdev->dev, buf->dma_addr, buf->len,DMA_FROM_DEVICE );
@@ -651,7 +667,7 @@ static int fnic_send_frame(struct fnic *fnic, void *frame, int frame_len)dma_unmap_single (&fnic->pdev->dev, pa, frame_len,DMA_TO_DEVICE );FNIC_FCS_DBG (KERN_INFO , fnic,"vnic work queue descriptor is not available" ); - ret =-1 ; + ret = -ENXIO ; goto fnic_send_frame_end; }
@@ -685,7 +701,6 @@ fdls_send_fcoe_frame(struct fnic *fnic, void *frame, int frame_size,struct fcoe_hdr *pfcoe_hdr;struct fnic_frame_list *frame_elem;int len = frame_size; -int ret;struct fc_frame_header *fchdr = (struct fc_frame_header *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET );
@@ -723,8 +738,7 @@ fdls_send_fcoe_frame(struct fnic *fnic, void *frame, int frame_size,fnic_debug_dump_fc_frame (fnic, fchdr, frame_size,"Outgoing" ); - ret =fnic_send_frame (fnic, frame, len); -return ret; +return fnic_send_frame (fnic, frame, len); } int fnic_send_fcoe_frame(struct fnic_iport_s *iport, void *frame,
@@ -872,6 +886,9 @@ static void fnic_wq_complete_frame_send(struct vnic_wq *wq, {struct fnic *fnic =vnic_dev_priv (wq->vdev); +if (WARN_ON (!buf)) +return ; +dma_unmap_single (&fnic->pdev->dev, buf->dma_addr, buf->len,DMA_TO_DEVICE );mempool_free (buf->os_buf, fnic->frame_pool);
@@ -914,6 +931,9 @@ void fnic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf) {struct fnic *fnic =vnic_dev_priv (wq->vdev); +if (WARN_ON (!buf)) +return ; +dma_unmap_single (&fnic->pdev->dev, buf->dma_addr, buf->len,DMA_TO_DEVICE );
Signature · 1 line
2.47.1
[email protected]
AI reviewRe: [PATCH v6 08/13] scsi: fnic: Handle NVMe LS frames in FDLS
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] Mismatched lock flags when temporarily dropping fnic->fnic_lock corrupt the CPU interrupt state.
Pre-existing issues:
- [High] Mempool-allocated FC frames are permanently leaked when hardware transmission fails.
- [High] Dropping a spinlock during list_for_each_entry_safe iteration allows concurrent list modifications, leading to use-after-free on loop resumption.
- [High] Missing synchronous cancellation of delayed works oxid_reclaim_work and schedule_oxid_free_retry causes Use-After-Free during module unload. --
--- Patch [8]: [PATCH v6 08/13] scsi: fnic: Handle NVMe LS frames in FDLS --- commit 1f929f12db7e96d3eff12397152cd2a0b81d2192
Author: Karan Tilak Kumar <[email protected]>
scsi: fnic: Handle NVMe LS frames in FDLS
Classify NVMe LS request OXIDs, route NVMe LS responses and ABTS frames through the FCS receive path, and reset NVMe exchanges when FDLS tears down target ports.
Extend FDLS link-down and frame-processing paths so NVMe LS traffic follows the same discovery and cleanup state machine as FCP traffic.
Quoted 4 lines
drivers/scsi/fnic/fdls_disc.c +0
-0
[ ... ]
Quoted 6 lines
drivers/scsi/fnic/fdls_disc.c +2
-0@@ -387,10 +394,25 @@ static bool fdls_is_oxid_tgt_req(uint16_t oxid)return true; } +static inline bool fdls_is_oxid_nvme_req (uint16_t oxid) +{
drivers/scsi/fnic/fdls_disc.c static bool fdls_is_oxid_tgt_req(uint16_t oxid) · line 408
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +6
-0+return FNIC_FRAME_TYPE (oxid) ==FNIC_FRAME_TYPE_NVME_LS ; +} +static void fdls_reset_oxid_pool (struct fnic_iport_s *iport) {struct fnic_oxid_pool_s *oxid_pool = &iport->oxid_pool; +struct reclaim_entry_s *reclaim_entry, *next; +cancel_delayed_work (&oxid_pool->oxid_reclaim_work); +cancel_delayed_work (&oxid_pool->schedule_oxid_free_retry);
[Severity: High]
This is a pre-existing issue, but does this code leave active delayed works running after module unload?
During module unload, the driver needs to synchronously cancel these works to prevent them from executing after the underlying fnic structure is freed.
Since this only attempts asynchronous cancellation via cancel_delayed_work(), if the worker is already running or concurrently dispatched, it will continue executing after kfree(fnic) is called in the module teardown.
Could this lead to a use-after-free when dereferencing oxid_pool? Should cancel_delayed_work_sync() be used instead?
Quoted 9 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+list_for_each_entry_safe (reclaim_entry, next, + &oxid_pool->oxid_reclaim_list, links) { +list_del (&reclaim_entry->links); +kfree (reclaim_entry); + } +bitmap_clear (oxid_pool->pending_schedule_free,0 ,FNIC_OXID_POOL_SZ ); +bitmap_clear (oxid_pool->bitmap,0 ,FNIC_OXID_POOL_SZ ); oxid_pool->next_idx =0 ; }
[ ... ]
drivers/scsi/fnic/fdls_disc.c bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport) · line 1312
Quoted 4 lines
drivers/scsi/fnic/fdls_disc.c +0
-0@@ -1288,6 +1310,10 @@ bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport)spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags);fnic_rport_exch_reset (iport->fnic, tport->fcid);spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags);
[Severity: High]
This is a pre-existing issue, but can this lock drop cause a use-after-free during list traversal?
When iterating over iport->tport_list or fnic->tport_event_list using list_for_each_entry_safe(), the macro caches the next element at the start of the loop.
However, dropping fnic_lock here in fdls_delete_tport() allows concurrent threads to acquire the lock and modify or free the cached next element.
When the lock is reacquired and the loop continues, will evaluating the loop condition access a freed next pointer?
drivers/scsi/fnic/fdls_disc.c bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport) · line 1314
Quoted 2 lines
drivers/scsi/fnic/fdls_disc.c +2
-0+ }else if (IS_FNIC_NVME_INITIATOR (fnic)) { +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags);
[Severity: High]
Can this sequence corrupt the CPU interrupt state?
Callers like fdls_tport_timer_callback() acquire the lock using a local flags variable:
spin_lock_irqsave(&fnic->fnic_lock, flags);
However, when this NVMe block temporarily drops the lock, it uses the shared struct member fnic->lock_flags:
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
Because fnic->lock_flags was never updated by the caller, doesn't this restore a stale, unrelated, or potentially garbage interrupt state?
Quoted 5 lines
drivers/scsi/fnic/fdls_disc.c +2
-0+nvfnic_exch_reset (iport, tport); +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); } if ((tport->flags & FNIC_FDLS_SCSI_REGISTERED) ||
[ ... ]
Quoted 4 lines
drivers/scsi/fnic/fnic_fcs.c +0
-0
[ ... ]
drivers/scsi/fnic/fnic_fcs.c static int fnic_send_frame(struct fnic *fnic, void *frame, int frame_len) · line 673
Quoted 9 lines
drivers/scsi/fnic/fnic_fcs.c +1
-1@@ -651,7 +667,7 @@ static int fnic_send_frame(struct fnic *fnic, void *frame, int frame_len)dma_unmap_single (&fnic->pdev->dev, pa, frame_len,DMA_TO_DEVICE );FNIC_FCS_DBG (KERN_INFO , fnic,"vnic work queue descriptor is not available" ); - ret =-1 ; + ret = -ENXIO ; goto fnic_send_frame_end; }
[Severity: High]
This is a pre-existing issue, but does this error path leak the mempool-allocated FC frame?
When fnic_send_frame() encounters a full hardware TX queue, it unmaps the DMA address and exits via fnic_send_frame_end:
dma_unmap_single(&fnic->pdev->dev, pa, frame_len, DMA_TO_DEVICE);
ret = -ENXIO;
goto fnic_send_frame_end;However, it fails to free the frame back to fnic->frame_pool.
Since callers like fdls_send_fcoe_frame() systematically ignore the return value, won't this frame be permanently leaked?
Under network congestion, could these leaks rapidly exhaust the mempool and prevent the driver from processing discoveries or recovering?
Quoted 1 line
drivers/scsi/fnic/fnic_fcs.c +0
-0@@ -685,7 +701,6 @@ fdls_send_fcoe_frame(struct fnic *fnic, void *frame, int frame_size,
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
Karan Tilak Kumar
maintainerPATCH v6 9/13 scsi: fnic: Send NVMe LS requests through FDLS
In reply to Karan Tilak KumarAdd the FC frame wrapper for NVMe LS requests and build LS request frames from the NVMe-FC transport callback.
Allocate OXIDs, track outstanding LS requests on the target port, arm request timers, and register the LS request callback in the NVMe FC port template.
---
Changes between v2 and v3:
Fix issues reported by kernel bot.
Guard tport logging when NVMe LS send has no tport.
Changes between v3 and v4:
Incorporate review comments from Sashiko:
Arm NVMe LS request timer before exposing the request
Changes between v4 and v5:
Incorporate review comments from Sashiko:
Avoid NVMe LS request send races
--- drivers/scsi/fnic/fdls_fc.h | 3 + drivers/scsi/fnic/fnic_nvme.c | 125 +++++++++++++++++++++++++++++++++- drivers/scsi/fnic/fnic_nvme.h | 3 + 3 files changed, 130 insertions(+), 1 deletion(-)
drivers/scsi/fnic/fdls_fc.h +3 -0
@@ -30,6 +30,9 @@#include <linux/if_ether.h> #include <scsi/fc/fc_encaps.h> #include <scsi/fc/fc_fcoe.h> +#include <linux/nvme.h> +#include <linux/nvme-fc.h> +#include <linux/nvme-fc-driver.h> #define FDLS_MIN_FRAMES (32)#define FDLS_MIN_FRAME_ELEM (4)
drivers/scsi/fnic/fnic_nvme.c +124 -1
137 lines not on this page · raw message
drivers/scsi/fnic/fnic_nvme.h +3 -0
@@ -112,6 +112,9 @@ void nvfnic_ls_req_abort(struct nvme_fc_local_port *lport, struct nvmefc_ls_req *lsreq);int nvfnic_create_queue (struct nvme_fc_local_port *lport,unsigned int idx,u16 size,void **handle); +int nvfnic_ls_req_send (struct nvme_fc_local_port *lport, +struct nvme_fc_remote_port *rport, +struct nvmefc_ls_req *ls_req);void nvfnic_ls_req_timeout (struct timer_list *t);uint16_t nvfnic_alloc_ls_req_oxid (struct fnic_iport_s *iport); struct nvfnic_ls_req *nvfnic_find_ls_req(struct fnic_tport_s *tport,
Signature · 1 line
2.47.1
[email protected]
AI reviewRe: [PATCH v6 09/13] scsi: fnic: Send NVMe LS requests through FDLS
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] The driver fails to transmit an FC ABTS frame when aborting or timing out an NVMe LS request, but…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The driver fails to transmit an FC ABTS frame when aborting or timing out an NVMe LS request, but immediately frees the local OXID, leading to potential exchange corruption and cross-talk.
- [High] Missing bounds check on ls_req->rqstlen leads to a heap buffer overflow when copying the NVMe LS request payload into the fixed-size FC frame.
--
--- Patch [9]: [PATCH v6 09/13] scsi: fnic: Send NVMe LS requests through FDLS --- commit c185a494dac754c12b5da24b26550de80039d738
Author: Karan Tilak Kumar <[email protected]>
scsi: fnic: Send NVMe LS requests through FDLS
This commit adds the FC frame wrapper for NVMe LS requests and builds LS request frames from the NVMe-FC transport callback. It allocates OXIDs, tracks outstanding LS requests on the target port, and arms request timers.
drivers/scsi/fnic/fnic_nvme.c void nvfnic_ls_req_timeout(struct timer_list *t) · line 1338
Quoted 7 lines
drivers/scsi/fnic/fnic_nvme.c +0
-0@@ -1337,6 +1337,129 @@ void nvfnic_ls_req_timeout(struct timer_list *t) ls_req->done (ls_req, -ETIMEDOUT ); }
[Severity: High]
Does this timeout handler fail to transmit an FC ABTS frame?
When an NVMe LS request times out or is aborted, the driver frees the OXID back to the pool in nvfnic_ls_req_timeout() (and the corresponding abort handler) but appears to skip sending an FC ABTS frame to the target to terminate the exchange.
If the target is still processing the request, it may send a delayed response. If the freed OXID is reused for a new request, could the target's delayed response match the new request, misrouting the payload and causing data corruption?
Quoted 3 lines
drivers/scsi/fnic/fnic_nvme.c +3
-0+ +/** +* nvfnic_ls_req_send - Send NVMe FC link service (LS) request
[ ... ]
Quoted 4 lines
drivers/scsi/fnic/fnic_nvme.c +4
-0+int nvfnic_ls_req_send (struct nvme_fc_local_port *lport, +struct nvme_fc_remote_port *rport, +struct nvmefc_ls_req *ls_req) +{
[ ... ]
Quoted 7 lines
drivers/scsi/fnic/fnic_nvme.c +7
-0+ frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_NVME_DBG (KERN_ERR , fnic, +"Failed to allocate frame to send NVME LS REQ" ); +spin_unlock_irqrestore (&fnic->fnic_lock, flags); +return -ENOMEM ; + }
[ ... ]
drivers/scsi/fnic/fnic_nvme.c void nvfnic_ls_req_timeout(struct timer_list *t) · line 1433
Quoted 2 lines
drivers/scsi/fnic/fnic_nvme.c +2
-0+ ls_req_payload = frame +FNIC_ETH_FCOE_HDRS_OFFSET +sizeof (*fchdr); +memcpy (ls_req_payload, ls_req->rqstaddr, ls_req->rqstlen);
[Severity: High]
Does this code overflow the frame buffer?
The unchecked ls_req->rqstlen is directly used as the size parameter for memcpy() into the fixed-size mempool buffer returned by fdls_alloc_frame().
If ls_req->rqstlen is larger than the available space in the frame, could this cause a heap buffer overflow?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
Karan Tilak Kumar
maintainerPATCH v6 10/13 scsi: fnic: Abort timed-out NVMe LS requests
In reply to Karan Tilak KumarAdd an FDLS helper that sends ABTS frames for outstanding NVMe LS requests.
Use the active LS request OXID when building the ABTS frame, send it through the FCoE transmit path, and call it from LS timeout and abort handling.
---
Changes between v3 and v4:
Incorporate review comments from Sashiko:
Free LS ABTS frame when send fails Reuse NVMe LS request cleanup for abort failure
Changes between v4 and v5:
Incorporate review comments from Sashiko:
Arm NVMe LS abort timer after send succeeds
Changes between v5 and v6:
Incorporate review comments from Sashiko:
Send timed-out LS aborts under fnic lock
--- drivers/scsi/fnic/fdls_disc.c | 44 ++++++++++++++++++++++ drivers/scsi/fnic/fnic_fdls.h | 2 + drivers/scsi/fnic/fnic_nvme.c | 69 ++++++++++++++++++++++++++++------- 3 files changed, 101 insertions(+), 14 deletions(-)
drivers/scsi/fnic/fdls_disc.c +44 -0
@@ -670,6 +670,50 @@ fdls_send_logo_resp(struct fnic_iport_s *iport,fnic_send_fcoe_frame (iport, frame, frame_size); } +int fdls_send_ls_req_abts (struct fnic_iport_s *iport, +struct fnic_tport_s *tport,unsigned int oxid) +{ +uint8_t *frame; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +struct fnic *fnic = iport->fnic; +struct fc_frame_header *pls_req_abts; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_frame_header ); +int ret; + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic, +"Failed to allocate frame to send ls req ABTS" ); +return -ENOMEM ; + } + + pls_req_abts = (struct fc_frame_header *) (frame + +FNIC_ETH_FCOE_HDRS_OFFSET ); +fdls_init_fabric_abts_frame (frame, iport); + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); +FNIC_STD_SET_S_ID (*pls_req_abts, s_id); +FNIC_STD_SET_D_ID (*pls_req_abts, d_id); + +FNIC_STD_SET_OX_ID (*pls_req_abts, oxid); + +FNIC_FCS_DBG (KERN_INFO , fnic, +"iport 0x%x: tport: 0x%x FDLS sending ls req abts with oxid: 0x%x" , + iport->fcid, tport->fcid, oxid); + + ret =fnic_send_fcoe_frame (iport, frame, frame_size); +if (ret) { +mempool_free (frame, fnic->frame_pool); +return ret; + } + +return 0 ; +} + +void fdls_send_tport_abts (struct fnic_iport_s *iport,struct fnic_tport_s *tport)
drivers/scsi/fnic/fnic_fdls.h +2 -0
@@ -407,6 +407,8 @@ uint16_t fdls_alloc_oxid(struct fnic_iport_s *iport, int oxid_frame_type, uint16_t *active_oxid);void fdls_free_oxid (struct fnic_iport_s *iport,uint16_t oxid,uint16_t *active_oxid); +int fdls_send_ls_req_abts (struct fnic_iport_s *iport, +struct fnic_tport_s *tport,unsigned int oxid);void fdls_tgt_logout (struct fnic_iport_s *iport,struct fnic_tport_s *tport);void fnic_del_fabric_timer_sync (struct fnic *fnic);
drivers/scsi/fnic/fnic_nvme.c +55 -14
126 lines not on this page · raw message
Signature · 1 line
2.47.1
[email protected]
AI reviewRe: [PATCH v6 10/13] scsi: fnic: Abort timed-out NVMe LS requests
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Use-after-free of `tport` in `nvfnic_ls_req_abort` due to concurrent target port deletion.…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Use-after-free of tport in nvfnic_ls_req_abort due to concurrent target port deletion.
- [High] Immediate reuse of an Exchange ID (OXID) on ABTS timeout risks cross-talk with delayed target responses. --
--- Patch [10]: [PATCH v6 10/13] scsi: fnic: Abort timed-out NVMe LS requests --- commit 39245a565a721e78c479fc226cff0b04ea8531d0
Author: Karan Tilak Kumar <[email protected]>
scsi: fnic: Abort timed-out NVMe LS requests
Add an FDLS helper that sends ABTS frames for outstanding NVMe LS requests.
Use the active LS request OXID when building the ABTS frame, send it through the FCoE transmit path, and call it from LS timeout and abort handling.
Quoted 10 lines
drivers/scsi/fnic/fnic_nvme.c +2
-0@@ -1279,6 +1283,23 @@ void nvfnic_ls_rsp_recv(struct fnic_iport_s *iport,spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); } +static bool nvfnic_ls_req_cleanup(struct fnic_iport_s *iport, + struct nvmefc_ls_req *lsreq,
drivers/scsi/fnic/fnic_nvme.c void nvfnic_ls_rsp_recv(struct fnic_iport_s *iport, · line 1297
Quoted 10 lines
drivers/scsi/fnic/fnic_nvme.c +10
-0+ uint16_t oxid) +{ +struct nvfnic_ls_req *nvfnic_ls_req = lsreq->private; + +if (!nvfnic_ls_req) +return false; + + lsreq->private =NULL ; +list_del (&nvfnic_ls_req->list); +fdls_free_oxid (iport, oxid, &nvfnic_ls_req->oxid);
[Severity: High]
Is it safe to immediately reuse the OXID on an ABTS timeout, or should it be quarantined for 2 * R_A_TOV?
When an NVMe LS request's ABTS frame times out, nvfnic_ls_req_timeout() calls nvfnic_ls_req_cleanup(), which unconditionally calls fdls_free_oxid() and returns the OXID to the active free pool.
According to Fibre Channel specifications, if an abort times out, the OXID must be quarantined for 2 * R_A_TOV because a slow target might still send a delayed response to the original aborted exchange.
If the OXID is reused immediately for a new request to the same target, could the delayed response be incorrectly matched to the new request, causing logic errors and potential data corruption?
Quoted 5 lines
drivers/scsi/fnic/fnic_nvme.c +5
-0+ nvfnic_ls_req->state =FNIC_LS_REQ_CMD_COMPLETE ; + +return true; +} +
[ ... ]
drivers/scsi/fnic/fnic_nvme.c void nvfnic_ls_req_abort(struct nvme_fc_local_port *lport, · line 1680
Quoted 10 lines
drivers/scsi/fnic/fnic_nvme.c +3
-3@@ -1648,10 +1675,24 @@ void nvfnic_ls_req_abort(struct nvme_fc_local_port *lport,/* Mark the state and flags */ nvfnic_ls_req->state =FNIC_LS_REQ_CMD_ABTS_PENDING ; - timeout =FNIC_LS_REQ_TMO_MSECS (lsreq->timeout); -mod_timer (&nvfnic_ls_req->ls_req_timer, -round_jiffies (jiffies +msecs_to_jiffies (timeout))); + oxid = nvfnic_ls_req->oxid; + + ret =fdls_send_ls_req_abts (iport, tport, oxid);
[Severity: High]
Can this result in a use-after-free of tport if nvfnic_delete_tport() is invoked concurrently?
If nvfnic_delete_tport() is invoked twice for the same target port (e.g. concurrently from the port event handler and the unload/cleanup path), the second call to nvme_fc_unregister_remoteport() will return -EINVAL since it is already marked for deletion.
The error path in nvfnic_delete_tport() then calls nvfnic_terminate_tport_ls_reqs(), which explicitly skips requests in the FNIC_LS_REQ_CMD_ABTS_STARTED state, and immediately calls kfree(tport).
Concurrently, nvfnic_ls_req_abort() may be in timer_delete_sync() with the lock dropped and the request in the ABTS_STARTED state. When nvfnic_ls_req_abort() wakes up and reacquires the lock, it checks lsreq->private (which was left intact by the cleanup path) and calls fdls_send_ls_req_abts(iport, tport, oxid). This dereferences the tport that was just freed.
Quoted 16 lines
drivers/scsi/fnic/fnic_nvme.c +14
-0+if (!ret) { + timeout =FNIC_LS_REQ_TMO_MSECS (lsreq->timeout); +mod_timer (&nvfnic_ls_req->ls_req_timer, +round_jiffies (jiffies +msecs_to_jiffies (timeout))); +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +return ; + } + +if (!nvfnic_ls_req_cleanup (iport, lsreq, oxid)) { +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +return ; + } +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); + lsreq->done (lsreq, -EAGAIN ); }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
Karan Tilak Kumar
maintainerPATCH v6 11/13 scsi: fnic: Track NVMe transport statistics
In reply to Karan Tilak KumarAdd counters for NVMe requests, responses, LS handling, aborts, and wait-queue activity.
Update NVMe I/O, completion, LS response, LS abort, and abort paths to maintain the new counters.
---
Incorporate review comments from Lee Duncan:
Convert the NVMe opcode stats helper to a switch statement. Share NVMe completion stats accounting and compute duration once.
Changes between v2 and v3:
Fix issues reported by kernel bot.
Changes between v3 and v4:
Incorporate review comments from Sashiko:
Decrement NVMe completion wait queue counter when draining completions Preserve jiffies wrap when computing NVMe abort stats
--- drivers/scsi/fnic/fnic_nvme.c | 188 ++++++++++++++++++++++++++++++++- drivers/scsi/fnic/fnic_stats.h | 21 ++++ 2 files changed, 207 insertions(+), 2 deletions(-)
drivers/scsi/fnic/fnic_nvme.c +186 -2
@@ -71,6 +71,61 @@ static void nvfnic_update_io_bytes(struct fnic *fnic, fnic->fcp_output_bytes += io_req->fcp_req->transferred_length; } +static void nvfnic_update_io_stats (struct fnic *fnic,u8 opcode) +{ +struct fnic_stats *fnic_stats = &fnic->fnic_stats; + +switch (opcode) { +case nvme_cmd_read: +atomic64_inc (&fnic_stats->nvme_stats.nvme_input_requests); +break ; +case nvme_cmd_write: +atomic64_inc (&fnic_stats->nvme_stats.nvme_output_requests); +break ; +default : +atomic64_inc (&fnic_stats->nvme_stats.nvme_control_requests); +break ; + } +} + +static void nvfnic_update_cmpl_stats (struct fnic *fnic, +struct fnic_io_req *io_req) +{ +struct io_path_stats *io_stats = &fnic->fnic_stats.io_stats; +atomic64_t *duration_stat; +unsigned long io_duration_time; + +atomic64_dec (&io_stats->active_ios); +if (atomic64_read (&fnic->io_cmpl_skip)) +atomic64_dec (&fnic->io_cmpl_skip); +else +atomic64_inc (&io_stats->io_completions); + + io_duration_time =jiffies_to_msecs (jiffies - io_req->start_time); + +if (io_duration_time <=10 ) + duration_stat = &io_stats->io_btw_0_to_10_msec; +else if (io_duration_time <=100 ) + duration_stat = &io_stats->io_btw_10_to_100_msec; +else if (io_duration_time <=500 ) + duration_stat = &io_stats->io_btw_100_to_500_msec; +else if (io_duration_time <=5000 ) + duration_stat = &io_stats->io_btw_500_to_5000_msec; +else if (io_duration_time <=10000 ) + duration_stat = &io_stats->io_btw_5000_to_10000_msec; +else if (io_duration_time <=30000 ) + duration_stat = &io_stats->io_btw_10000_to_30000_msec; +else { + duration_stat = &io_stats->io_greater_than_30000_msec; +if (io_duration_time > +atomic64_read (&io_stats->current_max_io_time)) +atomic64_set (&io_stats->current_max_io_time, + io_duration_time); + } + +atomic64_inc (duration_stat); +} +int nvfnic_alloc_fcpio_tag (struct fnic_iport_s *iport,struct fnic_io_req *io_req) {
@@ -141,6 +196,7 @@ inline int nvfnic_queue_wq_nvme_copy_desc(struct fnic *fnic,struct scatterlist *sg;struct fnic_tport_s *tport = io_req->tport;struct host_sg_desc *desc; +struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats;unsigned int i;unsigned long intr_flags;int flags;
@@ -177,6 +233,7 @@ inline int nvfnic_queue_wq_nvme_copy_desc(struct fnic *fnic,spin_unlock_irqrestore (&fnic->wq_copy_lock[idx], intr_flags);FNIC_NVME_DBG (KERN_ERR , fnic,"Enqueue failure: No descriptors\n" ); +atomic64_inc (&misc_stats->io_cpwq_alloc_failures);return -EBUSY ; }
@@ -198,6 +255,11 @@ inline int nvfnic_queue_wq_nvme_copy_desc(struct fnic *fnic, tport->max_payload_size, tport->r_a_tov, tport->e_d_tov); +atomic64_inc (&fnic->fnic_stats.fw_stats.active_fw_reqs); +if (atomic64_read (&fnic->fnic_stats.fw_stats.active_fw_reqs) > +atomic64_read (&fnic->fnic_stats.fw_stats.max_fw_reqs)) +atomic64_set (&fnic->fnic_stats.fw_stats.max_fw_reqs, +atomic64_read (&fnic->fnic_stats.fw_stats.active_fw_reqs));spin_unlock_irqrestore (&fnic->wq_copy_lock[idx], intr_flags);return 0 ;
@@ -207,20 +269,24 @@ bool nvfnic_transport_ready(struct fnic_iport_s *iport, struct fnic_tport_s *tport) { struct fnic *fnic = iport->fnic; +struct fnic_stats *fnic_stats = &fnic->fnic_stats;if (tport ==NULL )return false;if (fdls_get_state (&iport->fabric) ==FDLS_STATE_LINKDOWN || iport->state !=FNIC_IPORT_STATE_READY ) { +atomic64_inc (&fnic_stats->misc_stats.iport_not_ready);return false; }if (unlikely (fnic_chk_state_flags_locked (fnic,FNIC_FLAGS_IO_BLOCKED )))return false; -if (fdls_tport_is_offline (tport)) +if (fdls_tport_is_offline (tport)) { +atomic64_inc (&fnic_stats->misc_stats.tport_not_ready);return false; + }return true; }
@@ -230,11 +296,14 @@ int nvfnic_queuecommand(struct fnic_io_req *io_req)struct fnic_iport_s *iport = io_req->iport;struct fnic *fnic = iport->fnic;struct fnic_tport_s *tport = io_req->tport; +struct fnic_stats *fnic_stats = &fnic->fnic_stats; +struct vnic_wq_copy *wq = io_req->wq;int ret =0 ;int sg_count =0 ;unsigned long ptr;unsigned char *lba;u64 cmd_trace; +int idx;struct nvme_fc_cmd_iu *cmdiu = io_req->fcp_req->cmdaddr; io_req->cmd_state =FNIC_IOREQ_NOT_INITED ;
@@ -261,6 +330,7 @@ int nvfnic_queuecommand(struct fnic_io_req *io_req)mempool_alloc (fnic->io_sgl_pool[io_req->sgl_type],GFP_ATOMIC );if (!io_req->sgl_list) { +atomic64_inc (&fnic_stats->io_stats.alloc_failures);FNIC_NVME_DBG (KERN_INFO , fnic,"Unable to alloc SGLs\n" ); ret = -ENOMEM ;
@@ -283,6 +353,8 @@ int nvfnic_queuecommand(struct fnic_io_req *io_req) io_req->cmd_flags =FNIC_IO_INITIALIZED ;/* create copy wq desc and enqueue it */ + idx = wq - &fnic->hw_copy_wq[0 ]; +atomic64_inc (&fnic_stats->io_stats.ios[idx]); ret =nvfnic_queue_wq_nvme_copy_desc (fnic, io_req->wq, io_req, sg_count);if (ret) {FNIC_NVME_DBG (KERN_ERR , fnic,"Unable to queue frame\n" );
@@ -296,6 +368,13 @@ int nvfnic_queuecommand(struct fnic_io_req *io_req) (((u64)io_req->cmd_flags << 32) | io_req->cmd_state));return ret; } + +atomic64_inc (&fnic_stats->io_stats.active_ios); +atomic64_inc (&fnic_stats->io_stats.num_ios); +if (atomic64_read (&fnic_stats->io_stats.active_ios) > +atomic64_read (&fnic_stats->io_stats.max_active_ios)) +atomic64_set (&fnic_stats->io_stats.max_active_ios, +atomic64_read (&fnic_stats->io_stats.active_ios)); io_req->cmd_flags |=FNIC_IO_ISSUED ; out: lba = (char *)&cmdiu->sqe.rw.slba;
@@ -322,11 +401,14 @@ int nvfnic_fcpio_send(struct nvme_fc_local_port *lport,struct fnic *fnic = iport->fnic;unsigned long flags =0 ;struct fnic_tport_s *tport; +struct fnic_stats *fnic_stats = &fnic->fnic_stats;spin_lock_irqsave (&fnic->fnic_lock, flags); tport = (struct fnic_tport_s *)rport->private; +atomic64_inc (&fnic_stats->io_stats.nvme_io_reqs_rcvd);if (!nvfnic_transport_ready (iport, tport)) { +atomic64_inc (&fnic_stats->io_stats.nvme_io_rsps_sent);spin_unlock_irqrestore (&fnic->fnic_lock, flags);if (tport !=NULL ) FNIC_NVME_DBG(KERN_INFO, fnic,
@@ -357,7 +439,9 @@ int nvfnic_fcpio_send(struct nvme_fc_local_port *lport,if (io_req->tag ==FNIC_NVME_NO_FREE_TAG ) {FNIC_NVME_DBG (KERN_ERR , fnic,"No free tag available. Failing IO\n" ); +atomic64_inc (&fnic_stats->io_stats.alloc_failures);atomic_dec (&fnic->in_flight); +atomic64_inc (&fnic_stats->io_stats.nvme_io_rsps_sent);spin_unlock_irqrestore (&fnic->fnic_lock, flags);return -EBUSY ; }
@@ -383,6 +467,7 @@ void nvfnic_fcpio_nvme_fast_cmpl_handler(struct fnic *fnic,struct fcpio_tag ftag;u32 id;struct fnic_io_req *io_req; +struct fnic_stats *fnic_stats = &fnic->fnic_stats;unsigned long start_time;u64 cmd_trace;char *lba;
@@ -407,6 +492,7 @@ void nvfnic_fcpio_nvme_fast_cmpl_handler(struct fnic *fnic,WARN_ON_ONCE (!io_req);if (!io_req) { +atomic64_inc (&fnic_stats->io_stats.ioreq_null);FNIC_NVME_DBG (KERN_ERR , fnic,"IO req null hdr: %s tag: 0x%x desc: 0x%p\n" ,fnic_fcpio_status_to_str (hdr_status), id, desc);
@@ -475,6 +561,7 @@ void nvfnic_fcpio_nvme_fast_cmpl_handler(struct fnic *fnic, }if (hdr_status !=FCPIO_SUCCESS ) { +atomic64_inc (&fnic_stats->io_stats.io_failures);FNIC_NVME_DBG (KERN_INFO , fnic,"hdr status: %s\n" ,fnic_fcpio_status_to_str (hdr_status)); }
@@ -495,7 +582,9 @@ void nvfnic_fcpio_nvme_fast_cmpl_handler(struct fnic *fnic, (((u64 ) io_req->cmd_flags <<32 ) | io_req->cmd_state)); +nvfnic_update_io_stats (fnic, cmdiu->sqe.rw.opcode);nvfnic_update_io_bytes (fnic, io_req, cmdiu->sqe.rw.opcode); +nvfnic_update_cmpl_stats (fnic, io_req);nvfnic_release_nvme_ioreq_buf (iport, io_req);if (io_req->done)
@@ -513,6 +602,7 @@ void nvfnic_fcpio_ersp_cmpl_handler(struct fnic *fnic,u32 id;struct fcpio_nvme_cmpl *nvme_cmpl;struct fnic_io_req *io_req; +struct fnic_stats *fnic_stats = &fnic->fnic_stats;unsigned long start_time;uint32_t rsplen;struct nvme_fc_ersp_iu *ersp;
@@ -543,6 +633,7 @@ void nvfnic_fcpio_ersp_cmpl_handler(struct fnic *fnic, io_req =nvfnic_find_io_req_by_tag (fnic, tag);if (!io_req) { +atomic64_inc (&fnic_stats->io_stats.ioreq_null);FNIC_NVME_DBG (KERN_ERR , fnic,"IOREQ is null hdr status: %s tag: 0x%x desc: %p\n" ,fnic_fcpio_status_to_str (hdr_status), tag, desc);
@@ -635,6 +726,7 @@ void nvfnic_fcpio_ersp_cmpl_handler(struct fnic *fnic, }memcpy (io_req->fcp_req->rspaddr, ersp, rsplen); } +atomic64_inc (&fnic_stats->nvme_stats.nvme_ersps); io_req->fcp_req->rcv_rsplen = rsplen;break ;
@@ -646,6 +738,7 @@ void nvfnic_fcpio_ersp_cmpl_handler(struct fnic *fnic, }if (hdr_status !=FCPIO_SUCCESS ) { +atomic64_inc (&fnic_stats->io_stats.io_failures);FNIC_NVME_DBG (KERN_ERR , fnic,"hdr status: %s tag: 0x%x\n" ,fnic_fcpio_status_to_str (hdr_status), tag); }
@@ -668,7 +761,9 @@ void nvfnic_fcpio_ersp_cmpl_handler(struct fnic *fnic, (((u64 ) io_req->cmd_flags <<32 ) | io_req->cmd_state)); +nvfnic_update_io_stats (fnic, cmdiu->sqe.rw.opcode);nvfnic_update_io_bytes (fnic, io_req, cmdiu->sqe.rw.opcode); +nvfnic_update_cmpl_stats (fnic, io_req);nvfnic_release_nvme_ioreq_buf (iport, io_req);
@@ -689,6 +784,10 @@ void nvfnic_fcpio_nvme_itmf_cmpl_handler(struct fnic *fnic,unsigned int tag;struct fnic_io_req *io_req;struct nvme_fc_cmd_iu *cmd_iu; +struct fnic_stats *fnic_stats = &fnic->fnic_stats; +struct abort_stats *abts_stats = &fnic->fnic_stats.abts_stats; +struct terminate_stats *term_stats = &fnic->fnic_stats.term_stats; +struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats;struct fnic_iport_s *iport;fcpio_header_dec (&desc->hdr, &type, &hdr_status, &ftag);
@@ -706,6 +805,7 @@ void nvfnic_fcpio_nvme_itmf_cmpl_handler(struct fnic *fnic, io_req =nvfnic_find_io_req_by_tag (fnic, tag);WARN_ON_ONCE (!io_req);if (!io_req) { +atomic64_inc (&fnic_stats->io_stats.ioreq_null);FNIC_NVME_DBG (KERN_ERR , fnic,"IOREQ null hdr:%s tag:0x%x desc:%p\n" ,fnic_fcpio_status_to_str (hdr_status), tag, desc);
@@ -734,6 +834,10 @@ void nvfnic_fcpio_nvme_itmf_cmpl_handler(struct fnic *fnic,FNIC_NVME_DBG (KERN_ERR , fnic,"Abort timeout received tag: 0x%x id: 0x%x\n" , tag, id); +if (io_req->cmd_flags &FNIC_IO_ABTS_ISSUED ) +atomic64_inc (&abts_stats->abort_fw_timeouts); +else +atomic64_inc (&term_stats->terminate_fw_timeouts);break ;case FCPIO_ITMF_REJECTED : FNIC_NVME_DBG(KERN_ERR, fnic,
@@ -745,11 +849,19 @@ void nvfnic_fcpio_nvme_itmf_cmpl_handler(struct fnic *fnic,FNIC_NVME_DBG (KERN_ERR , fnic,"Abort IO not found tag:0x%x id:0x%x\n" , tag, id); +if (io_req->cmd_flags &FNIC_IO_ABTS_ISSUED ) +atomic64_inc (&abts_stats->abort_io_not_found); +else +atomic64_inc (&term_stats->terminate_io_not_found);break ;default :FNIC_NVME_DBG (KERN_ERR , fnic,"Abort unknown received tag: 0x%x id: 0x%x\n" , tag, id); +if (io_req->cmd_flags &FNIC_IO_ABTS_ISSUED ) +atomic64_inc (&abts_stats->abort_failures); +else +atomic64_inc (&term_stats->terminate_failures);break ; }
@@ -775,6 +887,8 @@ void nvfnic_fcpio_nvme_itmf_cmpl_handler(struct fnic *fnic, io_req->cmd_flags |=FNIC_IO_ABT_TERM_DONE ; +if (!(io_req->cmd_flags & (FNIC_IO_ABORTED |FNIC_IO_DONE ))) +atomic64_inc (&misc_stats->no_icmnd_itmf_cmpls); io_req->fcp_req->transferred_length =0 ; io_req->fcp_req->rcv_rsplen =0 ;
@@ -783,6 +897,12 @@ void nvfnic_fcpio_nvme_itmf_cmpl_handler(struct fnic *fnic,else io_req->fcp_req->status =NVME_SC_INTERNAL ; +atomic64_dec (&fnic_stats->io_stats.active_ios); +if (atomic64_read (&fnic->io_cmpl_skip)) +atomic64_dec (&fnic->io_cmpl_skip); +else +atomic64_inc (&fnic_stats->io_stats.io_completions); +nvfnic_release_nvme_ioreq_buf (iport, io_req);if (io_req->done) io_req->done (io_req);
@@ -982,9 +1102,14 @@ bool _terminate_tport_ios(struct sbitmap *map, unsigned int tag,void nvfnic_terminate_tport_ios (struct fnic *fnic,struct fnic_tport_s *tport) { +struct abort_stats *abts_stats = &fnic->fnic_stats.abts_stats;sbitmap_for_each_set (&fnic->nvfnic_tag_map, _terminate_tport_ios, tport); +FNIC_NVME_DBG (KERN_INFO , fnic, +"tport: 0x%x aborted %lld in_flight %d\n" , + tport->fcid,atomic64_read (&abts_stats->aborts), +atomic_read (&fnic->in_flight)); } bool _cleanup_all_nvme_io(struct sbitmap *map, unsigned int tag,
@@ -1114,12 +1239,15 @@ nvfnic_find_ls_req(struct fnic_tport_s *tport, uint16_t oxid)void nvfnic_fcpio_cmpl (struct fnic_io_req *io_req) {struct fnic *fnic = io_req->iport->fnic; +struct fnic_stats *fnic_stats = &fnic->fnic_stats;nvfnic_free_fcpio_tag (io_req->iport, io_req); +atomic64_inc (&fnic_stats->io_stats.nvme_ios_queued_for_rsp); io_req->waitq_start_time = jiffies;llist_add (&io_req->nvfnic_io_cmpl, &fnic->nvme_io_event_llist);atomic_inc (&fnic->nvme_io_event_queued); +atomic64_inc (&fnic_stats->io_stats.nvme_num_ios_in_waitq);queue_work (fnic_cmpl_queue, &fnic->nvme_io_cmpl_work); }
@@ -1134,6 +1262,7 @@ void nvfnic_process_ls_abts_rsp(struct fnic_iport_s *iport,uint8_t *fcid;uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);struct fnic *fnic = iport->fnic; +struct fnic_stats *fnic_stats = &fnic->fnic_stats; fcid =FNIC_STD_GET_S_ID (fchdr); tport_fcid =ntoh24 (fcid);
@@ -1161,8 +1290,12 @@ void nvfnic_process_ls_abts_rsp(struct fnic_iport_s *iport,return ; } +atomic64_inc (&fnic_stats->nvme_stats.nvme_ls_abort_responses); nvfnic_ls_req->state =FNIC_LS_REQ_ABTS_COMPLETE ; +FNIC_NVME_DBG (KERN_DEBUG , fnic,"nvme_ls_requests: %lld\n" , + (u64 )atomic64_read (&fnic_stats->nvme_stats.nvme_ls_requests)); +list_del (&nvfnic_ls_req->list);fdls_free_oxid (iport, oxid, &nvfnic_ls_req->oxid); lsreq->private =NULL ;
@@ -1197,6 +1330,7 @@ void nvfnic_ls_rsp_recv(struct fnic_iport_s *iport,sizeof (fchdr->fh_s_id);int status =0 ;struct fnic *fnic = iport->fnic; +struct fnic_stats *fnic_stats = &fnic->fnic_stats;if (len < (int )sizeof (*fchdr)) {if (len >= sid_len) {
@@ -1262,6 +1396,7 @@ void nvfnic_ls_rsp_recv(struct fnic_iport_s *iport, } nvfnic_ls_req->state =FNIC_LS_REQ_CMD_COMPLETE ; +atomic64_inc (&fnic_stats->nvme_stats.nvme_ls_responses);list_del_init (&nvfnic_ls_req->list); lsreq->private =NULL ;
@@ -1308,6 +1443,7 @@ void nvfnic_ls_req_timeout(struct timer_list *t)struct nvmefc_ls_req *ls_req = nvfnic_ls_req->ls_req;struct fnic_iport_s *iport = &fnic->iport;struct fnic_tport_s *tport = (struct fnic_tport_s *) nvfnic_ls_req->tport; +struct fnic_stats *fnic_stats = &fnic->fnic_stats;uint16_t oxid = nvfnic_ls_req->oxid;int timeout;
@@ -1342,6 +1478,7 @@ void nvfnic_ls_req_timeout(struct timer_list *t)"tport: 0x%x lsreq: 0x%x sending abort\n" , tport->fcid, nvfnic_ls_req->oxid); nvfnic_ls_req->state =FNIC_LS_REQ_CMD_ABTS_PENDING ; +atomic64_inc (&fnic_stats->nvme_stats.nvme_ls_aborts);if (fdls_send_ls_req_abts (iport, tport, nvfnic_ls_req->oxid) ==0 ) { timeout =FNIC_LS_REQ_TMO_MSECS (ls_req->timeout);
@@ -1393,6 +1530,7 @@ int nvfnic_ls_req_send(struct nvme_fc_local_port *lport,uint8_t *ls_req_payload;struct fnic *fnic = iport->fnic;struct fc_frame_header *fchdr; +struct fnic_stats *fnic_stats = &fnic->fnic_stats;struct nvfnic_ls_req *nvfnic_ls_req = ls_req->private;uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET +sizeof (struct fc_frame_header ) + ls_req->rqstlen;
@@ -1435,6 +1573,7 @@ int nvfnic_ls_req_send(struct nvme_fc_local_port *lport,return -EAGAIN ; } +atomic64_inc (&fnic_stats->nvme_stats.nvme_ls_requests);timer_setup (&nvfnic_ls_req->ls_req_timer, nvfnic_ls_req_timeout,0UL );
@@ -1467,6 +1606,11 @@ int nvfnic_ls_req_send(struct nvme_fc_local_port *lport, iport->fcid, nvfnic_ls_req->oxid, *((uint8_t *) ls_req->rqstaddr), ls_req->rqstlen); +FNIC_NVME_DBG (KERN_INFO , fnic, +"0x%x: ls_reqs count: %lld" , + iport->fcid, + (u64 )atomic64_read (&fnic_stats->nvme_stats.nvme_ls_requests)); +list_add_tail (&nvfnic_ls_req->list, &tport->ls_req_list); nvfnic_ls_req->state =FNIC_LS_REQ_CMD_PENDING ;
@@ -1614,6 +1758,7 @@ void nvfnic_ls_req_abort(struct nvme_fc_local_port *lport,struct fnic *fnic = iport->fnic;struct fnic_tport_s *tport;struct nvfnic_ls_req *nvfnic_ls_req; +struct fnic_stats *fnic_stats = &fnic->fnic_stats;uint16_t oxid;int timeout;int ret;
@@ -1675,6 +1820,7 @@ void nvfnic_ls_req_abort(struct nvme_fc_local_port *lport,/* Mark the state and flags */ nvfnic_ls_req->state =FNIC_LS_REQ_CMD_ABTS_PENDING ; +atomic64_inc (&fnic_stats->nvme_stats.nvme_ls_aborts); oxid = nvfnic_ls_req->oxid; ret =fdls_send_ls_req_abts (iport, tport, oxid);
@@ -1700,6 +1846,7 @@ bool nvfnic_queue_abort_io_req(struct fnic *fnic, int tag, {int idx;unsigned long flags; +struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; idx = io_req->wq - &fnic->hw_copy_wq[0 ];
@@ -1715,12 +1862,18 @@ bool nvfnic_queue_abort_io_req(struct fnic *fnic, int tag,atomic_dec (&fnic->in_flight);FNIC_NVME_DBG (KERN_ERR , fnic,"tag 0x%x failure: no descriptors\n" , tag); +atomic64_inc (&misc_stats->abts_cpwq_alloc_failures);return false; }fnic_queue_wq_copy_desc_itmf (io_req->wq, tag |FNIC_TAG_ABORT ,0 , task_req, tag,NULL , io_req->port_id, fnic->config.ra_tov, fnic->config.ed_tov); +atomic64_inc (&fnic->fnic_stats.fw_stats.active_fw_reqs); +if (atomic64_read (&fnic->fnic_stats.fw_stats.active_fw_reqs) > +atomic64_read (&fnic->fnic_stats.fw_stats.max_fw_reqs)) +atomic64_set (&fnic->fnic_stats.fw_stats.max_fw_reqs, +atomic64_read (&fnic->fnic_stats.fw_stats.active_fw_reqs));spin_unlock_irqrestore (&fnic->wq_copy_lock[idx], flags);atomic_dec (&fnic->in_flight);
@@ -1737,9 +1890,13 @@ void nvfnic_fcpio_abort(struct nvme_fc_local_port *lport,struct nvme_fc_cmd_iu *cmd_iu = fcp_req->cmdaddr;struct fnic_io_req *io_req = (struct fnic_io_req *)fcp_req->private;unsigned int tag = io_req->tag; +struct fnic_stats *fnic_stats = &fnic->fnic_stats; +struct abort_stats *abts_stats;unsigned long flags =0 ; +unsigned long abt_issued_time;unsigned int task_req;enum fnic_ioreq_state old_ioreq_state; +unsigned long num_ios_waitq, waitq_2sec, waitq_max_time;spin_lock_irqsave (&fnic->fnic_lock, flags);
@@ -1755,6 +1912,15 @@ void nvfnic_fcpio_abort(struct nvme_fc_local_port *lport,FNIC_NVME_DBG (KERN_INFO , fnic,"cmd tag freed or not issued:0x%x sn:0x%08x\n" , io_req->tag,be32_to_cpu (cmd_iu->csn)); + num_ios_waitq = +atomic64_read (&fnic_stats->io_stats.nvme_num_ios_in_waitq); + waitq_2sec = +atomic64_read (&fnic_stats->io_stats.nvme_ios_in_waitq_3000_msec); + waitq_max_time = +atomic64_read (&fnic_stats->io_stats.nvme_ios_in_waitq_max_time); +FNIC_NVME_DBG (KERN_INFO , fnic, +"waitq:%ld waitq_2sec:%ld max_wait:%ld\n" , + num_ios_waitq, waitq_2sec, waitq_max_time);spin_unlock_irqrestore (&fnic->fnic_lock, flags);return ; }
@@ -1802,7 +1968,24 @@ void nvfnic_fcpio_abort(struct nvme_fc_local_port *lport, task_req =FCPIO_ITMF_ABT_TASK ; } - + abts_stats = &fnic->fnic_stats.abts_stats; +atomic64_inc (&abts_stats->aborts); + + abt_issued_time =jiffies_to_msecs (jiffies - io_req->start_time); +if (abt_issued_time <=6000 ) +atomic64_inc (&abts_stats->abort_issued_btw_0_to_6_sec); +else if (abt_issued_time >6000 && abt_issued_time <=20000 ) +atomic64_inc (&abts_stats->abort_issued_btw_6_to_20_sec); +else if (abt_issued_time >20000 && abt_issued_time <=30000 ) +atomic64_inc (&abts_stats->abort_issued_btw_20_to_30_sec); +else if (abt_issued_time >30000 && abt_issued_time <=40000 ) +atomic64_inc (&abts_stats->abort_issued_btw_30_to_40_sec); +else if (abt_issued_time >40000 && abt_issued_time <=50000 ) +atomic64_inc (&abts_stats->abort_issued_btw_40_to_50_sec); +else if (abt_issued_time >50000 && abt_issued_time <=60000 ) +atomic64_inc (&abts_stats->abort_issued_btw_50_to_60_sec); +else +atomic64_inc (&abts_stats->abort_issued_greater_than_60_sec); old_ioreq_state = io_req->cmd_state; io_req->cmd_state =FNIC_IOREQ_ABTS_PENDING ;
@@ -1855,6 +2038,7 @@ void nvfnic_nvme_iodone_work(struct work_struct *work) llnode =llist_del_all (&fnic->nvme_io_event_llist);llist_for_each_entry_safe (io_req, tmp, llnode, nvfnic_io_cmpl) {atomic_dec (&fnic->nvme_io_event_queued); +atomic64_dec (&fnic->fnic_stats.io_stats.nvme_num_ios_in_waitq); io_req->fcp_req->done (io_req->fcp_req); } }
drivers/scsi/fnic/fnic_stats.h +21 -0
@@ -29,6 +29,15 @@ struct io_path_stats {atomic64_t io_greater_than_30000_msec;atomic64_t current_max_io_time;atomic64_t ios[FNIC_MQ_MAX_QUEUES ]; + +atomic64_t nvme_io_reqs_rcvd; +atomic64_t nvme_ios_queued_for_rsp; +atomic64_t nvme_io_rsps_unqueued; +atomic64_t nvme_io_rsps_sending; +atomic64_t nvme_io_rsps_sent; +atomic64_t nvme_num_ios_in_waitq; +atomic64_t nvme_ios_in_waitq_3000_msec; +atomic64_t nvme_ios_in_waitq_max_time; };struct abort_stats {
@@ -151,6 +160,17 @@ struct fnic_iport_stats {atomic64_t unsupported_frames_dropped; }; +struct nvme_host_statistics { +atomic64_t nvme_input_requests; +atomic64_t nvme_output_requests; +atomic64_t nvme_control_requests; +atomic64_t nvme_ersps; +atomic64_t nvme_ls_requests; +atomic64_t nvme_ls_responses; +atomic64_t nvme_ls_aborts; +atomic64_t nvme_ls_abort_responses; +}; +struct fnic_stats {struct stats_timestamps stats_timestamps;struct io_path_stats io_stats;
@@ -161,6 +181,7 @@ struct fnic_stats {struct vlan_stats vlan_stats;struct fc_host_statistics host_stats;struct misc_stats misc_stats; +struct nvme_host_statistics nvme_stats; };struct stats_debug_info {
Signature · 1 line
2.47.1
[email protected]
AI reviewRe: [PATCH v6 11/13] scsi: fnic: Track NVMe transport statistics
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Wait queue timeout and NVMe response metrics are declared and read, but never populated. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Wait queue timeout and NVMe response metrics are declared and read, but never populated. --
--- Patch [11]: [PATCH v6 11/13] scsi: fnic: Track NVMe transport statistics --- commit 9923585e497ab09ae056c5f083aec96413fc2a32
Author: Karan Tilak Kumar <[email protected]>
scsi: fnic: Track NVMe transport statistics
This commit adds counters for NVMe requests, responses, LS handling, aborts, and wait-queue activity. It also updates NVMe I/O, completion, LS response, LS abort, and abort paths to maintain the new counters.
Quoted 3 lines
drivers/scsi/fnic/fnic_nvme.c +0
-0
[ ... ]
Quoted 16 lines
drivers/scsi/fnic/fnic_nvme.c +9
-0@@ -1755,6 +1912,15 @@ void nvfnic_fcpio_abort(struct nvme_fc_local_port *lport,FNIC_NVME_DBG (KERN_INFO , fnic,"cmd tag freed or not issued:0x%x sn:0x%08x\n" , io_req->tag,be32_to_cpu (cmd_iu->csn)); + num_ios_waitq = +atomic64_read (&fnic_stats->io_stats.nvme_num_ios_in_waitq); + waitq_2sec = +atomic64_read (&fnic_stats->io_stats.nvme_ios_in_waitq_3000_msec); + waitq_max_time = +atomic64_read (&fnic_stats->io_stats.nvme_ios_in_waitq_max_time); +FNIC_NVME_DBG (KERN_INFO , fnic, +"waitq:%ld waitq_2sec:%ld max_wait:%ld\n" , + num_ios_waitq, waitq_2sec, waitq_max_time);spin_unlock_irqrestore (&fnic->fnic_lock, flags);return ; }
[ ... ]
drivers/scsi/fnic/fnic_nvme.c void nvfnic_nvme_iodone_work(struct work_struct *work) · line 2044
Quoted 8 lines
drivers/scsi/fnic/fnic_nvme.c +1
-0@@ -1855,6 +2038,7 @@ void nvfnic_nvme_iodone_work(struct work_struct *work) llnode =llist_del_all (&fnic->nvme_io_event_llist);llist_for_each_entry_safe (io_req, tmp, llnode, nvfnic_io_cmpl) {atomic_dec (&fnic->nvme_io_event_queued); +atomic64_dec (&fnic->fnic_stats.io_stats.nvme_num_ios_in_waitq); io_req->fcp_req->done (io_req->fcp_req); } }
[Severity: Medium]
Are we missing the logic to calculate and populate the wait queue duration metrics?
The nvme_ios_in_waitq_3000_msec and nvme_ios_in_waitq_max_time counters are read and logged in nvfnic_fcpio_abort(), but it appears they are never populated anywhere in the code. Should they be updated here in nvfnic_nvme_iodone_work() using io_req->waitq_start_time when processing the completion?
Quoted 3 lines
drivers/scsi/fnic/fnic_stats.h +0
-0
[ ... ]
Quoted 4 lines
drivers/scsi/fnic/fnic_stats.h +0
-0@@ -29,6 +29,15 @@ struct io_path_stats {atomic64_t io_greater_than_30000_msec;atomic64_t current_max_io_time;atomic64_t ios[FNIC_MQ_MAX_QUEUES ];
drivers/scsi/fnic/fnic_stats.h struct io_path_stats { · line 41
Quoted 10 lines
drivers/scsi/fnic/fnic_stats.h +9
-0+ +atomic64_t nvme_io_reqs_rcvd; +atomic64_t nvme_ios_queued_for_rsp; +atomic64_t nvme_io_rsps_unqueued; +atomic64_t nvme_io_rsps_sending; +atomic64_t nvme_io_rsps_sent; +atomic64_t nvme_num_ios_in_waitq; +atomic64_t nvme_ios_in_waitq_3000_msec; +atomic64_t nvme_ios_in_waitq_max_time; };
[Severity: Medium]
In addition to the wait queue metrics mentioned above, does this code also leave nvme_io_rsps_unqueued and nvme_io_rsps_sending completely unpopulated? They appear to be declared here but are never updated or read in the modified code.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
Karan Tilak Kumar
maintainerPATCH v6 12/13 scsi: fnic: Expose NVMe transport state in debugfs
In reply to Karan Tilak KumarCreate an NVMe debugfs directory with a per-host nvmef_info file.
Report local-port and target-port identifiers for NVMe initiator instances, and initialize and remove the debugfs entries with the NVMe probe and teardown paths.
---
Changes between v2 and v3:
Limit nvmef_info debugfs output to the allocated buffer.
Changes between v4 and v5:
Incorporate review comments from Sashiko:
Clean up NVMe debugfs on probe errors
--- drivers/scsi/fnic/fnic.h | 5 ++ drivers/scsi/fnic/fnic_debugfs.c | 94 ++++++++++++++++++++++++++++++++ drivers/scsi/fnic/fnic_main.c | 4 ++ drivers/scsi/fnic/fnic_nvme.c | 30 ++++++++++ drivers/scsi/fnic/fnic_nvme.h | 1 + drivers/scsi/fnic/fnic_stats.h | 7 +++ 6 files changed, 141 insertions(+)
drivers/scsi/fnic/fnic.h +5 -0
@@ -478,6 +478,8 @@ struct fnic {/*** FIP related data members -- end ***/ /* NVME data members */ +struct dentry *fnic_nvmef_debugfs_host; +struct dentry *fnic_nvmef_debugfs_file;struct sbitmap nvfnic_tag_map;struct work_struct nvme_io_cmpl_work;atomic_t nvme_io_event_queued;
@@ -551,6 +553,9 @@ void fnic_log_q_error(struct fnic *fnic);void fnic_handle_link_event (struct fnic *fnic);int fnic_stats_debugfs_init (struct fnic *fnic);void fnic_stats_debugfs_remove (struct fnic *fnic); +void fnic_nvmef_debugfs_init (struct fnic *fnic); +void fnic_nvmef_debugfs_remove (struct fnic *fnic); +int nvfnic_get_nvmef_info (struct fnic *fnic,struct fnic_nvmef_info *info);int fnic_is_abts_pending (struct fnic *,struct scsi_cmnd *);void fnic_handle_fip_frame (struct work_struct *work);
drivers/scsi/fnic/fnic_debugfs.c +94 -0
125 lines not on this page · raw message
drivers/scsi/fnic/fnic_main.c +4 -0
@@ -936,6 +936,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = -EOPNOTSUPP ; goto err_out_fnic_role;case VFCF_FC_NVME_INITIATOR : +fnic_nvmef_debugfs_init (fnic); fnic->role =FNIC_ROLE_NVME_INITIATOR ;dev_info (&fnic->pdev->dev,"fnic: %d is NVME initiator\n" , fnic->fnic_num);
@@ -1210,6 +1211,8 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_out_fnic_alloc_vnic_res:fnic_clear_intr_mode (fnic); err_out_fnic_set_intr_mode: +if (IS_FNIC_NVME_INITIATOR (fnic)) +fnic_nvmef_debugfs_remove (fnic);if (IS_FNIC_FCP_INITIATOR (fnic))scsi_host_put (fnic->host); err_out_fnic_role:
@@ -1280,6 +1283,7 @@ static void fnic_remove(struct pci_dev *pdev)if ((fnic_fdmi_support ==1 ) && (fnic->iport.fabric.fdmi_pending >0 ))timer_delete_sync (&fnic->iport.fabric.fdmi_timer); +fnic_nvmef_debugfs_remove (fnic);fnic_stats_debugfs_remove (fnic);/*
drivers/scsi/fnic/fnic_nvme.c +30 -0
@@ -188,6 +188,36 @@ void nvfnic_release_nvme_ioreq_buf(struct fnic_iport_s *iport, fnic->io_sgl_pool[io_req->sgl_type]); } +int nvfnic_get_nvmef_info (struct fnic *fnic,struct fnic_nvmef_info *info) +{ +int len =0 ; +struct fnic_iport_s *iport = &fnic->iport; +int buf_size = info->buf_size; +struct fnic_tport_s *tport; +struct fnic_tport_s *next; +unsigned long flags; + +if (buf_size <=0 ) +return 0 ; + + len +=scnprintf (info->info_buffer + len, buf_size - len, +"lport wwpn 0x%llx wwnn 0x%llx fcid 0x%06x\n" , + iport->wwpn, iport->wwnn, iport->fcid); + +spin_lock_irqsave (&fnic->fnic_lock, flags); +list_for_each_entry_safe (tport, next, &iport->tport_list, links) { +if (len >= buf_size -1 ) +break ; + + len +=scnprintf (info->info_buffer + len, buf_size - len, +"tport wwpn 0x%llx wwnn 0x%llx fcid 0x%06x\n" , + tport->wwpn, tport->wwnn, tport->fcid); + } +spin_unlock_irqrestore (&fnic->fnic_lock, flags); + +return len; +} + inline int nvfnic_queue_wq_nvme_copy_desc(struct fnic *fnic, struct vnic_wq_copy *wq, struct fnic_io_req *io_req,
drivers/scsi/fnic/fnic_nvme.h +1 -0
@@ -134,6 +134,7 @@ void nvfnic_terminate_tport_admin_ios(struct fnic *fnic, struct fnic_tport_s *tport);void nvfnic_cleanup_tport_io (struct fnic *fnic,struct fnic_tport_s *tport);void nvfnic_nvme_unload (struct fnic *fnic); +int nvfnic_get_nvmef_info (struct fnic *fnic,struct fnic_nvmef_info *info);void nvfnic_exch_reset (struct fnic_iport_s *iport,struct fnic_tport_s *tport);void nvfnic_nvme_iodone_work (struct work_struct *work);#else
drivers/scsi/fnic/fnic_stats.h +7 -0
@@ -191,6 +191,13 @@ struct stats_debug_info { int buffer_len; }; +struct fnic_nvmef_info { +char *info_buffer; +void *i_private; +int buf_size; +int buffer_len; +}; +int fnic_get_stats_data (struct stats_debug_info *,struct fnic_stats *);const char *fnic_role_to_str (unsigned int role);#endif /* _FNIC_STATS_H_ */
Signature · 1 line
2.47.1
[email protected]
AI reviewRe: [PATCH v6 12/13] scsi: fnic: Expose NVMe transport state in debugfs
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] The NVMe debugfs interface is registered prematurely in fnic_probe(), creating a TOCTOU window where user space can trigger a NULL pointer dereference or spinlock BUG.
- [Low] If global debugfs initialization fails, the per-host NVMe debugfs directories are created directly in the shared debugfs root.
Pre-existing issues:
- [High] Missing cleanup for NVMe resources on the fnic_probe error path.
- [High] Unsafe list traversal in fnic_delete_fcp_tports due to lock dropping. --
--- Patch [12]: [PATCH v6 12/13] scsi: fnic: Expose NVMe transport state in debugfs --- commit 0912b751cd90ccad01299101d08e42c6545ed96c
Author: Karan Tilak Kumar <[email protected]>
scsi: fnic: Expose NVMe transport state in debugfs
Create an NVMe debugfs directory with a per-host nvmef_info file. Report local-port and target-port identifiers for NVMe initiator instances, and initialize and remove the debugfs entries with the NVMe probe and teardown paths.
Quoted 4 lines
drivers/scsi/fnic/fnic_debugfs.c +0
-0
[ ... ]
drivers/scsi/fnic/fnic_debugfs.c void fnic_stats_debugfs_remove(struct fnic *fnic) · line 755
Quoted 13 lines
drivers/scsi/fnic/fnic_debugfs.c +9
-0@@ -722,3 +744,75 @@ void fnic_stats_debugfs_remove(struct fnic *fnic)debugfs_remove (fnic->fnic_stats_debugfs_host); fnic->fnic_stats_debugfs_host =NULL ; } + +void fnic_nvmef_debugfs_init (struct fnic *fnic) +{ +char name[16 ]; + +snprintf (name,sizeof (name),"host%d" , fnic->fnic_num); + + fnic->fnic_nvmef_debugfs_host =debugfs_create_dir (name, + fnic_nvmef_debugfs_root);
[Severity: Low]
Can this create the host directory in the debugfs root instead of the fnic subsystem directory?
If fnic_debugfs_init() fails during module load (for example, due to a memory allocation failure), fnic_nvmef_debugfs_root will be NULL.
When debugfs_create_dir() is later called with a NULL parent, it creates the directory directly in the global debugfs root. Should this check if fnic_nvmef_debugfs_root is valid before creating the directory?
Quoted 4 lines
drivers/scsi/fnic/fnic_main.c +0
-0
[ ... ]
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 942
Quoted 8 lines
drivers/scsi/fnic/fnic_main.c +1
-0@@ -936,6 +936,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = -EOPNOTSUPP ; goto err_out_fnic_role;case VFCF_FC_NVME_INITIATOR : +fnic_nvmef_debugfs_init (fnic); fnic->role =FNIC_ROLE_NVME_INITIATOR ;dev_info (&fnic->pdev->dev,"fnic: %d is NVME initiator\n" , fnic->fnic_num);
[Severity: High]
Could this expose the debugfs file before the fnic driver data is fully initialized?
By registering the NVMe debugfs interface here, a time-of-check to time-of-use window is created. If userspace reads the debugfs file immediately after it is created, nvfnic_get_nvmef_info() will execute before fnic_probe() has finished initializing fnic_lock and the tport_list.
This would cause list_for_each_entry_safe() in nvfnic_get_nvmef_info() to operate on a zero-initialized list, leading to a NULL pointer dereference when accessing the next pointer.
Should the debugfs initialization be moved later in the probe function, after all locks and lists are fully initialized?
[ ... ]
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 1218
Quoted 9 lines
drivers/scsi/fnic/fnic_main.c +2
-0@@ -1210,6 +1211,8 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_out_fnic_alloc_vnic_res:fnic_clear_intr_mode (fnic); err_out_fnic_set_intr_mode: +if (IS_FNIC_NVME_INITIATOR (fnic)) +fnic_nvmef_debugfs_remove (fnic);if (IS_FNIC_FCP_INITIATOR (fnic))scsi_host_put (fnic->host); err_out_fnic_role:
[Severity: High]
This is a pre-existing issue, but does the error handling path miss some cleanup for NVMe resources?
If fnic_probe() fails after fnic_nvme_drv_init() succeeds, the error handling jumps to err_out_free_stats_debugfs:
err_out_free_stats_debugfs:
fnic_stats_debugfs_remove(fnic);
fnic_free_ioreq_tables_mq(fnic);
if (IS_FNIC_FCP_INITIATOR(fnic))
scsi_remove_host(fnic->host);
err_out_nvme_drv_init:
err_out_scsi_drv_init:
fnic_free_intr(fnic);This path seems to miss calling mempool_destroy() for fnic->io_req_pool, sbitmap_free() for fnic->nvfnic_tag_map, and nvme_fc_unregister_localport().
Leaving the NVMe local port registered after freeing the fnic structure could lead to a use-after-free when the NVMe subsystem interacts with the dead port.
Quoted 4 lines
drivers/scsi/fnic/fnic_nvme.c +0
-0
[ ... ]
drivers/scsi/fnic/fnic_nvme.c void nvfnic_release_nvme_ioreq_buf(struct fnic_iport_s *iport, · line 192
Quoted 6 lines
drivers/scsi/fnic/fnic_nvme.c +2
-0@@ -188,6 +188,36 @@ void nvfnic_release_nvme_ioreq_buf(struct fnic_iport_s *iport, fnic->io_sgl_pool[io_req->sgl_type]); } +int nvfnic_get_nvmef_info (struct fnic *fnic,struct fnic_nvmef_info *info) +{
[Severity: High]
This isn't a bug introduced by this patch, but does fnic_delete_fcp_tports() have an unsafe list traversal?
When iterating over fnic->iport.tport_list, the code uses list_for_each_entry_safe():
fnic_fcs.c:fnic_delete_fcp_tports() {
...
list_for_each_entry_safe(tport, next, &fnic->iport.tport_list, links) {
...
nvfnic_delete_tport(...)
}However, nvfnic_delete_tport() temporarily drops the lock:
fnic_nvme.c:nvfnic_delete_tport() {
...
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
ret = nvme_fc_unregister_remoteport(tport->nv_rport);
...
}Because the lock is dropped during the iteration, concurrent threads could acquire the lock, remove the cached next element from the list, and free it.
When nvfnic_delete_tport() returns and the loop continues, could this result in dereferencing a stale next pointer?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
Karan Tilak Kumar
maintainerPATCH v6 13/13 scsi: fnic: Bump up version number
In reply to Karan Tilak KumarBump up version number to 1.9.0.0.
--- drivers/scsi/fnic/fnic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/fnic/fnic.h +1 -1
@@ -31,7 +31,7 @@#define DRV_NAME "fnic"#define DRV_DESCRIPTION "Cisco FCoE HBA Driver" -#define DRV_VERSION "1.8.0.3" +#define DRV_VERSION "1.9.0.0"#define PFX DRV_NAME ": "#define DFX DRV_NAME "%d: "
Signature · 1 line
2.47.1
[email protected]
AI reviewRe: [PATCH v6 13/13] scsi: fnic: Bump up version number
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Missing Signed-off-by tag for a Co-developed-by contributor in the commit message metadata. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Missing Signed-off-by tag for a Co-developed-by contributor in the commit message metadata. --
--- Patch [13]: [PATCH v6 13/13] scsi: fnic: Bump up version number --- commit 0b3f5f40f11defa58bb2ce3f372901e2f5c3c7e6
Author: Karan Tilak Kumar <[email protected]>
scsi: fnic: Bump up version number
This commit bumps the Cisco FCoE HBA Driver (fnic) version number to 1.9.0.0.
Quoted 2 lines
Signed-off-by Karan Tilak Kumar <[email protected]>Co-developed-by Hannes Reinecke <[email protected]>
[Severity: Low]
This isn't a bug in the code, but should there be a corresponding Signed-off-by tag for Hannes Reinecke here? According to the kernel patch submission guidelines, every Co-developed-by tag must be accompanied by a Signed-off-by tag from the same developer to meet Developer's Certificate of Origin requirements.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=13
Karan Tilak Kumar (kartilak)
maintainerQuoted 160 lines · Karan Tilak Kumar
Hi Martin, reviewers,
This series adds functionality for NVMe initiator to the fnic driver.
The changes enable the fnic driver to act as an NVMe initiator over Fibre Channel (FC-NVMe), allowing the host to discover and communicate with NVMe targets using the existing fnic infrastructure. The patches prepare the driver for full FC-NVMe initiator operation while maintaining existing SCSI/FC functionality.
These are some of the salient patches:
o. Make fnic debug logging usable by SCSI and NVMe initiator roles. o. Use fnic instance numbers for non-SCSI-facing identifiers. o. Decode firmware roles for FCP, NVMe, and unsupported targets. o. Advertise NVMe initiator service parameters during FC discovery. o. Add FDLS role handling for NVMe initiator discovery flows. o. Add the NVMe/FC transport path and port registration. o. Route completions, resets, and LS frames by initiator role. o. Add NVMe LS timeouts, statistics, and debugfs state reporting.
Even though the patches have been made into a series, some patches are heavier than others. But, every effort has been made to keep the purpose of each patch as a single-purpose, and to compile cleanly. All the individual patches compile cleanly. The compiler used is GCC 14.2.
This patch set has been tested as a whole. Therefore, the tested-by fields have been added only to one patch in the set.
I've refrained from adding tested-by to most of the patches, so as to not mislead the reviewer/reader.A brief note on the unit tests:
o. Configure multipathing, and run link flaps on single link. IOs drop briefly, but pick up as expected.
o. Configure multipathing, and run link flaps on two links, with a 30 second delay in between. IOs drop briefly, but pick up as expected. o. Repeat the above tests with 1 queue and 64 queues.
o. Perform tests with Netapp and Pure targets.All tests were successful.
This set of patches was reviewed before submitting upstream, and the following review comments were incorporated.
Incorporate review comments from Hannes Reinecke:
Decode target roles explicitly and report unsupported roles. Remove the empty line before the FLOGI completion else block. Add a short comment for the NVMe ERSP completion case.
Incorporate review comments from Lee Duncan:
Replace the NVMe LS OXID switch with a direct frame-type check. Rename the NVMe frame helper to follow fnic function naming style. Convert the NVMe opcode stats helper to a switch statement. Share NVMe completion stats accounting and compute duration once.
Changes between v1 and v2:
Incorporate review comments from Marco Crivellari:
Explicitly useWQ_PERCPUfor the fnic completion workqueue.Changes between v2 and v3:
Fix issues reported by kernel bot.
Add the active OXID to the tport timeout debug print. Guard NVMe I/O and LS request debug logs when tport is NULL. Validate ERSP response length before copying the response. Validate LS response frame and payload lengths before copying. Limitnvmef_infodebugfs output to the allocated buffer.Changes between v3 and v4:
Incorporate review comments from Sashiko:
Keep role strings private and const.
Clear NVMe SGL DMA address on map failure.
Drop fnic lock around NVMe tport registration.
Unlink unregistered NVMe tports before freeing them.
Clear NVMe unload completion pointer on exit.
Take fnic lock before NVMe tport cleanup tag lookup.
Clear NVMe tport delete completion pointer on unregister failure. Arm NVMe LS request timer before exposing the request.
Free LS ABTS frame when send fails.
Reuse NVMe LS request cleanup for abort failure.
Decrement NVMe completion wait queue counter when draining completions. Preserve jiffies wrap when computing NVMe abort stats.Changes between v4 and v5:
Incorporate review comments from Sashiko:
Set NVMe wait timestamp before queueing completions Use async timer delete for NVMe LS responses Complete failed NVMe ITMF aborts
Track NVMe SGL DMA mapping state
Detach NVMe LS cleanup before callbacks
Defer NVMe table frees until cleanup
Lock NVMe tport IO termination lookup
Count NVMe ERSP completions as firmware completions Gate NVMe completions by initiator role
Check cleaned buffers before dereferencing them Drain OXID reclaim state on reset
Avoid NVMe LS request send races
Arm NVMe LS abort timer after send succeeds
Clean up NVMe debugfs on probe errors
Clarify that FC-NVMe PRLI must not set Establish Image Pair.Changes between v5 and v6:
Synchronize the tport retry timer before remote-port delete completes. Avoid requeueing FDLS tport delete from the NVMe remote-port callback. Drop the unnecessary else after the tport delete timeout return. Name the tport cleanup retry limit instead of using a literal. Publish can-free before completion and set cleanup-pending on timeout. Incorporate review comments from Sashiko:
Flush NVMe completions after copy WQ cleanup
Reset NVMe SGL state before each I/O
Claim tport I/O before aborting it
Synchronize LS response timer before done
Preserve LS requests during abort start
Drain LS requests on rport unregister failure
Defer tport free after rport timeout
Avoid extra PCI device reference for lportThanks,
Karan
Karan Tilak Kumar (13):
scsi: fnic: Make debug logging protocol independent
scsi: fnic: Usefnic_numfor non-SCSI identifiers
scsi: fnic: Decode firmware role configuration
scsi: fnic: Advertise NVMe initiator service parameters
scsi: fnic: Add FDLS role handling for NVMe initiators
scsi: fnic: Add the NVMe/FC transport path
scsi: fnic: Route completions and resets by initiator role
scsi: fnic: Handle NVMe LS frames in FDLS
scsi: fnic: Send NVMe LS requests through FDLS
scsi: fnic: Abort timed-out NVMe LS requests
scsi: fnic: Track NVMe transport statistics
scsi: fnic: Expose NVMe transport state in debugfs
scsi: fnic: Bump up version numberdrivers/scsi/fnic/Makefile | 1 + drivers/scsi/fnic/fcpio.h | 35 + drivers/scsi/fnic/fdls_disc.c | 978 +++++++------ drivers/scsi/fnic/fdls_fc.h | 7 + drivers/scsi/fnic/fip.c | 117 +- drivers/scsi/fnic/fip.h | 2 +- drivers/scsi/fnic/fnic.h | 104 +- drivers/scsi/fnic/fnic_debugfs.c | 99 +- drivers/scsi/fnic/fnic_fcs.c | 199 +-- drivers/scsi/fnic/fnic_fdls.h | 48 +- drivers/scsi/fnic/fnic_io.h | 24 +- drivers/scsi/fnic/fnic_isr.c | 28 +- drivers/scsi/fnic/fnic_main.c | 214 ++- drivers/scsi/fnic/fnic_nvme.c | 2268 ++++++++++++++++++++++++++++++ drivers/scsi/fnic/fnic_nvme.h | 214 +++ drivers/scsi/fnic/fnic_res.c | 31 +- drivers/scsi/fnic/fnic_res.h | 32 +- drivers/scsi/fnic/fnic_scsi.c | 251 ++-- drivers/scsi/fnic/fnic_stats.h | 28 + drivers/scsi/fnic/fnic_trace.c | 3 +- drivers/scsi/fnic/vnic_devcmd.h | 2 +- 21 files changed, 3906 insertions(+), 779 deletions(-)
Quoted 7 lines
create mode 100644
drivers/scsi/fnic/fnic_nvme.c
create mode 100644drivers/scsi/fnic/fnic_nvme.h--
2.47.1
Hi Martin,
Thank you for your patience.
For the v6 fnic NVMe/FC series, we reviewed the Sashiko feedback and addressed the issues that we believe are valid and within the scope of this patch series.
Some of the issues we fixed based on Sashiko feedback across the recent revisions include:
- clearing and tracking NVMe SGL DMA mapping state correctly;
- dropping the fnic lock around NVMe tport registration;
- unlinking unregistered NVMe tports before freeing them;
- clearing NVMe unload and tport-delete completion pointers on failure paths;
- using async/synchronized timer deletion for NVMe LS responses;
- detaching NVMe LS cleanup before callbacks;
- draining LS requests on rport unregister failure;
- preserving LS requests during abort start;
- avoiding stale OXID reclaim after pool reset;
- flushing NVMe completions after copy workqueue cleanup;
- avoiding an extra PCI device reference for the lport.
We also reviewed the latest critical Sashiko findings. The items around NVMe PRLI formatting and target capability handling were evaluated against real targets in our test environment, and we did not observe any discovery or login failures. Based on that testing, we do not believe these are practical showstoppers for the v6 series.
A few other critical-looking reports are either pre-existing FDLS issues or are already addressed by later patches in the same v6 series. In our opinion, the remaining Sashiko findings are not critical enough to hold integration of this series. They can be handled later if needed.
We would highly appreciate your help in integrating this series.
Thanks,
Karan
Martin K. Petersen
AppliedKaran,
Quoted 7 lines
This series adds functionality for NVMe initiator to the fnic driver.
The changes enable the fnic driver to act as an NVMe initiator over Fibre Channel (FC-NVMe), allowing the host to discover and communicate with NVMe targets using the existing fnic infrastructure. The patches prepare the driver for full FC-NVMe initiator operation while maintaining existing SCSI/FC functionality.
Applied to 7.3/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen
Martin K. Petersen
AppliedQuoted 9 lines · Karan Tilak Kumar
This series adds functionality for NVMe initiator to the fnic driver.
The changes enable the fnic driver to act as an NVMe initiator over Fibre Channel (FC-NVMe), allowing the host to discover and communicate with NVMe targets using the existing fnic infrastructure. The patches prepare the driver for full FC-NVMe initiator operation while maintaining existing SCSI/FC functionality.
[...]
Applied to 7.3/scsi-queue, thanks!
[01/13] scsi: fnic: Make debug logging protocol independent
https://git.kernel.org/mkp/scsi/c/b93c38a9f2ce [02/13] scsi: fnic: Use fnic_num for non-SCSI identifiers https://git.kernel.org/mkp/scsi/c/6128fec94173 [03/13] scsi: fnic: Decode firmware role configuration https://git.kernel.org/mkp/scsi/c/12bd1b29128e [04/13] scsi: fnic: Advertise NVMe initiator service parameters https://git.kernel.org/mkp/scsi/c/20b991c30229 [05/13] scsi: fnic: Add FDLS role handling for NVMe initiators https://git.kernel.org/mkp/scsi/c/188dfadf025a [06/13] scsi: fnic: Add the NVMe/FC transport path https://git.kernel.org/mkp/scsi/c/5efdd5cf9281 [07/13] scsi: fnic: Route completions and resets by initiator role https://git.kernel.org/mkp/scsi/c/b3f4bc0a7aec [08/13] scsi: fnic: Handle NVMe LS frames in FDLS https://git.kernel.org/mkp/scsi/c/021db11aba3b [09/13] scsi: fnic: Send NVMe LS requests through FDLS https://git.kernel.org/mkp/scsi/c/39bf075599bd [10/13] scsi: fnic: Abort timed-out NVMe LS requests https://git.kernel.org/mkp/scsi/c/f06ee33d72f5 [11/13] scsi: fnic: Track NVMe transport statistics https://git.kernel.org/mkp/scsi/c/d25a557d344f [12/13] scsi: fnic: Expose NVMe transport state in debugfs https://git.kernel.org/mkp/scsi/c/8ef412ce8bb3 [13/13] scsi: fnic: Bump up version number https://git.kernel.org/mkp/scsi/c/2265541d221d
Signature · 1 line
Martin K. Petersen