mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 17:42:03 +02:00
scsi: ibmvfc: implement nvme-fc LS submission transport callback
NVMe FC Link Service commands are required to use the ibmvfc_passthru MAD. Initialize a pssthru mad for the target port including the DMA addresses for the FC4_LS request and response as well as the max length of each IU as provided in the nvmefc_ls_req struct. FC4_LS commands are sent via the primary CRQ. Further, store the assoc_id during a create association request as this is a required field in our vfc_cmd struct for nvme_fcp_io commands. Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Link: https://patch.msgid.link/20260723000149.969416-30-tyreld@linux.ibm.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
86e4953580
commit
7088e1c8b6
|
|
@ -1633,6 +1633,7 @@ void ibmvfc_init_event(struct ibmvfc_event *evt,
|
|||
void (*done) (struct ibmvfc_event *), u8 format)
|
||||
{
|
||||
evt->cmnd = NULL;
|
||||
evt->ls_req = NULL;
|
||||
evt->sync_iu = NULL;
|
||||
evt->eh_comp = NULL;
|
||||
evt->crq.format = format;
|
||||
|
|
|
|||
|
|
@ -62,10 +62,99 @@ static void ibmvfc_nvme_delete_queue(struct nvme_fc_local_port *lport, unsigned
|
|||
kfree(handle);
|
||||
}
|
||||
|
||||
static void ibmvfc_ls_req_done(struct ibmvfc_event *evt)
|
||||
{
|
||||
struct ibmvfc_target *tgt = evt->tgt;
|
||||
struct ibmvfc_passthru_mad *mad = &evt->xfer_iu->passthru;
|
||||
struct fcnvme_ls_rqst_w0 *ls_rqst;
|
||||
struct fcnvme_ls_cr_assoc_acc *ls_resp;
|
||||
u32 status = be16_to_cpu(mad->common.status);
|
||||
int rc = 0;
|
||||
|
||||
ls_rqst = (struct fcnvme_ls_rqst_w0 *)evt->ls_req->rqstaddr;
|
||||
ls_resp = (struct fcnvme_ls_cr_assoc_acc *)evt->ls_req->rspaddr;
|
||||
|
||||
switch (status) {
|
||||
case IBMVFC_MAD_SUCCESS:
|
||||
tgt_dbg(tgt, "ls_req succeeded\n");
|
||||
if ((ls_rqst->ls_cmd == FCNVME_LS_CREATE_ASSOCIATION) &&
|
||||
(ls_resp->hdr.w0.ls_cmd == FCNVME_LS_ACC)) {
|
||||
tgt->assoc_id = be64_to_cpu(ls_resp->associd.association_id);
|
||||
tgt_dbg(tgt, "assoc_id 0x%llx\n", tgt->assoc_id);
|
||||
}
|
||||
break;
|
||||
case IBMVFC_MAD_DRIVER_FAILED:
|
||||
break;
|
||||
case IBMVFC_MAD_FAILED:
|
||||
default:
|
||||
tgt_info(tgt, "ls_req failed: %s (%x:%x) rc=0x%02X\n",
|
||||
ibmvfc_get_cmd_error(be16_to_cpu(mad->iu.status), be16_to_cpu(mad->iu.error)),
|
||||
be16_to_cpu(mad->iu.status), be16_to_cpu(mad->iu.error), status);
|
||||
break;
|
||||
}
|
||||
|
||||
if (status)
|
||||
rc = -EIO;
|
||||
|
||||
evt->ls_req->done(evt->ls_req, rc);
|
||||
|
||||
kref_put(&tgt->kref, ibmvfc_release_tgt);
|
||||
ibmvfc_free_event(evt);
|
||||
}
|
||||
|
||||
static void ibmvfc_init_ls_req(struct ibmvfc_event *evt, struct nvmefc_ls_req *ls_req)
|
||||
{
|
||||
struct ibmvfc_passthru_mad *mad = &evt->iu.passthru;
|
||||
|
||||
memset(mad, 0, sizeof(*mad));
|
||||
mad->common.version = cpu_to_be32(2);
|
||||
mad->common.opcode = cpu_to_be32(IBMVFC_NVMF_PASSTHRU);
|
||||
mad->common.length = cpu_to_be16(sizeof(*mad) - sizeof(mad->fc_iu) - sizeof(mad->iu));
|
||||
mad->cmd_ioba.va = cpu_to_be64((u64)be64_to_cpu(evt->crq.ioba) +
|
||||
offsetof(struct ibmvfc_passthru_mad, iu));
|
||||
mad->cmd_ioba.len = cpu_to_be32(sizeof(mad->iu));
|
||||
mad->iu.cmd_len = cpu_to_be32(ls_req->rqstlen);
|
||||
mad->iu.rsp_len = cpu_to_be32(ls_req->rsplen);
|
||||
mad->iu.cmd.va = cpu_to_be64(ls_req->rqstdma);
|
||||
mad->iu.cmd.len = cpu_to_be32(ls_req->rqstlen);
|
||||
mad->iu.rsp.va = cpu_to_be64(ls_req->rspdma);
|
||||
mad->iu.rsp.len = cpu_to_be32(ls_req->rsplen);
|
||||
}
|
||||
|
||||
static int ibmvfc_nvme_ls_req(struct nvme_fc_local_port *lport,
|
||||
struct nvme_fc_remote_port *rport,
|
||||
struct nvmefc_ls_req *ls_req)
|
||||
{
|
||||
struct ibmvfc_host *vhost = lport->private;
|
||||
struct ibmvfc_target *tgt = rport->private;
|
||||
struct ibmvfc_passthru_mad *mad;
|
||||
struct ibmvfc_event *evt;
|
||||
|
||||
kref_get(&tgt->kref);
|
||||
evt = ibmvfc_get_event(&vhost->crq);
|
||||
if (!evt) {
|
||||
kref_put(&tgt->kref, ibmvfc_release_tgt);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
ibmvfc_init_event(evt, ibmvfc_ls_req_done, IBMVFC_MAD_FORMAT);
|
||||
evt->tgt = tgt;
|
||||
evt->ls_req = ls_req;
|
||||
ls_req->private = evt;
|
||||
|
||||
ibmvfc_init_ls_req(evt, ls_req);
|
||||
mad = &evt->iu.passthru;
|
||||
mad->iu.flags = cpu_to_be32(IBMVFC_FC4_LS_DSC_CTRL);
|
||||
mad->iu.scsi_id = cpu_to_be64(tgt->scsi_id);
|
||||
mad->iu.cancel_key = cpu_to_be32((u64)evt);
|
||||
mad->iu.target_wwpn = cpu_to_be64(tgt->wwpn);
|
||||
|
||||
ibmvfc_dbg(vhost, "nvme_ls_req\n");
|
||||
if (ibmvfc_send_event(evt, vhost, IBMVFC_FC4_LS_PLUS_CANCEL_TIMEOUT)) {
|
||||
kref_put(&tgt->kref, ibmvfc_release_tgt);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
#include <scsi/fc/fc_fs.h>
|
||||
#include <scsi/fc/fc_els.h>
|
||||
#include <linux/nvme-fc-driver.h>
|
||||
#include <linux/nvme.h>
|
||||
#include <linux/nvme-fc.h>
|
||||
|
||||
#include "ibmvfc.h"
|
||||
|
||||
|
|
@ -22,10 +24,16 @@
|
|||
#define IBMVFC_MAX_NVME_QUEUES 16
|
||||
#define IBMVFC_NVME_CHANNELS 8
|
||||
|
||||
#define IBMVFC_FC4_LS_TIMEOUT 15
|
||||
#define IBMVFC_FC4_LS_CANCEL_TIMEOUT 45
|
||||
#define IBMVFC_FC4_LS_PLUS_CANCEL_TIMEOUT \
|
||||
(IBMVFC_FC4_LS_TIMEOUT + IBMVFC_FC4_LS_CANCEL_TIMEOUT)
|
||||
|
||||
extern unsigned int ibmvfc_debug;
|
||||
|
||||
struct ibmvfc_host;
|
||||
struct ibmvfc_target;
|
||||
struct ibmvfc_queue;
|
||||
|
||||
struct ibmvfc_nvme_qhandle {
|
||||
unsigned int qidx;
|
||||
|
|
|
|||
|
|
@ -824,6 +824,7 @@ struct ibmvfc_target {
|
|||
u64 scsi_id;
|
||||
u64 wwpn;
|
||||
u64 new_scsi_id;
|
||||
u64 assoc_id;
|
||||
struct fc_rport *rport;
|
||||
int target_id;
|
||||
enum ibmvfc_target_action action;
|
||||
|
|
@ -851,6 +852,7 @@ struct ibmvfc_event {
|
|||
struct ibmvfc_queue *queue;
|
||||
struct ibmvfc_target *tgt;
|
||||
struct scsi_cmnd *cmnd;
|
||||
struct nvmefc_ls_req *ls_req;
|
||||
atomic_t free;
|
||||
atomic_t active;
|
||||
union ibmvfc_iu *xfer_iu;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user