* [PATCH v5 00/13] Introduce functionality for NVMe initiator
@ 2026-06-24 4:43 Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 01/13] scsi: fnic: Make debug logging protocol independent Karan Tilak Kumar
` (12 more replies)
0 siblings, 13 replies; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, 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 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.
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 | 969 +++++++------
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 | 211 ++-
drivers/scsi/fnic/fnic_nvme.c | 2202 ++++++++++++++++++++++++++++++
drivers/scsi/fnic/fnic_nvme.h | 209 +++
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, 3824 insertions(+), 778 deletions(-)
create mode 100644 drivers/scsi/fnic/fnic_nvme.c
create mode 100644 drivers/scsi/fnic/fnic_nvme.h
--
2.47.1
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v5 01/13] scsi: fnic: Make debug logging protocol independent
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
@ 2026-06-24 4:43 ` Karan Tilak Kumar
2026-06-24 5:08 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 02/13] scsi: fnic: Use fnic_num for non-SCSI identifiers Karan Tilak Kumar
` (11 subsequent siblings)
12 siblings, 1 reply; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, Karan Tilak Kumar, Hannes Reinecke
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 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.
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
---
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(-)
diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c
index 554dea767885..5880ca28a0ad 100644
--- a/drivers/scsi/fnic/fdls_disc.c
+++ b/drivers/scsi/fnic/fdls_disc.c
@@ -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);
}
diff --git a/drivers/scsi/fnic/fip.c b/drivers/scsi/fnic/fip.c
index 132f00512ee1..21d08a710f0d 100644
--- a/drivers/scsi/fnic/fip.c
+++ b/drivers/scsi/fnic/fip.c
@@ -27,7 +27,7 @@ void fnic_fcoe_reset_vlans(struct fnic *fnic)
}
spin_unlock_irqrestore(&fnic->vlans_lock, flags);
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"Reset vlan complete\n");
}
@@ -46,7 +46,7 @@ void fnic_fcoe_send_vlan_req(struct fnic *fnic)
frame = fdls_alloc_frame(iport);
if (frame == NULL) {
- FNIC_FIP_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_ERR, fnic,
"Failed to allocate frame to send VLAN req");
return;
}
@@ -54,10 +54,10 @@ void fnic_fcoe_send_vlan_req(struct fnic *fnic)
fnic_fcoe_reset_vlans(fnic);
fnic->set_vlan(fnic, 0);
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"set vlan done\n");
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"got MAC 0x%x:%x:%x:%x:%x:%x\n", iport->hwmac[0],
iport->hwmac[1], iport->hwmac[2], iport->hwmac[3],
iport->hwmac[4], iport->hwmac[5]);
@@ -81,13 +81,13 @@ void fnic_fcoe_send_vlan_req(struct fnic *fnic)
iport->fip.state = FDLS_FIP_VLAN_DISCOVERY_STARTED;
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"Send VLAN req\n");
fnic_send_fip_frame(iport, frame, frame_size);
vlan_tov = jiffies + msecs_to_jiffies(FCOE_CTLR_FIPVLAN_TOV);
mod_timer(&fnic->retry_fip_timer, round_jiffies(vlan_tov));
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"fip timer set\n");
}
@@ -111,11 +111,11 @@ void fnic_fcoe_process_vlan_resp(struct fnic *fnic, struct fip_header *fiph)
struct fip_vlan_desc *vlan_desc;
unsigned long flags;
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"fnic 0x%p got vlan resp\n", fnic);
desc_len = be16_to_cpu(vlan_notif->fip.fip_dl_len);
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"desc_len %d\n", desc_len);
spin_lock_irqsave(&fnic->vlans_lock, flags);
@@ -128,23 +128,20 @@ void fnic_fcoe_process_vlan_resp(struct fnic *fnic, struct fip_header *fiph)
if (vlan_desc->fd_desc.fip_dtype == FIP_DT_VLAN) {
if (vlan_desc->fd_desc.fip_dlen != 1) {
- FNIC_FIP_DBG(KERN_INFO, fnic->host,
- fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"Invalid descriptor length(%x) in VLan response\n",
vlan_desc->fd_desc.fip_dlen);
}
num_vlan++;
vid = be16_to_cpu(vlan_desc->fd_vlan);
- FNIC_FIP_DBG(KERN_INFO, fnic->host,
- fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"process_vlan_resp: FIP VLAN %d\n", vid);
vlan = kzalloc_obj(*vlan);
if (!vlan) {
/* retry from timer */
- FNIC_FIP_DBG(KERN_INFO, fnic->host,
- fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"Mem Alloc failure\n");
spin_unlock_irqrestore(&fnic->vlans_lock,
flags);
@@ -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
+ * 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;
}
@@ -170,7 +167,7 @@ void fnic_fcoe_process_vlan_resp(struct fnic *fnic, struct fip_header *fiph)
/* any VLAN descriptors present ? */
if (num_vlan == 0) {
atomic64_inc(&fnic_stats->vlan_stats.resp_withno_vlanID);
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"fnic 0x%p No VLAN descriptors in FIP VLAN response\n",
fnic);
}
@@ -195,7 +192,7 @@ void fnic_fcoe_start_fcf_discovery(struct fnic *fnic)
frame = fdls_alloc_frame(iport);
if (frame == NULL) {
- FNIC_FIP_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_ERR, fnic,
"Failed to allocate frame to start FCF discovery");
return;
}
@@ -222,7 +219,7 @@ void fnic_fcoe_start_fcf_discovery(struct fnic *fnic)
FNIC_STD_SET_NODE_NAME(&pdisc_sol->name_desc.fd_wwn, iport->wwnn);
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"Start FCF discovery\n");
fnic_send_fip_frame(iport, frame, frame_size);
@@ -257,16 +254,14 @@ void fnic_fcoe_fip_discovery_resp(struct fnic *fnic, struct fip_header *fiph)
switch (iport->fip.state) {
case FDLS_FIP_FCF_DISCOVERY_STARTED:
if (be16_to_cpu(disc_adv->fip.fip_flags) & FIP_FL_SOL) {
- FNIC_FIP_DBG(KERN_INFO, fnic->host,
- fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"fnic 0x%p Solicited adv\n", fnic);
if ((disc_adv->prio_desc.fd_pri <
iport->selected_fcf.fcf_priority)
&& (be16_to_cpu(disc_adv->fip.fip_flags) & FIP_FL_AVAIL)) {
- FNIC_FIP_DBG(KERN_INFO, fnic->host,
- fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"fnic 0x%p FCF Available\n", fnic);
memcpy(iport->selected_fcf.fcf_mac,
disc_adv->mac_desc.fd_mac, ETH_ALEN);
@@ -274,8 +269,8 @@ void fnic_fcoe_fip_discovery_resp(struct fnic *fnic, struct fip_header *fiph)
disc_adv->prio_desc.fd_pri;
iport->selected_fcf.fka_adv_period =
be32_to_cpu(disc_adv->fka_adv_desc.fd_fka_period);
- FNIC_FIP_DBG(KERN_INFO, fnic->host,
- fnic->fnic_num, "adv time %d",
+ FNIC_FIP_DBG(KERN_INFO, fnic,
+ "adv time %d",
iport->selected_fcf.fka_adv_period);
iport->selected_fcf.ka_disabled =
(disc_adv->fka_adv_desc.fd_flags & 1);
@@ -294,8 +289,7 @@ void fnic_fcoe_fip_discovery_resp(struct fnic *fnic, struct fip_header *fiph)
iport->selected_fcf.fka_adv_period =
be32_to_cpu(disc_adv->fka_adv_desc.fd_fka_period);
FNIC_FIP_DBG(KERN_INFO,
- fnic->host,
- fnic->fnic_num,
+ fnic,
"change fka to %d",
iport->selected_fcf.fka_adv_period);
}
@@ -362,7 +356,7 @@ void fnic_fcoe_start_flogi(struct fnic *fnic)
frame = fdls_alloc_frame(iport);
if (frame == NULL) {
- FNIC_FIP_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_ERR, fnic,
"Failed to allocate frame to start FIP FLOGI");
return;
}
@@ -415,7 +409,7 @@ void fnic_fcoe_start_flogi(struct fnic *fnic)
oxid = fdls_alloc_oxid(iport, FNIC_FRAME_TYPE_FABRIC_FLOGI,
&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,
"Failed to allocate OXID to send FIP FLOGI");
mempool_free(frame, fnic->frame_pool);
return;
@@ -427,7 +421,7 @@ void fnic_fcoe_start_flogi(struct fnic *fnic)
FNIC_STD_SET_NODE_NAME(&pflogi_req->flogi_desc.flogi.els.fl_wwnn,
iport->wwnn);
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"FIP start FLOGI\n");
fnic_send_fip_frame(iport, frame, frame_size);
iport->fip.flogi_retry++;
@@ -457,11 +451,11 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header *fiph)
struct fnic_stats *fnic_stats = &fnic->fnic_stats;
struct fc_frame_header *fchdr = &flogi_rsp->rsp_desc.flogi.fchdr;
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"fnic 0x%p FIP FLOGI rsp\n", fnic);
desc_len = be16_to_cpu(flogi_rsp->fip.fip_dl_len);
if (desc_len != 38) {
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"Invalid Descriptor List len (%x). Dropping frame\n",
desc_len);
return;
@@ -471,7 +465,7 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header *fiph)
&& (flogi_rsp->rsp_desc.fd_desc.fip_dlen == 36))
|| !((flogi_rsp->mac_desc.fd_desc.fip_dtype == 2)
&& (flogi_rsp->mac_desc.fd_desc.fip_dlen == 2))) {
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"Dropping frame invalid type and len mix\n");
return;
}
@@ -484,7 +478,7 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header *fiph)
|| (s_id != FC_FID_FLOGI)
|| (frame_type != FNIC_FABRIC_FLOGI_RSP)
|| (fchdr->fh_type != 0x01)) {
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"Dropping invalid frame: s_id %x F %x R %x t %x OX_ID %x\n",
s_id, fchdr->fh_f_ctl[0], fchdr->fh_r_ctl,
fchdr->fh_type, FNIC_STD_GET_OX_ID(fchdr));
@@ -492,7 +486,7 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header *fiph)
}
if (iport->fip.state == FDLS_FIP_FLOGI_STARTED) {
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"fnic 0x%p rsp for pending FLOGI\n", fnic);
oxid = FNIC_STD_GET_OX_ID(fchdr);
@@ -502,8 +496,7 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header *fiph)
if ((be16_to_cpu(flogi_rsp->fip.fip_dl_len) == FIP_FLOGI_LEN)
&& (flogi_rsp->rsp_desc.flogi.els.fl_cmd == ELS_LS_ACC)) {
- FNIC_FIP_DBG(KERN_INFO, fnic->host,
- fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"fnic 0x%p FLOGI success\n", fnic);
memcpy(iport->fpma, flogi_rsp->mac_desc.fd_mac, ETH_ALEN);
iport->fcid =
@@ -519,8 +512,7 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header *fiph)
if (fnic_fdls_register_portid(iport, iport->fcid, NULL)
!= 0) {
- FNIC_FIP_DBG(KERN_INFO, fnic->host,
- fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"fnic 0x%p flogi registration failed\n",
fnic);
return;
@@ -528,8 +520,8 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header *fiph)
iport->fip.state = FDLS_FIP_FLOGI_COMPLETE;
iport->state = FNIC_IPORT_STATE_FABRIC_DISC;
- FNIC_FIP_DBG(KERN_INFO, fnic->host,
- fnic->fnic_num, "iport->state:%d\n",
+ FNIC_FIP_DBG(KERN_INFO, fnic,
+ "iport->state:%d\n",
iport->state);
fnic_fdls_disc_start(iport);
if (!((iport->selected_fcf.ka_disabled)
@@ -575,7 +567,7 @@ void fnic_common_fip_cleanup(struct fnic *fnic)
if (!iport->usefip)
return;
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"fnic 0x%p fip cleanup\n", fnic);
iport->fip.state = FDLS_FIP_INIT;
@@ -617,7 +609,7 @@ void fnic_fcoe_process_cvl(struct fnic *fnic, struct fip_header *fiph)
int found = false;
int max_count = 0;
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"fnic 0x%p clear virtual link handler\n", fnic);
if (!((cvl_msg->fcf_mac_desc.fd_desc.fip_dtype == 2)
@@ -625,7 +617,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,
@@ -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);
@@ -664,12 +655,12 @@ void fnic_fcoe_process_cvl(struct fnic *fnic, struct fip_header *fiph)
spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
max_count++;
if (max_count >= FIP_FNIC_RESET_WAIT_COUNT) {
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"Rthr waited too long. Skipping handle link event %p\n",
fnic);
return;
}
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"fnic reset in progress. Link event needs to wait %p",
fnic);
}
@@ -714,7 +705,7 @@ int fdls_fip_recv_frame(struct fnic *fnic, void *frame)
return true;
}
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Not a FIP Frame");
return false;
}
@@ -724,7 +715,7 @@ void fnic_work_on_fip_timer(struct work_struct *work)
struct fnic *fnic = container_of(work, struct fnic, fip_timer_work);
struct fnic_iport_s *iport = &fnic->iport;
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"FIP timeout\n");
if (iport->fip.state == FDLS_FIP_VLAN_DISCOVERY_STARTED) {
@@ -732,7 +723,7 @@ void fnic_work_on_fip_timer(struct work_struct *work)
} else if (iport->fip.state == FDLS_FIP_FCF_DISCOVERY_STARTED) {
u8 zmac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"FCF Discovery timeout\n");
if (memcmp(iport->selected_fcf.fcf_mac, zmac, ETH_ALEN) != 0) {
@@ -754,13 +745,13 @@ void fnic_work_on_fip_timer(struct work_struct *work)
round_jiffies(fcf_tov));
}
} else {
- FNIC_FIP_DBG(KERN_INFO, fnic->host,
- fnic->fnic_num, "FCF Discovery timeout\n");
+ FNIC_FIP_DBG(KERN_INFO, fnic,
+ "FCF Discovery timeout\n");
fnic_vlan_discovery_timeout(fnic);
}
} else if (iport->fip.state == FDLS_FIP_FLOGI_STARTED) {
fdls_schedule_oxid_free(iport, &iport->active_oxid_fabric_req);
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"FLOGI timeout\n");
if (iport->fip.flogi_retry < fnic->config.flogi_retries)
fnic_fcoe_start_flogi(fnic);
@@ -807,7 +798,7 @@ void fnic_handle_enode_ka_timer(struct timer_list *t)
frame = fdls_alloc_frame(iport);
if (frame == NULL) {
- FNIC_FIP_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_ERR, fnic,
"Failed to allocate frame to send enode ka");
return;
}
@@ -828,7 +819,7 @@ void fnic_handle_enode_ka_timer(struct timer_list *t)
memcpy(penode_ka->eth.h_dest, iport->selected_fcf.fcf_mac, ETH_ALEN);
memcpy(penode_ka->mac_desc.fd_mac, iport->hwmac, ETH_ALEN);
- FNIC_FIP_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_DEBUG, fnic,
"Handle enode KA timer\n");
fnic_send_fip_frame(iport, frame, frame_size);
enode_ka_tov = jiffies
@@ -861,7 +852,7 @@ void fnic_handle_vn_ka_timer(struct timer_list *t)
frame = fdls_alloc_frame(iport);
if (frame == NULL) {
- FNIC_FIP_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_ERR, fnic,
"Failed to allocate frame to send vn ka");
return;
}
@@ -887,7 +878,7 @@ void fnic_handle_vn_ka_timer(struct timer_list *t)
memcpy(pvn_port_ka->vn_port_desc.fd_fc_id, fcid, 3);
FNIC_STD_SET_NPORT_NAME(&pvn_port_ka->vn_port_desc.fd_wwpn, iport->wwpn);
- FNIC_FIP_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_DEBUG, fnic,
"Handle vnport KA timer\n");
fnic_send_fip_frame(iport, frame, frame_size);
vn_ka_tov = jiffies + msecs_to_jiffies(FIP_VN_KA_PERIOD);
@@ -977,7 +968,7 @@ void fnic_work_on_fcs_ka_timer(struct work_struct *work)
*fnic = container_of(work, struct fnic, fip_timer_work);
struct fnic_iport_s *iport = &fnic->iport;
- FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FIP_DBG(KERN_INFO, fnic,
"fnic 0x%p fcs ka timeout\n", fnic);
fnic_common_fip_cleanup(fnic);
diff --git a/drivers/scsi/fnic/fip.h b/drivers/scsi/fnic/fip.h
index 79fee7628870..4866152a32df 100644
--- a/drivers/scsi/fnic/fip.h
+++ b/drivers/scsi/fnic/fip.h
@@ -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);
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 8724d64f2525..ad152fb4c15f 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -144,6 +144,9 @@
#define PCI_SUBDEVICE_ID_CISCO_HELSINKI 0x02e4 /* VIC 15235 */
#define PCI_SUBDEVICE_ID_CISCO_GOTHENBURG 0x02f2 /* VIC 15425 */
+#define IS_FNIC_FCP_INITIATOR(fnic) (fnic->role == FNIC_ROLE_FCP_INITIATOR)
+#define IS_FNIC_NVME_INITIATOR(fnic) (fnic->role == FNIC_ROLE_NVME_INITIATOR)
+
struct fnic_pcie_device {
u32 device;
u8 *desc;
@@ -240,6 +243,9 @@ extern struct work_struct reset_fnic_work;
#define FNIC_FCS_LOGGING 0x02
#define FNIC_SCSI_LOGGING 0x04
#define FNIC_ISR_LOGGING 0x08
+#define FNIC_FDLS_LOGGING 0x10
+#define FNIC_NVME_LOGGING 0x20
+#define FNIC_FIP_LOGGING 0x40
#define FNIC_CHECK_LOGGING(LEVEL, CMD) \
do { \
@@ -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);)
-
-#define FNIC_FCS_DBG(kern_level, host, fnic_num, fmt, args...) \
- FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING, \
- shost_printk(kern_level, host, \
- "fnic<%d>: %s: %d: " fmt, fnic_num,\
- __func__, __LINE__, ##args);)
-
-#define FNIC_FIP_DBG(kern_level, host, fnic_num, fmt, args...) \
- FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING, \
- shost_printk(kern_level, host, \
- "fnic<%d>: %s: %d: " fmt, fnic_num,\
- __func__, __LINE__, ##args);)
-
-#define FNIC_SCSI_DBG(kern_level, host, fnic_num, fmt, args...) \
- FNIC_CHECK_LOGGING(FNIC_SCSI_LOGGING, \
- shost_printk(kern_level, host, \
- "fnic<%d>: %s: %d: " fmt, fnic_num,\
- __func__, __LINE__, ##args);)
-
-#define FNIC_ISR_DBG(kern_level, host, fnic_num, fmt, args...) \
- FNIC_CHECK_LOGGING(FNIC_ISR_LOGGING, \
- shost_printk(kern_level, host, \
- "fnic<%d>: %s: %d: " fmt, fnic_num,\
- __func__, __LINE__, ##args);)
-
-#define FNIC_MAIN_NOTE(kern_level, host, fmt, args...) \
- shost_printk(kern_level, host, fmt, ##args)
+#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__))
+
+#define FNIC_MAIN_DBG(kern_level, fnic, fmt, args...) \
+ FNIC_CHECK_LOGGING(FNIC_MAIN_LOGGING, \
+ fnic_printk(kern_level, fnic, fmt, ##args);)
+
+#define FNIC_FCS_DBG(kern_level, fnic, fmt, args...) \
+ FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING, \
+ fnic_printk(kern_level, fnic, fmt, ##args);)
+
+#define FNIC_FIP_DBG(kern_level, fnic, fmt, args...) \
+ FNIC_CHECK_LOGGING(FNIC_FIP_LOGGING, \
+ fnic_printk(kern_level, fnic, fmt, ##args);)
+
+#define FNIC_SCSI_DBG(kern_level, fnic, fmt, args...) \
+ FNIC_CHECK_LOGGING(FNIC_SCSI_LOGGING, \
+ fnic_printk(kern_level, fnic, fmt, ##args);)
+
+#define FNIC_ISR_DBG(kern_level, fnic, fmt, args...) \
+ FNIC_CHECK_LOGGING(FNIC_ISR_LOGGING, \
+ fnic_printk(kern_level, fnic, fmt, ##args);)
+
+#define FNIC_NVME_DBG(kern_level, fnic, fmt, args...) \
+ FNIC_CHECK_LOGGING(FNIC_NVME_LOGGING, \
+ fnic_printk(kern_level, fnic, fmt, ##args);)
+
+#define FNIC_MAIN_NOTE(kern_level, fnic, fmt, args...) \
+ fnic_printk(kern_level, fnic, fmt, ##args)
#define FNIC_WQ_COPY_MAX 64
#define FNIC_WQ_MAX 1
@@ -325,6 +332,7 @@ enum fnic_state {
enum fnic_role_e {
FNIC_ROLE_FCP_INITIATOR = 0,
+ FNIC_ROLE_NVME_INITIATOR,
};
enum fnic_evt {
@@ -598,7 +606,7 @@ fnic_debug_dump(struct fnic *fnic, uint8_t *u8arr, int len)
int i;
for (i = 0; i < len; i = i+8) {
- FNIC_FCS_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"%d: %02x %02x %02x %02x %02x %02x %02x %02x", i / 8,
u8arr[i + 0], u8arr[i + 1], u8arr[i + 2], u8arr[i + 3],
u8arr[i + 4], u8arr[i + 5], u8arr[i + 6], u8arr[i + 7]);
@@ -613,7 +621,7 @@ fnic_debug_dump_fc_frame(struct fnic *fnic, struct fc_frame_header *fchdr,
s_id = ntoh24(fchdr->fh_s_id);
d_id = ntoh24(fchdr->fh_d_id);
- FNIC_FCS_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"%s packet contents: sid/did/type/oxid = 0x%x/0x%x/0x%x/0x%x (len = %d)\n",
pfx, s_id, d_id, fchdr->fh_type,
FNIC_STD_GET_OX_ID(fchdr), len);
diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index 063eb864a5cd..ca592bc3f618 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -39,7 +39,7 @@ static uint8_t FCOE_ALL_FCF_MAC[6] = FC_FCOE_FLOGI_MAC;
static inline void fnic_fdls_set_fcoe_srcmac(struct fnic *fnic,
uint8_t *src_mac)
{
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Setting src mac: %02x:%02x:%02x:%02x:%02x:%02x",
src_mac[0], src_mac[1], src_mac[2], src_mac[3],
src_mac[4], src_mac[5]);
@@ -54,7 +54,7 @@ static inline void fnic_fdls_set_fcoe_srcmac(struct fnic *fnic,
static inline void fnic_fdls_set_fcoe_dstmac(struct fnic *fnic,
uint8_t *dst_mac)
{
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Setting dst mac: %02x:%02x:%02x:%02x:%02x:%02x",
dst_mac[0], dst_mac[1], dst_mac[2], dst_mac[3],
dst_mac[4], dst_mac[5]);
@@ -82,7 +82,7 @@ void fnic_fdls_link_status_change(struct fnic *fnic, int linkup)
{
struct fnic_iport_s *iport = &fnic->iport;
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"link up: %d, usefip: %d", linkup, iport->usefip);
spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
@@ -90,12 +90,12 @@ void fnic_fdls_link_status_change(struct fnic *fnic, int linkup)
if (linkup) {
if (iport->usefip) {
iport->state = FNIC_IPORT_STATE_FIP;
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"link up: %d, usefip: %d", linkup, iport->usefip);
fnic_fcoe_send_vlan_req(fnic);
} else {
iport->state = FNIC_IPORT_STATE_FABRIC_DISC;
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"iport->state: %d", iport->state);
fnic_fdls_disc_start(iport);
}
@@ -125,13 +125,13 @@ void fnic_fdls_learn_fcoe_macs(struct fnic_iport_s *iport, void *rx_frame,
memcpy(&fcmac[3], fcid, 3);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"learn fcoe: dst_mac: %02x:%02x:%02x:%02x:%02x:%02x",
ethhdr->h_dest[0], ethhdr->h_dest[1],
ethhdr->h_dest[2], ethhdr->h_dest[3],
ethhdr->h_dest[4], ethhdr->h_dest[5]);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"learn fcoe: fc_mac: %02x:%02x:%02x:%02x:%02x:%02x",
fcmac[0], fcmac[1], fcmac[2], fcmac[3], fcmac[4],
fcmac[5]);
@@ -149,7 +149,7 @@ void fnic_fdls_init(struct fnic *fnic, int usefip)
iport->fnic = fnic;
iport->usefip = usefip;
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"iportsrcmac: %02x:%02x:%02x:%02x:%02x:%02x",
iport->hwmac[0], iport->hwmac[1], iport->hwmac[2],
iport->hwmac[3], iport->hwmac[4], iport->hwmac[5]);
@@ -168,14 +168,14 @@ void fnic_handle_link(struct work_struct *work)
int max_count = 0;
if (vnic_dev_get_intr_mode(fnic->vdev) != VNIC_DEV_INTR_MODE_MSI)
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Interrupt mode is not MSI\n");
spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
if (fnic->stop_rx_link_events) {
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Stop link rx events\n");
return;
}
@@ -184,10 +184,10 @@ void fnic_handle_link(struct work_struct *work)
if ((fnic->state != FNIC_IN_ETH_MODE)
&& (fnic->state != FNIC_IN_FC_MODE)) {
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"fnic in transitional state: %d. link up: %d ignored",
fnic->state, vnic_dev_link_status(fnic->vdev));
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Current link status: %d iport state: %d\n",
fnic->link_status, fnic->iport.state);
return;
@@ -199,36 +199,36 @@ void fnic_handle_link(struct work_struct *work)
fnic->link_down_cnt = vnic_dev_link_down_cnt(fnic->vdev);
while (fnic->reset_in_progress == IN_PROGRESS) {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"fnic reset in progress. Link event needs to wait\n");
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"waiting for reset completion\n");
wait_for_completion_timeout(&fnic->reset_completion_wait,
msecs_to_jiffies(5000));
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"woken up from reset completion wait\n");
spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
max_count++;
if (max_count >= MAX_RESET_WAIT_COUNT) {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Rstth waited for too long. Skipping handle link event\n");
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
return;
}
}
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Marking fnic reset in progress\n");
fnic->reset_in_progress = IN_PROGRESS;
if ((vnic_dev_get_intr_mode(fnic->vdev) != VNIC_DEV_INTR_MODE_MSI) ||
(fnic->link_status != old_link_status)) {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"old link status: %d link status: %d\n",
old_link_status, (int) fnic->link_status);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"old down count %d down count: %d\n",
old_link_down_cnt, (int) fnic->link_down_cnt);
}
@@ -237,36 +237,36 @@ void fnic_handle_link(struct work_struct *work)
if (!fnic->link_status) {
/* DOWN -> DOWN */
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"down->down\n");
} else {
if (old_link_down_cnt != fnic->link_down_cnt) {
/* UP -> DOWN -> UP */
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"up->down. Link down\n");
fnic_fdls_link_status_change(fnic, 0);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"down->up. Link up\n");
fnic_fdls_link_status_change(fnic, 1);
} else {
/* UP -> UP */
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"up->up\n");
}
}
} else if (fnic->link_status) {
/* DOWN -> UP */
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"down->up. Link up\n");
fnic_fdls_link_status_change(fnic, 1);
} else {
/* UP -> DOWN */
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"up->down. Link down\n");
fnic_fdls_link_status_change(fnic, 0);
}
@@ -275,7 +275,7 @@ void fnic_handle_link(struct work_struct *work)
fnic->reset_in_progress = NOT_IN_PROGRESS;
complete(&fnic->reset_completion_wait);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Marking fnic reset completion\n");
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
}
@@ -302,7 +302,7 @@ void fnic_handle_frame(struct work_struct *work)
*/
if (fnic->state != FNIC_IN_FC_MODE &&
fnic->state != FNIC_IN_ETH_MODE) {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Cannot process frame in transitional state\n");
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
return;
@@ -328,7 +328,7 @@ void fnic_handle_fip_frame(struct work_struct *work)
struct fnic_frame_list *cur_frame, *next;
struct fnic *fnic = container_of(work, struct fnic, fip_frame_work);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Processing FIP frame\n");
spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
@@ -407,7 +407,7 @@ void fnic_update_mac_locked(struct fnic *fnic, u8 *new)
if (ether_addr_equal(data, new))
return;
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Update MAC: %u\n", *new);
if (!is_zero_ether_addr(data) && !ether_addr_equal(data, ctl))
@@ -477,7 +477,7 @@ static void fnic_rq_cmpl_frame_recv(struct vnic_rq *rq, struct cq_desc
if (!fcs_ok) {
atomic64_inc(&fnic_stats->misc_stats.frame_errors);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"fnic 0x%p fcs error. Dropping packet.\n", fnic);
goto drop;
}
@@ -487,21 +487,21 @@ static void fnic_rq_cmpl_frame_recv(struct vnic_rq *rq, struct cq_desc
if (fnic_import_rq_eth_pkt(fnic, fp))
return;
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Dropping h_proto 0x%x",
be16_to_cpu(eh->h_proto));
goto drop;
}
} else {
/* wrong CQ type */
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"fnic rq_cmpl wrong cq type x%x\n", type);
goto drop;
}
if (!fcs_ok || packet_error || !fcoe_fnic_crc_ok || fcoe_enc_error) {
atomic64_inc(&fnic_stats->misc_stats.frame_errors);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"fcoe %x fcsok %x pkterr %x ffco %x fee %x\n",
fcoe, fcs_ok, packet_error,
fcoe_fnic_crc_ok, fcoe_enc_error);
@@ -511,7 +511,7 @@ static void fnic_rq_cmpl_frame_recv(struct vnic_rq *rq, struct cq_desc
spin_lock_irqsave(&fnic->fnic_lock, flags);
if (fnic->stop_rx_link_events) {
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"fnic->stop_rx_link_events: %d\n",
fnic->stop_rx_link_events);
goto drop;
@@ -521,7 +521,7 @@ static void fnic_rq_cmpl_frame_recv(struct vnic_rq *rq, struct cq_desc
frame_elem = mempool_alloc(fnic->frame_elem_pool, GFP_ATOMIC);
if (!frame_elem) {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Failed to allocate memory for frame elem");
goto drop;
}
@@ -567,7 +567,7 @@ int fnic_rq_cmpl_handler(struct fnic *fnic, int rq_work_to_do)
if (cur_work_done && fnic->stop_rx_link_events != 1) {
err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame);
if (err)
- shost_printk(KERN_ERR, fnic->host,
+ fnic_printk(KERN_ERR, fnic,
"fnic_alloc_rq_frame can't alloc"
" frame\n");
}
@@ -593,7 +593,7 @@ int fnic_alloc_rq_frame(struct vnic_rq *rq)
len = FNIC_FRAME_HT_ROOM;
buf = mempool_alloc(fnic->frame_recv_pool, GFP_ATOMIC);
if (!buf) {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Unable to allocate RQ buffer of size: %d\n", len);
return -ENOMEM;
}
@@ -601,7 +601,7 @@ int fnic_alloc_rq_frame(struct vnic_rq *rq)
pa = dma_map_single(&fnic->pdev->dev, buf, len, DMA_FROM_DEVICE);
if (dma_mapping_error(&fnic->pdev->dev, pa)) {
ret = -ENOMEM;
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"PCI mapping failed with error %d\n", ret);
goto free_buf;
}
@@ -642,7 +642,7 @@ static int fnic_send_frame(struct fnic *fnic, void *frame, int frame_len)
if ((fnic_fc_trace_set_data(fnic->fnic_num,
FNIC_FC_SEND | 0x80, (char *) frame,
frame_len)) != 0) {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"fnic ctlr frame trace error");
}
@@ -650,7 +650,7 @@ static int fnic_send_frame(struct fnic *fnic, void *frame, int frame_len)
if (!vnic_wq_desc_avail(wq)) {
dma_unmap_single(&fnic->pdev->dev, pa, frame_len, DMA_TO_DEVICE);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"vnic work queue descriptor is not available");
ret = -1;
goto fnic_send_frame_end;
@@ -706,13 +706,13 @@ fdls_send_fcoe_frame(struct fnic *fnic, void *frame, int frame_size,
&& (fnic->state != FNIC_IN_ETH_MODE)) {
frame_elem = mempool_alloc(fnic->frame_elem_pool, GFP_ATOMIC);
if (!frame_elem) {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Failed to allocate memory for frame elem");
return -ENOMEM;
}
memset(frame_elem, 0, sizeof(struct fnic_frame_list));
- FNIC_FCS_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Queueing FC frame: sid/did/type/oxid = 0x%x/0x%x/0x%x/0x%x\n",
ntoh24(fchdr->fh_s_id), ntoh24(fchdr->fh_d_id),
fchdr->fh_type, FNIC_STD_GET_OX_ID(fchdr));
@@ -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) {
@@ -797,7 +797,7 @@ fnic_fdls_register_portid(struct fnic_iport_s *iport, u32 port_id,
struct ethhdr *ethhdr;
int ret;
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Setting port id: 0x%x fp: 0x%p fnic state: %d", port_id,
fp, fnic->state);
@@ -810,7 +810,7 @@ fnic_fdls_register_portid(struct fnic_iport_s *iport, u32 port_id,
if (fnic->state == FNIC_IN_ETH_MODE || fnic->state == FNIC_IN_FC_MODE)
fnic->state = FNIC_IN_ETH_TRANS_FC_MODE;
else {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Unexpected fnic state while processing FLOGI response\n");
return -1;
}
@@ -821,7 +821,7 @@ fnic_fdls_register_portid(struct fnic_iport_s *iport, u32 port_id,
*/
ret = fnic_flogi_reg_handler(fnic, port_id);
if (ret < 0) {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"FLOGI registration error ret: %d fnic state: %d\n",
ret, fnic->state);
if (fnic->state == FNIC_IN_ETH_TRANS_FC_MODE)
@@ -831,7 +831,7 @@ fnic_fdls_register_portid(struct fnic_iport_s *iport, u32 port_id,
}
iport->fabric.flags |= FNIC_FDLS_FPMA_LEARNT;
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"FLOGI registration success\n");
return 0;
}
@@ -931,7 +931,7 @@ fnic_fdls_add_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport,
struct fc_rport_identifiers ids;
struct rport_dd_data_s *rdd_data;
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Adding rport fcid: 0x%x", tport->fcid);
ids.node_name = tport->wwnn;
@@ -943,12 +943,12 @@ fnic_fdls_add_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport,
rport = fc_remote_port_add(fnic->host, 0, &ids);
spin_lock_irqsave(&fnic->fnic_lock, flags);
if (!rport) {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Failed to add rport for tport: 0x%x", tport->fcid);
return;
}
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Added rport fcid: 0x%x", tport->fcid);
/* Mimic these assignments in queuecommand to avoid timing issues */
@@ -987,7 +987,7 @@ fnic_fdls_remove_tport(struct fnic_iport_s *iport,
fc_remote_port_delete(rport);
spin_lock_irqsave(&fnic->fnic_lock, flags);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Deregistered and freed tport fcid: 0x%x from scsi transport fc",
tport->fcid);
@@ -1014,7 +1014,7 @@ void fnic_delete_fcp_tports(struct fnic *fnic)
spin_lock_irqsave(&fnic->fnic_lock, flags);
list_for_each_entry_safe(tport, next, &fnic->iport.tport_list, links) {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, 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);
@@ -1041,36 +1041,36 @@ void fnic_tport_event_handler(struct work_struct *work)
tport = cur_evt->arg1;
switch (cur_evt->event) {
case TGT_EV_RPORT_ADD:
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ 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);
} else {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Target not ready. Add rport event dropped: 0x%x",
tport->fcid);
}
break;
case TGT_EV_RPORT_DEL:
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ 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);
} else {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"remove rport event dropped tport fcid: 0x%x",
tport->fcid);
}
break;
case TGT_EV_TPORT_DELETE:
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Delete tport event");
fdls_delete_tport(tport->iport, tport);
break;
default:
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Unknown tport event");
break;
}
@@ -1142,7 +1142,7 @@ void fnic_fcpio_reset(struct fnic *fnic)
if (unlikely(fnic->state == FNIC_IN_FC_TRANS_ETH_MODE)) {
/* fw reset is in progress, poll for its completion */
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"fnic is in unexpected state: %d for fw_reset\n",
fnic->state);
return;
@@ -1155,7 +1155,7 @@ void fnic_fcpio_reset(struct fnic *fnic)
fnic->fw_reset_done = &fw_reset_done;
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Issuing fw reset\n");
if (fnic_fw_reset_handler(fnic)) {
spin_lock_irqsave(&fnic->fnic_lock, flags);
@@ -1163,14 +1163,14 @@ void fnic_fcpio_reset(struct fnic *fnic)
fnic->state = old_state;
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
} else {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Waiting for fw completion\n");
time_remain = wait_for_completion_timeout(&fw_reset_done,
msecs_to_jiffies(FNIC_FW_RESET_TIMEOUT));
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"Woken up after fw completion timeout\n");
if (time_remain == 0) {
- FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_FCS_DBG(KERN_INFO, fnic,
"FW reset completion timed out after %d ms\n",
FNIC_FW_RESET_TIMEOUT);
}
diff --git a/drivers/scsi/fnic/fnic_isr.c b/drivers/scsi/fnic/fnic_isr.c
index 7ed50b11afa6..02856745580f 100644
--- a/drivers/scsi/fnic/fnic_isr.c
+++ b/drivers/scsi/fnic/fnic_isr.c
@@ -222,7 +222,7 @@ int fnic_request_intr(struct fnic *fnic)
fnic->msix[i].devname,
fnic->msix[i].devid);
if (err) {
- FNIC_ISR_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_ISR_DBG(KERN_ERR, fnic,
"request_irq failed with error: %d\n",
err);
fnic_free_intr(fnic);
@@ -250,10 +250,10 @@ int fnic_set_intr_mode_msix(struct fnic *fnic)
* We need n RQs, m WQs, o Copy WQs, n+m+o CQs, and n+m+o+1 INTRs
* (last INTR is used for WQ/RQ errors and notification area)
*/
- FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_ISR_DBG(KERN_INFO, fnic,
"rq-array size: %d wq-array size: %d copy-wq array size: %d\n",
n, m, o);
- FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_ISR_DBG(KERN_INFO, fnic,
"rq_count: %d raw_wq_count: %d wq_copy_count: %d cq_count: %d\n",
fnic->rq_count, fnic->raw_wq_count,
fnic->wq_copy_count, fnic->cq_count);
@@ -265,17 +265,17 @@ int fnic_set_intr_mode_msix(struct fnic *fnic)
vec_count = pci_alloc_irq_vectors(fnic->pdev, min_irqs, vecs,
PCI_IRQ_MSIX | PCI_IRQ_AFFINITY);
- FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_ISR_DBG(KERN_INFO, fnic,
"allocated %d MSI-X vectors\n",
vec_count);
if (vec_count > 0) {
if (vec_count < vecs) {
- FNIC_ISR_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_ISR_DBG(KERN_ERR, fnic,
"interrupts number mismatch: vec_count: %d vecs: %d\n",
vec_count, vecs);
if (vec_count < min_irqs) {
- FNIC_ISR_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_ISR_DBG(KERN_ERR, fnic,
"no interrupts for copy wq\n");
return 1;
}
@@ -287,7 +287,7 @@ int fnic_set_intr_mode_msix(struct fnic *fnic)
fnic->wq_copy_count = vec_count - n - m - 1;
fnic->wq_count = fnic->raw_wq_count + fnic->wq_copy_count;
if (fnic->cq_count != vec_count - 1) {
- FNIC_ISR_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_ISR_DBG(KERN_ERR, fnic,
"CQ count: %d does not match MSI-X vector count: %d\n",
fnic->cq_count, vec_count);
fnic->cq_count = vec_count - 1;
@@ -295,23 +295,23 @@ int fnic_set_intr_mode_msix(struct fnic *fnic)
fnic->intr_count = vec_count;
fnic->err_intr_offset = fnic->rq_count + fnic->wq_count;
- FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_ISR_DBG(KERN_INFO, fnic,
"rq_count: %d raw_wq_count: %d copy_wq_base: %d\n",
fnic->rq_count,
fnic->raw_wq_count, fnic->copy_wq_base);
- FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_ISR_DBG(KERN_INFO, fnic,
"wq_copy_count: %d wq_count: %d cq_count: %d\n",
fnic->wq_copy_count,
fnic->wq_count, fnic->cq_count);
- FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
- "intr_count: %d err_intr_offset: %u",
+ FNIC_ISR_DBG(KERN_INFO, fnic,
+ "intr_count: %d err_intr_offset: %u\n",
fnic->intr_count,
fnic->err_intr_offset);
vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_MSIX);
- FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_ISR_DBG(KERN_INFO, fnic,
"fnic using MSI-X\n");
return 0;
}
@@ -351,7 +351,7 @@ int fnic_set_intr_mode(struct fnic *fnic)
fnic->intr_count = 1;
fnic->err_intr_offset = 0;
- FNIC_ISR_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_ISR_DBG(KERN_DEBUG, fnic,
"Using MSI Interrupts\n");
vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_MSI);
@@ -377,7 +377,7 @@ int fnic_set_intr_mode(struct fnic *fnic)
fnic->cq_count = 3;
fnic->intr_count = 3;
- FNIC_ISR_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_ISR_DBG(KERN_DEBUG, fnic,
"Using Legacy Interrupts\n");
vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_INTX);
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index 24d62c0874ac..7c7f9ea5267b 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -185,7 +185,7 @@ static void fnic_get_host_speed(struct Scsi_Host *shost)
u32 port_speed = vnic_dev_port_speed(fnic->vdev);
struct fnic_stats *fnic_stats = &fnic->fnic_stats;
- FNIC_MAIN_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_MAIN_DBG(KERN_INFO, fnic,
"port_speed: %d Mbps", port_speed);
atomic64_set(&fnic_stats->misc_stats.port_speed_in_mbps, port_speed);
@@ -235,7 +235,7 @@ static void fnic_get_host_speed(struct Scsi_Host *shost)
fc_host_speed(shost) = FC_PORTSPEED_128GBIT;
break;
default:
- FNIC_MAIN_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_MAIN_DBG(KERN_INFO, fnic,
"Unknown FC speed: %d Mbps", port_speed);
fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
break;
@@ -261,7 +261,7 @@ static struct fc_host_statistics *fnic_get_stats(struct Scsi_Host *host)
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
if (ret) {
- FNIC_MAIN_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_MAIN_DBG(KERN_DEBUG, fnic,
"fnic: Get vnic stats failed: 0x%x", ret);
return stats;
}
@@ -287,64 +287,66 @@ static struct fc_host_statistics *fnic_get_stats(struct Scsi_Host *host)
void fnic_dump_fchost_stats(struct Scsi_Host *host,
struct fc_host_statistics *stats)
{
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ struct fnic *fnic = *((struct fnic **) shost_priv(host));
+
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: seconds since last reset = %llu\n",
stats->seconds_since_last_reset);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: tx frames = %llu\n",
stats->tx_frames);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: tx words = %llu\n",
stats->tx_words);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: rx frames = %llu\n",
stats->rx_frames);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: rx words = %llu\n",
stats->rx_words);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: lip count = %llu\n",
stats->lip_count);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: nos count = %llu\n",
stats->nos_count);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: error frames = %llu\n",
stats->error_frames);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: dumped frames = %llu\n",
stats->dumped_frames);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: link failure count = %llu\n",
stats->link_failure_count);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: loss of sync count = %llu\n",
stats->loss_of_sync_count);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: loss of signal count = %llu\n",
stats->loss_of_signal_count);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: prim seq protocol err count = %llu\n",
stats->prim_seq_protocol_err_count);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: invalid tx word count= %llu\n",
stats->invalid_tx_word_count);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: invalid crc count = %llu\n",
stats->invalid_crc_count);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: fcp input requests = %llu\n",
stats->fcp_input_requests);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: fcp output requests = %llu\n",
stats->fcp_output_requests);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: fcp control requests = %llu\n",
stats->fcp_control_requests);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: fcp input megabytes = %llu\n",
stats->fcp_input_megabytes);
- FNIC_MAIN_NOTE(KERN_NOTICE, host,
+ FNIC_MAIN_NOTE(KERN_NOTICE, fnic,
"fnic: fcp output megabytes = %llu\n",
stats->fcp_output_megabytes);
return;
@@ -370,7 +372,7 @@ static void fnic_reset_host_stats(struct Scsi_Host *host)
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
if (ret) {
- FNIC_MAIN_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_MAIN_DBG(KERN_DEBUG, fnic,
"fnic: Reset vnic stats failed"
" 0x%x", ret);
return;
@@ -684,16 +686,16 @@ void fnic_mq_map_queues_cpus(struct Scsi_Host *host)
struct blk_mq_queue_map *qmap = &host->tag_set.map[HCTX_TYPE_DEFAULT];
if (intr_mode == VNIC_DEV_INTR_MODE_MSI || intr_mode == VNIC_DEV_INTR_MODE_INTX) {
- FNIC_MAIN_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_MAIN_DBG(KERN_ERR, fnic,
"intr_mode is not msix\n");
return;
}
- FNIC_MAIN_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_MAIN_DBG(KERN_INFO, fnic,
"qmap->nr_queues: %d\n", qmap->nr_queues);
if (l_pdev == NULL) {
- FNIC_MAIN_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_MAIN_DBG(KERN_ERR, fnic,
"l_pdev is null\n");
return;
}
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 6ee3c559e129..0759540f6675 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -148,7 +148,7 @@ unsigned int fnic_count_ioreqs(struct fnic *fnic, u32 portid)
fnic_scsi_io_iter(fnic, fnic_count_portid_ioreqs_iter,
&portid, &count);
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"portid = 0x%x count = %u\n", portid, count);
return count;
}
@@ -180,7 +180,7 @@ fnic_count_lun_ioreqs(struct fnic *fnic, struct scsi_device *scsi_device)
fnic_scsi_io_iter(fnic, fnic_count_lun_ioreqs_iter,
scsi_device, &count);
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"lun = %p count = %u\n", scsi_device, count);
return count;
}
@@ -268,7 +268,7 @@ int fnic_fw_reset_handler(struct fnic *fnic)
if (!vnic_wq_copy_desc_avail(wq))
ret = -EAGAIN;
else {
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"ioreq_count: %u\n", ioreq_count);
fnic_queue_wq_copy_desc_fw_reset(wq, SCSI_NO_TAG);
atomic64_inc(&fnic->fnic_stats.fw_stats.active_fw_reqs);
@@ -283,11 +283,11 @@ int fnic_fw_reset_handler(struct fnic *fnic)
if (!ret) {
atomic64_inc(&fnic->fnic_stats.reset_stats.fw_resets);
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"Issued fw reset\n");
} else {
fnic_clear_state_flags(fnic, FNIC_FLAGS_FWRESET);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"Failed to issue fw reset\n");
}
@@ -326,13 +326,13 @@ int fnic_flogi_reg_handler(struct fnic *fnic, u32 fc_id)
fc_id, gw_mac,
fnic->iport.fpma,
iport->r_a_tov, iport->e_d_tov);
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"FLOGI FIP reg issued fcid: 0x%x src %p dest %p\n",
fc_id, fnic->iport.fpma, gw_mac);
} else {
fnic_queue_wq_copy_desc_flogi_reg(wq, SCSI_NO_TAG,
format, fc_id, gw_mac);
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"FLOGI reg issued fcid 0x%x dest %p\n",
fc_id, gw_mac);
}
@@ -413,7 +413,7 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
free_wq_copy_descs(fnic, wq, hwq);
if (unlikely(!vnic_wq_copy_desc_avail(wq))) {
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"fnic_queue_wq_copy_desc failure - no descriptors\n");
atomic64_inc(&misc_stats->io_cpwq_alloc_failures);
return SCSI_MLQUEUE_HOST_BUSY;
@@ -478,7 +478,7 @@ enum scsi_qc_status fnic_queuecommand(struct Scsi_Host *shost,
rport = starget_to_rport(scsi_target(sc->device));
if (!rport) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"returning DID_NO_CONNECT for IO as rport is NULL\n");
sc->result = DID_NO_CONNECT << 16;
done(sc);
@@ -487,7 +487,7 @@ enum scsi_qc_status fnic_queuecommand(struct Scsi_Host *shost,
ret = fc_remote_port_chkready(rport);
if (ret) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"rport is not ready\n");
atomic64_inc(&fnic_stats->misc_stats.tport_not_ready);
sc->result = ret;
@@ -501,7 +501,7 @@ enum scsi_qc_status fnic_queuecommand(struct Scsi_Host *shost,
if (iport->state != FNIC_IPORT_STATE_READY) {
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"returning DID_NO_CONNECT for IO as iport state: %d\n",
iport->state);
sc->result = DID_NO_CONNECT << 16;
@@ -515,13 +515,13 @@ enum scsi_qc_status fnic_queuecommand(struct Scsi_Host *shost,
rdd_data = rport->dd_data;
tport = rdd_data->tport;
if (!tport || (rdd_data->iport != iport)) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"dd_data not yet set in SCSI for rport portid: 0x%x\n",
rport->port_id);
tport = fnic_find_tport_by_fcid(iport, rport->port_id);
if (!tport) {
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"returning DID_BUS_BUSY for IO as tport not found for: 0x%x\n",
rport->port_id);
sc->result = DID_BUS_BUSY << 16;
@@ -544,7 +544,7 @@ enum scsi_qc_status fnic_queuecommand(struct Scsi_Host *shost,
if ((tport->state != FDLS_TGT_STATE_READY)
&& (tport->state != FDLS_TGT_STATE_ADISC)) {
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"returning DID_NO_CONNECT for IO as tport state: %d\n",
tport->state);
sc->result = DID_NO_CONNECT << 16;
@@ -564,7 +564,7 @@ enum scsi_qc_status fnic_queuecommand(struct Scsi_Host *shost,
if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_FWRESET))) {
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"fnic flags FW reset: 0x%lx. Returning SCSI_MLQUEUE_HOST_BUSY\n",
fnic->state_flags);
return SCSI_MLQUEUE_HOST_BUSY;
@@ -704,7 +704,7 @@ enum scsi_qc_status fnic_queuecommand(struct Scsi_Host *shost,
atomic_dec(&tport->in_flight);
if (lun0_delay) {
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"LUN0 delay\n");
mdelay(LUN0_DELAY_TIME);
}
@@ -744,12 +744,12 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic,
if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) {
/* Check status of reset completion */
if (!hdr_status) {
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"reset cmpl success\n");
/* Ready to send flogi out */
fnic->state = FNIC_IN_ETH_MODE;
} else {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"reset failed with header status: %s\n",
fnic_fcpio_status_to_str(hdr_status));
@@ -758,7 +758,7 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic,
ret = -1;
}
} else {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"Unexpected state while processing reset completion: %s\n",
fnic_state_to_str(fnic->state));
atomic64_inc(&reset_stats->fw_reset_failures);
@@ -810,19 +810,18 @@ static int fnic_fcpio_flogi_reg_cmpl_handler(struct fnic *fnic,
/* Check flogi registration completion status */
if (!hdr_status) {
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"FLOGI reg succeeded\n");
fnic->state = FNIC_IN_FC_MODE;
} else {
- FNIC_SCSI_DBG(KERN_DEBUG,
- fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"fnic flogi reg failed: %s\n",
fnic_fcpio_status_to_str(hdr_status));
fnic->state = FNIC_IN_ETH_MODE;
ret = -1;
}
} else {
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"Unexpected fnic state %s while"
" processing flogi reg completion\n",
fnic_state_to_str(fnic->state));
@@ -933,19 +932,19 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, unsigned int cq_ind
hwq = blk_mq_unique_tag_to_hwq(mqtag);
if (hwq != cq_index) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ",
hwq, mqtag, tag, cq_index);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hdr status: %s icmnd completion on the wrong queue\n",
fnic_fcpio_status_to_str(hdr_status));
}
if (tag >= fnic->fnic_max_tag_id) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ",
hwq, mqtag, tag, cq_index);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hdr status: %s Out of range tag\n",
fnic_fcpio_status_to_str(hdr_status));
return;
@@ -957,7 +956,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, unsigned int cq_ind
if (!sc) {
atomic64_inc(&fnic_stats->io_stats.sc_null);
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
- shost_printk(KERN_ERR, fnic->host,
+ fnic_printk(KERN_ERR, fnic,
"icmnd_cmpl sc is null - "
"hdr status = %s tag = 0x%x desc = 0x%p\n",
fnic_fcpio_status_to_str(hdr_status), id, desc);
@@ -985,7 +984,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, unsigned int cq_ind
atomic64_inc(&fnic_stats->io_stats.ioreq_null);
fnic_priv(sc)->flags |= FNIC_IO_REQ_NULL;
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
- shost_printk(KERN_ERR, fnic->host,
+ fnic_printk(KERN_ERR, fnic,
"icmnd_cmpl io_req is null - "
"hdr status = %s tag = 0x%x sc 0x%p\n",
fnic_fcpio_status_to_str(hdr_status), id, sc);
@@ -1012,7 +1011,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, unsigned int cq_ind
if(FCPIO_ABORTED == hdr_status)
fnic_priv(sc)->flags |= FNIC_IO_ABORTED;
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"icmnd_cmpl abts pending "
"hdr status = %s tag = 0x%x sc = 0x%p "
"scsi_status = %x residual = %d\n",
@@ -1044,7 +1043,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, unsigned int cq_ind
if (icmnd_cmpl->scsi_status == SAM_STAT_TASK_SET_FULL)
atomic64_inc(&fnic_stats->misc_stats.queue_fulls);
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"xfer_len: %llu", xfer_len);
break;
@@ -1107,7 +1106,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, unsigned int cq_ind
if (hdr_status != FCPIO_SUCCESS) {
atomic64_inc(&fnic_stats->io_stats.io_failures);
- shost_printk(KERN_ERR, fnic->host, "hdr status = %s\n",
+ fnic_printk(KERN_ERR, fnic, "hdr status = %s\n",
fnic_fcpio_status_to_str(hdr_status));
}
@@ -1200,27 +1199,27 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
hwq = blk_mq_unique_tag_to_hwq(id & FNIC_TAG_MASK);
if (hwq != cq_index) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ",
hwq, mqtag, tag, cq_index);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hdr status: %s ITMF completion on the wrong queue\n",
fnic_fcpio_status_to_str(hdr_status));
}
if (tag > fnic->fnic_max_tag_id) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ",
hwq, mqtag, tag, cq_index);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hdr status: %s Tag out of range\n",
fnic_fcpio_status_to_str(hdr_status));
return;
} else if ((tag == fnic->fnic_max_tag_id) && !(id & FNIC_TAG_DEV_RST)) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ",
hwq, mqtag, tag, cq_index);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hdr status: %s Tag out of range\n",
fnic_fcpio_status_to_str(hdr_status));
return;
@@ -1243,7 +1242,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
if (!sc) {
atomic64_inc(&fnic_stats->io_stats.sc_null);
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
- shost_printk(KERN_ERR, fnic->host,
+ fnic_printk(KERN_ERR, fnic,
"itmf_cmpl sc is null - hdr status = %s tag = 0x%x\n",
fnic_fcpio_status_to_str(hdr_status), tag);
return;
@@ -1255,7 +1254,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
atomic64_inc(&fnic_stats->io_stats.ioreq_null);
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL;
- shost_printk(KERN_ERR, fnic->host,
+ fnic_printk(KERN_ERR, fnic,
"itmf_cmpl io_req is null - "
"hdr status = %s tag = 0x%x sc 0x%p\n",
fnic_fcpio_status_to_str(hdr_status), tag, sc);
@@ -1266,7 +1265,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
if ((id & FNIC_TAG_ABORT) && (id & FNIC_TAG_DEV_RST)) {
/* Abort and terminate completion of device reset req */
/* REVISIT : Add asserts about various flags */
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"hwq: %d mqtag: 0x%x tag: 0x%x hst: %s Abt/term completion received\n",
hwq, mqtag, tag,
fnic_fcpio_status_to_str(hdr_status));
@@ -1278,7 +1277,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
} else if (id & FNIC_TAG_ABORT) {
/* Completion of abort cmd */
- shost_printk(KERN_DEBUG, fnic->host,
+ fnic_printk(KERN_DEBUG, fnic,
"hwq: %d mqtag: 0x%x tag: 0x%x Abort header status: %s\n",
hwq, mqtag, tag,
fnic_fcpio_status_to_str(hdr_status));
@@ -1293,7 +1292,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
&term_stats->terminate_fw_timeouts);
break;
case FCPIO_ITMF_REJECTED:
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"abort reject recd. id %d\n",
(int)(id & FNIC_TAG_MASK));
break;
@@ -1328,7 +1327,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
if (!(fnic_priv(sc)->flags & (FNIC_IO_ABORTED | FNIC_IO_DONE)))
atomic64_inc(&misc_stats->no_icmnd_itmf_cmpls);
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"abts cmpl recd. id %d status %s\n",
(int)(id & FNIC_TAG_MASK),
fnic_fcpio_status_to_str(hdr_status));
@@ -1341,11 +1340,11 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
if (io_req->abts_done) {
complete(io_req->abts_done);
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
- shost_printk(KERN_INFO, fnic->host,
+ fnic_printk(KERN_INFO, fnic,
"hwq: %d mqtag: 0x%x tag: 0x%x Waking up abort thread\n",
hwq, mqtag, tag);
} else {
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"hwq: %d mqtag: 0x%x tag: 0x%x hst: %s Completing IO\n",
hwq, mqtag,
tag, fnic_fcpio_status_to_str(hdr_status));
@@ -1376,7 +1375,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
}
} else if (id & FNIC_TAG_DEV_RST) {
/* Completion of device reset */
- shost_printk(KERN_INFO, fnic->host,
+ fnic_printk(KERN_INFO, fnic,
"hwq: %d mqtag: 0x%x tag: 0x%x DR hst: %s\n",
hwq, mqtag,
tag, fnic_fcpio_status_to_str(hdr_status));
@@ -1388,7 +1387,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
sc->device->host->host_no, id, sc,
jiffies_to_msecs(jiffies - start_time),
desc, 0, fnic_flags_and_state(sc));
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"hwq: %d mqtag: 0x%x tag: 0x%x hst: %s Terminate pending\n",
hwq, mqtag,
tag, fnic_fcpio_status_to_str(hdr_status));
@@ -1401,7 +1400,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
sc->device->host->host_no, id, sc,
jiffies_to_msecs(jiffies - start_time),
desc, 0, fnic_flags_and_state(sc));
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"dev reset cmpl recd after time out. "
"id %d status %s\n",
(int)(id & FNIC_TAG_MASK),
@@ -1410,7 +1409,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
}
fnic_priv(sc)->state = FNIC_IOREQ_CMD_COMPLETE;
fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE;
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"hwq: %d mqtag: 0x%x tag: 0x%x hst: %s DR completion received\n",
hwq, mqtag,
tag, fnic_fcpio_status_to_str(hdr_status));
@@ -1419,7 +1418,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
} else {
- shost_printk(KERN_ERR, fnic->host,
+ fnic_printk(KERN_ERR, fnic,
"%s: Unexpected itmf io state: hwq: %d tag 0x%x %s\n",
__func__, hwq, id, fnic_ioreq_state_to_str(fnic_priv(sc)->state));
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
@@ -1474,7 +1473,7 @@ static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev,
break;
default:
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"firmware completion type %d\n",
desc->hdr.type);
break;
@@ -1535,7 +1534,7 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data)
io_req = fnic_priv(sc)->io_req;
if (!io_req) {
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hwq: %d mqtag: 0x%x tag: 0x%x flags: 0x%x No ioreq. Returning\n",
hwq, mqtag, tag, fnic_priv(sc)->flags);
return true;
@@ -1573,7 +1572,7 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data)
mempool_free(io_req, fnic->io_req_pool);
sc->result = DID_TRANSPORT_DISRUPTED << 16;
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"mqtag: 0x%x tag: 0x%x sc: 0x%p duration = %lu DID_TRANSPORT_DISRUPTED\n",
mqtag, tag, sc, (jiffies - start_time));
@@ -1605,7 +1604,7 @@ static void fnic_cleanup_io(struct fnic *fnic, int exclude_id)
struct scsi_cmnd *sc = NULL;
io_count = fnic_count_all_ioreqs(fnic);
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"Outstanding ioreq count: %d active io count: %lld Waiting\n",
io_count,
atomic64_read(&fnic->fnic_stats.io_stats.active_ios));
@@ -1630,7 +1629,7 @@ static void fnic_cleanup_io(struct fnic *fnic, int exclude_id)
spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags);
while ((io_count = fnic_count_all_ioreqs(fnic))) {
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"Outstanding ioreq count: %d active io count: %lld Waiting\n",
io_count,
atomic64_read(&fnic->fnic_stats.io_stats.active_ios));
@@ -1686,7 +1685,7 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
wq_copy_cleanup_scsi_cmd:
sc->result = DID_NO_CONNECT << 16;
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "wq_copy_cleanup_handler:"
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic, "wq_copy_cleanup_handler:"
" DID_NO_CONNECT\n");
FNIC_TRACE(fnic_wq_copy_cleanup_handler,
@@ -1730,7 +1729,7 @@ static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag,
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
atomic_dec(&fnic->in_flight);
atomic_dec(&tport->in_flight);
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"fnic_queue_abort_io_req: failure: no descriptors\n");
atomic64_inc(&misc_stats->abts_cpwq_alloc_failures);
return 1;
@@ -1775,7 +1774,7 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data)
hwq = blk_mq_unique_tag_to_hwq(abt_tag);
if (!sc) {
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"sc is NULL abt_tag: 0x%x hwq: %d\n", abt_tag, hwq);
return true;
}
@@ -1789,7 +1788,7 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data)
if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) &&
!(fnic_priv(sc)->flags & FNIC_DEV_RST_ISSUED)) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hwq: %d abt_tag: 0x%x flags: 0x%x Device reset is not pending\n",
hwq, abt_tag, fnic_priv(sc)->flags);
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
@@ -1806,16 +1805,16 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data)
}
if (io_req->abts_done) {
- shost_printk(KERN_ERR, fnic->host,
+ fnic_printk(KERN_ERR, fnic,
"fnic_rport_exch_reset: io_req->abts_done is set state is %s\n",
fnic_ioreq_state_to_str(fnic_priv(sc)->state));
}
if (!(fnic_priv(sc)->flags & FNIC_IO_ISSUED)) {
- shost_printk(KERN_ERR, fnic->host,
+ fnic_printk(KERN_ERR, fnic,
"rport_exch_reset IO not yet issued %p abt_tag 0x%x",
sc, abt_tag);
- shost_printk(KERN_ERR, fnic->host,
+ fnic_printk(KERN_ERR, fnic,
"flags %x state %d\n", fnic_priv(sc)->flags,
fnic_priv(sc)->state);
}
@@ -1826,13 +1825,13 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data)
if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) {
atomic64_inc(&reset_stats->device_reset_terminates);
abt_tag |= FNIC_TAG_DEV_RST;
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"dev reset sc 0x%p\n", sc);
}
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"fnic_rport_exch_reset: dev rst sc 0x%p\n", sc);
WARN_ON_ONCE(io_req->abts_done);
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"fnic_rport_reset_exch: Issuing abts\n");
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
@@ -1850,7 +1849,7 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data)
* lun reset
*/
spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hwq: %d abt_tag: 0x%x flags: 0x%x Queuing abort failed\n",
hwq, abt_tag, fnic_priv(sc)->flags);
if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING)
@@ -1881,7 +1880,7 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id)
.term_cnt = 0,
};
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"fnic rport exchange reset for tport: 0x%06x\n",
port_id);
@@ -1889,7 +1888,7 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id)
return;
io_count = fnic_count_ioreqs(fnic, port_id);
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"Starting terminates: rport:0x%x portid-io-count: %d active-io-count: %lld\n",
port_id, io_count,
atomic64_read(&fnic->fnic_stats.io_stats.active_ios));
@@ -1915,7 +1914,7 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id)
while ((io_count = fnic_count_ioreqs(fnic, port_id)))
schedule_timeout(msecs_to_jiffies(1000));
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"rport: 0x%x remaining portid-io-count: %d ",
port_id, io_count);
}
@@ -2040,10 +2039,10 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
tport = rdd_data->tport;
if (!tport) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"Abort cmd called after tport delete! rport fcid: 0x%x",
rport->port_id);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"lun: %llu hwq: 0x%x mqtag: 0x%x Op: 0x%x flags: 0x%x\n",
sc->device->lun, hwq, mqtag,
sc->cmnd[0], fnic_priv(sc)->flags);
@@ -2052,18 +2051,18 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
goto fnic_abort_cmd_end;
}
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"Abort cmd called rport fcid: 0x%x lun: %llu hwq: 0x%x mqtag: 0x%x",
rport->port_id, sc->device->lun, hwq, mqtag);
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"Op: 0x%x flags: 0x%x\n",
sc->cmnd[0],
fnic_priv(sc)->flags);
if (iport->state != FNIC_IPORT_STATE_READY) {
atomic64_inc(&fnic_stats->misc_stats.iport_not_ready);
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"iport NOT in READY state");
ret = FAILED;
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
@@ -2072,7 +2071,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
if ((tport->state != FDLS_TGT_STATE_READY) &&
(tport->state != FDLS_TGT_STATE_ADISC)) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"tport state: %d\n", tport->state);
ret = FAILED;
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
@@ -2123,7 +2122,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
else
atomic64_inc(&abts_stats->abort_issued_greater_than_60_sec);
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"CDB Opcode: 0x%02x Abort issued time: %lu msec\n",
sc->cmnd[0], abt_issued_time);
/*
@@ -2214,7 +2213,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
if (!(fnic_priv(sc)->flags & (FNIC_IO_ABORTED | FNIC_IO_DONE))) {
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"Issuing host reset due to out of order IO\n");
ret = FAILED;
@@ -2262,7 +2261,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
(u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
fnic_flags_and_state(sc));
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"Returning from abort cmd type %x %s\n", task_req,
(ret == SUCCESS) ?
"SUCCESS" : "FAILED");
@@ -2303,7 +2302,7 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic,
free_wq_copy_descs(fnic, wq, hwq);
if (!vnic_wq_copy_desc_avail(wq)) {
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"queue_dr_io_req failure - no descriptors\n");
atomic64_inc(&misc_stats->devrst_cpwq_alloc_failures);
ret = -EAGAIN;
@@ -2371,7 +2370,7 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, void *data)
* Found IO that is still pending with firmware and
* belongs to the LUN that we are resetting
*/
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"Found IO in %s on lun\n",
fnic_ioreq_state_to_str(fnic_priv(sc)->state));
@@ -2381,14 +2380,14 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, void *data)
}
if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) &&
(!(fnic_priv(sc)->flags & FNIC_DEV_RST_ISSUED))) {
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"dev rst not pending sc 0x%p\n", sc);
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
return true;
}
if (io_req->abts_done)
- shost_printk(KERN_ERR, fnic->host,
+ fnic_printk(KERN_ERR, fnic,
"%s: io_req->abts_done is set state is %s\n",
__func__, fnic_ioreq_state_to_str(fnic_priv(sc)->state));
old_ioreq_state = fnic_priv(sc)->state;
@@ -2404,7 +2403,7 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, void *data)
BUG_ON(io_req->abts_done);
if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) {
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"dev rst sc 0x%p\n", sc);
}
@@ -2426,7 +2425,7 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, void *data)
fnic_priv(sc)->state = old_ioreq_state;
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
iter_data->ret = FAILED;
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"hwq: %d abt_tag: 0x%lx Abort could not be queued\n",
hwq, abt_tag);
return false;
@@ -2518,7 +2517,7 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
ret = 1;
clean_pending_aborts_end:
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"exit status: %d\n", ret);
return ret;
}
@@ -2568,7 +2567,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
rport = starget_to_rport(scsi_target(sc->device));
spin_lock_irqsave(&fnic->fnic_lock, flags);
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"fcid: 0x%x lun: %llu hwq: %d mqtag: 0x%x flags: 0x%x Device reset\n",
rport->port_id, sc->device->lun, hwq, mqtag,
fnic_priv(sc)->flags);
@@ -2576,7 +2575,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
rdd_data = rport->dd_data;
tport = rdd_data->tport;
if (!tport) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"Dev rst called after tport delete! rport fcid: 0x%x lun: %llu\n",
rport->port_id, sc->device->lun);
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
@@ -2585,7 +2584,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
if (iport->state != FNIC_IPORT_STATE_READY) {
atomic64_inc(&fnic_stats->misc_stats.iport_not_ready);
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"iport NOT in READY state");
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
goto fnic_device_reset_end;
@@ -2593,7 +2592,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
if ((tport->state != FDLS_TGT_STATE_READY) &&
(tport->state != FDLS_TGT_STATE_ADISC)) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"tport state: %d\n", tport->state);
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
goto fnic_device_reset_end;
@@ -2656,7 +2655,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
fnic_priv(sc)->lr_status = FCPIO_INVALID_CODE;
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "TAG %x\n", mqtag);
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic, "TAG %x\n", mqtag);
/*
* issue the device reset, if enqueue failed, clean up the ioreq
@@ -2707,13 +2706,13 @@ int fnic_device_reset(struct scsi_cmnd *sc)
io_req = fnic_priv(sc)->io_req;
if (!io_req) {
spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"io_req is null mqtag 0x%x sc 0x%p\n", mqtag, sc);
goto fnic_device_reset_end;
}
if (exit_dr) {
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"Host reset called for fnic. Exit device reset\n");
io_req->dr_done = NULL;
goto fnic_device_reset_clean;
@@ -2728,7 +2727,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
*/
if (status == FCPIO_INVALID_CODE) {
atomic64_inc(&reset_stats->device_reset_timeouts);
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"Device reset timed out\n");
fnic_priv(sc)->flags |= FNIC_DEV_RST_TIMED_OUT;
int_to_scsilun(sc->device->lun, &fc_lun);
@@ -2740,8 +2739,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
/* Completed, but not successful, clean up the io_req, return fail */
if (status != FCPIO_SUCCESS) {
spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags);
- FNIC_SCSI_DBG(KERN_DEBUG,
- fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"Device reset completed - failed\n");
io_req = fnic_priv(sc)->io_req;
goto fnic_device_reset_clean;
@@ -2757,7 +2755,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
if (fnic_clean_pending_aborts(fnic, sc, new_sc)) {
spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags);
io_req = fnic_priv(sc)->io_req;
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"Device reset failed: Cannot abort all IOs\n");
goto fnic_device_reset_clean;
}
@@ -2811,13 +2809,13 @@ int fnic_device_reset(struct scsi_cmnd *sc)
ret = FAILED;
break;
}
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"Cannot clean up all IOs for the LUN\n");
schedule_timeout(msecs_to_jiffies(1000));
count++;
}
- FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_DEBUG, fnic,
"Returning from device reset %s\n",
(ret == SUCCESS) ?
"SUCCESS" : "FAILED");
@@ -2852,13 +2850,13 @@ void fnic_reset(struct Scsi_Host *shost)
fnic = *((struct fnic **) shost_priv(shost));
reset_stats = &fnic->fnic_stats.reset_stats;
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"Issuing fnic reset\n");
atomic64_inc(&reset_stats->fnic_resets);
fnic_post_flogo_linkflap(fnic);
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"Returning from fnic reset");
atomic64_inc(&reset_stats->fnic_reset_completions);
@@ -2869,7 +2867,7 @@ int fnic_issue_fc_host_lip(struct Scsi_Host *shost)
int ret = 0;
struct fnic *fnic = *((struct fnic **) shost_priv(shost));
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"FC host lip issued");
ret = fnic_host_reset(shost);
@@ -2895,7 +2893,7 @@ int fnic_host_reset(struct Scsi_Host *shost)
spin_lock_irqsave(&fnic->fnic_lock, flags);
if (fnic->reset_in_progress == IN_PROGRESS) {
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
- FNIC_SCSI_DBG(KERN_WARNING, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_WARNING, fnic,
"Firmware reset in progress. Skipping another host reset\n");
return SUCCESS;
}
@@ -2933,7 +2931,7 @@ int fnic_host_reset(struct Scsi_Host *shost)
}
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"host reset return status: %d\n", ret);
return ret;
}
@@ -2973,7 +2971,7 @@ static bool fnic_abts_pending_iter(struct scsi_cmnd *sc, void *data)
* Found IO that is still pending with firmware and
* belongs to the LUN that we are resetting
*/
- FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_INFO, fnic,
"hwq: %d tag: 0x%x Found IO in state: %s on lun\n",
hwq, tag,
fnic_ioreq_state_to_str(fnic_priv(sc)->state));
@@ -3027,7 +3025,7 @@ int fnic_eh_host_reset_handler(struct scsi_cmnd *sc)
struct Scsi_Host *shost = sc->device->host;
struct fnic *fnic = *((struct fnic **) shost_priv(shost));
- FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num,
+ FNIC_SCSI_DBG(KERN_ERR, fnic,
"SCSI error handling: fnic host reset");
ret = fnic_host_reset(shost);
--
2.47.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 02/13] scsi: fnic: Use fnic_num for non-SCSI identifiers
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 01/13] scsi: fnic: Make debug logging protocol independent Karan Tilak Kumar
@ 2026-06-24 4:43 ` Karan Tilak Kumar
2026-06-24 5:11 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 03/13] scsi: fnic: Decode firmware role configuration Karan Tilak Kumar
` (10 subsequent siblings)
12 siblings, 1 reply; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, Karan Tilak Kumar, Hannes Reinecke
Use 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.
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
---
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(-)
diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c
index 5880ca28a0ad..f665460ef62c 100644
--- a/drivers/scsi/fnic/fdls_disc.c
+++ b/drivers/scsi/fnic/fdls_disc.c
@@ -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);
diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
index ba86964fb45e..467fba29ea5f 100644
--- a/drivers/scsi/fnic/fnic_debugfs.c
+++ b/drivers/scsi/fnic/fnic_debugfs.c
@@ -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);
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 0759540f6675..b92260583c67 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -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]);
}
--
2.47.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 03/13] scsi: fnic: Decode firmware role configuration
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 01/13] scsi: fnic: Make debug logging protocol independent Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 02/13] scsi: fnic: Use fnic_num for non-SCSI identifiers Karan Tilak Kumar
@ 2026-06-24 4:43 ` Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 04/13] scsi: fnic: Advertise NVMe initiator service parameters Karan Tilak Kumar
` (9 subsequent siblings)
12 siblings, 0 replies; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, Karan Tilak Kumar, Hannes Reinecke
Add 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.
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
---
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(-)
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index ad152fb4c15f..54ee52c453ba 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -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.
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index 7c7f9ea5267b..3a365ea455b1 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -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;
}
diff --git a/drivers/scsi/fnic/fnic_res.c b/drivers/scsi/fnic/fnic_res.c
index 9801e5fbb0dd..18353fbb5f98 100644
--- a/drivers/scsi/fnic/fnic_res.c
+++ b/drivers/scsi/fnic/fnic_res.c
@@ -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;
}
diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
index 4ed57ea1f854..a3f583703664 100644
--- a/drivers/scsi/fnic/fnic_trace.c
+++ b/drivers/scsi/fnic/fnic_trace.c
@@ -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)
--
2.47.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 04/13] scsi: fnic: Advertise NVMe initiator service parameters
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
` (2 preceding siblings ...)
2026-06-24 4:43 ` [PATCH v5 03/13] scsi: fnic: Decode firmware role configuration Karan Tilak Kumar
@ 2026-06-24 4:43 ` Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 05/13] scsi: fnic: Add FDLS role handling for NVMe initiators Karan Tilak Kumar
` (8 subsequent siblings)
12 siblings, 0 replies; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, Karan Tilak Kumar, Hannes Reinecke
Set 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.
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
---
drivers/scsi/fnic/fdls_fc.h | 3 +++
drivers/scsi/fnic/fnic_main.c | 15 ++++++++++-----
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/fnic/fdls_fc.h b/drivers/scsi/fnic/fdls_fc.h
index 012f43afd083..e33c829545fb 100644
--- a/drivers/scsi/fnic/fdls_fc.h
+++ b/drivers/scsi/fnic/fdls_fc.h
@@ -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)
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index 3a365ea455b1..5850d51b0e8f 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -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;
--
2.47.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 05/13] scsi: fnic: Add FDLS role handling for NVMe initiators
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
` (3 preceding siblings ...)
2026-06-24 4:43 ` [PATCH v5 04/13] scsi: fnic: Advertise NVMe initiator service parameters Karan Tilak Kumar
@ 2026-06-24 4:43 ` Karan Tilak Kumar
2026-06-24 5:18 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 06/13] scsi: fnic: Add the NVMe/FC transport path Karan Tilak Kumar
` (7 subsequent siblings)
12 siblings, 1 reply; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, Karan Tilak Kumar, Hannes Reinecke
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.
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
---
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(-)
diff --git a/drivers/scsi/fnic/fcpio.h b/drivers/scsi/fnic/fcpio.h
index 54a0b2ba8f6f..46eb442a47cb 100644
--- a/drivers/scsi/fnic/fcpio.h
+++ b/drivers/scsi/fnic/fcpio.h
@@ -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;
/*
diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c
index f665460ef62c..e03256183ac6 100644
--- a/drivers/scsi/fnic/fdls_disc.c
+++ b/drivers/scsi/fnic/fdls_disc.c
@@ -13,6 +13,10 @@
#include <linux/utsname.h>
#define FC_FC4_TYPE_SCSI 0x08
+#define FNIC_NVME_FEAT_TARG (1 << 0)
+#define FNIC_NVME_FEAT_INIT (1 << 1)
+#define FNIC_NVME_FEAT_DISC (1 << 2)
+
#define PORT_SPEED_BIT_8 8
#define PORT_SPEED_BIT_9 9
#define PORT_SPEED_BIT_14 14
@@ -562,6 +566,22 @@ static void fdls_init_fabric_abts_frame(uint8_t *frame,
};
}
+static void fdls_set_frame_type(struct fnic *fnic, uint8_t *frame_type)
+{
+ if (IS_FNIC_FCP_INITIATOR(fnic))
+ *frame_type = FC_TYPE_FCP;
+ else if (IS_FNIC_NVME_INITIATOR(fnic))
+ *frame_type = FC_TYPE_NVME;
+}
+
+static void fdls_set_feature_type(struct fnic *fnic, uint8_t *feature_type)
+{
+ if (IS_FNIC_FCP_INITIATOR(fnic))
+ *feature_type = FCP_FEAT_INIT;
+ else if (IS_FNIC_NVME_INITIATOR(fnic))
+ *feature_type = FNIC_NVME_FEAT_INIT;
+}
+
static void
fdls_send_rscn_resp(struct fnic_iport_s *iport,
struct fc_frame_header *rscn_fchdr)
@@ -1137,10 +1157,10 @@ static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state)
.fh_rx_id = cpu_to_be16(FNIC_UNASSIGNED_RXID)},
.fc_std_ct_hdr = {.ct_rev = FC_CT_REV, .ct_fs_type = FC_FST_DIR,
.ct_fs_subtype = FC_NS_SUBTYPE,
- .ct_cmd = cpu_to_be16(FC_NS_GPN_FT)},
- .gpn_ft.fn_fc4_type = 0x08
+ .ct_cmd = cpu_to_be16(FC_NS_GPN_FT)}
};
+ fdls_set_frame_type(fnic, &pgpn_ft->gpn_ft.fn_fc4_type);
hton24(fcid, iport->fcid);
FNIC_STD_SET_S_ID(pgpn_ft->fchdr, fcid);
@@ -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);
+ 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) {
@@ -1288,6 +1311,7 @@ bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport)
list_del(&tport->links);
kfree(tport);
}
+
return true;
}
@@ -1404,12 +1428,16 @@ static void fdls_send_register_fc4_types(struct fnic_iport_s *iport)
}
FNIC_STD_SET_OX_ID(prft_id->fchdr, oxid);
+ if (IS_FNIC_NVME_INITIATOR(fnic))
+ prft_id->rft_id.fr_fts.ff_type_map[FC_TYPE_NVME / FC_NS_BPW] =
+ cpu_to_be32(1 << (FC_TYPE_NVME % FC_NS_BPW));
+ else if (IS_FNIC_FCP_INITIATOR(fnic))
+ prft_id->rft_id.fr_fts.ff_type_map[FC_TYPE_FCP / FC_NS_BPW] =
+ cpu_to_be32(1 << (FC_TYPE_FCP % FC_NS_BPW));
- 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[FC_TYPE_CT / FC_NS_BPW] |=
+ cpu_to_be32(1 << (FC_TYPE_CT % FC_NS_BPW));
- 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],
@@ -1449,10 +1477,11 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport)
.fc_std_ct_hdr = {.ct_rev = FC_CT_REV, .ct_fs_type = FC_FST_DIR,
.ct_fs_subtype = FC_NS_SUBTYPE,
.ct_cmd = cpu_to_be16(FC_NS_RFF_ID)},
- .rff_id.fr_feat = 0x2,
- .rff_id.fr_type = FC_TYPE_FCP
};
+ fdls_set_frame_type(fnic, &prff_id->rff_id.fr_type);
+ fdls_set_feature_type(fnic, &prff_id->rff_id.fr_feat);
+
hton24(fcid, iport->fcid);
FNIC_STD_SET_S_ID(prff_id->fchdr, fcid);
FNIC_STD_SET_PORT_ID(prff_id->rff_id, fcid);
@@ -1469,8 +1498,6 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport)
}
FNIC_STD_SET_OX_ID(prff_id->fchdr, 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,
@@ -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);
+ 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);
+ }
+
oxid = fdls_alloc_oxid(iport, FNIC_FRAME_TYPE_TGT_PRLI, &tport->active_oxid);
if (oxid == FNIC_UNASSIGNED_OXID) {
FNIC_FCS_DBG(KERN_ERR, fnic,
@@ -2067,7 +2102,10 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport)
put_unaligned_be64(iport->wwnn, data);
memset(data, 0, FNIC_FDMI_FC4_LEN);
- data[2] = 1;
+ if (IS_FNIC_FCP_INITIATOR(fnic))
+ data[2] = 1;
+ else if (IS_FNIC_NVME_INITIATOR(fnic))
+ data[6] = 1;
fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_FC4_TYPES,
FNIC_FDMI_FC4_LEN, data, &attr_off_bytes);
@@ -2096,9 +2134,11 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport)
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);
- strscpy_pad(data, fc_host_system_hostname(fnic->host),
- FNIC_FDMI_HN_LEN);
+ if (IS_FNIC_FCP_INITIATOR(fnic))
+ sprintf(fc_host_system_hostname(fnic->host), "%s",
+ utsname()->nodename);
+
+ strscpy_pad(data, utsname()->nodename, FNIC_FDMI_HN_LEN);
fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_HOST_NAME,
FNIC_FDMI_HN_LEN, data, &attr_off_bytes);
@@ -2796,7 +2836,8 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport,
FNIC_FCS_DBG(KERN_INFO, fnic,
"PRLI accepted from target: 0x%x", tgt_fcid);
- if (prli_rsp->sp.spp_type != FC_FC4_TYPE_SCSI) {
+ if (IS_FNIC_FCP_INITIATOR(fnic) &&
+ prli_rsp->sp.spp_type != FC_FC4_TYPE_SCSI) {
FNIC_FCS_DBG(KERN_INFO, fnic,
"mismatched target zoned with FC SCSI initiator: 0x%x",
tgt_fcid);
@@ -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)) ||
+ (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;
@@ -2868,20 +2917,23 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport,
fdls_set_tport_state(tport, FDLS_TGT_STATE_READY);
/* 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,
+ if (IS_FNIC_FCP_INITIATOR(fnic) ||
+ IS_FNIC_NVME_INITIATOR(fnic)) {
+ tport_add_evt = kzalloc_obj(struct fnic_tport_event_s, GFP_ATOMIC);
+ if (!tport_add_evt) {
+ 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;
+ return;
+ }
+ tport_add_evt->event = TGT_EV_RPORT_ADD;
+ tport_add_evt->arg1 = (void *)tport;
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);
+ list_add_tail(&tport_add_evt->links, &fnic->tport_event_list);
+ queue_work(fnic_event_queue, &fnic->tport_work);
+ }
}
@@ -3530,9 +3582,11 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,
"From fabric: R_A_TOV: %d E_D_TOV: %d",
iport->r_a_tov, iport->e_d_tov);
- fc_host_fabric_name(iport->fnic->host) =
- get_unaligned_be64(&FNIC_LOGI_NODE_NAME(flogi_rsp->els));
- fc_host_port_id(iport->fnic->host) = iport->fcid;
+ if (IS_FNIC_FCP_INITIATOR(fnic)) {
+ fc_host_fabric_name(iport->fnic->host) =
+ get_unaligned_be64(&FNIC_LOGI_NODE_NAME(flogi_rsp->els));
+ fc_host_port_id(iport->fnic->host) = iport->fcid;
+ }
fnic_fdls_learn_fcoe_macs(iport, rx_frame, fcid);
@@ -4622,9 +4676,11 @@ void fnic_fdls_disc_start(struct fnic_iport_s *iport)
{
struct fnic *fnic = iport->fnic;
- fc_host_fabric_name(iport->fnic->host) = 0;
- fc_host_post_event(iport->fnic->host, fc_get_event_number(),
- FCH_EVT_LIPRESET, 0);
+ if (IS_FNIC_FCP_INITIATOR(fnic)) {
+ fc_host_fabric_name(iport->fnic->host) = 0;
+ fc_host_post_event(iport->fnic->host, fc_get_event_number(),
+ FCH_EVT_LIPRESET, 0);
+ }
if (!iport->usefip) {
if (iport->flags & FNIC_FIRST_LINK_UP) {
@@ -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)) {
+ 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);
+ }
}
+ fdls_reset_oxid_pool(iport);
if (fnic_fdmi_support == 1) {
if (iport->fabric.fdmi_pending > 0) {
diff --git a/drivers/scsi/fnic/fdls_fc.h b/drivers/scsi/fnic/fdls_fc.h
index e33c829545fb..a7b8b969f019 100644
--- a/drivers/scsi/fnic/fdls_fc.h
+++ b/drivers/scsi/fnic/fdls_fc.h
@@ -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)
diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index ca592bc3f618..a67d1085d720 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -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 =
diff --git a/drivers/scsi/fnic/fnic_fdls.h b/drivers/scsi/fnic/fnic_fdls.h
index e2959120c4f9..ff1e3bd0e39f 100644
--- a/drivers/scsi/fnic/fnic_fdls.h
+++ b/drivers/scsi/fnic/fnic_fdls.h
@@ -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
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index 5850d51b0e8f..0d7828be244d 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -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);
}
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index b92260583c67..37d1e136b7b9 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -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);
--
2.47.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 06/13] scsi: fnic: Add the NVMe/FC transport path
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
` (4 preceding siblings ...)
2026-06-24 4:43 ` [PATCH v5 05/13] scsi: fnic: Add FDLS role handling for NVMe initiators Karan Tilak Kumar
@ 2026-06-24 4:43 ` Karan Tilak Kumar
2026-06-24 5:12 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 07/13] scsi: fnic: Route completions and resets by initiator role Karan Tilak Kumar
` (6 subsequent siblings)
12 siblings, 1 reply; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, Karan Tilak Kumar, kernel test robot,
Hannes Reinecke
Build 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.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605280430.wTYAqI3A-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202605280619.pmobiDWp-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202605280519.Jd4fmgAZ-lkp@intel.com/
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
---
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
---
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 | 90 +-
drivers/scsi/fnic/fnic_nvme.c | 1823 +++++++++++++++++++++++++++++++
drivers/scsi/fnic/fnic_nvme.h | 205 ++++
drivers/scsi/fnic/fnic_res.h | 32 +-
drivers/scsi/fnic/fnic_scsi.c | 4 +-
drivers/scsi/fnic/vnic_devcmd.h | 2 +-
12 files changed, 2240 insertions(+), 13 deletions(-)
create mode 100644 drivers/scsi/fnic/fnic_nvme.c
create mode 100644 drivers/scsi/fnic/fnic_nvme.h
diff --git a/drivers/scsi/fnic/Makefile b/drivers/scsi/fnic/Makefile
index c025e875009e..48c5e0cb8ca6 100644
--- a/drivers/scsi/fnic/Makefile
+++ b/drivers/scsi/fnic/Makefile
@@ -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 \
diff --git a/drivers/scsi/fnic/fcpio.h b/drivers/scsi/fnic/fcpio.h
index 46eb442a47cb..a98a2a3bfe15 100644
--- a/drivers/scsi/fnic/fcpio.h
+++ b/drivers/scsi/fnic/fcpio.h
@@ -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
*/
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 54ee52c453ba..86293e112b34 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -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;
diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index a67d1085d720..94b7c150c08c 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -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",
diff --git a/drivers/scsi/fnic/fnic_fdls.h b/drivers/scsi/fnic/fnic_fdls.h
index ff1e3bd0e39f..0a68d0fb11b1 100644
--- a/drivers/scsi/fnic/fnic_fdls.h
+++ b/drivers/scsi/fnic/fnic_fdls.h
@@ -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,
diff --git a/drivers/scsi/fnic/fnic_io.h b/drivers/scsi/fnic/fnic_io.h
index 0d974e040ab7..93a24efba26c 100644
--- a/drivers/scsi/fnic/fnic_io.h
+++ b/drivers/scsi/fnic/fnic_io.h
@@ -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_ */
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index 0d7828be244d..df8c8ebbc32b 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -42,12 +42,12 @@ static struct kmem_cache *fdls_frame_cache;
static struct kmem_cache *fdls_frame_elem_cache;
static struct kmem_cache *fdls_frame_recv_cache;
static LIST_HEAD(fnic_list);
-static DEFINE_SPINLOCK(fnic_list_lock);
static DEFINE_IDA(fnic_ida);
struct work_struct reset_fnic_work;
LIST_HEAD(reset_fnic_list);
DEFINE_SPINLOCK(reset_fnic_list_lock);
+DEFINE_SPINLOCK(fnic_list_lock);
/* Supported devices by fnic module */
static const struct pci_device_id fnic_id_table[] = {
@@ -89,6 +89,15 @@ module_param(fnic_fc_trace_max_pages, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(fnic_fc_trace_max_pages,
"Total allocated memory pages for fc trace buffer");
+unsigned int nvme_dev_loss_tmo = 30;
+module_param_named(nvme_dev_loss_tmo, nvme_dev_loss_tmo, uint, 0644);
+MODULE_PARM_DESC(nvme_dev_loss_tmo, "configurable NVME dev loss timeout");
+
+unsigned int nvme_max_ios_to_process = 16;
+module_param(nvme_max_ios_to_process, uint, 0644);
+MODULE_PARM_DESC(nvme_max_ios_to_process,
+ "Maximum number of NVME IOs to process per work queue");
+
static unsigned int fnic_max_qdepth = FNIC_DFLT_QUEUE_DEPTH;
module_param(fnic_max_qdepth, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(fnic_max_qdepth, "Queue depth to report for each LUN");
@@ -100,6 +109,7 @@ MODULE_PARM_DESC(pc_rscn_handling_feature_flag,
struct workqueue_struct *reset_fnic_work_queue;
struct workqueue_struct *fnic_fip_queue;
+struct workqueue_struct *fnic_cmpl_queue;
static int fnic_sdev_init(struct scsi_device *sdev)
{
@@ -678,6 +688,59 @@ static int fnic_scsi_drv_init(struct fnic *fnic)
return 0;
}
+static int fnic_nvme_drv_init(struct fnic *fnic)
+{
+ int ret;
+ int hwq;
+
+ fnic->fnic_max_tag_id = NVFNIC_FCPIO_TAG_POOL_SZ;
+
+ for (hwq = 0; hwq < fnic->wq_copy_count; hwq++) {
+ fnic->sw_copy_wq[hwq].ioreq_table_size = fnic->fnic_max_tag_id;
+ fnic->sw_copy_wq[hwq].io_req_table =
+ kzalloc((fnic->sw_copy_wq[hwq].ioreq_table_size + 1) *
+ sizeof(struct fnic_io_req *), GFP_KERNEL);
+
+ if (!fnic->sw_copy_wq[hwq].io_req_table) {
+ fnic_free_ioreq_tables_mq(fnic);
+ return -ENOMEM;
+ }
+ }
+
+ dev_info(&fnic->pdev->dev, "fnic copy wqs: %d, Q0 ioreq table size: %d\n",
+ fnic->wq_copy_count, fnic->sw_copy_wq[0].ioreq_table_size);
+
+ if (sbitmap_init_node(&fnic->nvfnic_tag_map, NVFNIC_FCPIO_TAG_POOL_SZ,
+ -1, GFP_KERNEL, NUMA_NO_NODE, false, true)) {
+ dev_err(&fnic->pdev->dev,
+ "Unable to allocate tag pool\n");
+ ret = -ENOMEM;
+ goto out_free_ioreq_tables;
+ }
+
+ fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache);
+ if (!fnic->io_req_pool) {
+ ret = -ENOMEM;
+ goto out_free_sbitmap;
+ }
+
+ init_llist_head(&fnic->nvme_io_event_llist);
+ INIT_WORK(&fnic->nvme_io_cmpl_work, nvfnic_nvme_iodone_work);
+
+ ret = nvfnic_add_lport(fnic);
+ if (ret)
+ goto out_free_req_pool;
+
+ return 0;
+out_free_req_pool:
+ mempool_destroy(fnic->io_req_pool);
+out_free_sbitmap:
+ sbitmap_free(&fnic->nvfnic_tag_map);
+out_free_ioreq_tables:
+ fnic_free_ioreq_tables_mq(fnic);
+ return ret;
+}
+
void fnic_mq_map_queues_cpus(struct Scsi_Host *host)
{
struct fnic *fnic = *((struct fnic **) shost_priv(host));
@@ -1057,6 +1120,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
INIT_LIST_HEAD(&fnic->frame_queue);
INIT_LIST_HEAD(&fnic->tx_queue);
INIT_LIST_HEAD(&fnic->tport_event_list);
+ init_llist_head(&fnic->nvme_io_event_llist);
INIT_DELAYED_WORK(&iport->oxid_pool.schedule_oxid_free_retry,
fdls_schedule_oxid_free_retry_work);
@@ -1091,6 +1155,10 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
err = fnic_scsi_drv_init(fnic);
if (err)
goto err_out_scsi_drv_init;
+ } else if (IS_FNIC_NVME_INITIATOR(fnic)) {
+ err = fnic_nvme_drv_init(fnic);
+ if (err)
+ goto err_out_nvme_drv_init;
}
err = fnic_stats_debugfs_init(fnic);
@@ -1113,6 +1181,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
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);
err_out_fnic_request_intr:
@@ -1190,6 +1259,8 @@ static void fnic_remove(struct pci_dev *pdev)
if (IS_FNIC_FCP_INITIATOR(fnic))
fnic_scsi_unload(fnic);
+ else if (IS_FNIC_NVME_INITIATOR(fnic))
+ nvfnic_nvme_unload(fnic);
if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI)
timer_delete_sync(&fnic->notify_timer);
@@ -1215,6 +1286,11 @@ static void fnic_remove(struct pci_dev *pdev)
*/
fnic_cleanup(fnic);
+ if (IS_FNIC_NVME_INITIATOR(fnic)) {
+ sbitmap_free(&fnic->nvfnic_tag_map);
+ fnic_free_ioreq_tables_mq(fnic);
+ }
+
spin_lock_irqsave(&fnic_list_lock, flags);
list_del(&fnic->list);
spin_unlock_irqrestore(&fnic_list_lock, flags);
@@ -1356,6 +1432,15 @@ static int __init fnic_init_module(void)
goto err_create_fip_workq;
}
+ fnic_cmpl_queue =
+ alloc_workqueue("fnic_cmpl_wq",
+ WQ_PERCPU | WQ_HIGHPRI | WQ_MEM_RECLAIM, 0);
+ if (!fnic_cmpl_queue) {
+ pr_err("fnic completion work queue create failed\n");
+ err = -ENOMEM;
+ goto err_create_cmpl_workq;
+ }
+
if (pc_rscn_handling_feature_flag == PC_RSCN_HANDLING_FEATURE_ON) {
reset_fnic_work_queue =
create_singlethread_workqueue("reset_fnic_work_queue");
@@ -1387,6 +1472,8 @@ static int __init fnic_init_module(void)
err_pci_register:
fc_release_transport(fnic_fc_transport);
err_fc_transport:
+ destroy_workqueue(fnic_cmpl_queue);
+err_create_cmpl_workq:
destroy_workqueue(fnic_fip_queue);
err_create_fip_workq:
if (pc_rscn_handling_feature_flag == PC_RSCN_HANDLING_FEATURE_ON)
@@ -1415,6 +1502,7 @@ static int __init fnic_init_module(void)
static void __exit fnic_cleanup_module(void)
{
pci_unregister_driver(&fnic_driver);
+ destroy_workqueue(fnic_cmpl_queue);
destroy_workqueue(fnic_event_queue);
if (pc_rscn_handling_feature_flag == PC_RSCN_HANDLING_FEATURE_ON)
diff --git a/drivers/scsi/fnic/fnic_nvme.c b/drivers/scsi/fnic/fnic_nvme.c
new file mode 100644
index 000000000000..8374464e4fcc
--- /dev/null
+++ b/drivers/scsi/fnic/fnic_nvme.c
@@ -0,0 +1,1823 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ */
+#include <linux/mempool.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/workqueue.h>
+#include <linux/pci.h>
+#include <linux/scatterlist.h>
+#include <linux/skbuff.h>
+#include <linux/spinlock.h>
+#include <linux/kthread.h>
+#include <linux/if_ether.h>
+#include <linux/if_vlan.h>
+#include <linux/delay.h>
+#include <linux/gfp.h>
+#include <linux/nvme.h>
+#include <linux/nvme-fc.h>
+#include "fnic.h"
+#include "fnic_trace.h"
+#include "fdls_fc.h"
+
+#if IS_ENABLED(CONFIG_NVME_FC)
+
+int nvfnic_get_sg_count(struct fnic_io_req *io_req)
+{
+ return io_req->fcp_req->sg_cnt;
+}
+
+int nvfnic_dma_map_sgl(struct fnic *fnic, struct fnic_io_req *io_req,
+ int sg_count)
+{
+ io_req->sgl_list_pa = dma_map_single(&fnic->pdev->dev,
+ io_req->sgl_list,
+ sizeof(io_req->sgl_list[0]) *
+ sg_count, DMA_TO_DEVICE);
+ if (dma_mapping_error(&fnic->pdev->dev, io_req->sgl_list_pa)) {
+ dev_err(&fnic->pdev->dev, "DMA mapping failed\n");
+ io_req->sgl_list_pa = 0;
+ io_req->sgl_mapped = 0;
+ return -EBUSY;
+ }
+
+ io_req->sgl_mapped = 1;
+ return 0;
+}
+
+void nvfnic_dma_unmap_sgl(struct fnic *fnic, struct fnic_io_req *io_req)
+{
+ if (io_req->sgl_mapped) {
+ dma_unmap_single(&fnic->pdev->dev, io_req->sgl_list_pa,
+ sizeof(io_req->sgl_list[0]) * io_req->sgl_cnt,
+ DMA_TO_DEVICE);
+ io_req->sgl_mapped = 0;
+ io_req->sgl_list_pa = 0;
+ }
+}
+
+static void nvfnic_update_io_bytes(struct fnic *fnic,
+ struct fnic_io_req *io_req, u8 opcode)
+{
+ if (opcode == nvme_cmd_read)
+ fnic->fcp_input_bytes += io_req->fcp_req->transferred_length;
+ else if (opcode == nvme_cmd_write)
+ fnic->fcp_output_bytes += io_req->fcp_req->transferred_length;
+}
+
+int
+nvfnic_alloc_fcpio_tag(struct fnic_iport_s *iport, struct fnic_io_req *io_req)
+{
+ struct fnic *fnic = iport->fnic;
+ int tag;
+
+ tag = sbitmap_get(&fnic->nvfnic_tag_map);
+ if (tag >= 0) {
+ WRITE_ONCE(io_req->tag, tag);
+ fnic->sw_copy_wq[0].io_req_table[tag] = io_req;
+ return tag;
+ }
+ return FNIC_NVME_NO_FREE_TAG;
+}
+
+void
+nvfnic_free_fcpio_tag(struct fnic_iport_s *iport, struct fnic_io_req *io_req)
+{
+ struct fnic *fnic = iport->fnic;
+ uint16_t tag = io_req->tag;
+
+ if (tag == FNIC_NVME_NO_FREE_TAG) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Attempting to free invalid tag: 0x%x\n", tag);
+ return;
+ }
+ fnic->sw_copy_wq[0].io_req_table[tag] = NULL;
+ WRITE_ONCE(io_req->tag, FNIC_NVME_NO_FREE_TAG);
+ sbitmap_clear_bit(&fnic->nvfnic_tag_map, tag);
+}
+
+void
+nvfnic_reset_fcpio_tag_pool(struct fnic_iport_s *iport)
+{
+ WARN_ON(sbitmap_weight(&iport->fnic->nvfnic_tag_map));
+}
+
+struct fnic_io_req *
+nvfnic_find_io_req_by_tag(struct fnic *fnic, uint16_t tag)
+{
+ if (tag == FNIC_NVME_NO_FREE_TAG ||
+ !sbitmap_test_bit(&fnic->nvfnic_tag_map, tag))
+ return NULL;
+ return fnic->sw_copy_wq[0].io_req_table[tag];
+}
+
+/*
+ * Unmap the data buffer and sense buffer for an io_req,
+ * also unmap and free the device-private scatter/gather list.
+ */
+void nvfnic_release_nvme_ioreq_buf(struct fnic_iport_s *iport,
+ struct fnic_io_req *io_req)
+{
+ struct fnic *fnic = iport->fnic;
+
+ nvfnic_dma_unmap_sgl(fnic, io_req);
+
+ if (io_req->sgl_cnt)
+ mempool_free(io_req->sgl_list_alloc,
+ fnic->io_sgl_pool[io_req->sgl_type]);
+}
+
+inline int nvfnic_queue_wq_nvme_copy_desc(struct fnic *fnic,
+ struct vnic_wq_copy *wq,
+ struct fnic_io_req *io_req,
+ int sg_count)
+{
+ struct scatterlist *sg;
+ struct fnic_tport_s *tport = io_req->tport;
+ struct host_sg_desc *desc;
+ unsigned int i;
+ unsigned long intr_flags;
+ int flags;
+ u8 exch_flags;
+ struct scatterlist *sgl;
+ int idx;
+ int ret = 0;
+
+ if (sg_count) {
+ /* For each SGE, create a device desc entry */
+ desc = io_req->sgl_list;
+ sgl = io_req->fcp_req->first_sgl;
+ for_each_sg(sgl, sg, sg_count, i) {
+ desc->addr = cpu_to_le64(sg_dma_address(sg));
+ desc->len = cpu_to_le32(sg_dma_len(sg));
+ desc->_resvd = 0;
+ desc++;
+ }
+
+ ret = nvfnic_dma_map_sgl(fnic, io_req, sg_count);
+ if (ret)
+ return ret;
+ }
+
+ idx = (struct vnic_wq_copy *)wq - &fnic->hw_copy_wq[0];
+
+ /* Enqueue the descriptor in the Copy WQ */
+ spin_lock_irqsave(&fnic->wq_copy_lock[idx], intr_flags);
+
+ if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[idx])
+ free_wq_copy_descs(fnic, wq, idx);
+
+ if (unlikely(!vnic_wq_copy_desc_avail(wq))) {
+ spin_unlock_irqrestore(&fnic->wq_copy_lock[idx], intr_flags);
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Enqueue failure: No descriptors\n");
+ return -EBUSY;
+ }
+
+ flags = 0;
+ if (io_req->fcp_req->io_dir == NVMEFC_FCP_READ)
+ flags = FCPIO_ICMND_RDDATA;
+ else if (io_req->fcp_req->io_dir == NVMEFC_FCP_WRITE)
+ flags = FCPIO_ICMND_WRDATA;
+
+ exch_flags = 0;
+
+ fnic_queue_wq_copy_desc_nvme_io(wq, io_req->tag,
+ exch_flags, io_req->sgl_cnt,
+ io_req->sgl_list_pa, flags,
+ io_req->fcp_req->cmdaddr,
+ io_req->fcp_req->cmdlen,
+ io_req->fcp_req->payload_length,
+ io_req->port_id,
+ tport->max_payload_size, tport->r_a_tov,
+ tport->e_d_tov);
+
+
+ spin_unlock_irqrestore(&fnic->wq_copy_lock[idx], intr_flags);
+ return 0;
+}
+
+bool
+nvfnic_transport_ready(struct fnic_iport_s *iport, struct fnic_tport_s *tport)
+{
+ struct fnic *fnic = iport->fnic;
+
+ if (tport == NULL)
+ return false;
+
+ if (fdls_get_state(&iport->fabric) == FDLS_STATE_LINKDOWN ||
+ iport->state != FNIC_IPORT_STATE_READY) {
+ return false;
+ }
+
+ if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED)))
+ return false;
+
+ if (fdls_tport_is_offline(tport))
+ return false;
+
+ return true;
+}
+
+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;
+ int ret = 0;
+ int sg_count = 0;
+ unsigned long ptr;
+ unsigned char *lba;
+ u64 cmd_trace;
+ struct nvme_fc_cmd_iu *cmdiu = io_req->fcp_req->cmdaddr;
+
+ io_req->cmd_state = FNIC_IOREQ_NOT_INITED;
+ io_req->cmd_flags = FNIC_NO_FLAGS;
+ /* Map the data buffer */
+ sg_count = nvfnic_get_sg_count(io_req);
+ if (sg_count < 0) {
+ FNIC_TRACE(nvfnic_queuecommand, fnic->fnic_num,
+ io_req->tag, io_req, 0, io_req->fcp_req->io_dir,
+ sg_count, io_req->cmd_state);
+ FNIC_NVME_DBG(KERN_INFO, fnic, "sg count is less-than-zero\n");
+ ret = -1;
+ goto out;
+ }
+
+ /* Determine the type of scatter/gather list we need */
+ io_req->sgl_cnt = sg_count;
+ io_req->sgl_type = FNIC_SGL_CACHE_DFLT;
+ if (sg_count > FNIC_DFLT_SG_DESC_CNT)
+ io_req->sgl_type = FNIC_SGL_CACHE_MAX;
+
+ if (sg_count) {
+ io_req->sgl_list =
+ mempool_alloc(fnic->io_sgl_pool[io_req->sgl_type],
+ GFP_ATOMIC);
+ if (!io_req->sgl_list) {
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "Unable to alloc SGLs\n");
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ /* Cache sgl list allocated address before alignment */
+ io_req->sgl_list_alloc = io_req->sgl_list;
+ ptr = (unsigned long)io_req->sgl_list;
+ if (ptr % FNIC_SG_DESC_ALIGN) {
+ io_req->sgl_list = (struct host_sg_desc *)
+ (((unsigned long)ptr + FNIC_SG_DESC_ALIGN - 1)
+ & ~(FNIC_SG_DESC_ALIGN - 1));
+ }
+ }
+
+ io_req->port_id = tport->fcid;
+ io_req->start_time = jiffies;
+ io_req->cmd_state = FNIC_IOREQ_CMD_PENDING;
+ io_req->cmd_flags = FNIC_IO_INITIALIZED;
+
+ /* create copy wq desc and enqueue it */
+ 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");
+ /*
+ * In case another thread cancelled the request,
+ * refetch the pointer under the lock.
+ */
+ nvfnic_release_nvme_ioreq_buf(iport, io_req);
+ FNIC_TRACE(nvfnic_queuecommand, fnic->fnic_num,
+ io_req->tag, io_req->fcp_req, 0, 0, 0,
+ (((u64)io_req->cmd_flags << 32) | io_req->cmd_state));
+ return ret;
+ }
+ io_req->cmd_flags |= FNIC_IO_ISSUED;
+ out:
+ lba = (char *)&cmdiu->sqe.rw.slba;
+ cmd_trace = ((u64) cmdiu->sqe.rw.opcode << 56 | (u64) lba[4] << 40 |
+ (u64) lba[5] << 32 | (u64) lba[0] << 24 |
+ (u64) lba[1] << 16 | (u64) lba[2] << 8 | lba[3]);
+
+ FNIC_TRACE(nvfnic_queuecommand, fnic->fnic_num,
+ io_req->tag, 0, io_req,
+ sg_count, cmd_trace,
+ (((u64)io_req->cmd_flags >> 32) |
+ io_req->cmd_state));
+
+ return ret;
+}
+
+int nvfnic_fcpio_send(struct nvme_fc_local_port *lport,
+ struct nvme_fc_remote_port *rport, void *hw_queue_handle,
+ struct nvmefc_fcp_req *fcp_req)
+{
+ struct fnic_iport_s *iport = lport->private;
+ struct fnic_io_req *io_req;
+ int ret;
+ struct fnic *fnic = iport->fnic;
+ unsigned long flags = 0;
+ struct fnic_tport_s *tport;
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+
+ tport = (struct fnic_tport_s *)rport->private;
+ if (!nvfnic_transport_ready(iport, tport)) {
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ if (tport != NULL)
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "iport: 0x%x tport: 0x%x not ready\n",
+ iport->fcid, tport->fcid);
+ else
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "iport: 0x%x tport not ready\n",
+ iport->fcid);
+ return -ENODEV;
+ }
+ atomic_inc(&fnic->in_flight);
+
+ io_req = (struct fnic_io_req *) fcp_req->private;
+ io_req->iport = iport;
+ io_req->tport = (struct fnic_tport_s *)rport->private;
+ io_req->fcp_req = fcp_req;
+ io_req->done = nvfnic_fcpio_cmpl;
+ io_req->sgl_list_pa = 0;
+ io_req->wq = hw_queue_handle;
+ init_llist_node(&io_req->nvfnic_io_cmpl);
+
+ io_req->tag = nvfnic_alloc_fcpio_tag(iport, io_req);
+ if (io_req->tag == FNIC_NVME_NO_FREE_TAG) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "No free tag available. Failing IO\n");
+ atomic_dec(&fnic->in_flight);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return -EBUSY;
+ }
+
+ ret = nvfnic_queuecommand(io_req);
+ if (ret) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Queuecommand failed tag: 0x%x\n",
+ io_req->tag);
+ nvfnic_free_fcpio_tag(iport, io_req);
+ }
+
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ atomic_dec(&fnic->in_flight);
+ return ret;
+}
+
+void nvfnic_fcpio_nvme_fast_cmpl_handler(struct fnic *fnic,
+ struct fcpio_fw_req *desc)
+{
+ u8 type;
+ u8 hdr_status;
+ struct fcpio_tag ftag;
+ u32 id;
+ struct fnic_io_req *io_req;
+ unsigned long start_time;
+ u64 cmd_trace;
+ char *lba;
+ struct nvme_fc_cmd_iu *cmdiu;
+ struct fnic_iport_s *iport;
+ unsigned int tag;
+
+ /* Decode the cmpl description to get the io_req id */
+ fcpio_header_dec(&desc->hdr, &type, &hdr_status, &ftag);
+ fcpio_tag_id_dec(&ftag, &id);
+ tag = id & FNIC_TAG_MASK;
+
+ if (tag >= fnic->fnic_max_tag_id) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Tag out of range tag: 0x%x hdr status: %s\n", tag,
+ fnic_fcpio_status_to_str(hdr_status));
+ return;
+ }
+ spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
+
+ io_req = nvfnic_find_io_req_by_tag(fnic, tag);
+
+ WARN_ON_ONCE(!io_req);
+ if (!io_req) {
+ 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);
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "type: 0x%x status: 0x%x rsvd: 0x%x tag: 0x%x\n",
+ desc->hdr.type, desc->hdr.status, desc->hdr._resvd,
+ id);
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ return;
+ }
+
+ cmdiu = io_req->fcp_req->cmdaddr;
+ if (io_req->tag != tag) {
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "Tag mismatch tag:%d io:0x%x id:0x%x csn:%08x\n",
+ tag, io_req->tag, id, be32_to_cpu(cmdiu->csn));
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ return;
+ }
+ iport = io_req->iport;
+
+ start_time = io_req->start_time;
+
+ /* firmware completed the io */
+ io_req->io_completed = 1;
+ 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;
+ if (hdr_status == FCPIO_ABORTED)
+ io_req->cmd_flags |= FNIC_IO_ABORTED;
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "icmnd abts hdr:%d %s tag:0x%x io:%p",
+ hdr_status, fnic_fcpio_status_to_str(hdr_status),
+ id, io_req);
+ return;
+ }
+
+ if (io_req->cmd_state != FNIC_IOREQ_CMD_PENDING) {
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "IO freed id:%d tag:0x%x st:0x%x csn:%08x\n",
+ id, io_req->tag, io_req->cmd_state,
+ be32_to_cpu(cmdiu->csn));
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ return;
+ }
+
+ /* Mark the IO as complete */
+ io_req->cmd_state = FNIC_IOREQ_CMD_COMPLETE;
+ switch (hdr_status) {
+ case FCPIO_SUCCESS:
+ io_req->fcp_req->status = 0;
+ io_req->fcp_req->transferred_length =
+ io_req->fcp_req->payload_length;
+ io_req->fcp_req->rcv_rsplen = 12;
+ break;
+ default:
+ FNIC_NVME_DBG(KERN_ERR, fnic, "HDR status is non-zero\n");
+ io_req->fcp_req->status = NVME_SC_INTERNAL;
+ break;
+ }
+
+ if (hdr_status != FCPIO_SUCCESS) {
+ FNIC_NVME_DBG(KERN_INFO, fnic, "hdr status: %s\n",
+ fnic_fcpio_status_to_str(hdr_status));
+ }
+
+ io_req->cmd_flags |= FNIC_IO_DONE;
+
+ cmdiu = io_req->fcp_req->cmdaddr;
+ lba = (char *)&cmdiu->sqe.rw.slba;
+ cmd_trace = ((u64) hdr_status << 56) |
+ (u64) cmdiu->sqe.rw.opcode << 32 |
+ (u64) lba[0] << 24 | (u64) lba[1] << 16 |
+ (u64) lba[2] << 8 | lba[3];
+
+ FNIC_TRACE(nvfnic_fcpio_nvme_fast_cmpl_handler, fnic->fnic_num,
+ tag, io_req,
+ jiffies_to_msecs(jiffies - start_time),
+ desc, cmd_trace,
+ (((u64) io_req->cmd_flags << 32) |
+ io_req->cmd_state));
+
+ nvfnic_update_io_bytes(fnic, io_req, cmdiu->sqe.rw.opcode);
+
+ nvfnic_release_nvme_ioreq_buf(iport, io_req);
+ if (io_req->done)
+ io_req->done(io_req);
+
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+}
+
+void nvfnic_fcpio_ersp_cmpl_handler(struct fnic *fnic,
+ struct fcpio_fw_req *desc, int sw_flag)
+{
+ u8 type;
+ u8 hdr_status;
+ struct fcpio_tag ftag;
+ u32 id;
+ struct fcpio_nvme_cmpl *nvme_cmpl;
+ struct fnic_io_req *io_req;
+ unsigned long start_time;
+ uint32_t rsplen;
+ struct nvme_fc_ersp_iu *ersp;
+ struct nvme_fc_ersp_iu *nrsp;
+ struct nvme_fc_cmd_iu *cmdiu;
+ struct nvme_command *sqe;
+ struct nvme_completion *cqe;
+ u64 cmd_trace;
+ struct fnic_iport_s *iport;
+ unsigned int tag;
+ char *lba;
+ uint64_t tport_wwpn = 0;
+
+ /* Decode the cmpl description to get the io_req id */
+ fcpio_header_dec(&desc->hdr, &type, &hdr_status, &ftag);
+ fcpio_tag_id_dec(&ftag, &id);
+ nvme_cmpl = &desc->u.nvme_cmpl;
+ ersp = (struct nvme_fc_ersp_iu *) nvme_cmpl->resp_bytes;
+ tag = id & FNIC_TAG_MASK;
+
+ if (tag >= fnic->fnic_max_tag_id) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Tag out of range tag:0x%x hdr:%s\n", tag,
+ fnic_fcpio_status_to_str(hdr_status));
+ return;
+ }
+ spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
+
+ io_req = nvfnic_find_io_req_by_tag(fnic, tag);
+ if (!io_req) {
+ 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);
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "type: 0x%x status: 0x%x rsvd: 0x%x\n",
+ desc->hdr.type, desc->hdr.status, desc->hdr._resvd);
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ return;
+ }
+ iport = io_req->iport;
+ if (io_req->tport != NULL)
+ tport_wwpn = io_req->tport->wwpn;
+ cmdiu = io_req->fcp_req->cmdaddr;
+
+ if (io_req->tag != tag) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Tag mismatch io:0x%x tag:0x%x id:0x%x\n",
+ io_req->tag, tag, id);
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ return;
+ }
+
+ nrsp = (struct nvme_fc_ersp_iu *)io_req->fcp_req->rspaddr;
+ cmdiu = (struct nvme_fc_cmd_iu *)io_req->fcp_req->cmdaddr;
+ sqe = &cmdiu->sqe;
+ cqe = &nrsp->cqe;
+ start_time = io_req->start_time;
+
+ /* firmware completed the io */
+ io_req->io_completed = 1;
+
+ 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;
+ if (hdr_status == FCPIO_ABORTED)
+ io_req->cmd_flags |= FNIC_IO_ABORTED;
+
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "ABTS pending hdr status: %s tag: 0x%x",
+ fnic_fcpio_status_to_str(hdr_status), tag);
+ return;
+ }
+
+ if (io_req->cmd_state != FNIC_IOREQ_CMD_PENDING) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "IO already freed by abort. tag: 0x%x id: 0x%x\n",
+ io_req->tag, id);
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ return;
+ }
+
+ /* Mark the IO as complete */
+ io_req->cmd_state = FNIC_IOREQ_CMD_COMPLETE;
+
+ switch (hdr_status) {
+ case FCPIO_SUCCESS:
+ io_req->fcp_req->status = 0;
+ if (!sw_flag) {
+ io_req->fcp_req->transferred_length =
+ io_req->fcp_req->payload_length;
+ rsplen = 32;
+ nrsp->iu_len =
+ cpu_to_be16(sizeof(struct nvme_fc_ersp_iu) / 4);
+ nrsp->xfrd_len =
+ cpu_to_be32(io_req->fcp_req->payload_length);
+
+ nrsp->ersp_result = 0;
+ cqe->command_id = sqe->common.command_id;
+ cqe->status = 0;
+ cqe->result.u64 = 0;
+ } else {
+ io_req->fcp_req->transferred_length =
+ be32_to_cpu(ersp->xfrd_len);
+ rsplen = be16_to_cpu(ersp->iu_len) * 4;
+ if (rsplen > sizeof(nvme_cmpl->resp_bytes) ||
+ rsplen > io_req->fcp_req->rsplen) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport wwpn 0x%llx ERSP len %u desc %u req %u\n",
+ tport_wwpn, rsplen,
+ (u32)sizeof(nvme_cmpl->resp_bytes),
+ io_req->fcp_req->rsplen);
+ io_req->fcp_req->status = NVME_SC_INTERNAL;
+ io_req->fcp_req->rcv_rsplen = 0;
+ break;
+ }
+ memcpy(io_req->fcp_req->rspaddr, ersp, rsplen);
+ }
+ io_req->fcp_req->rcv_rsplen = rsplen;
+ break;
+
+ default:
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Unexpected header status: %d\n", hdr_status);
+ io_req->fcp_req->status = NVME_SC_INTERNAL;
+ break;
+ }
+
+ if (hdr_status != FCPIO_SUCCESS) {
+ FNIC_NVME_DBG(KERN_ERR, fnic, "hdr status: %s tag: 0x%x\n",
+ fnic_fcpio_status_to_str(hdr_status), tag);
+ }
+
+ io_req->cmd_flags |= FNIC_IO_DONE;
+
+ lba = (char *) &cmdiu->sqe.rw.slba;
+ cmd_trace = ((u64) hdr_status << 56) |
+ (u64) ersp->ersp_result << 48 |
+ (u64) cmdiu->sqe.rw.opcode << 32 |
+ (u64) lba[0] << 24 | (u64) lba[1] << 16 |
+ (u64) lba[2] << 8 | lba[3];
+
+ FNIC_TRACE(nvfnic_fcpio_ersp_cmpl_handler, fnic->fnic_num,
+ tag, io_req,
+ ((u64) nvme_cmpl->resvd[1] << 56 |
+ (u64) nvme_cmpl->resvd[0] << 48 |
+ jiffies_to_msecs(jiffies - start_time)),
+ desc, cmd_trace,
+ (((u64) io_req->cmd_flags << 32) |
+ io_req->cmd_state));
+
+ nvfnic_update_io_bytes(fnic, io_req, cmdiu->sqe.rw.opcode);
+
+ nvfnic_release_nvme_ioreq_buf(iport, io_req);
+
+ /* Call NVME completion function to complete the IO */
+ if (io_req->done)
+ io_req->done(io_req);
+
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+}
+
+void nvfnic_fcpio_nvme_itmf_cmpl_handler(struct fnic *fnic,
+ struct fcpio_fw_req *desc)
+{
+ u8 type;
+ u8 hdr_status;
+ struct fcpio_tag ftag;
+ u32 id;
+ unsigned int tag;
+ struct fnic_io_req *io_req;
+ struct nvme_fc_cmd_iu *cmd_iu;
+ struct fnic_iport_s *iport;
+
+ fcpio_header_dec(&desc->hdr, &type, &hdr_status, &ftag);
+ fcpio_tag_id_dec(&ftag, &id);
+ tag = id & FNIC_TAG_MASK;
+
+ if (tag >= fnic->fnic_max_tag_id) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Tag out of range id:0x%x tag:0x%x hdr:%s\n",
+ id, tag, fnic_fcpio_status_to_str(hdr_status));
+ return;
+ }
+ spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
+
+ io_req = nvfnic_find_io_req_by_tag(fnic, tag);
+ WARN_ON_ONCE(!io_req);
+ if (!io_req) {
+ 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);
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "type: 0x%x status: 0x%x rsvd: 0x%x\n",
+ desc->hdr.type, desc->hdr.status, desc->hdr._resvd);
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ return;
+ }
+
+ cmd_iu = io_req->fcp_req->cmdaddr;
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "Received ITMF completion tag: 0x%x hdr_status: %d csn: 0x%08x\n",
+ tag, hdr_status, be32_to_cpu(cmd_iu->csn));
+
+ iport = io_req->iport;
+
+ /* Completion of abort cmd */
+ switch (hdr_status) {
+ case FCPIO_SUCCESS:
+ FNIC_NVME_DBG(KERN_DEBUG, fnic,
+ "Abort success received tag: 0x%x id: 0x%x\n",
+ tag, id);
+ break;
+ case FCPIO_TIMEOUT:
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Abort timeout received tag: 0x%x id: 0x%x\n",
+ tag, id);
+ break;
+ case FCPIO_ITMF_REJECTED:
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Abort reject received tag: 0x%x id: 0x%x\n",
+ tag, id);
+ break;
+
+ case FCPIO_IO_NOT_FOUND:
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Abort IO not found tag:0x%x id:0x%x\n",
+ tag, id);
+ break;
+ default:
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Abort unknown received tag: 0x%x id: 0x%x\n",
+ tag, id);
+ break;
+ }
+
+ if (io_req->cmd_state != FNIC_IOREQ_ABTS_PENDING) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Abort late completion tag:0x%x id:0x%x\n",
+ tag, id);
+ /* This is a late completion. Ignore it */
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ return;
+ }
+
+ io_req->abts_state = hdr_status;
+
+ /* If the status is IO not found consider it as success.
+ * NVME sends abort even if rport is down in which case
+ * we will get FCPIO_TIMEOUT. Consider this as success.
+ */
+ if ((hdr_status == FCPIO_IO_NOT_FOUND) ||
+ (hdr_status == FCPIO_TIMEOUT) ||
+ (hdr_status == FCPIO_ITMF_REJECTED))
+ io_req->abts_state = FCPIO_SUCCESS;
+
+ io_req->cmd_flags |= FNIC_IO_ABT_TERM_DONE;
+
+
+ io_req->fcp_req->transferred_length = 0;
+ io_req->fcp_req->rcv_rsplen = 0;
+ if (io_req->abts_state == FCPIO_SUCCESS)
+ io_req->fcp_req->status = NVME_SC_ABORT_REQ;
+ else
+ io_req->fcp_req->status = NVME_SC_INTERNAL;
+
+ nvfnic_release_nvme_ioreq_buf(iport, io_req);
+ if (io_req->done)
+ io_req->done(io_req);
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+}
+
+bool _cleanup_tport_io(struct sbitmap *map, unsigned int tag,
+ void *data)
+{
+ struct fnic_tport_s *tport = data;
+ struct fnic_iport_s *iport = tport->iport;
+ struct fnic *fnic = iport->fnic;
+ struct fnic_io_req *io_req;
+ enum fnic_ioreq_state old_ioreq_state;
+ unsigned long flags;
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ io_req = nvfnic_find_io_req_by_tag(fnic, tag);
+ if (!io_req || io_req->tport != tport) {
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return true;
+ }
+
+ if ((io_req->cmd_state == FNIC_IOREQ_ABTS_PENDING) ||
+ (io_req->cmd_state == FNIC_DEV_RST_TERM_ISSUED)) {
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "Abort already pending 0x%x\n", io_req->tag);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return true;
+ }
+
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "io_req tag: 0x%x abort after unregister timeout\n",
+ io_req->tag);
+
+ old_ioreq_state = io_req->cmd_state;
+ io_req->cmd_state = FNIC_IOREQ_ABTS_PENDING;
+ io_req->abts_state = FCPIO_INVALID_CODE;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ if (!nvfnic_queue_abort_io_req(fnic, io_req->tag,
+ FCPIO_ITMF_ABT_TASK_TERM,
+ io_req)) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Failed to enqueue abort for ioreq tag: 0x%x\n",
+ io_req->tag);
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ io_req->cmd_state = old_ioreq_state;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ }
+ return true;
+}
+
+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;
+ if (!lsreq || (lsreq->private == NULL)) {
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "fnic_cleanup_tport_io lsreq NULL\n");
+ continue;
+ }
+ list_del_init(&nvfnic_ls_req->list);
+ lsreq->private = NULL;
+ oxid = nvfnic_ls_req->oxid;
+ fdls_free_oxid(&fnic->iport, oxid, &nvfnic_ls_req->oxid);
+ nvfnic_ls_req->state = FNIC_LS_REQ_CMD_COMPLETE;
+ list_add_tail(&nvfnic_ls_req->list, &done_reqs);
+ }
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ list_for_each_entry_safe(nvfnic_ls_req, next, &done_reqs, list) {
+ list_del_init(&nvfnic_ls_req->list);
+ lsreq = nvfnic_ls_req->ls_req;
+ timer_delete_sync(&nvfnic_ls_req->ls_req_timer);
+ lsreq->done(lsreq, -ENXIO);
+ }
+
+ /* For link-down, IOs are freed by firmware reset completion */
+ if (fdls_get_state(&fnic->iport.fabric) == FDLS_STATE_LINKDOWN)
+ return;
+
+ sbitmap_for_each_set(&fnic->nvfnic_tag_map, _cleanup_tport_io, tport);
+}
+
+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);
+ list_for_each_entry_safe(nvfnic_ls_req, next,
+ &(tport->ls_req_list), list) {
+
+ lsreq = nvfnic_ls_req->ls_req;
+ if (!lsreq || (lsreq->private == NULL)) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "lsreq is NULL\n");
+ continue;
+ }
+ oxid = nvfnic_ls_req->oxid;
+ list_del_init(&nvfnic_ls_req->list);
+ lsreq->private = NULL;
+ fdls_free_oxid(&fnic->iport, oxid, &nvfnic_ls_req->oxid);
+ nvfnic_ls_req->state = FNIC_LS_REQ_CMD_COMPLETE;
+ list_add_tail(&nvfnic_ls_req->list, &done_reqs);
+ }
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+
+ list_for_each_entry_safe(nvfnic_ls_req, next, &done_reqs, list) {
+ list_del_init(&nvfnic_ls_req->list);
+ lsreq = nvfnic_ls_req->ls_req;
+ timer_delete_sync(&nvfnic_ls_req->ls_req_timer);
+ lsreq->done(lsreq, -ENXIO);
+ count++;
+ }
+
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "fnic_terminate_tport_lsreqs tport: 0x%x: freed lsreq: %d\n",
+ tport->fcid, count);
+}
+
+bool _terminate_tport_ios(struct sbitmap *map, unsigned int tag,
+ void *data)
+{
+ struct fnic_tport_s *tport = data;
+ struct fnic_iport_s *iport = tport->iport;
+ struct fnic *fnic = iport->fnic;
+ struct fnic_io_req *io_req;
+ struct nvmefc_fcp_req *fcp_req = NULL;
+ struct nvme_fc_local_port *lport = iport->nv_lport;
+ struct nvme_fc_remote_port *rport = tport->nv_rport;
+ unsigned long flags;
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ io_req = fnic->sw_copy_wq[0].io_req_table[tag];
+ if (!io_req) {
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return true;
+ }
+
+ if (io_req->tport != tport) {
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return true;
+ }
+
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "Terminate tag: 0x%x (tport fcid 0x%x)\n",
+ io_req->tag, io_req->tport->fcid);
+ fcp_req = io_req->fcp_req;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ nvfnic_fcpio_abort(lport, rport, NULL, fcp_req);
+ return true;
+}
+
+void nvfnic_terminate_tport_ios(struct fnic *fnic,
+ struct fnic_tport_s *tport)
+{
+
+ sbitmap_for_each_set(&fnic->nvfnic_tag_map, _terminate_tport_ios, tport);
+
+}
+
+bool _cleanup_all_nvme_io(struct sbitmap *map, unsigned int tag,
+ void *data)
+{
+ struct fnic_iport_s *iport = data;
+ struct fnic_io_req *io_req;
+
+ io_req = iport->fnic->sw_copy_wq[0].io_req_table[tag];
+ if (!io_req)
+ return true;
+
+ io_req->cmd_state = FNIC_DEV_RST_TERM_ISSUED;
+ io_req->fcp_req->status = NVME_SC_INTERNAL;
+ io_req->fcp_req->transferred_length = 0;
+ io_req->fcp_req->rcv_rsplen = 0;
+ nvfnic_release_nvme_ioreq_buf(iport, io_req);
+ io_req->done(io_req);
+ return true;
+}
+
+void nvfnic_cleanup_all_nvme_ios(struct fnic *fnic)
+{
+ struct fnic_iport_s *iport = &fnic->iport;
+
+ spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
+ sbitmap_for_each_set(&fnic->nvfnic_tag_map, _cleanup_all_nvme_io,
+ iport);
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+}
+
+void nvfnic_nvme_zero_devloss_tports(struct fnic *fnic)
+{
+ struct fnic_tport_s *tport, *next;
+
+ spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
+ list_for_each_entry_safe(tport, next, &fnic->iport.tport_list, links) {
+ if (tport->flags & FNIC_FDLS_NVME_REGISTERED) {
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ nvme_fc_set_remoteport_devloss(tport->nv_rport, 0);
+ spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
+ }
+ }
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+}
+
+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);
+
+ /* Mark iport state as INIT so that no IOs can be issued from this point */
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ fnic->in_remove = 1;
+ fnic->iport.state = FNIC_IPORT_STATE_LINK_WAIT;
+ fnic->nvme_lport_unreg_done = &nvme_lport_unreg_done;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ /*
+ * If fnic is already processing link-down or fnic is held
+ * in disabled state following a reboot we dont need to issue
+ * firmware reset and unregister remote ports as it is already
+ * done as part of link down handling.
+ */
+ if (fdls_get_state(&iport->fabric) == FDLS_STATE_LINKDOWN) {
+ while (fnic->reset_in_progress == IN_PROGRESS) {
+ wait_for_completion_timeout(&fnic->reset_completion_wait,
+ msecs_to_jiffies(5000));
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "rmmod waiting for reset %p\n", fnic);
+ }
+ } else if (fdls_get_state(&iport->fabric) != FDLS_STATE_INIT)
+ fnic_fcpio_reset(fnic);
+
+ /*
+ * Mark state so that the workqueue thread stops forwarding
+ * received frames and link events to the local port. ISR and
+ * other threads that can queue work items will also stop
+ * creating work items on the fnic workqueue
+ */
+ nvfnic_nvme_zero_devloss_tports(fnic);
+ fnic_flush_tport_event_list(fnic);
+ fnic_delete_fcp_tports(fnic);
+
+ if (iport->flags & FNIC_LPORT_NVME_REGISTERED) {
+ ret = nvme_fc_unregister_localport(fnic->iport.nv_lport);
+ if (ret) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Unregister nvme localport failed: %d\n", ret);
+ } else {
+ 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);
+ }
+ }
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ fnic->nvme_lport_unreg_done = NULL;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ nvfnic_flush_nvme_io_list(fnic);
+}
+
+struct nvfnic_ls_req*
+nvfnic_find_ls_req(struct fnic_tport_s *tport, uint16_t oxid)
+{
+ struct nvfnic_ls_req *nvfnic_ls_req, *next;
+
+ list_for_each_entry_safe(nvfnic_ls_req, next, &(tport->ls_req_list), list) {
+ if (nvfnic_ls_req->oxid == oxid)
+ return nvfnic_ls_req;
+ }
+ return NULL;
+}
+
+void nvfnic_fcpio_cmpl(struct fnic_io_req *io_req)
+{
+ struct fnic *fnic = io_req->iport->fnic;
+
+ nvfnic_free_fcpio_tag(io_req->iport, io_req);
+ 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);
+
+ queue_work(fnic_cmpl_queue, &fnic->nvme_io_cmpl_work);
+}
+
+void nvfnic_process_ls_abts_rsp(struct fnic_iport_s *iport,
+ struct fc_frame_header *fchdr)
+{
+ uint32_t tport_fcid;
+ struct fnic_tport_s *tport;
+ struct nvfnic_ls_req *nvfnic_ls_req;
+ struct nvmefc_ls_req *lsreq;
+ uint8_t *fcid;
+ uint16_t oxid = FNIC_STD_GET_OX_ID(fchdr);
+ struct fnic *fnic = iport->fnic;
+
+ fcid = FNIC_STD_GET_S_ID(fchdr);
+ tport_fcid = ntoh24(fcid);
+
+ tport = fnic_find_tport_by_fcid(iport, tport_fcid);
+ if (tport == NULL) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport: 0x%x not found\n", tport_fcid);
+ return;
+ }
+
+ nvfnic_ls_req = nvfnic_find_ls_req(tport, oxid);
+ if (nvfnic_ls_req == NULL) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport: 0x%x lsreq oxid: 0x%x not found\n",
+ tport_fcid, oxid);
+ return;
+ }
+
+ lsreq = nvfnic_ls_req->ls_req;
+ if ((lsreq == NULL) || (lsreq->private == NULL)) {
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "tport: 0x%x lsreq oxid: 0x%x already aborted\n",
+ tport_fcid, oxid);
+ return;
+ }
+
+ nvfnic_ls_req->state = FNIC_LS_REQ_ABTS_COMPLETE;
+
+ list_del(&nvfnic_ls_req->list);
+ fdls_free_oxid(iport, oxid, &nvfnic_ls_req->oxid);
+ lsreq->private = NULL;
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ timer_delete_sync(&nvfnic_ls_req->ls_req_timer);
+ lsreq->done(lsreq, NVME_SC_HOST_ABORTED_CMD);
+ spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
+}
+
+/**
+ * nvfnic_ls_rsp_recv - Handle received NVMe FC link service (LS) response
+ * @iport: Pointer to the local FNIC port structure
+ * @fchdr: Pointer to the Fibre Channel frame header for the
+ * received response
+ * @len: Length of the received frame
+ *
+ * This function processes link service (LS) responses received from
+ * NVMe Discovery Controllers or regular NVMe subsystems during
+ * association.
+ */
+void nvfnic_ls_rsp_recv(struct fnic_iport_s *iport,
+ struct fc_frame_header *fchdr, int len)
+{
+ uint8_t *fcid;
+ uint32_t tport_fcid;
+ struct fnic_tport_s *tport;
+ struct nvfnic_ls_req *nvfnic_ls_req;
+ struct nvmefc_ls_req *lsreq;
+ uint16_t oxid;
+ uint32_t rsp_len;
+ int sid_len = offsetof(struct fc_frame_header, fh_s_id) +
+ sizeof(fchdr->fh_s_id);
+ int status = 0;
+ struct fnic *fnic = iport->fnic;
+
+ if (len < (int)sizeof(*fchdr)) {
+ if (len >= sid_len) {
+ fcid = FNIC_STD_GET_S_ID(fchdr);
+ tport_fcid = ntoh24(fcid);
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport: 0x%x LS rsp len %d too short\n",
+ tport_fcid, len);
+ } else {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "LS response len %d too short\n", len);
+ }
+ return;
+ }
+ rsp_len = len - sizeof(*fchdr);
+
+ fcid = FNIC_STD_GET_S_ID(fchdr);
+ tport_fcid = ntoh24(fcid);
+
+ tport = fnic_find_tport_by_fcid(iport, tport_fcid);
+ if (!tport) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport: 0x%x not found\n", tport_fcid);
+ return;
+ }
+
+ oxid = FNIC_STD_GET_OX_ID(fchdr);
+ nvfnic_ls_req = nvfnic_find_ls_req(tport, oxid);
+ if (!nvfnic_ls_req) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport: 0x%x no nvfnic_lsreq for oxid: 0x%x\n",
+ tport_fcid, oxid);
+ return;
+ }
+
+ lsreq = nvfnic_ls_req->ls_req;
+ if (!lsreq || (lsreq->private == NULL)) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport:0x%x lsreq:0x%x already done\n",
+ tport_fcid, oxid);
+ return;
+ }
+ if (!lsreq->rspaddr) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport 0x%x lsreq 0x%x rspaddr NULL\n",
+ tport_fcid, oxid);
+ return;
+ }
+
+ if ((nvfnic_ls_req->state == FNIC_LS_REQ_CMD_ABTS_PENDING) ||
+ (nvfnic_ls_req->state == FNIC_LS_REQ_CMD_ABTS_STARTED)) {
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "tport 0x%x lsreq oxid: 0x%x abts pending\n",
+ tport_fcid, oxid);
+ return;
+ }
+
+ if (rsp_len > lsreq->rsplen) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport:0x%x lsreq:0x%x rsp %u > %u\n",
+ tport_fcid, oxid, rsp_len, lsreq->rsplen);
+ status = -EOVERFLOW;
+ }
+
+ nvfnic_ls_req->state = FNIC_LS_REQ_CMD_COMPLETE;
+
+ list_del_init(&nvfnic_ls_req->list);
+ lsreq->private = NULL;
+ fdls_free_oxid(iport, oxid, &nvfnic_ls_req->oxid);
+ timer_delete(&nvfnic_ls_req->ls_req_timer);
+
+ if (status == 0) {
+ FNIC_NVME_DBG(KERN_DEBUG, fnic,
+ "tport:0x%x lsreq:0x%x completed\n",
+ tport_fcid, oxid);
+
+ /* Copy the Response */
+ memcpy(lsreq->rspaddr, (uint8_t *)fchdr + sizeof(*fchdr),
+ rsp_len);
+ }
+
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ lsreq->done(lsreq, status);
+ spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
+}
+
+void nvfnic_ls_req_timeout(struct timer_list *t)
+{
+ struct nvfnic_ls_req *nvfnic_ls_req = timer_container_of(nvfnic_ls_req,
+ t, ls_req_timer);
+ struct fnic *fnic = nvfnic_ls_req->fnic;
+ 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;
+ uint16_t oxid = nvfnic_ls_req->oxid;
+
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "tport: 0x%x lsreq: 0x%x state: %d timeout\n",
+ tport->fcid, nvfnic_ls_req->oxid,
+ nvfnic_ls_req->state);
+ spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
+
+ if ((ls_req->private == NULL) ||
+ (nvfnic_ls_req->state == FNIC_LS_REQ_CMD_ABTS_STARTED)) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport: 0x%x lsreq: 0x%x already aborted\n",
+ tport->fcid, nvfnic_ls_req->oxid);
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ return;
+ }
+
+ if (nvfnic_ls_req->state == FNIC_LS_REQ_CMD_ABTS_PENDING) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport: 0x%x lsreq: 0x%x abort timeout\n",
+ tport->fcid, nvfnic_ls_req->oxid);
+
+ list_del(&nvfnic_ls_req->list);
+ ls_req = nvfnic_ls_req->ls_req;
+ fdls_free_oxid(iport, oxid, &nvfnic_ls_req->oxid);
+ ls_req->private = NULL;
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ ls_req->done(ls_req, -ETIMEDOUT);
+ return;
+ } else if ((nvfnic_ls_req->state == FNIC_LS_REQ_CMD_PENDING) &&
+ (nvfnic_transport_ready(iport, tport))) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport: 0x%x lsreq: 0x%x sending abort\n",
+ tport->fcid, nvfnic_ls_req->oxid);
+ }
+
+ if (ls_req->private == NULL) {
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ return;
+ }
+
+ list_del(&nvfnic_ls_req->list);
+ ls_req = nvfnic_ls_req->ls_req;
+ fdls_free_oxid(iport, oxid, &nvfnic_ls_req->oxid);
+ ls_req->private = NULL;
+
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ ls_req->done(ls_req, -ETIMEDOUT);
+}
+
+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);
+ if (fnic->nvme_lport_unreg_done)
+ complete(fnic->nvme_lport_unreg_done);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+}
+
+void nvfnic_remote_port_delete(struct nvme_fc_remote_port *rport)
+{
+ /*
+ * Read rport->private without the lock only to find fnic.
+ * Re-read it under fnic_lock to claim this delete callback, since
+ * another callback may already have cleared it.
+ */
+ struct fnic_tport_s *tport = (struct fnic_tport_s *)rport->private;
+ struct fnic_iport_s *iport;
+ struct fnic *fnic = NULL;
+ unsigned long flags = 0;
+
+ if (tport == NULL) {
+ pr_err("Attempt to delete already deleted tport\n");
+ return;
+ }
+
+ iport = tport->iport;
+ fnic = iport->fnic;
+ FNIC_NVME_DBG(KERN_INFO, fnic, "0x%x tport 0x%x\n",
+ iport->fcid, tport->fcid);
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ tport = (struct fnic_tport_s *)rport->private;
+ if (tport == NULL) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "NVMe tport callback after NULL set %p\n",
+ rport);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return;
+ }
+
+ iport = tport->iport;
+ rport->private = NULL;
+ fdls_delete_tport(iport, tport);
+
+ if (tport->flags & FNIC_FDLS_NVME_TPORT_CLEANUP_PENDING) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport %8x waiting on clean pending\n",
+ tport->fcid);
+ }
+
+ while (tport->flags & FNIC_FDLS_NVME_TPORT_CLEANUP_PENDING) {
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ msleep(2000);
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ }
+
+ list_del(&tport->links);
+
+ if (tport->tport_del_done)
+ complete(tport->tport_del_done);
+
+ tport->flags |= FNIC_TPORT_CAN_BE_FREED;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+}
+
+int nvfnic_create_queue(struct nvme_fc_local_port *lport,
+ unsigned int idx, u16 size, void **handle)
+{
+ struct fnic_iport_s *iport = (struct fnic_iport_s *)lport->private;
+ struct fnic *fnic = iport->fnic;
+
+ FNIC_NVME_DBG(KERN_DEBUG, fnic,
+ "iport:0x%x queue:%d size:%d\n", iport->fcid, idx, size);
+
+ if (idx > fnic->wq_copy_count)
+ return -EINVAL;
+
+ if (idx == 0) {
+ /* Admin queue */
+ *handle = &fnic->hw_copy_wq[0];
+ } else {
+ /* IO queues */
+ *handle = &fnic->hw_copy_wq[idx-1];
+ }
+
+ return 0;
+}
+
+void nvfnic_ls_req_abort(struct nvme_fc_local_port *lport,
+ struct nvme_fc_remote_port *rport,
+ struct nvmefc_ls_req *lsreq)
+{
+ struct fnic_iport_s *iport = lport->private;
+ struct fnic *fnic = iport->fnic;
+ struct fnic_tport_s *tport;
+ struct nvfnic_ls_req *nvfnic_ls_req;
+ uint16_t oxid;
+ int timeout;
+
+ spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
+
+ tport = (struct fnic_tport_s *) rport->private;
+ /* find the request */
+ nvfnic_ls_req = lsreq->private;
+
+ if (nvfnic_ls_req == NULL) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "0x%x null lsreq already scheduled for abort\n",
+ iport->fcid);
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ return;
+ }
+
+ if (nvfnic_ls_req->state == FNIC_LS_REQ_CMD_ABTS_PENDING) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "0x%x lsreq 0x%x already scheduled for abort\n",
+ iport->fcid, nvfnic_ls_req->oxid);
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ return;
+ }
+
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "0x%x lsreq 0x%x abts\n",
+ iport->fcid, nvfnic_ls_req->oxid);
+
+ nvfnic_ls_req->state = FNIC_LS_REQ_CMD_ABTS_STARTED;
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ timer_delete_sync(&nvfnic_ls_req->ls_req_timer);
+
+ spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
+ nvfnic_ls_req = lsreq->private;
+
+ if ((nvfnic_ls_req == NULL) ||
+ (nvfnic_ls_req->state == FNIC_LS_REQ_CMD_ABTS_PENDING)) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "lsreq timeout raced with midlayer abort\n");
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ return;
+ }
+
+ /* Basic validations of the state */
+ if (!nvfnic_transport_ready(iport, tport)) {
+ /* If iport or tport offline, it will be handled from that event */
+ oxid = nvfnic_ls_req->oxid;
+ lsreq->private = NULL;
+ list_del(&nvfnic_ls_req->list);
+ fdls_free_oxid(iport, oxid, &nvfnic_ls_req->oxid);
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+ lsreq->done(lsreq, -ENXIO);
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "nvfnic_lsreq_abort transport not ready\n");
+ return;
+ }
+
+ /* 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)));
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+}
+
+bool nvfnic_queue_abort_io_req(struct fnic *fnic, int tag,
+ u32 task_req, struct fnic_io_req *io_req)
+{
+ int idx;
+ unsigned long flags;
+
+ idx = io_req->wq - &fnic->hw_copy_wq[0];
+
+ atomic_inc(&fnic->in_flight);
+
+ spin_lock_irqsave(&fnic->wq_copy_lock[idx], flags);
+
+ if (vnic_wq_copy_desc_avail(io_req->wq) <= fnic->wq_copy_desc_low[idx])
+ free_wq_copy_descs(fnic, io_req->wq, idx);
+
+ if (!vnic_wq_copy_desc_avail(io_req->wq)) {
+ spin_unlock_irqrestore(&fnic->wq_copy_lock[idx], flags);
+ atomic_dec(&fnic->in_flight);
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tag 0x%x failure: no descriptors\n", tag);
+ 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);
+
+
+ spin_unlock_irqrestore(&fnic->wq_copy_lock[idx], flags);
+ atomic_dec(&fnic->in_flight);
+
+ return true;
+}
+
+void nvfnic_fcpio_abort(struct nvme_fc_local_port *lport,
+ struct nvme_fc_remote_port *rport,
+ void *hw_queue_handle, struct nvmefc_fcp_req *fcp_req)
+{
+ struct fnic_iport_s *iport = lport->private;
+ struct fnic *fnic = iport->fnic;
+ 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;
+ unsigned long flags = 0;
+ unsigned int task_req;
+ enum fnic_ioreq_state old_ioreq_state;
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+
+ if (io_req->tag == FNIC_NVME_NO_FREE_TAG) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tag: (0x%x) tport_fcid: 0x%x\n",
+ io_req->tag, io_req->tport->fcid);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return;
+ }
+
+ if (io_req != nvfnic_find_io_req_by_tag(fnic, io_req->tag)) {
+ 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));
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return;
+ }
+
+ if (io_req->cmd_state == FNIC_IOREQ_CMD_COMPLETE) {
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "IO already completed before abort: 0x%x\n", tag);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return;
+ }
+
+ if ((io_req->cmd_state == FNIC_IOREQ_ABTS_PENDING) ||
+ (io_req->cmd_state == FNIC_DEV_RST_TERM_ISSUED)) {
+ FNIC_NVME_DBG(KERN_INFO, fnic, "abort already pending %d\n",
+ tag);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return;
+ }
+
+ if (io_req->cmd_state != FNIC_IOREQ_CMD_PENDING) {
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "io_req completed or aborted for tag:0x%x\n",
+ tag);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return;
+ }
+
+ FNIC_NVME_DBG(KERN_INFO, fnic, "in abort cmd_sn:%08x %llx tag: 0x%x\n",
+ be32_to_cpu(cmd_iu->csn),
+ le64_to_cpu(cmd_iu->sqe.rw.slba), io_req->tag);
+
+ if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED))) {
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "abort tag:0x%x returned during fw reset\n",
+ io_req->tag);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return;
+ }
+ atomic_inc(&fnic->in_flight);
+
+ if (fdls_tport_is_offline(io_req->tport) ||
+ (io_req->cmd_state == FNIC_IOREQ_RESET_TERM)) {
+ task_req = FCPIO_ITMF_ABT_TASK_TERM;
+ } else {
+ task_req = FCPIO_ITMF_ABT_TASK;
+ }
+
+
+
+ old_ioreq_state = io_req->cmd_state;
+ io_req->cmd_state = FNIC_IOREQ_ABTS_PENDING;
+ io_req->abts_state = FCPIO_INVALID_CODE;
+
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ if (!nvfnic_queue_abort_io_req(fnic, io_req->tag, task_req, io_req)) {
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "Abort io req queue failed\n");
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ io_req->cmd_state = old_ioreq_state;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ }
+ atomic_dec(&fnic->in_flight);
+}
+
+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,
+ .ls_abort = nvfnic_ls_req_abort,
+ .fcp_io = nvfnic_fcpio_send,
+ .fcp_abort = nvfnic_fcpio_abort,
+ .max_hw_queues = 1,
+ .max_sgl_segments = 256,
+ .max_dif_sgl_segments = 64,
+ .dma_boundary = 0xFFFFFFFF,
+ .local_priv_sz = sizeof(struct fnic_iport_s *),
+ .remote_priv_sz = sizeof(struct fnic_tport_s *),
+ .lsrqst_priv_sz = sizeof(struct nvfnic_ls_req),
+ .fcprqst_priv_sz = sizeof(struct fnic_io_req),
+};
+
+void nvfnic_flush_nvme_io_list(struct fnic *fnic)
+{
+ queue_work(fnic_cmpl_queue, &fnic->nvme_io_cmpl_work);
+ flush_work(&fnic->nvme_io_cmpl_work);
+}
+
+void nvfnic_nvme_iodone_work(struct work_struct *work)
+{
+ struct fnic *fnic = container_of(work, struct fnic, nvme_io_cmpl_work);
+ struct llist_node *llnode;
+ struct fnic_io_req *io_req, *tmp;
+
+ 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);
+ io_req->fcp_req->done(io_req->fcp_req);
+ }
+}
+
+void nvfnic_exch_reset(struct fnic_iport_s *iport, struct fnic_tport_s *tport)
+{
+ FNIC_NVME_DBG(KERN_DEBUG, iport->fnic,
+ "0x%x: Exchange reset scheduled for tport: 0x%x\n",
+ iport->fcid, tport->fcid);
+
+ nvfnic_terminate_tport_ls_reqs(iport->fnic, tport);
+ nvfnic_terminate_tport_ios(iport->fnic, tport);
+}
+
+void nvfnic_delete_tport(struct fnic_iport_s *iport,
+ struct fnic_tport_s *tport,
+ unsigned long flags)
+{
+ struct fnic *fnic = iport->fnic;
+ int ret;
+ unsigned int time_wait = FNIC_NVME_TPORT_REMOVE_WAIT;
+ unsigned int time_remain;
+ DECLARE_COMPLETION_ONSTACK(tm_done);
+ unsigned int fcid;
+ int count = 0;
+
+ if (!tport)
+ return;
+
+ fcid = tport->fcid;
+ fdls_set_tport_state(tport, FDLS_TGT_STATE_OFFLINE);
+
+ FNIC_NVME_DBG(KERN_DEBUG, fnic,
+ "0x%x: scheduled deletion for tport: 0x%x\n",
+ iport->fcid, tport->fcid);
+
+ 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;
+
+ tport->flags |= FNIC_FDLS_TPORT_DELETED;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ ret = nvme_fc_unregister_remoteport(tport->nv_rport);
+ if (ret) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport: 0x%x unregister failed %d\n",
+ tport->fcid, ret);
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ tport->tport_del_done = NULL;
+ list_del(&tport->links);
+ kfree(tport);
+ return;
+ }
+ time_remain = wait_for_completion_timeout(tport->tport_del_done,
+ msecs_to_jiffies(time_wait));
+
+ FNIC_NVME_DBG(KERN_DEBUG, fnic,
+ "tport: 0x%x wait for deletion done\n",
+ tport->fcid);
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ tport->tport_del_done = NULL;
+
+ if (!time_remain) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport: 0x%x nvme midlayer completion timed out\n",
+ tport->fcid);
+
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ nvfnic_cleanup_tport_io(fnic, tport);
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ tport->flags &= ~FNIC_FDLS_NVME_TPORT_CLEANUP_PENDING;
+ list_del(&tport->links);
+ kfree(tport);
+ } else {
+ while (!(tport->flags & FNIC_TPORT_CAN_BE_FREED) && (count < 8)) {
+ count++;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ msleep(2000);
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ }
+ if (tport->flags & FNIC_TPORT_CAN_BE_FREED)
+ kfree(tport);
+ }
+
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "tport: 0x%x delete complete\n", fcid);
+}
+
+int nvfnic_add_tport(struct fnic *fnic, struct fnic_tport_s *tport,
+ unsigned long flags)
+{
+ struct fnic_iport_s *iport = &fnic->iport;
+ struct nvme_fc_port_info pinfo;
+ int ret = 0;
+
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "Adding tport to nvme wwpn: 0x%llx\n",
+ tport->wwpn);
+
+ memset(&pinfo, 0, sizeof(struct nvme_fc_port_info));
+
+ pinfo.port_name = tport->wwpn;
+ pinfo.node_name = tport->wwnn;
+ pinfo.port_role = FC_PORT_ROLE_NVME_DISCOVERY | FC_PORT_ROLE_NVME_TARGET;
+ pinfo.port_id = tport->fcid;
+ pinfo.dev_loss_tmo = nvme_dev_loss_tmo;
+
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ ret = nvme_fc_register_remoteport(iport->nv_lport, &pinfo,
+ &tport->nv_rport);
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+ if (ret) {
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "Failed to register tport wwpn: 0x%llx ret: %d\n",
+ tport->wwpn, ret);
+ return ret;
+ }
+ tport->flags |= FNIC_FDLS_NVME_REGISTERED;
+ tport->nv_rport->private = tport;
+
+ snprintf(tport->str_wwpn, sizeof(tport->str_wwpn), "0x%llx", tport->wwpn);
+ snprintf(tport->str_wwnn, sizeof(tport->str_wwnn), "0x%llx", tport->wwnn);
+ return ret;
+}
+
+int nvfnic_add_lport(struct fnic *fnic)
+{
+ struct nvme_fc_port_info pinfo;
+ struct fnic_iport_s *iport = &fnic->iport;
+ int ret = 0;
+
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "Adding lport nvme wwpn: 0x%llx\n",
+ iport->wwpn);
+
+ pinfo.node_name = iport->wwnn;
+ pinfo.port_name = iport->wwpn;
+ pinfo.port_role = FC_PORT_ROLE_NVME_INITIATOR;
+ pinfo.port_id = iport->fcid;
+
+ nvfnic_reset_fcpio_tag_pool(iport);
+
+ if (!(iport->flags & FNIC_LPORT_NVME_REGISTERED)) {
+ iport->nv_tmpl = kzalloc_obj(struct nvme_fc_port_template, GFP_ATOMIC);
+ if (!iport->nv_tmpl) {
+ FNIC_FCS_DBG(KERN_INFO, fnic,
+ "iport:0x%x NVMe tmpl alloc failed\n",
+ iport->fcid);
+ return -ENOMEM;
+ }
+ memcpy(iport->nv_tmpl, &nvfnic_port,
+ sizeof(struct nvme_fc_port_template));
+ iport->nv_tmpl->max_hw_queues = fnic->wq_copy_count;
+
+ ret = nvme_fc_register_localport(&pinfo, iport->nv_tmpl,
+ get_device(&fnic->pdev->dev),
+ &iport->nv_lport);
+ if (ret) {
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "Failed to add wwpn: 0x%llx ret: %d\n",
+ iport->wwpn, ret);
+ kfree(iport->nv_tmpl);
+ return ret;
+ }
+ iport->flags |= FNIC_LPORT_NVME_REGISTERED;
+ iport->nv_lport->private = iport;
+ }
+
+ sprintf(iport->str_wwpn, "0x%llx", iport->wwpn);
+ sprintf(iport->str_wwnn, "0x%llx", iport->wwnn);
+
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "Successfully added lport wwpn: 0x%llx\n",
+ iport->wwpn);
+ return 0;
+}
+
+#endif
diff --git a/drivers/scsi/fnic/fnic_nvme.h b/drivers/scsi/fnic/fnic_nvme.h
new file mode 100644
index 000000000000..ab96b8d13931
--- /dev/null
+++ b/drivers/scsi/fnic/fnic_nvme.h
@@ -0,0 +1,205 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright 2008 Cisco Systems, Inc. All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc. All rights reserved.
+ */
+#ifndef _FNIC_NVME_H
+#define _FNIC_NVME_H
+
+#include "fdls_fc.h"
+#include "fnic_fdls.h"
+
+#define FNIC_NVME_TPORT_REMOVE_WAIT (5 * 1000)
+#define FNIC_NVME_TPORT_LIST_EMPTY_WAIT (FNIC_NVME_TPORT_REMOVE_WAIT * 2)
+#define FNIC_NVME_LPORT_REMOVE_WAIT (2 * 60 * 1000)
+
+#define FNIC_LS_REQ_FLAGS_NONE 0x0
+#define FNIC_LS_REQ_FLAGS_ABORTED 0x1
+#define FNIC_LS_REQ_FLAGS_DONE 0x2
+#define FNIC_LS_REQ_ABORT_COMPLETED 0x4
+#define FNIC_STATUS_LS_REQ_ABORTED 0x1
+
+#define FNIC_LS_REQ_MIN_TMO_SECS (2)
+#define FNIC_LS_REQ_MAX_TMO_SECS (5)
+#define FNIC_NVME_ADMIN_IO_TIMEOUT 30000 /* mSec */
+#define FNIC_NVME_NO_FREE_TAG (0xFFFF)
+
+#define FNIC_LS_REQ_TMO_MSECS(tmo) (((tmo >= FNIC_LS_REQ_MIN_TMO_SECS) && \
+ (tmo <= FNIC_LS_REQ_MAX_TMO_SECS)) ? \
+ (tmo * 1000) : (FNIC_LS_REQ_MIN_TMO_SECS * 1000))
+
+#define IS_ADMIN_IO(_io_req) \
+ (NVME_CMD_FLAGS(_io_req) & FNIC_NVME_ADMIN_IO_TIMER_PENDING)
+
+extern unsigned int nvme_max_ios_to_process;
+extern unsigned int nvme_dev_loss_tmo;
+extern spinlock_t fnic_list_lock;
+
+enum nvfnic_lsreq_state_e {
+ FNIC_LS_REQ_CMD_INIT = 0,
+ FNIC_LS_REQ_CMD_PENDING,
+ FNIC_LS_REQ_CMD_ABTS_PENDING,
+ FNIC_LS_REQ_CMD_COMPLETE,
+ FNIC_LS_REQ_ABTS_COMPLETE,
+ FNIC_LS_REQ_CMD_ABTS_STARTED,
+};
+
+struct fnic_nvme_tag {
+ struct list_head free_list;
+ int tag_id;
+};
+
+struct nvfnic_ls_req {
+ struct list_head list;
+ struct nvmefc_ls_req *ls_req;
+ uint16_t oxid;
+ struct timer_list ls_req_timer;
+ struct fnic *fnic;
+ struct fnic_tport_s *tport;
+ int state;
+ unsigned int flags;
+};
+
+#if IS_ENABLED(CONFIG_NVME_FC)
+int nvfnic_nvme_io_done_handler(void *arg);
+struct fnic_io_req *nvfnic_find_io_req_by_tag(struct fnic *fnic, uint16_t tag);
+void nvfnic_reset_fcpio_tag_pool(struct fnic_iport_s *iport);
+int nvfnic_add_lport(struct fnic *fnic);
+void nvfnic_fcpio_abort(struct nvme_fc_local_port *lport,
+ struct nvme_fc_remote_port *rport,
+ void *hw_queue_handle, struct nvmefc_fcp_req *fcp_req);
+void nvfnic_remote_port_delete(struct nvme_fc_remote_port *rport);
+void nvfnic_local_port_delete(struct nvme_fc_local_port *lport);
+int nvfnic_dma_map_sgl(struct fnic *fnic, struct fnic_io_req *io_req,
+ int sg_count);
+void nvfnic_dma_unmap_sgl(struct fnic *fnic, struct fnic_io_req *io_req);
+int nvfnic_get_sg_count(struct fnic_io_req *io_req);
+void nvfnic_release_nvme_ioreq_buf(struct fnic_iport_s *iport,
+ struct fnic_io_req *io_req);
+void nvfnic_dump_nvcmd(struct fnic_io_req *io_req, uint8_t flags);
+bool _cleanup_tport_io(struct sbitmap *map, unsigned int tag, void *data);
+void nvfnic_flush_nvme_io_list(struct fnic *fnic);
+void nvfnic_fcpio_cmpl(struct fnic_io_req *io_req);
+bool nvfnic_transport_ready(struct fnic_iport_s *iport,
+ struct fnic_tport_s *tport);
+int nvfnic_alloc_fcpio_tag(struct fnic_iport_s *iport,
+ struct fnic_io_req *io_req);
+int nvfnic_queuecommand(struct fnic_io_req *io_req);
+void nvfnic_free_fcpio_tag(struct fnic_iport_s *iport,
+ struct fnic_io_req *io_req);
+void nvfnic_delete_lport(struct fnic_iport_s *iport);
+int nvfnic_add_tport(struct fnic *fnic, struct fnic_tport_s *tport,
+ unsigned long flags);
+void nvfnic_cleanup_all_nvme_ios(struct fnic *fnic);
+void nvfnic_delete_tport_work(struct work_struct *work);
+void nvfnic_delete_tport(struct fnic_iport_s *iport,
+ struct fnic_tport_s *tport, unsigned long flags);
+void nvfnic_fcpio_nvme_fast_cmpl_handler(struct fnic *fnic,
+ struct fcpio_fw_req *desc);
+void nvfnic_ls_rsp_recv(struct fnic_iport_s *iport,
+ struct fc_frame_header *fchdr, int len);
+void nvfnic_process_ls_abts_rsp(struct fnic_iport_s *iport,
+ struct fc_frame_header *fchdr);
+void nvfnic_admin_io_timeout(struct timer_list *t);
+void nvfnic_fcpio_nvme_itmf_cmpl_handler(struct fnic *fnic,
+ struct fcpio_fw_req *desc);
+void nvfnic_nvme_zero_devloss_tports(struct fnic *fnic);
+bool nvfnic_queue_abort_io_req(struct fnic *fnic, int tag, u32 task_req,
+ struct fnic_io_req *io_req);
+void nvfnic_ls_req_abort(struct nvme_fc_local_port *lport,
+ struct nvme_fc_remote_port *rport,
+ struct nvmefc_ls_req *lsreq);
+int nvfnic_create_queue(struct nvme_fc_local_port *lport, unsigned int idx,
+ u16 size, void **handle);
+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,
+ uint16_t oxid);
+void nvfnic_terminate_tport_ios(struct fnic *fnic, struct fnic_tport_s *tport);
+bool _terminate_tport_ios(struct sbitmap *map, unsigned int tag, void *data);
+bool _cleanup_all_nvme_io(struct sbitmap *map, unsigned int tag, void *data);
+void nvfnic_cleanup_all_nvme_ios(struct fnic *fnic);
+int nvfnic_fcpio_send(struct nvme_fc_local_port *lport,
+ struct nvme_fc_remote_port *rport, void *hw_queue_handle,
+ struct nvmefc_fcp_req *fcp_req);
+void nvfnic_fcpio_ersp_cmpl_handler(struct fnic *fnic,
+ struct fcpio_fw_req *desc, int sw_flag);
+void nvfnic_terminate_tport_ls_reqs(struct fnic *fnic,
+ struct fnic_tport_s *tport);
+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);
+void nvfnic_exch_reset(struct fnic_iport_s *iport, struct fnic_tport_s *tport);
+void nvfnic_nvme_iodone_work(struct work_struct *work);
+#else
+static inline int nvfnic_add_lport(struct fnic *fnic)
+{
+ return -EOPNOTSUPP;
+}
+
+static inline void nvfnic_nvme_unload(struct fnic *fnic)
+{
+}
+
+static inline void nvfnic_nvme_iodone_work(struct work_struct *work)
+{
+}
+
+static inline void nvfnic_exch_reset(struct fnic_iport_s *iport,
+ struct fnic_tport_s *tport)
+{
+}
+
+static inline void nvfnic_process_ls_abts_rsp(struct fnic_iport_s *iport,
+ struct fc_frame_header *fchdr)
+{
+}
+
+static inline void nvfnic_ls_rsp_recv(struct fnic_iport_s *iport,
+ struct fc_frame_header *fchdr, int len)
+{
+}
+
+static inline int nvfnic_add_tport(struct fnic *fnic,
+ struct fnic_tport_s *tport,
+ unsigned long flags)
+{
+ return 0;
+}
+
+static inline void nvfnic_delete_tport(struct fnic_iport_s *iport,
+ struct fnic_tport_s *tport,
+ unsigned long flags)
+{
+}
+
+static inline void nvfnic_cleanup_all_nvme_ios(struct fnic *fnic)
+{
+}
+
+static inline void nvfnic_fcpio_nvme_fast_cmpl_handler(struct fnic *fnic,
+ struct fcpio_fw_req *desc)
+{
+}
+
+static inline void nvfnic_fcpio_ersp_cmpl_handler(struct fnic *fnic,
+ struct fcpio_fw_req *desc,
+ int sw_flag)
+{
+}
+
+static inline void nvfnic_fcpio_nvme_itmf_cmpl_handler(struct fnic *fnic,
+ struct fcpio_fw_req *desc)
+{
+}
+
+static inline int nvfnic_get_nvmef_info(struct fnic *fnic,
+ struct fnic_nvmef_info *info)
+{
+ return 0;
+}
+#endif
+
+extern const char *fnic_fcpio_status_to_str(unsigned int status);
+#endif /* _FNIC_NVME_H */
diff --git a/drivers/scsi/fnic/fnic_res.h b/drivers/scsi/fnic/fnic_res.h
index 92a2fcfd3ea9..12a2a356dc13 100644
--- a/drivers/scsi/fnic/fnic_res.h
+++ b/drivers/scsi/fnic/fnic_res.h
@@ -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;
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 37d1e136b7b9..04ab384033b1 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -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])
diff --git a/drivers/scsi/fnic/vnic_devcmd.h b/drivers/scsi/fnic/vnic_devcmd.h
index f876d223b2b4..20878a3e9e26 100644
--- a/drivers/scsi/fnic/vnic_devcmd.h
+++ b/drivers/scsi/fnic/vnic_devcmd.h
@@ -430,7 +430,7 @@ struct vnic_devcmd_notify {
struct vnic_devcmd_provinfo {
u8 oui[3];
u8 type;
- u8 data[];
+ u8 data[0];
};
/*
--
2.47.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 07/13] scsi: fnic: Route completions and resets by initiator role
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
` (5 preceding siblings ...)
2026-06-24 4:43 ` [PATCH v5 06/13] scsi: fnic: Add the NVMe/FC transport path Karan Tilak Kumar
@ 2026-06-24 4:43 ` Karan Tilak Kumar
2026-06-24 5:11 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 08/13] scsi: fnic: Handle NVMe LS frames in FDLS Karan Tilak Kumar
` (5 subsequent siblings)
12 siblings, 1 reply; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, Karan Tilak Kumar, Hannes Reinecke
Dispatch 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.
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
---
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(-)
diff --git a/drivers/scsi/fnic/fnic_res.c b/drivers/scsi/fnic/fnic_res.c
index 18353fbb5f98..d75d7046c7f6 100644
--- a/drivers/scsi/fnic/fnic_res.c
+++ b/drivers/scsi/fnic/fnic_res.c
@@ -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;
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 04ab384033b1..9607684bc610 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -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;
--
2.47.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 08/13] scsi: fnic: Handle NVMe LS frames in FDLS
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
` (6 preceding siblings ...)
2026-06-24 4:43 ` [PATCH v5 07/13] scsi: fnic: Route completions and resets by initiator role Karan Tilak Kumar
@ 2026-06-24 4:43 ` Karan Tilak Kumar
2026-06-24 5:13 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 09/13] scsi: fnic: Send NVMe LS requests through FDLS Karan Tilak Kumar
` (4 subsequent siblings)
12 siblings, 1 reply; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, Karan Tilak Kumar, Hannes Reinecke
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.
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
---
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
---
drivers/scsi/fnic/fdls_disc.c | 39 +++++++++++++++++++++++++++++++++++
drivers/scsi/fnic/fnic_fcs.c | 34 +++++++++++++++++++++++-------
2 files changed, 66 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c
index e03256183ac6..f66c121cb712 100644
--- a/drivers/scsi/fnic/fdls_disc.c
+++ b/drivers/scsi/fnic/fdls_disc.c
@@ -387,10 +387,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 +1303,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 +1848,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 +2460,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 +2554,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 +2870,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 +4887,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 +5121,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;
diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index 94b7c150c08c..b00672ef8b00 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -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);
--
2.47.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 09/13] scsi: fnic: Send NVMe LS requests through FDLS
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
` (7 preceding siblings ...)
2026-06-24 4:43 ` [PATCH v5 08/13] scsi: fnic: Handle NVMe LS frames in FDLS Karan Tilak Kumar
@ 2026-06-24 4:43 ` Karan Tilak Kumar
2026-06-24 5:11 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 10/13] scsi: fnic: Abort timed-out NVMe LS requests Karan Tilak Kumar
` (3 subsequent siblings)
12 siblings, 1 reply; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, Karan Tilak Kumar, kernel test robot,
Hannes Reinecke
Add 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.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605280619.pmobiDWp-lkp@intel.com/
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
---
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(-)
diff --git a/drivers/scsi/fnic/fdls_fc.h b/drivers/scsi/fnic/fdls_fc.h
index a7b8b969f019..cdf84462dd37 100644
--- a/drivers/scsi/fnic/fdls_fc.h
+++ b/drivers/scsi/fnic/fdls_fc.h
@@ -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)
diff --git a/drivers/scsi/fnic/fnic_nvme.c b/drivers/scsi/fnic/fnic_nvme.c
index 8374464e4fcc..16e2f0add5ce 100644
--- a/drivers/scsi/fnic/fnic_nvme.c
+++ b/drivers/scsi/fnic/fnic_nvme.c
@@ -1306,6 +1306,129 @@ void nvfnic_ls_req_timeout(struct timer_list *t)
ls_req->done(ls_req, -ETIMEDOUT);
}
+/**
+ * nvfnic_ls_req_send - Send NVMe FC link service (LS) request
+ * @lport: Pointer to local NVMe FC port structure
+ * @rport: Pointer to remote NVMe FC port structure
+ * @ls_req: Pointer to the link service request structure
+ *
+ * This function is used to send link service (LS) commands to an NVMe
+ * Discovery Controller for discovery operations, as well as to regular
+ * NVMe subsystems during association. It encapsulates the logic for
+ * transmitting LS requests over the NVMe over Fabrics (NVMe-oF) FC
+ * transport.
+ *
+ * Returns: 0 on success, or a negative error code on failure.
+ */
+int nvfnic_ls_req_send(struct nvme_fc_local_port *lport,
+ struct nvme_fc_remote_port *rport,
+ struct nvmefc_ls_req *ls_req)
+{
+ int timeout;
+ uint8_t *frame;
+ uint8_t fcid[3];
+ unsigned long flags = 0;
+ struct fnic_iport_s *iport = lport->private;
+ uint8_t *ls_req_payload;
+ struct fnic *fnic = iport->fnic;
+ struct fc_frame_header *fchdr;
+ 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;
+ struct fnic_tport_s *tport;
+ int ret;
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
+
+ tport = (struct fnic_tport_s *)rport->private;
+ INIT_LIST_HEAD(&nvfnic_ls_req->list);
+
+ if (!nvfnic_transport_ready(iport, tport)) {
+ if (tport != NULL)
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "iport: 0x%x tport: 0x%x transport not ready\n",
+ iport->fcid, tport->fcid);
+ else
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "iport: 0x%x transport not ready\n",
+ iport->fcid);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return -ENOLINK;
+ }
+
+ 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;
+ }
+
+ if (fdls_alloc_oxid(iport, FNIC_FRAME_TYPE_NVME_LS,
+ &nvfnic_ls_req->oxid) == FNIC_UNASSIGNED_OXID) {
+ FNIC_FCS_DBG(KERN_INFO, fnic,
+ "0x%x: Failed to allocate OXID to send NVME LS REQ",
+ iport->fcid);
+ mempool_free(frame, fnic->frame_pool);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ return -EAGAIN;
+ }
+
+ timer_setup(&nvfnic_ls_req->ls_req_timer, nvfnic_ls_req_timeout,
+ 0UL);
+
+ nvfnic_ls_req->fnic = fnic;
+ nvfnic_ls_req->tport = tport;
+ nvfnic_ls_req->state = FNIC_LS_REQ_CMD_INIT;
+ nvfnic_ls_req->ls_req = ls_req;
+
+ fchdr = (struct fc_frame_header *)(frame + FNIC_ETH_FCOE_HDRS_OFFSET);
+ *fchdr = (struct fc_frame_header) {
+ .fh_r_ctl = FC_RCTL_ELS4_REQ,
+ .fh_type = FC_TYPE_NVME,
+ .fh_f_ctl = {FNIC_ELS_REQ_FCTL, 0, 0},
+ .fh_rx_id = cpu_to_be16(FNIC_UNASSIGNED_RXID)
+ };
+
+ hton24(fcid, iport->fcid);
+ FNIC_STD_SET_S_ID(*fchdr, fcid);
+
+ hton24(fcid, tport->fcid);
+ FNIC_STD_SET_D_ID(*fchdr, fcid);
+
+ FNIC_STD_SET_OX_ID(*fchdr, nvfnic_ls_req->oxid);
+
+ ls_req_payload = frame + FNIC_ETH_FCOE_HDRS_OFFSET + sizeof(*fchdr);
+ memcpy(ls_req_payload, ls_req->rqstaddr, ls_req->rqstlen);
+
+ FNIC_NVME_DBG(KERN_INFO, fnic,
+ "0x%x: NVME send ls req with oxid: 0x%x type: 0x%02x len: %d",
+ iport->fcid, nvfnic_ls_req->oxid, *((uint8_t *) ls_req->rqstaddr),
+ ls_req->rqstlen);
+
+ list_add_tail(&nvfnic_ls_req->list, &tport->ls_req_list);
+ nvfnic_ls_req->state = FNIC_LS_REQ_CMD_PENDING;
+
+ ret = fnic_send_fcoe_frame(iport, frame, frame_size);
+ if (ret) {
+ list_del(&nvfnic_ls_req->list);
+ fdls_free_oxid(iport, nvfnic_ls_req->oxid,
+ &nvfnic_ls_req->oxid);
+ nvfnic_ls_req->state = FNIC_LS_REQ_CMD_COMPLETE;
+ ls_req->private = NULL;
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+ mempool_free(frame, fnic->frame_pool);
+ return ret;
+ }
+
+ timeout = FNIC_LS_REQ_TMO_MSECS(ls_req->timeout);
+ mod_timer(&nvfnic_ls_req->ls_req_timer,
+ round_jiffies(jiffies + msecs_to_jiffies(timeout)));
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+
+ return 0;
+}
+
void nvfnic_local_port_delete(struct nvme_fc_local_port *lport)
{
struct fnic_iport_s *iport = (struct fnic_iport_s *) lport->private;
@@ -1606,7 +1729,7 @@ nvme_fc_port_template nvfnic_port = {
.remoteport_delete = nvfnic_remote_port_delete,
.create_queue = nvfnic_create_queue,
.delete_queue = NULL,
- .ls_req = NULL,
+ .ls_req = nvfnic_ls_req_send,
.ls_abort = nvfnic_ls_req_abort,
.fcp_io = nvfnic_fcpio_send,
.fcp_abort = nvfnic_fcpio_abort,
diff --git a/drivers/scsi/fnic/fnic_nvme.h b/drivers/scsi/fnic/fnic_nvme.h
index ab96b8d13931..ebdaf6930f8e 100644
--- a/drivers/scsi/fnic/fnic_nvme.h
+++ b/drivers/scsi/fnic/fnic_nvme.h
@@ -111,6 +111,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,
--
2.47.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 10/13] scsi: fnic: Abort timed-out NVMe LS requests
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
` (8 preceding siblings ...)
2026-06-24 4:43 ` [PATCH v5 09/13] scsi: fnic: Send NVMe LS requests through FDLS Karan Tilak Kumar
@ 2026-06-24 4:43 ` Karan Tilak Kumar
2026-06-24 5:13 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 11/13] scsi: fnic: Track NVMe transport statistics Karan Tilak Kumar
` (2 subsequent siblings)
12 siblings, 1 reply; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, Karan Tilak Kumar, Hannes Reinecke
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.
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
---
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
---
drivers/scsi/fnic/fdls_disc.c | 44 ++++++++++++++++++++++
drivers/scsi/fnic/fnic_fdls.h | 2 +
drivers/scsi/fnic/fnic_nvme.c | 70 ++++++++++++++++++++++++++++-------
3 files changed, 102 insertions(+), 14 deletions(-)
diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c
index f66c121cb712..d44b98e753d1 100644
--- a/drivers/scsi/fnic/fdls_disc.c
+++ b/drivers/scsi/fnic/fdls_disc.c
@@ -663,6 +663,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)
diff --git a/drivers/scsi/fnic/fnic_fdls.h b/drivers/scsi/fnic/fnic_fdls.h
index 0a68d0fb11b1..ce4b3aae77e3 100644
--- a/drivers/scsi/fnic/fnic_fdls.h
+++ b/drivers/scsi/fnic/fnic_fdls.h
@@ -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);
diff --git a/drivers/scsi/fnic/fnic_nvme.c b/drivers/scsi/fnic/fnic_nvme.c
index 16e2f0add5ce..c4de6606c0b2 100644
--- a/drivers/scsi/fnic/fnic_nvme.c
+++ b/drivers/scsi/fnic/fnic_nvme.c
@@ -24,6 +24,10 @@
#if IS_ENABLED(CONFIG_NVME_FC)
+static bool nvfnic_ls_req_cleanup(struct fnic_iport_s *iport,
+ struct nvmefc_ls_req *lsreq,
+ uint16_t oxid);
+
int nvfnic_get_sg_count(struct fnic_io_req *io_req)
{
return io_req->fcp_req->sg_cnt;
@@ -1248,6 +1252,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,
+ 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);
+ nvfnic_ls_req->state = FNIC_LS_REQ_CMD_COMPLETE;
+
+ return true;
+}
+
void nvfnic_ls_req_timeout(struct timer_list *t)
{
struct nvfnic_ls_req *nvfnic_ls_req = timer_container_of(nvfnic_ls_req,
@@ -1257,6 +1278,7 @@ void nvfnic_ls_req_timeout(struct timer_list *t)
struct fnic_iport_s *iport = &fnic->iport;
struct fnic_tport_s *tport = (struct fnic_tport_s *) nvfnic_ls_req->tport;
uint16_t oxid = nvfnic_ls_req->oxid;
+ int timeout;
FNIC_NVME_DBG(KERN_INFO, fnic,
"tport: 0x%x lsreq: 0x%x state: %d timeout\n",
@@ -1278,10 +1300,8 @@ void nvfnic_ls_req_timeout(struct timer_list *t)
"tport: 0x%x lsreq: 0x%x abort timeout\n",
tport->fcid, nvfnic_ls_req->oxid);
- list_del(&nvfnic_ls_req->list);
ls_req = nvfnic_ls_req->ls_req;
- fdls_free_oxid(iport, oxid, &nvfnic_ls_req->oxid);
- ls_req->private = NULL;
+ nvfnic_ls_req_cleanup(iport, ls_req, oxid);
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
ls_req->done(ls_req, -ETIMEDOUT);
return;
@@ -1290,6 +1310,19 @@ void nvfnic_ls_req_timeout(struct timer_list *t)
FNIC_NVME_DBG(KERN_ERR, fnic,
"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;
+ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
+
+ if (fdls_send_ls_req_abts(iport, tport, nvfnic_ls_req->oxid) == 0) {
+ timeout = FNIC_LS_REQ_TMO_MSECS(ls_req->timeout);
+ mod_timer(&nvfnic_ls_req->ls_req_timer,
+ round_jiffies(jiffies + msecs_to_jiffies(timeout)));
+ return;
+ }
+ FNIC_NVME_DBG(KERN_ERR, fnic,
+ "tport: 0x%x lsreq: 0x%x cannot send abort\n",
+ tport->fcid, oxid);
+ spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
}
if (ls_req->private == NULL) {
@@ -1297,10 +1330,8 @@ void nvfnic_ls_req_timeout(struct timer_list *t)
return;
}
- list_del(&nvfnic_ls_req->list);
ls_req = nvfnic_ls_req->ls_req;
- fdls_free_oxid(iport, oxid, &nvfnic_ls_req->oxid);
- ls_req->private = NULL;
+ nvfnic_ls_req_cleanup(iport, ls_req, oxid);
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
ls_req->done(ls_req, -ETIMEDOUT);
@@ -1411,11 +1442,7 @@ int nvfnic_ls_req_send(struct nvme_fc_local_port *lport,
ret = fnic_send_fcoe_frame(iport, frame, frame_size);
if (ret) {
- list_del(&nvfnic_ls_req->list);
- fdls_free_oxid(iport, nvfnic_ls_req->oxid,
- &nvfnic_ls_req->oxid);
- nvfnic_ls_req->state = FNIC_LS_REQ_CMD_COMPLETE;
- ls_req->private = NULL;
+ nvfnic_ls_req_cleanup(iport, ls_req, nvfnic_ls_req->oxid);
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
mempool_free(frame, fnic->frame_pool);
return ret;
@@ -1534,6 +1561,7 @@ void nvfnic_ls_req_abort(struct nvme_fc_local_port *lport,
struct nvfnic_ls_req *nvfnic_ls_req;
uint16_t oxid;
int timeout;
+ int ret;
spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
@@ -1592,10 +1620,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);
+ 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);
}
bool nvfnic_queue_abort_io_req(struct fnic *fnic, int tag,
--
2.47.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 11/13] scsi: fnic: Track NVMe transport statistics
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
` (9 preceding siblings ...)
2026-06-24 4:43 ` [PATCH v5 10/13] scsi: fnic: Abort timed-out NVMe LS requests Karan Tilak Kumar
@ 2026-06-24 4:43 ` Karan Tilak Kumar
2026-06-24 5:15 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 12/13] scsi: fnic: Expose NVMe transport state in debugfs Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 13/13] scsi: fnic: Bump up version number Karan Tilak Kumar
12 siblings, 1 reply; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, Karan Tilak Kumar, kernel test robot,
Hannes Reinecke
Add 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.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605280619.pmobiDWp-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202605280519.Jd4fmgAZ-lkp@intel.com/
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
---
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(-)
diff --git a/drivers/scsi/fnic/fnic_nvme.c b/drivers/scsi/fnic/fnic_nvme.c
index c4de6606c0b2..e322dd4dcb78 100644
--- a/drivers/scsi/fnic/fnic_nvme.c
+++ b/drivers/scsi/fnic/fnic_nvme.c
@@ -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,
@@ -353,7 +435,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;
}
@@ -379,6 +463,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;
@@ -403,6 +488,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);
@@ -471,6 +557,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));
}
@@ -491,7 +578,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)
@@ -509,6 +598,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;
@@ -539,6 +629,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);
@@ -631,6 +722,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;
@@ -642,6 +734,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);
}
@@ -664,7 +757,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);
@@ -685,6 +780,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);
@@ -702,6 +801,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);
@@ -730,6 +830,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,
@@ -741,11 +845,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;
}
@@ -771,6 +883,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;
@@ -779,6 +893,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);
@@ -951,9 +1071,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,
@@ -1083,12 +1208,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);
}
@@ -1103,6 +1231,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);
@@ -1130,8 +1259,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;
@@ -1166,6 +1299,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) {
@@ -1231,6 +1365,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;
@@ -1277,6 +1412,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;
@@ -1311,6 +1447,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);
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
if (fdls_send_ls_req_abts(iport, tport, nvfnic_ls_req->oxid) == 0) {
@@ -1363,6 +1500,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;
@@ -1405,6 +1543,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);
@@ -1437,6 +1576,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;
@@ -1559,6 +1703,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;
@@ -1620,6 +1765,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);
@@ -1645,6 +1791,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];
@@ -1660,12 +1807,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);
@@ -1682,9 +1835,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);
@@ -1700,6 +1857,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;
}
@@ -1747,7 +1913,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;
@@ -1800,6 +1983,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);
}
}
diff --git a/drivers/scsi/fnic/fnic_stats.h b/drivers/scsi/fnic/fnic_stats.h
index 8ddd20401a59..fc81e4a7e29e 100644
--- a/drivers/scsi/fnic/fnic_stats.h
+++ b/drivers/scsi/fnic/fnic_stats.h
@@ -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 {
--
2.47.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 12/13] scsi: fnic: Expose NVMe transport state in debugfs
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
` (10 preceding siblings ...)
2026-06-24 4:43 ` [PATCH v5 11/13] scsi: fnic: Track NVMe transport statistics Karan Tilak Kumar
@ 2026-06-24 4:43 ` Karan Tilak Kumar
2026-06-24 5:17 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 13/13] scsi: fnic: Bump up version number Karan Tilak Kumar
12 siblings, 1 reply; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, Karan Tilak Kumar, Hannes Reinecke
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.
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
---
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(+)
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 86293e112b34..507c22d21882 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -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);
diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
index 467fba29ea5f..61f167e20574 100644
--- a/drivers/scsi/fnic/fnic_debugfs.c
+++ b/drivers/scsi/fnic/fnic_debugfs.c
@@ -10,10 +10,19 @@
extern int fnic_get_debug_info(struct stats_debug_info *debug_buffer,
struct fnic *fnic);
+static int fnic_nvmef_debugfs_open(struct inode *inode,
+ struct file *file);
+static ssize_t fnic_nvmef_debugfs_read(struct file *file,
+ char __user *ubuf,
+ size_t nbytes, loff_t *pos);
+static int fnic_nvmef_debugfs_release(struct inode *inode,
+ struct file *file);
+
static struct dentry *fnic_trace_debugfs_root;
static struct dentry *fnic_trace_debugfs_file;
static struct dentry *fnic_trace_enable;
static struct dentry *fnic_stats_debugfs_root;
+static struct dentry *fnic_nvmef_debugfs_root;
static struct dentry *fnic_fc_trace_debugfs_file;
static struct dentry *fnic_fc_rdata_trace_debugfs_file;
@@ -46,6 +55,9 @@ int fnic_debugfs_init(void)
fnic_stats_debugfs_root = debugfs_create_dir("statistics",
fnic_trace_debugfs_root);
+ fnic_nvmef_debugfs_root = debugfs_create_dir("nvme_info",
+ fnic_trace_debugfs_root);
+
/* Allocate memory to structure */
fc_trc_flag = vmalloc(sizeof(struct fc_trace_flag_type));
@@ -70,6 +82,9 @@ int fnic_debugfs_init(void)
*/
void fnic_debugfs_terminate(void)
{
+ debugfs_remove(fnic_nvmef_debugfs_root);
+ fnic_nvmef_debugfs_root = NULL;
+
debugfs_remove(fnic_stats_debugfs_root);
fnic_stats_debugfs_root = NULL;
@@ -669,6 +684,13 @@ static const struct file_operations fnic_reset_debugfs_fops = {
.release = fnic_reset_stats_release,
};
+static const struct file_operations fnic_nvmef_debugfs_fops = {
+ .owner = THIS_MODULE,
+ .open = fnic_nvmef_debugfs_open,
+ .read = fnic_nvmef_debugfs_read,
+ .release = fnic_nvmef_debugfs_release,
+};
+
/*
* fnic_stats_init - Initialize stats struct and create stats file per fnic
*
@@ -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);
+ fnic->fnic_nvmef_debugfs_file = debugfs_create_file("nvmef_info",
+ S_IFREG | 0444,
+ fnic->fnic_nvmef_debugfs_host,
+ fnic,
+ &fnic_nvmef_debugfs_fops);
+}
+
+static int fnic_nvmef_debugfs_open(struct inode *inode, struct file *file)
+{
+
+ struct fnic *fnic = inode->i_private;
+ struct fnic_nvmef_info *info;
+ int buf_size = 2 * PAGE_SIZE;
+
+ info = kzalloc_obj(struct fnic_nvmef_info, GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+
+ info->info_buffer = vmalloc(buf_size);
+ if (!info->info_buffer) {
+ kfree(info);
+ return -ENOMEM;
+ }
+
+ info->buf_size = buf_size;
+ memset((void *)info->info_buffer, 0, buf_size);
+ info->buffer_len = nvfnic_get_nvmef_info(fnic, info);
+
+ file->private_data = info;
+
+ return 0;
+}
+
+static ssize_t fnic_nvmef_debugfs_read(struct file *file,
+ char __user *ubuf,
+ size_t nbytes, loff_t *pos)
+{
+ struct fnic_nvmef_info *info = file->private_data;
+
+ return simple_read_from_buffer(ubuf, nbytes, pos,
+ info->info_buffer, info->buffer_len);
+}
+
+static int fnic_nvmef_debugfs_release(struct inode *inode, struct file *file)
+{
+ struct fnic_nvmef_info *info = file->private_data;
+
+ vfree(info->info_buffer);
+ kfree(info);
+ return 0;
+}
+
+void fnic_nvmef_debugfs_remove(struct fnic *fnic)
+{
+ if (!fnic)
+ return;
+
+ debugfs_remove(fnic->fnic_nvmef_debugfs_file);
+ fnic->fnic_nvmef_debugfs_file = NULL;
+
+ debugfs_remove(fnic->fnic_nvmef_debugfs_host);
+ fnic->fnic_nvmef_debugfs_host = NULL;
+}
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index df8c8ebbc32b..245db1b992b5 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -933,6 +933,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);
@@ -1207,6 +1208,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:
@@ -1277,6 +1280,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);
/*
diff --git a/drivers/scsi/fnic/fnic_nvme.c b/drivers/scsi/fnic/fnic_nvme.c
index e322dd4dcb78..a19dd9cf76cf 100644
--- a/drivers/scsi/fnic/fnic_nvme.c
+++ b/drivers/scsi/fnic/fnic_nvme.c
@@ -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,
diff --git a/drivers/scsi/fnic/fnic_nvme.h b/drivers/scsi/fnic/fnic_nvme.h
index ebdaf6930f8e..62e2a3e68449 100644
--- a/drivers/scsi/fnic/fnic_nvme.h
+++ b/drivers/scsi/fnic/fnic_nvme.h
@@ -133,6 +133,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
diff --git a/drivers/scsi/fnic/fnic_stats.h b/drivers/scsi/fnic/fnic_stats.h
index fc81e4a7e29e..a3ddd7b55729 100644
--- a/drivers/scsi/fnic/fnic_stats.h
+++ b/drivers/scsi/fnic/fnic_stats.h
@@ -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_ */
--
2.47.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 13/13] scsi: fnic: Bump up version number
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
` (11 preceding siblings ...)
2026-06-24 4:43 ` [PATCH v5 12/13] scsi: fnic: Expose NVMe transport state in debugfs Karan Tilak Kumar
@ 2026-06-24 4:43 ` Karan Tilak Kumar
12 siblings, 0 replies; 24+ messages in thread
From: Karan Tilak Kumar @ 2026-06-24 4:43 UTC (permalink / raw)
To: sebaddel
Cc: arulponn, djhawar, gcboffa, mkai2, satishkh, aeasi, jejb,
martin.petersen, linux-scsi, linux-kernel, jmeneghi, revers,
adakopou, lduncan, Karan Tilak Kumar, Hannes Reinecke
Bump up version number to 1.9.0.0.
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Tested-by: Karan Tilak Kumar <kartilak@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
---
drivers/scsi/fnic/fnic.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 507c22d21882..c576a7f5083e 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -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: "
--
2.47.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH v5 01/13] scsi: fnic: Make debug logging protocol independent
2026-06-24 4:43 ` [PATCH v5 01/13] scsi: fnic: Make debug logging protocol independent Karan Tilak Kumar
@ 2026-06-24 5:08 ` sashiko-bot
0 siblings, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-06-24 5:08 UTC (permalink / raw)
To: Karan Tilak Kumar; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Shared struct member used as the flags argument in spin_lock_irqsave() causing IRQ state corruption.
- [High] Lockless modification of fnic_priv(sc)->flags after dropping wq_copy_lock leads to data races and potential Use-After-Free.
--
commit d6c65edf1de54a8d582352945f8226579f06a57d
Author: Karan Tilak Kumar <kartilak@cisco.com>
Subject: 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. Route FCP
messages through shost_printk() and NVMe messages through printk(). Convert
existing debug call sites to pass the fnic instance directly.
> diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
> index 063eb864a5cd0..ca592bc3f6182 100644
> --- a/drivers/scsi/fnic/fnic_fcs.c
> +++ b/drivers/scsi/fnic/fnic_fcs.c
> @@ -1014,7 +1014,7 @@ void fnic_delete_fcp_tports(struct fnic *fnic)
>
> spin_lock_irqsave(&fnic->fnic_lock, flags);
> list_for_each_entry_safe(tport, next, &fnic->iport.tport_list, links) {
> - FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
> + FNIC_FCS_DBG(KERN_INFO, 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);
[Severity: High]
This is a pre-existing issue, but can the call to fnic_del_tport_timer_sync()
corrupt the CPU's IRQ state here?
In fnic_delete_fcp_tports(), the lock is acquired using a local flags
variable:
spin_lock_irqsave(&fnic->fnic_lock, flags);
However, inside fnic_del_tport_timer_sync(), the lock is released and
reacquired using the shared fnic->lock_flags struct member:
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
timer_delete_sync(&tport->retry_timer);
spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
Would restoring the IRQ state from the uninitialized or stale fnic->lock_flags
leave interrupts incorrectly enabled or disabled? The same pattern also exists
in fnic_tport_event_handler() where it acquires the lock using a local flags
variable but later calls fdls_delete_tport().
[ ... ]
> diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
> index 6ee3c559e129c..0759540f66753 100644
> --- a/drivers/scsi/fnic/fnic_scsi.c
> +++ b/drivers/scsi/fnic/fnic_scsi.c
> @@ -1255,7 +1254,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde
> atomic64_inc(&fnic_stats->io_stats.ioreq_null);
> spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags);
> fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL;
> - shost_printk(KERN_ERR, fnic->host,
> + fnic_printk(KERN_ERR, fnic,
> "itmf_cmpl io_req is null - "
[Severity: High]
This is a pre-existing issue, but could this lockless modification cause a data
race or a use-after-free?
In fnic_fcpio_itmf_cmpl_handler(), fnic_priv(sc)->flags is modified
immediately after dropping the wq_copy_lock. If io_req is NULL, it indicates
the IO request has already been cleaned up. Once cleaned up, the block layer
may have already completed the SCSI command via scsi_done() and freed or
recycled the scsi_cmnd structure.
Is it possible that modifying the command's flags locklessly here will result
in memory corruption of a newly recycled or freed command? This pattern also
appears to exist in fnic_abort_cmd() and fnic_pending_aborts_iter().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624044334.3079-1-kartilak@cisco.com?part=1
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 02/13] scsi: fnic: Use fnic_num for non-SCSI identifiers
2026-06-24 4:43 ` [PATCH v5 02/13] scsi: fnic: Use fnic_num for non-SCSI identifiers Karan Tilak Kumar
@ 2026-06-24 5:11 ` sashiko-bot
0 siblings, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-06-24 5:11 UTC (permalink / raw)
To: Karan Tilak Kumar; +Cc: linux-scsi
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 events breaks event correlation for FCP initiators.
--
commit 899ac498b451c2fff04272de1bf2b696b5332d70
Author: Karan Tilak Kumar <kartilak@cisco.com>
scsi: fnic: Use fnic_num for non-SCSI identifiers
This commit updates the driver to use the fnic instance number for
NVMe-facing FDMI and debugfs entries, and for trace events. It aims to
reserve SCSI host numbers strictly for FCP initiator paths.
[ ... ]
> diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
> index 0759540f66753..b92260583c67b 100644
> --- a/drivers/scsi/fnic/fnic_scsi.c
> +++ b/drivers/scsi/fnic/fnic_scsi.c
> @@ -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]
Will this unconditional use of fnic_num break trace event correlation for
FCP initiators?
Other FCP-specific trace events continue to use the SCSI midlayer-allocated
host_no. By changing fnic_fcpio_ack_handler() to use fnic_num
unconditionally, a single FCP I/O sequence will interleave two different
identifier values in the trace buffer (e.g., host_no 2 vs fnic_num 0) on
systems with other SCSI controllers.
Should this trace call check IS_FNIC_FCP_INITIATOR(fnic) to log the host_no
for FCP traffic, similar to the debugfs and FDMI changes?
> ox_id_tag[4], ox_id_tag[5]);
> }
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624044334.3079-1-kartilak@cisco.com?part=2
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 09/13] scsi: fnic: Send NVMe LS requests through FDLS
2026-06-24 4:43 ` [PATCH v5 09/13] scsi: fnic: Send NVMe LS requests through FDLS Karan Tilak Kumar
@ 2026-06-24 5:11 ` sashiko-bot
0 siblings, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-06-24 5:11 UTC (permalink / raw)
To: Karan Tilak Kumar; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [Critical] A race condition between NVMe-FC LS request submission and abort paths allows mod_timer to be called on an uninitialized timer.
Pre-existing issues:
- [Critical] Using the shared struct member fnic->lock_flags for spin_lock_irqsave leads to IRQ flag corruption.
- [High] Missing synchronous timer cancellation in LS response processing leads to UAF in timer callback.
- [High] Dereferencing lsreq->private after dropping lock in nvfnic_ls_req_abort() causes UAF.
--
commit 6b90bcf4cce6c8a0c7e6c0e98d68dca9d9d15359
Author: Karan Tilak Kumar <kartilak@cisco.com>
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, arms request timers,
and registers the LS request callback in the NVMe FC port template.
Closes: https://lore.kernel.org/oe-kbuild-all/202605280619.pmobiDWp-lkp@intel.com/
> diff --git a/drivers/scsi/fnic/fnic_nvme.c b/drivers/scsi/fnic/fnic_nvme.c
> index 8374464e4fcc8..16e2f0add5ce6 100644
> --- a/drivers/scsi/fnic/fnic_nvme.c
> +++ b/drivers/scsi/fnic/fnic_nvme.c
> @@ -1306,6 +1306,129 @@ void nvfnic_ls_req_timeout(struct timer_list *t)
> ls_req->done(ls_req, -ETIMEDOUT);
> }
[Severity: Critical]
This is a pre-existing issue, but does nvfnic_ls_req_timeout() use the
shared struct member fnic->lock_flags for spin_lock_irqsave()?
If spin_lock_irqsave() saves the local IRQ state into a shared variable,
and multiple CPUs attempt to acquire the lock concurrently, won't they
overwrite fnic->lock_flags with their own IRQ state?
When releasing the lock, a CPU would restore the IRQ state written by
another CPU instead of its own, potentially leading to permanent IRQ
disablement and hard lockups.
[Severity: High]
This isn't a bug introduced by this patch, but is it possible for a
timeout and an LS response to race and cause a use-after-free here?
If a concurrent completion path like nvfnic_ls_rsp_recv() completes an
LS request using timer_delete() (which is not synchronous) and then calls
lsreq->done(), the NVMe FC transport will free the lsreq memory.
If nvfnic_ls_req_timeout() is executing concurrently on another CPU, won't
it acquire the lock and dereference the already freed lsreq memory?
> +
> +/**
> + * nvfnic_ls_req_send - Send NVMe FC link service (LS) request
[ ... ]
> + if (fdls_alloc_oxid(iport, FNIC_FRAME_TYPE_NVME_LS,
> + &nvfnic_ls_req->oxid) == FNIC_UNASSIGNED_OXID) {
> + FNIC_FCS_DBG(KERN_INFO, fnic,
> + "0x%x: Failed to allocate OXID to send NVME LS REQ",
> + iport->fcid);
> + mempool_free(frame, fnic->frame_pool);
> + spin_unlock_irqrestore(&fnic->fnic_lock, flags);
> + return -EAGAIN;
> + }
> +
> + timer_setup(&nvfnic_ls_req->ls_req_timer, nvfnic_ls_req_timeout,
> + 0UL);
[Severity: Critical]
Is there a race condition here between the LS request submission and the
abort path?
In the NVMe-FC midlayer, __nvme_fc_send_ls_req() adds the LS request to
rport->ls_req_list before calling the ls_req callback (nvfnic_ls_req_send).
If nvme_fc_abort_lsops() executes asynchronously right after the list
insertion but before nvfnic_ls_req_send() initializes the timer here,
will it invoke nvfnic_ls_req_abort() on a request where lsreq->private
is still purely zero-initialized memory?
If so, nvfnic_ls_req_abort() would unconditionally call mod_timer() on an
uninitialized timer, which could lead to a NULL pointer dereference or
timer wheel corruption.
> +
> + nvfnic_ls_req->fnic = fnic;
> + nvfnic_ls_req->tport = tport;
[ ... ]
> @@ -1606,7 +1729,7 @@ nvme_fc_port_template nvfnic_port = {
> .remoteport_delete = nvfnic_remote_port_delete,
> .create_queue = nvfnic_create_queue,
> .delete_queue = NULL,
> - .ls_req = NULL,
> + .ls_req = nvfnic_ls_req_send,
> .ls_abort = nvfnic_ls_req_abort,
[Severity: High]
This is a pre-existing issue, but does dropping the lock in
nvfnic_ls_req_abort() open a window for a use-after-free?
In nvfnic_ls_req_abort(), fnic->fnic_lock is dropped to safely call
timer_delete_sync(). During this unlocked window, if a concurrent
completion path calls lsreq->done(), the transport will free the lsreq
memory.
When timer_delete_sync() returns and nvfnic_ls_req_abort() reacquires the
lock, it executes nvfnic_ls_req = lsreq->private. Does this blindly
dereference the freed lsreq structure?
> .fcp_io = nvfnic_fcpio_send,
> .fcp_abort = nvfnic_fcpio_abort,
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624044334.3079-1-kartilak@cisco.com?part=9
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 07/13] scsi: fnic: Route completions and resets by initiator role
2026-06-24 4:43 ` [PATCH v5 07/13] scsi: fnic: Route completions and resets by initiator role Karan Tilak Kumar
@ 2026-06-24 5:11 ` sashiko-bot
0 siblings, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-06-24 5:11 UTC (permalink / raw)
To: Karan Tilak Kumar; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Asynchronous NVMe IO completion work queued during driver teardown executes after the fnic structure is freed, leading to a Use-After-Free.
Pre-existing issues:
- [Critical] The firmware reset completion handler calls `schedule_timeout()` from a hardirq context, leading to a "scheduling while atomic" kernel panic.
- [High] Using a shared struct member (`fnic->lock_flags`) to store IRQ state for `spin_lock_irqsave` violates locking semantics and can corrupt IRQ state across CPUs.
--
commit 0746859ac4c31fbfb285f20a291564287cfa0119
Author: Karan Tilak Kumar <kartilak@cisco.com>
scsi: fnic: Route completions and resets by initiator role
Dispatch 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.
[ ... ]
> diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
> index 04ab384033b19..9607684bc6107 100644
> --- a/drivers/scsi/fnic/fnic_scsi.c
> +++ b/drivers/scsi/fnic/fnic_scsi.c
[ ... ]
> @@ -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: Critical]
This is a pre-existing issue, but does calling fnic_cleanup_io() from a
hardware interrupt context trigger a "scheduling while atomic" panic?
If a hardware interrupt handler like fnic_isr_msix_wq_copy() processes
a FCPIO_RESET_CMPL event:
fnic_wq_copy_cmpl_handler() ->
fnic_fcpio_fw_reset_cmpl_handler() ->
fnic_cleanup_io() ->
schedule_timeout(msecs_to_jiffies(100))
Calling schedule_timeout() yields the CPU to the scheduler, which is
invalid from hardirq context. Will this crash the system upon firmware
reset completion?
> + 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);
[ ... ]
> @@ -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);
[Severity: High]
This is a pre-existing issue, but does calling these NVMe completion handlers
corrupt IRQ state across CPUs?
Looking at nvfnic_fcpio_nvme_fast_cmpl_handler() and
nvfnic_fcpio_ersp_cmpl_handler() in fnic_nvme.c, they both use a shared
structure member to save IRQ state:
spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
Because fnic->lock_flags is shared rather than a local stack variable,
concurrent threads acquiring the lock on different CPUs will overwrite
each other's saved IRQ states. When spin_unlock_irqrestore() is called,
the wrong IRQ state is restored.
> 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;
[ ... ]
> @@ -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: High]
Can this unconditional cleanup lead to a use-after-free during driver
teardown?
The fnic_remove() sequence calls nvfnic_nvme_unload() which flushes
fnic->nvme_io_cmpl_work. It then calls fnic_cleanup() which invokes this
handler:
fnic_remove()
nvfnic_nvme_unload()
flush_work(&fnic->nvme_io_cmpl_work);
fnic_cleanup()
fnic_wq_copy_cleanup_handler()
nvfnic_cleanup_all_nvme_ios()
io_req->done()
If there are uncompleted requests, nvfnic_cleanup_all_nvme_ios() will
forcibly complete them, and io_req->done() queues new async work referencing
&fnic->nvme_io_cmpl_work.
Since fnic_remove() then frees the fnic structure without another flush,
won't the asynchronously executing work item dereference the freed fnic
pointer?
> /* get the tag reference */
> fcpio_tag_id_dec(&desc->hdr.tag, &id);
> id &= FNIC_TAG_MASK;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624044334.3079-1-kartilak@cisco.com?part=7
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 06/13] scsi: fnic: Add the NVMe/FC transport path
2026-06-24 4:43 ` [PATCH v5 06/13] scsi: fnic: Add the NVMe/FC transport path Karan Tilak Kumar
@ 2026-06-24 5:12 ` sashiko-bot
0 siblings, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-06-24 5:12 UTC (permalink / raw)
To: Karan Tilak Kumar; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found 11 potential issue(s) to consider:
New issues:
- [Critical] Premature freeing of I/O tags during ABTS completion leads to tag reuse and data corruption.
- [High] Non-sync timer cancel in nvfnic_ls_rsp_recv leads to Use-After-Free of lsreq and fnic structures.
- [High] Asynchronous deletion timeouts cause Use-After-Free of tport and lport objects.
- [High] Missing cancellation of nvme_io_cmpl_work allows a work item to execute after the fnic structure is freed.
- [High] Leaked LS requests and active timers when remote port unregistration fails.
- [High] A failed abort request combined with a concurrent completion causes an I/O to hang forever.
- [High] Concurrent I/O completion causes Use-After-Free of fcp_req when _terminate_tport_ios drops the lock.
- [High] Accessing lsreq->private after dropping the lock in nvfnic_ls_req_abort causes Use-After-Free.
- [Medium] Uninitialized sgl_mapped state leads to unbalanced dma_unmap_single calls for zero-length NVMe requests.
- [Medium] Permanent reference leak of the PCI device (pdev->dev) during localport registration.
Pre-existing issues:
- [High] Dropping the spinlock inside list_for_each_entry_safe() permits concurrent list corruption.
--
commit 78a3171c3dafe1bc2912707cce47ec94e43860f3
Author: Karan Tilak Kumar <kartilak@cisco.com>
scsi: fnic: Add the NVMe/FC transport path
This patch introduces the NVMe/FC transport path for the fnic driver.
It includes local and remote port registration, I/O submission, tag
management, abort handling, and cleanup logic.
Closes: https://lore.kernel.org/oe-kbuild-all/202605280430.wTYAqI3A-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202605280619.pmobiDWp-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202605280519.Jd4fmgAZ-lkp@intel.com/
> diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
> index 0d7828be244da..df8c8ebbc32b9 100644
> --- a/drivers/scsi/fnic/fnic_main.c
> +++ b/drivers/scsi/fnic/fnic_main.c
[ ... ]
> @@ -1215,6 +1286,11 @@ static void fnic_remove(struct pci_dev *pdev)
> */
> fnic_cleanup(fnic);
>
> + if (IS_FNIC_NVME_INITIATOR(fnic)) {
> + sbitmap_free(&fnic->nvfnic_tag_map);
> + fnic_free_ioreq_tables_mq(fnic);
> + }
> +
> spin_lock_irqsave(&fnic_list_lock, flags);
> list_del(&fnic->list);
> spin_unlock_irqrestore(&fnic_list_lock, flags);
[Severity: High]
Does this code leave work items running after the fnic structure is freed?
Looking at fnic_remove(), we call fnic_cleanup(fnic) which drains the hardware
completion queues, potentially finding completions and queueing work items via
queue_work(fnic_cmpl_queue, &fnic->nvme_io_cmpl_work).
Since there is no cancel_work_sync() before kfree(fnic), could a re-queued
work item execute after the memory is freed and cause a use-after-free crash?
> diff --git a/drivers/scsi/fnic/fnic_nvme.c b/drivers/scsi/fnic/fnic_nvme.c
> new file mode 100644
> index 0000000000000..8374464e4fcc8
> --- /dev/null
> +++ b/drivers/scsi/fnic/fnic_nvme.c
[ ... ]
> +void nvfnic_dma_unmap_sgl(struct fnic *fnic, struct fnic_io_req *io_req)
> +{
> + if (io_req->sgl_mapped) {
> + dma_unmap_single(&fnic->pdev->dev, io_req->sgl_list_pa,
> + sizeof(io_req->sgl_list[0]) * io_req->sgl_cnt,
> + DMA_TO_DEVICE);
> + io_req->sgl_mapped = 0;
> + io_req->sgl_list_pa = 0;
> + }
> +}
[Severity: Medium]
Could this lead to an unbalanced DMA unmap?
In nvfnic_fcpio_send(), io_req->sgl_mapped is not explicitly zeroed during
initialization:
nvfnic_fcpio_send() {
...
io_req->sgl_list_pa = 0;
io_req->wq = hw_queue_handle;
...
}
If a previous I/O set sgl_mapped to 1, and the current I/O has zero length,
the mapping step is skipped but sgl_mapped might still be 1. Will this cause
nvfnic_dma_unmap_sgl() to unmap a 0 address with 0 length?
[ ... ]
> +void nvfnic_fcpio_nvme_fast_cmpl_handler(struct fnic *fnic,
> + struct fcpio_fw_req *desc)
> +{
> + u8 type;
> + u8 hdr_status;
> + struct fcpio_tag ftag;
> + u32 id;
> + struct fnic_io_req *io_req;
[ ... ]
> + fcpio_header_dec(&desc->hdr, &type, &hdr_status, &ftag);
> + fcpio_tag_id_dec(&ftag, &id);
> + tag = id & FNIC_TAG_MASK;
> +
> + if (tag >= fnic->fnic_max_tag_id) {
> + FNIC_NVME_DBG(KERN_ERR, fnic,
> + "Tag out of range tag: 0x%x hdr status: %s\n", tag,
> + fnic_fcpio_status_to_str(hdr_status));
> + return;
> + }
> + spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
> +
> + io_req = nvfnic_find_io_req_by_tag(fnic, tag);
> +
> + WARN_ON_ONCE(!io_req);
> + if (!io_req) {
[ ... ]
> + /* firmware completed the io */
> + io_req->io_completed = 1;
> + 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;
> + if (hdr_status == FCPIO_ABORTED)
> + io_req->cmd_flags |= FNIC_IO_ABORTED;
> + spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
> +
> + FNIC_NVME_DBG(KERN_INFO, fnic,
> + "icmnd abts hdr:%d %s tag:0x%x io:%p",
> + hdr_status, fnic_fcpio_status_to_str(hdr_status),
> + id, io_req);
> + return;
> + }
[Severity: High]
Could an I/O hang indefinitely here if the abort request fails to queue?
When aborting an I/O, nvfnic_fcpio_abort() sets the state to
FNIC_IOREQ_ABTS_PENDING and drops the lock. If a hardware completion arrives
during this window, nvfnic_fcpio_nvme_fast_cmpl_handler() observes
ABTS_PENDING and intentionally drops the completion.
If the subsequent nvfnic_queue_abort_io_req() call fails, the state is
reverted back to FNIC_IOREQ_CMD_PENDING. Because the completion was
permanently discarded and the hardware was not told to abort, does this
leave the I/O hanging forever?
[ ... ]
> +void nvfnic_fcpio_nvme_itmf_cmpl_handler(struct fnic *fnic,
> + struct fcpio_fw_req *desc)
> +{
> + u8 type;
> + u8 hdr_status;
[ ... ]
> + /* If the status is IO not found consider it as success.
> + * NVME sends abort even if rport is down in which case
> + * we will get FCPIO_TIMEOUT. Consider this as success.
> + */
> + if ((hdr_status == FCPIO_IO_NOT_FOUND) ||
> + (hdr_status == FCPIO_TIMEOUT) ||
> + (hdr_status == FCPIO_ITMF_REJECTED))
> + io_req->abts_state = FCPIO_SUCCESS;
> +
> + io_req->cmd_flags |= FNIC_IO_ABT_TERM_DONE;
> +
> +
> + io_req->fcp_req->transferred_length = 0;
> + io_req->fcp_req->rcv_rsplen = 0;
> + if (io_req->abts_state == FCPIO_SUCCESS)
> + io_req->fcp_req->status = NVME_SC_ABORT_REQ;
> + else
> + io_req->fcp_req->status = NVME_SC_INTERNAL;
> +
> + nvfnic_release_nvme_ioreq_buf(iport, io_req);
> + if (io_req->done)
> + io_req->done(io_req);
> + spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
> +}
[Severity: Critical]
Does this allow a tag to be reused before the hardware has actually completed
the original request, potentially corrupting a new I/O?
When an ITMF (abort) completion times out (FCPIO_TIMEOUT), the tag is
forcefully freed via io_req->done() and can be reallocated to a new request.
Since the driver matches completions only by the tag without a generation
count, if the late completion for the original I/O arrives, will
nvfnic_fcpio_nvme_fast_cmpl_handler() match it to the new request and
prematurely complete it with stale data?
[ ... ]
> +bool _terminate_tport_ios(struct sbitmap *map, unsigned int tag,
> + void *data)
> +{
> + struct fnic_tport_s *tport = data;
> + struct fnic_iport_s *iport = tport->iport;
> + struct fnic *fnic = iport->fnic;
> + struct fnic_io_req *io_req;
> + struct nvmefc_fcp_req *fcp_req = NULL;
> + struct nvme_fc_local_port *lport = iport->nv_lport;
> + struct nvme_fc_remote_port *rport = tport->nv_rport;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&fnic->fnic_lock, flags);
> + io_req = fnic->sw_copy_wq[0].io_req_table[tag];
> + if (!io_req) {
> + spin_unlock_irqrestore(&fnic->fnic_lock, flags);
> + return true;
> + }
> +
> + if (io_req->tport != tport) {
> + spin_unlock_irqrestore(&fnic->fnic_lock, flags);
> + return true;
> + }
> +
> + FNIC_NVME_DBG(KERN_INFO, fnic,
> + "Terminate tag: 0x%x (tport fcid 0x%x)\n",
> + io_req->tag, io_req->tport->fcid);
> + fcp_req = io_req->fcp_req;
> + spin_unlock_irqrestore(&fnic->fnic_lock, flags);
> +
> + nvfnic_fcpio_abort(lport, rport, NULL, fcp_req);
> + return true;
> +}
[Severity: High]
Can fcp_req be accessed after it has been freed?
Here, fcp_req is extracted from io_req under the lock. The lock is then dropped
without modifying io_req->cmd_state. During this unlocked window, a concurrent
hardware completion could run, process the I/O, invoke io_req->done(), and
return the request to the midlayer, which might free or reuse fcp_req.
When nvfnic_fcpio_abort() is subsequently called, could it dereference the
now-freed fcp_req structure?
[ ... ]
> +void nvfnic_nvme_zero_devloss_tports(struct fnic *fnic)
> +{
> + struct fnic_tport_s *tport, *next;
> +
> + spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
> + list_for_each_entry_safe(tport, next, &fnic->iport.tport_list, links) {
> + if (tport->flags & FNIC_FDLS_NVME_REGISTERED) {
> + spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
> + nvme_fc_set_remoteport_devloss(tport->nv_rport, 0);
> + spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
> + }
> + }
> + spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
> +}
[Severity: High]
This is a pre-existing issue, but dropping the lock inside
list_for_each_entry_safe() allows concurrent list corruption.
list_for_each_entry_safe() protects against deletion of the *current* entry
by caching the 'next' pointer. However, while the fnic_lock is dropped,
concurrent threads can remove and free the cached 'next' entry from the list.
When the loop resumes and accesses 'next', does this result in a
use-after-free? This pattern also exists in fnic_delete_fcp_tports().
[ ... ]
> +void nvfnic_ls_rsp_recv(struct fnic_iport_s *iport,
> + struct fc_frame_header *fchdr, int len)
> +{
> + uint8_t *fcid;
[ ... ]
> + nvfnic_ls_req->state = FNIC_LS_REQ_CMD_COMPLETE;
> +
> + list_del_init(&nvfnic_ls_req->list);
> + lsreq->private = NULL;
> + fdls_free_oxid(iport, oxid, &nvfnic_ls_req->oxid);
> + timer_delete(&nvfnic_ls_req->ls_req_timer);
> +
> + if (status == 0) {
> + FNIC_NVME_DBG(KERN_DEBUG, fnic,
> + "tport:0x%x lsreq:0x%x completed\n",
> + tport_fcid, oxid);
> +
> + /* Copy the Response */
> + memcpy(lsreq->rspaddr, (uint8_t *)fchdr + sizeof(*fchdr),
> + rsp_len);
> + }
> +
> + spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
> + lsreq->done(lsreq, status);
> + spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
> +}
[Severity: High]
Could the timer callback race with lsreq->done() and cause a use-after-free?
Because timer_delete() is used instead of timer_delete_sync(), the timer
callback might be concurrently executing on another CPU spinning on fnic_lock.
When the lock is dropped here, lsreq->done() is called, returning ownership
to the NVMe FC midlayer which frees lsreq.
Once the lock is released, won't the spinning timer callback wake up and
dereference the freed lsreq memory?
[ ... ]
> +void nvfnic_ls_req_abort(struct nvme_fc_local_port *lport,
> + struct nvme_fc_remote_port *rport,
> + struct nvmefc_ls_req *lsreq)
> +{
> + struct fnic_iport_s *iport = lport->private;
> + struct fnic *fnic = iport->fnic;
> + struct fnic_tport_s *tport;
> + struct nvfnic_ls_req *nvfnic_ls_req;
> + uint16_t oxid;
> + int timeout;
> +
> + spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
[ ... ]
> + nvfnic_ls_req->state = FNIC_LS_REQ_CMD_ABTS_STARTED;
> + spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
> + timer_delete_sync(&nvfnic_ls_req->ls_req_timer);
> +
> + spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
> + nvfnic_ls_req = lsreq->private;
> +
> + if ((nvfnic_ls_req == NULL) ||
> + (nvfnic_ls_req->state == FNIC_LS_REQ_CMD_ABTS_PENDING)) {
[Severity: High]
Does this dereference lsreq->private after the lock is reacquired, when lsreq
might already be freed?
The fnic_lock is dropped to call timer_delete_sync(). During this window,
nvfnic_terminate_tport_ls_reqs() could process the request and invoke
lsreq->done(), returning it to the midlayer which then frees it.
When the lock is reacquired, nvfnic_ls_req = lsreq->private accesses the freed
lsreq memory. Can this result in a use-after-free crash?
[ ... ]
> +void nvfnic_delete_tport(struct fnic_iport_s *iport,
> + struct fnic_tport_s *tport,
> + unsigned long flags)
> +{
> + struct fnic *fnic = iport->fnic;
> + int ret;
> + unsigned int time_wait = FNIC_NVME_TPORT_REMOVE_WAIT;
> + unsigned int time_remain;
> + DECLARE_COMPLETION_ONSTACK(tm_done);
> + unsigned int fcid;
> + int count = 0;
> +
> + if (!tport)
> + return;
> +
> + fcid = tport->fcid;
> + fdls_set_tport_state(tport, FDLS_TGT_STATE_OFFLINE);
> +
> + FNIC_NVME_DBG(KERN_DEBUG, fnic,
> + "0x%x: scheduled deletion for tport: 0x%x\n",
> + iport->fcid, tport->fcid);
> +
> + 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;
> +
> + tport->flags |= FNIC_FDLS_TPORT_DELETED;
> + spin_unlock_irqrestore(&fnic->fnic_lock, flags);
> + ret = nvme_fc_unregister_remoteport(tport->nv_rport);
> + if (ret) {
> + FNIC_NVME_DBG(KERN_ERR, fnic,
> + "tport: 0x%x unregister failed %d\n",
> + tport->fcid, ret);
> + spin_lock_irqsave(&fnic->fnic_lock, flags);
> + tport->tport_del_done = NULL;
> + list_del(&tport->links);
> + kfree(tport);
> + return;
> + }
[Severity: High]
Does this leak pending LS requests and leave their timers active?
If nvme_fc_unregister_remoteport() fails, kfree(tport) is called directly.
This bypasses nvfnic_terminate_tport_ls_reqs(), which leaks all nvfnic_ls_req
structures left on tport->ls_req_list.
Since their timers are never stopped, won't nvfnic_ls_req_timeout()
eventually fire and access the freed tport structure?
> + time_remain = wait_for_completion_timeout(tport->tport_del_done,
> + msecs_to_jiffies(time_wait));
> +
> + FNIC_NVME_DBG(KERN_DEBUG, fnic,
> + "tport: 0x%x wait for deletion done\n",
> + tport->fcid);
> +
> + spin_lock_irqsave(&fnic->fnic_lock, flags);
> + tport->tport_del_done = NULL;
> +
> + if (!time_remain) {
> + FNIC_NVME_DBG(KERN_ERR, fnic,
> + "tport: 0x%x nvme midlayer completion timed out\n",
> + tport->fcid);
> +
> + spin_unlock_irqrestore(&fnic->fnic_lock, flags);
> + nvfnic_cleanup_tport_io(fnic, tport);
> + spin_lock_irqsave(&fnic->fnic_lock, flags);
> + tport->flags &= ~FNIC_FDLS_NVME_TPORT_CLEANUP_PENDING;
> + list_del(&tport->links);
> + kfree(tport);
[Severity: High]
If this timeout expires, will the NVMe FC midlayer still call the
remoteport_delete callback and cause a use-after-free?
When the timeout expires, the driver forcefully calls kfree(tport). However,
the NVMe FC midlayer retains pointers to these structures and will eventually
execute the asynchronous remoteport_delete callback.
When nvfnic_remote_port_delete() is called later, it dereferences
rport->private. Since tport was already freed here, does this lead to a
use-after-free crash?
[ ... ]
> +int nvfnic_add_lport(struct fnic *fnic)
> +{
> + struct nvme_fc_port_info pinfo;
> + struct fnic_iport_s *iport = &fnic->iport;
> + int ret = 0;
[ ... ]
> + ret = nvme_fc_register_localport(&pinfo, iport->nv_tmpl,
> + get_device(&fnic->pdev->dev),
> + &iport->nv_lport);
> + if (ret) {
> + FNIC_NVME_DBG(KERN_ERR, fnic,
> + "Failed to add wwpn: 0x%llx ret: %d\n",
> + iport->wwpn, ret);
> + kfree(iport->nv_tmpl);
> + return ret;
> + }
[Severity: Medium]
Does this create a permanent reference leak of the PCI device?
The get_device(&fnic->pdev->dev) call takes a reference that is passed to
the NVMe FC midlayer, which internally takes its own reference when registering
the localport and puts it upon unregistration.
Because this driver-level get_device() is never balanced with a put_device()
call by fnic, will this leak prevent PCI device teardown or hot-unplug?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624044334.3079-1-kartilak@cisco.com?part=6
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 08/13] scsi: fnic: Handle NVMe LS frames in FDLS
2026-06-24 4:43 ` [PATCH v5 08/13] scsi: fnic: Handle NVMe LS frames in FDLS Karan Tilak Kumar
@ 2026-06-24 5:13 ` sashiko-bot
0 siblings, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-06-24 5:13 UTC (permalink / raw)
To: Karan Tilak Kumar; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [High] Using non-synchronous cancel_delayed_work() in fdls_reset_oxid_pool() allows concurrent lockless execution of the retry worker, leading to state corruption and OXID double-allocations.
- [High] Mismatched lock/unlock flags cause IRQ state corruption when acquiring fnic_lock with local flags and releasing it with the stale global fnic->lock_flags.
- [High] Using non-sync timer_delete() in nvfnic_ls_rsp_recv() causes a UAF in the timer callback.
Pre-existing issues:
- [High] Dropping a lock inside list_for_each_entry_safe() allows concurrent deletion of the 'next' pointer.
- [High] Module unload/teardown sequence fails to synchronously cancel the oxid_pool delayed works, leading to a UAF crash.
--
commit 04dceb559b15b01cb194adfb5c26b4d828e90ace
Author: Karan Tilak Kumar <kartilak@cisco.com>
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.
> diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c
> --- a/drivers/scsi/fnic/fdls_disc.c
> +++ b/drivers/scsi/fnic/fdls_disc.c
[ ... ]
> @@ -387,10 +387,25 @@ static bool fdls_is_oxid_tgt_req(uint16_t oxid)
>
> 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);
[Severity: High]
Can this race with the lockless retry worker? fdls_reset_oxid_pool() uses
non-synchronous cancel_delayed_work() and immediately clears the bitmaps.
If fdls_schedule_oxid_free_retry_work() is traversing
pending_schedule_free locklessly on another CPU, could it read a set bit
just before the reset clears the bitmap, allocate memory, and block on
fnic_lock?
Once the reset finishes and unlocks, the worker might inject a stale
reclaim entry into the now empty list and schedule oxid_reclaim_work. When
the reclaim work fires, could it clear a bit in oxid_pool->bitmap that may
have been reallocated to a new active I/O request, causing an OXID
collision?
[Severity: High]
This is a pre-existing issue, but does the module unload/teardown sequence
fail to synchronously cancel these oxid_pool delayed works?
If fnic_remove() initiates driver teardown and frees the fnic struct without
calling cancel_delayed_work_sync(), flush_workqueue(fnic_event_queue) won't
synchronize them because they are queued on the system workqueue. Could
fdls_reclaim_oxid_handler() execute after the fnic structure is freed,
causing a use-after-free crash?
> oxid_pool->next_idx = 0;
> }
[ ... ]
> @@ -1288,6 +1303,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);
> }
[Severity: High]
This is a pre-existing issue, but does dropping fnic_lock here allow
concurrent modification of the tport_list?
When fnic_fdls_link_down() iterates over tport_list using
list_for_each_entry_safe(), it caches the next pointer. Since
fdls_delete_tport() unlocks the list briefly, could another context
process a concurrent event and delete the cached next entry?
If the cached next entry is freed while the lock is dropped, won't the
loop dereference a freed pointer when it continues?
[Severity: High]
Does this sequence corrupt the hardware IRQ masking state?
When callers like fdls_tport_timer_callback() or fnic_tport_event_handler()
acquire the fnic_lock using a local flags variable:
spin_lock_irqsave(&fnic->fnic_lock, flags);
and then invoke helpers like fdls_delete_tport() or
nvfnic_process_ls_abts_rsp() which temporarily drop and reacquire the lock
using the struct member fnic->lock_flags:
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
Because fnic->lock_flags was never initialized by the original caller, does
it restore an arbitrary stale IRQ state? Reacquiring the lock then overwrites
fnic->lock_flags, causing the caller to unlock with the original local flags
and severely corrupt the IRQ state.
[ ... ]
> diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
> --- a/drivers/scsi/fnic/fnic_fcs.c
> +++ b/drivers/scsi/fnic/fnic_fcs.c
[ ... ]
> @@ -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);
[Severity: High]
Does calling nvfnic_ls_rsp_recv() here introduce a use-after-free risk
in its timer callback?
Inside nvfnic_ls_rsp_recv(), it executes with fnic_lock held and invokes
timer_delete(&nvfnic_ls_req->ls_req_timer) without synchronization. If the
timer callback nvfnic_ls_req_timeout() is concurrently executing on another
CPU, it will spin-wait on fnic_lock.
nvfnic_ls_rsp_recv() then drops the lock and calls lsreq->done(), which
commonly causes the transport layer to free the request and its private
payload. Once the lock is dropped, will the spinning timer callback unblock,
acquire the lock, and inspect the now-freed nvfnic_ls_req memory?
> + } else {
> + fnic_fdls_recv_frame(&fnic->iport, cur_frame->fp,
> + cur_frame->frame_len, fchdr_offset);
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624044334.3079-1-kartilak@cisco.com?part=8
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 10/13] scsi: fnic: Abort timed-out NVMe LS requests
2026-06-24 4:43 ` [PATCH v5 10/13] scsi: fnic: Abort timed-out NVMe LS requests Karan Tilak Kumar
@ 2026-06-24 5:13 ` sashiko-bot
0 siblings, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-06-24 5:13 UTC (permalink / raw)
To: Karan Tilak Kumar; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Critical] Data Race / List Corruption and Use-After-Free due to incorrectly dropping fnic_lock before sending ABTS.
Pre-existing issues:
- [High] Use-After-Free in the timer callback due to missing timer_delete_sync() before freeing memory.
--
commit da372c5b4e5660f32542c6cb182b777f4f2e3531
Author: Karan Tilak Kumar <kartilak@cisco.com>
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.
> diff --git a/drivers/scsi/fnic/fnic_nvme.c b/drivers/scsi/fnic/fnic_nvme.c
> index 16e2f0add5ce6..c4de6606c0b2f 100644
> --- a/drivers/scsi/fnic/fnic_nvme.c
> +++ b/drivers/scsi/fnic/fnic_nvme.c
[ ... ]
> @@ -1248,6 +1252,23 @@ void nvfnic_ls_rsp_recv(struct fnic_iport_s *iport,
> spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
> }
[Severity: High]
This isn't a bug introduced by this patch, but does the timer cancellation in
nvfnic_ls_rsp_recv() have a use-after-free race with the timer callback?
In nvfnic_ls_rsp_recv(), the code calls the non-synchronous timer_delete():
timer_delete(&nvfnic_ls_req->ls_req_timer);
...
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
lsreq->done(lsreq, status);
Because timer_delete() doesn't wait for the timer callback to finish on other
CPUs, if nvfnic_ls_req_timeout() is concurrently executing and spinning to
acquire fnic_lock, couldn't the lock be dropped here, allowing lsreq->done()
to immediately free the memory, while the timer callback proceeds to access it?
[ ... ]
> @@ -1290,6 +1310,19 @@ void nvfnic_ls_req_timeout(struct timer_list *t)
> FNIC_NVME_DBG(KERN_ERR, fnic,
> "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;
> + spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
> +
> + if (fdls_send_ls_req_abts(iport, tport, nvfnic_ls_req->oxid) == 0) {
[Severity: Critical]
Does dropping fnic_lock here before calling fdls_send_ls_req_abts() expose the
driver to list corruption?
fdls_send_ls_req_abts() calls fnic_send_fcoe_frame(), which eventually calls
fdls_send_fcoe_frame(). That function appears to perform a lockless
list_add_tail(&frame_elem->links, &fnic->tx_queue), relying on the caller
to hold fnic_lock.
Additionally, does dropping the lock here expose the tport pointer to
concurrent deletion, potentially causing a use-after-free?
> + timeout = FNIC_LS_REQ_TMO_MSECS(ls_req->timeout);
> + mod_timer(&nvfnic_ls_req->ls_req_timer,
> + round_jiffies(jiffies + msecs_to_jiffies(timeout)));
> + return;
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624044334.3079-1-kartilak@cisco.com?part=10
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 11/13] scsi: fnic: Track NVMe transport statistics
2026-06-24 4:43 ` [PATCH v5 11/13] scsi: fnic: Track NVMe transport statistics Karan Tilak Kumar
@ 2026-06-24 5:15 ` sashiko-bot
0 siblings, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-06-24 5:15 UTC (permalink / raw)
To: Karan Tilak Kumar; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
New issues:
- [Medium] Concurrent completions can underflow `io_cmpl_skip`, permanently breaking `io_completions` counting
- [Medium] Unlocked read-modify-write race corrupting max statistics counters
- [Medium] The `active_fw_reqs` gauge is incremented but never decremented in NVMe completion paths
- [Low] Several newly added NVMe wait-queue statistics counters are dead code and never updated
Pre-existing issues:
- [High] Use-After-Free accessing IO request memory after hardware submission
- [High] Use-After-Free due to non-sync timer_delete() on NVMe LS requests
--
commit 4e8ddd73c76a57b49825d3889a5531eb4520f10a
Author: Karan Tilak Kumar <kartilak@cisco.com>
scsi: fnic: Track NVMe transport statistics
Add counters for NVMe requests, responses, LS handling, aborts, and
wait-queue activity.
Link: https://lore.kernel.org/oe-kbuild-all/202605280619.pmobiDWp-lkp@intel.com/
Link: https://lore.kernel.org/oe-kbuild-all/202605280519.Jd4fmgAZ-lkp@intel.com/
> diff --git a/drivers/scsi/fnic/fnic_nvme.c b/drivers/scsi/fnic/fnic_nvme.c
> index c4de6606c0b2f..e322dd4dcb787 100644
> --- a/drivers/scsi/fnic/fnic_nvme.c
> +++ b/drivers/scsi/fnic/fnic_nvme.c
> @@ -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)
> +{
[ ... ]
> +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);
[Severity: Medium]
Could concurrent completions underflow io_cmpl_skip?
If multiple threads process completions concurrently in
nvfnic_update_cmpl_stats(), they can both read a positive value and
decrement the counter, causing it to fall below zero.
Because atomic64_read() evaluates to true for negative values, all
subsequent completions would continue to decrement io_cmpl_skip indefinitely.
Will io_completions ever be incremented again if this happens?
[ ... ]
> @@ -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);
[Severity: Medium]
Does active_fw_reqs ever get decremented?
This gauge is incremented here in nvfnic_queue_wq_nvme_copy_desc() and
also in nvfnic_queue_abort_io_req(), but there do not appear to be any
corresponding atomic64_dec() calls added to the NVMe completion handlers.
If it is never decremented when requests complete, will it act as a
monotonically increasing counter rather than a gauge of in-flight requests?
> + 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));
[Severity: Medium]
Can this read-modify-write pattern corrupt the maximum statistic?
If active_fw_reqs drops between the first conditional check and the second
atomic64_read() inside atomic64_set(), max_fw_reqs could be set to a
lower value than the one that triggered the condition.
Could this cause the maximum statistic to shrink over time under high
concurrency?
>
> spin_unlock_irqrestore(&fnic->wq_copy_lock[idx], intr_flags);
> return 0;
[ ... ]
> @@ -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;
[Severity: High]
This isn't a bug introduced by this patch, but is there a use-after-free
risk here?
In nvfnic_queuecommand(), the IO request is submitted to the hardware via
nvfnic_queue_wq_nvme_copy_desc(). Once the doorbell is written, the hardware
can execute the NVMe command and post a completion immediately.
If the thread executing nvfnic_queuecommand() is preempted after submitting
the request, the completion handler could process the completion and free
the fcp_req memory. When the preempted thread resumes, it writes to
io_req->cmd_flags and reads from cmdiu->sqe.rw.slba:
io_req->cmd_flags |= FNIC_IO_ISSUED;
out:
lba = (char *)&cmdiu->sqe.rw.slba;
Should all local state modifications and tracing be performed before the
hardware submission?
[ ... ]
> @@ -1231,6 +1365,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;
[Severity: High]
This is a pre-existing issue, but does the timer cancellation create a
use-after-free risk in nvfnic_ls_rsp_recv()?
When timer_delete() is called without sync on nvfnic_ls_req->ls_req_timer:
timer_delete(&nvfnic_ls_req->ls_req_timer);
if (status == 0) {
...
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
lsreq->done(lsreq, status);
The timer callback nvfnic_ls_req_timeout() might be executing concurrently
on another CPU. After the lock is dropped and lsreq->done() is called, the
NVMe FC transport frees the lsreq structure.
If the concurrent timer callback resumes, it will dereference
nvfnic_ls_req->fnic.
Is timer_delete_sync() required here?
[ ... ]
> @@ -1700,6 +1857,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);
[Severity: Low]
Are these wait-queue counters actually updated anywhere?
The counters like nvme_ios_in_waitq_3000_msec and
nvme_ios_in_waitq_max_time are read and logged here, but there does not
appear to be any logic in the patch to increment them or measure the wait
queue duration.
Will these counters perpetually read as zero?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624044334.3079-1-kartilak@cisco.com?part=11
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 12/13] scsi: fnic: Expose NVMe transport state in debugfs
2026-06-24 4:43 ` [PATCH v5 12/13] scsi: fnic: Expose NVMe transport state in debugfs Karan Tilak Kumar
@ 2026-06-24 5:17 ` sashiko-bot
0 siblings, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-06-24 5:17 UTC (permalink / raw)
To: Karan Tilak Kumar; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The NVMe debugfs file is created and exposed to user space before the data structures and locks it depends on are initialized, creating a race condition that can trigger a NULL pointer dereference and uninitialized spinlock access.
--
commit 82342d5cda06cd97fbd3a125f13faf76b39082ad
Author: Karan Tilak Kumar <kartilak@cisco.com>
scsi: fnic: Expose NVMe transport state in debugfs
Create an NVMe debugfs directory with a per-host nvmef_info file,
reporting local-port and target-port identifiers for NVMe initiator
instances.
> diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
> index df8c8ebbc32b9..245db1b992b51 100644
> --- a/drivers/scsi/fnic/fnic_main.c
> +++ b/drivers/scsi/fnic/fnic_main.c
[ ... ]
> @@ -933,6 +933,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);
[Severity: High]
Is it safe to create and expose the debugfs file nvmef_info this early in
the probe sequence?
At this point in fnic_probe(), the fnic structure has been allocated with
kzalloc(), but critical structures like fnic_lock and iport->tport_list
haven't been initialized yet. They appear to be initialized later in the
function or in fnic_fdls_init().
If a process concurrently opens and reads this debugfs file right after
fnic_nvmef_debugfs_init() returns, could it trigger a crash?
> fnic->role = FNIC_ROLE_NVME_INITIATOR;
> dev_info(&fnic->pdev->dev, "fnic: %d is NVME initiator\n",
> fnic->fnic_num);
[ ... ]
> diff --git a/drivers/scsi/fnic/fnic_nvme.c b/drivers/scsi/fnic/fnic_nvme.c
> index e322dd4dcb787..a19dd9cf76cf9 100644
> --- a/drivers/scsi/fnic/fnic_nvme.c
> +++ b/drivers/scsi/fnic/fnic_nvme.c
[ ... ]
> @@ -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) {
[Severity: High]
If nvfnic_get_nvmef_info() is executed concurrently before the fnic
struct is fully initialized, will this attempt to acquire an
uninitialized fnic_lock?
Furthermore, if iport->tport_list is still zeroed from the kzalloc(),
the list_for_each_entry_safe() macro expects a properly initialized
list head. Could passing a zeroed list head cause a NULL pointer
dereference when computing the next pointer for the first entry?
> + 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;
> +}
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624044334.3079-1-kartilak@cisco.com?part=12
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 05/13] scsi: fnic: Add FDLS role handling for NVMe initiators
2026-06-24 4:43 ` [PATCH v5 05/13] scsi: fnic: Add FDLS role handling for NVMe initiators Karan Tilak Kumar
@ 2026-06-24 5:18 ` sashiko-bot
0 siblings, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-06-24 5:18 UTC (permalink / raw)
To: Karan Tilak Kumar; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found 8 potential issue(s) to consider:
New issues:
- [High] The NVMe PRLI payload is truncated because `frame_size` is calculated using the smaller FCP payload structure.
- [High] NVMe initiators incorrectly validate the FCP Target Function bit instead of the NVMe Target Function bit.
Pre-existing issues:
- [Critical] `fnic_cleanup_io` calls `schedule_timeout(100)` while executing in a hardirq context, causing a kernel panic.
- [Critical] The `notify_timer` unconditionally re-arms itself, bypassing `timer_delete_sync` during module teardown and causing a Use-After-Free.
- [High] Dropping the lock inside a `list_for_each_entry_safe` loop creates a Use-After-Free condition.
- [High] The `fnic` structure is freed without being removed from the global `reset_fnic_list`, resulting in a Use-After-Free in the worker thread.
- [High] The `fabric.retry_timer` is never cancelled before freeing the `fnic` structure, leading to a Use-After-Free.
- [High] The code restores a stale IRQ state by using the `fnic->lock_flags` struct member instead of the caller's saved flags.
--
commit 5d6ee3fb48072d18a71bfad0fac88f211a7027ca
Author: Karan Tilak Kumar <kartilak@cisco.com>
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.
> diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c
> index f665460ef62c5..e03256183ac63 100644
> --- a/drivers/scsi/fnic/fdls_disc.c
> +++ b/drivers/scsi/fnic/fdls_disc.c
[ ... ]
> @@ -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);
> + 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 is it safe to use the struct member
fnic->lock_flags to restore the lock state here?
In fnic_tport_event_handler(), the fnic_lock is acquired using a local flags
variable, so fnic->lock_flags is never updated. When fdls_delete_tport()
subsequently drops the lock here using fnic->lock_flags, it restores a
potentially stale IRQ state. This can corrupt the CPU's interrupt state and
lead to deadlocks.
[ ... ]
> @@ -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);
> + 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]
Does this result in a truncated NVMe payload?
The NVMe PRLI length is correctly set to 24 bytes here (0x18), but the
frame_size allocated for the transmission at the beginning of
fdls_send_tgt_prli() is calculated using sizeof(struct fc_std_els_prli).
Because that struct only accommodates the smaller 16-byte FCP payload, the
NVMe request is sent with an incomplete payload, which violates the FC-NVMe
standard.
[ ... ]
> @@ -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)) ||
> + (IS_FNIC_NVME_INITIATOR(fnic) &&
> + !(tport->fcp_csp & FCP_PRLI_FUNC_TARGET))) {
[Severity: High]
Are we checking the correct bit for NVMe targets?
The condition explicitly checks the FCP_PRLI_FUNC_TARGET bit (bit 4) for both
FCP and NVMe initiators. NVMe targets use a different bit mask
(FNIC_NVME_FEAT_TARG, which is bit 0) to indicate target support. This causes
the driver to incorrectly evaluate target support when connecting to NVMe
endpoints.
[ ... ]
> @@ -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)) {
> + 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 lock inside
list_for_each_entry_safe() defeat the safety of the loop iteration?
When fdls_delete_tport() is called inside the loop body, it explicitly drops
fnic->fnic_lock. While unlocked, another thread or workqueue can delete and
free the pre-fetched next element. This can lead to a use-after-free crash
when the loop iterates.
[ ... ]
> diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
> index ca592bc3f6182..a67d1085d720b 100644
> --- a/drivers/scsi/fnic/fnic_fcs.c
> +++ b/drivers/scsi/fnic/fnic_fcs.c
[ ... ]
> @@ -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);
> + }
[Severity: High]
This is a pre-existing issue, but does this leak the fnic structure onto a
global list when the device is removed?
When fdls_process_rscn() is called, it adds the fnic instance to the global
reset_fnic_list. If the device is subsequently removed, fnic_remove() frees
the fnic memory without deleting it from reset_fnic_list or flushing the
reset_fnic_work_queue. The background worker iterates over reset_fnic_list
here and will access the freed cur_fnic object, resulting in a
use-after-free.
[ ... ]
> diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
> index 5850d51b0e8f6..0d7828be244da 100644
> --- a/drivers/scsi/fnic/fnic_main.c
> +++ b/drivers/scsi/fnic/fnic_main.c
[ ... ]
> @@ -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);
[Severity: Critical]
This is a pre-existing issue, but can this lead to a use-after-free due to
a self-rearming timer?
The timer callback fnic_notify_timer() unconditionally re-arms itself with
mod_timer(). Calling timer_delete_sync() here will wait for the currently
executing callback to finish, but the callback will queue itself again. This
leaves a pending timer firing after the fnic structure is freed below.
[Severity: High]
This is a pre-existing issue, but is the fabric.retry_timer left active?
The discovery process arms iport->fabric.retry_timer, but it is not
cancelled in fnic_remove() alongside the other timers like fip_timer and
notify_timer. This can cause the timer callback to execute after the fnic
memory is freed.
[ ... ]
> diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
> index b92260583c67b..37d1e136b7b91 100644
> --- a/drivers/scsi/fnic/fnic_scsi.c
> +++ b/drivers/scsi/fnic/fnic_scsi.c
> @@ -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);
[Severity: Critical]
This is a pre-existing issue, but does this lead to sleeping in atomic
context?
The fnic_fcpio_fw_reset_cmpl_handler() function executes in a hardirq context
(via an MSI-X interrupt). It calls fnic_cleanup_io() which contains a while
loop that unconditionally calls schedule_timeout(msecs_to_jiffies(100)).
Calling a sleeping function in a hardirq context causes a kernel panic.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624044334.3079-1-kartilak@cisco.com?part=5
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2026-06-24 5:18 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 01/13] scsi: fnic: Make debug logging protocol independent Karan Tilak Kumar
2026-06-24 5:08 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 02/13] scsi: fnic: Use fnic_num for non-SCSI identifiers Karan Tilak Kumar
2026-06-24 5:11 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 03/13] scsi: fnic: Decode firmware role configuration Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 04/13] scsi: fnic: Advertise NVMe initiator service parameters Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 05/13] scsi: fnic: Add FDLS role handling for NVMe initiators Karan Tilak Kumar
2026-06-24 5:18 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 06/13] scsi: fnic: Add the NVMe/FC transport path Karan Tilak Kumar
2026-06-24 5:12 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 07/13] scsi: fnic: Route completions and resets by initiator role Karan Tilak Kumar
2026-06-24 5:11 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 08/13] scsi: fnic: Handle NVMe LS frames in FDLS Karan Tilak Kumar
2026-06-24 5:13 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 09/13] scsi: fnic: Send NVMe LS requests through FDLS Karan Tilak Kumar
2026-06-24 5:11 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 10/13] scsi: fnic: Abort timed-out NVMe LS requests Karan Tilak Kumar
2026-06-24 5:13 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 11/13] scsi: fnic: Track NVMe transport statistics Karan Tilak Kumar
2026-06-24 5:15 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 12/13] scsi: fnic: Expose NVMe transport state in debugfs Karan Tilak Kumar
2026-06-24 5:17 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 13/13] scsi: fnic: Bump up version number Karan Tilak Kumar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.