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, dan.carpenter@linaro.org,
adakopou@redhat.com, lduncan@suse.com,
Karan Tilak Kumar <kartilak@cisco.com>,
Hannes Reinecke <hare@kernel.org>
Subject: [PATCH 08/13] scsi: fnic: Handle NVMe LS frames in FDLS
Date: Thu, 21 May 2026 11:04:53 -0700 [thread overview]
Message-ID: <20260521180458.5448-9-kartilak@cisco.com> (raw)
In-Reply-To: <20260521180458.5448-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>
---
drivers/scsi/fnic/fdls_disc.c | 30 ++++++++++++++++++++++++++++++
drivers/scsi/fnic/fnic_fcs.c | 33 +++++++++++++++++++++++++++------
2 files changed, 57 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c
index 9ecbb967be2e..0fcdfdea8fb4 100644
--- a/drivers/scsi/fnic/fdls_disc.c
+++ b/drivers/scsi/fnic/fdls_disc.c
@@ -387,10 +387,16 @@ 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;
+ bitmap_clear(oxid_pool->bitmap, 0, FNIC_OXID_POOL_SZ);
oxid_pool->next_idx = 0;
}
@@ -1288,6 +1294,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) ||
@@ -1828,6 +1838,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");
@@ -2439,6 +2450,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) {
@@ -2531,6 +2544,12 @@ static void fdls_tport_timer_callback(struct timer_list *t)
FNIC_FCS_DBG(KERN_INFO, fnic,
"0x%x timeout for tport 0x%x unhandled state %d\n",
iport->fcid, tport->fcid, 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);
@@ -2841,6 +2860,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);
@@ -4852,6 +4877,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",
@@ -5084,6 +5111,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 ac1febaa8474..24fc36c0ad5c 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);
@@ -617,6 +629,9 @@ void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf)
void *rq_buf = buf->os_buf;
struct fnic *fnic = vnic_dev_priv(rq->vdev);
+ if (WARN_ON(!buf))
+ return;
+
dma_unmap_single(&fnic->pdev->dev, buf->dma_addr, buf->len,
DMA_FROM_DEVICE);
@@ -651,7 +666,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 +700,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 +737,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 +885,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);
@@ -917,6 +933,9 @@ void fnic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf)
dma_unmap_single(&fnic->pdev->dev, buf->dma_addr, buf->len,
DMA_TO_DEVICE);
+ if (WARN_ON(!buf))
+ return;
+
mempool_free(buf->os_buf, fnic->frame_pool);
buf->os_buf = NULL;
}
@@ -1048,6 +1067,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);
} else {
FNIC_FCS_DBG(KERN_INFO, fnic,
"Target not ready. Add rport event dropped: 0x%x",
--
2.47.1
next prev parent reply other threads:[~2026-05-21 18:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 18:04 [PATCH 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
2026-05-21 18:04 ` [PATCH 01/13] scsi: fnic: Make debug logging protocol independent Karan Tilak Kumar
2026-05-21 18:04 ` [PATCH 02/13] scsi: fnic: Use fnic_num for non-SCSI identifiers Karan Tilak Kumar
2026-05-21 18:04 ` [PATCH 03/13] scsi: fnic: Decode firmware role configuration Karan Tilak Kumar
2026-05-21 18:04 ` [PATCH 04/13] scsi: fnic: Advertise NVMe initiator service parameters Karan Tilak Kumar
2026-05-21 18:04 ` [PATCH 05/13] scsi: fnic: Add FDLS role handling for NVMe initiators Karan Tilak Kumar
2026-05-21 18:04 ` [PATCH 06/13] scsi: fnic: Add the NVMe/FC transport path Karan Tilak Kumar
2026-05-27 9:00 ` Marco Crivellari
2026-05-27 18:17 ` Karan Tilak Kumar (kartilak)
2026-05-21 18:04 ` [PATCH 07/13] scsi: fnic: Route completions and resets by initiator role Karan Tilak Kumar
2026-05-21 18:04 ` Karan Tilak Kumar [this message]
2026-05-21 18:04 ` [PATCH 09/13] scsi: fnic: Send NVMe LS requests through FDLS Karan Tilak Kumar
2026-05-21 18:04 ` [PATCH 10/13] scsi: fnic: Abort timed-out NVMe LS requests Karan Tilak Kumar
2026-05-21 18:04 ` [PATCH 11/13] scsi: fnic: Track NVMe transport statistics Karan Tilak Kumar
2026-05-21 18:04 ` [PATCH 12/13] scsi: fnic: Expose NVMe transport state in debugfs Karan Tilak Kumar
2026-05-21 18:04 ` [PATCH 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=20260521180458.5448-9-kartilak@cisco.com \
--to=kartilak@cisco.com \
--cc=adakopou@redhat.com \
--cc=aeasi@cisco.com \
--cc=arulponn@cisco.com \
--cc=dan.carpenter@linaro.org \
--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®