From: Karan Tilak Kumar <kartilak@cisco.com>
To: sebaddel@cisco.com
Cc: arulponn@cisco.com, djhawar@cisco.com, gcboffa@cisco.com,
mkai2@cisco.com, satishkh@cisco.com, aeasi@cisco.com,
jejb@linux.ibm.com, martin.petersen@oracle.com,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
jmeneghi@redhat.com, revers@redhat.com, adakopou@redhat.com,
lduncan@suse.com, Karan Tilak Kumar <kartilak@cisco.com>,
Hannes Reinecke <hare@kernel.org>
Subject: [PATCH v5 08/13] scsi: fnic: Handle NVMe LS frames in FDLS
Date: Tue, 23 Jun 2026 21:43:29 -0700 [thread overview]
Message-ID: <20260624044334.3079-9-kartilak@cisco.com> (raw)
In-Reply-To: <20260624044334.3079-1-kartilak@cisco.com>
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
next prev parent reply other threads:[~2026-06-24 4:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` [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 4:43 ` [PATCH v5 06/13] scsi: fnic: Add the NVMe/FC transport path Karan Tilak Kumar
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 [this message]
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 ` [PATCH v5 10/13] scsi: fnic: Abort timed-out NVMe LS requests Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 11/13] scsi: fnic: Track NVMe transport statistics Karan Tilak Kumar
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260624044334.3079-9-kartilak@cisco.com \
--to=kartilak@cisco.com \
--cc=adakopou@redhat.com \
--cc=aeasi@cisco.com \
--cc=arulponn@cisco.com \
--cc=djhawar@cisco.com \
--cc=gcboffa@cisco.com \
--cc=hare@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=jmeneghi@redhat.com \
--cc=lduncan@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mkai2@cisco.com \
--cc=revers@redhat.com \
--cc=satishkh@cisco.com \
--cc=sebaddel@cisco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®