| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * QLogic Fibre Channel HBA Driver |
|---|
| 3 | 4 | * Copyright (c) 2003-2017 QLogic Corporation |
|---|
| 4 | | - * |
|---|
| 5 | | - * See LICENSE.qla2xxx for copyright and licensing details. |
|---|
| 6 | 5 | */ |
|---|
| 7 | 6 | #include "qla_nvme.h" |
|---|
| 8 | 7 | #include <linux/scatterlist.h> |
|---|
| .. | .. |
|---|
| 11 | 10 | #include <linux/nvme-fc.h> |
|---|
| 12 | 11 | |
|---|
| 13 | 12 | static struct nvme_fc_port_template qla_nvme_fc_transport; |
|---|
| 14 | | - |
|---|
| 15 | | -static void qla_nvme_unregister_remote_port(struct work_struct *); |
|---|
| 16 | 13 | |
|---|
| 17 | 14 | int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport) |
|---|
| 18 | 15 | { |
|---|
| .. | .. |
|---|
| 38 | 35 | (fcport->nvme_flag & NVME_FLAG_REGISTERED)) |
|---|
| 39 | 36 | return 0; |
|---|
| 40 | 37 | |
|---|
| 41 | | - INIT_WORK(&fcport->nvme_del_work, qla_nvme_unregister_remote_port); |
|---|
| 42 | 38 | fcport->nvme_flag &= ~NVME_FLAG_RESETTING; |
|---|
| 43 | 39 | |
|---|
| 44 | 40 | memset(&req, 0, sizeof(struct nvme_fc_port_info)); |
|---|
| 45 | 41 | req.port_name = wwn_to_u64(fcport->port_name); |
|---|
| 46 | 42 | req.node_name = wwn_to_u64(fcport->node_name); |
|---|
| 47 | 43 | req.port_role = 0; |
|---|
| 48 | | - req.dev_loss_tmo = NVME_FC_DEV_LOSS_TMO; |
|---|
| 44 | + req.dev_loss_tmo = 0; |
|---|
| 49 | 45 | |
|---|
| 50 | 46 | if (fcport->nvme_prli_service_param & NVME_PRLI_SP_INITIATOR) |
|---|
| 51 | 47 | req.port_role = FC_PORT_ROLE_NVME_INITIATOR; |
|---|
| .. | .. |
|---|
| 72 | 68 | return ret; |
|---|
| 73 | 69 | } |
|---|
| 74 | 70 | |
|---|
| 71 | + if (fcport->nvme_prli_service_param & NVME_PRLI_SP_SLER) |
|---|
| 72 | + ql_log(ql_log_info, vha, 0x212a, |
|---|
| 73 | + "PortID:%06x Supports SLER\n", req.port_id); |
|---|
| 74 | + |
|---|
| 75 | + if (fcport->nvme_prli_service_param & NVME_PRLI_SP_PI_CTRL) |
|---|
| 76 | + ql_log(ql_log_info, vha, 0x212b, |
|---|
| 77 | + "PortID:%06x Supports PI control\n", req.port_id); |
|---|
| 78 | + |
|---|
| 75 | 79 | rport = fcport->nvme_remote_port->private; |
|---|
| 76 | 80 | rport->fcport = fcport; |
|---|
| 77 | | - list_add_tail(&rport->list, &vha->nvme_rport_list); |
|---|
| 78 | 81 | |
|---|
| 79 | 82 | fcport->nvme_flag |= NVME_FLAG_REGISTERED; |
|---|
| 80 | 83 | return 0; |
|---|
| .. | .. |
|---|
| 106 | 109 | return -EINVAL; |
|---|
| 107 | 110 | } |
|---|
| 108 | 111 | |
|---|
| 109 | | - if (ha->queue_pair_map[qidx]) { |
|---|
| 110 | | - *handle = ha->queue_pair_map[qidx]; |
|---|
| 111 | | - ql_log(ql_log_info, vha, 0x2121, |
|---|
| 112 | | - "Returning existing qpair of %p for idx=%x\n", |
|---|
| 113 | | - *handle, qidx); |
|---|
| 114 | | - return 0; |
|---|
| 115 | | - } |
|---|
| 112 | + /* Use base qpair if max_qpairs is 0 */ |
|---|
| 113 | + if (!ha->max_qpairs) { |
|---|
| 114 | + qpair = ha->base_qpair; |
|---|
| 115 | + } else { |
|---|
| 116 | + if (ha->queue_pair_map[qidx]) { |
|---|
| 117 | + *handle = ha->queue_pair_map[qidx]; |
|---|
| 118 | + ql_log(ql_log_info, vha, 0x2121, |
|---|
| 119 | + "Returning existing qpair of %p for idx=%x\n", |
|---|
| 120 | + *handle, qidx); |
|---|
| 121 | + return 0; |
|---|
| 122 | + } |
|---|
| 116 | 123 | |
|---|
| 117 | | - qpair = qla2xxx_create_qpair(vha, 5, vha->vp_idx, true); |
|---|
| 118 | | - if (qpair == NULL) { |
|---|
| 119 | | - ql_log(ql_log_warn, vha, 0x2122, |
|---|
| 120 | | - "Failed to allocate qpair\n"); |
|---|
| 121 | | - return -EINVAL; |
|---|
| 124 | + qpair = qla2xxx_create_qpair(vha, 5, vha->vp_idx, true); |
|---|
| 125 | + if (!qpair) { |
|---|
| 126 | + ql_log(ql_log_warn, vha, 0x2122, |
|---|
| 127 | + "Failed to allocate qpair\n"); |
|---|
| 128 | + return -EINVAL; |
|---|
| 129 | + } |
|---|
| 122 | 130 | } |
|---|
| 123 | 131 | *handle = qpair; |
|---|
| 124 | 132 | |
|---|
| 125 | 133 | return 0; |
|---|
| 126 | 134 | } |
|---|
| 127 | 135 | |
|---|
| 128 | | -static void qla_nvme_sp_ls_done(void *ptr, int res) |
|---|
| 136 | +static void qla_nvme_release_fcp_cmd_kref(struct kref *kref) |
|---|
| 129 | 137 | { |
|---|
| 130 | | - srb_t *sp = ptr; |
|---|
| 138 | + struct srb *sp = container_of(kref, struct srb, cmd_kref); |
|---|
| 139 | + struct nvme_private *priv = (struct nvme_private *)sp->priv; |
|---|
| 140 | + struct nvmefc_fcp_req *fd; |
|---|
| 131 | 141 | struct srb_iocb *nvme; |
|---|
| 132 | | - struct nvmefc_ls_req *fd; |
|---|
| 133 | | - struct nvme_private *priv; |
|---|
| 142 | + unsigned long flags; |
|---|
| 134 | 143 | |
|---|
| 135 | | - if (atomic_read(&sp->ref_count) == 0) { |
|---|
| 136 | | - ql_log(ql_log_warn, sp->fcport->vha, 0x2123, |
|---|
| 137 | | - "SP reference-count to ZERO on LS_done -- sp=%p.\n", sp); |
|---|
| 138 | | - return; |
|---|
| 144 | + if (!priv) |
|---|
| 145 | + goto out; |
|---|
| 146 | + |
|---|
| 147 | + nvme = &sp->u.iocb_cmd; |
|---|
| 148 | + fd = nvme->u.nvme.desc; |
|---|
| 149 | + |
|---|
| 150 | + spin_lock_irqsave(&priv->cmd_lock, flags); |
|---|
| 151 | + priv->sp = NULL; |
|---|
| 152 | + sp->priv = NULL; |
|---|
| 153 | + if (priv->comp_status == QLA_SUCCESS) { |
|---|
| 154 | + fd->rcv_rsplen = le16_to_cpu(nvme->u.nvme.rsp_pyld_len); |
|---|
| 155 | + fd->status = NVME_SC_SUCCESS; |
|---|
| 156 | + } else { |
|---|
| 157 | + fd->rcv_rsplen = 0; |
|---|
| 158 | + fd->transferred_length = 0; |
|---|
| 159 | + fd->status = NVME_SC_INTERNAL; |
|---|
| 139 | 160 | } |
|---|
| 161 | + spin_unlock_irqrestore(&priv->cmd_lock, flags); |
|---|
| 140 | 162 | |
|---|
| 141 | | - if (!atomic_dec_and_test(&sp->ref_count)) |
|---|
| 163 | + fd->done(fd); |
|---|
| 164 | +out: |
|---|
| 165 | + qla2xxx_rel_qpair_sp(sp->qpair, sp); |
|---|
| 166 | +} |
|---|
| 167 | + |
|---|
| 168 | +static void qla_nvme_release_ls_cmd_kref(struct kref *kref) |
|---|
| 169 | +{ |
|---|
| 170 | + struct srb *sp = container_of(kref, struct srb, cmd_kref); |
|---|
| 171 | + struct nvme_private *priv = (struct nvme_private *)sp->priv; |
|---|
| 172 | + struct nvmefc_ls_req *fd; |
|---|
| 173 | + unsigned long flags; |
|---|
| 174 | + |
|---|
| 175 | + if (!priv) |
|---|
| 176 | + goto out; |
|---|
| 177 | + |
|---|
| 178 | + spin_lock_irqsave(&priv->cmd_lock, flags); |
|---|
| 179 | + priv->sp = NULL; |
|---|
| 180 | + sp->priv = NULL; |
|---|
| 181 | + spin_unlock_irqrestore(&priv->cmd_lock, flags); |
|---|
| 182 | + |
|---|
| 183 | + fd = priv->fd; |
|---|
| 184 | + |
|---|
| 185 | + fd->done(fd, priv->comp_status); |
|---|
| 186 | +out: |
|---|
| 187 | + qla2x00_rel_sp(sp); |
|---|
| 188 | +} |
|---|
| 189 | + |
|---|
| 190 | +static void qla_nvme_ls_complete(struct work_struct *work) |
|---|
| 191 | +{ |
|---|
| 192 | + struct nvme_private *priv = |
|---|
| 193 | + container_of(work, struct nvme_private, ls_work); |
|---|
| 194 | + |
|---|
| 195 | + kref_put(&priv->sp->cmd_kref, qla_nvme_release_ls_cmd_kref); |
|---|
| 196 | +} |
|---|
| 197 | + |
|---|
| 198 | +static void qla_nvme_sp_ls_done(srb_t *sp, int res) |
|---|
| 199 | +{ |
|---|
| 200 | + struct nvme_private *priv = sp->priv; |
|---|
| 201 | + |
|---|
| 202 | + if (WARN_ON_ONCE(kref_read(&sp->cmd_kref) == 0)) |
|---|
| 142 | 203 | return; |
|---|
| 143 | 204 | |
|---|
| 144 | 205 | if (res) |
|---|
| 145 | 206 | res = -EINVAL; |
|---|
| 146 | 207 | |
|---|
| 147 | | - nvme = &sp->u.iocb_cmd; |
|---|
| 148 | | - fd = nvme->u.nvme.desc; |
|---|
| 149 | | - priv = fd->private; |
|---|
| 150 | 208 | priv->comp_status = res; |
|---|
| 209 | + INIT_WORK(&priv->ls_work, qla_nvme_ls_complete); |
|---|
| 151 | 210 | schedule_work(&priv->ls_work); |
|---|
| 152 | | - /* work schedule doesn't need the sp */ |
|---|
| 153 | | - qla2x00_rel_sp(sp); |
|---|
| 154 | 211 | } |
|---|
| 155 | 212 | |
|---|
| 156 | | -static void qla_nvme_sp_done(void *ptr, int res) |
|---|
| 213 | +/* it assumed that QPair lock is held. */ |
|---|
| 214 | +static void qla_nvme_sp_done(srb_t *sp, int res) |
|---|
| 157 | 215 | { |
|---|
| 158 | | - srb_t *sp = ptr; |
|---|
| 159 | | - struct srb_iocb *nvme; |
|---|
| 160 | | - struct nvmefc_fcp_req *fd; |
|---|
| 216 | + struct nvme_private *priv = sp->priv; |
|---|
| 161 | 217 | |
|---|
| 162 | | - nvme = &sp->u.iocb_cmd; |
|---|
| 163 | | - fd = nvme->u.nvme.desc; |
|---|
| 164 | | - |
|---|
| 165 | | - if (!atomic_dec_and_test(&sp->ref_count)) |
|---|
| 166 | | - return; |
|---|
| 167 | | - |
|---|
| 168 | | - if (res == QLA_SUCCESS) |
|---|
| 169 | | - fd->status = 0; |
|---|
| 170 | | - else |
|---|
| 171 | | - fd->status = NVME_SC_INTERNAL; |
|---|
| 172 | | - |
|---|
| 173 | | - fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len; |
|---|
| 174 | | - fd->done(fd); |
|---|
| 175 | | - qla2xxx_rel_qpair_sp(sp->qpair, sp); |
|---|
| 218 | + priv->comp_status = res; |
|---|
| 219 | + kref_put(&sp->cmd_kref, qla_nvme_release_fcp_cmd_kref); |
|---|
| 176 | 220 | |
|---|
| 177 | 221 | return; |
|---|
| 178 | 222 | } |
|---|
| .. | .. |
|---|
| 186 | 230 | struct qla_hw_data *ha = fcport->vha->hw; |
|---|
| 187 | 231 | int rval; |
|---|
| 188 | 232 | |
|---|
| 233 | + ql_dbg(ql_dbg_io, fcport->vha, 0xffff, |
|---|
| 234 | + "%s called for sp=%p, hndl=%x on fcport=%p deleted=%d\n", |
|---|
| 235 | + __func__, sp, sp->handle, fcport, fcport->deleted); |
|---|
| 236 | + |
|---|
| 237 | + if (!ha->flags.fw_started && fcport->deleted) |
|---|
| 238 | + goto out; |
|---|
| 239 | + |
|---|
| 240 | + if (ha->flags.host_shutting_down) { |
|---|
| 241 | + ql_log(ql_log_info, sp->fcport->vha, 0xffff, |
|---|
| 242 | + "%s Calling done on sp: %p, type: 0x%x\n", |
|---|
| 243 | + __func__, sp, sp->type); |
|---|
| 244 | + sp->done(sp, 0); |
|---|
| 245 | + goto out; |
|---|
| 246 | + } |
|---|
| 247 | + |
|---|
| 189 | 248 | rval = ha->isp_ops->abort_command(sp); |
|---|
| 190 | 249 | |
|---|
| 191 | 250 | ql_dbg(ql_dbg_io, fcport->vha, 0x212b, |
|---|
| 192 | 251 | "%s: %s command for sp=%p, handle=%x on fcport=%p rval=%x\n", |
|---|
| 193 | 252 | __func__, (rval != QLA_SUCCESS) ? "Failed to abort" : "Aborted", |
|---|
| 194 | 253 | sp, sp->handle, fcport, rval); |
|---|
| 254 | + |
|---|
| 255 | +out: |
|---|
| 256 | + /* kref_get was done before work was schedule. */ |
|---|
| 257 | + kref_put(&sp->cmd_kref, sp->put_fn); |
|---|
| 195 | 258 | } |
|---|
| 196 | 259 | |
|---|
| 197 | 260 | static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport, |
|---|
| 198 | 261 | struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd) |
|---|
| 199 | 262 | { |
|---|
| 200 | 263 | struct nvme_private *priv = fd->private; |
|---|
| 264 | + unsigned long flags; |
|---|
| 265 | + |
|---|
| 266 | + spin_lock_irqsave(&priv->cmd_lock, flags); |
|---|
| 267 | + if (!priv->sp) { |
|---|
| 268 | + spin_unlock_irqrestore(&priv->cmd_lock, flags); |
|---|
| 269 | + return; |
|---|
| 270 | + } |
|---|
| 271 | + |
|---|
| 272 | + if (!kref_get_unless_zero(&priv->sp->cmd_kref)) { |
|---|
| 273 | + spin_unlock_irqrestore(&priv->cmd_lock, flags); |
|---|
| 274 | + return; |
|---|
| 275 | + } |
|---|
| 276 | + spin_unlock_irqrestore(&priv->cmd_lock, flags); |
|---|
| 201 | 277 | |
|---|
| 202 | 278 | INIT_WORK(&priv->abort_work, qla_nvme_abort_work); |
|---|
| 203 | 279 | schedule_work(&priv->abort_work); |
|---|
| 204 | | -} |
|---|
| 205 | | - |
|---|
| 206 | | -static void qla_nvme_ls_complete(struct work_struct *work) |
|---|
| 207 | | -{ |
|---|
| 208 | | - struct nvme_private *priv = |
|---|
| 209 | | - container_of(work, struct nvme_private, ls_work); |
|---|
| 210 | | - struct nvmefc_ls_req *fd = priv->fd; |
|---|
| 211 | | - |
|---|
| 212 | | - fd->done(fd, priv->comp_status); |
|---|
| 213 | 280 | } |
|---|
| 214 | 281 | |
|---|
| 215 | 282 | static int qla_nvme_ls_req(struct nvme_fc_local_port *lport, |
|---|
| .. | .. |
|---|
| 224 | 291 | struct qla_hw_data *ha; |
|---|
| 225 | 292 | srb_t *sp; |
|---|
| 226 | 293 | |
|---|
| 294 | + |
|---|
| 295 | + if (!fcport || (fcport && fcport->deleted)) |
|---|
| 296 | + return rval; |
|---|
| 297 | + |
|---|
| 227 | 298 | vha = fcport->vha; |
|---|
| 228 | 299 | ha = vha->hw; |
|---|
| 300 | + |
|---|
| 301 | + if (!ha->flags.fw_started) |
|---|
| 302 | + return rval; |
|---|
| 303 | + |
|---|
| 229 | 304 | /* Alloc SRB structure */ |
|---|
| 230 | 305 | sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); |
|---|
| 231 | 306 | if (!sp) |
|---|
| .. | .. |
|---|
| 234 | 309 | sp->type = SRB_NVME_LS; |
|---|
| 235 | 310 | sp->name = "nvme_ls"; |
|---|
| 236 | 311 | sp->done = qla_nvme_sp_ls_done; |
|---|
| 237 | | - atomic_set(&sp->ref_count, 1); |
|---|
| 238 | | - nvme = &sp->u.iocb_cmd; |
|---|
| 312 | + sp->put_fn = qla_nvme_release_ls_cmd_kref; |
|---|
| 313 | + sp->priv = priv; |
|---|
| 239 | 314 | priv->sp = sp; |
|---|
| 315 | + kref_init(&sp->cmd_kref); |
|---|
| 316 | + spin_lock_init(&priv->cmd_lock); |
|---|
| 317 | + nvme = &sp->u.iocb_cmd; |
|---|
| 240 | 318 | priv->fd = fd; |
|---|
| 241 | | - INIT_WORK(&priv->ls_work, qla_nvme_ls_complete); |
|---|
| 242 | 319 | nvme->u.nvme.desc = fd; |
|---|
| 243 | 320 | nvme->u.nvme.dir = 0; |
|---|
| 244 | 321 | nvme->u.nvme.dl = 0; |
|---|
| .. | .. |
|---|
| 246 | 323 | nvme->u.nvme.rsp_len = fd->rsplen; |
|---|
| 247 | 324 | nvme->u.nvme.rsp_dma = fd->rspdma; |
|---|
| 248 | 325 | nvme->u.nvme.timeout_sec = fd->timeout; |
|---|
| 249 | | - nvme->u.nvme.cmd_dma = dma_map_single(&ha->pdev->dev, fd->rqstaddr, |
|---|
| 250 | | - fd->rqstlen, DMA_TO_DEVICE); |
|---|
| 326 | + nvme->u.nvme.cmd_dma = fd->rqstdma; |
|---|
| 251 | 327 | dma_sync_single_for_device(&ha->pdev->dev, nvme->u.nvme.cmd_dma, |
|---|
| 252 | 328 | fd->rqstlen, DMA_TO_DEVICE); |
|---|
| 253 | 329 | |
|---|
| .. | .. |
|---|
| 255 | 331 | if (rval != QLA_SUCCESS) { |
|---|
| 256 | 332 | ql_log(ql_log_warn, vha, 0x700e, |
|---|
| 257 | 333 | "qla2x00_start_sp failed = %d\n", rval); |
|---|
| 258 | | - atomic_dec(&sp->ref_count); |
|---|
| 259 | | - wake_up(&sp->nvme_ls_waitq); |
|---|
| 334 | + sp->priv = NULL; |
|---|
| 335 | + priv->sp = NULL; |
|---|
| 336 | + qla2x00_rel_sp(sp); |
|---|
| 260 | 337 | return rval; |
|---|
| 261 | 338 | } |
|---|
| 262 | 339 | |
|---|
| .. | .. |
|---|
| 268 | 345 | struct nvmefc_fcp_req *fd) |
|---|
| 269 | 346 | { |
|---|
| 270 | 347 | struct nvme_private *priv = fd->private; |
|---|
| 348 | + unsigned long flags; |
|---|
| 349 | + |
|---|
| 350 | + spin_lock_irqsave(&priv->cmd_lock, flags); |
|---|
| 351 | + if (!priv->sp) { |
|---|
| 352 | + spin_unlock_irqrestore(&priv->cmd_lock, flags); |
|---|
| 353 | + return; |
|---|
| 354 | + } |
|---|
| 355 | + if (!kref_get_unless_zero(&priv->sp->cmd_kref)) { |
|---|
| 356 | + spin_unlock_irqrestore(&priv->cmd_lock, flags); |
|---|
| 357 | + return; |
|---|
| 358 | + } |
|---|
| 359 | + spin_unlock_irqrestore(&priv->cmd_lock, flags); |
|---|
| 271 | 360 | |
|---|
| 272 | 361 | INIT_WORK(&priv->abort_work, qla_nvme_abort_work); |
|---|
| 273 | 362 | schedule_work(&priv->abort_work); |
|---|
| 274 | | -} |
|---|
| 275 | | - |
|---|
| 276 | | -static void qla_nvme_poll(struct nvme_fc_local_port *lport, void *hw_queue_handle) |
|---|
| 277 | | -{ |
|---|
| 278 | | - struct qla_qpair *qpair = hw_queue_handle; |
|---|
| 279 | | - unsigned long flags; |
|---|
| 280 | | - struct scsi_qla_host *vha = lport->private; |
|---|
| 281 | | - |
|---|
| 282 | | - spin_lock_irqsave(&qpair->qp_lock, flags); |
|---|
| 283 | | - qla24xx_process_response_queue(vha, qpair->rsp); |
|---|
| 284 | | - spin_unlock_irqrestore(&qpair->qp_lock, flags); |
|---|
| 285 | 363 | } |
|---|
| 286 | 364 | |
|---|
| 287 | 365 | static inline int qla2x00_start_nvme_mq(srb_t *sp) |
|---|
| 288 | 366 | { |
|---|
| 289 | 367 | unsigned long flags; |
|---|
| 290 | 368 | uint32_t *clr_ptr; |
|---|
| 291 | | - uint32_t index; |
|---|
| 292 | 369 | uint32_t handle; |
|---|
| 293 | 370 | struct cmd_nvme *cmd_pkt; |
|---|
| 294 | 371 | uint16_t cnt, i; |
|---|
| 295 | 372 | uint16_t req_cnt; |
|---|
| 296 | 373 | uint16_t tot_dsds; |
|---|
| 297 | 374 | uint16_t avail_dsds; |
|---|
| 298 | | - uint32_t *cur_dsd; |
|---|
| 375 | + struct dsd64 *cur_dsd; |
|---|
| 299 | 376 | struct req_que *req = NULL; |
|---|
| 300 | 377 | struct scsi_qla_host *vha = sp->fcport->vha; |
|---|
| 301 | 378 | struct qla_hw_data *ha = vha->hw; |
|---|
| .. | .. |
|---|
| 303 | 380 | struct srb_iocb *nvme = &sp->u.iocb_cmd; |
|---|
| 304 | 381 | struct scatterlist *sgl, *sg; |
|---|
| 305 | 382 | struct nvmefc_fcp_req *fd = nvme->u.nvme.desc; |
|---|
| 383 | + struct nvme_fc_cmd_iu *cmd = fd->cmdaddr; |
|---|
| 306 | 384 | uint32_t rval = QLA_SUCCESS; |
|---|
| 307 | 385 | |
|---|
| 308 | 386 | /* Setup qpair pointers */ |
|---|
| .. | .. |
|---|
| 312 | 390 | /* Acquire qpair specific lock */ |
|---|
| 313 | 391 | spin_lock_irqsave(&qpair->qp_lock, flags); |
|---|
| 314 | 392 | |
|---|
| 315 | | - /* Check for room in outstanding command list. */ |
|---|
| 316 | | - handle = req->current_outstanding_cmd; |
|---|
| 317 | | - for (index = 1; index < req->num_outstanding_cmds; index++) { |
|---|
| 318 | | - handle++; |
|---|
| 319 | | - if (handle == req->num_outstanding_cmds) |
|---|
| 320 | | - handle = 1; |
|---|
| 321 | | - if (!req->outstanding_cmds[handle]) |
|---|
| 322 | | - break; |
|---|
| 323 | | - } |
|---|
| 324 | | - |
|---|
| 325 | | - if (index == req->num_outstanding_cmds) { |
|---|
| 393 | + handle = qla2xxx_get_next_handle(req); |
|---|
| 394 | + if (handle == 0) { |
|---|
| 326 | 395 | rval = -EBUSY; |
|---|
| 327 | 396 | goto queuing_error; |
|---|
| 328 | 397 | } |
|---|
| 329 | 398 | req_cnt = qla24xx_calc_iocbs(vha, tot_dsds); |
|---|
| 330 | 399 | if (req->cnt < (req_cnt + 2)) { |
|---|
| 331 | | - cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr : |
|---|
| 332 | | - RD_REG_DWORD_RELAXED(req->req_q_out); |
|---|
| 400 | + if (IS_SHADOW_REG_CAPABLE(ha)) { |
|---|
| 401 | + cnt = *req->out_ptr; |
|---|
| 402 | + } else { |
|---|
| 403 | + cnt = rd_reg_dword_relaxed(req->req_q_out); |
|---|
| 404 | + if (qla2x00_check_reg16_for_disconnect(vha, cnt)) |
|---|
| 405 | + goto queuing_error; |
|---|
| 406 | + } |
|---|
| 333 | 407 | |
|---|
| 334 | 408 | if (req->ring_index < cnt) |
|---|
| 335 | 409 | req->cnt = cnt - req->ring_index; |
|---|
| .. | .. |
|---|
| 343 | 417 | } |
|---|
| 344 | 418 | |
|---|
| 345 | 419 | if (unlikely(!fd->sqid)) { |
|---|
| 346 | | - struct nvme_fc_cmd_iu *cmd = fd->cmdaddr; |
|---|
| 347 | 420 | if (cmd->sqe.common.opcode == nvme_admin_async_event) { |
|---|
| 348 | 421 | nvme->u.nvme.aen_op = 1; |
|---|
| 349 | 422 | atomic_inc(&ha->nvme_active_aen_cnt); |
|---|
| .. | .. |
|---|
| 357 | 430 | req->cnt -= req_cnt; |
|---|
| 358 | 431 | |
|---|
| 359 | 432 | cmd_pkt = (struct cmd_nvme *)req->ring_ptr; |
|---|
| 360 | | - cmd_pkt->handle = MAKE_HANDLE(req->id, handle); |
|---|
| 433 | + cmd_pkt->handle = make_handle(req->id, handle); |
|---|
| 361 | 434 | |
|---|
| 362 | 435 | /* Zero out remaining portion of packet. */ |
|---|
| 363 | 436 | clr_ptr = (uint32_t *)cmd_pkt + 2; |
|---|
| .. | .. |
|---|
| 370 | 443 | |
|---|
| 371 | 444 | /* No data transfer how do we check buffer len == 0?? */ |
|---|
| 372 | 445 | if (fd->io_dir == NVMEFC_FCP_READ) { |
|---|
| 373 | | - cmd_pkt->control_flags = |
|---|
| 374 | | - cpu_to_le16(CF_READ_DATA | CF_NVME_ENABLE); |
|---|
| 375 | | - vha->qla_stats.input_bytes += fd->payload_length; |
|---|
| 376 | | - vha->qla_stats.input_requests++; |
|---|
| 446 | + cmd_pkt->control_flags = cpu_to_le16(CF_READ_DATA); |
|---|
| 447 | + qpair->counters.input_bytes += fd->payload_length; |
|---|
| 448 | + qpair->counters.input_requests++; |
|---|
| 377 | 449 | } else if (fd->io_dir == NVMEFC_FCP_WRITE) { |
|---|
| 378 | | - cmd_pkt->control_flags = |
|---|
| 379 | | - cpu_to_le16(CF_WRITE_DATA | CF_NVME_ENABLE); |
|---|
| 380 | | - vha->qla_stats.output_bytes += fd->payload_length; |
|---|
| 381 | | - vha->qla_stats.output_requests++; |
|---|
| 450 | + cmd_pkt->control_flags = cpu_to_le16(CF_WRITE_DATA); |
|---|
| 451 | + if ((vha->flags.nvme_first_burst) && |
|---|
| 452 | + (sp->fcport->nvme_prli_service_param & |
|---|
| 453 | + NVME_PRLI_SP_FIRST_BURST)) { |
|---|
| 454 | + if ((fd->payload_length <= |
|---|
| 455 | + sp->fcport->nvme_first_burst_size) || |
|---|
| 456 | + (sp->fcport->nvme_first_burst_size == 0)) |
|---|
| 457 | + cmd_pkt->control_flags |= |
|---|
| 458 | + cpu_to_le16(CF_NVME_FIRST_BURST_ENABLE); |
|---|
| 459 | + } |
|---|
| 460 | + qpair->counters.output_bytes += fd->payload_length; |
|---|
| 461 | + qpair->counters.output_requests++; |
|---|
| 382 | 462 | } else if (fd->io_dir == 0) { |
|---|
| 383 | | - cmd_pkt->control_flags = cpu_to_le16(CF_NVME_ENABLE); |
|---|
| 463 | + cmd_pkt->control_flags = 0; |
|---|
| 464 | + } |
|---|
| 465 | + /* Set BIT_13 of control flags for Async event */ |
|---|
| 466 | + if (vha->flags.nvme2_enabled && |
|---|
| 467 | + cmd->sqe.common.opcode == nvme_admin_async_event) { |
|---|
| 468 | + cmd_pkt->control_flags |= cpu_to_le16(CF_ADMIN_ASYNC_EVENT); |
|---|
| 384 | 469 | } |
|---|
| 385 | 470 | |
|---|
| 386 | 471 | /* Set NPORT-ID */ |
|---|
| .. | .. |
|---|
| 392 | 477 | |
|---|
| 393 | 478 | /* NVME RSP IU */ |
|---|
| 394 | 479 | cmd_pkt->nvme_rsp_dsd_len = cpu_to_le16(fd->rsplen); |
|---|
| 395 | | - cmd_pkt->nvme_rsp_dseg_address[0] = cpu_to_le32(LSD(fd->rspdma)); |
|---|
| 396 | | - cmd_pkt->nvme_rsp_dseg_address[1] = cpu_to_le32(MSD(fd->rspdma)); |
|---|
| 480 | + put_unaligned_le64(fd->rspdma, &cmd_pkt->nvme_rsp_dseg_address); |
|---|
| 397 | 481 | |
|---|
| 398 | 482 | /* NVME CNMD IU */ |
|---|
| 399 | 483 | cmd_pkt->nvme_cmnd_dseg_len = cpu_to_le16(fd->cmdlen); |
|---|
| 400 | | - cmd_pkt->nvme_cmnd_dseg_address[0] = cpu_to_le32(LSD(fd->cmddma)); |
|---|
| 401 | | - cmd_pkt->nvme_cmnd_dseg_address[1] = cpu_to_le32(MSD(fd->cmddma)); |
|---|
| 484 | + cmd_pkt->nvme_cmnd_dseg_address = cpu_to_le64(fd->cmddma); |
|---|
| 402 | 485 | |
|---|
| 403 | 486 | cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); |
|---|
| 404 | 487 | cmd_pkt->byte_count = cpu_to_le32(fd->payload_length); |
|---|
| 405 | 488 | |
|---|
| 406 | 489 | /* One DSD is available in the Command Type NVME IOCB */ |
|---|
| 407 | 490 | avail_dsds = 1; |
|---|
| 408 | | - cur_dsd = (uint32_t *)&cmd_pkt->nvme_data_dseg_address[0]; |
|---|
| 491 | + cur_dsd = &cmd_pkt->nvme_dsd; |
|---|
| 409 | 492 | sgl = fd->first_sgl; |
|---|
| 410 | 493 | |
|---|
| 411 | 494 | /* Load data segments */ |
|---|
| 412 | 495 | for_each_sg(sgl, sg, tot_dsds, i) { |
|---|
| 413 | | - dma_addr_t sle_dma; |
|---|
| 414 | 496 | cont_a64_entry_t *cont_pkt; |
|---|
| 415 | 497 | |
|---|
| 416 | 498 | /* Allocate additional continuation packets? */ |
|---|
| .. | .. |
|---|
| 429 | 511 | req->ring_ptr++; |
|---|
| 430 | 512 | } |
|---|
| 431 | 513 | cont_pkt = (cont_a64_entry_t *)req->ring_ptr; |
|---|
| 432 | | - *((uint32_t *)(&cont_pkt->entry_type)) = |
|---|
| 433 | | - cpu_to_le32(CONTINUE_A64_TYPE); |
|---|
| 514 | + put_unaligned_le32(CONTINUE_A64_TYPE, |
|---|
| 515 | + &cont_pkt->entry_type); |
|---|
| 434 | 516 | |
|---|
| 435 | | - cur_dsd = (uint32_t *)cont_pkt->dseg_0_address; |
|---|
| 436 | | - avail_dsds = 5; |
|---|
| 517 | + cur_dsd = cont_pkt->dsd; |
|---|
| 518 | + avail_dsds = ARRAY_SIZE(cont_pkt->dsd); |
|---|
| 437 | 519 | } |
|---|
| 438 | 520 | |
|---|
| 439 | | - sle_dma = sg_dma_address(sg); |
|---|
| 440 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
|---|
| 441 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
|---|
| 442 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
|---|
| 521 | + append_dsd64(&cur_dsd, sg); |
|---|
| 443 | 522 | avail_dsds--; |
|---|
| 444 | 523 | } |
|---|
| 445 | 524 | |
|---|
| .. | .. |
|---|
| 457 | 536 | } |
|---|
| 458 | 537 | |
|---|
| 459 | 538 | /* Set chip new ring index. */ |
|---|
| 460 | | - WRT_REG_DWORD(req->req_q_in, req->ring_index); |
|---|
| 539 | + wrt_reg_dword(req->req_q_in, req->ring_index); |
|---|
| 461 | 540 | |
|---|
| 462 | 541 | queuing_error: |
|---|
| 463 | 542 | spin_unlock_irqrestore(&qpair->qp_lock, flags); |
|---|
| 543 | + |
|---|
| 464 | 544 | return rval; |
|---|
| 465 | 545 | } |
|---|
| 466 | 546 | |
|---|
| .. | .. |
|---|
| 472 | 552 | fc_port_t *fcport; |
|---|
| 473 | 553 | struct srb_iocb *nvme; |
|---|
| 474 | 554 | struct scsi_qla_host *vha; |
|---|
| 475 | | - int rval = -ENODEV; |
|---|
| 555 | + int rval; |
|---|
| 476 | 556 | srb_t *sp; |
|---|
| 477 | 557 | struct qla_qpair *qpair = hw_queue_handle; |
|---|
| 478 | 558 | struct nvme_private *priv = fd->private; |
|---|
| .. | .. |
|---|
| 480 | 560 | |
|---|
| 481 | 561 | if (!priv) { |
|---|
| 482 | 562 | /* nvme association has been torn down */ |
|---|
| 483 | | - return rval; |
|---|
| 563 | + return -ENODEV; |
|---|
| 484 | 564 | } |
|---|
| 485 | 565 | |
|---|
| 486 | 566 | fcport = qla_rport->fcport; |
|---|
| 487 | 567 | |
|---|
| 568 | + if (!qpair || !fcport) |
|---|
| 569 | + return -ENODEV; |
|---|
| 570 | + |
|---|
| 571 | + if (!qpair->fw_started || fcport->deleted) |
|---|
| 572 | + return -EBUSY; |
|---|
| 573 | + |
|---|
| 488 | 574 | vha = fcport->vha; |
|---|
| 489 | 575 | |
|---|
| 490 | | - if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) |
|---|
| 491 | | - return rval; |
|---|
| 576 | + if (!(fcport->nvme_flag & NVME_FLAG_REGISTERED)) |
|---|
| 577 | + return -ENODEV; |
|---|
| 578 | + |
|---|
| 579 | + if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) || |
|---|
| 580 | + (qpair && !qpair->fw_started) || fcport->deleted) |
|---|
| 581 | + return -EBUSY; |
|---|
| 492 | 582 | |
|---|
| 493 | 583 | /* |
|---|
| 494 | 584 | * If we know the dev is going away while the transport is still sending |
|---|
| .. | .. |
|---|
| 501 | 591 | return -EBUSY; |
|---|
| 502 | 592 | |
|---|
| 503 | 593 | /* Alloc SRB structure */ |
|---|
| 504 | | - sp = qla2xxx_get_qpair_sp(qpair, fcport, GFP_ATOMIC); |
|---|
| 594 | + sp = qla2xxx_get_qpair_sp(vha, qpair, fcport, GFP_ATOMIC); |
|---|
| 505 | 595 | if (!sp) |
|---|
| 506 | 596 | return -EBUSY; |
|---|
| 507 | 597 | |
|---|
| 508 | | - atomic_set(&sp->ref_count, 1); |
|---|
| 509 | | - init_waitqueue_head(&sp->nvme_ls_waitq); |
|---|
| 598 | + kref_init(&sp->cmd_kref); |
|---|
| 599 | + spin_lock_init(&priv->cmd_lock); |
|---|
| 600 | + sp->priv = priv; |
|---|
| 510 | 601 | priv->sp = sp; |
|---|
| 511 | 602 | sp->type = SRB_NVME_CMD; |
|---|
| 512 | 603 | sp->name = "nvme_cmd"; |
|---|
| 513 | 604 | sp->done = qla_nvme_sp_done; |
|---|
| 605 | + sp->put_fn = qla_nvme_release_fcp_cmd_kref; |
|---|
| 514 | 606 | sp->qpair = qpair; |
|---|
| 515 | 607 | sp->vha = vha; |
|---|
| 516 | 608 | nvme = &sp->u.iocb_cmd; |
|---|
| .. | .. |
|---|
| 518 | 610 | |
|---|
| 519 | 611 | rval = qla2x00_start_nvme_mq(sp); |
|---|
| 520 | 612 | if (rval != QLA_SUCCESS) { |
|---|
| 521 | | - ql_log(ql_log_warn, vha, 0x212d, |
|---|
| 613 | + ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x212d, |
|---|
| 522 | 614 | "qla2x00_start_nvme_mq failed = %d\n", rval); |
|---|
| 523 | | - atomic_dec(&sp->ref_count); |
|---|
| 524 | | - wake_up(&sp->nvme_ls_waitq); |
|---|
| 615 | + sp->priv = NULL; |
|---|
| 616 | + priv->sp = NULL; |
|---|
| 617 | + qla2xxx_rel_qpair_sp(sp->qpair, sp); |
|---|
| 525 | 618 | } |
|---|
| 526 | 619 | |
|---|
| 527 | 620 | return rval; |
|---|
| .. | .. |
|---|
| 540 | 633 | static void qla_nvme_remoteport_delete(struct nvme_fc_remote_port *rport) |
|---|
| 541 | 634 | { |
|---|
| 542 | 635 | fc_port_t *fcport; |
|---|
| 543 | | - struct qla_nvme_rport *qla_rport = rport->private, *trport; |
|---|
| 636 | + struct qla_nvme_rport *qla_rport = rport->private; |
|---|
| 544 | 637 | |
|---|
| 545 | 638 | fcport = qla_rport->fcport; |
|---|
| 546 | 639 | fcport->nvme_remote_port = NULL; |
|---|
| 547 | 640 | fcport->nvme_flag &= ~NVME_FLAG_REGISTERED; |
|---|
| 548 | | - |
|---|
| 549 | | - list_for_each_entry_safe(qla_rport, trport, |
|---|
| 550 | | - &fcport->vha->nvme_rport_list, list) { |
|---|
| 551 | | - if (qla_rport->fcport == fcport) { |
|---|
| 552 | | - list_del(&qla_rport->list); |
|---|
| 553 | | - break; |
|---|
| 554 | | - } |
|---|
| 555 | | - } |
|---|
| 556 | | - complete(&fcport->nvme_del_done); |
|---|
| 557 | | - |
|---|
| 558 | | - if (!test_bit(UNLOADING, &fcport->vha->dpc_flags)) { |
|---|
| 559 | | - INIT_WORK(&fcport->free_work, qlt_free_session_done); |
|---|
| 560 | | - schedule_work(&fcport->free_work); |
|---|
| 561 | | - } |
|---|
| 562 | | - |
|---|
| 563 | 641 | fcport->nvme_flag &= ~NVME_FLAG_DELETING; |
|---|
| 564 | 642 | ql_log(ql_log_info, fcport->vha, 0x2110, |
|---|
| 565 | | - "remoteport_delete of %p completed.\n", fcport); |
|---|
| 643 | + "remoteport_delete of %p %8phN completed.\n", |
|---|
| 644 | + fcport, fcport->port_name); |
|---|
| 645 | + complete(&fcport->nvme_del_done); |
|---|
| 566 | 646 | } |
|---|
| 567 | 647 | |
|---|
| 568 | 648 | static struct nvme_fc_port_template qla_nvme_fc_transport = { |
|---|
| .. | .. |
|---|
| 574 | 654 | .ls_abort = qla_nvme_ls_abort, |
|---|
| 575 | 655 | .fcp_io = qla_nvme_post_cmd, |
|---|
| 576 | 656 | .fcp_abort = qla_nvme_fcp_abort, |
|---|
| 577 | | - .poll_queue = qla_nvme_poll, |
|---|
| 578 | 657 | .max_hw_queues = 8, |
|---|
| 579 | | - .max_sgl_segments = 128, |
|---|
| 658 | + .max_sgl_segments = 1024, |
|---|
| 580 | 659 | .max_dif_sgl_segments = 64, |
|---|
| 581 | 660 | .dma_boundary = 0xFFFFFFFF, |
|---|
| 582 | 661 | .local_priv_sz = 8, |
|---|
| .. | .. |
|---|
| 585 | 664 | .fcprqst_priv_sz = sizeof(struct nvme_private), |
|---|
| 586 | 665 | }; |
|---|
| 587 | 666 | |
|---|
| 588 | | -#define NVME_ABORT_POLLING_PERIOD 2 |
|---|
| 589 | | -static int qla_nvme_wait_on_command(srb_t *sp) |
|---|
| 667 | +void qla_nvme_unregister_remote_port(struct fc_port *fcport) |
|---|
| 590 | 668 | { |
|---|
| 591 | | - int ret = QLA_SUCCESS; |
|---|
| 592 | | - |
|---|
| 593 | | - wait_event_timeout(sp->nvme_ls_waitq, (atomic_read(&sp->ref_count) > 1), |
|---|
| 594 | | - NVME_ABORT_POLLING_PERIOD*HZ); |
|---|
| 595 | | - |
|---|
| 596 | | - if (atomic_read(&sp->ref_count) > 1) |
|---|
| 597 | | - ret = QLA_FUNCTION_FAILED; |
|---|
| 598 | | - |
|---|
| 599 | | - return ret; |
|---|
| 600 | | -} |
|---|
| 601 | | - |
|---|
| 602 | | -void qla_nvme_abort(struct qla_hw_data *ha, struct srb *sp, int res) |
|---|
| 603 | | -{ |
|---|
| 604 | | - int rval; |
|---|
| 605 | | - |
|---|
| 606 | | - if (ha->flags.fw_started) { |
|---|
| 607 | | - rval = ha->isp_ops->abort_command(sp); |
|---|
| 608 | | - if (!rval && !qla_nvme_wait_on_command(sp)) |
|---|
| 609 | | - ql_log(ql_log_warn, NULL, 0x2112, |
|---|
| 610 | | - "timed out waiting on sp=%p\n", sp); |
|---|
| 611 | | - } else { |
|---|
| 612 | | - sp->done(sp, res); |
|---|
| 613 | | - } |
|---|
| 614 | | -} |
|---|
| 615 | | - |
|---|
| 616 | | -static void qla_nvme_unregister_remote_port(struct work_struct *work) |
|---|
| 617 | | -{ |
|---|
| 618 | | - struct fc_port *fcport = container_of(work, struct fc_port, |
|---|
| 619 | | - nvme_del_work); |
|---|
| 620 | | - struct qla_nvme_rport *qla_rport, *trport; |
|---|
| 669 | + int ret; |
|---|
| 621 | 670 | |
|---|
| 622 | 671 | if (!IS_ENABLED(CONFIG_NVME_FC)) |
|---|
| 623 | 672 | return; |
|---|
| 624 | 673 | |
|---|
| 625 | 674 | ql_log(ql_log_warn, NULL, 0x2112, |
|---|
| 626 | | - "%s: unregister remoteport on %p\n",__func__, fcport); |
|---|
| 675 | + "%s: unregister remoteport on %p %8phN\n", |
|---|
| 676 | + __func__, fcport, fcport->port_name); |
|---|
| 627 | 677 | |
|---|
| 628 | | - list_for_each_entry_safe(qla_rport, trport, |
|---|
| 629 | | - &fcport->vha->nvme_rport_list, list) { |
|---|
| 630 | | - if (qla_rport->fcport == fcport) { |
|---|
| 631 | | - ql_log(ql_log_info, fcport->vha, 0x2113, |
|---|
| 632 | | - "%s: fcport=%p\n", __func__, fcport); |
|---|
| 633 | | - init_completion(&fcport->nvme_del_done); |
|---|
| 634 | | - nvme_fc_unregister_remoteport( |
|---|
| 635 | | - fcport->nvme_remote_port); |
|---|
| 636 | | - wait_for_completion(&fcport->nvme_del_done); |
|---|
| 637 | | - break; |
|---|
| 638 | | - } |
|---|
| 639 | | - } |
|---|
| 678 | + if (test_bit(PFLG_DRIVER_REMOVING, &fcport->vha->pci_flags)) |
|---|
| 679 | + nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port, 0); |
|---|
| 680 | + |
|---|
| 681 | + init_completion(&fcport->nvme_del_done); |
|---|
| 682 | + ret = nvme_fc_unregister_remoteport(fcport->nvme_remote_port); |
|---|
| 683 | + if (ret) |
|---|
| 684 | + ql_log(ql_log_info, fcport->vha, 0x2114, |
|---|
| 685 | + "%s: Failed to unregister nvme_remote_port (%d)\n", |
|---|
| 686 | + __func__, ret); |
|---|
| 687 | + wait_for_completion(&fcport->nvme_del_done); |
|---|
| 640 | 688 | } |
|---|
| 641 | 689 | |
|---|
| 642 | 690 | void qla_nvme_delete(struct scsi_qla_host *vha) |
|---|
| 643 | 691 | { |
|---|
| 644 | | - struct qla_nvme_rport *qla_rport, *trport; |
|---|
| 645 | | - fc_port_t *fcport; |
|---|
| 646 | 692 | int nv_ret; |
|---|
| 647 | 693 | |
|---|
| 648 | 694 | if (!IS_ENABLED(CONFIG_NVME_FC)) |
|---|
| 649 | 695 | return; |
|---|
| 650 | | - |
|---|
| 651 | | - list_for_each_entry_safe(qla_rport, trport, |
|---|
| 652 | | - &vha->nvme_rport_list, list) { |
|---|
| 653 | | - fcport = qla_rport->fcport; |
|---|
| 654 | | - |
|---|
| 655 | | - ql_log(ql_log_info, fcport->vha, 0x2114, "%s: fcport=%p\n", |
|---|
| 656 | | - __func__, fcport); |
|---|
| 657 | | - |
|---|
| 658 | | - nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port, 0); |
|---|
| 659 | | - } |
|---|
| 660 | 696 | |
|---|
| 661 | 697 | if (vha->nvme_local_port) { |
|---|
| 662 | 698 | init_completion(&vha->nvme_del_done); |
|---|
| .. | .. |
|---|
| 686 | 722 | tmpl = &qla_nvme_fc_transport; |
|---|
| 687 | 723 | |
|---|
| 688 | 724 | WARN_ON(vha->nvme_local_port); |
|---|
| 689 | | - WARN_ON(ha->max_req_queues < 3); |
|---|
| 690 | 725 | |
|---|
| 691 | 726 | qla_nvme_fc_transport.max_hw_queues = |
|---|
| 692 | 727 | min((uint8_t)(qla_nvme_fc_transport.max_hw_queues), |
|---|
| 693 | | - (uint8_t)(ha->max_req_queues - 2)); |
|---|
| 728 | + (uint8_t)(ha->max_qpairs ? ha->max_qpairs : 1)); |
|---|
| 694 | 729 | |
|---|
| 695 | 730 | pinfo.node_name = wwn_to_u64(vha->node_name); |
|---|
| 696 | 731 | pinfo.port_name = wwn_to_u64(vha->port_name); |
|---|