James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1 | /******************************************************************* |
| 2 | * This file is part of the Emulex Linux Device Driver for * |
| 3 | * Fibre Channel Host Bus Adapters. * |
Justin Tee | 22871fe | 2023-03-01 15:16:26 -0800 | [diff] [blame] | 4 | * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * |
James Smart | 3e21d1c | 2018-05-04 20:37:59 -0700 | [diff] [blame] | 5 | * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 6 | * Copyright (C) 2004-2016 Emulex. All rights reserved. * |
| 7 | * EMULEX and SLI are trademarks of Emulex. * |
James Smart | d080abe | 2017-02-12 13:52:39 -0800 | [diff] [blame] | 8 | * www.broadcom.com * |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 9 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
| 10 | * * |
| 11 | * This program is free software; you can redistribute it and/or * |
| 12 | * modify it under the terms of version 2 of the GNU General * |
| 13 | * Public License as published by the Free Software Foundation. * |
| 14 | * This program is distributed in the hope that it will be useful. * |
| 15 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * |
| 16 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * |
| 18 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * |
| 19 | * TO BE LEGALLY INVALID. See the GNU General Public License for * |
| 20 | * more details, a copy of which can be found in the file COPYING * |
| 21 | * included with this package. * |
| 22 | ********************************************************************/ |
| 23 | #include <linux/pci.h> |
| 24 | #include <linux/slab.h> |
| 25 | #include <linux/interrupt.h> |
| 26 | #include <linux/delay.h> |
| 27 | #include <asm/unaligned.h> |
| 28 | #include <linux/crc-t10dif.h> |
| 29 | #include <net/checksum.h> |
| 30 | |
| 31 | #include <scsi/scsi.h> |
| 32 | #include <scsi/scsi_device.h> |
| 33 | #include <scsi/scsi_eh.h> |
| 34 | #include <scsi/scsi_host.h> |
| 35 | #include <scsi/scsi_tcq.h> |
| 36 | #include <scsi/scsi_transport_fc.h> |
| 37 | #include <scsi/fc/fc_fs.h> |
| 38 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 39 | #include "lpfc_version.h" |
| 40 | #include "lpfc_hw4.h" |
| 41 | #include "lpfc_hw.h" |
| 42 | #include "lpfc_sli.h" |
| 43 | #include "lpfc_sli4.h" |
| 44 | #include "lpfc_nl.h" |
| 45 | #include "lpfc_disc.h" |
| 46 | #include "lpfc.h" |
| 47 | #include "lpfc_nvme.h" |
| 48 | #include "lpfc_scsi.h" |
| 49 | #include "lpfc_logmsg.h" |
| 50 | #include "lpfc_crtn.h" |
| 51 | #include "lpfc_vport.h" |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 52 | #include "lpfc_debugfs.h" |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 53 | |
| 54 | /* NVME initiator-based functions */ |
| 55 | |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 56 | static struct lpfc_io_buf * |
James Smart | cf1a1d3 | 2017-12-08 17:18:03 -0800 | [diff] [blame] | 57 | lpfc_get_nvme_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 58 | int idx, int expedite); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 59 | |
| 60 | static void |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 61 | lpfc_release_nvme_buf(struct lpfc_hba *, struct lpfc_io_buf *); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 62 | |
James Smart | 81e6a63 | 2017-11-20 16:00:43 -0800 | [diff] [blame] | 63 | static struct nvme_fc_port_template lpfc_nvme_template; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * lpfc_nvme_create_queue - |
Lee Jones | 09d9970 | 2020-07-13 08:59:57 +0100 | [diff] [blame] | 67 | * @pnvme_lport: Transport localport that LS is to be issued from |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 68 | * @qidx: An cpu index used to affinitize IO queues and MSIX vectors. |
Lee Jones | 09d9970 | 2020-07-13 08:59:57 +0100 | [diff] [blame] | 69 | * @qsize: Size of the queue in bytes |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 70 | * @handle: An opaque driver handle used in follow-up calls. |
| 71 | * |
| 72 | * Driver registers this routine to preallocate and initialize any |
| 73 | * internal data structures to bind the @qidx to its internal IO queues. |
| 74 | * A hardware queue maps (qidx) to a specific driver MSI-X vector/EQ/CQ/WQ. |
| 75 | * |
| 76 | * Return value : |
| 77 | * 0 - Success |
| 78 | * -EINVAL - Unsupported input value. |
| 79 | * -ENOMEM - Could not alloc necessary memory |
| 80 | **/ |
| 81 | static int |
| 82 | lpfc_nvme_create_queue(struct nvme_fc_local_port *pnvme_lport, |
| 83 | unsigned int qidx, u16 qsize, |
| 84 | void **handle) |
| 85 | { |
| 86 | struct lpfc_nvme_lport *lport; |
| 87 | struct lpfc_vport *vport; |
| 88 | struct lpfc_nvme_qhandle *qhandle; |
| 89 | char *str; |
| 90 | |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 91 | if (!pnvme_lport->private) |
| 92 | return -ENOMEM; |
| 93 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 94 | lport = (struct lpfc_nvme_lport *)pnvme_lport->private; |
| 95 | vport = lport->vport; |
James Smart | a4691038 | 2022-03-16 20:27:35 -0700 | [diff] [blame] | 96 | |
| 97 | if (!vport || vport->load_flag & FC_UNLOADING || |
| 98 | vport->phba->hba_flag & HBA_IOQ_FLUSH) |
| 99 | return -ENODEV; |
| 100 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 101 | qhandle = kzalloc(sizeof(struct lpfc_nvme_qhandle), GFP_KERNEL); |
| 102 | if (qhandle == NULL) |
| 103 | return -ENOMEM; |
| 104 | |
Bart Van Assche | d6d189c | 2019-03-28 11:06:22 -0700 | [diff] [blame] | 105 | qhandle->cpu_id = raw_smp_processor_id(); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 106 | qhandle->qidx = qidx; |
| 107 | /* |
| 108 | * NVME qidx == 0 is the admin queue, so both admin queue |
| 109 | * and first IO queue will use MSI-X vector and associated |
| 110 | * EQ/CQ/WQ at index 0. After that they are sequentially assigned. |
| 111 | */ |
| 112 | if (qidx) { |
| 113 | str = "IO "; /* IO queue */ |
| 114 | qhandle->index = ((qidx - 1) % |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 115 | lpfc_nvme_template.max_hw_queues); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 116 | } else { |
| 117 | str = "ADM"; /* Admin queue */ |
| 118 | qhandle->index = qidx; |
| 119 | } |
| 120 | |
James Smart | d58734f | 2017-08-23 16:55:46 -0700 | [diff] [blame] | 121 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 122 | "6073 Binding %s HdwQueue %d (cpu %d) to " |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 123 | "hdw_queue %d qhandle x%px\n", str, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 124 | qidx, qhandle->cpu_id, qhandle->index, qhandle); |
| 125 | *handle = (void *)qhandle; |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * lpfc_nvme_delete_queue - |
Lee Jones | 09d9970 | 2020-07-13 08:59:57 +0100 | [diff] [blame] | 131 | * @pnvme_lport: Transport localport that LS is to be issued from |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 132 | * @qidx: An cpu index used to affinitize IO queues and MSIX vectors. |
| 133 | * @handle: An opaque driver handle from lpfc_nvme_create_queue |
| 134 | * |
| 135 | * Driver registers this routine to free |
| 136 | * any internal data structures to bind the @qidx to its internal |
| 137 | * IO queues. |
| 138 | * |
| 139 | * Return value : |
| 140 | * 0 - Success |
| 141 | * TODO: What are the failure codes. |
| 142 | **/ |
| 143 | static void |
| 144 | lpfc_nvme_delete_queue(struct nvme_fc_local_port *pnvme_lport, |
| 145 | unsigned int qidx, |
| 146 | void *handle) |
| 147 | { |
| 148 | struct lpfc_nvme_lport *lport; |
| 149 | struct lpfc_vport *vport; |
| 150 | |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 151 | if (!pnvme_lport->private) |
| 152 | return; |
| 153 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 154 | lport = (struct lpfc_nvme_lport *)pnvme_lport->private; |
| 155 | vport = lport->vport; |
| 156 | |
| 157 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 158 | "6001 ENTER. lpfc_pnvme x%px, qidx x%x qhandle x%px\n", |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 159 | lport, qidx, handle); |
| 160 | kfree(handle); |
| 161 | } |
| 162 | |
| 163 | static void |
| 164 | lpfc_nvme_localport_delete(struct nvme_fc_local_port *localport) |
| 165 | { |
| 166 | struct lpfc_nvme_lport *lport = localport->private; |
| 167 | |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 168 | lpfc_printf_vlog(lport->vport, KERN_INFO, LOG_NVME, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 169 | "6173 localport x%px delete complete\n", |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 170 | lport); |
| 171 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 172 | /* release any threads waiting for the unreg to complete */ |
Ewan D. Milne | 7961cba6f | 2019-01-17 11:14:44 -0500 | [diff] [blame] | 173 | if (lport->vport->localport) |
| 174 | complete(lport->lport_unreg_cmp); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | /* lpfc_nvme_remoteport_delete |
| 178 | * |
| 179 | * @remoteport: Pointer to an nvme transport remoteport instance. |
| 180 | * |
| 181 | * This is a template downcall. NVME transport calls this function |
| 182 | * when it has completed the unregistration of a previously |
| 183 | * registered remoteport. |
| 184 | * |
| 185 | * Return value : |
| 186 | * None |
| 187 | */ |
Bart Van Assche | 3999df7 | 2019-03-28 11:06:16 -0700 | [diff] [blame] | 188 | static void |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 189 | lpfc_nvme_remoteport_delete(struct nvme_fc_remote_port *remoteport) |
| 190 | { |
| 191 | struct lpfc_nvme_rport *rport = remoteport->private; |
| 192 | struct lpfc_vport *vport; |
| 193 | struct lpfc_nodelist *ndlp; |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 194 | u32 fc4_xpt_flags; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 195 | |
| 196 | ndlp = rport->ndlp; |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 197 | if (!ndlp) { |
James Smart | f115612 | 2021-04-11 18:31:24 -0700 | [diff] [blame] | 198 | pr_err("**** %s: NULL ndlp on rport x%px remoteport x%px\n", |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 199 | __func__, rport, remoteport); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 200 | goto rport_err; |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 201 | } |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 202 | |
| 203 | vport = ndlp->vport; |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 204 | if (!vport) { |
James Smart | f115612 | 2021-04-11 18:31:24 -0700 | [diff] [blame] | 205 | pr_err("**** %s: Null vport on ndlp x%px, ste x%x rport x%px\n", |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 206 | __func__, ndlp, ndlp->nlp_state, rport); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 207 | goto rport_err; |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | fc4_xpt_flags = NVME_XPT_REGD | SCSI_XPT_REGD; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 211 | |
| 212 | /* Remove this rport from the lport's list - memory is owned by the |
| 213 | * transport. Remove the ndlp reference for the NVME transport before |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 214 | * calling state machine to remove the node. |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 215 | */ |
| 216 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC, |
James Smart | 982fc39 | 2021-09-10 16:31:47 -0700 | [diff] [blame] | 217 | "6146 remoteport delete of remoteport x%px, ndlp x%px " |
| 218 | "DID x%x xflags x%x\n", |
| 219 | remoteport, ndlp, ndlp->nlp_DID, ndlp->fc4_xpt_flags); |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 220 | spin_lock_irq(&ndlp->lock); |
James Smart | b15bd3e | 2018-04-09 14:24:30 -0700 | [diff] [blame] | 221 | |
| 222 | /* The register rebind might have occurred before the delete |
| 223 | * downcall. Guard against this race. |
| 224 | */ |
James Smart | 0614568 | 2021-07-07 11:43:46 -0700 | [diff] [blame] | 225 | if (ndlp->fc4_xpt_flags & NVME_XPT_UNREG_WAIT) |
| 226 | ndlp->fc4_xpt_flags &= ~(NVME_XPT_UNREG_WAIT | NVME_XPT_REGD); |
James Smart | 3fd7835 | 2017-12-08 17:18:09 -0800 | [diff] [blame] | 227 | |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 228 | spin_unlock_irq(&ndlp->lock); |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 229 | |
| 230 | /* On a devloss timeout event, one more put is executed provided the |
| 231 | * NVME and SCSI rport unregister requests are complete. If the vport |
| 232 | * is unloading, this extra put is executed by lpfc_drop_node. |
| 233 | */ |
| 234 | if (!(ndlp->fc4_xpt_flags & fc4_xpt_flags)) |
| 235 | lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 236 | |
| 237 | rport_err: |
James Smart | 3fd7835 | 2017-12-08 17:18:09 -0800 | [diff] [blame] | 238 | return; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 239 | } |
| 240 | |
James Smart | 3a8070c | 2020-03-31 09:50:05 -0700 | [diff] [blame] | 241 | /** |
| 242 | * lpfc_nvme_handle_lsreq - Process an unsolicited NVME LS request |
| 243 | * @phba: pointer to lpfc hba data structure. |
| 244 | * @axchg: pointer to exchange context for the NVME LS request |
| 245 | * |
| 246 | * This routine is used for processing an asychronously received NVME LS |
| 247 | * request. Any remaining validation is done and the LS is then forwarded |
| 248 | * to the nvme-fc transport via nvme_fc_rcv_ls_req(). |
| 249 | * |
James Smart | 9aa09e9 | 2020-03-31 09:50:09 -0700 | [diff] [blame] | 250 | * The calling sequence should be: nvme_fc_rcv_ls_req() -> (processing) |
| 251 | * -> lpfc_nvme_xmt_ls_rsp/cmp -> req->done. |
| 252 | * __lpfc_nvme_xmt_ls_rsp_cmp should free the allocated axchg. |
| 253 | * |
James Smart | 3a8070c | 2020-03-31 09:50:05 -0700 | [diff] [blame] | 254 | * Returns 0 if LS was handled and delivered to the transport |
| 255 | * Returns 1 if LS failed to be handled and should be dropped |
| 256 | */ |
| 257 | int |
| 258 | lpfc_nvme_handle_lsreq(struct lpfc_hba *phba, |
| 259 | struct lpfc_async_xchg_ctx *axchg) |
| 260 | { |
James Smart | 9aa09e9 | 2020-03-31 09:50:09 -0700 | [diff] [blame] | 261 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 262 | struct lpfc_vport *vport; |
| 263 | struct lpfc_nvme_rport *lpfc_rport; |
| 264 | struct nvme_fc_remote_port *remoteport; |
| 265 | struct lpfc_nvme_lport *lport; |
| 266 | uint32_t *payload = axchg->payload; |
| 267 | int rc; |
| 268 | |
| 269 | vport = axchg->ndlp->vport; |
| 270 | lpfc_rport = axchg->ndlp->nrport; |
| 271 | if (!lpfc_rport) |
| 272 | return -EINVAL; |
| 273 | |
| 274 | remoteport = lpfc_rport->remoteport; |
James Smart | a4691038 | 2022-03-16 20:27:35 -0700 | [diff] [blame] | 275 | if (!vport->localport || |
| 276 | vport->phba->hba_flag & HBA_IOQ_FLUSH) |
James Smart | 9aa09e9 | 2020-03-31 09:50:09 -0700 | [diff] [blame] | 277 | return -EINVAL; |
| 278 | |
| 279 | lport = vport->localport->private; |
| 280 | if (!lport) |
| 281 | return -EINVAL; |
| 282 | |
| 283 | rc = nvme_fc_rcv_ls_req(remoteport, &axchg->ls_rsp, axchg->payload, |
| 284 | axchg->size); |
| 285 | |
| 286 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, |
| 287 | "6205 NVME Unsol rcv: sz %d rc %d: %08x %08x %08x " |
| 288 | "%08x %08x %08x\n", |
| 289 | axchg->size, rc, |
| 290 | *payload, *(payload+1), *(payload+2), |
| 291 | *(payload+3), *(payload+4), *(payload+5)); |
| 292 | |
| 293 | if (!rc) |
| 294 | return 0; |
| 295 | #endif |
James Smart | 3a8070c | 2020-03-31 09:50:05 -0700 | [diff] [blame] | 296 | return 1; |
| 297 | } |
| 298 | |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 299 | /** |
| 300 | * __lpfc_nvme_ls_req_cmp - Generic completion handler for a NVME |
| 301 | * LS request. |
| 302 | * @phba: Pointer to HBA context object |
| 303 | * @vport: The local port that issued the LS |
| 304 | * @cmdwqe: Pointer to driver command WQE object. |
| 305 | * @wcqe: Pointer to driver response CQE object. |
| 306 | * |
| 307 | * This function is the generic completion handler for NVME LS requests. |
| 308 | * The function updates any states and statistics, calls the transport |
| 309 | * ls_req done() routine, then tears down the command and buffers used |
| 310 | * for the LS request. |
| 311 | **/ |
| 312 | void |
| 313 | __lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_vport *vport, |
| 314 | struct lpfc_iocbq *cmdwqe, |
| 315 | struct lpfc_wcqe_complete *wcqe) |
| 316 | { |
| 317 | struct nvmefc_ls_req *pnvme_lsreq; |
| 318 | struct lpfc_dmabuf *buf_ptr; |
| 319 | struct lpfc_nodelist *ndlp; |
| 320 | uint32_t status; |
| 321 | |
James Smart | d51cf5b | 2022-04-12 15:20:02 -0700 | [diff] [blame] | 322 | pnvme_lsreq = cmdwqe->context_un.nvme_lsreq; |
| 323 | ndlp = cmdwqe->ndlp; |
| 324 | buf_ptr = cmdwqe->bpl_dmabuf; |
| 325 | |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 326 | status = bf_get(lpfc_wcqe_c_status, wcqe) & LPFC_IOCB_STATUS_MASK; |
| 327 | |
| 328 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC, |
James Smart | f115612 | 2021-04-11 18:31:24 -0700 | [diff] [blame] | 329 | "6047 NVMEx LS REQ x%px cmpl DID %x Xri: %x " |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 330 | "status %x reason x%x cmd:x%px lsreg:x%px bmp:x%px " |
| 331 | "ndlp:x%px\n", |
| 332 | pnvme_lsreq, ndlp ? ndlp->nlp_DID : 0, |
| 333 | cmdwqe->sli4_xritag, status, |
| 334 | (wcqe->parameter & 0xffff), |
James Smart | d51cf5b | 2022-04-12 15:20:02 -0700 | [diff] [blame] | 335 | cmdwqe, pnvme_lsreq, cmdwqe->bpl_dmabuf, |
| 336 | ndlp); |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 337 | |
| 338 | lpfc_nvmeio_data(phba, "NVMEx LS CMPL: xri x%x stat x%x parm x%x\n", |
| 339 | cmdwqe->sli4_xritag, status, wcqe->parameter); |
| 340 | |
James Smart | d51cf5b | 2022-04-12 15:20:02 -0700 | [diff] [blame] | 341 | if (buf_ptr) { |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 342 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 343 | kfree(buf_ptr); |
James Smart | d51cf5b | 2022-04-12 15:20:02 -0700 | [diff] [blame] | 344 | cmdwqe->bpl_dmabuf = NULL; |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 345 | } |
| 346 | if (pnvme_lsreq->done) |
| 347 | pnvme_lsreq->done(pnvme_lsreq, status); |
| 348 | else |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 349 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 350 | "6046 NVMEx cmpl without done call back? " |
James Smart | f115612 | 2021-04-11 18:31:24 -0700 | [diff] [blame] | 351 | "Data x%px DID %x Xri: %x status %x\n", |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 352 | pnvme_lsreq, ndlp ? ndlp->nlp_DID : 0, |
| 353 | cmdwqe->sli4_xritag, status); |
| 354 | if (ndlp) { |
| 355 | lpfc_nlp_put(ndlp); |
James Smart | d51cf5b | 2022-04-12 15:20:02 -0700 | [diff] [blame] | 356 | cmdwqe->ndlp = NULL; |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 357 | } |
| 358 | lpfc_sli_release_iocbq(phba, cmdwqe); |
| 359 | } |
| 360 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 361 | static void |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 362 | lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 363 | struct lpfc_iocbq *rspwqe) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 364 | { |
| 365 | struct lpfc_vport *vport = cmdwqe->vport; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 366 | struct lpfc_nvme_lport *lport; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 367 | uint32_t status; |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 368 | struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 369 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 370 | status = bf_get(lpfc_wcqe_c_status, wcqe) & LPFC_IOCB_STATUS_MASK; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 371 | |
James Smart | 66a8515 | 2018-04-09 14:24:31 -0700 | [diff] [blame] | 372 | if (vport->localport) { |
| 373 | lport = (struct lpfc_nvme_lport *)vport->localport->private; |
| 374 | if (lport) { |
| 375 | atomic_inc(&lport->fc4NvmeLsCmpls); |
| 376 | if (status) { |
| 377 | if (bf_get(lpfc_wcqe_c_xb, wcqe)) |
| 378 | atomic_inc(&lport->cmpl_ls_xb); |
| 379 | atomic_inc(&lport->cmpl_ls_err); |
| 380 | } |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 381 | } |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 382 | } |
| 383 | |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 384 | __lpfc_nvme_ls_req_cmp(phba, vport, cmdwqe, wcqe); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | static int |
| 388 | lpfc_nvme_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, |
| 389 | struct lpfc_dmabuf *inp, |
James Smart | 205e824 | 2018-03-05 12:04:03 -0800 | [diff] [blame] | 390 | struct nvmefc_ls_req *pnvme_lsreq, |
| 391 | void (*cmpl)(struct lpfc_hba *, struct lpfc_iocbq *, |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 392 | struct lpfc_iocbq *), |
James Smart | 205e824 | 2018-03-05 12:04:03 -0800 | [diff] [blame] | 393 | struct lpfc_nodelist *ndlp, uint32_t num_entry, |
| 394 | uint32_t tmo, uint8_t retry) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 395 | { |
James Smart | 205e824 | 2018-03-05 12:04:03 -0800 | [diff] [blame] | 396 | struct lpfc_hba *phba = vport->phba; |
| 397 | union lpfc_wqe128 *wqe; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 398 | struct lpfc_iocbq *genwqe; |
| 399 | struct ulp_bde64 *bpl; |
| 400 | struct ulp_bde64 bde; |
| 401 | int i, rc, xmit_len, first_len; |
| 402 | |
| 403 | /* Allocate buffer for command WQE */ |
| 404 | genwqe = lpfc_sli_get_iocbq(phba); |
| 405 | if (genwqe == NULL) |
| 406 | return 1; |
| 407 | |
| 408 | wqe = &genwqe->wqe; |
James Smart | d9f492a | 2019-08-14 16:57:04 -0700 | [diff] [blame] | 409 | /* Initialize only 64 bytes */ |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 410 | memset(wqe, 0, sizeof(union lpfc_wqe)); |
| 411 | |
James Smart | d51cf5b | 2022-04-12 15:20:02 -0700 | [diff] [blame] | 412 | genwqe->bpl_dmabuf = bmp; |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 413 | genwqe->cmd_flag |= LPFC_IO_NVME_LS; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 414 | |
| 415 | /* Save for completion so we can release these resources */ |
James Smart | d51cf5b | 2022-04-12 15:20:02 -0700 | [diff] [blame] | 416 | genwqe->ndlp = lpfc_nlp_get(ndlp); |
| 417 | if (!genwqe->ndlp) { |
James Smart | 4430f7f | 2020-11-15 11:26:31 -0800 | [diff] [blame] | 418 | dev_warn(&phba->pcidev->dev, |
| 419 | "Warning: Failed node ref, not sending LS_REQ\n"); |
| 420 | lpfc_sli_release_iocbq(phba, genwqe); |
| 421 | return 1; |
| 422 | } |
| 423 | |
James Smart | d51cf5b | 2022-04-12 15:20:02 -0700 | [diff] [blame] | 424 | genwqe->context_un.nvme_lsreq = pnvme_lsreq; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 425 | /* Fill in payload, bp points to frame payload */ |
| 426 | |
| 427 | if (!tmo) |
| 428 | /* FC spec states we need 3 * ratov for CT requests */ |
| 429 | tmo = (3 * phba->fc_ratov); |
| 430 | |
| 431 | /* For this command calculate the xmit length of the request bde. */ |
| 432 | xmit_len = 0; |
| 433 | first_len = 0; |
| 434 | bpl = (struct ulp_bde64 *)bmp->virt; |
| 435 | for (i = 0; i < num_entry; i++) { |
| 436 | bde.tus.w = bpl[i].tus.w; |
| 437 | if (bde.tus.f.bdeFlags != BUFF_TYPE_BDE_64) |
| 438 | break; |
| 439 | xmit_len += bde.tus.f.bdeSize; |
| 440 | if (i == 0) |
| 441 | first_len = xmit_len; |
| 442 | } |
| 443 | |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 444 | genwqe->num_bdes = num_entry; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 445 | genwqe->hba_wqidx = 0; |
| 446 | |
| 447 | /* Words 0 - 2 */ |
| 448 | wqe->generic.bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64; |
| 449 | wqe->generic.bde.tus.f.bdeSize = first_len; |
| 450 | wqe->generic.bde.addrLow = bpl[0].addrLow; |
| 451 | wqe->generic.bde.addrHigh = bpl[0].addrHigh; |
| 452 | |
| 453 | /* Word 3 */ |
| 454 | wqe->gen_req.request_payload_len = first_len; |
| 455 | |
| 456 | /* Word 4 */ |
| 457 | |
| 458 | /* Word 5 */ |
| 459 | bf_set(wqe_dfctl, &wqe->gen_req.wge_ctl, 0); |
| 460 | bf_set(wqe_si, &wqe->gen_req.wge_ctl, 1); |
| 461 | bf_set(wqe_la, &wqe->gen_req.wge_ctl, 1); |
James Smart | 8b36163 | 2017-03-04 09:30:26 -0800 | [diff] [blame] | 462 | bf_set(wqe_rctl, &wqe->gen_req.wge_ctl, FC_RCTL_ELS4_REQ); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 463 | bf_set(wqe_type, &wqe->gen_req.wge_ctl, FC_TYPE_NVME); |
| 464 | |
| 465 | /* Word 6 */ |
| 466 | bf_set(wqe_ctxt_tag, &wqe->gen_req.wqe_com, |
| 467 | phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); |
| 468 | bf_set(wqe_xri_tag, &wqe->gen_req.wqe_com, genwqe->sli4_xritag); |
| 469 | |
| 470 | /* Word 7 */ |
James Smart | c33b160 | 2021-01-04 10:02:30 -0800 | [diff] [blame] | 471 | bf_set(wqe_tmo, &wqe->gen_req.wqe_com, tmo); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 472 | bf_set(wqe_class, &wqe->gen_req.wqe_com, CLASS3); |
| 473 | bf_set(wqe_cmnd, &wqe->gen_req.wqe_com, CMD_GEN_REQUEST64_WQE); |
| 474 | bf_set(wqe_ct, &wqe->gen_req.wqe_com, SLI4_CT_RPI); |
| 475 | |
| 476 | /* Word 8 */ |
| 477 | wqe->gen_req.wqe_com.abort_tag = genwqe->iotag; |
| 478 | |
| 479 | /* Word 9 */ |
| 480 | bf_set(wqe_reqtag, &wqe->gen_req.wqe_com, genwqe->iotag); |
| 481 | |
| 482 | /* Word 10 */ |
| 483 | bf_set(wqe_dbde, &wqe->gen_req.wqe_com, 1); |
| 484 | bf_set(wqe_iod, &wqe->gen_req.wqe_com, LPFC_WQE_IOD_READ); |
| 485 | bf_set(wqe_qosd, &wqe->gen_req.wqe_com, 1); |
| 486 | bf_set(wqe_lenloc, &wqe->gen_req.wqe_com, LPFC_WQE_LENLOC_NONE); |
| 487 | bf_set(wqe_ebde_cnt, &wqe->gen_req.wqe_com, 0); |
| 488 | |
| 489 | /* Word 11 */ |
| 490 | bf_set(wqe_cqid, &wqe->gen_req.wqe_com, LPFC_WQE_CQ_ID_DEFAULT); |
| 491 | bf_set(wqe_cmd_type, &wqe->gen_req.wqe_com, OTHER_COMMAND); |
| 492 | |
| 493 | |
| 494 | /* Issue GEN REQ WQE for NPORT <did> */ |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 495 | genwqe->cmd_cmpl = cmpl; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 496 | genwqe->drvrTimeout = tmo + LPFC_DRVR_TIMEOUT; |
| 497 | genwqe->vport = vport; |
| 498 | genwqe->retry = retry; |
| 499 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 500 | lpfc_nvmeio_data(phba, "NVME LS XMIT: xri x%x iotag x%x to x%06x\n", |
| 501 | genwqe->sli4_xritag, genwqe->iotag, ndlp->nlp_DID); |
| 502 | |
James Smart | 1fbf974 | 2019-01-28 11:14:26 -0800 | [diff] [blame] | 503 | rc = lpfc_sli4_issue_wqe(phba, &phba->sli4_hba.hdwq[0], genwqe); |
Dick Kennedy | cd22d60 | 2017-08-23 16:55:35 -0700 | [diff] [blame] | 504 | if (rc) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 505 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 506 | "6045 Issue GEN REQ WQE to NPORT x%x " |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 507 | "Data: x%x x%x rc x%x\n", |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 508 | ndlp->nlp_DID, genwqe->iotag, |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 509 | vport->port_state, rc); |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 510 | lpfc_nlp_put(ndlp); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 511 | lpfc_sli_release_iocbq(phba, genwqe); |
| 512 | return 1; |
| 513 | } |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 514 | |
| 515 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC | LOG_ELS, |
| 516 | "6050 Issue GEN REQ WQE to NPORT x%x " |
| 517 | "Data: oxid: x%x state: x%x wq:x%px lsreq:x%px " |
| 518 | "bmp:x%px xmit:%d 1st:%d\n", |
| 519 | ndlp->nlp_DID, genwqe->sli4_xritag, |
| 520 | vport->port_state, |
| 521 | genwqe, pnvme_lsreq, bmp, xmit_len, first_len); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 522 | return 0; |
| 523 | } |
| 524 | |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 525 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 526 | /** |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 527 | * __lpfc_nvme_ls_req - Generic service routine to issue an NVME LS request |
| 528 | * @vport: The local port issuing the LS |
| 529 | * @ndlp: The remote port to send the LS to |
| 530 | * @pnvme_lsreq: Pointer to LS request structure from the transport |
Lee Jones | 09d9970 | 2020-07-13 08:59:57 +0100 | [diff] [blame] | 531 | * @gen_req_cmp: Completion call-back |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 532 | * |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 533 | * Routine validates the ndlp, builds buffers and sends a GEN_REQUEST |
| 534 | * WQE to perform the LS operation. |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 535 | * |
| 536 | * Return value : |
| 537 | * 0 - Success |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 538 | * non-zero: various error codes, in form of -Exxx |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 539 | **/ |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 540 | int |
| 541 | __lpfc_nvme_ls_req(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 542 | struct nvmefc_ls_req *pnvme_lsreq, |
| 543 | void (*gen_req_cmp)(struct lpfc_hba *phba, |
| 544 | struct lpfc_iocbq *cmdwqe, |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 545 | struct lpfc_iocbq *rspwqe)) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 546 | { |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 547 | struct lpfc_dmabuf *bmp; |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 548 | struct ulp_bde64 *bpl; |
| 549 | int ret; |
James Smart | ba43c4d | 2017-04-21 16:04:47 -0700 | [diff] [blame] | 550 | uint16_t ntype, nstate; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 551 | |
James Smart | 307e338 | 2020-11-15 11:26:30 -0800 | [diff] [blame] | 552 | if (!ndlp) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 553 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 554 | "6051 NVMEx LS REQ: Bad NDLP x%px, Failing " |
| 555 | "LS Req\n", |
| 556 | ndlp); |
James Smart | ba43c4d | 2017-04-21 16:04:47 -0700 | [diff] [blame] | 557 | return -ENODEV; |
| 558 | } |
| 559 | |
James Smart | ba43c4d | 2017-04-21 16:04:47 -0700 | [diff] [blame] | 560 | ntype = ndlp->nlp_type; |
| 561 | nstate = ndlp->nlp_state; |
| 562 | if ((ntype & NLP_NVME_TARGET && nstate != NLP_STE_MAPPED_NODE) || |
| 563 | (ntype & NLP_NVME_INITIATOR && nstate != NLP_STE_UNMAPPED_NODE)) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 564 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 565 | "6088 NVMEx LS REQ: Fail DID x%06x not " |
| 566 | "ready for IO. Type x%x, State x%x\n", |
| 567 | ndlp->nlp_DID, ntype, nstate); |
James Smart | ba43c4d | 2017-04-21 16:04:47 -0700 | [diff] [blame] | 568 | return -ENODEV; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 569 | } |
James Smart | a4691038 | 2022-03-16 20:27:35 -0700 | [diff] [blame] | 570 | if (vport->phba->hba_flag & HBA_IOQ_FLUSH) |
| 571 | return -ENODEV; |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 572 | |
James Smart | 8c65830 | 2021-01-27 14:16:01 -0800 | [diff] [blame] | 573 | if (!vport->phba->sli4_hba.nvmels_wq) |
| 574 | return -ENOMEM; |
| 575 | |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 576 | /* |
| 577 | * there are two dma buf in the request, actually there is one and |
| 578 | * the second one is just the start address + cmd size. |
| 579 | * Before calling lpfc_nvme_gen_req these buffers need to be wrapped |
| 580 | * in a lpfc_dmabuf struct. When freeing we just free the wrapper |
| 581 | * because the nvem layer owns the data bufs. |
| 582 | * We do not have to break these packets open, we don't care what is |
| 583 | * in them. And we do not have to look at the resonse data, we only |
| 584 | * care that we got a response. All of the caring is going to happen |
| 585 | * in the nvme-fc layer. |
| 586 | */ |
| 587 | |
| 588 | bmp = kmalloc(sizeof(*bmp), GFP_KERNEL); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 589 | if (!bmp) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 590 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 591 | "6044 NVMEx LS REQ: Could not alloc LS buf " |
| 592 | "for DID %x\n", |
| 593 | ndlp->nlp_DID); |
| 594 | return -ENOMEM; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 595 | } |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 596 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 597 | bmp->virt = lpfc_mbuf_alloc(vport->phba, MEM_PRI, &(bmp->phys)); |
| 598 | if (!bmp->virt) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 599 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 600 | "6042 NVMEx LS REQ: Could not alloc mbuf " |
| 601 | "for DID %x\n", |
| 602 | ndlp->nlp_DID); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 603 | kfree(bmp); |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 604 | return -ENOMEM; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 605 | } |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 606 | |
| 607 | INIT_LIST_HEAD(&bmp->list); |
| 608 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 609 | bpl = (struct ulp_bde64 *)bmp->virt; |
| 610 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(pnvme_lsreq->rqstdma)); |
| 611 | bpl->addrLow = le32_to_cpu(putPaddrLow(pnvme_lsreq->rqstdma)); |
| 612 | bpl->tus.f.bdeFlags = 0; |
| 613 | bpl->tus.f.bdeSize = pnvme_lsreq->rqstlen; |
| 614 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 615 | bpl++; |
| 616 | |
| 617 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(pnvme_lsreq->rspdma)); |
| 618 | bpl->addrLow = le32_to_cpu(putPaddrLow(pnvme_lsreq->rspdma)); |
| 619 | bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64I; |
| 620 | bpl->tus.f.bdeSize = pnvme_lsreq->rsplen; |
| 621 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 622 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 623 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC, |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 624 | "6149 NVMEx LS REQ: Issue to DID 0x%06x lsreq x%px, " |
| 625 | "rqstlen:%d rsplen:%d %pad %pad\n", |
| 626 | ndlp->nlp_DID, pnvme_lsreq, pnvme_lsreq->rqstlen, |
| 627 | pnvme_lsreq->rsplen, &pnvme_lsreq->rqstdma, |
| 628 | &pnvme_lsreq->rspdma); |
| 629 | |
| 630 | ret = lpfc_nvme_gen_req(vport, bmp, pnvme_lsreq->rqstaddr, |
| 631 | pnvme_lsreq, gen_req_cmp, ndlp, 2, |
James Smart | c33b160 | 2021-01-04 10:02:30 -0800 | [diff] [blame] | 632 | pnvme_lsreq->timeout, 0); |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 633 | if (ret != WQE_SUCCESS) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 634 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 635 | "6052 NVMEx REQ: EXIT. issue ls wqe failed " |
| 636 | "lsreq x%px Status %x DID %x\n", |
| 637 | pnvme_lsreq, ret, ndlp->nlp_DID); |
| 638 | lpfc_mbuf_free(vport->phba, bmp->virt, bmp->phys); |
| 639 | kfree(bmp); |
| 640 | return -EIO; |
| 641 | } |
| 642 | |
| 643 | return 0; |
| 644 | } |
| 645 | |
| 646 | /** |
| 647 | * lpfc_nvme_ls_req - Issue an NVME Link Service request |
Lee Jones | 09d9970 | 2020-07-13 08:59:57 +0100 | [diff] [blame] | 648 | * @pnvme_lport: Transport localport that LS is to be issued from. |
Lee Jones | 3e74917 | 2020-11-02 14:23:52 +0000 | [diff] [blame] | 649 | * @pnvme_rport: Transport remoteport that LS is to be sent to. |
Lee Jones | 09d9970 | 2020-07-13 08:59:57 +0100 | [diff] [blame] | 650 | * @pnvme_lsreq: the transport nvme_ls_req structure for the LS |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 651 | * |
| 652 | * Driver registers this routine to handle any link service request |
| 653 | * from the nvme_fc transport to a remote nvme-aware port. |
| 654 | * |
| 655 | * Return value : |
| 656 | * 0 - Success |
| 657 | * non-zero: various error codes, in form of -Exxx |
| 658 | **/ |
| 659 | static int |
| 660 | lpfc_nvme_ls_req(struct nvme_fc_local_port *pnvme_lport, |
| 661 | struct nvme_fc_remote_port *pnvme_rport, |
| 662 | struct nvmefc_ls_req *pnvme_lsreq) |
| 663 | { |
| 664 | struct lpfc_nvme_lport *lport; |
| 665 | struct lpfc_nvme_rport *rport; |
| 666 | struct lpfc_vport *vport; |
| 667 | int ret; |
| 668 | |
| 669 | lport = (struct lpfc_nvme_lport *)pnvme_lport->private; |
| 670 | rport = (struct lpfc_nvme_rport *)pnvme_rport->private; |
| 671 | if (unlikely(!lport) || unlikely(!rport)) |
| 672 | return -EINVAL; |
| 673 | |
| 674 | vport = lport->vport; |
James Smart | a4691038 | 2022-03-16 20:27:35 -0700 | [diff] [blame] | 675 | if (vport->load_flag & FC_UNLOADING || |
| 676 | vport->phba->hba_flag & HBA_IOQ_FLUSH) |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 677 | return -ENODEV; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 678 | |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 679 | atomic_inc(&lport->fc4NvmeLsRequests); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 680 | |
James Smart | 6514b25 | 2020-03-31 09:50:06 -0700 | [diff] [blame] | 681 | ret = __lpfc_nvme_ls_req(vport, rport->ndlp, pnvme_lsreq, |
| 682 | lpfc_nvme_ls_req_cmp); |
| 683 | if (ret) |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 684 | atomic_inc(&lport->xmt_ls_err); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 685 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 686 | return ret; |
| 687 | } |
| 688 | |
| 689 | /** |
James Smart | e96a22b | 2020-03-31 09:50:07 -0700 | [diff] [blame] | 690 | * __lpfc_nvme_ls_abort - Generic service routine to abort a prior |
| 691 | * NVME LS request |
| 692 | * @vport: The local port that issued the LS |
| 693 | * @ndlp: The remote port the LS was sent to |
| 694 | * @pnvme_lsreq: Pointer to LS request structure from the transport |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 695 | * |
James Smart | e96a22b | 2020-03-31 09:50:07 -0700 | [diff] [blame] | 696 | * The driver validates the ndlp, looks for the LS, and aborts the |
| 697 | * LS if found. |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 698 | * |
James Smart | e96a22b | 2020-03-31 09:50:07 -0700 | [diff] [blame] | 699 | * Returns: |
| 700 | * 0 : if LS found and aborted |
| 701 | * non-zero: various error conditions in form -Exxx |
| 702 | **/ |
| 703 | int |
| 704 | __lpfc_nvme_ls_abort(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 705 | struct nvmefc_ls_req *pnvme_lsreq) |
| 706 | { |
| 707 | struct lpfc_hba *phba = vport->phba; |
| 708 | struct lpfc_sli_ring *pring; |
| 709 | struct lpfc_iocbq *wqe, *next_wqe; |
| 710 | bool foundit = false; |
| 711 | |
| 712 | if (!ndlp) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 713 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | e96a22b | 2020-03-31 09:50:07 -0700 | [diff] [blame] | 714 | "6049 NVMEx LS REQ Abort: Bad NDLP x%px DID " |
| 715 | "x%06x, Failing LS Req\n", |
| 716 | ndlp, ndlp ? ndlp->nlp_DID : 0); |
| 717 | return -EINVAL; |
| 718 | } |
| 719 | |
| 720 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC | LOG_NVME_ABTS, |
| 721 | "6040 NVMEx LS REQ Abort: Issue LS_ABORT for lsreq " |
James Smart | f115612 | 2021-04-11 18:31:24 -0700 | [diff] [blame] | 722 | "x%px rqstlen:%d rsplen:%d %pad %pad\n", |
James Smart | e96a22b | 2020-03-31 09:50:07 -0700 | [diff] [blame] | 723 | pnvme_lsreq, pnvme_lsreq->rqstlen, |
| 724 | pnvme_lsreq->rsplen, &pnvme_lsreq->rqstdma, |
| 725 | &pnvme_lsreq->rspdma); |
| 726 | |
| 727 | /* |
| 728 | * Lock the ELS ring txcmplq and look for the wqe that matches |
| 729 | * this ELS. If found, issue an abort on the wqe. |
| 730 | */ |
| 731 | pring = phba->sli4_hba.nvmels_wq->pring; |
| 732 | spin_lock_irq(&phba->hbalock); |
| 733 | spin_lock(&pring->ring_lock); |
| 734 | list_for_each_entry_safe(wqe, next_wqe, &pring->txcmplq, list) { |
James Smart | d51cf5b | 2022-04-12 15:20:02 -0700 | [diff] [blame] | 735 | if (wqe->context_un.nvme_lsreq == pnvme_lsreq) { |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 736 | wqe->cmd_flag |= LPFC_DRIVER_ABORTED; |
James Smart | e96a22b | 2020-03-31 09:50:07 -0700 | [diff] [blame] | 737 | foundit = true; |
| 738 | break; |
| 739 | } |
| 740 | } |
| 741 | spin_unlock(&pring->ring_lock); |
| 742 | |
| 743 | if (foundit) |
James Smart | db7531d | 2020-11-15 11:26:44 -0800 | [diff] [blame] | 744 | lpfc_sli_issue_abort_iotag(phba, pring, wqe, NULL); |
James Smart | e96a22b | 2020-03-31 09:50:07 -0700 | [diff] [blame] | 745 | spin_unlock_irq(&phba->hbalock); |
| 746 | |
| 747 | if (foundit) |
| 748 | return 0; |
| 749 | |
| 750 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC | LOG_NVME_ABTS, |
James Smart | f115612 | 2021-04-11 18:31:24 -0700 | [diff] [blame] | 751 | "6213 NVMEx LS REQ Abort: Unable to locate req x%px\n", |
James Smart | e96a22b | 2020-03-31 09:50:07 -0700 | [diff] [blame] | 752 | pnvme_lsreq); |
James Smart | 6b6e896 | 2020-05-20 11:59:29 -0700 | [diff] [blame] | 753 | return -EINVAL; |
James Smart | e96a22b | 2020-03-31 09:50:07 -0700 | [diff] [blame] | 754 | } |
| 755 | |
James Smart | 9aa09e9 | 2020-03-31 09:50:09 -0700 | [diff] [blame] | 756 | static int |
| 757 | lpfc_nvme_xmt_ls_rsp(struct nvme_fc_local_port *localport, |
| 758 | struct nvme_fc_remote_port *remoteport, |
| 759 | struct nvmefc_ls_rsp *ls_rsp) |
| 760 | { |
| 761 | struct lpfc_async_xchg_ctx *axchg = |
| 762 | container_of(ls_rsp, struct lpfc_async_xchg_ctx, ls_rsp); |
| 763 | struct lpfc_nvme_lport *lport; |
| 764 | int rc; |
| 765 | |
| 766 | if (axchg->phba->pport->load_flag & FC_UNLOADING) |
| 767 | return -ENODEV; |
| 768 | |
| 769 | lport = (struct lpfc_nvme_lport *)localport->private; |
| 770 | |
| 771 | rc = __lpfc_nvme_xmt_ls_rsp(axchg, ls_rsp, __lpfc_nvme_xmt_ls_rsp_cmp); |
| 772 | |
| 773 | if (rc) { |
| 774 | /* |
| 775 | * unless the failure is due to having already sent |
| 776 | * the response, an abort will be generated for the |
| 777 | * exchange if the rsp can't be sent. |
| 778 | */ |
| 779 | if (rc != -EALREADY) |
| 780 | atomic_inc(&lport->xmt_ls_abort); |
| 781 | return rc; |
| 782 | } |
| 783 | |
| 784 | return 0; |
| 785 | } |
| 786 | |
James Smart | e96a22b | 2020-03-31 09:50:07 -0700 | [diff] [blame] | 787 | /** |
| 788 | * lpfc_nvme_ls_abort - Abort a prior NVME LS request |
Lee Jones | 09d9970 | 2020-07-13 08:59:57 +0100 | [diff] [blame] | 789 | * @pnvme_lport: Transport localport that LS is to be issued from. |
| 790 | * @pnvme_rport: Transport remoteport that LS is to be sent to. |
| 791 | * @pnvme_lsreq: the transport nvme_ls_req structure for the LS |
James Smart | e96a22b | 2020-03-31 09:50:07 -0700 | [diff] [blame] | 792 | * |
| 793 | * Driver registers this routine to abort a NVME LS request that is |
| 794 | * in progress (from the transports perspective). |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 795 | **/ |
| 796 | static void |
| 797 | lpfc_nvme_ls_abort(struct nvme_fc_local_port *pnvme_lport, |
| 798 | struct nvme_fc_remote_port *pnvme_rport, |
| 799 | struct nvmefc_ls_req *pnvme_lsreq) |
| 800 | { |
| 801 | struct lpfc_nvme_lport *lport; |
| 802 | struct lpfc_vport *vport; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 803 | struct lpfc_nodelist *ndlp; |
James Smart | e96a22b | 2020-03-31 09:50:07 -0700 | [diff] [blame] | 804 | int ret; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 805 | |
| 806 | lport = (struct lpfc_nvme_lport *)pnvme_lport->private; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 807 | if (unlikely(!lport)) |
| 808 | return; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 809 | vport = lport->vport; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 810 | |
James Smart | 3386f4bd | 2017-11-20 16:00:41 -0800 | [diff] [blame] | 811 | if (vport->load_flag & FC_UNLOADING) |
| 812 | return; |
| 813 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 814 | ndlp = lpfc_findnode_did(vport, pnvme_rport->port_id); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 815 | |
James Smart | e96a22b | 2020-03-31 09:50:07 -0700 | [diff] [blame] | 816 | ret = __lpfc_nvme_ls_abort(vport, ndlp, pnvme_lsreq); |
| 817 | if (!ret) |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 818 | atomic_inc(&lport->xmt_ls_abort); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | /* Fix up the existing sgls for NVME IO. */ |
James Smart | 5fd1108 | 2018-03-05 12:04:04 -0800 | [diff] [blame] | 822 | static inline void |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 823 | lpfc_nvme_adj_fcp_sgls(struct lpfc_vport *vport, |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 824 | struct lpfc_io_buf *lpfc_ncmd, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 825 | struct nvmefc_fcp_req *nCmd) |
| 826 | { |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 827 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 828 | struct sli4_sge *sgl; |
| 829 | union lpfc_wqe128 *wqe; |
| 830 | uint32_t *wptr, *dptr; |
| 831 | |
| 832 | /* |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 833 | * Get a local pointer to the built-in wqe and correct |
| 834 | * the cmd size to match NVME's 96 bytes and fix |
| 835 | * the dma address. |
| 836 | */ |
| 837 | |
James Smart | 205e824 | 2018-03-05 12:04:03 -0800 | [diff] [blame] | 838 | wqe = &lpfc_ncmd->cur_iocbq.wqe; |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 839 | |
| 840 | /* |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 841 | * Adjust the FCP_CMD and FCP_RSP DMA data and sge_len to |
| 842 | * match NVME. NVME sends 96 bytes. Also, use the |
| 843 | * nvme commands command and response dma addresses |
| 844 | * rather than the virtual memory to ease the restore |
| 845 | * operation. |
| 846 | */ |
James Smart | 0794d60 | 2019-01-28 11:14:19 -0800 | [diff] [blame] | 847 | sgl = lpfc_ncmd->dma_sgl; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 848 | sgl->sge_len = cpu_to_le32(nCmd->cmdlen); |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 849 | if (phba->cfg_nvme_embed_cmd) { |
| 850 | sgl->addr_hi = 0; |
| 851 | sgl->addr_lo = 0; |
| 852 | |
| 853 | /* Word 0-2 - NVME CMND IU (embedded payload) */ |
| 854 | wqe->generic.bde.tus.f.bdeFlags = BUFF_TYPE_BDE_IMMED; |
| 855 | wqe->generic.bde.tus.f.bdeSize = 56; |
| 856 | wqe->generic.bde.addrHigh = 0; |
| 857 | wqe->generic.bde.addrLow = 64; /* Word 16 */ |
James Smart | 5fd1108 | 2018-03-05 12:04:04 -0800 | [diff] [blame] | 858 | |
| 859 | /* Word 10 - dbde is 0, wqes is 1 in template */ |
| 860 | |
| 861 | /* |
| 862 | * Embed the payload in the last half of the WQE |
| 863 | * WQE words 16-30 get the NVME CMD IU payload |
| 864 | * |
| 865 | * WQE words 16-19 get payload Words 1-4 |
| 866 | * WQE words 20-21 get payload Words 6-7 |
| 867 | * WQE words 22-29 get payload Words 16-23 |
| 868 | */ |
| 869 | wptr = &wqe->words[16]; /* WQE ptr */ |
| 870 | dptr = (uint32_t *)nCmd->cmdaddr; /* payload ptr */ |
| 871 | dptr++; /* Skip Word 0 in payload */ |
| 872 | |
| 873 | *wptr++ = *dptr++; /* Word 1 */ |
| 874 | *wptr++ = *dptr++; /* Word 2 */ |
| 875 | *wptr++ = *dptr++; /* Word 3 */ |
| 876 | *wptr++ = *dptr++; /* Word 4 */ |
| 877 | dptr++; /* Skip Word 5 in payload */ |
| 878 | *wptr++ = *dptr++; /* Word 6 */ |
| 879 | *wptr++ = *dptr++; /* Word 7 */ |
| 880 | dptr += 8; /* Skip Words 8-15 in payload */ |
| 881 | *wptr++ = *dptr++; /* Word 16 */ |
| 882 | *wptr++ = *dptr++; /* Word 17 */ |
| 883 | *wptr++ = *dptr++; /* Word 18 */ |
| 884 | *wptr++ = *dptr++; /* Word 19 */ |
| 885 | *wptr++ = *dptr++; /* Word 20 */ |
| 886 | *wptr++ = *dptr++; /* Word 21 */ |
| 887 | *wptr++ = *dptr++; /* Word 22 */ |
| 888 | *wptr = *dptr; /* Word 23 */ |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 889 | } else { |
| 890 | sgl->addr_hi = cpu_to_le32(putPaddrHigh(nCmd->cmddma)); |
| 891 | sgl->addr_lo = cpu_to_le32(putPaddrLow(nCmd->cmddma)); |
| 892 | |
| 893 | /* Word 0-2 - NVME CMND IU Inline BDE */ |
| 894 | wqe->generic.bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64; |
| 895 | wqe->generic.bde.tus.f.bdeSize = nCmd->cmdlen; |
| 896 | wqe->generic.bde.addrHigh = sgl->addr_hi; |
| 897 | wqe->generic.bde.addrLow = sgl->addr_lo; |
James Smart | 5fd1108 | 2018-03-05 12:04:04 -0800 | [diff] [blame] | 898 | |
| 899 | /* Word 10 */ |
| 900 | bf_set(wqe_dbde, &wqe->generic.wqe_com, 1); |
| 901 | bf_set(wqe_wqes, &wqe->generic.wqe_com, 0); |
James Smart | 4e565cf | 2018-02-22 08:18:50 -0800 | [diff] [blame] | 902 | } |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 903 | |
| 904 | sgl++; |
| 905 | |
| 906 | /* Setup the physical region for the FCP RSP */ |
| 907 | sgl->addr_hi = cpu_to_le32(putPaddrHigh(nCmd->rspdma)); |
| 908 | sgl->addr_lo = cpu_to_le32(putPaddrLow(nCmd->rspdma)); |
| 909 | sgl->word2 = le32_to_cpu(sgl->word2); |
| 910 | if (nCmd->sg_cnt) |
| 911 | bf_set(lpfc_sli4_sge_last, sgl, 0); |
| 912 | else |
| 913 | bf_set(lpfc_sli4_sge_last, sgl, 1); |
| 914 | sgl->word2 = cpu_to_le32(sgl->word2); |
| 915 | sgl->sge_len = cpu_to_le32(nCmd->rsplen); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 916 | } |
| 917 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 918 | |
Lee Jones | 09d9970 | 2020-07-13 08:59:57 +0100 | [diff] [blame] | 919 | /* |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 920 | * lpfc_nvme_io_cmd_cmpl - Complete an NVME-over-FCP IO |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 921 | * |
| 922 | * Driver registers this routine as it io request handler. This |
| 923 | * routine issues an fcp WQE with data from the @lpfc_nvme_fcpreq |
| 924 | * data structure to the rport indicated in @lpfc_nvme_rport. |
| 925 | * |
| 926 | * Return value : |
| 927 | * 0 - Success |
| 928 | * TODO: What are the failure codes. |
| 929 | **/ |
| 930 | static void |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 931 | lpfc_nvme_io_cmd_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, |
| 932 | struct lpfc_iocbq *pwqeOut) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 933 | { |
James Smart | d51cf5b | 2022-04-12 15:20:02 -0700 | [diff] [blame] | 934 | struct lpfc_io_buf *lpfc_ncmd = pwqeIn->io_buf; |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 935 | struct lpfc_wcqe_complete *wcqe = &pwqeOut->wcqe_cmpl; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 936 | struct lpfc_vport *vport = pwqeIn->vport; |
| 937 | struct nvmefc_fcp_req *nCmd; |
| 938 | struct nvme_fc_ersp_iu *ep; |
| 939 | struct nvme_fc_cmd_iu *cp; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 940 | struct lpfc_nodelist *ndlp; |
James Smart | bbe3012 | 2017-04-21 17:49:08 -0700 | [diff] [blame] | 941 | struct lpfc_nvme_fcpreq_priv *freqpriv; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 942 | struct lpfc_nvme_lport *lport; |
Arnd Bergmann | 352b205 | 2019-03-04 20:39:08 +0100 | [diff] [blame] | 943 | uint32_t code, status, idx; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 944 | uint16_t cid, sqhd, data; |
| 945 | uint32_t *ptr; |
James Smart | 0224383 | 2021-08-16 09:28:54 -0700 | [diff] [blame] | 946 | uint32_t lat; |
| 947 | bool call_done = false; |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 948 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
| 949 | int cpu; |
| 950 | #endif |
James Smart | 25ac2c97 | 2021-09-10 16:31:54 -0700 | [diff] [blame] | 951 | int offline = 0; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 952 | |
| 953 | /* Sanity check on return of outstanding command */ |
James Smart | c201726 | 2019-01-28 11:14:37 -0800 | [diff] [blame] | 954 | if (!lpfc_ncmd) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 955 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | c201726 | 2019-01-28 11:14:37 -0800 | [diff] [blame] | 956 | "6071 Null lpfc_ncmd pointer. No " |
| 957 | "release, skip completion\n"); |
| 958 | return; |
| 959 | } |
James Smart | 4d5e789 | 2018-05-24 21:08:58 -0700 | [diff] [blame] | 960 | |
James Smart | c201726 | 2019-01-28 11:14:37 -0800 | [diff] [blame] | 961 | /* Guard against abort handler being called at same time */ |
| 962 | spin_lock(&lpfc_ncmd->buf_lock); |
| 963 | |
| 964 | if (!lpfc_ncmd->nvmeCmd) { |
| 965 | spin_unlock(&lpfc_ncmd->buf_lock); |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 966 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 967 | "6066 Missing cmpl ptrs: lpfc_ncmd x%px, " |
| 968 | "nvmeCmd x%px\n", |
James Smart | 0b05e9f | 2019-01-28 11:14:17 -0800 | [diff] [blame] | 969 | lpfc_ncmd, lpfc_ncmd->nvmeCmd); |
James Smart | 4d5e789 | 2018-05-24 21:08:58 -0700 | [diff] [blame] | 970 | |
| 971 | /* Release the lpfc_ncmd regardless of the missing elements. */ |
| 972 | lpfc_release_nvme_buf(phba, lpfc_ncmd); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 973 | return; |
| 974 | } |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 975 | nCmd = lpfc_ncmd->nvmeCmd; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 976 | status = bf_get(lpfc_wcqe_c_status, wcqe); |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 977 | |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 978 | idx = lpfc_ncmd->cur_iocbq.hba_wqidx; |
| 979 | phba->sli4_hba.hdwq[idx].nvme_cstat.io_cmpls++; |
| 980 | |
James Smart | 1df0944 | 2019-08-14 16:57:05 -0700 | [diff] [blame] | 981 | if (unlikely(status && vport->localport)) { |
James Smart | 66a8515 | 2018-04-09 14:24:31 -0700 | [diff] [blame] | 982 | lport = (struct lpfc_nvme_lport *)vport->localport->private; |
James Smart | 1df0944 | 2019-08-14 16:57:05 -0700 | [diff] [blame] | 983 | if (lport) { |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 984 | if (bf_get(lpfc_wcqe_c_xb, wcqe)) |
| 985 | atomic_inc(&lport->cmpl_fcp_xb); |
| 986 | atomic_inc(&lport->cmpl_fcp_err); |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 987 | } |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 988 | } |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 989 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 990 | lpfc_nvmeio_data(phba, "NVME FCP CMPL: xri x%x stat x%x parm x%x\n", |
| 991 | lpfc_ncmd->cur_iocbq.sli4_xritag, |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 992 | status, wcqe->parameter); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 993 | /* |
| 994 | * Catch race where our node has transitioned, but the |
| 995 | * transport is still transitioning. |
| 996 | */ |
James Smart | 0b05e9f | 2019-01-28 11:14:17 -0800 | [diff] [blame] | 997 | ndlp = lpfc_ncmd->ndlp; |
James Smart | 307e338 | 2020-11-15 11:26:30 -0800 | [diff] [blame] | 998 | if (!ndlp) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 999 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 0b05e9f | 2019-01-28 11:14:17 -0800 | [diff] [blame] | 1000 | "6062 Ignoring NVME cmpl. No ndlp\n"); |
| 1001 | goto out_err; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1002 | } |
| 1003 | |
| 1004 | code = bf_get(lpfc_wcqe_c_code, wcqe); |
| 1005 | if (code == CQE_CODE_NVME_ERSP) { |
| 1006 | /* For this type of CQE, we need to rebuild the rsp */ |
| 1007 | ep = (struct nvme_fc_ersp_iu *)nCmd->rspaddr; |
| 1008 | |
| 1009 | /* |
| 1010 | * Get Command Id from cmd to plug into response. This |
| 1011 | * code is not needed in the next NVME Transport drop. |
| 1012 | */ |
| 1013 | cp = (struct nvme_fc_cmd_iu *)nCmd->cmdaddr; |
| 1014 | cid = cp->sqe.common.command_id; |
| 1015 | |
| 1016 | /* |
| 1017 | * RSN is in CQE word 2 |
| 1018 | * SQHD is in CQE Word 3 bits 15:0 |
| 1019 | * Cmd Specific info is in CQE Word 1 |
| 1020 | * and in CQE Word 0 bits 15:0 |
| 1021 | */ |
| 1022 | sqhd = bf_get(lpfc_wcqe_c_sqhead, wcqe); |
| 1023 | |
| 1024 | /* Now lets build the NVME ERSP IU */ |
| 1025 | ep->iu_len = cpu_to_be16(8); |
| 1026 | ep->rsn = wcqe->parameter; |
| 1027 | ep->xfrd_len = cpu_to_be32(nCmd->payload_length); |
| 1028 | ep->rsvd12 = 0; |
| 1029 | ptr = (uint32_t *)&ep->cqe.result.u64; |
| 1030 | *ptr++ = wcqe->total_data_placed; |
| 1031 | data = bf_get(lpfc_wcqe_c_ersp0, wcqe); |
| 1032 | *ptr = (uint32_t)data; |
| 1033 | ep->cqe.sq_head = sqhd; |
| 1034 | ep->cqe.sq_id = nCmd->sqid; |
| 1035 | ep->cqe.command_id = cid; |
| 1036 | ep->cqe.status = 0; |
| 1037 | |
| 1038 | lpfc_ncmd->status = IOSTAT_SUCCESS; |
| 1039 | lpfc_ncmd->result = 0; |
| 1040 | nCmd->rcv_rsplen = LPFC_NVME_ERSP_LEN; |
| 1041 | nCmd->transferred_length = nCmd->payload_length; |
| 1042 | } else { |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1043 | lpfc_ncmd->status = (status & LPFC_IOCB_STATUS_MASK); |
Dick Kennedy | 952c303 | 2017-09-29 17:34:43 -0700 | [diff] [blame] | 1044 | lpfc_ncmd->result = (wcqe->parameter & IOERR_PARAM_MASK); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1045 | |
| 1046 | /* For NVME, the only failure path that results in an |
| 1047 | * IO error is when the adapter rejects it. All other |
| 1048 | * conditions are a success case and resolved by the |
| 1049 | * transport. |
| 1050 | * IOSTAT_FCP_RSP_ERROR means: |
| 1051 | * 1. Length of data received doesn't match total |
| 1052 | * transfer length in WQE |
| 1053 | * 2. If the RSP payload does NOT match these cases: |
| 1054 | * a. RSP length 12/24 bytes and all zeros |
| 1055 | * b. NVME ERSP |
| 1056 | */ |
| 1057 | switch (lpfc_ncmd->status) { |
| 1058 | case IOSTAT_SUCCESS: |
| 1059 | nCmd->transferred_length = wcqe->total_data_placed; |
| 1060 | nCmd->rcv_rsplen = 0; |
| 1061 | nCmd->status = 0; |
| 1062 | break; |
| 1063 | case IOSTAT_FCP_RSP_ERROR: |
| 1064 | nCmd->transferred_length = wcqe->total_data_placed; |
| 1065 | nCmd->rcv_rsplen = wcqe->parameter; |
| 1066 | nCmd->status = 0; |
James Smart | fa21189 | 2021-05-14 12:55:50 -0700 | [diff] [blame] | 1067 | |
James Smart | ea7bd1f | 2022-06-03 10:43:27 -0700 | [diff] [blame] | 1068 | /* Get the NVME cmd details for this unique error. */ |
| 1069 | cp = (struct nvme_fc_cmd_iu *)nCmd->cmdaddr; |
| 1070 | ep = (struct nvme_fc_ersp_iu *)nCmd->rspaddr; |
| 1071 | |
James Smart | fa21189 | 2021-05-14 12:55:50 -0700 | [diff] [blame] | 1072 | /* Check if this is really an ERSP */ |
| 1073 | if (nCmd->rcv_rsplen == LPFC_NVME_ERSP_LEN) { |
| 1074 | lpfc_ncmd->status = IOSTAT_SUCCESS; |
| 1075 | lpfc_ncmd->result = 0; |
| 1076 | |
| 1077 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME, |
James Smart | ea7bd1f | 2022-06-03 10:43:27 -0700 | [diff] [blame] | 1078 | "6084 NVME FCP_ERR ERSP: " |
| 1079 | "xri %x placed x%x opcode x%x cmd_id " |
| 1080 | "x%x cqe_status x%x\n", |
| 1081 | lpfc_ncmd->cur_iocbq.sli4_xritag, |
| 1082 | wcqe->total_data_placed, |
| 1083 | cp->sqe.common.opcode, |
| 1084 | cp->sqe.common.command_id, |
| 1085 | ep->cqe.status); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1086 | break; |
James Smart | fa21189 | 2021-05-14 12:55:50 -0700 | [diff] [blame] | 1087 | } |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 1088 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1089 | "6081 NVME Completion Protocol Error: " |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1090 | "xri %x status x%x result x%x " |
James Smart | ea7bd1f | 2022-06-03 10:43:27 -0700 | [diff] [blame] | 1091 | "placed x%x opcode x%x cmd_id x%x, " |
| 1092 | "cqe_status x%x\n", |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1093 | lpfc_ncmd->cur_iocbq.sli4_xritag, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1094 | lpfc_ncmd->status, lpfc_ncmd->result, |
James Smart | ea7bd1f | 2022-06-03 10:43:27 -0700 | [diff] [blame] | 1095 | wcqe->total_data_placed, |
| 1096 | cp->sqe.common.opcode, |
| 1097 | cp->sqe.common.command_id, |
| 1098 | ep->cqe.status); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1099 | break; |
Dick Kennedy | 952c303 | 2017-09-29 17:34:43 -0700 | [diff] [blame] | 1100 | case IOSTAT_LOCAL_REJECT: |
| 1101 | /* Let fall through to set command final state. */ |
| 1102 | if (lpfc_ncmd->result == IOERR_ABORT_REQUESTED) |
| 1103 | lpfc_printf_vlog(vport, KERN_INFO, |
| 1104 | LOG_NVME_IOERR, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 1105 | "6032 Delay Aborted cmd x%px " |
| 1106 | "nvme cmd x%px, xri x%x, " |
Dick Kennedy | 952c303 | 2017-09-29 17:34:43 -0700 | [diff] [blame] | 1107 | "xb %d\n", |
| 1108 | lpfc_ncmd, nCmd, |
| 1109 | lpfc_ncmd->cur_iocbq.sli4_xritag, |
| 1110 | bf_get(lpfc_wcqe_c_xb, wcqe)); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 1111 | fallthrough; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1112 | default: |
| 1113 | out_err: |
James Smart | e3246a1 | 2017-09-29 17:34:36 -0700 | [diff] [blame] | 1114 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR, |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1115 | "6072 NVME Completion Error: xri %x " |
James Smart | 2c013a3 | 2019-03-12 16:30:31 -0700 | [diff] [blame] | 1116 | "status x%x result x%x [x%x] " |
| 1117 | "placed x%x\n", |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1118 | lpfc_ncmd->cur_iocbq.sli4_xritag, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1119 | lpfc_ncmd->status, lpfc_ncmd->result, |
James Smart | 2c013a3 | 2019-03-12 16:30:31 -0700 | [diff] [blame] | 1120 | wcqe->parameter, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1121 | wcqe->total_data_placed); |
| 1122 | nCmd->transferred_length = 0; |
| 1123 | nCmd->rcv_rsplen = 0; |
James Smart | 8e009ce | 2017-09-07 16:27:29 -0700 | [diff] [blame] | 1124 | nCmd->status = NVME_SC_INTERNAL; |
James Smart | 25ac2c97 | 2021-09-10 16:31:54 -0700 | [diff] [blame] | 1125 | offline = pci_channel_offline(vport->phba->pcidev); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1126 | } |
| 1127 | } |
| 1128 | |
| 1129 | /* pick up SLI4 exhange busy condition */ |
James Smart | 25ac2c97 | 2021-09-10 16:31:54 -0700 | [diff] [blame] | 1130 | if (bf_get(lpfc_wcqe_c_xb, wcqe) && !offline) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1131 | lpfc_ncmd->flags |= LPFC_SBUF_XBUSY; |
| 1132 | else |
| 1133 | lpfc_ncmd->flags &= ~LPFC_SBUF_XBUSY; |
| 1134 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1135 | /* Update stats and complete the IO. There is |
| 1136 | * no need for dma unprep because the nvme_transport |
| 1137 | * owns the dma address. |
| 1138 | */ |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1139 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
Dick Kennedy | c8a4ce0 | 2017-09-29 17:34:33 -0700 | [diff] [blame] | 1140 | if (lpfc_ncmd->ts_cmd_start) { |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1141 | lpfc_ncmd->ts_isr_cmpl = pwqeIn->isr_timestamp; |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 1142 | lpfc_ncmd->ts_data_io = ktime_get_ns(); |
| 1143 | phba->ktime_last_cmd = lpfc_ncmd->ts_data_io; |
| 1144 | lpfc_io_ktime(phba, lpfc_ncmd); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1145 | } |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1146 | if (unlikely(phba->hdwqstat_on & LPFC_CHECK_NVME_IO)) { |
Bart Van Assche | d6d189c | 2019-03-28 11:06:22 -0700 | [diff] [blame] | 1147 | cpu = raw_smp_processor_id(); |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1148 | this_cpu_inc(phba->sli4_hba.c_stat->cmpl_io); |
| 1149 | if (lpfc_ncmd->cpu != cpu) |
| 1150 | lpfc_printf_vlog(vport, |
| 1151 | KERN_INFO, LOG_NVME_IOERR, |
| 1152 | "6701 CPU Check cmpl: " |
| 1153 | "cpu %d expect %d\n", |
| 1154 | cpu, lpfc_ncmd->cpu); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1155 | } |
| 1156 | #endif |
Dick Kennedy | 952c303 | 2017-09-29 17:34:43 -0700 | [diff] [blame] | 1157 | |
| 1158 | /* NVME targets need completion held off until the abort exchange |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 1159 | * completes unless the NVME Rport is getting unregistered. |
Dick Kennedy | 952c303 | 2017-09-29 17:34:43 -0700 | [diff] [blame] | 1160 | */ |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 1161 | |
James Smart | 3fd7835 | 2017-12-08 17:18:09 -0800 | [diff] [blame] | 1162 | if (!(lpfc_ncmd->flags & LPFC_SBUF_XBUSY)) { |
James Smart | 91455b8 | 2018-01-30 15:58:51 -0800 | [diff] [blame] | 1163 | freqpriv = nCmd->private; |
| 1164 | freqpriv->nvme_buf = NULL; |
James Smart | 3fd7835 | 2017-12-08 17:18:09 -0800 | [diff] [blame] | 1165 | lpfc_ncmd->nvmeCmd = NULL; |
James Smart | 0224383 | 2021-08-16 09:28:54 -0700 | [diff] [blame] | 1166 | call_done = true; |
| 1167 | } |
| 1168 | spin_unlock(&lpfc_ncmd->buf_lock); |
| 1169 | |
| 1170 | /* Check if IO qualified for CMF */ |
| 1171 | if (phba->cmf_active_mode != LPFC_CFG_OFF && |
| 1172 | nCmd->io_dir == NVMEFC_FCP_READ && |
| 1173 | nCmd->payload_length) { |
| 1174 | /* Used when calculating average latency */ |
| 1175 | lat = ktime_get_ns() - lpfc_ncmd->rx_cmd_start; |
| 1176 | lpfc_update_cmf_cmpl(phba, lat, nCmd->payload_length, NULL); |
| 1177 | } |
| 1178 | |
| 1179 | if (call_done) |
James Smart | c201726 | 2019-01-28 11:14:37 -0800 | [diff] [blame] | 1180 | nCmd->done(nCmd); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1181 | |
Dick Kennedy | 952c303 | 2017-09-29 17:34:43 -0700 | [diff] [blame] | 1182 | /* Call release with XB=1 to queue the IO into the abort list. */ |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1183 | lpfc_release_nvme_buf(phba, lpfc_ncmd); |
| 1184 | } |
| 1185 | |
| 1186 | |
| 1187 | /** |
| 1188 | * lpfc_nvme_prep_io_cmd - Issue an NVME-over-FCP IO |
Lee Jones | 09d9970 | 2020-07-13 08:59:57 +0100 | [diff] [blame] | 1189 | * @vport: pointer to a host virtual N_Port data structure |
Lee Jones | 3e74917 | 2020-11-02 14:23:52 +0000 | [diff] [blame] | 1190 | * @lpfc_ncmd: Pointer to lpfc scsi command |
Lee Jones | 09d9970 | 2020-07-13 08:59:57 +0100 | [diff] [blame] | 1191 | * @pnode: pointer to a node-list data structure |
| 1192 | * @cstat: pointer to the control status structure |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1193 | * |
| 1194 | * Driver registers this routine as it io request handler. This |
| 1195 | * routine issues an fcp WQE with data from the @lpfc_nvme_fcpreq |
| 1196 | * data structure to the rport indicated in @lpfc_nvme_rport. |
| 1197 | * |
| 1198 | * Return value : |
| 1199 | * 0 - Success |
| 1200 | * TODO: What are the failure codes. |
| 1201 | **/ |
| 1202 | static int |
| 1203 | lpfc_nvme_prep_io_cmd(struct lpfc_vport *vport, |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 1204 | struct lpfc_io_buf *lpfc_ncmd, |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 1205 | struct lpfc_nodelist *pnode, |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1206 | struct lpfc_fc4_ctrl_stat *cstat) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1207 | { |
| 1208 | struct lpfc_hba *phba = vport->phba; |
| 1209 | struct nvmefc_fcp_req *nCmd = lpfc_ncmd->nvmeCmd; |
James Smart | 2e7e9c0 | 2022-06-03 10:43:28 -0700 | [diff] [blame] | 1210 | struct nvme_common_command *sqe; |
| 1211 | struct lpfc_iocbq *pwqeq = &lpfc_ncmd->cur_iocbq; |
James Smart | 205e824 | 2018-03-05 12:04:03 -0800 | [diff] [blame] | 1212 | union lpfc_wqe128 *wqe = &pwqeq->wqe; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1213 | uint32_t req_len; |
| 1214 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1215 | /* |
| 1216 | * There are three possibilities here - use scatter-gather segment, use |
| 1217 | * the single mapping, or neither. |
| 1218 | */ |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1219 | if (nCmd->sg_cnt) { |
| 1220 | if (nCmd->io_dir == NVMEFC_FCP_WRITE) { |
James Smart | 5fd1108 | 2018-03-05 12:04:04 -0800 | [diff] [blame] | 1221 | /* From the iwrite template, initialize words 7 - 11 */ |
| 1222 | memcpy(&wqe->words[7], |
| 1223 | &lpfc_iwrite_cmd_template.words[7], |
| 1224 | sizeof(uint32_t) * 5); |
| 1225 | |
| 1226 | /* Word 4 */ |
| 1227 | wqe->fcp_iwrite.total_xfer_len = nCmd->payload_length; |
| 1228 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1229 | /* Word 5 */ |
| 1230 | if ((phba->cfg_nvme_enable_fb) && |
| 1231 | (pnode->nlp_flag & NLP_FIRSTBURST)) { |
| 1232 | req_len = lpfc_ncmd->nvmeCmd->payload_length; |
| 1233 | if (req_len < pnode->nvme_fb_size) |
| 1234 | wqe->fcp_iwrite.initial_xfer_len = |
| 1235 | req_len; |
| 1236 | else |
| 1237 | wqe->fcp_iwrite.initial_xfer_len = |
| 1238 | pnode->nvme_fb_size; |
James Smart | 5fd1108 | 2018-03-05 12:04:04 -0800 | [diff] [blame] | 1239 | } else { |
| 1240 | wqe->fcp_iwrite.initial_xfer_len = 0; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1241 | } |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1242 | cstat->output_requests++; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1243 | } else { |
James Smart | 5fd1108 | 2018-03-05 12:04:04 -0800 | [diff] [blame] | 1244 | /* From the iread template, initialize words 7 - 11 */ |
| 1245 | memcpy(&wqe->words[7], |
| 1246 | &lpfc_iread_cmd_template.words[7], |
| 1247 | sizeof(uint32_t) * 5); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1248 | |
James Smart | 5fd1108 | 2018-03-05 12:04:04 -0800 | [diff] [blame] | 1249 | /* Word 4 */ |
| 1250 | wqe->fcp_iread.total_xfer_len = nCmd->payload_length; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1251 | |
James Smart | 5fd1108 | 2018-03-05 12:04:04 -0800 | [diff] [blame] | 1252 | /* Word 5 */ |
| 1253 | wqe->fcp_iread.rsrvd5 = 0; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1254 | |
James Smart | 0224383 | 2021-08-16 09:28:54 -0700 | [diff] [blame] | 1255 | /* For a CMF Managed port, iod must be zero'ed */ |
| 1256 | if (phba->cmf_active_mode == LPFC_CFG_MANAGED) |
| 1257 | bf_set(wqe_iod, &wqe->fcp_iread.wqe_com, |
| 1258 | LPFC_WQE_IOD_NONE); |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1259 | cstat->input_requests++; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1260 | } |
| 1261 | } else { |
James Smart | 5fd1108 | 2018-03-05 12:04:04 -0800 | [diff] [blame] | 1262 | /* From the icmnd template, initialize words 4 - 11 */ |
| 1263 | memcpy(&wqe->words[4], &lpfc_icmnd_cmd_template.words[4], |
| 1264 | sizeof(uint32_t) * 8); |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1265 | cstat->control_requests++; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1266 | } |
James Smart | 0d8af09 | 2019-08-14 16:57:10 -0700 | [diff] [blame] | 1267 | |
James Smart | 2e7e9c0 | 2022-06-03 10:43:28 -0700 | [diff] [blame] | 1268 | if (pnode->nlp_nvme_info & NLP_NVME_NSLER) { |
James Smart | 0d8af09 | 2019-08-14 16:57:10 -0700 | [diff] [blame] | 1269 | bf_set(wqe_erp, &wqe->generic.wqe_com, 1); |
James Smart | 2e7e9c0 | 2022-06-03 10:43:28 -0700 | [diff] [blame] | 1270 | sqe = &((struct nvme_fc_cmd_iu *) |
| 1271 | nCmd->cmdaddr)->sqe.common; |
| 1272 | if (sqe->opcode == nvme_admin_async_event) |
| 1273 | bf_set(wqe_ffrq, &wqe->generic.wqe_com, 1); |
| 1274 | } |
| 1275 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1276 | /* |
| 1277 | * Finish initializing those WQE fields that are independent |
| 1278 | * of the nvme_cmnd request_buffer |
| 1279 | */ |
| 1280 | |
James Smart | 5fd1108 | 2018-03-05 12:04:04 -0800 | [diff] [blame] | 1281 | /* Word 3 */ |
| 1282 | bf_set(payload_offset_len, &wqe->fcp_icmd, |
| 1283 | (nCmd->rsplen + nCmd->cmdlen)); |
| 1284 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1285 | /* Word 6 */ |
| 1286 | bf_set(wqe_ctxt_tag, &wqe->generic.wqe_com, |
| 1287 | phba->sli4_hba.rpi_ids[pnode->nlp_rpi]); |
| 1288 | bf_set(wqe_xri_tag, &wqe->generic.wqe_com, pwqeq->sli4_xritag); |
| 1289 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1290 | /* Word 8 */ |
| 1291 | wqe->generic.wqe_com.abort_tag = pwqeq->iotag; |
| 1292 | |
| 1293 | /* Word 9 */ |
| 1294 | bf_set(wqe_reqtag, &wqe->generic.wqe_com, pwqeq->iotag); |
| 1295 | |
James Smart | 840a470 | 2020-11-15 11:26:40 -0800 | [diff] [blame] | 1296 | /* Word 10 */ |
| 1297 | bf_set(wqe_xchg, &wqe->fcp_iwrite.wqe_com, LPFC_NVME_XCHG); |
| 1298 | |
James Smart | 414abe0 | 2018-06-26 08:24:26 -0700 | [diff] [blame] | 1299 | /* Words 13 14 15 are for PBDE support */ |
| 1300 | |
James Smart | 896325a | 2022-05-19 05:31:10 -0700 | [diff] [blame] | 1301 | /* add the VMID tags as per switch response */ |
| 1302 | if (unlikely(lpfc_ncmd->cur_iocbq.cmd_flag & LPFC_IO_VMID)) { |
| 1303 | if (phba->pport->vmid_priority_tagging) { |
| 1304 | bf_set(wqe_ccpe, &wqe->fcp_iwrite.wqe_com, 1); |
| 1305 | bf_set(wqe_ccp, &wqe->fcp_iwrite.wqe_com, |
| 1306 | lpfc_ncmd->cur_iocbq.vmid_tag.cs_ctl_vmid); |
| 1307 | } else { |
| 1308 | bf_set(wqe_appid, &wqe->fcp_iwrite.wqe_com, 1); |
| 1309 | bf_set(wqe_wqes, &wqe->fcp_iwrite.wqe_com, 1); |
| 1310 | wqe->words[31] = lpfc_ncmd->cur_iocbq.vmid_tag.app_id; |
| 1311 | } |
| 1312 | } |
| 1313 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1314 | pwqeq->vport = vport; |
| 1315 | return 0; |
| 1316 | } |
| 1317 | |
| 1318 | |
| 1319 | /** |
| 1320 | * lpfc_nvme_prep_io_dma - Issue an NVME-over-FCP IO |
Lee Jones | 09d9970 | 2020-07-13 08:59:57 +0100 | [diff] [blame] | 1321 | * @vport: pointer to a host virtual N_Port data structure |
Lee Jones | 3e74917 | 2020-11-02 14:23:52 +0000 | [diff] [blame] | 1322 | * @lpfc_ncmd: Pointer to lpfc scsi command |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1323 | * |
| 1324 | * Driver registers this routine as it io request handler. This |
| 1325 | * routine issues an fcp WQE with data from the @lpfc_nvme_fcpreq |
| 1326 | * data structure to the rport indicated in @lpfc_nvme_rport. |
| 1327 | * |
| 1328 | * Return value : |
| 1329 | * 0 - Success |
| 1330 | * TODO: What are the failure codes. |
| 1331 | **/ |
| 1332 | static int |
| 1333 | lpfc_nvme_prep_io_dma(struct lpfc_vport *vport, |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 1334 | struct lpfc_io_buf *lpfc_ncmd) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1335 | { |
| 1336 | struct lpfc_hba *phba = vport->phba; |
| 1337 | struct nvmefc_fcp_req *nCmd = lpfc_ncmd->nvmeCmd; |
James Smart | 205e824 | 2018-03-05 12:04:03 -0800 | [diff] [blame] | 1338 | union lpfc_wqe128 *wqe = &lpfc_ncmd->cur_iocbq.wqe; |
James Smart | 0794d60 | 2019-01-28 11:14:19 -0800 | [diff] [blame] | 1339 | struct sli4_sge *sgl = lpfc_ncmd->dma_sgl; |
James Smart | d79c9e9 | 2019-08-14 16:57:09 -0700 | [diff] [blame] | 1340 | struct sli4_hybrid_sgl *sgl_xtra = NULL; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1341 | struct scatterlist *data_sg; |
| 1342 | struct sli4_sge *first_data_sgl; |
James Smart | 0bc2b7c | 2018-02-22 08:18:48 -0800 | [diff] [blame] | 1343 | struct ulp_bde64 *bde; |
James Smart | d79c9e9 | 2019-08-14 16:57:09 -0700 | [diff] [blame] | 1344 | dma_addr_t physaddr = 0; |
James Smart | d79c9e9 | 2019-08-14 16:57:09 -0700 | [diff] [blame] | 1345 | uint32_t dma_len = 0; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1346 | uint32_t dma_offset = 0; |
James Smart | d79c9e9 | 2019-08-14 16:57:09 -0700 | [diff] [blame] | 1347 | int nseg, i, j; |
| 1348 | bool lsp_just_set = false; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1349 | |
| 1350 | /* Fix up the command and response DMA stuff. */ |
| 1351 | lpfc_nvme_adj_fcp_sgls(vport, lpfc_ncmd, nCmd); |
| 1352 | |
| 1353 | /* |
| 1354 | * There are three possibilities here - use scatter-gather segment, use |
| 1355 | * the single mapping, or neither. |
| 1356 | */ |
| 1357 | if (nCmd->sg_cnt) { |
| 1358 | /* |
| 1359 | * Jump over the cmd and rsp SGEs. The fix routine |
| 1360 | * has already adjusted for this. |
| 1361 | */ |
| 1362 | sgl += 2; |
| 1363 | |
| 1364 | first_data_sgl = sgl; |
| 1365 | lpfc_ncmd->seg_cnt = nCmd->sg_cnt; |
James Smart | 81e6a63 | 2017-11-20 16:00:43 -0800 | [diff] [blame] | 1366 | if (lpfc_ncmd->seg_cnt > lpfc_nvme_template.max_sgl_segments) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 1367 | lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1368 | "6058 Too many sg segments from " |
| 1369 | "NVME Transport. Max %d, " |
| 1370 | "nvmeIO sg_cnt %d\n", |
James Smart | 29bfd55 | 2017-09-29 17:34:46 -0700 | [diff] [blame] | 1371 | phba->cfg_nvme_seg_cnt + 1, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1372 | lpfc_ncmd->seg_cnt); |
| 1373 | lpfc_ncmd->seg_cnt = 0; |
| 1374 | return 1; |
| 1375 | } |
| 1376 | |
| 1377 | /* |
| 1378 | * The driver established a maximum scatter-gather segment count |
| 1379 | * during probe that limits the number of sg elements in any |
| 1380 | * single nvme command. Just run through the seg_cnt and format |
| 1381 | * the sge's. |
| 1382 | */ |
| 1383 | nseg = nCmd->sg_cnt; |
| 1384 | data_sg = nCmd->first_sgl; |
James Smart | d79c9e9 | 2019-08-14 16:57:09 -0700 | [diff] [blame] | 1385 | |
| 1386 | /* for tracking the segment boundaries */ |
| 1387 | j = 2; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1388 | for (i = 0; i < nseg; i++) { |
| 1389 | if (data_sg == NULL) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 1390 | lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1391 | "6059 dptr err %d, nseg %d\n", |
| 1392 | i, nseg); |
| 1393 | lpfc_ncmd->seg_cnt = 0; |
| 1394 | return 1; |
| 1395 | } |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1396 | |
James Smart | d79c9e9 | 2019-08-14 16:57:09 -0700 | [diff] [blame] | 1397 | sgl->word2 = 0; |
James Smart | 315b3fd | 2021-09-10 16:31:58 -0700 | [diff] [blame] | 1398 | if (nseg == 1) { |
James Smart | d79c9e9 | 2019-08-14 16:57:09 -0700 | [diff] [blame] | 1399 | bf_set(lpfc_sli4_sge_last, sgl, 1); |
| 1400 | bf_set(lpfc_sli4_sge_type, sgl, |
| 1401 | LPFC_SGE_TYPE_DATA); |
| 1402 | } else { |
| 1403 | bf_set(lpfc_sli4_sge_last, sgl, 0); |
| 1404 | |
| 1405 | /* expand the segment */ |
| 1406 | if (!lsp_just_set && |
| 1407 | !((j + 1) % phba->border_sge_num) && |
| 1408 | ((nseg - 1) != i)) { |
| 1409 | /* set LSP type */ |
| 1410 | bf_set(lpfc_sli4_sge_type, sgl, |
| 1411 | LPFC_SGE_TYPE_LSP); |
| 1412 | |
| 1413 | sgl_xtra = lpfc_get_sgl_per_hdwq( |
| 1414 | phba, lpfc_ncmd); |
| 1415 | |
| 1416 | if (unlikely(!sgl_xtra)) { |
| 1417 | lpfc_ncmd->seg_cnt = 0; |
| 1418 | return 1; |
| 1419 | } |
| 1420 | sgl->addr_lo = cpu_to_le32(putPaddrLow( |
| 1421 | sgl_xtra->dma_phys_sgl)); |
| 1422 | sgl->addr_hi = cpu_to_le32(putPaddrHigh( |
| 1423 | sgl_xtra->dma_phys_sgl)); |
| 1424 | |
| 1425 | } else { |
| 1426 | bf_set(lpfc_sli4_sge_type, sgl, |
| 1427 | LPFC_SGE_TYPE_DATA); |
| 1428 | } |
| 1429 | } |
| 1430 | |
| 1431 | if (!(bf_get(lpfc_sli4_sge_type, sgl) & |
| 1432 | LPFC_SGE_TYPE_LSP)) { |
| 1433 | if ((nseg - 1) == i) |
| 1434 | bf_set(lpfc_sli4_sge_last, sgl, 1); |
| 1435 | |
James Smart | a14396b | 2022-05-05 20:55:18 -0700 | [diff] [blame] | 1436 | physaddr = sg_dma_address(data_sg); |
| 1437 | dma_len = sg_dma_len(data_sg); |
James Smart | d79c9e9 | 2019-08-14 16:57:09 -0700 | [diff] [blame] | 1438 | sgl->addr_lo = cpu_to_le32( |
| 1439 | putPaddrLow(physaddr)); |
| 1440 | sgl->addr_hi = cpu_to_le32( |
| 1441 | putPaddrHigh(physaddr)); |
| 1442 | |
| 1443 | bf_set(lpfc_sli4_sge_offset, sgl, dma_offset); |
| 1444 | sgl->word2 = cpu_to_le32(sgl->word2); |
| 1445 | sgl->sge_len = cpu_to_le32(dma_len); |
| 1446 | |
| 1447 | dma_offset += dma_len; |
| 1448 | data_sg = sg_next(data_sg); |
| 1449 | |
| 1450 | sgl++; |
| 1451 | |
| 1452 | lsp_just_set = false; |
| 1453 | } else { |
| 1454 | sgl->word2 = cpu_to_le32(sgl->word2); |
| 1455 | |
| 1456 | sgl->sge_len = cpu_to_le32( |
| 1457 | phba->cfg_sg_dma_buf_size); |
| 1458 | |
| 1459 | sgl = (struct sli4_sge *)sgl_xtra->dma_sgl; |
| 1460 | i = i - 1; |
| 1461 | |
| 1462 | lsp_just_set = true; |
| 1463 | } |
| 1464 | |
| 1465 | j++; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1466 | } |
James Smart | 315b3fd | 2021-09-10 16:31:58 -0700 | [diff] [blame] | 1467 | |
| 1468 | /* PBDE support for first data SGE only */ |
| 1469 | if (nseg == 1 && phba->cfg_enable_pbde) { |
James Smart | 0bc2b7c | 2018-02-22 08:18:48 -0800 | [diff] [blame] | 1470 | /* Words 13-15 */ |
| 1471 | bde = (struct ulp_bde64 *) |
| 1472 | &wqe->words[13]; |
| 1473 | bde->addrLow = first_data_sgl->addr_lo; |
| 1474 | bde->addrHigh = first_data_sgl->addr_hi; |
| 1475 | bde->tus.f.bdeSize = |
| 1476 | le32_to_cpu(first_data_sgl->sge_len); |
| 1477 | bde->tus.f.bdeFlags = BUFF_TYPE_BDE_64; |
| 1478 | bde->tus.w = cpu_to_le32(bde->tus.w); |
James Smart | b101eb2 | 2020-11-15 11:26:39 -0800 | [diff] [blame] | 1479 | |
James Smart | 315b3fd | 2021-09-10 16:31:58 -0700 | [diff] [blame] | 1480 | /* Word 11 - set PBDE bit */ |
James Smart | b101eb2 | 2020-11-15 11:26:39 -0800 | [diff] [blame] | 1481 | bf_set(wqe_pbde, &wqe->generic.wqe_com, 1); |
James Smart | 5fd1108 | 2018-03-05 12:04:04 -0800 | [diff] [blame] | 1482 | } else { |
| 1483 | memset(&wqe->words[13], 0, (sizeof(uint32_t) * 3)); |
James Smart | 315b3fd | 2021-09-10 16:31:58 -0700 | [diff] [blame] | 1484 | /* Word 11 - PBDE bit disabled by default template */ |
James Smart | 5fd1108 | 2018-03-05 12:04:04 -0800 | [diff] [blame] | 1485 | } |
James Smart | 0bc2b7c | 2018-02-22 08:18:48 -0800 | [diff] [blame] | 1486 | |
James Smart | 414abe0 | 2018-06-26 08:24:26 -0700 | [diff] [blame] | 1487 | } else { |
James Smart | 0794d60 | 2019-01-28 11:14:19 -0800 | [diff] [blame] | 1488 | lpfc_ncmd->seg_cnt = 0; |
| 1489 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1490 | /* For this clause to be valid, the payload_length |
| 1491 | * and sg_cnt must zero. |
| 1492 | */ |
| 1493 | if (nCmd->payload_length != 0) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 1494 | lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1495 | "6063 NVME DMA Prep Err: sg_cnt %d " |
| 1496 | "payload_length x%x\n", |
| 1497 | nCmd->sg_cnt, nCmd->payload_length); |
| 1498 | return 1; |
| 1499 | } |
| 1500 | } |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1501 | return 0; |
| 1502 | } |
| 1503 | |
| 1504 | /** |
| 1505 | * lpfc_nvme_fcp_io_submit - Issue an NVME-over-FCP IO |
Lee Jones | 3e74917 | 2020-11-02 14:23:52 +0000 | [diff] [blame] | 1506 | * @pnvme_lport: Pointer to the driver's local port data |
| 1507 | * @pnvme_rport: Pointer to the rport getting the @lpfc_nvme_ereq |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1508 | * @hw_queue_handle: Driver-returned handle in lpfc_nvme_create_queue |
Lee Jones | 3e74917 | 2020-11-02 14:23:52 +0000 | [diff] [blame] | 1509 | * @pnvme_fcreq: IO request from nvme fc to driver. |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1510 | * |
| 1511 | * Driver registers this routine as it io request handler. This |
| 1512 | * routine issues an fcp WQE with data from the @lpfc_nvme_fcpreq |
Lee Jones | 3e74917 | 2020-11-02 14:23:52 +0000 | [diff] [blame] | 1513 | * data structure to the rport indicated in @lpfc_nvme_rport. |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1514 | * |
| 1515 | * Return value : |
| 1516 | * 0 - Success |
| 1517 | * TODO: What are the failure codes. |
| 1518 | **/ |
| 1519 | static int |
| 1520 | lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port *pnvme_lport, |
| 1521 | struct nvme_fc_remote_port *pnvme_rport, |
| 1522 | void *hw_queue_handle, |
| 1523 | struct nvmefc_fcp_req *pnvme_fcreq) |
| 1524 | { |
| 1525 | int ret = 0; |
James Smart | cf1a1d3 | 2017-12-08 17:18:03 -0800 | [diff] [blame] | 1526 | int expedite = 0; |
James Smart | 63df6d6 | 2019-01-28 11:14:24 -0800 | [diff] [blame] | 1527 | int idx, cpu; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1528 | struct lpfc_nvme_lport *lport; |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1529 | struct lpfc_fc4_ctrl_stat *cstat; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1530 | struct lpfc_vport *vport; |
| 1531 | struct lpfc_hba *phba; |
| 1532 | struct lpfc_nodelist *ndlp; |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 1533 | struct lpfc_io_buf *lpfc_ncmd; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1534 | struct lpfc_nvme_rport *rport; |
| 1535 | struct lpfc_nvme_qhandle *lpfc_queue_info; |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 1536 | struct lpfc_nvme_fcpreq_priv *freqpriv; |
James Smart | cf1a1d3 | 2017-12-08 17:18:03 -0800 | [diff] [blame] | 1537 | struct nvme_common_command *sqe; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1538 | uint64_t start = 0; |
James Smart | 896325a | 2022-05-19 05:31:10 -0700 | [diff] [blame] | 1539 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 1540 | u8 *uuid = NULL; |
| 1541 | int err; |
| 1542 | enum dma_data_direction iodir; |
| 1543 | #endif |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1544 | |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 1545 | /* Validate pointers. LLDD fault handling with transport does |
| 1546 | * have timing races. |
| 1547 | */ |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1548 | lport = (struct lpfc_nvme_lport *)pnvme_lport->private; |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 1549 | if (unlikely(!lport)) { |
| 1550 | ret = -EINVAL; |
| 1551 | goto out_fail; |
| 1552 | } |
| 1553 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1554 | vport = lport->vport; |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 1555 | |
| 1556 | if (unlikely(!hw_queue_handle)) { |
James Smart | 44c2757 | 2018-05-04 20:37:56 -0700 | [diff] [blame] | 1557 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR, |
| 1558 | "6117 Fail IO, NULL hw_queue_handle\n"); |
| 1559 | atomic_inc(&lport->xmt_fcp_err); |
James Smart | cd24007 | 2018-05-04 20:37:50 -0700 | [diff] [blame] | 1560 | ret = -EBUSY; |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 1561 | goto out_fail; |
| 1562 | } |
| 1563 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1564 | phba = vport->phba; |
| 1565 | |
James Smart | a4691038 | 2022-03-16 20:27:35 -0700 | [diff] [blame] | 1566 | if ((unlikely(vport->load_flag & FC_UNLOADING)) || |
| 1567 | phba->hba_flag & HBA_IOQ_FLUSH) { |
James Smart | 44c2757 | 2018-05-04 20:37:56 -0700 | [diff] [blame] | 1568 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR, |
| 1569 | "6124 Fail IO, Driver unload\n"); |
| 1570 | atomic_inc(&lport->xmt_fcp_err); |
James Smart | 3386f4bd | 2017-11-20 16:00:41 -0800 | [diff] [blame] | 1571 | ret = -ENODEV; |
| 1572 | goto out_fail; |
| 1573 | } |
| 1574 | |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 1575 | freqpriv = pnvme_fcreq->private; |
| 1576 | if (unlikely(!freqpriv)) { |
James Smart | 44c2757 | 2018-05-04 20:37:56 -0700 | [diff] [blame] | 1577 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR, |
| 1578 | "6158 Fail IO, NULL request data\n"); |
| 1579 | atomic_inc(&lport->xmt_fcp_err); |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 1580 | ret = -EINVAL; |
Dick Kennedy | b7672ae | 2017-09-29 17:34:41 -0700 | [diff] [blame] | 1581 | goto out_fail; |
| 1582 | } |
| 1583 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1584 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
| 1585 | if (phba->ktime_on) |
| 1586 | start = ktime_get_ns(); |
| 1587 | #endif |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1588 | rport = (struct lpfc_nvme_rport *)pnvme_rport->private; |
| 1589 | lpfc_queue_info = (struct lpfc_nvme_qhandle *)hw_queue_handle; |
| 1590 | |
| 1591 | /* |
| 1592 | * Catch race where our node has transitioned, but the |
| 1593 | * transport is still transitioning. |
| 1594 | */ |
| 1595 | ndlp = rport->ndlp; |
James Smart | 307e338 | 2020-11-15 11:26:30 -0800 | [diff] [blame] | 1596 | if (!ndlp) { |
James Smart | 44c2757 | 2018-05-04 20:37:56 -0700 | [diff] [blame] | 1597 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE | LOG_NVME_IOERR, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 1598 | "6053 Busy IO, ndlp not ready: rport x%px " |
| 1599 | "ndlp x%px, DID x%06x\n", |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1600 | rport, ndlp, pnvme_rport->port_id); |
James Smart | 44c2757 | 2018-05-04 20:37:56 -0700 | [diff] [blame] | 1601 | atomic_inc(&lport->xmt_fcp_err); |
| 1602 | ret = -EBUSY; |
| 1603 | goto out_fail; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1604 | } |
| 1605 | |
| 1606 | /* The remote node has to be a mapped target or it's an error. */ |
| 1607 | if ((ndlp->nlp_type & NLP_NVME_TARGET) && |
| 1608 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) { |
James Smart | 44c2757 | 2018-05-04 20:37:56 -0700 | [diff] [blame] | 1609 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE | LOG_NVME_IOERR, |
| 1610 | "6036 Fail IO, DID x%06x not ready for " |
James Smart | cd24007 | 2018-05-04 20:37:50 -0700 | [diff] [blame] | 1611 | "IO. State x%x, Type x%x Flg x%x\n", |
James Smart | 44c2757 | 2018-05-04 20:37:56 -0700 | [diff] [blame] | 1612 | pnvme_rport->port_id, |
James Smart | cd24007 | 2018-05-04 20:37:50 -0700 | [diff] [blame] | 1613 | ndlp->nlp_state, ndlp->nlp_type, |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 1614 | ndlp->fc4_xpt_flags); |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1615 | atomic_inc(&lport->xmt_fcp_bad_ndlp); |
James Smart | cd24007 | 2018-05-04 20:37:50 -0700 | [diff] [blame] | 1616 | ret = -EBUSY; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1617 | goto out_fail; |
| 1618 | |
| 1619 | } |
| 1620 | |
James Smart | cf1a1d3 | 2017-12-08 17:18:03 -0800 | [diff] [blame] | 1621 | /* Currently only NVME Keep alive commands should be expedited |
| 1622 | * if the driver runs out of a resource. These should only be |
| 1623 | * issued on the admin queue, qidx 0 |
| 1624 | */ |
| 1625 | if (!lpfc_queue_info->qidx && !pnvme_fcreq->sg_cnt) { |
| 1626 | sqe = &((struct nvme_fc_cmd_iu *) |
| 1627 | pnvme_fcreq->cmdaddr)->sqe.common; |
| 1628 | if (sqe->opcode == nvme_admin_keep_alive) |
| 1629 | expedite = 1; |
| 1630 | } |
| 1631 | |
James Smart | 0224383 | 2021-08-16 09:28:54 -0700 | [diff] [blame] | 1632 | /* Check if IO qualifies for CMF */ |
| 1633 | if (phba->cmf_active_mode != LPFC_CFG_OFF && |
| 1634 | pnvme_fcreq->io_dir == NVMEFC_FCP_READ && |
| 1635 | pnvme_fcreq->payload_length) { |
| 1636 | ret = lpfc_update_cmf_cmd(phba, pnvme_fcreq->payload_length); |
| 1637 | if (ret) { |
| 1638 | ret = -EBUSY; |
| 1639 | goto out_fail; |
| 1640 | } |
| 1641 | /* Get start time for IO latency */ |
| 1642 | start = ktime_get_ns(); |
| 1643 | } |
| 1644 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1645 | /* The node is shared with FCP IO, make sure the IO pending count does |
| 1646 | * not exceed the programmed depth. |
| 1647 | */ |
James Smart | 2a5b7d6 | 2018-07-31 17:23:22 -0700 | [diff] [blame] | 1648 | if (lpfc_ndlp_check_qdepth(phba, ndlp)) { |
| 1649 | if ((atomic_read(&ndlp->cmd_pending) >= ndlp->cmd_qdepth) && |
| 1650 | !expedite) { |
| 1651 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR, |
| 1652 | "6174 Fail IO, ndlp qdepth exceeded: " |
| 1653 | "idx %d DID %x pend %d qdepth %d\n", |
| 1654 | lpfc_queue_info->index, ndlp->nlp_DID, |
| 1655 | atomic_read(&ndlp->cmd_pending), |
| 1656 | ndlp->cmd_qdepth); |
| 1657 | atomic_inc(&lport->xmt_fcp_qdepth); |
| 1658 | ret = -EBUSY; |
James Smart | 0224383 | 2021-08-16 09:28:54 -0700 | [diff] [blame] | 1659 | goto out_fail1; |
James Smart | 2a5b7d6 | 2018-07-31 17:23:22 -0700 | [diff] [blame] | 1660 | } |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1661 | } |
| 1662 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 1663 | /* Lookup Hardware Queue index based on fcp_io_sched module parameter */ |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 1664 | if (phba->cfg_fcp_io_sched == LPFC_FCP_SCHED_BY_HDWQ) { |
| 1665 | idx = lpfc_queue_info->index; |
| 1666 | } else { |
Bart Van Assche | d6d189c | 2019-03-28 11:06:22 -0700 | [diff] [blame] | 1667 | cpu = raw_smp_processor_id(); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 1668 | idx = phba->sli4_hba.cpu_map[cpu].hdwq; |
James Smart | 45aa312 | 2019-01-28 11:14:29 -0800 | [diff] [blame] | 1669 | } |
| 1670 | |
| 1671 | lpfc_ncmd = lpfc_get_nvme_buf(phba, ndlp, idx, expedite); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1672 | if (lpfc_ncmd == NULL) { |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1673 | atomic_inc(&lport->xmt_fcp_noxri); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1674 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR, |
James Smart | 44c2757 | 2018-05-04 20:37:56 -0700 | [diff] [blame] | 1675 | "6065 Fail IO, driver buffer pool is empty: " |
| 1676 | "idx %d DID %x\n", |
| 1677 | lpfc_queue_info->index, ndlp->nlp_DID); |
Dick Kennedy | cd22d60 | 2017-08-23 16:55:35 -0700 | [diff] [blame] | 1678 | ret = -EBUSY; |
James Smart | 0224383 | 2021-08-16 09:28:54 -0700 | [diff] [blame] | 1679 | goto out_fail1; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1680 | } |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1681 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
Dick Kennedy | c8a4ce0 | 2017-09-29 17:34:33 -0700 | [diff] [blame] | 1682 | if (start) { |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1683 | lpfc_ncmd->ts_cmd_start = start; |
| 1684 | lpfc_ncmd->ts_last_cmd = phba->ktime_last_cmd; |
Dick Kennedy | c8a4ce0 | 2017-09-29 17:34:33 -0700 | [diff] [blame] | 1685 | } else { |
| 1686 | lpfc_ncmd->ts_cmd_start = 0; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1687 | } |
| 1688 | #endif |
James Smart | 0224383 | 2021-08-16 09:28:54 -0700 | [diff] [blame] | 1689 | lpfc_ncmd->rx_cmd_start = start; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1690 | |
| 1691 | /* |
| 1692 | * Store the data needed by the driver to issue, abort, and complete |
| 1693 | * an IO. |
| 1694 | * Do not let the IO hang out forever. There is no midlayer issuing |
| 1695 | * an abort so inform the FW of the maximum IO pending time. |
| 1696 | */ |
James Smart | bbe3012 | 2017-04-21 17:49:08 -0700 | [diff] [blame] | 1697 | freqpriv->nvme_buf = lpfc_ncmd; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1698 | lpfc_ncmd->nvmeCmd = pnvme_fcreq; |
James Smart | 318083a | 2017-03-04 09:30:30 -0800 | [diff] [blame] | 1699 | lpfc_ncmd->ndlp = ndlp; |
James Smart | 0794d60 | 2019-01-28 11:14:19 -0800 | [diff] [blame] | 1700 | lpfc_ncmd->qidx = lpfc_queue_info->qidx; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1701 | |
James Smart | 896325a | 2022-05-19 05:31:10 -0700 | [diff] [blame] | 1702 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 1703 | /* check the necessary and sufficient condition to support VMID */ |
| 1704 | if (lpfc_is_vmid_enabled(phba) && |
| 1705 | (ndlp->vmid_support || |
| 1706 | phba->pport->vmid_priority_tagging == |
| 1707 | LPFC_VMID_PRIO_TAG_ALL_TARGETS)) { |
| 1708 | /* is the I/O generated by a VM, get the associated virtual */ |
| 1709 | /* entity id */ |
| 1710 | uuid = nvme_fc_io_getuuid(pnvme_fcreq); |
| 1711 | |
| 1712 | if (uuid) { |
| 1713 | if (pnvme_fcreq->io_dir == NVMEFC_FCP_WRITE) |
| 1714 | iodir = DMA_TO_DEVICE; |
| 1715 | else if (pnvme_fcreq->io_dir == NVMEFC_FCP_READ) |
| 1716 | iodir = DMA_FROM_DEVICE; |
| 1717 | else |
| 1718 | iodir = DMA_NONE; |
| 1719 | |
| 1720 | err = lpfc_vmid_get_appid(vport, uuid, iodir, |
| 1721 | (union lpfc_vmid_io_tag *) |
| 1722 | &lpfc_ncmd->cur_iocbq.vmid_tag); |
| 1723 | if (!err) |
| 1724 | lpfc_ncmd->cur_iocbq.cmd_flag |= LPFC_IO_VMID; |
| 1725 | } |
| 1726 | } |
| 1727 | #endif |
| 1728 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1729 | /* |
| 1730 | * Issue the IO on the WQ indicated by index in the hw_queue_handle. |
| 1731 | * This identfier was create in our hardware queue create callback |
| 1732 | * routine. The driver now is dependent on the IO queue steering from |
| 1733 | * the transport. We are trusting the upper NVME layers know which |
| 1734 | * index to use and that they have affinitized a CPU to this hardware |
| 1735 | * queue. A hardware queue maps to a driver MSI-X vector/EQ/CQ/WQ. |
| 1736 | */ |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 1737 | lpfc_ncmd->cur_iocbq.hba_wqidx = idx; |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1738 | cstat = &phba->sli4_hba.hdwq[idx].nvme_cstat; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 1739 | |
| 1740 | lpfc_nvme_prep_io_cmd(vport, lpfc_ncmd, ndlp, cstat); |
| 1741 | ret = lpfc_nvme_prep_io_dma(vport, lpfc_ncmd); |
| 1742 | if (ret) { |
James Smart | 44c2757 | 2018-05-04 20:37:56 -0700 | [diff] [blame] | 1743 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR, |
| 1744 | "6175 Fail IO, Prep DMA: " |
| 1745 | "idx %d DID %x\n", |
| 1746 | lpfc_queue_info->index, ndlp->nlp_DID); |
| 1747 | atomic_inc(&lport->xmt_fcp_err); |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 1748 | ret = -ENOMEM; |
| 1749 | goto out_free_nvme_buf; |
| 1750 | } |
| 1751 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1752 | lpfc_nvmeio_data(phba, "NVME FCP XMIT: xri x%x idx %d to %06x\n", |
| 1753 | lpfc_ncmd->cur_iocbq.sli4_xritag, |
| 1754 | lpfc_queue_info->index, ndlp->nlp_DID); |
| 1755 | |
James Smart | 1fbf974 | 2019-01-28 11:14:26 -0800 | [diff] [blame] | 1756 | ret = lpfc_sli4_issue_wqe(phba, lpfc_ncmd->hdwq, &lpfc_ncmd->cur_iocbq); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1757 | if (ret) { |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1758 | atomic_inc(&lport->xmt_fcp_wqerr); |
James Smart | e3246a1 | 2017-09-29 17:34:36 -0700 | [diff] [blame] | 1759 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR, |
James Smart | 44c2757 | 2018-05-04 20:37:56 -0700 | [diff] [blame] | 1760 | "6113 Fail IO, Could not issue WQE err %x " |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1761 | "sid: x%x did: x%x oxid: x%x\n", |
| 1762 | ret, vport->fc_myDID, ndlp->nlp_DID, |
| 1763 | lpfc_ncmd->cur_iocbq.sli4_xritag); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1764 | goto out_free_nvme_buf; |
| 1765 | } |
| 1766 | |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 1767 | if (phba->cfg_xri_rebalancing) |
| 1768 | lpfc_keep_pvt_pool_above_lowwm(phba, lpfc_ncmd->hdwq_no); |
| 1769 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1770 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
Dick Kennedy | c8a4ce0 | 2017-09-29 17:34:33 -0700 | [diff] [blame] | 1771 | if (lpfc_ncmd->ts_cmd_start) |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1772 | lpfc_ncmd->ts_cmd_wqput = ktime_get_ns(); |
| 1773 | |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1774 | if (phba->hdwqstat_on & LPFC_CHECK_NVME_IO) { |
Bart Van Assche | d6d189c | 2019-03-28 11:06:22 -0700 | [diff] [blame] | 1775 | cpu = raw_smp_processor_id(); |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1776 | this_cpu_inc(phba->sli4_hba.c_stat->xmt_io); |
| 1777 | lpfc_ncmd->cpu = cpu; |
| 1778 | if (idx != cpu) |
| 1779 | lpfc_printf_vlog(vport, |
| 1780 | KERN_INFO, LOG_NVME_IOERR, |
| 1781 | "6702 CPU Check cmd: " |
| 1782 | "cpu %d wq %d\n", |
| 1783 | lpfc_ncmd->cpu, |
| 1784 | lpfc_queue_info->index); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1785 | } |
| 1786 | #endif |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1787 | return 0; |
| 1788 | |
| 1789 | out_free_nvme_buf: |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 1790 | if (lpfc_ncmd->nvmeCmd->sg_cnt) { |
| 1791 | if (lpfc_ncmd->nvmeCmd->io_dir == NVMEFC_FCP_WRITE) |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1792 | cstat->output_requests--; |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 1793 | else |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1794 | cstat->input_requests--; |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 1795 | } else |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1796 | cstat->control_requests--; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1797 | lpfc_release_nvme_buf(phba, lpfc_ncmd); |
James Smart | 0224383 | 2021-08-16 09:28:54 -0700 | [diff] [blame] | 1798 | out_fail1: |
| 1799 | lpfc_update_cmf_cmpl(phba, LPFC_CGN_NOT_SENT, |
| 1800 | pnvme_fcreq->payload_length, NULL); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1801 | out_fail: |
| 1802 | return ret; |
| 1803 | } |
| 1804 | |
| 1805 | /** |
| 1806 | * lpfc_nvme_abort_fcreq_cmpl - Complete an NVME FCP abort request. |
| 1807 | * @phba: Pointer to HBA context object |
| 1808 | * @cmdiocb: Pointer to command iocb object. |
James Smart | 24e1f05 | 2022-06-03 10:43:22 -0700 | [diff] [blame] | 1809 | * @rspiocb: Pointer to response iocb object. |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1810 | * |
| 1811 | * This is the callback function for any NVME FCP IO that was aborted. |
| 1812 | * |
| 1813 | * Return value: |
| 1814 | * None |
| 1815 | **/ |
| 1816 | void |
| 1817 | lpfc_nvme_abort_fcreq_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
James Smart | 24e1f05 | 2022-06-03 10:43:22 -0700 | [diff] [blame] | 1818 | struct lpfc_iocbq *rspiocb) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1819 | { |
James Smart | 24e1f05 | 2022-06-03 10:43:22 -0700 | [diff] [blame] | 1820 | struct lpfc_wcqe_complete *abts_cmpl = &rspiocb->wcqe_cmpl; |
| 1821 | |
James Smart | e3246a1 | 2017-09-29 17:34:36 -0700 | [diff] [blame] | 1822 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1823 | "6145 ABORT_XRI_CN completing on rpi x%x " |
| 1824 | "original iotag x%x, abort cmd iotag x%x " |
| 1825 | "req_tag x%x, status x%x, hwstatus x%x\n", |
James Smart | 31a59f75 | 2022-02-24 18:23:05 -0800 | [diff] [blame] | 1826 | bf_get(wqe_ctxt_tag, &cmdiocb->wqe.generic.wqe_com), |
| 1827 | get_job_abtsiotag(phba, cmdiocb), cmdiocb->iotag, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1828 | bf_get(lpfc_wcqe_c_request_tag, abts_cmpl), |
| 1829 | bf_get(lpfc_wcqe_c_status, abts_cmpl), |
| 1830 | bf_get(lpfc_wcqe_c_hw_status, abts_cmpl)); |
| 1831 | lpfc_sli_release_iocbq(phba, cmdiocb); |
| 1832 | } |
| 1833 | |
| 1834 | /** |
| 1835 | * lpfc_nvme_fcp_abort - Issue an NVME-over-FCP ABTS |
Lee Jones | 3e74917 | 2020-11-02 14:23:52 +0000 | [diff] [blame] | 1836 | * @pnvme_lport: Pointer to the driver's local port data |
| 1837 | * @pnvme_rport: Pointer to the rport getting the @lpfc_nvme_ereq |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1838 | * @hw_queue_handle: Driver-returned handle in lpfc_nvme_create_queue |
Lee Jones | 3e74917 | 2020-11-02 14:23:52 +0000 | [diff] [blame] | 1839 | * @pnvme_fcreq: IO request from nvme fc to driver. |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1840 | * |
| 1841 | * Driver registers this routine as its nvme request io abort handler. This |
| 1842 | * routine issues an fcp Abort WQE with data from the @lpfc_nvme_fcpreq |
| 1843 | * data structure to the rport indicated in @lpfc_nvme_rport. This routine |
| 1844 | * is executed asynchronously - one the target is validated as "MAPPED" and |
| 1845 | * ready for IO, the driver issues the abort request and returns. |
| 1846 | * |
| 1847 | * Return value: |
| 1848 | * None |
| 1849 | **/ |
| 1850 | static void |
| 1851 | lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport, |
| 1852 | struct nvme_fc_remote_port *pnvme_rport, |
| 1853 | void *hw_queue_handle, |
| 1854 | struct nvmefc_fcp_req *pnvme_fcreq) |
| 1855 | { |
| 1856 | struct lpfc_nvme_lport *lport; |
| 1857 | struct lpfc_vport *vport; |
| 1858 | struct lpfc_hba *phba; |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 1859 | struct lpfc_io_buf *lpfc_nbuf; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1860 | struct lpfc_iocbq *nvmereq_wqe; |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 1861 | struct lpfc_nvme_fcpreq_priv *freqpriv; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1862 | unsigned long flags; |
| 1863 | int ret_val; |
James Smart | ea7bd1f | 2022-06-03 10:43:27 -0700 | [diff] [blame] | 1864 | struct nvme_fc_cmd_iu *cp; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1865 | |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 1866 | /* Validate pointers. LLDD fault handling with transport does |
| 1867 | * have timing races. |
| 1868 | */ |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1869 | lport = (struct lpfc_nvme_lport *)pnvme_lport->private; |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 1870 | if (unlikely(!lport)) |
| 1871 | return; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1872 | |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 1873 | vport = lport->vport; |
| 1874 | |
| 1875 | if (unlikely(!hw_queue_handle)) { |
| 1876 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_ABTS, |
| 1877 | "6129 Fail Abort, HW Queue Handle NULL.\n"); |
| 1878 | return; |
| 1879 | } |
| 1880 | |
| 1881 | phba = vport->phba; |
| 1882 | freqpriv = pnvme_fcreq->private; |
| 1883 | |
| 1884 | if (unlikely(!freqpriv)) |
| 1885 | return; |
James Smart | 3386f4bd | 2017-11-20 16:00:41 -0800 | [diff] [blame] | 1886 | if (vport->load_flag & FC_UNLOADING) |
| 1887 | return; |
| 1888 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1889 | /* Announce entry to new IO submit field. */ |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1890 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_ABTS, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1891 | "6002 Abort Request to rport DID x%06x " |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 1892 | "for nvme_fc_req x%px\n", |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1893 | pnvme_rport->port_id, |
| 1894 | pnvme_fcreq); |
| 1895 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1896 | /* If the hba is getting reset, this flag is set. It is |
| 1897 | * cleared when the reset is complete and rings reestablished. |
| 1898 | */ |
| 1899 | spin_lock_irqsave(&phba->hbalock, flags); |
| 1900 | /* driver queued commands are in process of being flushed */ |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 1901 | if (phba->hba_flag & HBA_IOQ_FLUSH) { |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1902 | spin_unlock_irqrestore(&phba->hbalock, flags); |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 1903 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1904 | "6139 Driver in reset cleanup - flushing " |
| 1905 | "NVME Req now. hba_flag x%x\n", |
| 1906 | phba->hba_flag); |
| 1907 | return; |
| 1908 | } |
| 1909 | |
James Smart | bbe3012 | 2017-04-21 17:49:08 -0700 | [diff] [blame] | 1910 | lpfc_nbuf = freqpriv->nvme_buf; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1911 | if (!lpfc_nbuf) { |
| 1912 | spin_unlock_irqrestore(&phba->hbalock, flags); |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 1913 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1914 | "6140 NVME IO req has no matching lpfc nvme " |
| 1915 | "io buffer. Skipping abort req.\n"); |
| 1916 | return; |
| 1917 | } else if (!lpfc_nbuf->nvmeCmd) { |
| 1918 | spin_unlock_irqrestore(&phba->hbalock, flags); |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 1919 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1920 | "6141 lpfc NVME IO req has no nvme_fcreq " |
| 1921 | "io buffer. Skipping abort req.\n"); |
| 1922 | return; |
| 1923 | } |
James Smart | 2b7824d | 2017-04-21 16:04:59 -0700 | [diff] [blame] | 1924 | nvmereq_wqe = &lpfc_nbuf->cur_iocbq; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1925 | |
James Smart | c201726 | 2019-01-28 11:14:37 -0800 | [diff] [blame] | 1926 | /* Guard against IO completion being called at same time */ |
| 1927 | spin_lock(&lpfc_nbuf->buf_lock); |
| 1928 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1929 | /* |
| 1930 | * The lpfc_nbuf and the mapped nvme_fcreq in the driver's |
| 1931 | * state must match the nvme_fcreq passed by the nvme |
| 1932 | * transport. If they don't match, it is likely the driver |
| 1933 | * has already completed the NVME IO and the nvme transport |
| 1934 | * has not seen it yet. |
| 1935 | */ |
| 1936 | if (lpfc_nbuf->nvmeCmd != pnvme_fcreq) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 1937 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1938 | "6143 NVME req mismatch: " |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 1939 | "lpfc_nbuf x%px nvmeCmd x%px, " |
| 1940 | "pnvme_fcreq x%px. Skipping Abort xri x%x\n", |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1941 | lpfc_nbuf, lpfc_nbuf->nvmeCmd, |
James Smart | 2b7824d | 2017-04-21 16:04:59 -0700 | [diff] [blame] | 1942 | pnvme_fcreq, nvmereq_wqe->sli4_xritag); |
James Smart | c201726 | 2019-01-28 11:14:37 -0800 | [diff] [blame] | 1943 | goto out_unlock; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1944 | } |
| 1945 | |
| 1946 | /* Don't abort IOs no longer on the pending queue. */ |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 1947 | if (!(nvmereq_wqe->cmd_flag & LPFC_IO_ON_TXCMPLQ)) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 1948 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 1949 | "6142 NVME IO req x%px not queued - skipping " |
James Smart | 2b7824d | 2017-04-21 16:04:59 -0700 | [diff] [blame] | 1950 | "abort req xri x%x\n", |
| 1951 | pnvme_fcreq, nvmereq_wqe->sli4_xritag); |
James Smart | c201726 | 2019-01-28 11:14:37 -0800 | [diff] [blame] | 1952 | goto out_unlock; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1953 | } |
| 1954 | |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1955 | atomic_inc(&lport->xmt_fcp_abort); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1956 | lpfc_nvmeio_data(phba, "NVME FCP ABORT: xri x%x idx %d to %06x\n", |
| 1957 | nvmereq_wqe->sli4_xritag, |
James Smart | 00cefeb | 2017-06-21 10:37:58 -0700 | [diff] [blame] | 1958 | nvmereq_wqe->hba_wqidx, pnvme_rport->port_id); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1959 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1960 | /* Outstanding abort is in progress */ |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 1961 | if (nvmereq_wqe->cmd_flag & LPFC_DRIVER_ABORTED) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 1962 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1963 | "6144 Outstanding NVME I/O Abort Request " |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 1964 | "still pending on nvme_fcreq x%px, " |
James Smart | f115612 | 2021-04-11 18:31:24 -0700 | [diff] [blame] | 1965 | "lpfc_ncmd x%px xri x%x\n", |
James Smart | 2b7824d | 2017-04-21 16:04:59 -0700 | [diff] [blame] | 1966 | pnvme_fcreq, lpfc_nbuf, |
| 1967 | nvmereq_wqe->sli4_xritag); |
James Smart | c201726 | 2019-01-28 11:14:37 -0800 | [diff] [blame] | 1968 | goto out_unlock; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1969 | } |
| 1970 | |
James Smart | db7531d | 2020-11-15 11:26:44 -0800 | [diff] [blame] | 1971 | ret_val = lpfc_sli4_issue_abort_iotag(phba, nvmereq_wqe, |
| 1972 | lpfc_nvme_abort_fcreq_cmpl); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1973 | |
James Smart | c201726 | 2019-01-28 11:14:37 -0800 | [diff] [blame] | 1974 | spin_unlock(&lpfc_nbuf->buf_lock); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1975 | spin_unlock_irqrestore(&phba->hbalock, flags); |
James Smart | a22d73b | 2021-01-04 10:02:38 -0800 | [diff] [blame] | 1976 | |
| 1977 | /* Make sure HBA is alive */ |
| 1978 | lpfc_issue_hb_tmo(phba); |
| 1979 | |
James Smart | db7531d | 2020-11-15 11:26:44 -0800 | [diff] [blame] | 1980 | if (ret_val != WQE_SUCCESS) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 1981 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1982 | "6137 Failed abts issue_wqe with status x%x " |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 1983 | "for nvme_fcreq x%px.\n", |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1984 | ret_val, pnvme_fcreq); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 1985 | return; |
| 1986 | } |
| 1987 | |
James Smart | ea7bd1f | 2022-06-03 10:43:27 -0700 | [diff] [blame] | 1988 | /* |
| 1989 | * Get Command Id from cmd to plug into response. This |
| 1990 | * code is not needed in the next NVME Transport drop. |
| 1991 | */ |
| 1992 | cp = (struct nvme_fc_cmd_iu *)lpfc_nbuf->nvmeCmd->cmdaddr; |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1993 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_ABTS, |
James Smart | 2b7824d | 2017-04-21 16:04:59 -0700 | [diff] [blame] | 1994 | "6138 Transport Abort NVME Request Issued for " |
James Smart | ea7bd1f | 2022-06-03 10:43:27 -0700 | [diff] [blame] | 1995 | "ox_id x%x nvme opcode x%x nvme cmd_id x%x\n", |
| 1996 | nvmereq_wqe->sli4_xritag, cp->sqe.common.opcode, |
| 1997 | cp->sqe.common.command_id); |
James Smart | c201726 | 2019-01-28 11:14:37 -0800 | [diff] [blame] | 1998 | return; |
| 1999 | |
| 2000 | out_unlock: |
| 2001 | spin_unlock(&lpfc_nbuf->buf_lock); |
| 2002 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| 2003 | return; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2004 | } |
| 2005 | |
| 2006 | /* Declare and initialization an instance of the FC NVME template. */ |
| 2007 | static struct nvme_fc_port_template lpfc_nvme_template = { |
| 2008 | /* initiator-based functions */ |
| 2009 | .localport_delete = lpfc_nvme_localport_delete, |
| 2010 | .remoteport_delete = lpfc_nvme_remoteport_delete, |
| 2011 | .create_queue = lpfc_nvme_create_queue, |
| 2012 | .delete_queue = lpfc_nvme_delete_queue, |
| 2013 | .ls_req = lpfc_nvme_ls_req, |
| 2014 | .fcp_io = lpfc_nvme_fcp_io_submit, |
| 2015 | .ls_abort = lpfc_nvme_ls_abort, |
| 2016 | .fcp_abort = lpfc_nvme_fcp_abort, |
James Smart | 9aa09e9 | 2020-03-31 09:50:09 -0700 | [diff] [blame] | 2017 | .xmt_ls_rsp = lpfc_nvme_xmt_ls_rsp, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2018 | |
| 2019 | .max_hw_queues = 1, |
| 2020 | .max_sgl_segments = LPFC_NVME_DEFAULT_SEGS, |
| 2021 | .max_dif_sgl_segments = LPFC_NVME_DEFAULT_SEGS, |
| 2022 | .dma_boundary = 0xFFFFFFFF, |
| 2023 | |
| 2024 | /* Sizes of additional private data for data structures. |
| 2025 | * No use for the last two sizes at this time. |
| 2026 | */ |
| 2027 | .local_priv_sz = sizeof(struct lpfc_nvme_lport), |
| 2028 | .remote_priv_sz = sizeof(struct lpfc_nvme_rport), |
| 2029 | .lsrqst_priv_sz = 0, |
James Smart | bbe3012 | 2017-04-21 17:49:08 -0700 | [diff] [blame] | 2030 | .fcprqst_priv_sz = sizeof(struct lpfc_nvme_fcpreq_priv), |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2031 | }; |
| 2032 | |
Lee Jones | 3e74917 | 2020-11-02 14:23:52 +0000 | [diff] [blame] | 2033 | /* |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2034 | * lpfc_get_nvme_buf - Get a nvme buffer from io_buf_list of the HBA |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2035 | * |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2036 | * This routine removes a nvme buffer from head of @hdwq io_buf_list |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2037 | * and returns to caller. |
| 2038 | * |
| 2039 | * Return codes: |
| 2040 | * NULL - Error |
| 2041 | * Pointer to lpfc_nvme_buf - Success |
| 2042 | **/ |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2043 | static struct lpfc_io_buf * |
James Smart | cf1a1d3 | 2017-12-08 17:18:03 -0800 | [diff] [blame] | 2044 | lpfc_get_nvme_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2045 | int idx, int expedite) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2046 | { |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2047 | struct lpfc_io_buf *lpfc_ncmd; |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2048 | struct lpfc_sli4_hdw_queue *qp; |
James Smart | 0794d60 | 2019-01-28 11:14:19 -0800 | [diff] [blame] | 2049 | struct sli4_sge *sgl; |
| 2050 | struct lpfc_iocbq *pwqeq; |
| 2051 | union lpfc_wqe128 *wqe; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2052 | |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2053 | lpfc_ncmd = lpfc_get_io_buf(phba, NULL, idx, expedite); |
James Smart | 2a5b7d6 | 2018-07-31 17:23:22 -0700 | [diff] [blame] | 2054 | |
James Smart | 0794d60 | 2019-01-28 11:14:19 -0800 | [diff] [blame] | 2055 | if (lpfc_ncmd) { |
| 2056 | pwqeq = &(lpfc_ncmd->cur_iocbq); |
| 2057 | wqe = &pwqeq->wqe; |
| 2058 | |
| 2059 | /* Setup key fields in buffer that may have been changed |
| 2060 | * if other protocols used this buffer. |
| 2061 | */ |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 2062 | pwqeq->cmd_flag = LPFC_IO_NVME; |
| 2063 | pwqeq->cmd_cmpl = lpfc_nvme_io_cmd_cmpl; |
James Smart | 0794d60 | 2019-01-28 11:14:19 -0800 | [diff] [blame] | 2064 | lpfc_ncmd->start_time = jiffies; |
| 2065 | lpfc_ncmd->flags = 0; |
| 2066 | |
| 2067 | /* Rsp SGE will be filled in when we rcv an IO |
| 2068 | * from the NVME Layer to be sent. |
| 2069 | * The cmd is going to be embedded so we need a SKIP SGE. |
| 2070 | */ |
| 2071 | sgl = lpfc_ncmd->dma_sgl; |
| 2072 | bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_SKIP); |
| 2073 | bf_set(lpfc_sli4_sge_last, sgl, 0); |
| 2074 | sgl->word2 = cpu_to_le32(sgl->word2); |
| 2075 | /* Fill in word 3 / sgl_len during cmd submission */ |
| 2076 | |
James Smart | d9f492a | 2019-08-14 16:57:04 -0700 | [diff] [blame] | 2077 | /* Initialize 64 bytes only */ |
James Smart | 0794d60 | 2019-01-28 11:14:19 -0800 | [diff] [blame] | 2078 | memset(wqe, 0, sizeof(union lpfc_wqe)); |
| 2079 | |
| 2080 | if (lpfc_ndlp_check_qdepth(phba, ndlp)) { |
| 2081 | atomic_inc(&ndlp->cmd_pending); |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2082 | lpfc_ncmd->flags |= LPFC_SBUF_BUMP_QDEPTH; |
James Smart | 0794d60 | 2019-01-28 11:14:19 -0800 | [diff] [blame] | 2083 | } |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2084 | |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2085 | } else { |
| 2086 | qp = &phba->sli4_hba.hdwq[idx]; |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2087 | qp->empty_io_bufs++; |
James Smart | 2a5b7d6 | 2018-07-31 17:23:22 -0700 | [diff] [blame] | 2088 | } |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2089 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2090 | return lpfc_ncmd; |
| 2091 | } |
| 2092 | |
| 2093 | /** |
| 2094 | * lpfc_release_nvme_buf: Return a nvme buffer back to hba nvme buf list. |
| 2095 | * @phba: The Hba for which this call is being executed. |
| 2096 | * @lpfc_ncmd: The nvme buffer which is being released. |
| 2097 | * |
| 2098 | * This routine releases @lpfc_ncmd nvme buffer by adding it to tail of @phba |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2099 | * lpfc_io_buf_list list. For SLI4 XRI's are tied to the nvme buffer |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2100 | * and cannot be reused for at least RA_TOV amount of time if it was |
| 2101 | * aborted. |
| 2102 | **/ |
| 2103 | static void |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2104 | lpfc_release_nvme_buf(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_ncmd) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2105 | { |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2106 | struct lpfc_sli4_hdw_queue *qp; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2107 | unsigned long iflag = 0; |
| 2108 | |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2109 | if ((lpfc_ncmd->flags & LPFC_SBUF_BUMP_QDEPTH) && lpfc_ncmd->ndlp) |
James Smart | 2a5b7d6 | 2018-07-31 17:23:22 -0700 | [diff] [blame] | 2110 | atomic_dec(&lpfc_ncmd->ndlp->cmd_pending); |
| 2111 | |
James Smart | 2a5b7d6 | 2018-07-31 17:23:22 -0700 | [diff] [blame] | 2112 | lpfc_ncmd->ndlp = NULL; |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2113 | lpfc_ncmd->flags &= ~LPFC_SBUF_BUMP_QDEPTH; |
James Smart | 2a5b7d6 | 2018-07-31 17:23:22 -0700 | [diff] [blame] | 2114 | |
James Smart | 1fbf974 | 2019-01-28 11:14:26 -0800 | [diff] [blame] | 2115 | qp = lpfc_ncmd->hdwq; |
James Smart | 22770cb | 2019-10-18 14:18:24 -0700 | [diff] [blame] | 2116 | if (unlikely(lpfc_ncmd->flags & LPFC_SBUF_XBUSY)) { |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 2117 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS, |
| 2118 | "6310 XB release deferred for " |
| 2119 | "ox_id x%x on reqtag x%x\n", |
| 2120 | lpfc_ncmd->cur_iocbq.sli4_xritag, |
| 2121 | lpfc_ncmd->cur_iocbq.iotag); |
| 2122 | |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 2123 | spin_lock_irqsave(&qp->abts_io_buf_list_lock, iflag); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2124 | list_add_tail(&lpfc_ncmd->list, |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 2125 | &qp->lpfc_abts_io_buf_list); |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2126 | qp->abts_nvme_io_bufs++; |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 2127 | spin_unlock_irqrestore(&qp->abts_io_buf_list_lock, iflag); |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2128 | } else |
| 2129 | lpfc_release_io_buf(phba, (struct lpfc_io_buf *)lpfc_ncmd, qp); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2130 | } |
| 2131 | |
| 2132 | /** |
| 2133 | * lpfc_nvme_create_localport - Create/Bind an nvme localport instance. |
Lee Jones | f6b35a7 | 2021-03-12 09:47:23 +0000 | [diff] [blame] | 2134 | * @vport: the lpfc_vport instance requesting a localport. |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2135 | * |
| 2136 | * This routine is invoked to create an nvme localport instance to bind |
| 2137 | * to the nvme_fc_transport. It is called once during driver load |
| 2138 | * like lpfc_create_shost after all other services are initialized. |
| 2139 | * It requires a vport, vpi, and wwns at call time. Other localport |
| 2140 | * parameters are modified as the driver's FCID and the Fabric WWN |
| 2141 | * are established. |
| 2142 | * |
| 2143 | * Return codes |
| 2144 | * 0 - successful |
| 2145 | * -ENOMEM - no heap memory available |
| 2146 | * other values - from nvme registration upcall |
| 2147 | **/ |
| 2148 | int |
| 2149 | lpfc_nvme_create_localport(struct lpfc_vport *vport) |
| 2150 | { |
James Smart | 166d721 | 2017-03-04 09:30:33 -0800 | [diff] [blame] | 2151 | int ret = 0; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2152 | struct lpfc_hba *phba = vport->phba; |
| 2153 | struct nvme_fc_port_info nfcp_info; |
| 2154 | struct nvme_fc_local_port *localport; |
| 2155 | struct lpfc_nvme_lport *lport; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2156 | |
| 2157 | /* Initialize this localport instance. The vport wwn usage ensures |
| 2158 | * that NPIV is accounted for. |
| 2159 | */ |
| 2160 | memset(&nfcp_info, 0, sizeof(struct nvme_fc_port_info)); |
| 2161 | nfcp_info.port_role = FC_PORT_ROLE_NVME_INITIATOR; |
| 2162 | nfcp_info.node_name = wwn_to_u64(vport->fc_nodename.u.wwn); |
| 2163 | nfcp_info.port_name = wwn_to_u64(vport->fc_portname.u.wwn); |
| 2164 | |
James Smart | 5b9e70b | 2018-09-10 10:30:42 -0700 | [diff] [blame] | 2165 | /* We need to tell the transport layer + 1 because it takes page |
| 2166 | * alignment into account. When space for the SGL is allocated we |
| 2167 | * allocate + 3, one for cmd, one for rsp and one for this alignment |
James Smart | 4d4c4a4 | 2017-04-21 16:05:01 -0700 | [diff] [blame] | 2168 | */ |
James Smart | 4d4c4a4 | 2017-04-21 16:05:01 -0700 | [diff] [blame] | 2169 | lpfc_nvme_template.max_sgl_segments = phba->cfg_nvme_seg_cnt + 1; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2170 | |
James Smart | 542ddc9 | 2019-11-11 15:04:00 -0800 | [diff] [blame] | 2171 | /* Advertise how many hw queues we support based on cfg_hdw_queue, |
| 2172 | * which will not exceed cpu count. |
| 2173 | */ |
| 2174 | lpfc_nvme_template.max_hw_queues = phba->cfg_hdw_queue; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 2175 | |
Arnd Bergmann | faf5a744f | 2019-03-22 15:25:49 +0100 | [diff] [blame] | 2176 | if (!IS_ENABLED(CONFIG_NVME_FC)) |
| 2177 | return ret; |
| 2178 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2179 | /* localport is allocated from the stack, but the registration |
| 2180 | * call allocates heap memory as well as the private area. |
| 2181 | */ |
Arnd Bergmann | faf5a744f | 2019-03-22 15:25:49 +0100 | [diff] [blame] | 2182 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2183 | ret = nvme_fc_register_localport(&nfcp_info, &lpfc_nvme_template, |
| 2184 | &vport->phba->pcidev->dev, &localport); |
| 2185 | if (!ret) { |
| 2186 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME | LOG_NVME_DISC, |
| 2187 | "6005 Successfully registered local " |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 2188 | "NVME port num %d, localP x%px, private " |
| 2189 | "x%px, sg_seg %d\n", |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2190 | localport->port_num, localport, |
| 2191 | localport->private, |
| 2192 | lpfc_nvme_template.max_sgl_segments); |
| 2193 | |
| 2194 | /* Private is our lport size declared in the template. */ |
| 2195 | lport = (struct lpfc_nvme_lport *)localport->private; |
| 2196 | vport->localport = localport; |
| 2197 | lport->vport = vport; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2198 | vport->nvmei_support = 1; |
Dick Kennedy | 6b486ce | 2017-08-23 16:55:45 -0700 | [diff] [blame] | 2199 | |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 2200 | atomic_set(&lport->xmt_fcp_noxri, 0); |
| 2201 | atomic_set(&lport->xmt_fcp_bad_ndlp, 0); |
| 2202 | atomic_set(&lport->xmt_fcp_qdepth, 0); |
James Smart | 44c2757 | 2018-05-04 20:37:56 -0700 | [diff] [blame] | 2203 | atomic_set(&lport->xmt_fcp_err, 0); |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 2204 | atomic_set(&lport->xmt_fcp_wqerr, 0); |
| 2205 | atomic_set(&lport->xmt_fcp_abort, 0); |
| 2206 | atomic_set(&lport->xmt_ls_abort, 0); |
| 2207 | atomic_set(&lport->xmt_ls_err, 0); |
| 2208 | atomic_set(&lport->cmpl_fcp_xb, 0); |
| 2209 | atomic_set(&lport->cmpl_fcp_err, 0); |
| 2210 | atomic_set(&lport->cmpl_ls_xb, 0); |
| 2211 | atomic_set(&lport->cmpl_ls_err, 0); |
James Smart | 9aa09e9 | 2020-03-31 09:50:09 -0700 | [diff] [blame] | 2212 | |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 2213 | atomic_set(&lport->fc4NvmeLsRequests, 0); |
| 2214 | atomic_set(&lport->fc4NvmeLsCmpls, 0); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2215 | } |
| 2216 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2217 | return ret; |
| 2218 | } |
| 2219 | |
Bart Van Assche | d964b3e | 2019-04-05 09:14:10 -0700 | [diff] [blame] | 2220 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 2221 | /* lpfc_nvme_lport_unreg_wait - Wait for the host to complete an lport unreg. |
| 2222 | * |
| 2223 | * The driver has to wait for the host nvme transport to callback |
| 2224 | * indicating the localport has successfully unregistered all |
| 2225 | * resources. Since this is an uninterruptible wait, loop every ten |
| 2226 | * seconds and print a message indicating no progress. |
| 2227 | * |
| 2228 | * An uninterruptible wait is used because of the risk of transport-to- |
| 2229 | * driver state mismatch. |
| 2230 | */ |
Bart Van Assche | 3999df7 | 2019-03-28 11:06:16 -0700 | [diff] [blame] | 2231 | static void |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 2232 | lpfc_nvme_lport_unreg_wait(struct lpfc_vport *vport, |
Ewan D. Milne | 7961cba6f | 2019-01-17 11:14:44 -0500 | [diff] [blame] | 2233 | struct lpfc_nvme_lport *lport, |
| 2234 | struct completion *lport_unreg_cmp) |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 2235 | { |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 2236 | u32 wait_tmo; |
James Smart | 2ab70c2 | 2019-05-21 17:48:54 -0700 | [diff] [blame] | 2237 | int ret, i, pending = 0; |
| 2238 | struct lpfc_sli_ring *pring; |
| 2239 | struct lpfc_hba *phba = vport->phba; |
James Smart | e7dab16 | 2020-10-20 13:27:12 -0700 | [diff] [blame] | 2240 | struct lpfc_sli4_hdw_queue *qp; |
| 2241 | int abts_scsi, abts_nvme; |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 2242 | |
| 2243 | /* Host transport has to clean up and confirm requiring an indefinite |
| 2244 | * wait. Print a message if a 10 second wait expires and renew the |
| 2245 | * wait. This is unexpected. |
| 2246 | */ |
| 2247 | wait_tmo = msecs_to_jiffies(LPFC_NVME_WAIT_TMO * 1000); |
| 2248 | while (true) { |
Ewan D. Milne | 7961cba6f | 2019-01-17 11:14:44 -0500 | [diff] [blame] | 2249 | ret = wait_for_completion_timeout(lport_unreg_cmp, wait_tmo); |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 2250 | if (unlikely(!ret)) { |
James Smart | 2ab70c2 | 2019-05-21 17:48:54 -0700 | [diff] [blame] | 2251 | pending = 0; |
James Smart | e7dab16 | 2020-10-20 13:27:12 -0700 | [diff] [blame] | 2252 | abts_scsi = 0; |
| 2253 | abts_nvme = 0; |
James Smart | 2ab70c2 | 2019-05-21 17:48:54 -0700 | [diff] [blame] | 2254 | for (i = 0; i < phba->cfg_hdw_queue; i++) { |
James Smart | e7dab16 | 2020-10-20 13:27:12 -0700 | [diff] [blame] | 2255 | qp = &phba->sli4_hba.hdwq[i]; |
James Smart | 35ed961 | 2022-03-16 20:27:34 -0700 | [diff] [blame] | 2256 | if (!vport->localport || !qp || !qp->io_wq) |
James Smart | 25ac2c97 | 2021-09-10 16:31:54 -0700 | [diff] [blame] | 2257 | return; |
| 2258 | |
James Smart | e7dab16 | 2020-10-20 13:27:12 -0700 | [diff] [blame] | 2259 | pring = qp->io_wq->pring; |
James Smart | 2ab70c2 | 2019-05-21 17:48:54 -0700 | [diff] [blame] | 2260 | if (!pring) |
| 2261 | continue; |
James Smart | e7dab16 | 2020-10-20 13:27:12 -0700 | [diff] [blame] | 2262 | pending += pring->txcmplq_cnt; |
| 2263 | abts_scsi += qp->abts_scsi_io_bufs; |
| 2264 | abts_nvme += qp->abts_nvme_io_bufs; |
James Smart | 2ab70c2 | 2019-05-21 17:48:54 -0700 | [diff] [blame] | 2265 | } |
James Smart | 35ed961 | 2022-03-16 20:27:34 -0700 | [diff] [blame] | 2266 | if (!vport->localport || |
| 2267 | test_bit(HBA_PCI_ERR, &vport->phba->bit_flags) || |
Justin Tee | 27c2bcf | 2023-03-01 15:16:23 -0800 | [diff] [blame] | 2268 | phba->link_state == LPFC_HBA_ERROR || |
James Smart | 35ed961 | 2022-03-16 20:27:34 -0700 | [diff] [blame] | 2269 | vport->load_flag & FC_UNLOADING) |
James Smart | 25ac2c97 | 2021-09-10 16:31:54 -0700 | [diff] [blame] | 2270 | return; |
| 2271 | |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 2272 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 2273 | "6176 Lport x%px Localport x%px wait " |
James Smart | e7dab16 | 2020-10-20 13:27:12 -0700 | [diff] [blame] | 2274 | "timed out. Pending %d [%d:%d]. " |
| 2275 | "Renewing.\n", |
| 2276 | lport, vport->localport, pending, |
| 2277 | abts_scsi, abts_nvme); |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 2278 | continue; |
| 2279 | } |
| 2280 | break; |
| 2281 | } |
| 2282 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 2283 | "6177 Lport x%px Localport x%px Complete Success\n", |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 2284 | lport, vport->localport); |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 2285 | } |
Bart Van Assche | d964b3e | 2019-04-05 09:14:10 -0700 | [diff] [blame] | 2286 | #endif |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 2287 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2288 | /** |
| 2289 | * lpfc_nvme_destroy_localport - Destroy lpfc_nvme bound to nvme transport. |
Lee Jones | 3e74917 | 2020-11-02 14:23:52 +0000 | [diff] [blame] | 2290 | * @vport: pointer to a host virtual N_Port data structure |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2291 | * |
| 2292 | * This routine is invoked to destroy all lports bound to the phba. |
| 2293 | * The lport memory was allocated by the nvme fc transport and is |
| 2294 | * released there. This routine ensures all rports bound to the |
| 2295 | * lport have been disconnected. |
| 2296 | * |
| 2297 | **/ |
| 2298 | void |
| 2299 | lpfc_nvme_destroy_localport(struct lpfc_vport *vport) |
| 2300 | { |
James Smart | 7d70803 | 2017-03-08 14:36:01 -0800 | [diff] [blame] | 2301 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2302 | struct nvme_fc_local_port *localport; |
| 2303 | struct lpfc_nvme_lport *lport; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2304 | int ret; |
Ewan D. Milne | 7961cba6f | 2019-01-17 11:14:44 -0500 | [diff] [blame] | 2305 | DECLARE_COMPLETION_ONSTACK(lport_unreg_cmp); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2306 | |
| 2307 | if (vport->nvmei_support == 0) |
| 2308 | return; |
| 2309 | |
| 2310 | localport = vport->localport; |
James Smart | 25ac2c97 | 2021-09-10 16:31:54 -0700 | [diff] [blame] | 2311 | if (!localport) |
| 2312 | return; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2313 | lport = (struct lpfc_nvme_lport *)localport->private; |
| 2314 | |
| 2315 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 2316 | "6011 Destroying NVME localport x%px\n", |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2317 | localport); |
James Smart | 166d721 | 2017-03-04 09:30:33 -0800 | [diff] [blame] | 2318 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2319 | /* lport's rport list is clear. Unregister |
| 2320 | * lport and release resources. |
| 2321 | */ |
Ewan D. Milne | 7961cba6f | 2019-01-17 11:14:44 -0500 | [diff] [blame] | 2322 | lport->lport_unreg_cmp = &lport_unreg_cmp; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2323 | ret = nvme_fc_unregister_localport(localport); |
James Smart | add9d6b | 2017-11-20 16:00:40 -0800 | [diff] [blame] | 2324 | |
| 2325 | /* Wait for completion. This either blocks |
| 2326 | * indefinitely or succeeds |
| 2327 | */ |
Ewan D. Milne | 7961cba6f | 2019-01-17 11:14:44 -0500 | [diff] [blame] | 2328 | lpfc_nvme_lport_unreg_wait(vport, lport, &lport_unreg_cmp); |
| 2329 | vport->localport = NULL; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2330 | |
| 2331 | /* Regardless of the unregister upcall response, clear |
| 2332 | * nvmei_support. All rports are unregistered and the |
| 2333 | * driver will clean up. |
| 2334 | */ |
| 2335 | vport->nvmei_support = 0; |
| 2336 | if (ret == 0) { |
| 2337 | lpfc_printf_vlog(vport, |
| 2338 | KERN_INFO, LOG_NVME_DISC, |
| 2339 | "6009 Unregistered lport Success\n"); |
| 2340 | } else { |
| 2341 | lpfc_printf_vlog(vport, |
| 2342 | KERN_INFO, LOG_NVME_DISC, |
| 2343 | "6010 Unregistered lport " |
| 2344 | "Failed, status x%x\n", |
| 2345 | ret); |
| 2346 | } |
James Smart | 166d721 | 2017-03-04 09:30:33 -0800 | [diff] [blame] | 2347 | #endif |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2348 | } |
| 2349 | |
| 2350 | void |
| 2351 | lpfc_nvme_update_localport(struct lpfc_vport *vport) |
| 2352 | { |
James Smart | 4410a67 | 2017-04-21 16:04:57 -0700 | [diff] [blame] | 2353 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2354 | struct nvme_fc_local_port *localport; |
| 2355 | struct lpfc_nvme_lport *lport; |
| 2356 | |
| 2357 | localport = vport->localport; |
James Smart | 4410a67 | 2017-04-21 16:04:57 -0700 | [diff] [blame] | 2358 | if (!localport) { |
| 2359 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_NVME, |
| 2360 | "6710 Update NVME fail. No localport\n"); |
| 2361 | return; |
| 2362 | } |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2363 | lport = (struct lpfc_nvme_lport *)localport->private; |
James Smart | 4410a67 | 2017-04-21 16:04:57 -0700 | [diff] [blame] | 2364 | if (!lport) { |
| 2365 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_NVME, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 2366 | "6171 Update NVME fail. localP x%px, No lport\n", |
James Smart | 4410a67 | 2017-04-21 16:04:57 -0700 | [diff] [blame] | 2367 | localport); |
| 2368 | return; |
| 2369 | } |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2370 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 2371 | "6012 Update NVME lport x%px did x%x\n", |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2372 | localport, vport->fc_myDID); |
| 2373 | |
| 2374 | localport->port_id = vport->fc_myDID; |
| 2375 | if (localport->port_id == 0) |
| 2376 | localport->port_role = FC_PORT_ROLE_NVME_DISCOVERY; |
| 2377 | else |
| 2378 | localport->port_role = FC_PORT_ROLE_NVME_INITIATOR; |
| 2379 | |
| 2380 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 2381 | "6030 bound lport x%px to DID x%06x\n", |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2382 | lport, localport->port_id); |
James Smart | 4410a67 | 2017-04-21 16:04:57 -0700 | [diff] [blame] | 2383 | #endif |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2384 | } |
| 2385 | |
| 2386 | int |
| 2387 | lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) |
| 2388 | { |
James Smart | 7d70803 | 2017-03-08 14:36:01 -0800 | [diff] [blame] | 2389 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2390 | int ret = 0; |
| 2391 | struct nvme_fc_local_port *localport; |
| 2392 | struct lpfc_nvme_lport *lport; |
| 2393 | struct lpfc_nvme_rport *rport; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 2394 | struct lpfc_nvme_rport *oldrport; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2395 | struct nvme_fc_remote_port *remote_port; |
| 2396 | struct nvme_fc_port_info rpinfo; |
James Smart | 93a3922 | 2018-07-31 17:23:21 -0700 | [diff] [blame] | 2397 | struct lpfc_nodelist *prev_ndlp = NULL; |
James Smart | 1f54682 | 2020-07-14 14:14:12 -0700 | [diff] [blame] | 2398 | struct fc_rport *srport = ndlp->rport; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2399 | |
| 2400 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NVME_DISC, |
| 2401 | "6006 Register NVME PORT. DID x%06x nlptype x%x\n", |
| 2402 | ndlp->nlp_DID, ndlp->nlp_type); |
| 2403 | |
| 2404 | localport = vport->localport; |
Dick Kennedy | bb6a8a2 | 2017-08-23 16:55:33 -0700 | [diff] [blame] | 2405 | if (!localport) |
| 2406 | return 0; |
| 2407 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2408 | lport = (struct lpfc_nvme_lport *)localport->private; |
| 2409 | |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 2410 | /* NVME rports are not preserved across devloss. |
| 2411 | * Just register this instance. Note, rpinfo->dev_loss_tmo |
| 2412 | * is left 0 to indicate accept transport defaults. The |
| 2413 | * driver communicates port role capabilities consistent |
| 2414 | * with the PRLI response data. |
| 2415 | */ |
| 2416 | memset(&rpinfo, 0, sizeof(struct nvme_fc_port_info)); |
| 2417 | rpinfo.port_id = ndlp->nlp_DID; |
| 2418 | if (ndlp->nlp_type & NLP_NVME_TARGET) |
| 2419 | rpinfo.port_role |= FC_PORT_ROLE_NVME_TARGET; |
| 2420 | if (ndlp->nlp_type & NLP_NVME_INITIATOR) |
| 2421 | rpinfo.port_role |= FC_PORT_ROLE_NVME_INITIATOR; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2422 | |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 2423 | if (ndlp->nlp_type & NLP_NVME_DISCOVERY) |
| 2424 | rpinfo.port_role |= FC_PORT_ROLE_NVME_DISCOVERY; |
| 2425 | |
| 2426 | rpinfo.port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn); |
| 2427 | rpinfo.node_name = wwn_to_u64(ndlp->nlp_nodename.u.wwn); |
James Smart | 1f54682 | 2020-07-14 14:14:12 -0700 | [diff] [blame] | 2428 | if (srport) |
| 2429 | rpinfo.dev_loss_tmo = srport->dev_loss_tmo; |
| 2430 | else |
| 2431 | rpinfo.dev_loss_tmo = vport->cfg_devloss_tmo; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 2432 | |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 2433 | spin_lock_irq(&ndlp->lock); |
James Smart | ba3d58a | 2022-05-05 20:55:09 -0700 | [diff] [blame] | 2434 | |
| 2435 | /* If an oldrport exists, so does the ndlp reference. If not |
| 2436 | * a new reference is needed because either the node has never |
| 2437 | * been registered or it's been unregistered and getting deleted. |
| 2438 | */ |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 2439 | oldrport = lpfc_ndlp_get_nrport(ndlp); |
James Smart | 61184f1 | 2019-08-14 16:56:41 -0700 | [diff] [blame] | 2440 | if (oldrport) { |
| 2441 | prev_ndlp = oldrport->ndlp; |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 2442 | spin_unlock_irq(&ndlp->lock); |
James Smart | 61184f1 | 2019-08-14 16:56:41 -0700 | [diff] [blame] | 2443 | } else { |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 2444 | spin_unlock_irq(&ndlp->lock); |
James Smart | 4430f7f | 2020-11-15 11:26:31 -0800 | [diff] [blame] | 2445 | if (!lpfc_nlp_get(ndlp)) { |
| 2446 | dev_warn(&vport->phba->pcidev->dev, |
| 2447 | "Warning - No node ref - exit register\n"); |
| 2448 | return 0; |
| 2449 | } |
James Smart | 61184f1 | 2019-08-14 16:56:41 -0700 | [diff] [blame] | 2450 | } |
James Smart | 3fd7835 | 2017-12-08 17:18:09 -0800 | [diff] [blame] | 2451 | |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 2452 | ret = nvme_fc_register_remoteport(localport, &rpinfo, &remote_port); |
| 2453 | if (!ret) { |
| 2454 | /* If the ndlp already has an nrport, this is just |
| 2455 | * a resume of the existing rport. Else this is a |
| 2456 | * new rport. |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2457 | */ |
James Smart | b15bd3e | 2018-04-09 14:24:30 -0700 | [diff] [blame] | 2458 | /* Guard against an unregister/reregister |
| 2459 | * race that leaves the WAIT flag set. |
| 2460 | */ |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 2461 | spin_lock_irq(&ndlp->lock); |
James Smart | 0614568 | 2021-07-07 11:43:46 -0700 | [diff] [blame] | 2462 | ndlp->fc4_xpt_flags &= ~NVME_XPT_UNREG_WAIT; |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 2463 | ndlp->fc4_xpt_flags |= NVME_XPT_REGD; |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 2464 | spin_unlock_irq(&ndlp->lock); |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 2465 | rport = remote_port->private; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 2466 | if (oldrport) { |
Dick Kennedy | 2b75d0f | 2017-09-29 17:34:30 -0700 | [diff] [blame] | 2467 | |
James Smart | 3fd7835 | 2017-12-08 17:18:09 -0800 | [diff] [blame] | 2468 | /* Sever the ndlp<->rport association |
| 2469 | * before dropping the ndlp ref from |
| 2470 | * register. |
Dick Kennedy | 2b75d0f | 2017-09-29 17:34:30 -0700 | [diff] [blame] | 2471 | */ |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 2472 | spin_lock_irq(&ndlp->lock); |
Dick Kennedy | 2b75d0f | 2017-09-29 17:34:30 -0700 | [diff] [blame] | 2473 | ndlp->nrport = NULL; |
James Smart | 0614568 | 2021-07-07 11:43:46 -0700 | [diff] [blame] | 2474 | ndlp->fc4_xpt_flags &= ~NVME_XPT_UNREG_WAIT; |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 2475 | spin_unlock_irq(&ndlp->lock); |
Dick Kennedy | 2b75d0f | 2017-09-29 17:34:30 -0700 | [diff] [blame] | 2476 | rport->ndlp = NULL; |
James Smart | 3fd7835 | 2017-12-08 17:18:09 -0800 | [diff] [blame] | 2477 | rport->remoteport = NULL; |
James Smart | b04744c | 2018-04-09 14:24:29 -0700 | [diff] [blame] | 2478 | |
| 2479 | /* Reference only removed if previous NDLP is no longer |
| 2480 | * active. It might be just a swap and removing the |
| 2481 | * reference would cause a premature cleanup. |
| 2482 | */ |
| 2483 | if (prev_ndlp && prev_ndlp != ndlp) { |
James Smart | 307e338 | 2020-11-15 11:26:30 -0800 | [diff] [blame] | 2484 | if (!prev_ndlp->nrport) |
James Smart | b04744c | 2018-04-09 14:24:29 -0700 | [diff] [blame] | 2485 | lpfc_nlp_put(prev_ndlp); |
| 2486 | } |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2487 | } |
Dick Kennedy | 2b75d0f | 2017-09-29 17:34:30 -0700 | [diff] [blame] | 2488 | |
| 2489 | /* Clean bind the rport to the ndlp. */ |
| 2490 | rport->remoteport = remote_port; |
| 2491 | rport->lport = lport; |
James Smart | 3fd7835 | 2017-12-08 17:18:09 -0800 | [diff] [blame] | 2492 | rport->ndlp = ndlp; |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 2493 | spin_lock_irq(&ndlp->lock); |
Dick Kennedy | 2b75d0f | 2017-09-29 17:34:30 -0700 | [diff] [blame] | 2494 | ndlp->nrport = rport; |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 2495 | spin_unlock_irq(&ndlp->lock); |
Dick Kennedy | 2b75d0f | 2017-09-29 17:34:30 -0700 | [diff] [blame] | 2496 | lpfc_printf_vlog(vport, KERN_INFO, |
| 2497 | LOG_NVME_DISC | LOG_NODE, |
James Smart | 6825b7b | 2019-08-14 16:56:51 -0700 | [diff] [blame] | 2498 | "6022 Bind lport x%px to remoteport x%px " |
| 2499 | "rport x%px WWNN 0x%llx, " |
Dick Kennedy | 2b75d0f | 2017-09-29 17:34:30 -0700 | [diff] [blame] | 2500 | "Rport WWPN 0x%llx DID " |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 2501 | "x%06x Role x%x, ndlp %p prev_ndlp x%px\n", |
James Smart | 93a3922 | 2018-07-31 17:23:21 -0700 | [diff] [blame] | 2502 | lport, remote_port, rport, |
Dick Kennedy | 2b75d0f | 2017-09-29 17:34:30 -0700 | [diff] [blame] | 2503 | rpinfo.node_name, rpinfo.port_name, |
James Smart | 3fd7835 | 2017-12-08 17:18:09 -0800 | [diff] [blame] | 2504 | rpinfo.port_id, rpinfo.port_role, |
James Smart | 93a3922 | 2018-07-31 17:23:21 -0700 | [diff] [blame] | 2505 | ndlp, prev_ndlp); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2506 | } else { |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 2507 | lpfc_printf_vlog(vport, KERN_ERR, |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 2508 | LOG_TRACE_EVENT, |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 2509 | "6031 RemotePort Registration failed " |
| 2510 | "err: %d, DID x%06x\n", |
| 2511 | ret, ndlp->nlp_DID); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2512 | } |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 2513 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2514 | return ret; |
James Smart | 166d721 | 2017-03-04 09:30:33 -0800 | [diff] [blame] | 2515 | #else |
| 2516 | return 0; |
| 2517 | #endif |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2518 | } |
| 2519 | |
Lee Jones | 3e74917 | 2020-11-02 14:23:52 +0000 | [diff] [blame] | 2520 | /* |
James Smart | 6f2589f | 2019-05-14 14:58:07 -0700 | [diff] [blame] | 2521 | * lpfc_nvme_rescan_port - Check to see if we should rescan this remoteport |
| 2522 | * |
| 2523 | * If the ndlp represents an NVME Target, that we are logged into, |
| 2524 | * ping the NVME FC Transport layer to initiate a device rescan |
| 2525 | * on this remote NPort. |
| 2526 | */ |
| 2527 | void |
| 2528 | lpfc_nvme_rescan_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) |
| 2529 | { |
| 2530 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
James Smart | a6d10f2 | 2019-08-14 16:56:50 -0700 | [diff] [blame] | 2531 | struct lpfc_nvme_rport *nrport; |
| 2532 | struct nvme_fc_remote_port *remoteport = NULL; |
James Smart | 6f2589f | 2019-05-14 14:58:07 -0700 | [diff] [blame] | 2533 | |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 2534 | spin_lock_irq(&ndlp->lock); |
James Smart | a6d10f2 | 2019-08-14 16:56:50 -0700 | [diff] [blame] | 2535 | nrport = lpfc_ndlp_get_nrport(ndlp); |
| 2536 | if (nrport) |
| 2537 | remoteport = nrport->remoteport; |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 2538 | spin_unlock_irq(&ndlp->lock); |
James Smart | 6f2589f | 2019-05-14 14:58:07 -0700 | [diff] [blame] | 2539 | |
| 2540 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC, |
| 2541 | "6170 Rescan NPort DID x%06x type x%x " |
James Smart | a6d10f2 | 2019-08-14 16:56:50 -0700 | [diff] [blame] | 2542 | "state x%x nrport x%px remoteport x%px\n", |
| 2543 | ndlp->nlp_DID, ndlp->nlp_type, ndlp->nlp_state, |
| 2544 | nrport, remoteport); |
| 2545 | |
| 2546 | if (!nrport || !remoteport) |
| 2547 | goto rescan_exit; |
James Smart | 6f2589f | 2019-05-14 14:58:07 -0700 | [diff] [blame] | 2548 | |
James Smart | b83a8c2 | 2022-04-12 15:19:43 -0700 | [diff] [blame] | 2549 | /* Rescan an NVME target in MAPPED state with DISCOVERY role set */ |
James Smart | 6f2589f | 2019-05-14 14:58:07 -0700 | [diff] [blame] | 2550 | if (remoteport->port_role & FC_PORT_ROLE_NVME_DISCOVERY && |
| 2551 | ndlp->nlp_state == NLP_STE_MAPPED_NODE) { |
| 2552 | nvme_fc_rescan_remoteport(remoteport); |
| 2553 | |
James Smart | b83a8c2 | 2022-04-12 15:19:43 -0700 | [diff] [blame] | 2554 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC, |
James Smart | 6f2589f | 2019-05-14 14:58:07 -0700 | [diff] [blame] | 2555 | "6172 NVME rescanned DID x%06x " |
| 2556 | "port_state x%x\n", |
| 2557 | ndlp->nlp_DID, remoteport->port_state); |
| 2558 | } |
| 2559 | return; |
James Smart | a6d10f2 | 2019-08-14 16:56:50 -0700 | [diff] [blame] | 2560 | rescan_exit: |
| 2561 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC, |
| 2562 | "6169 Skip NVME Rport Rescan, NVME remoteport " |
| 2563 | "unregistered\n"); |
James Smart | 6f2589f | 2019-05-14 14:58:07 -0700 | [diff] [blame] | 2564 | #endif |
| 2565 | } |
| 2566 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2567 | /* lpfc_nvme_unregister_port - unbind the DID and port_role from this rport. |
| 2568 | * |
| 2569 | * There is no notion of Devloss or rport recovery from the current |
| 2570 | * nvme_transport perspective. Loss of an rport just means IO cannot |
| 2571 | * be sent and recovery is completely up to the initator. |
| 2572 | * For now, the driver just unbinds the DID and port_role so that |
| 2573 | * no further IO can be issued. Changes are planned for later. |
| 2574 | * |
| 2575 | * Notes - the ndlp reference count is not decremented here since |
| 2576 | * since there is no nvme_transport api for devloss. Node ref count |
| 2577 | * is only adjusted in driver unload. |
| 2578 | */ |
| 2579 | void |
| 2580 | lpfc_nvme_unregister_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) |
| 2581 | { |
James Smart | 7d70803 | 2017-03-08 14:36:01 -0800 | [diff] [blame] | 2582 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2583 | int ret; |
| 2584 | struct nvme_fc_local_port *localport; |
| 2585 | struct lpfc_nvme_lport *lport; |
| 2586 | struct lpfc_nvme_rport *rport; |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 2587 | struct nvme_fc_remote_port *remoteport = NULL; |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2588 | |
| 2589 | localport = vport->localport; |
| 2590 | |
| 2591 | /* This is fundamental error. The localport is always |
| 2592 | * available until driver unload. Just exit. |
| 2593 | */ |
| 2594 | if (!localport) |
| 2595 | return; |
| 2596 | |
| 2597 | lport = (struct lpfc_nvme_lport *)localport->private; |
| 2598 | if (!lport) |
| 2599 | goto input_err; |
| 2600 | |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 2601 | spin_lock_irq(&ndlp->lock); |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 2602 | rport = lpfc_ndlp_get_nrport(ndlp); |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 2603 | if (rport) |
| 2604 | remoteport = rport->remoteport; |
James Smart | c6adba1 | 2020-11-15 11:26:34 -0800 | [diff] [blame] | 2605 | spin_unlock_irq(&ndlp->lock); |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 2606 | if (!remoteport) |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2607 | goto input_err; |
| 2608 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2609 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 2610 | "6033 Unreg nvme remoteport x%px, portname x%llx, " |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 2611 | "port_id x%06x, portstate x%x port type x%x " |
| 2612 | "refcnt %d\n", |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2613 | remoteport, remoteport->port_name, |
| 2614 | remoteport->port_id, remoteport->port_state, |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 2615 | ndlp->nlp_type, kref_read(&ndlp->kref)); |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2616 | |
| 2617 | /* Sanity check ndlp type. Only call for NVME ports. Don't |
| 2618 | * clear any rport state until the transport calls back. |
| 2619 | */ |
James Smart | 3b5bde69 | 2017-11-20 16:00:39 -0800 | [diff] [blame] | 2620 | |
| 2621 | if (ndlp->nlp_type & NLP_NVME_TARGET) { |
James Smart | 7a06dcd | 2017-06-01 21:06:55 -0700 | [diff] [blame] | 2622 | /* No concern about the role change on the nvme remoteport. |
| 2623 | * The transport will update it. |
| 2624 | */ |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 2625 | spin_lock_irq(&vport->phba->hbalock); |
James Smart | 0614568 | 2021-07-07 11:43:46 -0700 | [diff] [blame] | 2626 | ndlp->fc4_xpt_flags |= NVME_XPT_UNREG_WAIT; |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 2627 | spin_unlock_irq(&vport->phba->hbalock); |
James Smart | 7438273 | 2018-05-24 21:08:59 -0700 | [diff] [blame] | 2628 | |
| 2629 | /* Don't let the host nvme transport keep sending keep-alives |
| 2630 | * on this remoteport. Vport is unloading, no recovery. The |
| 2631 | * return values is ignored. The upcall is a courtesy to the |
| 2632 | * transport. |
| 2633 | */ |
Justin Tee | 27c2bcf | 2023-03-01 15:16:23 -0800 | [diff] [blame] | 2634 | if (vport->load_flag & FC_UNLOADING || |
| 2635 | unlikely(vport->phba->link_state == LPFC_HBA_ERROR)) |
James Smart | 7438273 | 2018-05-24 21:08:59 -0700 | [diff] [blame] | 2636 | (void)nvme_fc_set_remoteport_devloss(remoteport, 0); |
| 2637 | |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2638 | ret = nvme_fc_unregister_remoteport(remoteport); |
James Smart | e9b1108 | 2020-11-15 11:26:33 -0800 | [diff] [blame] | 2639 | |
| 2640 | /* The driver no longer knows if the nrport memory is valid. |
| 2641 | * because the controller teardown process has begun and |
| 2642 | * is asynchronous. Break the binding in the ndlp. Also |
| 2643 | * remove the register ndlp reference to setup node release. |
| 2644 | */ |
| 2645 | ndlp->nrport = NULL; |
| 2646 | lpfc_nlp_put(ndlp); |
James Smart | 3fd7835 | 2017-12-08 17:18:09 -0800 | [diff] [blame] | 2647 | if (ret != 0) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 2648 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2649 | "6167 NVME unregister failed %d " |
| 2650 | "port_state x%x\n", |
| 2651 | ret, remoteport->port_state); |
James Smart | 3fd7835 | 2017-12-08 17:18:09 -0800 | [diff] [blame] | 2652 | } |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2653 | } |
| 2654 | return; |
| 2655 | |
| 2656 | input_err: |
James Smart | 166d721 | 2017-03-04 09:30:33 -0800 | [diff] [blame] | 2657 | #endif |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 2658 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 2659 | "6168 State error: lport x%px, rport x%px FCID x%06x\n", |
James Smart | 0164956 | 2017-02-12 13:52:32 -0800 | [diff] [blame] | 2660 | vport->localport, ndlp->rport, ndlp->nlp_DID); |
| 2661 | } |
James Smart | 318083a | 2017-03-04 09:30:30 -0800 | [diff] [blame] | 2662 | |
| 2663 | /** |
James Smart | 25ac2c97 | 2021-09-10 16:31:54 -0700 | [diff] [blame] | 2664 | * lpfc_sli4_nvme_pci_offline_aborted - Fast-path process of NVME xri abort |
| 2665 | * @phba: pointer to lpfc hba data structure. |
| 2666 | * @lpfc_ncmd: The nvme job structure for the request being aborted. |
| 2667 | * |
| 2668 | * This routine is invoked by the worker thread to process a SLI4 fast-path |
| 2669 | * NVME aborted xri. Aborted NVME IO commands are completed to the transport |
| 2670 | * here. |
| 2671 | **/ |
| 2672 | void |
| 2673 | lpfc_sli4_nvme_pci_offline_aborted(struct lpfc_hba *phba, |
| 2674 | struct lpfc_io_buf *lpfc_ncmd) |
| 2675 | { |
| 2676 | struct nvmefc_fcp_req *nvme_cmd = NULL; |
| 2677 | |
| 2678 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS, |
| 2679 | "6533 %s nvme_cmd %p tag x%x abort complete and " |
| 2680 | "xri released\n", __func__, |
| 2681 | lpfc_ncmd->nvmeCmd, |
| 2682 | lpfc_ncmd->cur_iocbq.iotag); |
| 2683 | |
| 2684 | /* Aborted NVME commands are required to not complete |
| 2685 | * before the abort exchange command fully completes. |
| 2686 | * Once completed, it is available via the put list. |
| 2687 | */ |
| 2688 | if (lpfc_ncmd->nvmeCmd) { |
| 2689 | nvme_cmd = lpfc_ncmd->nvmeCmd; |
| 2690 | nvme_cmd->transferred_length = 0; |
| 2691 | nvme_cmd->rcv_rsplen = 0; |
| 2692 | nvme_cmd->status = NVME_SC_INTERNAL; |
| 2693 | nvme_cmd->done(nvme_cmd); |
| 2694 | lpfc_ncmd->nvmeCmd = NULL; |
| 2695 | } |
| 2696 | lpfc_release_nvme_buf(phba, lpfc_ncmd); |
| 2697 | } |
| 2698 | |
| 2699 | /** |
James Smart | 318083a | 2017-03-04 09:30:30 -0800 | [diff] [blame] | 2700 | * lpfc_sli4_nvme_xri_aborted - Fast-path process of NVME xri abort |
| 2701 | * @phba: pointer to lpfc hba data structure. |
| 2702 | * @axri: pointer to the fcp xri abort wcqe structure. |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 2703 | * @lpfc_ncmd: The nvme job structure for the request being aborted. |
James Smart | 318083a | 2017-03-04 09:30:30 -0800 | [diff] [blame] | 2704 | * |
| 2705 | * This routine is invoked by the worker thread to process a SLI4 fast-path |
Dick Kennedy | 952c303 | 2017-09-29 17:34:43 -0700 | [diff] [blame] | 2706 | * NVME aborted xri. Aborted NVME IO commands are completed to the transport |
| 2707 | * here. |
James Smart | 318083a | 2017-03-04 09:30:30 -0800 | [diff] [blame] | 2708 | **/ |
| 2709 | void |
| 2710 | lpfc_sli4_nvme_xri_aborted(struct lpfc_hba *phba, |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 2711 | struct sli4_wcqe_xri_aborted *axri, |
| 2712 | struct lpfc_io_buf *lpfc_ncmd) |
James Smart | 318083a | 2017-03-04 09:30:30 -0800 | [diff] [blame] | 2713 | { |
| 2714 | uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri); |
Dick Kennedy | 952c303 | 2017-09-29 17:34:43 -0700 | [diff] [blame] | 2715 | struct nvmefc_fcp_req *nvme_cmd = NULL; |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 2716 | struct lpfc_nodelist *ndlp = lpfc_ncmd->ndlp; |
James Smart | 318083a | 2017-03-04 09:30:30 -0800 | [diff] [blame] | 2717 | |
James Smart | 318083a | 2017-03-04 09:30:30 -0800 | [diff] [blame] | 2718 | |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 2719 | if (ndlp) |
| 2720 | lpfc_sli4_abts_err_handler(phba, ndlp, axri); |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 2721 | |
| 2722 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS, |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 2723 | "6311 nvme_cmd %p xri x%x tag x%x abort complete and " |
| 2724 | "xri released\n", |
| 2725 | lpfc_ncmd->nvmeCmd, xri, |
| 2726 | lpfc_ncmd->cur_iocbq.iotag); |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 2727 | |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 2728 | /* Aborted NVME commands are required to not complete |
| 2729 | * before the abort exchange command fully completes. |
| 2730 | * Once completed, it is available via the put list. |
| 2731 | */ |
| 2732 | if (lpfc_ncmd->nvmeCmd) { |
| 2733 | nvme_cmd = lpfc_ncmd->nvmeCmd; |
| 2734 | nvme_cmd->done(nvme_cmd); |
| 2735 | lpfc_ncmd->nvmeCmd = NULL; |
| 2736 | } |
| 2737 | lpfc_release_nvme_buf(phba, lpfc_ncmd); |
James Smart | 318083a | 2017-03-04 09:30:30 -0800 | [diff] [blame] | 2738 | } |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 2739 | |
| 2740 | /** |
| 2741 | * lpfc_nvme_wait_for_io_drain - Wait for all NVME wqes to complete |
| 2742 | * @phba: Pointer to HBA context object. |
| 2743 | * |
| 2744 | * This function flushes all wqes in the nvme rings and frees all resources |
| 2745 | * in the txcmplq. This function does not issue abort wqes for the IO |
| 2746 | * commands in txcmplq, they will just be returned with |
| 2747 | * IOERR_SLI_DOWN. This function is invoked with EEH when device's PCI |
| 2748 | * slot has been permanently disabled. |
| 2749 | **/ |
| 2750 | void |
| 2751 | lpfc_nvme_wait_for_io_drain(struct lpfc_hba *phba) |
| 2752 | { |
| 2753 | struct lpfc_sli_ring *pring; |
| 2754 | u32 i, wait_cnt = 0; |
| 2755 | |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 2756 | if (phba->sli_rev < LPFC_SLI_REV4 || !phba->sli4_hba.hdwq) |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 2757 | return; |
| 2758 | |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 2759 | /* Cycle through all IO rings and make sure all outstanding |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 2760 | * WQEs have been removed from the txcmplqs. |
| 2761 | */ |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 2762 | for (i = 0; i < phba->cfg_hdw_queue; i++) { |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 2763 | if (!phba->sli4_hba.hdwq[i].io_wq) |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 2764 | continue; |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 2765 | pring = phba->sli4_hba.hdwq[i].io_wq->pring; |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 2766 | |
James Smart | d580c61 | 2018-06-26 08:24:24 -0700 | [diff] [blame] | 2767 | if (!pring) |
| 2768 | continue; |
| 2769 | |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 2770 | /* Retrieve everything on the txcmplq */ |
| 2771 | while (!list_empty(&pring->txcmplq)) { |
| 2772 | msleep(LPFC_XRI_EXCH_BUSY_WAIT_T1); |
| 2773 | wait_cnt++; |
| 2774 | |
| 2775 | /* The sleep is 10mS. Every ten seconds, |
| 2776 | * dump a message. Something is wrong. |
| 2777 | */ |
| 2778 | if ((wait_cnt % 1000) == 0) { |
Dick Kennedy | 372c187 | 2020-06-30 14:50:00 -0700 | [diff] [blame] | 2779 | lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 2780 | "6178 NVME IO not empty, " |
| 2781 | "cnt %d\n", wait_cnt); |
| 2782 | } |
| 2783 | } |
| 2784 | } |
James Smart | a22d73b | 2021-01-04 10:02:38 -0800 | [diff] [blame] | 2785 | |
| 2786 | /* Make sure HBA is alive */ |
| 2787 | lpfc_issue_hb_tmo(phba); |
| 2788 | |
James Smart | c3725bd | 2017-11-20 16:00:42 -0800 | [diff] [blame] | 2789 | } |
James Smart | 84f2ddf | 2019-08-14 16:56:55 -0700 | [diff] [blame] | 2790 | |
| 2791 | void |
James Smart | 9ec58ec | 2021-01-04 10:02:35 -0800 | [diff] [blame] | 2792 | lpfc_nvme_cancel_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, |
| 2793 | uint32_t stat, uint32_t param) |
James Smart | 84f2ddf | 2019-08-14 16:56:55 -0700 | [diff] [blame] | 2794 | { |
| 2795 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 2796 | struct lpfc_io_buf *lpfc_ncmd; |
| 2797 | struct nvmefc_fcp_req *nCmd; |
James Smart | 9ec58ec | 2021-01-04 10:02:35 -0800 | [diff] [blame] | 2798 | struct lpfc_wcqe_complete wcqe; |
| 2799 | struct lpfc_wcqe_complete *wcqep = &wcqe; |
James Smart | 84f2ddf | 2019-08-14 16:56:55 -0700 | [diff] [blame] | 2800 | |
James Smart | d51cf5b | 2022-04-12 15:20:02 -0700 | [diff] [blame] | 2801 | lpfc_ncmd = pwqeIn->io_buf; |
James Smart | 9ec58ec | 2021-01-04 10:02:35 -0800 | [diff] [blame] | 2802 | if (!lpfc_ncmd) { |
James Smart | 84f2ddf | 2019-08-14 16:56:55 -0700 | [diff] [blame] | 2803 | lpfc_sli_release_iocbq(phba, pwqeIn); |
| 2804 | return; |
| 2805 | } |
| 2806 | /* For abort iocb just return, IO iocb will do a done call */ |
| 2807 | if (bf_get(wqe_cmnd, &pwqeIn->wqe.gen_req.wqe_com) == |
| 2808 | CMD_ABORT_XRI_CX) { |
| 2809 | lpfc_sli_release_iocbq(phba, pwqeIn); |
| 2810 | return; |
| 2811 | } |
James Smart | 84f2ddf | 2019-08-14 16:56:55 -0700 | [diff] [blame] | 2812 | |
| 2813 | spin_lock(&lpfc_ncmd->buf_lock); |
James Smart | 9ec58ec | 2021-01-04 10:02:35 -0800 | [diff] [blame] | 2814 | nCmd = lpfc_ncmd->nvmeCmd; |
| 2815 | if (!nCmd) { |
James Smart | 84f2ddf | 2019-08-14 16:56:55 -0700 | [diff] [blame] | 2816 | spin_unlock(&lpfc_ncmd->buf_lock); |
| 2817 | lpfc_release_nvme_buf(phba, lpfc_ncmd); |
| 2818 | return; |
| 2819 | } |
James Smart | 9ec58ec | 2021-01-04 10:02:35 -0800 | [diff] [blame] | 2820 | spin_unlock(&lpfc_ncmd->buf_lock); |
James Smart | 84f2ddf | 2019-08-14 16:56:55 -0700 | [diff] [blame] | 2821 | |
James Smart | 84f2ddf | 2019-08-14 16:56:55 -0700 | [diff] [blame] | 2822 | lpfc_printf_log(phba, KERN_INFO, LOG_NVME_IOERR, |
| 2823 | "6194 NVME Cancel xri %x\n", |
| 2824 | lpfc_ncmd->cur_iocbq.sli4_xritag); |
| 2825 | |
James Smart | 9ec58ec | 2021-01-04 10:02:35 -0800 | [diff] [blame] | 2826 | wcqep->word0 = 0; |
| 2827 | bf_set(lpfc_wcqe_c_status, wcqep, stat); |
| 2828 | wcqep->parameter = param; |
James Smart | 4ecc9b0 | 2022-07-01 14:14:14 -0700 | [diff] [blame] | 2829 | wcqep->total_data_placed = 0; |
James Smart | 9ec58ec | 2021-01-04 10:02:35 -0800 | [diff] [blame] | 2830 | wcqep->word3 = 0; /* xb is 0 */ |
James Smart | 84f2ddf | 2019-08-14 16:56:55 -0700 | [diff] [blame] | 2831 | |
| 2832 | /* Call release with XB=1 to queue the IO into the abort list. */ |
James Smart | 9ec58ec | 2021-01-04 10:02:35 -0800 | [diff] [blame] | 2833 | if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) |
| 2834 | bf_set(lpfc_wcqe_c_xb, wcqep, 1); |
| 2835 | |
James Smart | a680a92 | 2022-02-24 18:22:52 -0800 | [diff] [blame] | 2836 | memcpy(&pwqeIn->wcqe_cmpl, wcqep, sizeof(*wcqep)); |
| 2837 | (pwqeIn->cmd_cmpl)(phba, pwqeIn, pwqeIn); |
James Smart | 84f2ddf | 2019-08-14 16:56:55 -0700 | [diff] [blame] | 2838 | #endif |
| 2839 | } |