^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*******************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * This file is part of the Emulex Linux Device Driver for *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Fibre Channel Host Bus Adapters. *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2017-2020 Broadcom. All Rights Reserved. The term *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2004-2016 Emulex. All rights reserved. *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * EMULEX and SLI are trademarks of Emulex. *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * www.broadcom.com *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Portions Copyright (C) 2004-2005 Christoph Hellwig *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * This program is free software; you can redistribute it and/or *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * modify it under the terms of version 2 of the GNU General *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Public License as published by the Free Software Foundation. *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * This program is distributed in the hope that it will be useful. *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * TO BE LEGALLY INVALID. See the GNU General Public License for *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * more details, a copy of which can be found in the file COPYING *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * included with this package. *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *******************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/t10-pi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/crc-t10dif.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <net/checksum.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <scsi/scsi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <scsi/scsi_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <scsi/scsi_eh.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <scsi/scsi_host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <scsi/scsi_tcq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <scsi/scsi_transport_fc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include "lpfc_version.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include "lpfc_hw4.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include "lpfc_hw.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include "lpfc_sli.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include "lpfc_sli4.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #include "lpfc_nl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include "lpfc_disc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include "lpfc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #include "lpfc_scsi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #include "lpfc_logmsg.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #include "lpfc_crtn.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #include "lpfc_vport.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define LPFC_RESET_WAIT 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define LPFC_ABORT_WAIT 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static char *dif_op_str[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) "PROT_NORMAL",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) "PROT_READ_INSERT",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) "PROT_WRITE_STRIP",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) "PROT_READ_STRIP",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) "PROT_WRITE_INSERT",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) "PROT_READ_PASS",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) "PROT_WRITE_PASS",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct scsi_dif_tuple {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) __be16 guard_tag; /* Checksum */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) __be16 app_tag; /* Opaque storage */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) __be32 ref_tag; /* Target LBA or indirect LBA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static struct lpfc_rport_data *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) lpfc_rport_data_from_scsi_device(struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct lpfc_vport *vport = (struct lpfc_vport *)sdev->host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if (vport->phba->cfg_fof)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) return ((struct lpfc_device_data *)sdev->hostdata)->rport_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) return (struct lpfc_rport_data *)sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *psb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) lpfc_release_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_io_buf *psb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) lpfc_prot_group_type(struct lpfc_hba *phba, struct scsi_cmnd *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) static inline unsigned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) lpfc_cmd_blksize(struct scsi_cmnd *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) return sc->device->sector_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #define LPFC_CHECK_PROTECT_GUARD 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #define LPFC_CHECK_PROTECT_REF 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static inline unsigned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) lpfc_cmd_protect(struct scsi_cmnd *sc, int flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static inline unsigned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) lpfc_cmd_guard_csum(struct scsi_cmnd *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) if (lpfc_prot_group_type(NULL, sc) == LPFC_PG_TYPE_NO_DIF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (scsi_host_get_guard(sc->device->host) == SHOST_DIX_GUARD_IP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * lpfc_sli4_set_rsp_sgl_last - Set the last bit in the response sge.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * @phba: Pointer to HBA object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * @lpfc_cmd: lpfc scsi command object pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * This function is called from the lpfc_prep_task_mgmt_cmd function to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * set the last bit in the response sge entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) lpfc_sli4_set_rsp_sgl_last(struct lpfc_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) if (sgl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) sgl += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) sgl->word2 = le32_to_cpu(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) bf_set(lpfc_sli4_sge_last, sgl, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) sgl->word2 = cpu_to_le32(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * lpfc_update_stats - Update statistical data for the command completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * @vport: The virtual port on which this call is executing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * @lpfc_cmd: lpfc scsi command object pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * This function is called when there is a command completion and this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * function updates the statistical data for the command completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) lpfc_update_stats(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct lpfc_rport_data *rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct lpfc_nodelist *pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct scsi_cmnd *cmd = lpfc_cmd->pCmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) unsigned long latency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (!vport->stat_data_enabled ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) vport->stat_data_blocked ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) (cmd->result))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) latency = jiffies_to_msecs((long)jiffies - (long)lpfc_cmd->start_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) rdata = lpfc_cmd->rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) pnode = rdata->pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) spin_lock_irqsave(shost->host_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) if (!pnode ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) !pnode->lat_data ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) (phba->bucket_type == LPFC_NO_BUCKET)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) spin_unlock_irqrestore(shost->host_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (phba->bucket_type == LPFC_LINEAR_BUCKET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) i = (latency + phba->bucket_step - 1 - phba->bucket_base)/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) phba->bucket_step;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /* check array subscript bounds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (i < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) else if (i >= LPFC_MAX_BUCKET_COUNT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) i = LPFC_MAX_BUCKET_COUNT - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) for (i = 0; i < LPFC_MAX_BUCKET_COUNT-1; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (latency <= (phba->bucket_base +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) ((1<<i)*phba->bucket_step)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) pnode->lat_data[i].cmd_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) spin_unlock_irqrestore(shost->host_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * lpfc_rampdown_queue_depth - Post RAMP_DOWN_QUEUE event to worker thread
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * This routine is called when there is resource error in driver or firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) * This routine posts WORKER_RAMP_DOWN_QUEUE event for @phba. This routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * posts at most 1 event each second. This routine wakes up worker thread of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * @phba to process WORKER_RAM_DOWN_EVENT event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * This routine should be called with no lock held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) uint32_t evt_posted;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) unsigned long expires;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) spin_lock_irqsave(&phba->hbalock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) atomic_inc(&phba->num_rsrc_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) phba->last_rsrc_error_time = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) expires = phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (time_after(expires, jiffies)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) spin_unlock_irqrestore(&phba->hbalock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) phba->last_ramp_down_time = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) spin_unlock_irqrestore(&phba->hbalock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) spin_lock_irqsave(&phba->pport->work_port_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) evt_posted = phba->pport->work_port_events & WORKER_RAMP_DOWN_QUEUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (!evt_posted)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) phba->pport->work_port_events |= WORKER_RAMP_DOWN_QUEUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) spin_unlock_irqrestore(&phba->pport->work_port_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (!evt_posted)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) lpfc_worker_wake_up(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) * lpfc_ramp_down_queue_handler - WORKER_RAMP_DOWN_QUEUE event handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) * This routine is called to process WORKER_RAMP_DOWN_QUEUE event for worker
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) * thread.This routine reduces queue depth for all scsi device on each vport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) * associated with @phba.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) struct lpfc_vport **vports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) unsigned long new_queue_depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) unsigned long num_rsrc_err, num_cmd_success;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) num_rsrc_err = atomic_read(&phba->num_rsrc_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) num_cmd_success = atomic_read(&phba->num_cmd_success);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * The error and success command counters are global per
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * driver instance. If another handler has already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * operated on this error event, just exit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) if (num_rsrc_err == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) vports = lpfc_create_vport_work_array(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if (vports != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) shost = lpfc_shost_from_vport(vports[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) shost_for_each_device(sdev, shost) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) new_queue_depth =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) sdev->queue_depth * num_rsrc_err /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) (num_rsrc_err + num_cmd_success);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) if (!new_queue_depth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) new_queue_depth = sdev->queue_depth - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) new_queue_depth = sdev->queue_depth -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) new_queue_depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) scsi_change_queue_depth(sdev, new_queue_depth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) lpfc_destroy_vport_work_array(phba, vports);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) atomic_set(&phba->num_rsrc_err, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) atomic_set(&phba->num_cmd_success, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) * lpfc_scsi_dev_block - set all scsi hosts to block state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) * @phba: Pointer to HBA context object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * This function walks vport list and set each SCSI host to block state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) * by invoking fc_remote_port_delete() routine. This function is invoked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) * with EEH when device's PCI slot has been permanently disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) lpfc_scsi_dev_block(struct lpfc_hba *phba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) struct lpfc_vport **vports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) struct fc_rport *rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) vports = lpfc_create_vport_work_array(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) if (vports != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) shost = lpfc_shost_from_vport(vports[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) shost_for_each_device(sdev, shost) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) rport = starget_to_rport(scsi_target(sdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) fc_remote_port_delete(rport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) lpfc_destroy_vport_work_array(phba, vports);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) * lpfc_new_scsi_buf_s3 - Scsi buffer allocator for HBA with SLI3 IF spec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) * @vport: The virtual port for which this call being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) * @num_to_allocate: The requested number of buffers to allocate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) * This routine allocates a scsi buffer for device with SLI-3 interface spec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) * the scsi buffer contains all the necessary information needed to initiate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) * a SCSI I/O. The non-DMAable buffer region contains information to build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) * the IOCB. The DMAable region contains memory for the FCP CMND, FCP RSP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * and the initial BPL. In addition to allocating memory, the FCP CMND and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) * FCP RSP BDEs are setup in the BPL and the BPL BDE is setup in the IOCB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) * int - number of scsi buffers that were allocated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) * 0 = failure, less than num_to_alloc is a partial failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) lpfc_new_scsi_buf_s3(struct lpfc_vport *vport, int num_to_alloc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) struct lpfc_io_buf *psb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) struct ulp_bde64 *bpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) IOCB_t *iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) dma_addr_t pdma_phys_fcp_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) dma_addr_t pdma_phys_fcp_rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) dma_addr_t pdma_phys_sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) uint16_t iotag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) int bcnt, bpl_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) bpl_size = phba->cfg_sg_dma_buf_size -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) (sizeof(struct fcp_cmnd) + sizeof(struct fcp_rsp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) "9067 ALLOC %d scsi_bufs: %d (%d + %d + %d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) num_to_alloc, phba->cfg_sg_dma_buf_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) (int)sizeof(struct fcp_cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) (int)sizeof(struct fcp_rsp), bpl_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) for (bcnt = 0; bcnt < num_to_alloc; bcnt++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) psb = kzalloc(sizeof(struct lpfc_io_buf), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) if (!psb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) * Get memory from the pci pool to map the virt space to pci
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) * bus space for an I/O. The DMA buffer includes space for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) * struct fcp_cmnd, struct fcp_rsp and the number of bde's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) * necessary to support the sg_tablesize.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) psb->data = dma_pool_zalloc(phba->lpfc_sg_dma_buf_pool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) GFP_KERNEL, &psb->dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) if (!psb->data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) kfree(psb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) /* Allocate iotag for psb->cur_iocbq. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) iotag = lpfc_sli_next_iotag(phba, &psb->cur_iocbq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) if (iotag == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) dma_pool_free(phba->lpfc_sg_dma_buf_pool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) psb->data, psb->dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) kfree(psb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) psb->cur_iocbq.iocb_flag |= LPFC_IO_FCP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) psb->fcp_cmnd = psb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) psb->fcp_rsp = psb->data + sizeof(struct fcp_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) psb->dma_sgl = psb->data + sizeof(struct fcp_cmnd) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) sizeof(struct fcp_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) /* Initialize local short-hand pointers. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) bpl = (struct ulp_bde64 *)psb->dma_sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) pdma_phys_fcp_cmd = psb->dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) pdma_phys_fcp_rsp = psb->dma_handle + sizeof(struct fcp_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) pdma_phys_sgl = psb->dma_handle + sizeof(struct fcp_cmnd) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) sizeof(struct fcp_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) * The first two bdes are the FCP_CMD and FCP_RSP. The balance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) * are sg list bdes. Initialize the first two and leave the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) * rest for queuecommand.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) bpl[0].addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys_fcp_cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) bpl[0].addrLow = le32_to_cpu(putPaddrLow(pdma_phys_fcp_cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) bpl[0].tus.f.bdeSize = sizeof(struct fcp_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) bpl[0].tus.f.bdeFlags = BUFF_TYPE_BDE_64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) bpl[0].tus.w = le32_to_cpu(bpl[0].tus.w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) /* Setup the physical region for the FCP RSP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) bpl[1].addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys_fcp_rsp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) bpl[1].addrLow = le32_to_cpu(putPaddrLow(pdma_phys_fcp_rsp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) bpl[1].tus.f.bdeSize = sizeof(struct fcp_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) bpl[1].tus.f.bdeFlags = BUFF_TYPE_BDE_64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) bpl[1].tus.w = le32_to_cpu(bpl[1].tus.w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) * Since the IOCB for the FCP I/O is built into this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) * lpfc_scsi_buf, initialize it with all known data now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) iocb = &psb->cur_iocbq.iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) iocb->un.fcpi64.bdl.ulpIoTag32 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) if ((phba->sli_rev == 3) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) !(phba->sli3_options & LPFC_SLI3_BG_ENABLED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) /* fill in immediate fcp command BDE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BDE_IMMED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) iocb->un.fcpi64.bdl.bdeSize = sizeof(struct fcp_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) iocb->un.fcpi64.bdl.addrLow = offsetof(IOCB_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) unsli3.fcp_ext.icd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) iocb->un.fcpi64.bdl.addrHigh = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) iocb->ulpBdeCount = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) iocb->ulpLe = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) /* fill in response BDE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) iocb->unsli3.fcp_ext.rbde.tus.f.bdeFlags =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) BUFF_TYPE_BDE_64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) iocb->unsli3.fcp_ext.rbde.tus.f.bdeSize =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) sizeof(struct fcp_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) iocb->unsli3.fcp_ext.rbde.addrLow =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) putPaddrLow(pdma_phys_fcp_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) iocb->unsli3.fcp_ext.rbde.addrHigh =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) putPaddrHigh(pdma_phys_fcp_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BLP_64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) iocb->un.fcpi64.bdl.bdeSize =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) (2 * sizeof(struct ulp_bde64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) iocb->un.fcpi64.bdl.addrLow =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) putPaddrLow(pdma_phys_sgl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) iocb->un.fcpi64.bdl.addrHigh =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) putPaddrHigh(pdma_phys_sgl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) iocb->ulpBdeCount = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) iocb->ulpLe = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) iocb->ulpClass = CLASS3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) psb->status = IOSTAT_SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) /* Put it back into the SCSI buffer list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) psb->cur_iocbq.context1 = psb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) spin_lock_init(&psb->buf_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) lpfc_release_scsi_buf_s3(phba, psb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) return bcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) * lpfc_sli4_vport_delete_fcp_xri_aborted -Remove all ndlp references for vport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) * @vport: pointer to lpfc vport data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) * This routine is invoked by the vport cleanup for deletions and the cleanup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) * for an ndlp on removal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) lpfc_sli4_vport_delete_fcp_xri_aborted(struct lpfc_vport *vport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) struct lpfc_io_buf *psb, *next_psb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) struct lpfc_sli4_hdw_queue *qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) unsigned long iflag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) spin_lock_irqsave(&phba->hbalock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) for (idx = 0; idx < phba->cfg_hdw_queue; idx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) qp = &phba->sli4_hba.hdwq[idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) spin_lock(&qp->abts_io_buf_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) list_for_each_entry_safe(psb, next_psb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) &qp->lpfc_abts_io_buf_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) if (psb->cur_iocbq.iocb_flag & LPFC_IO_NVME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) if (psb->rdata && psb->rdata->pnode &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) psb->rdata->pnode->vport == vport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) psb->rdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) spin_unlock(&qp->abts_io_buf_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) spin_unlock_irqrestore(&phba->hbalock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) * lpfc_sli4_io_xri_aborted - Fast-path process of fcp xri abort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) * @phba: pointer to lpfc hba data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) * @axri: pointer to the fcp xri abort wcqe structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) * This routine is invoked by the worker thread to process a SLI4 fast-path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) * FCP or NVME aborted xri.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) lpfc_sli4_io_xri_aborted(struct lpfc_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) struct sli4_wcqe_xri_aborted *axri, int idx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) uint16_t rxid = bf_get(lpfc_wcqe_xa_remote_xid, axri);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) struct lpfc_io_buf *psb, *next_psb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) struct lpfc_sli4_hdw_queue *qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) unsigned long iflag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) struct lpfc_iocbq *iocbq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) struct lpfc_nodelist *ndlp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) int rrq_empty = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) struct lpfc_sli_ring *pring = phba->sli4_hba.els_wq->pring;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) qp = &phba->sli4_hba.hdwq[idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) spin_lock_irqsave(&phba->hbalock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) spin_lock(&qp->abts_io_buf_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) list_for_each_entry_safe(psb, next_psb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) &qp->lpfc_abts_io_buf_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) if (psb->cur_iocbq.sli4_xritag == xri) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) list_del_init(&psb->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) psb->flags &= ~LPFC_SBUF_XBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) psb->status = IOSTAT_SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) if (psb->cur_iocbq.iocb_flag & LPFC_IO_NVME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) qp->abts_nvme_io_bufs--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) spin_unlock(&qp->abts_io_buf_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) spin_unlock_irqrestore(&phba->hbalock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) lpfc_sli4_nvme_xri_aborted(phba, axri, psb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) qp->abts_scsi_io_bufs--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) spin_unlock(&qp->abts_io_buf_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) if (psb->rdata && psb->rdata->pnode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) ndlp = psb->rdata->pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) ndlp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) rrq_empty = list_empty(&phba->active_rrq_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) spin_unlock_irqrestore(&phba->hbalock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) if (ndlp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) lpfc_set_rrq_active(phba, ndlp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) psb->cur_iocbq.sli4_lxritag, rxid, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) lpfc_sli4_abts_err_handler(phba, ndlp, axri);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) lpfc_release_scsi_buf_s4(phba, psb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) if (rrq_empty)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) lpfc_worker_wake_up(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) spin_unlock(&qp->abts_io_buf_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) for (i = 1; i <= phba->sli.last_iotag; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) iocbq = phba->sli.iocbq_lookup[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) if (!(iocbq->iocb_flag & LPFC_IO_FCP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) (iocbq->iocb_flag & LPFC_IO_LIBDFC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) if (iocbq->sli4_xritag != xri)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) psb = container_of(iocbq, struct lpfc_io_buf, cur_iocbq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) psb->flags &= ~LPFC_SBUF_XBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) spin_unlock_irqrestore(&phba->hbalock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) if (!list_empty(&pring->txq))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) lpfc_worker_wake_up(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) spin_unlock_irqrestore(&phba->hbalock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) * lpfc_get_scsi_buf_s3 - Get a scsi buffer from lpfc_scsi_buf_list of the HBA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) * @phba: The HBA for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) * This routine removes a scsi buffer from head of @phba lpfc_scsi_buf_list list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) * and returns to caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) * NULL - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) * Pointer to lpfc_scsi_buf - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) static struct lpfc_io_buf *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) lpfc_get_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) struct scsi_cmnd *cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) struct lpfc_io_buf *lpfc_cmd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) struct list_head *scsi_buf_list_get = &phba->lpfc_scsi_buf_list_get;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) unsigned long iflag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) spin_lock_irqsave(&phba->scsi_buf_list_get_lock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) list_remove_head(scsi_buf_list_get, lpfc_cmd, struct lpfc_io_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) if (!lpfc_cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) spin_lock(&phba->scsi_buf_list_put_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) list_splice(&phba->lpfc_scsi_buf_list_put,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) &phba->lpfc_scsi_buf_list_get);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_put);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) list_remove_head(scsi_buf_list_get, lpfc_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) struct lpfc_io_buf, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) spin_unlock(&phba->scsi_buf_list_put_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) spin_unlock_irqrestore(&phba->scsi_buf_list_get_lock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) if (lpfc_ndlp_check_qdepth(phba, ndlp) && lpfc_cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) atomic_inc(&ndlp->cmd_pending);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) lpfc_cmd->flags |= LPFC_SBUF_BUMP_QDEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) return lpfc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) * lpfc_get_scsi_buf_s4 - Get a scsi buffer from io_buf_list of the HBA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) * @phba: The HBA for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) * This routine removes a scsi buffer from head of @hdwq io_buf_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) * and returns to caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) * NULL - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) * Pointer to lpfc_scsi_buf - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) static struct lpfc_io_buf *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) struct scsi_cmnd *cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) struct lpfc_io_buf *lpfc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) struct lpfc_sli4_hdw_queue *qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) struct sli4_sge *sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) IOCB_t *iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) dma_addr_t pdma_phys_fcp_rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) dma_addr_t pdma_phys_fcp_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) uint32_t cpu, idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) int tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) struct fcp_cmd_rsp_buf *tmp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) cpu = raw_smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) if (cmnd && phba->cfg_fcp_io_sched == LPFC_FCP_SCHED_BY_HDWQ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) tag = blk_mq_unique_tag(cmnd->request);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) idx = blk_mq_unique_tag_to_hwq(tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) idx = phba->sli4_hba.cpu_map[cpu].hdwq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) lpfc_cmd = lpfc_get_io_buf(phba, ndlp, idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) !phba->cfg_xri_rebalancing);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) if (!lpfc_cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) qp = &phba->sli4_hba.hdwq[idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) qp->empty_io_bufs++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) /* Setup key fields in buffer that may have been changed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) * if other protocols used this buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) lpfc_cmd->cur_iocbq.iocb_flag = LPFC_IO_FCP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) lpfc_cmd->prot_seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) lpfc_cmd->seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) lpfc_cmd->timeout = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) lpfc_cmd->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) lpfc_cmd->start_time = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) lpfc_cmd->waitq = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) lpfc_cmd->cpu = cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) lpfc_cmd->prot_data_type = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) tmp = lpfc_get_cmd_rsp_buf_per_hdwq(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) if (!tmp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) lpfc_release_io_buf(phba, lpfc_cmd, lpfc_cmd->hdwq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) lpfc_cmd->fcp_cmnd = tmp->fcp_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) lpfc_cmd->fcp_rsp = tmp->fcp_rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) * The first two SGEs are the FCP_CMD and FCP_RSP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) * The balance are sg list bdes. Initialize the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) * first two and leave the rest for queuecommand.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) pdma_phys_fcp_cmd = tmp->fcp_cmd_rsp_dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) sgl->addr_hi = cpu_to_le32(putPaddrHigh(pdma_phys_fcp_cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) sgl->addr_lo = cpu_to_le32(putPaddrLow(pdma_phys_fcp_cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) sgl->word2 = le32_to_cpu(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) bf_set(lpfc_sli4_sge_last, sgl, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) sgl->word2 = cpu_to_le32(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) sgl->sge_len = cpu_to_le32(sizeof(struct fcp_cmnd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) sgl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) /* Setup the physical region for the FCP RSP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) pdma_phys_fcp_rsp = pdma_phys_fcp_cmd + sizeof(struct fcp_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) sgl->addr_hi = cpu_to_le32(putPaddrHigh(pdma_phys_fcp_rsp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) sgl->addr_lo = cpu_to_le32(putPaddrLow(pdma_phys_fcp_rsp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) sgl->word2 = le32_to_cpu(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) bf_set(lpfc_sli4_sge_last, sgl, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) sgl->word2 = cpu_to_le32(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) sgl->sge_len = cpu_to_le32(sizeof(struct fcp_rsp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) * Since the IOCB for the FCP I/O is built into this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) * lpfc_io_buf, initialize it with all known data now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) iocb = &lpfc_cmd->cur_iocbq.iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) iocb->un.fcpi64.bdl.ulpIoTag32 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BDE_64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) /* setting the BLP size to 2 * sizeof BDE may not be correct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) * We are setting the bpl to point to out sgl. An sgl's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) * entries are 16 bytes, a bpl entries are 12 bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) iocb->un.fcpi64.bdl.bdeSize = sizeof(struct fcp_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) iocb->un.fcpi64.bdl.addrLow = putPaddrLow(pdma_phys_fcp_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) iocb->un.fcpi64.bdl.addrHigh = putPaddrHigh(pdma_phys_fcp_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) iocb->ulpBdeCount = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) iocb->ulpLe = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) iocb->ulpClass = CLASS3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) if (lpfc_ndlp_check_qdepth(phba, ndlp)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) atomic_inc(&ndlp->cmd_pending);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) lpfc_cmd->flags |= LPFC_SBUF_BUMP_QDEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) return lpfc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) * lpfc_get_scsi_buf - Get a scsi buffer from lpfc_scsi_buf_list of the HBA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) * @phba: The HBA for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) * This routine removes a scsi buffer from head of @phba lpfc_scsi_buf_list list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) * and returns to caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) * NULL - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) * Pointer to lpfc_scsi_buf - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) static struct lpfc_io_buf*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) lpfc_get_scsi_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) struct scsi_cmnd *cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) return phba->lpfc_get_scsi_buf(phba, ndlp, cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) * lpfc_release_scsi_buf - Return a scsi buffer back to hba scsi buf list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) * @psb: The scsi buffer which is being released.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) * This routine releases @psb scsi buffer by adding it to tail of @phba
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) * lpfc_scsi_buf_list list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) lpfc_release_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_io_buf *psb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) unsigned long iflag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) psb->seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) psb->prot_seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) spin_lock_irqsave(&phba->scsi_buf_list_put_lock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) psb->pCmd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) psb->cur_iocbq.iocb_flag = LPFC_IO_FCP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) list_add_tail(&psb->list, &phba->lpfc_scsi_buf_list_put);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) spin_unlock_irqrestore(&phba->scsi_buf_list_put_lock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) * lpfc_release_scsi_buf_s4: Return a scsi buffer back to hba scsi buf list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) * @psb: The scsi buffer which is being released.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) * This routine releases @psb scsi buffer by adding it to tail of @hdwq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) * io_buf_list list. For SLI4 XRI's are tied to the scsi buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) * and cannot be reused for at least RA_TOV amount of time if it was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) * aborted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *psb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) struct lpfc_sli4_hdw_queue *qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) unsigned long iflag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) psb->seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) psb->prot_seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) qp = psb->hdwq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) if (psb->flags & LPFC_SBUF_XBUSY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) spin_lock_irqsave(&qp->abts_io_buf_list_lock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) psb->pCmd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) list_add_tail(&psb->list, &qp->lpfc_abts_io_buf_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) qp->abts_scsi_io_bufs++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) spin_unlock_irqrestore(&qp->abts_io_buf_list_lock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) lpfc_release_io_buf(phba, (struct lpfc_io_buf *)psb, qp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) * lpfc_release_scsi_buf: Return a scsi buffer back to hba scsi buf list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) * @psb: The scsi buffer which is being released.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) * This routine releases @psb scsi buffer by adding it to tail of @phba
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) * lpfc_scsi_buf_list list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) lpfc_release_scsi_buf(struct lpfc_hba *phba, struct lpfc_io_buf *psb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) if ((psb->flags & LPFC_SBUF_BUMP_QDEPTH) && psb->ndlp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) atomic_dec(&psb->ndlp->cmd_pending);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) psb->flags &= ~LPFC_SBUF_BUMP_QDEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) phba->lpfc_release_scsi_buf(phba, psb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) * lpfc_scsi_prep_dma_buf_s3 - DMA mapping for scsi buffer to SLI3 IF spec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) * @lpfc_cmd: The scsi buffer which is going to be mapped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) * This routine does the pci dma mapping for scatter-gather list of scsi cmnd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) * field of @lpfc_cmd for device with SLI-3 interface spec. This routine scans
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) * through sg elements and format the bde. This routine also initializes all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) * IOCB fields which are dependent on scsi command request buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) * 1 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) * 0 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) struct scatterlist *sgel = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) struct ulp_bde64 *bpl = (struct ulp_bde64 *)lpfc_cmd->dma_sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) struct lpfc_iocbq *iocbq = &lpfc_cmd->cur_iocbq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) struct ulp_bde64 *data_bde = iocb_cmd->unsli3.fcp_ext.dbde;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) dma_addr_t physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) uint32_t num_bde = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) int nseg, datadir = scsi_cmnd->sc_data_direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) * There are three possibilities here - use scatter-gather segment, use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) * the single mapping, or neither. Start the lpfc command prep by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) * bumping the bpl beyond the fcp_cmnd and fcp_rsp regions to the first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) * data bde entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) bpl += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) if (scsi_sg_count(scsi_cmnd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) * The driver stores the segment count returned from pci_map_sg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) * because this a count of dma-mappings used to map the use_sg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) * pages. They are not guaranteed to be the same for those
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) * architectures that implement an IOMMU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) nseg = dma_map_sg(&phba->pcidev->dev, scsi_sglist(scsi_cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) scsi_sg_count(scsi_cmnd), datadir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) if (unlikely(!nseg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) lpfc_cmd->seg_cnt = nseg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) "9064 BLKGRD: %s: Too many sg segments"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) " from dma_map_sg. Config %d, seg_cnt"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) " %d\n", __func__, phba->cfg_sg_seg_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) lpfc_cmd->seg_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) WARN_ON_ONCE(lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) lpfc_cmd->seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) scsi_dma_unmap(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) return 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) * The driver established a maximum scatter-gather segment count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) * during probe that limits the number of sg elements in any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) * single scsi command. Just run through the seg_cnt and format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) * the bde's.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) * When using SLI-3 the driver will try to fit all the BDEs into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) * the IOCB. If it can't then the BDEs get added to a BPL as it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) * does for SLI-2 mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) scsi_for_each_sg(scsi_cmnd, sgel, nseg, num_bde) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) physaddr = sg_dma_address(sgel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) if (phba->sli_rev == 3 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) !(phba->sli3_options & LPFC_SLI3_BG_ENABLED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) !(iocbq->iocb_flag & DSS_SECURITY_OP) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) nseg <= LPFC_EXT_DATA_BDE_COUNT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) data_bde->tus.f.bdeFlags = BUFF_TYPE_BDE_64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) data_bde->tus.f.bdeSize = sg_dma_len(sgel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) data_bde->addrLow = putPaddrLow(physaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) data_bde->addrHigh = putPaddrHigh(physaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) data_bde++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) bpl->tus.f.bdeSize = sg_dma_len(sgel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) bpl->tus.w = le32_to_cpu(bpl->tus.w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) bpl->addrLow =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) le32_to_cpu(putPaddrLow(physaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) bpl->addrHigh =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) le32_to_cpu(putPaddrHigh(physaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) bpl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) * Finish initializing those IOCB fields that are dependent on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) * scsi_cmnd request_buffer. Note that for SLI-2 the bdeSize is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) * explicitly reinitialized and for SLI-3 the extended bde count is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) * explicitly reinitialized since all iocb memory resources are reused.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) if (phba->sli_rev == 3 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) !(phba->sli3_options & LPFC_SLI3_BG_ENABLED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) !(iocbq->iocb_flag & DSS_SECURITY_OP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) if (num_bde > LPFC_EXT_DATA_BDE_COUNT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) * The extended IOCB format can only fit 3 BDE or a BPL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) * This I/O has more than 3 BDE so the 1st data bde will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) * be a BPL that is filled in here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) physaddr = lpfc_cmd->dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) data_bde->tus.f.bdeFlags = BUFF_TYPE_BLP_64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) data_bde->tus.f.bdeSize = (num_bde *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) sizeof(struct ulp_bde64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) physaddr += (sizeof(struct fcp_cmnd) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) sizeof(struct fcp_rsp) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) (2 * sizeof(struct ulp_bde64)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) data_bde->addrHigh = putPaddrHigh(physaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) data_bde->addrLow = putPaddrLow(physaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) /* ebde count includes the response bde and data bpl */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) iocb_cmd->unsli3.fcp_ext.ebde_count = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) /* ebde count includes the response bde and data bdes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) iocb_cmd->unsli3.fcp_ext.ebde_count = (num_bde + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) iocb_cmd->un.fcpi64.bdl.bdeSize =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) ((num_bde + 2) * sizeof(struct ulp_bde64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) iocb_cmd->unsli3.fcp_ext.ebde_count = (num_bde + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) fcp_cmnd->fcpDl = cpu_to_be32(scsi_bufflen(scsi_cmnd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) * Due to difference in data length between DIF/non-DIF paths,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) * we need to set word 4 of IOCB here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) iocb_cmd->un.fcpi.fcpi_parm = scsi_bufflen(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) /* Return BG_ERR_INIT if error injection is detected by Initiator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) #define BG_ERR_INIT 0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) /* Return BG_ERR_TGT if error injection is detected by Target */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) #define BG_ERR_TGT 0x2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) /* Return BG_ERR_SWAP if swapping CSUM<-->CRC is required for error injection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) #define BG_ERR_SWAP 0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) * Return BG_ERR_CHECK if disabling Guard/Ref/App checking is required for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) * error injection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) #define BG_ERR_CHECK 0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) * lpfc_bg_err_inject - Determine if we should inject an error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) * @sc: The SCSI command to examine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) * @reftag: (out) BlockGuard reference tag for transmitted data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) * @apptag: (out) BlockGuard application tag for transmitted data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) * @new_guard (in) Value to replace CRC with if needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) * Returns BG_ERR_* bit mask or 0 if request ignored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) uint32_t *reftag, uint16_t *apptag, uint32_t new_guard)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) struct scatterlist *sgpe; /* s/g prot entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) struct lpfc_io_buf *lpfc_cmd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) struct scsi_dif_tuple *src = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) struct lpfc_nodelist *ndlp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) struct lpfc_rport_data *rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) uint32_t op = scsi_get_prot_op(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) uint32_t blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) uint32_t numblks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) sector_t lba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) int blockoff = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) if (op == SCSI_PROT_NORMAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) sgpe = scsi_prot_sglist(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) lba = scsi_get_lba(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) /* First check if we need to match the LBA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) if (phba->lpfc_injerr_lba != LPFC_INJERR_LBA_OFF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) blksize = lpfc_cmd_blksize(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) numblks = (scsi_bufflen(sc) + blksize - 1) / blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) /* Make sure we have the right LBA if one is specified */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) if ((phba->lpfc_injerr_lba < lba) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) (phba->lpfc_injerr_lba >= (lba + numblks)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) if (sgpe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) blockoff = phba->lpfc_injerr_lba - lba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) numblks = sg_dma_len(sgpe) /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) sizeof(struct scsi_dif_tuple);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) if (numblks < blockoff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) blockoff = numblks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) /* Next check if we need to match the remote NPortID or WWPN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) rdata = lpfc_rport_data_from_scsi_device(sc->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) if (rdata && rdata->pnode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) ndlp = rdata->pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) /* Make sure we have the right NPortID if one is specified */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) if (phba->lpfc_injerr_nportid &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) (phba->lpfc_injerr_nportid != ndlp->nlp_DID))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) * Make sure we have the right WWPN if one is specified.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) * wwn[0] should be a non-zero NAA in a good WWPN.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) if (phba->lpfc_injerr_wwpn.u.wwn[0] &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) (memcmp(&ndlp->nlp_portname, &phba->lpfc_injerr_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) sizeof(struct lpfc_name)) != 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) /* Setup a ptr to the protection data if the SCSI host provides it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) if (sgpe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) src = (struct scsi_dif_tuple *)sg_virt(sgpe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) src += blockoff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) lpfc_cmd = (struct lpfc_io_buf *)sc->host_scribble;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) /* Should we change the Reference Tag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) if (reftag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) if (phba->lpfc_injerr_wref_cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) switch (op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) case SCSI_PROT_WRITE_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) if (src) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) * For WRITE_PASS, force the error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) * to be sent on the wire. It should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) * be detected by the Target.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) * If blockoff != 0 error will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) * inserted in middle of the IO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) lpfc_printf_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) "9076 BLKGRD: Injecting reftag error: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) "write lba x%lx + x%x oldrefTag x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) (unsigned long)lba, blockoff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) be32_to_cpu(src->ref_tag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) * Save the old ref_tag so we can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) * restore it on completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) if (lpfc_cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) lpfc_cmd->prot_data_type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) LPFC_INJERR_REFTAG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) lpfc_cmd->prot_data_segment =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) src;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) lpfc_cmd->prot_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) src->ref_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) src->ref_tag = cpu_to_be32(0xDEADBEEF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) phba->lpfc_injerr_wref_cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) if (phba->lpfc_injerr_wref_cnt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) phba->lpfc_injerr_nportid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) phba->lpfc_injerr_lba =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) LPFC_INJERR_LBA_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) memset(&phba->lpfc_injerr_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 0, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) rc = BG_ERR_TGT | BG_ERR_CHECK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) case SCSI_PROT_WRITE_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) * For WRITE_INSERT, force the error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) * to be sent on the wire. It should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) * detected by the Target.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) /* DEADBEEF will be the reftag on the wire */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) *reftag = 0xDEADBEEF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) phba->lpfc_injerr_wref_cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) if (phba->lpfc_injerr_wref_cnt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) phba->lpfc_injerr_nportid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) phba->lpfc_injerr_lba =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) LPFC_INJERR_LBA_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) memset(&phba->lpfc_injerr_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 0, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) rc = BG_ERR_TGT | BG_ERR_CHECK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) "9078 BLKGRD: Injecting reftag error: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) "write lba x%lx\n", (unsigned long)lba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) case SCSI_PROT_WRITE_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) * For WRITE_STRIP and WRITE_PASS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) * force the error on data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) * being copied from SLI-Host to SLI-Port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) *reftag = 0xDEADBEEF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) phba->lpfc_injerr_wref_cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) if (phba->lpfc_injerr_wref_cnt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) phba->lpfc_injerr_nportid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) phba->lpfc_injerr_lba =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) LPFC_INJERR_LBA_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) memset(&phba->lpfc_injerr_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 0, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) rc = BG_ERR_INIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) "9077 BLKGRD: Injecting reftag error: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) "write lba x%lx\n", (unsigned long)lba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) if (phba->lpfc_injerr_rref_cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) switch (op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) case SCSI_PROT_READ_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) case SCSI_PROT_READ_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) case SCSI_PROT_READ_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) * For READ_STRIP and READ_PASS, force the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) * error on data being read off the wire. It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) * should force an IO error to the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) *reftag = 0xDEADBEEF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) phba->lpfc_injerr_rref_cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) if (phba->lpfc_injerr_rref_cnt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) phba->lpfc_injerr_nportid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) phba->lpfc_injerr_lba =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) LPFC_INJERR_LBA_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) memset(&phba->lpfc_injerr_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 0, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) rc = BG_ERR_INIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) "9079 BLKGRD: Injecting reftag error: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) "read lba x%lx\n", (unsigned long)lba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) /* Should we change the Application Tag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) if (apptag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) if (phba->lpfc_injerr_wapp_cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) switch (op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) case SCSI_PROT_WRITE_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) if (src) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) * For WRITE_PASS, force the error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) * to be sent on the wire. It should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) * be detected by the Target.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) * If blockoff != 0 error will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) * inserted in middle of the IO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) lpfc_printf_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) "9080 BLKGRD: Injecting apptag error: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) "write lba x%lx + x%x oldappTag x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) (unsigned long)lba, blockoff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) be16_to_cpu(src->app_tag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) * Save the old app_tag so we can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) * restore it on completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) if (lpfc_cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) lpfc_cmd->prot_data_type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) LPFC_INJERR_APPTAG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) lpfc_cmd->prot_data_segment =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) src;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) lpfc_cmd->prot_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) src->app_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) src->app_tag = cpu_to_be16(0xDEAD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) phba->lpfc_injerr_wapp_cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) if (phba->lpfc_injerr_wapp_cnt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) phba->lpfc_injerr_nportid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) phba->lpfc_injerr_lba =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) LPFC_INJERR_LBA_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) memset(&phba->lpfc_injerr_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 0, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) rc = BG_ERR_TGT | BG_ERR_CHECK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) case SCSI_PROT_WRITE_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) * For WRITE_INSERT, force the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) * error to be sent on the wire. It should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) * detected by the Target.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) /* DEAD will be the apptag on the wire */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) *apptag = 0xDEAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) phba->lpfc_injerr_wapp_cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) if (phba->lpfc_injerr_wapp_cnt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) phba->lpfc_injerr_nportid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) phba->lpfc_injerr_lba =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) LPFC_INJERR_LBA_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) memset(&phba->lpfc_injerr_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 0, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) rc = BG_ERR_TGT | BG_ERR_CHECK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) "0813 BLKGRD: Injecting apptag error: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) "write lba x%lx\n", (unsigned long)lba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) case SCSI_PROT_WRITE_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) * For WRITE_STRIP and WRITE_PASS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) * force the error on data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) * being copied from SLI-Host to SLI-Port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) *apptag = 0xDEAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) phba->lpfc_injerr_wapp_cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) if (phba->lpfc_injerr_wapp_cnt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) phba->lpfc_injerr_nportid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) phba->lpfc_injerr_lba =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) LPFC_INJERR_LBA_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) memset(&phba->lpfc_injerr_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 0, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) rc = BG_ERR_INIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) "0812 BLKGRD: Injecting apptag error: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) "write lba x%lx\n", (unsigned long)lba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) if (phba->lpfc_injerr_rapp_cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) switch (op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) case SCSI_PROT_READ_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) case SCSI_PROT_READ_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) case SCSI_PROT_READ_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) * For READ_STRIP and READ_PASS, force the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) * error on data being read off the wire. It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) * should force an IO error to the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) *apptag = 0xDEAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) phba->lpfc_injerr_rapp_cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) if (phba->lpfc_injerr_rapp_cnt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) phba->lpfc_injerr_nportid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) phba->lpfc_injerr_lba =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) LPFC_INJERR_LBA_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) memset(&phba->lpfc_injerr_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 0, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) rc = BG_ERR_INIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) "0814 BLKGRD: Injecting apptag error: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) "read lba x%lx\n", (unsigned long)lba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) /* Should we change the Guard Tag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) if (new_guard) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) if (phba->lpfc_injerr_wgrd_cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) switch (op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) case SCSI_PROT_WRITE_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) rc = BG_ERR_CHECK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) case SCSI_PROT_WRITE_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) * For WRITE_INSERT, force the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) * error to be sent on the wire. It should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) * detected by the Target.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) phba->lpfc_injerr_wgrd_cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) if (phba->lpfc_injerr_wgrd_cnt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) phba->lpfc_injerr_nportid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) phba->lpfc_injerr_lba =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) LPFC_INJERR_LBA_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) memset(&phba->lpfc_injerr_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) 0, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) rc |= BG_ERR_TGT | BG_ERR_SWAP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) /* Signals the caller to swap CRC->CSUM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) "0817 BLKGRD: Injecting guard error: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) "write lba x%lx\n", (unsigned long)lba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) case SCSI_PROT_WRITE_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) * For WRITE_STRIP and WRITE_PASS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) * force the error on data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) * being copied from SLI-Host to SLI-Port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) phba->lpfc_injerr_wgrd_cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) if (phba->lpfc_injerr_wgrd_cnt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) phba->lpfc_injerr_nportid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) phba->lpfc_injerr_lba =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) LPFC_INJERR_LBA_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) memset(&phba->lpfc_injerr_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 0, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) rc = BG_ERR_INIT | BG_ERR_SWAP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) /* Signals the caller to swap CRC->CSUM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) "0816 BLKGRD: Injecting guard error: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) "write lba x%lx\n", (unsigned long)lba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) if (phba->lpfc_injerr_rgrd_cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) switch (op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) case SCSI_PROT_READ_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) case SCSI_PROT_READ_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) case SCSI_PROT_READ_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) * For READ_STRIP and READ_PASS, force the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) * error on data being read off the wire. It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) * should force an IO error to the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) phba->lpfc_injerr_rgrd_cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) if (phba->lpfc_injerr_rgrd_cnt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) phba->lpfc_injerr_nportid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) phba->lpfc_injerr_lba =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) LPFC_INJERR_LBA_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) memset(&phba->lpfc_injerr_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 0, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) rc = BG_ERR_INIT | BG_ERR_SWAP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) /* Signals the caller to swap CRC->CSUM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) "0818 BLKGRD: Injecting guard error: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) "read lba x%lx\n", (unsigned long)lba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) * lpfc_sc_to_bg_opcodes - Determine the BlockGuard opcodes to be used with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) * the specified SCSI command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) * @sc: The SCSI command to examine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) * @txopt: (out) BlockGuard operation for transmitted data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) * @rxopt: (out) BlockGuard operation for received data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) * Returns: zero on success; non-zero if tx and/or rx op cannot be determined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) lpfc_sc_to_bg_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) uint8_t *txop, uint8_t *rxop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) uint8_t ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) if (lpfc_cmd_guard_csum(sc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) switch (scsi_get_prot_op(sc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) case SCSI_PROT_READ_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) case SCSI_PROT_WRITE_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) *rxop = BG_OP_IN_NODIF_OUT_CSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) *txop = BG_OP_IN_CSUM_OUT_NODIF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) case SCSI_PROT_READ_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) case SCSI_PROT_WRITE_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) *rxop = BG_OP_IN_CRC_OUT_NODIF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) *txop = BG_OP_IN_NODIF_OUT_CRC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) case SCSI_PROT_READ_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) case SCSI_PROT_WRITE_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) *rxop = BG_OP_IN_CRC_OUT_CSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) *txop = BG_OP_IN_CSUM_OUT_CRC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) case SCSI_PROT_NORMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) "9063 BLKGRD: Bad op/guard:%d/IP combination\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) scsi_get_prot_op(sc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) ret = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) switch (scsi_get_prot_op(sc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) case SCSI_PROT_READ_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) case SCSI_PROT_WRITE_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) *rxop = BG_OP_IN_CRC_OUT_NODIF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) *txop = BG_OP_IN_NODIF_OUT_CRC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) case SCSI_PROT_READ_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) case SCSI_PROT_WRITE_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) *rxop = BG_OP_IN_CRC_OUT_CRC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) *txop = BG_OP_IN_CRC_OUT_CRC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) case SCSI_PROT_READ_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) case SCSI_PROT_WRITE_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) *rxop = BG_OP_IN_NODIF_OUT_CRC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) *txop = BG_OP_IN_CRC_OUT_NODIF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) case SCSI_PROT_NORMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) "9075 BLKGRD: Bad op/guard:%d/CRC combination\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) scsi_get_prot_op(sc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) ret = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) * lpfc_bg_err_opcodes - reDetermine the BlockGuard opcodes to be used with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) * the specified SCSI command in order to force a guard tag error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) * @sc: The SCSI command to examine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) * @txopt: (out) BlockGuard operation for transmitted data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) * @rxopt: (out) BlockGuard operation for received data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) * Returns: zero on success; non-zero if tx and/or rx op cannot be determined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) lpfc_bg_err_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) uint8_t *txop, uint8_t *rxop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) uint8_t ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) if (lpfc_cmd_guard_csum(sc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) switch (scsi_get_prot_op(sc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) case SCSI_PROT_READ_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) case SCSI_PROT_WRITE_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) *rxop = BG_OP_IN_NODIF_OUT_CRC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) *txop = BG_OP_IN_CRC_OUT_NODIF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) case SCSI_PROT_READ_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) case SCSI_PROT_WRITE_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) *rxop = BG_OP_IN_CSUM_OUT_NODIF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) *txop = BG_OP_IN_NODIF_OUT_CSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) case SCSI_PROT_READ_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) case SCSI_PROT_WRITE_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) *rxop = BG_OP_IN_CSUM_OUT_CRC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) *txop = BG_OP_IN_CRC_OUT_CSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) case SCSI_PROT_NORMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) switch (scsi_get_prot_op(sc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) case SCSI_PROT_READ_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) case SCSI_PROT_WRITE_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) *rxop = BG_OP_IN_CSUM_OUT_NODIF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) *txop = BG_OP_IN_NODIF_OUT_CSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) case SCSI_PROT_READ_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) case SCSI_PROT_WRITE_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) *rxop = BG_OP_IN_CSUM_OUT_CSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) *txop = BG_OP_IN_CSUM_OUT_CSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) case SCSI_PROT_READ_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) case SCSI_PROT_WRITE_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) *rxop = BG_OP_IN_NODIF_OUT_CSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) *txop = BG_OP_IN_CSUM_OUT_NODIF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) case SCSI_PROT_NORMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) * lpfc_bg_setup_bpl - Setup BlockGuard BPL with no protection data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) * @sc: pointer to scsi command we're working on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) * @bpl: pointer to buffer list for protection groups
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) * @datacnt: number of segments of data that have been dma mapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) * This function sets up BPL buffer list for protection groups of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) * type LPFC_PG_TYPE_NO_DIF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) * This is usually used when the HBA is instructed to generate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) * DIFs and insert them into data stream (or strip DIF from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) * incoming data stream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) * The buffer list consists of just one protection group described
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) * below:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) * start of prot group --> | PDE_5 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) * | PDE_6 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) * | Data BDE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) * |more Data BDE's ... (opt)|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) * Note: Data s/g buffers have been dma mapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) * Returns the number of BDEs added to the BPL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) struct ulp_bde64 *bpl, int datasegcnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) struct scatterlist *sgde = NULL; /* s/g data entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) struct lpfc_pde5 *pde5 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) struct lpfc_pde6 *pde6 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) dma_addr_t physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) int i = 0, num_bde = 0, status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) int datadir = sc->sc_data_direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) uint32_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) uint32_t checking = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) uint32_t reftag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) uint8_t txop, rxop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) status = lpfc_sc_to_bg_opcodes(phba, sc, &txop, &rxop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) /* extract some info from the scsi command for pde*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) if (rc & BG_ERR_SWAP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) lpfc_bg_err_opcodes(phba, sc, &txop, &rxop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) if (rc & BG_ERR_CHECK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) checking = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) /* setup PDE5 with what we have */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) pde5 = (struct lpfc_pde5 *) bpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) memset(pde5, 0, sizeof(struct lpfc_pde5));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) bf_set(pde5_type, pde5, LPFC_PDE5_DESCRIPTOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) /* Endianness conversion if necessary for PDE5 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) pde5->word0 = cpu_to_le32(pde5->word0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) pde5->reftag = cpu_to_le32(reftag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) /* advance bpl and increment bde count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) num_bde++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) bpl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) pde6 = (struct lpfc_pde6 *) bpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) /* setup PDE6 with the rest of the info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) memset(pde6, 0, sizeof(struct lpfc_pde6));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) bf_set(pde6_type, pde6, LPFC_PDE6_DESCRIPTOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) bf_set(pde6_optx, pde6, txop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) bf_set(pde6_oprx, pde6, rxop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) * We only need to check the data on READs, for WRITEs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) * protection data is automatically generated, not checked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) if (datadir == DMA_FROM_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) if (lpfc_cmd_protect(sc, LPFC_CHECK_PROTECT_GUARD))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) bf_set(pde6_ce, pde6, checking);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) bf_set(pde6_ce, pde6, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) if (lpfc_cmd_protect(sc, LPFC_CHECK_PROTECT_REF))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) bf_set(pde6_re, pde6, checking);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) bf_set(pde6_re, pde6, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) bf_set(pde6_ai, pde6, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) bf_set(pde6_ae, pde6, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) bf_set(pde6_apptagval, pde6, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) /* Endianness conversion if necessary for PDE6 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) pde6->word0 = cpu_to_le32(pde6->word0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) pde6->word1 = cpu_to_le32(pde6->word1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) pde6->word2 = cpu_to_le32(pde6->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) /* advance bpl and increment bde count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) num_bde++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) bpl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) /* assumption: caller has already run dma_map_sg on command data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) scsi_for_each_sg(sc, sgde, datasegcnt, i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) physaddr = sg_dma_address(sgde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) bpl->addrLow = le32_to_cpu(putPaddrLow(physaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) bpl->addrHigh = le32_to_cpu(putPaddrHigh(physaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) bpl->tus.f.bdeSize = sg_dma_len(sgde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) if (datadir == DMA_TO_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64I;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) bpl->tus.w = le32_to_cpu(bpl->tus.w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) bpl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) num_bde++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) return num_bde;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) * lpfc_bg_setup_bpl_prot - Setup BlockGuard BPL with protection data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) * @sc: pointer to scsi command we're working on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) * @bpl: pointer to buffer list for protection groups
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) * @datacnt: number of segments of data that have been dma mapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) * @protcnt: number of segment of protection data that have been dma mapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) * This function sets up BPL buffer list for protection groups of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) * type LPFC_PG_TYPE_DIF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) * This is usually used when DIFs are in their own buffers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) * separate from the data. The HBA can then by instructed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) * to place the DIFs in the outgoing stream. For read operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) * The HBA could extract the DIFs and place it in DIF buffers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) * The buffer list for this type consists of one or more of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) * protection groups described below:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) * start of first prot group --> | PDE_5 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) * | PDE_6 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) * | PDE_7 (Prot BDE) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) * | Data BDE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) * |more Data BDE's ... (opt)|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) * start of new prot group --> | PDE_5 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) * | ... |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) * Note: It is assumed that both data and protection s/g buffers have been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) * mapped for DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) * Returns the number of BDEs added to the BPL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) struct ulp_bde64 *bpl, int datacnt, int protcnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) struct scatterlist *sgde = NULL; /* s/g data entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) struct scatterlist *sgpe = NULL; /* s/g prot entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) struct lpfc_pde5 *pde5 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) struct lpfc_pde6 *pde6 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) struct lpfc_pde7 *pde7 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) dma_addr_t dataphysaddr, protphysaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) unsigned short curr_data = 0, curr_prot = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) unsigned int split_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) unsigned int protgroup_len, protgroup_offset = 0, protgroup_remainder;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) unsigned int protgrp_blks, protgrp_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) unsigned int remainder, subtotal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) int datadir = sc->sc_data_direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) unsigned char pgdone = 0, alldone = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) unsigned blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) uint32_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) uint32_t checking = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) uint32_t reftag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) uint8_t txop, rxop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) int num_bde = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) sgpe = scsi_prot_sglist(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) sgde = scsi_sglist(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) if (!sgpe || !sgde) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) "9020 Invalid s/g entry: data=x%px prot=x%px\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) sgpe, sgde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) status = lpfc_sc_to_bg_opcodes(phba, sc, &txop, &rxop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) /* extract some info from the scsi command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) blksize = lpfc_cmd_blksize(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) if (rc & BG_ERR_SWAP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) lpfc_bg_err_opcodes(phba, sc, &txop, &rxop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) if (rc & BG_ERR_CHECK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) checking = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) split_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) /* Check to see if we ran out of space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) if (num_bde >= (phba->cfg_total_seg_cnt - 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) return num_bde + 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) /* setup PDE5 with what we have */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) pde5 = (struct lpfc_pde5 *) bpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) memset(pde5, 0, sizeof(struct lpfc_pde5));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) bf_set(pde5_type, pde5, LPFC_PDE5_DESCRIPTOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) /* Endianness conversion if necessary for PDE5 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) pde5->word0 = cpu_to_le32(pde5->word0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) pde5->reftag = cpu_to_le32(reftag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) /* advance bpl and increment bde count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) num_bde++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) bpl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) pde6 = (struct lpfc_pde6 *) bpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) /* setup PDE6 with the rest of the info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) memset(pde6, 0, sizeof(struct lpfc_pde6));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) bf_set(pde6_type, pde6, LPFC_PDE6_DESCRIPTOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) bf_set(pde6_optx, pde6, txop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) bf_set(pde6_oprx, pde6, rxop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) if (lpfc_cmd_protect(sc, LPFC_CHECK_PROTECT_GUARD))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) bf_set(pde6_ce, pde6, checking);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) bf_set(pde6_ce, pde6, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) if (lpfc_cmd_protect(sc, LPFC_CHECK_PROTECT_REF))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) bf_set(pde6_re, pde6, checking);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) bf_set(pde6_re, pde6, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) bf_set(pde6_ai, pde6, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) bf_set(pde6_ae, pde6, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) bf_set(pde6_apptagval, pde6, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) /* Endianness conversion if necessary for PDE6 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) pde6->word0 = cpu_to_le32(pde6->word0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) pde6->word1 = cpu_to_le32(pde6->word1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) pde6->word2 = cpu_to_le32(pde6->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) /* advance bpl and increment bde count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) num_bde++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) bpl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) /* setup the first BDE that points to protection buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) protphysaddr = sg_dma_address(sgpe) + protgroup_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) protgroup_len = sg_dma_len(sgpe) - protgroup_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) /* must be integer multiple of the DIF block length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) BUG_ON(protgroup_len % 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) pde7 = (struct lpfc_pde7 *) bpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) memset(pde7, 0, sizeof(struct lpfc_pde7));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) bf_set(pde7_type, pde7, LPFC_PDE7_DESCRIPTOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) pde7->addrHigh = le32_to_cpu(putPaddrHigh(protphysaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) pde7->addrLow = le32_to_cpu(putPaddrLow(protphysaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) protgrp_blks = protgroup_len / 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) protgrp_bytes = protgrp_blks * blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) /* check if this pde is crossing the 4K boundary; if so split */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) if ((pde7->addrLow & 0xfff) + protgroup_len > 0x1000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) protgroup_remainder = 0x1000 - (pde7->addrLow & 0xfff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) protgroup_offset += protgroup_remainder;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) protgrp_blks = protgroup_remainder / 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) protgrp_bytes = protgrp_blks * blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) protgroup_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) curr_prot++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) num_bde++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) /* setup BDE's for data blocks associated with DIF data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) pgdone = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) subtotal = 0; /* total bytes processed for current prot grp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) while (!pgdone) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) /* Check to see if we ran out of space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) if (num_bde >= phba->cfg_total_seg_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) return num_bde + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) if (!sgde) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) "9065 BLKGRD:%s Invalid data segment\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) bpl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) dataphysaddr = sg_dma_address(sgde) + split_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) bpl->addrLow = le32_to_cpu(putPaddrLow(dataphysaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) bpl->addrHigh = le32_to_cpu(putPaddrHigh(dataphysaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) remainder = sg_dma_len(sgde) - split_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) if ((subtotal + remainder) <= protgrp_bytes) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) /* we can use this whole buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) bpl->tus.f.bdeSize = remainder;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) split_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) if ((subtotal + remainder) == protgrp_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) pgdone = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) /* must split this buffer with next prot grp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) bpl->tus.f.bdeSize = protgrp_bytes - subtotal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) split_offset += bpl->tus.f.bdeSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) subtotal += bpl->tus.f.bdeSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) if (datadir == DMA_TO_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64I;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) bpl->tus.w = le32_to_cpu(bpl->tus.w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) num_bde++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) curr_data++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) if (split_offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) /* Move to the next s/g segment if possible */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) sgde = sg_next(sgde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) if (protgroup_offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) /* update the reference tag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) reftag += protgrp_blks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) bpl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) /* are we done ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) if (curr_prot == protcnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) alldone = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) } else if (curr_prot < protcnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) /* advance to next prot buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) sgpe = sg_next(sgpe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) bpl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) /* update the reference tag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) reftag += protgrp_blks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) /* if we're here, we have a bug */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) "9054 BLKGRD: bug in %s\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) } while (!alldone);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) return num_bde;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) * lpfc_bg_setup_sgl - Setup BlockGuard SGL with no protection data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) * @sc: pointer to scsi command we're working on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) * @sgl: pointer to buffer list for protection groups
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) * @datacnt: number of segments of data that have been dma mapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) * This function sets up SGL buffer list for protection groups of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) * type LPFC_PG_TYPE_NO_DIF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) * This is usually used when the HBA is instructed to generate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) * DIFs and insert them into data stream (or strip DIF from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) * incoming data stream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) * The buffer list consists of just one protection group described
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) * below:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) * start of prot group --> | DI_SEED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) * | Data SGE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) * |more Data SGE's ... (opt)|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) * Note: Data s/g buffers have been dma mapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) * Returns the number of SGEs added to the SGL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) struct sli4_sge *sgl, int datasegcnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) struct scatterlist *sgde = NULL; /* s/g data entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) struct sli4_sge_diseed *diseed = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) dma_addr_t physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) int i = 0, num_sge = 0, status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) uint32_t reftag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) uint8_t txop, rxop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) uint32_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) uint32_t checking = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) uint32_t dma_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) uint32_t dma_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) struct sli4_hybrid_sgl *sgl_xtra = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) int j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) bool lsp_just_set = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) status = lpfc_sc_to_bg_opcodes(phba, sc, &txop, &rxop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) /* extract some info from the scsi command for pde*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) if (rc & BG_ERR_SWAP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) lpfc_bg_err_opcodes(phba, sc, &txop, &rxop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) if (rc & BG_ERR_CHECK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) checking = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) /* setup DISEED with what we have */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) diseed = (struct sli4_sge_diseed *) sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) memset(diseed, 0, sizeof(struct sli4_sge_diseed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DISEED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) /* Endianness conversion if necessary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) diseed->ref_tag = cpu_to_le32(reftag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) diseed->ref_tag_tran = diseed->ref_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) * We only need to check the data on READs, for WRITEs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) * protection data is automatically generated, not checked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) if (sc->sc_data_direction == DMA_FROM_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) if (lpfc_cmd_protect(sc, LPFC_CHECK_PROTECT_GUARD))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) bf_set(lpfc_sli4_sge_dif_ce, diseed, checking);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) bf_set(lpfc_sli4_sge_dif_ce, diseed, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) if (lpfc_cmd_protect(sc, LPFC_CHECK_PROTECT_REF))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) bf_set(lpfc_sli4_sge_dif_re, diseed, checking);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) bf_set(lpfc_sli4_sge_dif_re, diseed, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) /* setup DISEED with the rest of the info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) bf_set(lpfc_sli4_sge_dif_optx, diseed, txop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) bf_set(lpfc_sli4_sge_dif_oprx, diseed, rxop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) bf_set(lpfc_sli4_sge_dif_ai, diseed, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) bf_set(lpfc_sli4_sge_dif_me, diseed, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) /* Endianness conversion if necessary for DISEED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) diseed->word2 = cpu_to_le32(diseed->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) diseed->word3 = cpu_to_le32(diseed->word3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) /* advance bpl and increment sge count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) num_sge++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) sgl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) /* assumption: caller has already run dma_map_sg on command data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) sgde = scsi_sglist(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) j = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) for (i = 0; i < datasegcnt; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) /* clear it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) sgl->word2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) /* do we need to expand the segment */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) if (!lsp_just_set && !((j + 1) % phba->border_sge_num) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) ((datasegcnt - 1) != i)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) /* set LSP type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_LSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) sgl_xtra = lpfc_get_sgl_per_hdwq(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) if (unlikely(!sgl_xtra)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) lpfc_cmd->seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) sgl->addr_lo = cpu_to_le32(putPaddrLow(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) sgl_xtra->dma_phys_sgl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) sgl->addr_hi = cpu_to_le32(putPaddrHigh(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) sgl_xtra->dma_phys_sgl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) if (!(bf_get(lpfc_sli4_sge_type, sgl) & LPFC_SGE_TYPE_LSP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) if ((datasegcnt - 1) == i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) bf_set(lpfc_sli4_sge_last, sgl, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) physaddr = sg_dma_address(sgde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) dma_len = sg_dma_len(sgde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) sgl->addr_lo = cpu_to_le32(putPaddrLow(physaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) sgl->addr_hi = cpu_to_le32(putPaddrHigh(physaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) sgl->word2 = cpu_to_le32(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) sgl->sge_len = cpu_to_le32(dma_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) dma_offset += dma_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) sgde = sg_next(sgde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) sgl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) num_sge++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) lsp_just_set = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) sgl->word2 = cpu_to_le32(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) sgl->sge_len = cpu_to_le32(phba->cfg_sg_dma_buf_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) sgl = (struct sli4_sge *)sgl_xtra->dma_sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) i = i - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) lsp_just_set = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) j++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) return num_sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) * lpfc_bg_setup_sgl_prot - Setup BlockGuard SGL with protection data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) * @sc: pointer to scsi command we're working on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) * @sgl: pointer to buffer list for protection groups
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) * @datacnt: number of segments of data that have been dma mapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) * @protcnt: number of segment of protection data that have been dma mapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) * This function sets up SGL buffer list for protection groups of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) * type LPFC_PG_TYPE_DIF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) * This is usually used when DIFs are in their own buffers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) * separate from the data. The HBA can then by instructed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) * to place the DIFs in the outgoing stream. For read operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) * The HBA could extract the DIFs and place it in DIF buffers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) * The buffer list for this type consists of one or more of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) * protection groups described below:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) * start of first prot group --> | DISEED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) * | DIF (Prot SGE) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) * | Data SGE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) * |more Data SGE's ... (opt)|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) * start of new prot group --> | DISEED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) * | ... |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) * +-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) * Note: It is assumed that both data and protection s/g buffers have been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) * mapped for DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) * Returns the number of SGEs added to the SGL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) struct sli4_sge *sgl, int datacnt, int protcnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) struct scatterlist *sgde = NULL; /* s/g data entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) struct scatterlist *sgpe = NULL; /* s/g prot entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) struct sli4_sge_diseed *diseed = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) dma_addr_t dataphysaddr, protphysaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) unsigned short curr_data = 0, curr_prot = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) unsigned int split_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) unsigned int protgroup_len, protgroup_offset = 0, protgroup_remainder;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) unsigned int protgrp_blks, protgrp_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) unsigned int remainder, subtotal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) unsigned char pgdone = 0, alldone = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) unsigned blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) uint32_t reftag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) uint8_t txop, rxop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) uint32_t dma_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) uint32_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) uint32_t checking = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) uint32_t dma_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) int num_sge = 0, j = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) struct sli4_hybrid_sgl *sgl_xtra = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) sgpe = scsi_prot_sglist(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) sgde = scsi_sglist(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) if (!sgpe || !sgde) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) "9082 Invalid s/g entry: data=x%px prot=x%px\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) sgpe, sgde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) status = lpfc_sc_to_bg_opcodes(phba, sc, &txop, &rxop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) /* extract some info from the scsi command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) blksize = lpfc_cmd_blksize(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) if (rc & BG_ERR_SWAP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) lpfc_bg_err_opcodes(phba, sc, &txop, &rxop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) if (rc & BG_ERR_CHECK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) checking = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) split_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) /* Check to see if we ran out of space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) if ((num_sge >= (phba->cfg_total_seg_cnt - 2)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) !(phba->cfg_xpsgl))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) return num_sge + 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) /* DISEED and DIF have to be together */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) if (!((j + 1) % phba->border_sge_num) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) !((j + 2) % phba->border_sge_num) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) !((j + 3) % phba->border_sge_num)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) sgl->word2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) /* set LSP type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_LSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) sgl_xtra = lpfc_get_sgl_per_hdwq(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) if (unlikely(!sgl_xtra)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) sgl->addr_lo = cpu_to_le32(putPaddrLow(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) sgl_xtra->dma_phys_sgl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) sgl->addr_hi = cpu_to_le32(putPaddrHigh(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) sgl_xtra->dma_phys_sgl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) sgl->word2 = cpu_to_le32(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) sgl->sge_len = cpu_to_le32(phba->cfg_sg_dma_buf_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) sgl = (struct sli4_sge *)sgl_xtra->dma_sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) j = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) /* setup DISEED with what we have */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) diseed = (struct sli4_sge_diseed *) sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) memset(diseed, 0, sizeof(struct sli4_sge_diseed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DISEED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) /* Endianness conversion if necessary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) diseed->ref_tag = cpu_to_le32(reftag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) diseed->ref_tag_tran = diseed->ref_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) if (lpfc_cmd_protect(sc, LPFC_CHECK_PROTECT_GUARD)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) bf_set(lpfc_sli4_sge_dif_ce, diseed, checking);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) bf_set(lpfc_sli4_sge_dif_ce, diseed, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) * When in this mode, the hardware will replace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) * the guard tag from the host with a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) * newly generated good CRC for the wire.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) * Switch to raw mode here to avoid this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) * behavior. What the host sends gets put on the wire.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) if (txop == BG_OP_IN_CRC_OUT_CRC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) txop = BG_OP_RAW_MODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) rxop = BG_OP_RAW_MODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) if (lpfc_cmd_protect(sc, LPFC_CHECK_PROTECT_REF))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) bf_set(lpfc_sli4_sge_dif_re, diseed, checking);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) bf_set(lpfc_sli4_sge_dif_re, diseed, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) /* setup DISEED with the rest of the info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) bf_set(lpfc_sli4_sge_dif_optx, diseed, txop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) bf_set(lpfc_sli4_sge_dif_oprx, diseed, rxop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) bf_set(lpfc_sli4_sge_dif_ai, diseed, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) bf_set(lpfc_sli4_sge_dif_me, diseed, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) /* Endianness conversion if necessary for DISEED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) diseed->word2 = cpu_to_le32(diseed->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) diseed->word3 = cpu_to_le32(diseed->word3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) /* advance sgl and increment bde count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) num_sge++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) sgl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) j++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) /* setup the first BDE that points to protection buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) protphysaddr = sg_dma_address(sgpe) + protgroup_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) protgroup_len = sg_dma_len(sgpe) - protgroup_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) /* must be integer multiple of the DIF block length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) BUG_ON(protgroup_len % 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) /* Now setup DIF SGE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) sgl->word2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DIF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) sgl->addr_hi = le32_to_cpu(putPaddrHigh(protphysaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) sgl->addr_lo = le32_to_cpu(putPaddrLow(protphysaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) sgl->word2 = cpu_to_le32(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) sgl->sge_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) protgrp_blks = protgroup_len / 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) protgrp_bytes = protgrp_blks * blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) /* check if DIF SGE is crossing the 4K boundary; if so split */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) if ((sgl->addr_lo & 0xfff) + protgroup_len > 0x1000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) protgroup_remainder = 0x1000 - (sgl->addr_lo & 0xfff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) protgroup_offset += protgroup_remainder;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) protgrp_blks = protgroup_remainder / 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) protgrp_bytes = protgrp_blks * blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) protgroup_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) curr_prot++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) num_sge++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) /* setup SGE's for data blocks associated with DIF data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) pgdone = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) subtotal = 0; /* total bytes processed for current prot grp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) sgl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) j++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) while (!pgdone) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) /* Check to see if we ran out of space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) if ((num_sge >= phba->cfg_total_seg_cnt) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) !phba->cfg_xpsgl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) return num_sge + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) if (!sgde) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) "9086 BLKGRD:%s Invalid data segment\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) if (!((j + 1) % phba->border_sge_num)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) sgl->word2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) /* set LSP type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) bf_set(lpfc_sli4_sge_type, sgl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) LPFC_SGE_TYPE_LSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) sgl_xtra = lpfc_get_sgl_per_hdwq(phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) if (unlikely(!sgl_xtra)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) sgl->addr_lo = cpu_to_le32(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) putPaddrLow(sgl_xtra->dma_phys_sgl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) sgl->addr_hi = cpu_to_le32(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) putPaddrHigh(sgl_xtra->dma_phys_sgl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) sgl->word2 = cpu_to_le32(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) sgl->sge_len = cpu_to_le32(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) phba->cfg_sg_dma_buf_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) sgl = (struct sli4_sge *)sgl_xtra->dma_sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) dataphysaddr = sg_dma_address(sgde) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) split_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) remainder = sg_dma_len(sgde) - split_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) if ((subtotal + remainder) <= protgrp_bytes) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) /* we can use this whole buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) dma_len = remainder;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) split_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) if ((subtotal + remainder) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) protgrp_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) pgdone = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) /* must split this buffer with next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) * prot grp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) dma_len = protgrp_bytes - subtotal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) split_offset += dma_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) subtotal += dma_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) sgl->word2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) sgl->addr_lo = cpu_to_le32(putPaddrLow(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) dataphysaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) sgl->addr_hi = cpu_to_le32(putPaddrHigh(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) dataphysaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) bf_set(lpfc_sli4_sge_last, sgl, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) bf_set(lpfc_sli4_sge_type, sgl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) LPFC_SGE_TYPE_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) sgl->sge_len = cpu_to_le32(dma_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) dma_offset += dma_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) num_sge++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) curr_data++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) if (split_offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) sgl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) j++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) /* Move to the next s/g segment if possible */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) sgde = sg_next(sgde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) sgl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) j++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) if (protgroup_offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) /* update the reference tag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) reftag += protgrp_blks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) /* are we done ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) if (curr_prot == protcnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) /* mark the last SGL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) sgl--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) bf_set(lpfc_sli4_sge_last, sgl, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) alldone = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) } else if (curr_prot < protcnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) /* advance to next prot buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) sgpe = sg_next(sgpe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) /* update the reference tag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) reftag += protgrp_blks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) /* if we're here, we have a bug */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) "9085 BLKGRD: bug in %s\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) } while (!alldone);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) return num_sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) * lpfc_prot_group_type - Get prtotection group type of SCSI command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) * @sc: pointer to scsi command we're working on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) * Given a SCSI command that supports DIF, determine composition of protection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) * groups involved in setting up buffer lists
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) * Returns: Protection group type (with or without DIF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) lpfc_prot_group_type(struct lpfc_hba *phba, struct scsi_cmnd *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) int ret = LPFC_PG_TYPE_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) unsigned char op = scsi_get_prot_op(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) switch (op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) case SCSI_PROT_READ_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) case SCSI_PROT_WRITE_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) ret = LPFC_PG_TYPE_NO_DIF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) case SCSI_PROT_READ_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) case SCSI_PROT_WRITE_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) case SCSI_PROT_READ_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) case SCSI_PROT_WRITE_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) ret = LPFC_PG_TYPE_DIF_BUF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) if (phba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) "9021 Unsupported protection op:%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) * lpfc_bg_scsi_adjust_dl - Adjust SCSI data length for BlockGuard
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) * @lpfc_cmd: The scsi buffer which is going to be adjusted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) * Adjust the data length to account for how much data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) * is actually on the wire.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) * returns the adjusted data length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) lpfc_bg_scsi_adjust_dl(struct lpfc_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) struct scsi_cmnd *sc = lpfc_cmd->pCmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) int fcpdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) fcpdl = scsi_bufflen(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) /* Check if there is protection data on the wire */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) if (sc->sc_data_direction == DMA_FROM_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) /* Read check for protection data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) if (scsi_get_prot_op(sc) == SCSI_PROT_READ_INSERT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) return fcpdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) /* Write check for protection data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) if (scsi_get_prot_op(sc) == SCSI_PROT_WRITE_STRIP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) return fcpdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) * If we are in DIF Type 1 mode every data block has a 8 byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) * DIF (trailer) attached to it. Must ajust FCP data length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) * to account for the protection data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) fcpdl += (fcpdl / lpfc_cmd_blksize(sc)) * 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) return fcpdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) * lpfc_bg_scsi_prep_dma_buf_s3 - DMA mapping for scsi buffer to SLI3 IF spec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) * @lpfc_cmd: The scsi buffer which is going to be prep'ed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) * This is the protection/DIF aware version of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) * lpfc_scsi_prep_dma_buf(). It may be a good idea to combine the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) * two functions eventually, but for now, it's here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) * RETURNS 0 - SUCCESS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) * 1 - Failed DMA map, retry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) * 2 - Invalid scsi cmd or prot-type. Do not rety.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) lpfc_bg_scsi_prep_dma_buf_s3(struct lpfc_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) struct ulp_bde64 *bpl = (struct ulp_bde64 *)lpfc_cmd->dma_sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) uint32_t num_bde = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) int datasegcnt, protsegcnt, datadir = scsi_cmnd->sc_data_direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) int prot_group_type = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) int fcpdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) int ret = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) struct lpfc_vport *vport = phba->pport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) * Start the lpfc command prep by bumping the bpl beyond fcp_cmnd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) * fcp_rsp regions to the first data bde entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538) bpl += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) if (scsi_sg_count(scsi_cmnd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) * The driver stores the segment count returned from pci_map_sg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) * because this a count of dma-mappings used to map the use_sg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) * pages. They are not guaranteed to be the same for those
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) * architectures that implement an IOMMU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) datasegcnt = dma_map_sg(&phba->pcidev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) scsi_sglist(scsi_cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) scsi_sg_count(scsi_cmnd), datadir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) if (unlikely(!datasegcnt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) lpfc_cmd->seg_cnt = datasegcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) /* First check if data segment count from SCSI Layer is good */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) WARN_ON_ONCE(lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) ret = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) prot_group_type = lpfc_prot_group_type(phba, scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) switch (prot_group_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) case LPFC_PG_TYPE_NO_DIF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) /* Here we need to add a PDE5 and PDE6 to the count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) if ((lpfc_cmd->seg_cnt + 2) > phba->cfg_total_seg_cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) ret = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) num_bde = lpfc_bg_setup_bpl(phba, scsi_cmnd, bpl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) datasegcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) /* we should have 2 or more entries in buffer list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) if (num_bde < 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) ret = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) case LPFC_PG_TYPE_DIF_BUF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) * This type indicates that protection buffers are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) * passed to the driver, so that needs to be prepared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) * for DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) protsegcnt = dma_map_sg(&phba->pcidev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) scsi_prot_sglist(scsi_cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) scsi_prot_sg_count(scsi_cmnd), datadir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) if (unlikely(!protsegcnt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) scsi_dma_unmap(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) lpfc_cmd->prot_seg_cnt = protsegcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) * There is a minimun of 4 BPLs used for every
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) * protection data segment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) if ((lpfc_cmd->prot_seg_cnt * 4) >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) (phba->cfg_total_seg_cnt - 2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) ret = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) num_bde = lpfc_bg_setup_bpl_prot(phba, scsi_cmnd, bpl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) datasegcnt, protsegcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) /* we should have 3 or more entries in buffer list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) if ((num_bde < 3) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) (num_bde > phba->cfg_total_seg_cnt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) ret = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) case LPFC_PG_TYPE_INVALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) scsi_dma_unmap(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) lpfc_cmd->seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) "9022 Unexpected protection group %i\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) prot_group_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) return 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) * Finish initializing those IOCB fields that are dependent on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) * scsi_cmnd request_buffer. Note that the bdeSize is explicitly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) * reinitialized since all iocb memory resources are used many times
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) * for transmit, receive, and continuation bpl's.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) iocb_cmd->un.fcpi64.bdl.bdeSize = (2 * sizeof(struct ulp_bde64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) iocb_cmd->un.fcpi64.bdl.bdeSize += (num_bde * sizeof(struct ulp_bde64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) iocb_cmd->ulpBdeCount = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) iocb_cmd->ulpLe = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) fcpdl = lpfc_bg_scsi_adjust_dl(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) fcp_cmnd->fcpDl = be32_to_cpu(fcpdl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) * Due to difference in data length between DIF/non-DIF paths,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) * we need to set word 4 of IOCB here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) iocb_cmd->un.fcpi.fcpi_parm = fcpdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) * For First burst, we may need to adjust the initial transfer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) * length for DIF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) if (iocb_cmd->un.fcpi.fcpi_XRdy &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) (fcpdl < vport->cfg_first_burst_size))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) iocb_cmd->un.fcpi.fcpi_XRdy = fcpdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) if (lpfc_cmd->seg_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) scsi_dma_unmap(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) if (lpfc_cmd->prot_seg_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) dma_unmap_sg(&phba->pcidev->dev, scsi_prot_sglist(scsi_cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) scsi_prot_sg_count(scsi_cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) scsi_cmnd->sc_data_direction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) "9023 Cannot setup S/G List for HBA"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) "IO segs %d/%d BPL %d SCSI %d: %d %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) lpfc_cmd->seg_cnt, lpfc_cmd->prot_seg_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) phba->cfg_total_seg_cnt, phba->cfg_sg_seg_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671) prot_group_type, num_bde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) lpfc_cmd->seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) lpfc_cmd->prot_seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) * This function calcuates the T10 DIF guard tag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) * on the specified data using a CRC algorithmn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) * using crc_t10dif.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) static uint16_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) lpfc_bg_crc(uint8_t *data, int count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) uint16_t crc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) uint16_t x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) crc = crc_t10dif(data, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) x = cpu_to_be16(crc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) return x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) * This function calcuates the T10 DIF guard tag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) * on the specified data using a CSUM algorithmn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) * using ip_compute_csum.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) static uint16_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) lpfc_bg_csum(uint8_t *data, int count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) uint16_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) ret = ip_compute_csum(data, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) * This function examines the protection data to try to determine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) * what type of T10-DIF error occurred.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) struct scatterlist *sgpe; /* s/g prot entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) struct scatterlist *sgde; /* s/g data entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) struct scsi_cmnd *cmd = lpfc_cmd->pCmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) struct scsi_dif_tuple *src = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) uint8_t *data_src = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) uint16_t guard_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) uint16_t start_app_tag, app_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) uint32_t start_ref_tag, ref_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) int prot, protsegcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) int err_type, len, data_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) int chk_ref, chk_app, chk_guard;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) uint16_t sum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) unsigned blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) err_type = BGS_GUARD_ERR_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) sum = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) guard_tag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) /* First check to see if there is protection data to examine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) prot = scsi_get_prot_op(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) if ((prot == SCSI_PROT_READ_STRIP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) (prot == SCSI_PROT_WRITE_INSERT) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) (prot == SCSI_PROT_NORMAL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) /* Currently the driver just supports ref_tag and guard_tag checking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) chk_ref = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) chk_app = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) chk_guard = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) /* Setup a ptr to the protection data provided by the SCSI host */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746) sgpe = scsi_prot_sglist(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) protsegcnt = lpfc_cmd->prot_seg_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) if (sgpe && protsegcnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) * We will only try to verify guard tag if the segment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) * data length is a multiple of the blksize.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) sgde = scsi_sglist(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) blksize = lpfc_cmd_blksize(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) data_src = (uint8_t *)sg_virt(sgde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) data_len = sgde->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) if ((data_len & (blksize - 1)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) chk_guard = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) src = (struct scsi_dif_tuple *)sg_virt(sgpe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) start_ref_tag = (uint32_t)scsi_get_lba(cmd); /* Truncate LBA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) start_app_tag = src->app_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) len = sgpe->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) while (src && protsegcnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) while (len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) * First check to see if a protection data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) * check is valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) if ((src->ref_tag == T10_PI_REF_ESCAPE) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) (src->app_tag == T10_PI_APP_ESCAPE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) start_ref_tag++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) goto skipit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779) /* First Guard Tag checking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) if (chk_guard) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) guard_tag = src->guard_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) if (lpfc_cmd_guard_csum(cmd))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) sum = lpfc_bg_csum(data_src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) blksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) sum = lpfc_bg_crc(data_src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) blksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) if ((guard_tag != sum)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) err_type = BGS_GUARD_ERR_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) /* Reference Tag checking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) ref_tag = be32_to_cpu(src->ref_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) if (chk_ref && (ref_tag != start_ref_tag)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) err_type = BGS_REFTAG_ERR_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) start_ref_tag++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) /* App Tag checking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) app_tag = src->app_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) if (chk_app && (app_tag != start_app_tag)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) err_type = BGS_APPTAG_ERR_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) skipit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) len -= sizeof(struct scsi_dif_tuple);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) if (len < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) src++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) data_src += blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) data_len -= blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) * Are we at the end of the Data segment?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) * The data segment is only used for Guard
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) * tag checking.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) if (chk_guard && (data_len == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) chk_guard = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) sgde = sg_next(sgde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) if (!sgde)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) data_src = (uint8_t *)sg_virt(sgde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) data_len = sgde->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) if ((data_len & (blksize - 1)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) chk_guard = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) /* Goto the next Protection data segment */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) sgpe = sg_next(sgpe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) if (sgpe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) src = (struct scsi_dif_tuple *)sg_virt(sgpe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) len = sgpe->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) src = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) protsegcnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) if (err_type == BGS_GUARD_ERR_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) 0x10, 0x1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) SAM_STAT_CHECK_CONDITION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) phba->bg_guard_err_cnt++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853) lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) "9069 BLKGRD: LBA %lx grd_tag error %x != %x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) (unsigned long)scsi_get_lba(cmd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) sum, guard_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858) } else if (err_type == BGS_REFTAG_ERR_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) 0x10, 0x3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) SAM_STAT_CHECK_CONDITION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) phba->bg_reftag_err_cnt++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) "9066 BLKGRD: LBA %lx ref_tag error %x != %x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) (unsigned long)scsi_get_lba(cmd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) ref_tag, start_ref_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) } else if (err_type == BGS_APPTAG_ERR_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) 0x10, 0x2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) SAM_STAT_CHECK_CONDITION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) phba->bg_apptag_err_cnt++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877) lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) "9041 BLKGRD: LBA %lx app_tag error %x != %x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) (unsigned long)scsi_get_lba(cmd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) app_tag, start_app_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) * This function checks for BlockGuard errors detected by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) * the HBA. In case of errors, the ASC/ASCQ fields in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888) * sense buffer will be set accordingly, paired with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) * ILLEGAL_REQUEST to signal to the kernel that the HBA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) * detected corruption.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) * 0 - No error found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) * 1 - BlockGuard error found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) * -1 - Internal error (bad profile, ...etc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) struct lpfc_iocbq *pIocbOut)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901) struct scsi_cmnd *cmd = lpfc_cmd->pCmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) struct sli3_bg_fields *bgf = &pIocbOut->iocb.unsli3.sli3_bg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) uint32_t bghm = bgf->bghm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) uint32_t bgstat = bgf->bgstat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) uint64_t failing_sector = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) if (lpfc_bgs_get_invalid_prof(bgstat)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) cmd->result = DID_ERROR << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911) "9072 BLKGRD: Invalid BG Profile in cmd"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) " 0x%x lba 0x%llx blk cnt 0x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913) "bgstat=x%x bghm=x%x\n", cmd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) (unsigned long long)scsi_get_lba(cmd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) blk_rq_sectors(cmd->request), bgstat, bghm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) ret = (-1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) if (lpfc_bgs_get_uninit_dif_block(bgstat)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) cmd->result = DID_ERROR << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) "9073 BLKGRD: Invalid BG PDIF Block in cmd"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) " 0x%x lba 0x%llx blk cnt 0x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925) "bgstat=x%x bghm=x%x\n", cmd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) (unsigned long long)scsi_get_lba(cmd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) blk_rq_sectors(cmd->request), bgstat, bghm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) ret = (-1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) if (lpfc_bgs_get_guard_err(bgstat)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) ret = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935) scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) 0x10, 0x1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) SAM_STAT_CHECK_CONDITION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) phba->bg_guard_err_cnt++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) "9055 BLKGRD: Guard Tag error in cmd"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) " 0x%x lba 0x%llx blk cnt 0x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) "bgstat=x%x bghm=x%x\n", cmd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) (unsigned long long)scsi_get_lba(cmd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) blk_rq_sectors(cmd->request), bgstat, bghm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) if (lpfc_bgs_get_reftag_err(bgstat)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) ret = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) 0x10, 0x3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) SAM_STAT_CHECK_CONDITION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) phba->bg_reftag_err_cnt++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) "9056 BLKGRD: Ref Tag error in cmd"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) " 0x%x lba 0x%llx blk cnt 0x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) "bgstat=x%x bghm=x%x\n", cmd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) (unsigned long long)scsi_get_lba(cmd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) blk_rq_sectors(cmd->request), bgstat, bghm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) if (lpfc_bgs_get_apptag_err(bgstat)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) ret = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) scsi_build_sense_buffer(1, cmd->sense_buffer, ILLEGAL_REQUEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) 0x10, 0x2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970) cmd->result = DRIVER_SENSE << 24 | DID_ABORT << 16 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) SAM_STAT_CHECK_CONDITION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) phba->bg_apptag_err_cnt++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) "9061 BLKGRD: App Tag error in cmd"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976) " 0x%x lba 0x%llx blk cnt 0x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) "bgstat=x%x bghm=x%x\n", cmd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) (unsigned long long)scsi_get_lba(cmd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) blk_rq_sectors(cmd->request), bgstat, bghm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) if (lpfc_bgs_get_hi_water_mark_present(bgstat)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) * setup sense data descriptor 0 per SPC-4 as an information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) * field, and put the failing LBA in it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) * This code assumes there was also a guard/app/ref tag error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) * indication.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) cmd->sense_buffer[7] = 0xc; /* Additional sense length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) cmd->sense_buffer[8] = 0; /* Information descriptor type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) cmd->sense_buffer[9] = 0xa; /* Additional descriptor length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) cmd->sense_buffer[10] = 0x80; /* Validity bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) /* bghm is a "on the wire" FC frame based count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) switch (scsi_get_prot_op(cmd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) case SCSI_PROT_READ_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997) case SCSI_PROT_WRITE_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) bghm /= cmd->device->sector_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000) case SCSI_PROT_READ_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) case SCSI_PROT_WRITE_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) case SCSI_PROT_READ_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003) case SCSI_PROT_WRITE_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) bghm /= (cmd->device->sector_size +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) sizeof(struct scsi_dif_tuple));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) failing_sector = scsi_get_lba(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) failing_sector += bghm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) /* Descriptor Information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) put_unaligned_be64(failing_sector, &cmd->sense_buffer[12]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) if (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) /* No error was reported - problem in FW? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) "9057 BLKGRD: Unknown error in cmd"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) " 0x%x lba 0x%llx blk cnt 0x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) "bgstat=x%x bghm=x%x\n", cmd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) (unsigned long long)scsi_get_lba(cmd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) blk_rq_sectors(cmd->request), bgstat, bghm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) /* Calcuate what type of error it was */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) lpfc_calc_bg_err(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) * lpfc_scsi_prep_dma_buf_s4 - DMA mapping for scsi buffer to SLI4 IF spec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) * @lpfc_cmd: The scsi buffer which is going to be mapped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) * This routine does the pci dma mapping for scatter-gather list of scsi cmnd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038) * field of @lpfc_cmd for device with SLI-4 interface spec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) * 2 - Error - Do not retry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) * 1 - Error - Retry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) * 0 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) struct scatterlist *sgel = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051) struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) struct sli4_sge *first_data_sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053) IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) dma_addr_t physaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) uint32_t num_bde = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) uint32_t dma_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) uint32_t dma_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) int nseg, i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) struct ulp_bde64 *bde;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) bool lsp_just_set = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061) struct sli4_hybrid_sgl *sgl_xtra = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) * There are three possibilities here - use scatter-gather segment, use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) * the single mapping, or neither. Start the lpfc command prep by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) * bumping the bpl beyond the fcp_cmnd and fcp_rsp regions to the first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) * data bde entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) if (scsi_sg_count(scsi_cmnd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) * The driver stores the segment count returned from pci_map_sg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) * because this a count of dma-mappings used to map the use_sg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) * pages. They are not guaranteed to be the same for those
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) * architectures that implement an IOMMU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) nseg = scsi_dma_map(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) if (unlikely(nseg <= 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) sgl += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) /* clear the last flag in the fcp_rsp map entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) sgl->word2 = le32_to_cpu(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) bf_set(lpfc_sli4_sge_last, sgl, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) sgl->word2 = cpu_to_le32(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) sgl += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) first_data_sgl = sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) lpfc_cmd->seg_cnt = nseg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) if (!phba->cfg_xpsgl &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091) "9074 BLKGRD:"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) " %s: Too many sg segments from "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) "dma_map_sg. Config %d, seg_cnt %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) __func__, phba->cfg_sg_seg_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095) lpfc_cmd->seg_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) WARN_ON_ONCE(lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) lpfc_cmd->seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) scsi_dma_unmap(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099) return 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) * The driver established a maximum scatter-gather segment count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) * during probe that limits the number of sg elements in any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) * single scsi command. Just run through the seg_cnt and format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) * the sge's.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) * When using SLI-3 the driver will try to fit all the BDEs into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) * the IOCB. If it can't then the BDEs get added to a BPL as it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) * does for SLI-2 mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) /* for tracking segment boundaries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113) sgel = scsi_sglist(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) j = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) for (i = 0; i < nseg; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116) sgl->word2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117) if ((num_bde + 1) == nseg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) bf_set(lpfc_sli4_sge_last, sgl, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) bf_set(lpfc_sli4_sge_type, sgl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) LPFC_SGE_TYPE_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122) bf_set(lpfc_sli4_sge_last, sgl, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124) /* do we need to expand the segment */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) if (!lsp_just_set &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) !((j + 1) % phba->border_sge_num) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127) ((nseg - 1) != i)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) /* set LSP type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) bf_set(lpfc_sli4_sge_type, sgl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130) LPFC_SGE_TYPE_LSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132) sgl_xtra = lpfc_get_sgl_per_hdwq(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133) phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135) if (unlikely(!sgl_xtra)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136) lpfc_cmd->seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) scsi_dma_unmap(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) sgl->addr_lo = cpu_to_le32(putPaddrLow(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) sgl_xtra->dma_phys_sgl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) sgl->addr_hi = cpu_to_le32(putPaddrHigh(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) sgl_xtra->dma_phys_sgl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) bf_set(lpfc_sli4_sge_type, sgl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147) LPFC_SGE_TYPE_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) if (!(bf_get(lpfc_sli4_sge_type, sgl) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) LPFC_SGE_TYPE_LSP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) if ((nseg - 1) == i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) bf_set(lpfc_sli4_sge_last, sgl, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156) physaddr = sg_dma_address(sgel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) dma_len = sg_dma_len(sgel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158) sgl->addr_lo = cpu_to_le32(putPaddrLow(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159) physaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) sgl->addr_hi = cpu_to_le32(putPaddrHigh(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161) physaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) sgl->word2 = cpu_to_le32(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) sgl->sge_len = cpu_to_le32(dma_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) dma_offset += dma_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168) sgel = sg_next(sgel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170) sgl++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) lsp_just_set = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174) sgl->word2 = cpu_to_le32(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) sgl->sge_len = cpu_to_le32(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176) phba->cfg_sg_dma_buf_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) sgl = (struct sli4_sge *)sgl_xtra->dma_sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179) i = i - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) lsp_just_set = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) j++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) * Setup the first Payload BDE. For FCoE we just key off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) * Performance Hints, for FC we use lpfc_enable_pbde.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189) * We populate words 13-15 of IOCB/WQE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) if ((phba->sli3_options & LPFC_SLI4_PERFH_ENABLED) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) phba->cfg_enable_pbde) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193) bde = (struct ulp_bde64 *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) &(iocb_cmd->unsli3.sli3Words[5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195) bde->addrLow = first_data_sgl->addr_lo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) bde->addrHigh = first_data_sgl->addr_hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) bde->tus.f.bdeSize =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) le32_to_cpu(first_data_sgl->sge_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199) bde->tus.f.bdeFlags = BUFF_TYPE_BDE_64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200) bde->tus.w = cpu_to_le32(bde->tus.w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) sgl += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) /* clear the last flag in the fcp_rsp map entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205) sgl->word2 = le32_to_cpu(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) bf_set(lpfc_sli4_sge_last, sgl, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) sgl->word2 = cpu_to_le32(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209) if ((phba->sli3_options & LPFC_SLI4_PERFH_ENABLED) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) phba->cfg_enable_pbde) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211) bde = (struct ulp_bde64 *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212) &(iocb_cmd->unsli3.sli3Words[5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) memset(bde, 0, (sizeof(uint32_t) * 3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) * Finish initializing those IOCB fields that are dependent on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) * scsi_cmnd request_buffer. Note that for SLI-2 the bdeSize is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) * explicitly reinitialized.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) * all iocb memory resources are reused.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) fcp_cmnd->fcpDl = cpu_to_be32(scsi_bufflen(scsi_cmnd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226) * Due to difference in data length between DIF/non-DIF paths,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) * we need to set word 4 of IOCB here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229) iocb_cmd->un.fcpi.fcpi_parm = scsi_bufflen(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) * If the OAS driver feature is enabled and the lun is enabled for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233) * OAS, set the oas iocb related flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) if ((phba->cfg_fof) && ((struct lpfc_device_data *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236) scsi_cmnd->device->hostdata)->oas_enabled) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237) lpfc_cmd->cur_iocbq.iocb_flag |= (LPFC_IO_OAS | LPFC_IO_FOF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) lpfc_cmd->cur_iocbq.priority = ((struct lpfc_device_data *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) scsi_cmnd->device->hostdata)->priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246) * lpfc_bg_scsi_prep_dma_buf_s4 - DMA mapping for scsi buffer to SLI4 IF spec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) * @lpfc_cmd: The scsi buffer which is going to be mapped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) * This is the protection/DIF aware version of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251) * lpfc_scsi_prep_dma_buf(). It may be a good idea to combine the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) * two functions eventually, but for now, it's here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254) * 2 - Error - Do not retry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) * 1 - Error - Retry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) * 0 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) lpfc_bg_scsi_prep_dma_buf_s4(struct lpfc_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263) struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) struct sli4_sge *sgl = (struct sli4_sge *)(lpfc_cmd->dma_sgl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265) IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) uint32_t num_sge = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) int datasegcnt, protsegcnt, datadir = scsi_cmnd->sc_data_direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) int prot_group_type = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) int fcpdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) int ret = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271) struct lpfc_vport *vport = phba->pport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274) * Start the lpfc command prep by bumping the sgl beyond fcp_cmnd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275) * fcp_rsp regions to the first data sge entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277) if (scsi_sg_count(scsi_cmnd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279) * The driver stores the segment count returned from pci_map_sg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280) * because this a count of dma-mappings used to map the use_sg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) * pages. They are not guaranteed to be the same for those
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) * architectures that implement an IOMMU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284) datasegcnt = dma_map_sg(&phba->pcidev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) scsi_sglist(scsi_cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286) scsi_sg_count(scsi_cmnd), datadir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287) if (unlikely(!datasegcnt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) sgl += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291) /* clear the last flag in the fcp_rsp map entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) sgl->word2 = le32_to_cpu(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) bf_set(lpfc_sli4_sge_last, sgl, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) sgl->word2 = cpu_to_le32(sgl->word2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) sgl += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297) lpfc_cmd->seg_cnt = datasegcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) /* First check if data segment count from SCSI Layer is good */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) !phba->cfg_xpsgl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) WARN_ON_ONCE(lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303) ret = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) prot_group_type = lpfc_prot_group_type(phba, scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) switch (prot_group_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) case LPFC_PG_TYPE_NO_DIF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) /* Here we need to add a DISEED to the count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) if (((lpfc_cmd->seg_cnt + 1) >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) phba->cfg_total_seg_cnt) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314) !phba->cfg_xpsgl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) ret = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) num_sge = lpfc_bg_setup_sgl(phba, scsi_cmnd, sgl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) datasegcnt, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) /* we should have 2 or more entries in buffer list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323) if (num_sge < 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) ret = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) case LPFC_PG_TYPE_DIF_BUF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331) * This type indicates that protection buffers are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) * passed to the driver, so that needs to be prepared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) * for DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) protsegcnt = dma_map_sg(&phba->pcidev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) scsi_prot_sglist(scsi_cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) scsi_prot_sg_count(scsi_cmnd), datadir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338) if (unlikely(!protsegcnt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) scsi_dma_unmap(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343) lpfc_cmd->prot_seg_cnt = protsegcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) * There is a minimun of 3 SGEs used for every
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) * protection data segment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) if (((lpfc_cmd->prot_seg_cnt * 3) >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) (phba->cfg_total_seg_cnt - 2)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350) !phba->cfg_xpsgl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) ret = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) num_sge = lpfc_bg_setup_sgl_prot(phba, scsi_cmnd, sgl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) datasegcnt, protsegcnt, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) /* we should have 3 or more entries in buffer list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359) if (num_sge < 3 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) (num_sge > phba->cfg_total_seg_cnt &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) !phba->cfg_xpsgl)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362) ret = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367) case LPFC_PG_TYPE_INVALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369) scsi_dma_unmap(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) lpfc_cmd->seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373) "9083 Unexpected protection group %i\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374) prot_group_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375) return 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) switch (scsi_get_prot_op(scsi_cmnd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380) case SCSI_PROT_WRITE_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) case SCSI_PROT_READ_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) lpfc_cmd->cur_iocbq.iocb_flag |= LPFC_IO_DIF_STRIP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) case SCSI_PROT_WRITE_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) case SCSI_PROT_READ_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) lpfc_cmd->cur_iocbq.iocb_flag |= LPFC_IO_DIF_INSERT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) case SCSI_PROT_WRITE_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) case SCSI_PROT_READ_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) lpfc_cmd->cur_iocbq.iocb_flag |= LPFC_IO_DIF_PASS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) fcpdl = lpfc_bg_scsi_adjust_dl(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395) fcp_cmnd->fcpDl = be32_to_cpu(fcpdl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398) * Due to difference in data length between DIF/non-DIF paths,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399) * we need to set word 4 of IOCB here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) iocb_cmd->un.fcpi.fcpi_parm = fcpdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) * For First burst, we may need to adjust the initial transfer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) * length for DIF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407) if (iocb_cmd->un.fcpi.fcpi_XRdy &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) (fcpdl < vport->cfg_first_burst_size))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409) iocb_cmd->un.fcpi.fcpi_XRdy = fcpdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) * If the OAS driver feature is enabled and the lun is enabled for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) * OAS, set the oas iocb related flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) if ((phba->cfg_fof) && ((struct lpfc_device_data *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) scsi_cmnd->device->hostdata)->oas_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417) lpfc_cmd->cur_iocbq.iocb_flag |= (LPFC_IO_OAS | LPFC_IO_FOF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) if (lpfc_cmd->seg_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) scsi_dma_unmap(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) if (lpfc_cmd->prot_seg_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) dma_unmap_sg(&phba->pcidev->dev, scsi_prot_sglist(scsi_cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425) scsi_prot_sg_count(scsi_cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) scsi_cmnd->sc_data_direction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429) "9084 Cannot setup S/G List for HBA"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430) "IO segs %d/%d SGL %d SCSI %d: %d %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) lpfc_cmd->seg_cnt, lpfc_cmd->prot_seg_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) phba->cfg_total_seg_cnt, phba->cfg_sg_seg_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) prot_group_type, num_sge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435) lpfc_cmd->seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) lpfc_cmd->prot_seg_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) * lpfc_scsi_prep_dma_buf - Wrapper function for DMA mapping of scsi buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) * @lpfc_cmd: The scsi buffer which is going to be mapped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) * This routine wraps the actual DMA mapping function pointer from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) * lpfc_hba struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449) * 1 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) * 0 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453) lpfc_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) return phba->lpfc_scsi_prep_dma_buf(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) * lpfc_bg_scsi_prep_dma_buf - Wrapper function for DMA mapping of scsi buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) * using BlockGuard.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) * @lpfc_cmd: The scsi buffer which is going to be mapped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) * This routine wraps the actual DMA mapping function pointer from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) * lpfc_hba struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) * 1 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) * 0 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) lpfc_bg_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) return phba->lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) * lpfc_send_scsi_error_event - Posts an event when there is SCSI error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479) * @phba: Pointer to hba context object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) * @vport: Pointer to vport object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) * @lpfc_cmd: Pointer to lpfc scsi command which reported the error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) * @rsp_iocb: Pointer to response iocb object which reported error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) * This function posts an event when there is a SCSI command reporting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) * error from the scsi device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488) lpfc_send_scsi_error_event(struct lpfc_hba *phba, struct lpfc_vport *vport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) struct lpfc_io_buf *lpfc_cmd, struct lpfc_iocbq *rsp_iocb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) struct scsi_cmnd *cmnd = lpfc_cmd->pCmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492) uint32_t resp_info = fcprsp->rspStatus2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493) uint32_t scsi_status = fcprsp->rspStatus3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) uint32_t fcpi_parm = rsp_iocb->iocb.un.fcpi.fcpi_parm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) struct lpfc_fast_path_event *fast_path_evt = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) struct lpfc_nodelist *pnode = lpfc_cmd->rdata->pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) if (!pnode || !NLP_CHK_NODE_ACT(pnode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) /* If there is queuefull or busy condition send a scsi event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) if ((cmnd->result == SAM_STAT_TASK_SET_FULL) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) (cmnd->result == SAM_STAT_BUSY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) fast_path_evt = lpfc_alloc_fast_evt(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506) if (!fast_path_evt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) fast_path_evt->un.scsi_evt.event_type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) FC_REG_SCSI_EVENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510) fast_path_evt->un.scsi_evt.subcategory =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511) (cmnd->result == SAM_STAT_TASK_SET_FULL) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) LPFC_EVENT_QFULL : LPFC_EVENT_DEVBSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) fast_path_evt->un.scsi_evt.lun = cmnd->device->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) memcpy(&fast_path_evt->un.scsi_evt.wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515) &pnode->nlp_portname, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) memcpy(&fast_path_evt->un.scsi_evt.wwnn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) &pnode->nlp_nodename, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518) } else if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519) ((cmnd->cmnd[0] == READ_10) || (cmnd->cmnd[0] == WRITE_10))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) fast_path_evt = lpfc_alloc_fast_evt(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521) if (!fast_path_evt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523) fast_path_evt->un.check_cond_evt.scsi_event.event_type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) FC_REG_SCSI_EVENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) fast_path_evt->un.check_cond_evt.scsi_event.subcategory =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) LPFC_EVENT_CHECK_COND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527) fast_path_evt->un.check_cond_evt.scsi_event.lun =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) cmnd->device->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) memcpy(&fast_path_evt->un.check_cond_evt.scsi_event.wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) &pnode->nlp_portname, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) memcpy(&fast_path_evt->un.check_cond_evt.scsi_event.wwnn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) &pnode->nlp_nodename, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) fast_path_evt->un.check_cond_evt.sense_key =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) cmnd->sense_buffer[2] & 0xf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535) fast_path_evt->un.check_cond_evt.asc = cmnd->sense_buffer[12];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) fast_path_evt->un.check_cond_evt.ascq = cmnd->sense_buffer[13];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) } else if ((cmnd->sc_data_direction == DMA_FROM_DEVICE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) fcpi_parm &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539) ((be32_to_cpu(fcprsp->rspResId) != fcpi_parm) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) ((scsi_status == SAM_STAT_GOOD) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) !(resp_info & (RESID_UNDER | RESID_OVER))))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543) * If status is good or resid does not match with fcp_param and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) * there is valid fcpi_parm, then there is a read_check error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) fast_path_evt = lpfc_alloc_fast_evt(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) if (!fast_path_evt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549) fast_path_evt->un.read_check_error.header.event_type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550) FC_REG_FABRIC_EVENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551) fast_path_evt->un.read_check_error.header.subcategory =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) LPFC_EVENT_FCPRDCHKERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) memcpy(&fast_path_evt->un.read_check_error.header.wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) &pnode->nlp_portname, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555) memcpy(&fast_path_evt->un.read_check_error.header.wwnn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) &pnode->nlp_nodename, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) fast_path_evt->un.read_check_error.lun = cmnd->device->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) fast_path_evt->un.read_check_error.opcode = cmnd->cmnd[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559) fast_path_evt->un.read_check_error.fcpiparam =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) fcpi_parm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) fast_path_evt->vport = vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) spin_lock_irqsave(&phba->hbalock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566) list_add_tail(&fast_path_evt->work_evt.evt_listp, &phba->work_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) spin_unlock_irqrestore(&phba->hbalock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) lpfc_worker_wake_up(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) * lpfc_scsi_unprep_dma_buf - Un-map DMA mapping of SG-list for dev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574) * @phba: The HBA for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575) * @psb: The scsi buffer which is going to be un-mapped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) * This routine does DMA un-mapping of scatter gather list of scsi command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) * field of @lpfc_cmd for device with SLI-3 interface spec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581) lpfc_scsi_unprep_dma_buf(struct lpfc_hba *phba, struct lpfc_io_buf *psb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584) * There are only two special cases to consider. (1) the scsi command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585) * requested scatter-gather usage or (2) the scsi command allocated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) * a request buffer, but did not request use_sg. There is a third
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) * case, but it does not require resource deallocation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589) if (psb->seg_cnt > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) scsi_dma_unmap(psb->pCmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591) if (psb->prot_seg_cnt > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) dma_unmap_sg(&phba->pcidev->dev, scsi_prot_sglist(psb->pCmd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593) scsi_prot_sg_count(psb->pCmd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) psb->pCmd->sc_data_direction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) * lpfc_handler_fcp_err - FCP response handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599) * @vport: The virtual port for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) * @lpfc_cmd: Pointer to lpfc_io_buf data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) * @rsp_iocb: The response IOCB which contains FCP error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603) * This routine is called to process response IOCB with status field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) * IOSTAT_FCP_RSP_ERROR. This routine sets result field of scsi command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) * based upon SCSI and FCP error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608) lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) struct lpfc_iocbq *rsp_iocb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) struct scsi_cmnd *cmnd = lpfc_cmd->pCmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) struct fcp_cmnd *fcpcmd = lpfc_cmd->fcp_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) uint32_t fcpi_parm = rsp_iocb->iocb.un.fcpi.fcpi_parm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) uint32_t resp_info = fcprsp->rspStatus2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) uint32_t scsi_status = fcprsp->rspStatus3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) uint32_t *lp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) uint32_t host_status = DID_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) uint32_t rsplen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621) uint32_t fcpDl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) uint32_t logit = LOG_FCP | LOG_FCP_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) * If this is a task management command, there is no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) * scsi packet associated with this lpfc_cmd. The driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628) * consumes it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) if (fcpcmd->fcpCntl2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) scsi_status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635) if (resp_info & RSP_LEN_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) rsplen = be32_to_cpu(fcprsp->rspRspLen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) if (rsplen != 0 && rsplen != 4 && rsplen != 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) "2719 Invalid response length: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640) "tgt x%x lun x%llx cmnd x%x rsplen "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) "x%x\n", cmnd->device->id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) cmnd->device->lun, cmnd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) rsplen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) host_status = DID_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) if (fcprsp->rspInfo3 != RSP_NO_FAILURE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) "2757 Protocol failure detected during "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) "processing of FCP I/O op: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) "tgt x%x lun x%llx cmnd x%x rspInfo3 x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) cmnd->device->id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) cmnd->device->lun, cmnd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) fcprsp->rspInfo3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655) host_status = DID_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660) if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661) uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662) if (snslen > SCSI_SENSE_BUFFERSIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) snslen = SCSI_SENSE_BUFFERSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) if (resp_info & RSP_LEN_VALID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) rsplen = be32_to_cpu(fcprsp->rspRspLen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667) memcpy(cmnd->sense_buffer, &fcprsp->rspInfo0 + rsplen, snslen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669) lp = (uint32_t *)cmnd->sense_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) /* special handling for under run conditions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672) if (!scsi_status && (resp_info & RESID_UNDER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673) /* don't log under runs if fcp set... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) if (vport->cfg_log_verbose & LOG_FCP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675) logit = LOG_FCP_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676) /* unless operator says so */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677) if (vport->cfg_log_verbose & LOG_FCP_UNDER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678) logit = LOG_FCP_UNDER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) lpfc_printf_vlog(vport, KERN_WARNING, logit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) "9024 FCP command x%x failed: x%x SNS x%x x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683) "Data: x%x x%x x%x x%x x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684) cmnd->cmnd[0], scsi_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) be32_to_cpu(*lp), be32_to_cpu(*(lp + 3)), resp_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) be32_to_cpu(fcprsp->rspResId),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687) be32_to_cpu(fcprsp->rspSnsLen),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688) be32_to_cpu(fcprsp->rspRspLen),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689) fcprsp->rspInfo3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) scsi_set_resid(cmnd, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) fcpDl = be32_to_cpu(fcpcmd->fcpDl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693) if (resp_info & RESID_UNDER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694) scsi_set_resid(cmnd, be32_to_cpu(fcprsp->rspResId));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP_UNDER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697) "9025 FCP Underrun, expected %d, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) "residual %d Data: x%x x%x x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699) fcpDl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700) scsi_get_resid(cmnd), fcpi_parm, cmnd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701) cmnd->underflow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) * If there is an under run, check if under run reported by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705) * storage array is same as the under run reported by HBA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) * If this is not same, there is a dropped frame.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) if (fcpi_parm && (scsi_get_resid(cmnd) != fcpi_parm)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709) lpfc_printf_vlog(vport, KERN_WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710) LOG_FCP | LOG_FCP_ERROR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) "9026 FCP Read Check Error "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712) "and Underrun Data: x%x x%x x%x x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713) fcpDl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714) scsi_get_resid(cmnd), fcpi_parm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) cmnd->cmnd[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716) scsi_set_resid(cmnd, scsi_bufflen(cmnd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) host_status = DID_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720) * The cmnd->underflow is the minimum number of bytes that must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721) * be transferred for this command. Provided a sense condition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) * is not present, make sure the actual amount transferred is at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723) * least the underflow value or fail.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725) if (!(resp_info & SNS_LEN_VALID) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726) (scsi_status == SAM_STAT_GOOD) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727) (scsi_bufflen(cmnd) - scsi_get_resid(cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728) < cmnd->underflow)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730) "9027 FCP command x%x residual "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) "underrun converted to error "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732) "Data: x%x x%x x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) cmnd->cmnd[0], scsi_bufflen(cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734) scsi_get_resid(cmnd), cmnd->underflow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) host_status = DID_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) } else if (resp_info & RESID_OVER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738) lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739) "9028 FCP command x%x residual overrun error. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740) "Data: x%x x%x\n", cmnd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) scsi_bufflen(cmnd), scsi_get_resid(cmnd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742) host_status = DID_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745) * Check SLI validation that all the transfer was actually done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746) * (fcpi_parm should be zero). Apply check only to reads.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748) } else if (fcpi_parm) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP | LOG_FCP_ERROR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) "9029 FCP %s Check Error xri x%x Data: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751) "x%x x%x x%x x%x x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) ((cmnd->sc_data_direction == DMA_FROM_DEVICE) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753) "Read" : "Write"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) ((phba->sli_rev == LPFC_SLI_REV4) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755) lpfc_cmd->cur_iocbq.sli4_xritag :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756) rsp_iocb->iocb.ulpContext),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757) fcpDl, be32_to_cpu(fcprsp->rspResId),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) fcpi_parm, cmnd->cmnd[0], scsi_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760) /* There is some issue with the LPe12000 that causes it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761) * to miscalculate the fcpi_parm and falsely trip this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) * recovery logic. Detect this case and don't error when true.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) if (fcpi_parm > fcpDl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3767) switch (scsi_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3768) case SAM_STAT_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3769) case SAM_STAT_CHECK_CONDITION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770) /* Fabric dropped a data frame. Fail any successful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771) * command in which we detected dropped frames.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772) * A status of good or some check conditions could
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773) * be considered a successful command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775) host_status = DID_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778) scsi_set_resid(cmnd, scsi_bufflen(cmnd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782) cmnd->result = host_status << 16 | scsi_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783) lpfc_send_scsi_error_event(vport->phba, vport, lpfc_cmd, rsp_iocb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) * lpfc_scsi_cmd_iocb_cmpl - Scsi cmnd IOCB completion routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789) * @pIocbIn: The command IOCBQ for the scsi cmnd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790) * @pIocbOut: The response IOCBQ for the scsi cmnd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792) * This routine assigns scsi command result by looking into response IOCB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793) * status field appropriately. This routine handles QUEUE FULL condition as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794) * well by ramping down device queue depth.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) struct lpfc_iocbq *pIocbOut)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) struct lpfc_io_buf *lpfc_cmd =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801) (struct lpfc_io_buf *) pIocbIn->context1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802) struct lpfc_vport *vport = pIocbIn->vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) struct lpfc_rport_data *rdata = lpfc_cmd->rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) struct lpfc_nodelist *pnode = rdata->pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805) struct scsi_cmnd *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) struct lpfc_fast_path_event *fast_path_evt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809) int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810) uint32_t logit = LOG_FCP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812) /* Guard against abort handler being called at same time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) spin_lock(&lpfc_cmd->buf_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815) /* Sanity check on return of outstanding command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816) cmd = lpfc_cmd->pCmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817) if (!cmd || !phba) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819) "2621 IO completion: Not an active IO\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820) spin_unlock(&lpfc_cmd->buf_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824) idx = lpfc_cmd->cur_iocbq.hba_wqidx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825) if (phba->sli4_hba.hdwq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826) phba->sli4_hba.hdwq[idx].scsi_cstat.io_cmpls++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3829) if (unlikely(phba->hdwqstat_on & LPFC_CHECK_SCSI_IO))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3830) this_cpu_inc(phba->sli4_hba.c_stat->cmpl_io);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3831) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3832) shost = cmd->device->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834) lpfc_cmd->result = (pIocbOut->iocb.un.ulpWord[4] & IOERR_PARAM_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835) lpfc_cmd->status = pIocbOut->iocb.ulpStatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836) /* pick up SLI4 exhange busy status from HBA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) if (pIocbOut->iocb_flag & LPFC_EXCHANGE_BUSY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838) lpfc_cmd->flags |= LPFC_SBUF_XBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3840) lpfc_cmd->flags &= ~LPFC_SBUF_XBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3842) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843) if (lpfc_cmd->prot_data_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844) struct scsi_dif_tuple *src = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846) src = (struct scsi_dif_tuple *)lpfc_cmd->prot_data_segment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3847) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3848) * Used to restore any changes to protection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3849) * data for error injection.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3850) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3851) switch (lpfc_cmd->prot_data_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3852) case LPFC_INJERR_REFTAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3853) src->ref_tag =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3854) lpfc_cmd->prot_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3855) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3856) case LPFC_INJERR_APPTAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3857) src->app_tag =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3858) (uint16_t)lpfc_cmd->prot_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3859) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3860) case LPFC_INJERR_GUARD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3861) src->guard_tag =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3862) (uint16_t)lpfc_cmd->prot_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3863) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3864) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3865) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3866) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3868) lpfc_cmd->prot_data = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3869) lpfc_cmd->prot_data_type = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3870) lpfc_cmd->prot_data_segment = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3871) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3872) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3873)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3874) if (unlikely(lpfc_cmd->status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3875) if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3876) (lpfc_cmd->result & IOERR_DRVR_MASK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3877) lpfc_cmd->status = IOSTAT_DRIVER_REJECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3878) else if (lpfc_cmd->status >= IOSTAT_CNT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3879) lpfc_cmd->status = IOSTAT_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3880) if (lpfc_cmd->status == IOSTAT_FCP_RSP_ERROR &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3881) !lpfc_cmd->fcp_rsp->rspStatus3 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3882) (lpfc_cmd->fcp_rsp->rspStatus2 & RESID_UNDER) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3883) !(vport->cfg_log_verbose & LOG_FCP_UNDER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3884) logit = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3885) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3886) logit = LOG_FCP | LOG_FCP_UNDER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3887) lpfc_printf_vlog(vport, KERN_WARNING, logit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3888) "9030 FCP cmd x%x failed <%d/%lld> "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3889) "status: x%x result: x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3890) "sid: x%x did: x%x oxid: x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3891) "Data: x%x x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3892) cmd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3893) cmd->device ? cmd->device->id : 0xffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3894) cmd->device ? cmd->device->lun : 0xffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3895) lpfc_cmd->status, lpfc_cmd->result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3896) vport->fc_myDID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3897) (pnode) ? pnode->nlp_DID : 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3898) phba->sli_rev == LPFC_SLI_REV4 ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3899) lpfc_cmd->cur_iocbq.sli4_xritag : 0xffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3900) pIocbOut->iocb.ulpContext,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3901) lpfc_cmd->cur_iocbq.iocb.ulpIoTag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3903) switch (lpfc_cmd->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3904) case IOSTAT_FCP_RSP_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3905) /* Call FCP RSP handler to determine result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3906) lpfc_handle_fcp_err(vport, lpfc_cmd, pIocbOut);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3907) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3908) case IOSTAT_NPORT_BSY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3909) case IOSTAT_FABRIC_BSY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3910) cmd->result = DID_TRANSPORT_DISRUPTED << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3911) fast_path_evt = lpfc_alloc_fast_evt(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3912) if (!fast_path_evt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3913) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3914) fast_path_evt->un.fabric_evt.event_type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3915) FC_REG_FABRIC_EVENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3916) fast_path_evt->un.fabric_evt.subcategory =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3917) (lpfc_cmd->status == IOSTAT_NPORT_BSY) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3918) LPFC_EVENT_PORT_BUSY : LPFC_EVENT_FABRIC_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3919) if (pnode && NLP_CHK_NODE_ACT(pnode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3920) memcpy(&fast_path_evt->un.fabric_evt.wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3921) &pnode->nlp_portname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3922) sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3923) memcpy(&fast_path_evt->un.fabric_evt.wwnn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3924) &pnode->nlp_nodename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3925) sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3926) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3927) fast_path_evt->vport = vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3928) fast_path_evt->work_evt.evt =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3929) LPFC_EVT_FASTPATH_MGMT_EVT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3930) spin_lock_irqsave(&phba->hbalock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3931) list_add_tail(&fast_path_evt->work_evt.evt_listp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3932) &phba->work_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3933) spin_unlock_irqrestore(&phba->hbalock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3934) lpfc_worker_wake_up(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3935) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3936) case IOSTAT_LOCAL_REJECT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3937) case IOSTAT_REMOTE_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3938) if (lpfc_cmd->result == IOERR_ELXSEC_KEY_UNWRAP_ERROR ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3939) lpfc_cmd->result ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3940) IOERR_ELXSEC_KEY_UNWRAP_COMPARE_ERROR ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3941) lpfc_cmd->result == IOERR_ELXSEC_CRYPTO_ERROR ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3942) lpfc_cmd->result ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3943) IOERR_ELXSEC_CRYPTO_COMPARE_ERROR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3944) cmd->result = DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3945) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3946) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3947) if (lpfc_cmd->result == IOERR_INVALID_RPI ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3948) lpfc_cmd->result == IOERR_NO_RESOURCES ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3949) lpfc_cmd->result == IOERR_ABORT_REQUESTED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3950) lpfc_cmd->result == IOERR_SLER_CMD_RCV_FAILURE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3951) cmd->result = DID_REQUEUE << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3952) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3953) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3954) if ((lpfc_cmd->result == IOERR_RX_DMA_FAILED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3955) lpfc_cmd->result == IOERR_TX_DMA_FAILED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3956) pIocbOut->iocb.unsli3.sli3_bg.bgstat) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3957) if (scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3958) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3959) * This is a response for a BG enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3960) * cmd. Parse BG error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3961) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3962) lpfc_parse_bg_err(phba, lpfc_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3963) pIocbOut);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3964) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3965) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3966) lpfc_printf_vlog(vport, KERN_WARNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3967) LOG_BG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3968) "9031 non-zero BGSTAT "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3969) "on unprotected cmd\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3970) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3971) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3972) if ((lpfc_cmd->status == IOSTAT_REMOTE_STOP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3973) && (phba->sli_rev == LPFC_SLI_REV4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3974) && (pnode && NLP_CHK_NODE_ACT(pnode))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3975) /* This IO was aborted by the target, we don't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3976) * know the rxid and because we did not send the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3977) * ABTS we cannot generate and RRQ.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3978) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3979) lpfc_set_rrq_active(phba, pnode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3980) lpfc_cmd->cur_iocbq.sli4_lxritag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3981) 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3982) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3983) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3984) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3985) cmd->result = DID_ERROR << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3986) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3987) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3989) if (!pnode || !NLP_CHK_NODE_ACT(pnode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3990) || (pnode->nlp_state != NLP_STE_MAPPED_NODE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3991) cmd->result = DID_TRANSPORT_DISRUPTED << 16 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3992) SAM_STAT_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3993) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3994) cmd->result = DID_OK << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3996) if (cmd->result || lpfc_cmd->fcp_rsp->rspSnsLen) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3997) uint32_t *lp = (uint32_t *)cmd->sense_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3999) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4000) "0710 Iodone <%d/%llu> cmd x%px, error "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4001) "x%x SNS x%x x%x Data: x%x x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4002) cmd->device->id, cmd->device->lun, cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4003) cmd->result, *lp, *(lp + 3), cmd->retries,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4004) scsi_get_resid(cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4005) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4007) lpfc_update_stats(vport, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4008) if (vport->cfg_max_scsicmpl_time &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4009) time_after(jiffies, lpfc_cmd->start_time +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4010) msecs_to_jiffies(vport->cfg_max_scsicmpl_time))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4011) spin_lock_irqsave(shost->host_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4012) if (pnode && NLP_CHK_NODE_ACT(pnode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4013) if (pnode->cmd_qdepth >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4014) atomic_read(&pnode->cmd_pending) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4015) (atomic_read(&pnode->cmd_pending) >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4016) LPFC_MIN_TGT_QDEPTH) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4017) ((cmd->cmnd[0] == READ_10) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4018) (cmd->cmnd[0] == WRITE_10)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4019) pnode->cmd_qdepth =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4020) atomic_read(&pnode->cmd_pending);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4022) pnode->last_change_time = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4023) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4024) spin_unlock_irqrestore(shost->host_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4025) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4026) lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4028) lpfc_cmd->pCmd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4029) spin_unlock(&lpfc_cmd->buf_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4031) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4032) if (lpfc_cmd->ts_cmd_start) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4033) lpfc_cmd->ts_isr_cmpl = pIocbIn->isr_timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4034) lpfc_cmd->ts_data_io = ktime_get_ns();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4035) phba->ktime_last_cmd = lpfc_cmd->ts_data_io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4036) lpfc_io_ktime(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4037) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4038) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4039) /* The sdev is not guaranteed to be valid post scsi_done upcall. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4040) cmd->scsi_done(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4042) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4043) * If there is an abort thread waiting for command completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4044) * wake up the thread.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4045) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4046) spin_lock(&lpfc_cmd->buf_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4047) lpfc_cmd->cur_iocbq.iocb_flag &= ~LPFC_DRIVER_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4048) if (lpfc_cmd->waitq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4049) wake_up(lpfc_cmd->waitq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4050) spin_unlock(&lpfc_cmd->buf_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4052) lpfc_release_scsi_buf(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4053) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4054)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4055) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4056) * lpfc_fcpcmd_to_iocb - copy the fcp_cmd data into the IOCB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4057) * @data: A pointer to the immediate command data portion of the IOCB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4058) * @fcp_cmnd: The FCP Command that is provided by the SCSI layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4059) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4060) * The routine copies the entire FCP command from @fcp_cmnd to @data while
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4061) * byte swapping the data to big endian format for transmission on the wire.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4062) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4063) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4064) lpfc_fcpcmd_to_iocb(uint8_t *data, struct fcp_cmnd *fcp_cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4065) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4066) int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4067) for (i = 0, j = 0; i < sizeof(struct fcp_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4068) i += sizeof(uint32_t), j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4069) ((uint32_t *)data)[j] = cpu_to_be32(((uint32_t *)fcp_cmnd)[j]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4070) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4071) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4073) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4074) * lpfc_scsi_prep_cmnd - Wrapper func for convert scsi cmnd to FCP info unit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4075) * @vport: The virtual port for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4076) * @lpfc_cmd: The scsi command which needs to send.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4077) * @pnode: Pointer to lpfc_nodelist.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4078) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4079) * This routine initializes fcp_cmnd and iocb data structure from scsi command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4080) * to transfer for device with SLI3 interface spec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4081) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4082) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4083) lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4084) struct lpfc_nodelist *pnode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4085) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4086) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4087) struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4088) struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4089) IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4090) struct lpfc_iocbq *piocbq = &(lpfc_cmd->cur_iocbq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4091) struct lpfc_sli4_hdw_queue *hdwq = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4092) int datadir = scsi_cmnd->sc_data_direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4093) int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4094) uint8_t *ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4095) bool sli4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4096) uint32_t fcpdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4097)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4098) if (!pnode || !NLP_CHK_NODE_ACT(pnode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4099) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4101) lpfc_cmd->fcp_rsp->rspSnsLen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4102) /* clear task management bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4103) lpfc_cmd->fcp_cmnd->fcpCntl2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4105) int_to_scsilun(lpfc_cmd->pCmd->device->lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4106) &lpfc_cmd->fcp_cmnd->fcp_lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4108) ptr = &fcp_cmnd->fcpCdb[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4109) memcpy(ptr, scsi_cmnd->cmnd, scsi_cmnd->cmd_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4110) if (scsi_cmnd->cmd_len < LPFC_FCP_CDB_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4111) ptr += scsi_cmnd->cmd_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4112) memset(ptr, 0, (LPFC_FCP_CDB_LEN - scsi_cmnd->cmd_len));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4115) fcp_cmnd->fcpCntl1 = SIMPLE_Q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4117) sli4 = (phba->sli_rev == LPFC_SLI_REV4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4118) piocbq->iocb.un.fcpi.fcpi_XRdy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4119) idx = lpfc_cmd->hdwq_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4120) if (phba->sli4_hba.hdwq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4121) hdwq = &phba->sli4_hba.hdwq[idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4123) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4124) * There are three possibilities here - use scatter-gather segment, use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4125) * the single mapping, or neither. Start the lpfc command prep by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4126) * bumping the bpl beyond the fcp_cmnd and fcp_rsp regions to the first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4127) * data bde entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4128) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4129) if (scsi_sg_count(scsi_cmnd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4130) if (datadir == DMA_TO_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4131) iocb_cmd->ulpCommand = CMD_FCP_IWRITE64_CR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4132) iocb_cmd->ulpPU = PARM_READ_CHECK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4133) if (vport->cfg_first_burst_size &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4134) (pnode->nlp_flag & NLP_FIRSTBURST)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4135) fcpdl = scsi_bufflen(scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4136) if (fcpdl < vport->cfg_first_burst_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4137) piocbq->iocb.un.fcpi.fcpi_XRdy = fcpdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4138) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4139) piocbq->iocb.un.fcpi.fcpi_XRdy =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4140) vport->cfg_first_burst_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4142) fcp_cmnd->fcpCntl3 = WRITE_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4143) if (hdwq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4144) hdwq->scsi_cstat.output_requests++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4145) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4146) iocb_cmd->ulpCommand = CMD_FCP_IREAD64_CR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4147) iocb_cmd->ulpPU = PARM_READ_CHECK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4148) fcp_cmnd->fcpCntl3 = READ_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4149) if (hdwq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4150) hdwq->scsi_cstat.input_requests++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4152) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4153) iocb_cmd->ulpCommand = CMD_FCP_ICMND64_CR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4154) iocb_cmd->un.fcpi.fcpi_parm = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4155) iocb_cmd->ulpPU = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4156) fcp_cmnd->fcpCntl3 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4157) if (hdwq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4158) hdwq->scsi_cstat.control_requests++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4160) if (phba->sli_rev == 3 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4161) !(phba->sli3_options & LPFC_SLI3_BG_ENABLED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4162) lpfc_fcpcmd_to_iocb(iocb_cmd->unsli3.fcp_ext.icd, fcp_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4163) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4164) * Finish initializing those IOCB fields that are independent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4165) * of the scsi_cmnd request_buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4166) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4167) piocbq->iocb.ulpContext = pnode->nlp_rpi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4168) if (sli4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4169) piocbq->iocb.ulpContext =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4170) phba->sli4_hba.rpi_ids[pnode->nlp_rpi];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4171) if (pnode->nlp_fcp_info & NLP_FCP_2_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4172) piocbq->iocb.ulpFCP2Rcvy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4173) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4174) piocbq->iocb.ulpFCP2Rcvy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4176) piocbq->iocb.ulpClass = (pnode->nlp_fcp_info & 0x0f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4177) piocbq->context1 = lpfc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4178) piocbq->iocb_cmpl = lpfc_scsi_cmd_iocb_cmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4179) piocbq->iocb.ulpTimeout = lpfc_cmd->timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4180) piocbq->vport = vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4183) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4184) * lpfc_scsi_prep_task_mgmt_cmd - Convert SLI3 scsi TM cmd to FCP info unit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4185) * @vport: The virtual port for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4186) * @lpfc_cmd: Pointer to lpfc_io_buf data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4187) * @lun: Logical unit number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4188) * @task_mgmt_cmd: SCSI task management command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4189) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4190) * This routine creates FCP information unit corresponding to @task_mgmt_cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4191) * for device with SLI-3 interface spec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4192) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4193) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4194) * 0 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4195) * 1 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4196) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4197) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4198) lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_vport *vport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4199) struct lpfc_io_buf *lpfc_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4200) uint64_t lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4201) uint8_t task_mgmt_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4203) struct lpfc_iocbq *piocbq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4204) IOCB_t *piocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4205) struct fcp_cmnd *fcp_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4206) struct lpfc_rport_data *rdata = lpfc_cmd->rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4207) struct lpfc_nodelist *ndlp = rdata->pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4209) if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4210) ndlp->nlp_state != NLP_STE_MAPPED_NODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4211) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4213) piocbq = &(lpfc_cmd->cur_iocbq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4214) piocbq->vport = vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4216) piocb = &piocbq->iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4218) fcp_cmnd = lpfc_cmd->fcp_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4219) /* Clear out any old data in the FCP command area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4220) memset(fcp_cmnd, 0, sizeof(struct fcp_cmnd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4221) int_to_scsilun(lun, &fcp_cmnd->fcp_lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4222) fcp_cmnd->fcpCntl2 = task_mgmt_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4223) if (vport->phba->sli_rev == 3 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4224) !(vport->phba->sli3_options & LPFC_SLI3_BG_ENABLED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4225) lpfc_fcpcmd_to_iocb(piocb->unsli3.fcp_ext.icd, fcp_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4226) piocb->ulpCommand = CMD_FCP_ICMND64_CR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4227) piocb->ulpContext = ndlp->nlp_rpi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4228) if (vport->phba->sli_rev == LPFC_SLI_REV4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4229) piocb->ulpContext =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4230) vport->phba->sli4_hba.rpi_ids[ndlp->nlp_rpi];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4232) piocb->ulpFCP2Rcvy = (ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4233) piocb->ulpClass = (ndlp->nlp_fcp_info & 0x0f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4234) piocb->ulpPU = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4235) piocb->un.fcpi.fcpi_parm = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4237) /* ulpTimeout is only one byte */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4238) if (lpfc_cmd->timeout > 0xff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4239) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4240) * Do not timeout the command at the firmware level.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4241) * The driver will provide the timeout mechanism.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4242) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4243) piocb->ulpTimeout = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4244) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4245) piocb->ulpTimeout = lpfc_cmd->timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4247) if (vport->phba->sli_rev == LPFC_SLI_REV4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4248) lpfc_sli4_set_rsp_sgl_last(vport->phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4250) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4253) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4254) * lpfc_scsi_api_table_setup - Set up scsi api function jump table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4255) * @phba: The hba struct for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4256) * @dev_grp: The HBA PCI-Device group number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4257) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4258) * This routine sets up the SCSI interface API function jump table in @phba
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4259) * struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4260) * Returns: 0 - success, -ENODEV - failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4261) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4262) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4263) lpfc_scsi_api_table_setup(struct lpfc_hba *phba, uint8_t dev_grp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4264) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4266) phba->lpfc_scsi_unprep_dma_buf = lpfc_scsi_unprep_dma_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4267) phba->lpfc_scsi_prep_cmnd = lpfc_scsi_prep_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4269) switch (dev_grp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4270) case LPFC_PCI_DEV_LP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4271) phba->lpfc_scsi_prep_dma_buf = lpfc_scsi_prep_dma_buf_s3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4272) phba->lpfc_bg_scsi_prep_dma_buf = lpfc_bg_scsi_prep_dma_buf_s3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4273) phba->lpfc_release_scsi_buf = lpfc_release_scsi_buf_s3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4274) phba->lpfc_get_scsi_buf = lpfc_get_scsi_buf_s3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4275) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4276) case LPFC_PCI_DEV_OC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4277) phba->lpfc_scsi_prep_dma_buf = lpfc_scsi_prep_dma_buf_s4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4278) phba->lpfc_bg_scsi_prep_dma_buf = lpfc_bg_scsi_prep_dma_buf_s4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4279) phba->lpfc_release_scsi_buf = lpfc_release_scsi_buf_s4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4280) phba->lpfc_get_scsi_buf = lpfc_get_scsi_buf_s4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4281) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4282) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4283) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4284) "1418 Invalid HBA PCI-device group: 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4285) dev_grp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4286) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4287) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4289) phba->lpfc_rampdown_queue_depth = lpfc_rampdown_queue_depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4290) phba->lpfc_scsi_cmd_iocb_cmpl = lpfc_scsi_cmd_iocb_cmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4291) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4294) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4295) * lpfc_taskmgmt_def_cmpl - IOCB completion routine for task management command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4296) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4297) * @cmdiocbq: Pointer to lpfc_iocbq data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4298) * @rspiocbq: Pointer to lpfc_iocbq data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4299) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4300) * This routine is IOCB completion routine for device reset and target reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4301) * routine. This routine release scsi buffer associated with lpfc_cmd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4302) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4303) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4304) lpfc_tskmgmt_def_cmpl(struct lpfc_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4305) struct lpfc_iocbq *cmdiocbq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4306) struct lpfc_iocbq *rspiocbq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4307) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4308) struct lpfc_io_buf *lpfc_cmd =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4309) (struct lpfc_io_buf *) cmdiocbq->context1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4310) if (lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4311) lpfc_release_scsi_buf(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4312) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4315) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4316) * lpfc_check_pci_resettable - Walks list of devices on pci_dev's bus to check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4317) * if issuing a pci_bus_reset is possibly unsafe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4318) * @phba: lpfc_hba pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4319) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4320) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4321) * Walks the bus_list to ensure only PCI devices with Emulex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4322) * vendor id, device ids that support hot reset, and only one occurrence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4323) * of function 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4324) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4325) * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4326) * -EBADSLT, detected invalid device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4327) * 0, successful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4328) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4329) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4330) lpfc_check_pci_resettable(struct lpfc_hba *phba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4331) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4332) const struct pci_dev *pdev = phba->pcidev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4333) struct pci_dev *ptr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4334) u8 counter = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4336) /* Walk the list of devices on the pci_dev's bus */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4337) list_for_each_entry(ptr, &pdev->bus->devices, bus_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4338) /* Check for Emulex Vendor ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4339) if (ptr->vendor != PCI_VENDOR_ID_EMULEX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4340) lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4341) "8346 Non-Emulex vendor found: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4342) "0x%04x\n", ptr->vendor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4343) return -EBADSLT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4344) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4346) /* Check for valid Emulex Device ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4347) switch (ptr->device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4348) case PCI_DEVICE_ID_LANCER_FC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4349) case PCI_DEVICE_ID_LANCER_G6_FC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4350) case PCI_DEVICE_ID_LANCER_G7_FC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4351) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4352) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4353) lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4354) "8347 Invalid device found: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4355) "0x%04x\n", ptr->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4356) return -EBADSLT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4359) /* Check for only one function 0 ID to ensure only one HBA on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4360) * secondary bus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4361) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4362) if (ptr->devfn == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4363) if (++counter > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4364) lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4365) "8348 More than one device on "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4366) "secondary bus found\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4367) return -EBADSLT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4372) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4375) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4376) * lpfc_info - Info entry point of scsi_host_template data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4377) * @host: The scsi host for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4378) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4379) * This routine provides module information about hba.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4380) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4381) * Reutrn code:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4382) * Pointer to char - Success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4383) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4384) const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4385) lpfc_info(struct Scsi_Host *host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4386) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4387) struct lpfc_vport *vport = (struct lpfc_vport *) host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4388) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4389) int link_speed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4390) static char lpfcinfobuf[384];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4391) char tmp[384] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4393) memset(lpfcinfobuf, 0, sizeof(lpfcinfobuf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4394) if (phba && phba->pcidev){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4395) /* Model Description */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4396) scnprintf(tmp, sizeof(tmp), phba->ModelDesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4397) if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4398) sizeof(lpfcinfobuf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4399) goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4401) /* PCI Info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4402) scnprintf(tmp, sizeof(tmp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4403) " on PCI bus %02x device %02x irq %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4404) phba->pcidev->bus->number, phba->pcidev->devfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4405) phba->pcidev->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4406) if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4407) sizeof(lpfcinfobuf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4408) goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4410) /* Port Number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4411) if (phba->Port[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4412) scnprintf(tmp, sizeof(tmp), " port %s", phba->Port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4413) if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4414) sizeof(lpfcinfobuf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4415) goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4418) /* Link Speed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4419) link_speed = lpfc_sli_port_speed_get(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4420) if (link_speed != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4421) scnprintf(tmp, sizeof(tmp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4422) " Logical Link Speed: %d Mbps", link_speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4423) if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4424) sizeof(lpfcinfobuf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4425) goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4428) /* PCI resettable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4429) if (!lpfc_check_pci_resettable(phba)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4430) scnprintf(tmp, sizeof(tmp), " PCI resettable");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4431) strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4435) buffer_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4436) return lpfcinfobuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4439) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4440) * lpfc_poll_rearm_time - Routine to modify fcp_poll timer of hba
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4441) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4442) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4443) * This routine modifies fcp_poll_timer field of @phba by cfg_poll_tmo.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4444) * The default value of cfg_poll_tmo is 10 milliseconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4445) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4446) static __inline__ void lpfc_poll_rearm_timer(struct lpfc_hba * phba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4447) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4448) unsigned long poll_tmo_expires =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4449) (jiffies + msecs_to_jiffies(phba->cfg_poll_tmo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4451) if (!list_empty(&phba->sli.sli3_ring[LPFC_FCP_RING].txcmplq))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4452) mod_timer(&phba->fcp_poll_timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4453) poll_tmo_expires);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4456) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4457) * lpfc_poll_start_timer - Routine to start fcp_poll_timer of HBA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4458) * @phba: The Hba for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4459) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4460) * This routine starts the fcp_poll_timer of @phba.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4461) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4462) void lpfc_poll_start_timer(struct lpfc_hba * phba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4463) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4464) lpfc_poll_rearm_timer(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4465) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4467) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4468) * lpfc_poll_timeout - Restart polling timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4469) * @ptr: Map to lpfc_hba data structure pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4470) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4471) * This routine restarts fcp_poll timer, when FCP ring polling is enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4472) * and FCP Ring interrupt is disable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4473) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4475) void lpfc_poll_timeout(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4476) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4477) struct lpfc_hba *phba = from_timer(phba, t, fcp_poll_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4479) if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4480) lpfc_sli_handle_fast_ring_event(phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4481) &phba->sli.sli3_ring[LPFC_FCP_RING], HA_R0RE_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4483) if (phba->cfg_poll & DISABLE_FCP_RING_INT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4484) lpfc_poll_rearm_timer(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4485) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4486) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4488) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4489) * lpfc_queuecommand - scsi_host_template queuecommand entry point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4490) * @cmnd: Pointer to scsi_cmnd data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4491) * @done: Pointer to done routine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4492) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4493) * Driver registers this routine to scsi midlayer to submit a @cmd to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4494) * This routine prepares an IOCB from scsi command and provides to firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4495) * The @done callback is invoked after driver finished processing the command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4496) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4497) * Return value :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4498) * 0 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4499) * SCSI_MLQUEUE_HOST_BUSY - Block all devices served by this host temporarily.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4500) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4501) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4502) lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4503) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4504) struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4505) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4506) struct lpfc_rport_data *rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4507) struct lpfc_nodelist *ndlp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4508) struct lpfc_io_buf *lpfc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4509) struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4510) int err, idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4511) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4512) uint64_t start = 0L;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4514) if (phba->ktime_on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4515) start = ktime_get_ns();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4516) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4518) rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4520) /* sanity check on references */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4521) if (unlikely(!rdata) || unlikely(!rport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4522) goto out_fail_command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4524) err = fc_remote_port_chkready(rport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4525) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4526) cmnd->result = err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4527) goto out_fail_command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4528) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4529) ndlp = rdata->pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4531) if ((scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4532) (!(phba->sli3_options & LPFC_SLI3_BG_ENABLED))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4534) lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4535) "9058 BLKGRD: ERROR: rcvd protected cmd:%02x"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4536) " op:%02x str=%s without registering for"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4537) " BlockGuard - Rejecting command\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4538) cmnd->cmnd[0], scsi_get_prot_op(cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4539) dif_op_str[scsi_get_prot_op(cmnd)]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4540) goto out_fail_command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4541) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4543) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4544) * Catch race where our node has transitioned, but the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4545) * transport is still transitioning.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4546) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4547) if (!ndlp || !NLP_CHK_NODE_ACT(ndlp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4548) goto out_tgt_busy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4549) if (lpfc_ndlp_check_qdepth(phba, ndlp)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4550) if (atomic_read(&ndlp->cmd_pending) >= ndlp->cmd_qdepth) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4551) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP_ERROR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4552) "3377 Target Queue Full, scsi Id:%d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4553) "Qdepth:%d Pending command:%d"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4554) " WWNN:%02x:%02x:%02x:%02x:"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4555) "%02x:%02x:%02x:%02x, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4556) " WWPN:%02x:%02x:%02x:%02x:"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4557) "%02x:%02x:%02x:%02x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4558) ndlp->nlp_sid, ndlp->cmd_qdepth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4559) atomic_read(&ndlp->cmd_pending),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4560) ndlp->nlp_nodename.u.wwn[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4561) ndlp->nlp_nodename.u.wwn[1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4562) ndlp->nlp_nodename.u.wwn[2],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4563) ndlp->nlp_nodename.u.wwn[3],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4564) ndlp->nlp_nodename.u.wwn[4],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4565) ndlp->nlp_nodename.u.wwn[5],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4566) ndlp->nlp_nodename.u.wwn[6],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4567) ndlp->nlp_nodename.u.wwn[7],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4568) ndlp->nlp_portname.u.wwn[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4569) ndlp->nlp_portname.u.wwn[1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4570) ndlp->nlp_portname.u.wwn[2],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4571) ndlp->nlp_portname.u.wwn[3],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4572) ndlp->nlp_portname.u.wwn[4],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4573) ndlp->nlp_portname.u.wwn[5],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4574) ndlp->nlp_portname.u.wwn[6],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4575) ndlp->nlp_portname.u.wwn[7]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4576) goto out_tgt_busy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4577) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4580) lpfc_cmd = lpfc_get_scsi_buf(phba, ndlp, cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4581) if (lpfc_cmd == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4582) lpfc_rampdown_queue_depth(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4584) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP_ERROR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4585) "0707 driver's buffer pool is empty, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4586) "IO busied\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4587) goto out_host_busy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4590) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4591) * Store the midlayer's command structure for the completion phase
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4592) * and complete the command initialization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4593) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4594) lpfc_cmd->pCmd = cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4595) lpfc_cmd->rdata = rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4596) lpfc_cmd->ndlp = ndlp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4597) cmnd->host_scribble = (unsigned char *)lpfc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4599) if (scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4600) if (vport->phba->cfg_enable_bg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4601) lpfc_printf_vlog(vport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4602) KERN_INFO, LOG_SCSI_CMD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4603) "9033 BLKGRD: rcvd %s cmd:x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4604) "sector x%llx cnt %u pt %x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4605) dif_op_str[scsi_get_prot_op(cmnd)],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4606) cmnd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4607) (unsigned long long)scsi_get_lba(cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4608) blk_rq_sectors(cmnd->request),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4609) (cmnd->cmnd[1]>>5));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4611) err = lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4612) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4613) if (vport->phba->cfg_enable_bg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4614) lpfc_printf_vlog(vport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4615) KERN_INFO, LOG_SCSI_CMD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4616) "9038 BLKGRD: rcvd PROT_NORMAL cmd: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4617) "x%x sector x%llx cnt %u pt %x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4618) cmnd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4619) (unsigned long long)scsi_get_lba(cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4620) blk_rq_sectors(cmnd->request),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4621) (cmnd->cmnd[1]>>5));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4622) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4623) err = lpfc_scsi_prep_dma_buf(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4624) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4626) if (unlikely(err)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4627) if (err == 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4628) cmnd->result = DID_ERROR << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4629) goto out_fail_command_release_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4630) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4631) goto out_host_busy_free_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4634) lpfc_scsi_prep_cmnd(vport, lpfc_cmd, ndlp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4636) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4637) if (unlikely(phba->hdwqstat_on & LPFC_CHECK_SCSI_IO))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4638) this_cpu_inc(phba->sli4_hba.c_stat->xmt_io);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4639) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4640) err = lpfc_sli_issue_iocb(phba, LPFC_FCP_RING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4641) &lpfc_cmd->cur_iocbq, SLI_IOCB_RET_IOCB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4642) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4643) if (start) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4644) lpfc_cmd->ts_cmd_start = start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4645) lpfc_cmd->ts_last_cmd = phba->ktime_last_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4646) lpfc_cmd->ts_cmd_wqput = ktime_get_ns();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4647) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4648) lpfc_cmd->ts_cmd_start = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4650) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4651) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4652) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4653) "3376 FCP could not issue IOCB err %x"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4654) "FCP cmd x%x <%d/%llu> "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4655) "sid: x%x did: x%x oxid: x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4656) "Data: x%x x%x x%x x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4657) err, cmnd->cmnd[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4658) cmnd->device ? cmnd->device->id : 0xffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4659) cmnd->device ? cmnd->device->lun : (u64) -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4660) vport->fc_myDID, ndlp->nlp_DID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4661) phba->sli_rev == LPFC_SLI_REV4 ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4662) lpfc_cmd->cur_iocbq.sli4_xritag : 0xffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4663) lpfc_cmd->cur_iocbq.iocb.ulpContext,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4664) lpfc_cmd->cur_iocbq.iocb.ulpIoTag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4665) lpfc_cmd->cur_iocbq.iocb.ulpTimeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4666) (uint32_t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4667) (cmnd->request->timeout / 1000));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4669) goto out_host_busy_free_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4670) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4671) if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4672) lpfc_sli_handle_fast_ring_event(phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4673) &phba->sli.sli3_ring[LPFC_FCP_RING], HA_R0RE_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4675) if (phba->cfg_poll & DISABLE_FCP_RING_INT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4676) lpfc_poll_rearm_timer(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4677) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4679) if (phba->cfg_xri_rebalancing)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4680) lpfc_keep_pvt_pool_above_lowwm(phba, lpfc_cmd->hdwq_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4682) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4684) out_host_busy_free_buf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4685) idx = lpfc_cmd->hdwq_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4686) lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4687) if (phba->sli4_hba.hdwq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4688) switch (lpfc_cmd->fcp_cmnd->fcpCntl3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4689) case WRITE_DATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4690) phba->sli4_hba.hdwq[idx].scsi_cstat.output_requests--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4691) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4692) case READ_DATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4693) phba->sli4_hba.hdwq[idx].scsi_cstat.input_requests--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4694) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4695) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4696) phba->sli4_hba.hdwq[idx].scsi_cstat.control_requests--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4697) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4698) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4699) lpfc_release_scsi_buf(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4700) out_host_busy:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4701) return SCSI_MLQUEUE_HOST_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4703) out_tgt_busy:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4704) return SCSI_MLQUEUE_TARGET_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4706) out_fail_command_release_buf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4707) lpfc_release_scsi_buf(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4709) out_fail_command:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4710) cmnd->scsi_done(cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4711) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4715) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4716) * lpfc_abort_handler - scsi_host_template eh_abort_handler entry point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4717) * @cmnd: Pointer to scsi_cmnd data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4718) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4719) * This routine aborts @cmnd pending in base driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4720) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4721) * Return code :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4722) * 0x2003 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4723) * 0x2002 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4724) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4725) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4726) lpfc_abort_handler(struct scsi_cmnd *cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4727) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4728) struct Scsi_Host *shost = cmnd->device->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4729) struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4730) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4731) struct lpfc_iocbq *iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4732) struct lpfc_iocbq *abtsiocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4733) struct lpfc_io_buf *lpfc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4734) IOCB_t *cmd, *icmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4735) int ret = SUCCESS, status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4736) struct lpfc_sli_ring *pring_s4 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4737) int ret_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4738) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4739) DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4741) status = fc_block_scsi_eh(cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4742) if (status != 0 && status != SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4743) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4745) lpfc_cmd = (struct lpfc_io_buf *)cmnd->host_scribble;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4746) if (!lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4747) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4749) spin_lock_irqsave(&phba->hbalock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4750) /* driver queued commands are in process of being flushed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4751) if (phba->hba_flag & HBA_IOQ_FLUSH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4752) lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4753) "3168 SCSI Layer abort requested I/O has been "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4754) "flushed by LLD.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4755) ret = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4756) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4757) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4759) /* Guard against IO completion being called at same time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4760) spin_lock(&lpfc_cmd->buf_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4762) if (!lpfc_cmd->pCmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4763) lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4764) "2873 SCSI Layer I/O Abort Request IO CMPL Status "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4765) "x%x ID %d LUN %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4766) SUCCESS, cmnd->device->id, cmnd->device->lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4767) goto out_unlock_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4768) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4770) iocb = &lpfc_cmd->cur_iocbq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4771) if (phba->sli_rev == LPFC_SLI_REV4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4772) pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4773) if (!pring_s4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4774) ret = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4775) goto out_unlock_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4776) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4777) spin_lock(&pring_s4->ring_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4778) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4779) /* the command is in process of being cancelled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4780) if (!(iocb->iocb_flag & LPFC_IO_ON_TXCMPLQ)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4781) lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4782) "3169 SCSI Layer abort requested I/O has been "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4783) "cancelled by LLD.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4784) ret = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4785) goto out_unlock_ring;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4787) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4788) * If pCmd field of the corresponding lpfc_io_buf structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4789) * points to a different SCSI command, then the driver has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4790) * already completed this command, but the midlayer did not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4791) * see the completion before the eh fired. Just return SUCCESS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4792) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4793) if (lpfc_cmd->pCmd != cmnd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4794) lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4795) "3170 SCSI Layer abort requested I/O has been "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4796) "completed by LLD.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4797) goto out_unlock_ring;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4798) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4800) BUG_ON(iocb->context1 != lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4802) /* abort issued in recovery is still in progress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4803) if (iocb->iocb_flag & LPFC_DRIVER_ABORTED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4804) lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4805) "3389 SCSI Layer I/O Abort Request is pending\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4806) if (phba->sli_rev == LPFC_SLI_REV4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4807) spin_unlock(&pring_s4->ring_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4808) spin_unlock(&lpfc_cmd->buf_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4809) spin_unlock_irqrestore(&phba->hbalock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4810) goto wait_for_cmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4811) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4813) abtsiocb = __lpfc_sli_get_iocbq(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4814) if (abtsiocb == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4815) ret = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4816) goto out_unlock_ring;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4817) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4819) /* Indicate the IO is being aborted by the driver. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4820) iocb->iocb_flag |= LPFC_DRIVER_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4822) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4823) * The scsi command can not be in txq and it is in flight because the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4824) * pCmd is still pointig at the SCSI command we have to abort. There
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4825) * is no need to search the txcmplq. Just send an abort to the FW.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4826) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4828) cmd = &iocb->iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4829) icmd = &abtsiocb->iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4830) icmd->un.acxri.abortType = ABORT_TYPE_ABTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4831) icmd->un.acxri.abortContextTag = cmd->ulpContext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4832) if (phba->sli_rev == LPFC_SLI_REV4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4833) icmd->un.acxri.abortIoTag = iocb->sli4_xritag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4834) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4835) icmd->un.acxri.abortIoTag = cmd->ulpIoTag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4837) icmd->ulpLe = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4838) icmd->ulpClass = cmd->ulpClass;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4840) /* ABTS WQE must go to the same WQ as the WQE to be aborted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4841) abtsiocb->hba_wqidx = iocb->hba_wqidx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4842) abtsiocb->iocb_flag |= LPFC_USE_FCPWQIDX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4843) if (iocb->iocb_flag & LPFC_IO_FOF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4844) abtsiocb->iocb_flag |= LPFC_IO_FOF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4846) if (lpfc_is_link_up(phba))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4847) icmd->ulpCommand = CMD_ABORT_XRI_CN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4848) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4849) icmd->ulpCommand = CMD_CLOSE_XRI_CN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4851) abtsiocb->iocb_cmpl = lpfc_sli_abort_fcp_cmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4852) abtsiocb->vport = vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4853) lpfc_cmd->waitq = &waitq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4854) if (phba->sli_rev == LPFC_SLI_REV4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4855) /* Note: both hbalock and ring_lock must be set here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4856) ret_val = __lpfc_sli_issue_iocb(phba, pring_s4->ringno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4857) abtsiocb, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4858) spin_unlock(&pring_s4->ring_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4859) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4860) ret_val = __lpfc_sli_issue_iocb(phba, LPFC_FCP_RING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4861) abtsiocb, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4862) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4864) if (ret_val == IOCB_ERROR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4865) /* Indicate the IO is not being aborted by the driver. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4866) iocb->iocb_flag &= ~LPFC_DRIVER_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4867) lpfc_cmd->waitq = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4868) spin_unlock(&lpfc_cmd->buf_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4869) spin_unlock_irqrestore(&phba->hbalock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4870) lpfc_sli_release_iocbq(phba, abtsiocb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4871) ret = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4872) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4873) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4875) /* no longer need the lock after this point */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4876) spin_unlock(&lpfc_cmd->buf_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4877) spin_unlock_irqrestore(&phba->hbalock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4879) if (phba->cfg_poll & DISABLE_FCP_RING_INT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4880) lpfc_sli_handle_fast_ring_event(phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4881) &phba->sli.sli3_ring[LPFC_FCP_RING], HA_R0RE_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4882)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4883) wait_for_cmpl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4884) /* Wait for abort to complete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4885) wait_event_timeout(waitq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4886) (lpfc_cmd->pCmd != cmnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4887) msecs_to_jiffies(2*vport->cfg_devloss_tmo*1000));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4889) spin_lock(&lpfc_cmd->buf_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4891) if (lpfc_cmd->pCmd == cmnd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4892) ret = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4893) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4894) "0748 abort handler timed out waiting "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4895) "for aborting I/O (xri:x%x) to complete: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4896) "ret %#x, ID %d, LUN %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4897) iocb->sli4_xritag, ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4898) cmnd->device->id, cmnd->device->lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4899) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4901) lpfc_cmd->waitq = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4903) spin_unlock(&lpfc_cmd->buf_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4904) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4906) out_unlock_ring:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4907) if (phba->sli_rev == LPFC_SLI_REV4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4908) spin_unlock(&pring_s4->ring_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4909) out_unlock_buf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4910) spin_unlock(&lpfc_cmd->buf_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4911) out_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4912) spin_unlock_irqrestore(&phba->hbalock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4913) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4914) lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4915) "0749 SCSI Layer I/O Abort Request Status x%x ID %d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4916) "LUN %llu\n", ret, cmnd->device->id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4917) cmnd->device->lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4918) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4919) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4921) static char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4922) lpfc_taskmgmt_name(uint8_t task_mgmt_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4923) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4924) switch (task_mgmt_cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4925) case FCP_ABORT_TASK_SET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4926) return "ABORT_TASK_SET";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4927) case FCP_CLEAR_TASK_SET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4928) return "FCP_CLEAR_TASK_SET";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4929) case FCP_BUS_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4930) return "FCP_BUS_RESET";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4931) case FCP_LUN_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4932) return "FCP_LUN_RESET";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4933) case FCP_TARGET_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4934) return "FCP_TARGET_RESET";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4935) case FCP_CLEAR_ACA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4936) return "FCP_CLEAR_ACA";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4937) case FCP_TERMINATE_TASK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4938) return "FCP_TERMINATE_TASK";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4939) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4940) return "unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4941) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4942) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4945) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4946) * lpfc_check_fcp_rsp - check the returned fcp_rsp to see if task failed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4947) * @vport: The virtual port for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4948) * @lpfc_cmd: Pointer to lpfc_io_buf data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4949) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4950) * This routine checks the FCP RSP INFO to see if the tsk mgmt command succeded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4951) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4952) * Return code :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4953) * 0x2003 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4954) * 0x2002 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4955) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4956) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4957) lpfc_check_fcp_rsp(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4958) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4959) struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4960) uint32_t rsp_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4961) uint32_t rsp_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4962) uint8_t rsp_info_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4963) int ret = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4966) if (fcprsp == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4967) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4968) "0703 fcp_rsp is missing\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4969) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4970) rsp_info = fcprsp->rspStatus2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4971) rsp_len = be32_to_cpu(fcprsp->rspRspLen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4972) rsp_info_code = fcprsp->rspInfo3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4974)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4975) lpfc_printf_vlog(vport, KERN_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4976) LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4977) "0706 fcp_rsp valid 0x%x,"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4978) " rsp len=%d code 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4979) rsp_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4980) rsp_len, rsp_info_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4982) /* If FCP_RSP_LEN_VALID bit is one, then the FCP_RSP_LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4983) * field specifies the number of valid bytes of FCP_RSP_INFO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4984) * The FCP_RSP_LEN field shall be set to 0x04 or 0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4985) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4986) if ((fcprsp->rspStatus2 & RSP_LEN_VALID) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4987) ((rsp_len == 8) || (rsp_len == 4))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4988) switch (rsp_info_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4989) case RSP_NO_FAILURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4990) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4991) "0715 Task Mgmt No Failure\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4992) ret = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4993) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4994) case RSP_TM_NOT_SUPPORTED: /* TM rejected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4995) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4996) "0716 Task Mgmt Target "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4997) "reject\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4998) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4999) case RSP_TM_NOT_COMPLETED: /* TM failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5000) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5001) "0717 Task Mgmt Target "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5002) "failed TM\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5003) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5004) case RSP_TM_INVALID_LU: /* TM to invalid LU! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5005) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5006) "0718 Task Mgmt to invalid "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5007) "LUN\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5008) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5009) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5010) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5011) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5012) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5013) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5016) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5017) * lpfc_send_taskmgmt - Generic SCSI Task Mgmt Handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5018) * @vport: The virtual port for which this call is being executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5019) * @rdata: Pointer to remote port local data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5020) * @tgt_id: Target ID of remote device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5021) * @lun_id: Lun number for the TMF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5022) * @task_mgmt_cmd: type of TMF to send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5023) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5024) * This routine builds and sends a TMF (SCSI Task Mgmt Function) to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5025) * a remote port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5026) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5027) * Return Code:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5028) * 0x2003 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5029) * 0x2002 - Success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5030) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5031) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5032) lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5033) unsigned int tgt_id, uint64_t lun_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5034) uint8_t task_mgmt_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5035) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5036) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5037) struct lpfc_io_buf *lpfc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5038) struct lpfc_iocbq *iocbq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5039) struct lpfc_iocbq *iocbqrsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5040) struct lpfc_rport_data *rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5041) struct lpfc_nodelist *pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5042) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5043) int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5045) rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5046) if (!rdata || !rdata->pnode || !NLP_CHK_NODE_ACT(rdata->pnode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5047) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5048) pnode = rdata->pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5049)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5050) lpfc_cmd = lpfc_get_scsi_buf(phba, pnode, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5051) if (lpfc_cmd == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5052) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5053) lpfc_cmd->timeout = phba->cfg_task_mgmt_tmo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5054) lpfc_cmd->rdata = rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5055) lpfc_cmd->pCmd = cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5056) lpfc_cmd->ndlp = pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5057)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5058) status = lpfc_scsi_prep_task_mgmt_cmd(vport, lpfc_cmd, lun_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5059) task_mgmt_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5060) if (!status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5061) lpfc_release_scsi_buf(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5062) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5063) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5065) iocbq = &lpfc_cmd->cur_iocbq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5066) iocbqrsp = lpfc_sli_get_iocbq(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5067) if (iocbqrsp == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5068) lpfc_release_scsi_buf(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5069) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5070) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5071) iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5073) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5074) "0702 Issue %s to TGT %d LUN %llu "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5075) "rpi x%x nlp_flag x%x Data: x%x x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5076) lpfc_taskmgmt_name(task_mgmt_cmd), tgt_id, lun_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5077) pnode->nlp_rpi, pnode->nlp_flag, iocbq->sli4_xritag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5078) iocbq->iocb_flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5079)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5080) status = lpfc_sli_issue_iocb_wait(phba, LPFC_FCP_RING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5081) iocbq, iocbqrsp, lpfc_cmd->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5082) if ((status != IOCB_SUCCESS) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5083) (iocbqrsp->iocb.ulpStatus != IOSTAT_SUCCESS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5084) if (status != IOCB_SUCCESS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5085) iocbqrsp->iocb.ulpStatus != IOSTAT_FCP_RSP_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5086) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5087) "0727 TMF %s to TGT %d LUN %llu "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5088) "failed (%d, %d) iocb_flag x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5089) lpfc_taskmgmt_name(task_mgmt_cmd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5090) tgt_id, lun_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5091) iocbqrsp->iocb.ulpStatus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5092) iocbqrsp->iocb.un.ulpWord[4],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5093) iocbq->iocb_flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5094) /* if ulpStatus != IOCB_SUCCESS, then status == IOCB_SUCCESS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5095) if (status == IOCB_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5096) if (iocbqrsp->iocb.ulpStatus == IOSTAT_FCP_RSP_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5097) /* Something in the FCP_RSP was invalid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5098) * Check conditions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5099) ret = lpfc_check_fcp_rsp(vport, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5100) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5101) ret = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5102) } else if (status == IOCB_TIMEDOUT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5103) ret = TIMEOUT_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5104) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5105) ret = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5107) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5108) ret = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5110) lpfc_sli_release_iocbq(phba, iocbqrsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5112) if (ret != TIMEOUT_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5113) lpfc_release_scsi_buf(phba, lpfc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5115) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5118) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5119) * lpfc_chk_tgt_mapped -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5120) * @vport: The virtual port to check on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5121) * @cmnd: Pointer to scsi_cmnd data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5122) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5123) * This routine delays until the scsi target (aka rport) for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5124) * command exists (is present and logged in) or we declare it non-existent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5125) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5126) * Return code :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5127) * 0x2003 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5128) * 0x2002 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5129) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5130) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5131) lpfc_chk_tgt_mapped(struct lpfc_vport *vport, struct scsi_cmnd *cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5133) struct lpfc_rport_data *rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5134) struct lpfc_nodelist *pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5135) unsigned long later;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5137) rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5138) if (!rdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5139) lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5140) "0797 Tgt Map rport failure: rdata x%px\n", rdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5141) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5143) pnode = rdata->pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5144) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5145) * If target is not in a MAPPED state, delay until
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5146) * target is rediscovered or devloss timeout expires.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5147) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5148) later = msecs_to_jiffies(2 * vport->cfg_devloss_tmo * 1000) + jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5149) while (time_after(later, jiffies)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5150) if (!pnode || !NLP_CHK_NODE_ACT(pnode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5151) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5152) if (pnode->nlp_state == NLP_STE_MAPPED_NODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5153) return SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5154) schedule_timeout_uninterruptible(msecs_to_jiffies(500));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5155) rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5156) if (!rdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5157) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5158) pnode = rdata->pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5160) if (!pnode || !NLP_CHK_NODE_ACT(pnode) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5161) (pnode->nlp_state != NLP_STE_MAPPED_NODE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5162) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5163) return SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5166) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5167) * lpfc_reset_flush_io_context -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5168) * @vport: The virtual port (scsi_host) for the flush context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5169) * @tgt_id: If aborting by Target contect - specifies the target id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5170) * @lun_id: If aborting by Lun context - specifies the lun id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5171) * @context: specifies the context level to flush at.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5172) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5173) * After a reset condition via TMF, we need to flush orphaned i/o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5174) * contexts from the adapter. This routine aborts any contexts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5175) * outstanding, then waits for their completions. The wait is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5176) * bounded by devloss_tmo though.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5177) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5178) * Return code :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5179) * 0x2003 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5180) * 0x2002 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5181) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5182) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5183) lpfc_reset_flush_io_context(struct lpfc_vport *vport, uint16_t tgt_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5184) uint64_t lun_id, lpfc_ctx_cmd context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5186) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5187) unsigned long later;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5188) int cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5190) cnt = lpfc_sli_sum_iocb(vport, tgt_id, lun_id, context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5191) if (cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5192) lpfc_sli_abort_taskmgmt(vport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5193) &phba->sli.sli3_ring[LPFC_FCP_RING],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5194) tgt_id, lun_id, context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5195) later = msecs_to_jiffies(2 * vport->cfg_devloss_tmo * 1000) + jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5196) while (time_after(later, jiffies) && cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5197) schedule_timeout_uninterruptible(msecs_to_jiffies(20));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5198) cnt = lpfc_sli_sum_iocb(vport, tgt_id, lun_id, context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5200) if (cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5201) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5202) "0724 I/O flush failure for context %s : cnt x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5203) ((context == LPFC_CTX_LUN) ? "LUN" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5204) ((context == LPFC_CTX_TGT) ? "TGT" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5205) ((context == LPFC_CTX_HOST) ? "HOST" : "Unknown"))),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5206) cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5207) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5209) return SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5212) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5213) * lpfc_device_reset_handler - scsi_host_template eh_device_reset entry point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5214) * @cmnd: Pointer to scsi_cmnd data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5215) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5216) * This routine does a device reset by sending a LUN_RESET task management
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5217) * command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5218) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5219) * Return code :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5220) * 0x2003 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5221) * 0x2002 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5222) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5223) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5224) lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5225) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5226) struct Scsi_Host *shost = cmnd->device->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5227) struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5228) struct lpfc_rport_data *rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5229) struct lpfc_nodelist *pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5230) unsigned tgt_id = cmnd->device->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5231) uint64_t lun_id = cmnd->device->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5232) struct lpfc_scsi_event_header scsi_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5233) int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5235) rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5236) if (!rdata || !rdata->pnode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5237) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5238) "0798 Device Reset rdata failure: rdata x%px\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5239) rdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5240) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5242) pnode = rdata->pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5243) status = fc_block_scsi_eh(cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5244) if (status != 0 && status != SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5245) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5247) status = lpfc_chk_tgt_mapped(vport, cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5248) if (status == FAILED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5249) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5250) "0721 Device Reset rport failure: rdata x%px\n", rdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5251) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5254) scsi_event.event_type = FC_REG_SCSI_EVENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5255) scsi_event.subcategory = LPFC_EVENT_LUNRESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5256) scsi_event.lun = lun_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5257) memcpy(scsi_event.wwpn, &pnode->nlp_portname, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5258) memcpy(scsi_event.wwnn, &pnode->nlp_nodename, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5260) fc_host_post_vendor_event(shost, fc_get_event_number(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5261) sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5263) status = lpfc_send_taskmgmt(vport, cmnd, tgt_id, lun_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5264) FCP_LUN_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5266) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5267) "0713 SCSI layer issued Device Reset (%d, %llu) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5268) "return x%x\n", tgt_id, lun_id, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5270) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5271) * We have to clean up i/o as : they may be orphaned by the TMF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5272) * or if the TMF failed, they may be in an indeterminate state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5273) * So, continue on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5274) * We will report success if all the i/o aborts successfully.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5275) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5276) if (status == SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5277) status = lpfc_reset_flush_io_context(vport, tgt_id, lun_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5278) LPFC_CTX_LUN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5280) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5283) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5284) * lpfc_target_reset_handler - scsi_host_template eh_target_reset entry point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5285) * @cmnd: Pointer to scsi_cmnd data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5286) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5287) * This routine does a target reset by sending a TARGET_RESET task management
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5288) * command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5289) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5290) * Return code :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5291) * 0x2003 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5292) * 0x2002 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5293) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5294) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5295) lpfc_target_reset_handler(struct scsi_cmnd *cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5296) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5297) struct Scsi_Host *shost = cmnd->device->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5298) struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5299) struct lpfc_rport_data *rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5300) struct lpfc_nodelist *pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5301) unsigned tgt_id = cmnd->device->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5302) uint64_t lun_id = cmnd->device->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5303) struct lpfc_scsi_event_header scsi_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5304) int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5306) rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5307) if (!rdata || !rdata->pnode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5308) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5309) "0799 Target Reset rdata failure: rdata x%px\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5310) rdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5311) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5313) pnode = rdata->pnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5314) status = fc_block_scsi_eh(cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5315) if (status != 0 && status != SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5316) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5318) status = lpfc_chk_tgt_mapped(vport, cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5319) if (status == FAILED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5320) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5321) "0722 Target Reset rport failure: rdata x%px\n", rdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5322) if (pnode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5323) spin_lock_irq(shost->host_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5324) pnode->nlp_flag &= ~NLP_NPR_ADISC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5325) pnode->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5326) spin_unlock_irq(shost->host_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5328) lpfc_reset_flush_io_context(vport, tgt_id, lun_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5329) LPFC_CTX_TGT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5330) return FAST_IO_FAIL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5333) scsi_event.event_type = FC_REG_SCSI_EVENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5334) scsi_event.subcategory = LPFC_EVENT_TGTRESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5335) scsi_event.lun = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5336) memcpy(scsi_event.wwpn, &pnode->nlp_portname, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5337) memcpy(scsi_event.wwnn, &pnode->nlp_nodename, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5339) fc_host_post_vendor_event(shost, fc_get_event_number(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5340) sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5342) status = lpfc_send_taskmgmt(vport, cmnd, tgt_id, lun_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5343) FCP_TARGET_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5345) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5346) "0723 SCSI layer issued Target Reset (%d, %llu) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5347) "return x%x\n", tgt_id, lun_id, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5349) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5350) * We have to clean up i/o as : they may be orphaned by the TMF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5351) * or if the TMF failed, they may be in an indeterminate state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5352) * So, continue on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5353) * We will report success if all the i/o aborts successfully.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5354) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5355) if (status == SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5356) status = lpfc_reset_flush_io_context(vport, tgt_id, lun_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5357) LPFC_CTX_TGT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5358) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5361) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5362) * lpfc_bus_reset_handler - scsi_host_template eh_bus_reset_handler entry point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5363) * @cmnd: Pointer to scsi_cmnd data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5364) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5365) * This routine does target reset to all targets on @cmnd->device->host.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5366) * This emulates Parallel SCSI Bus Reset Semantics.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5367) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5368) * Return code :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5369) * 0x2003 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5370) * 0x2002 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5371) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5372) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5373) lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5374) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5375) struct Scsi_Host *shost = cmnd->device->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5376) struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5377) struct lpfc_nodelist *ndlp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5378) struct lpfc_scsi_event_header scsi_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5379) int match;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5380) int ret = SUCCESS, status, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5382) scsi_event.event_type = FC_REG_SCSI_EVENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5383) scsi_event.subcategory = LPFC_EVENT_BUSRESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5384) scsi_event.lun = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5385) memcpy(scsi_event.wwpn, &vport->fc_portname, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5386) memcpy(scsi_event.wwnn, &vport->fc_nodename, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5388) fc_host_post_vendor_event(shost, fc_get_event_number(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5389) sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5391) status = fc_block_scsi_eh(cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5392) if (status != 0 && status != SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5393) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5395) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5396) * Since the driver manages a single bus device, reset all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5397) * targets known to the driver. Should any target reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5398) * fail, this routine returns failure to the midlayer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5399) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5400) for (i = 0; i < LPFC_MAX_TARGET; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5401) /* Search for mapped node by target ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5402) match = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5403) spin_lock_irq(shost->host_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5404) list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5405) if (!NLP_CHK_NODE_ACT(ndlp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5406) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5407) if (vport->phba->cfg_fcp2_no_tgt_reset &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5408) (ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5409) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5410) if (ndlp->nlp_state == NLP_STE_MAPPED_NODE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5411) ndlp->nlp_sid == i &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5412) ndlp->rport &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5413) ndlp->nlp_type & NLP_FCP_TARGET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5414) match = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5415) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5418) spin_unlock_irq(shost->host_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5419) if (!match)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5420) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5422) status = lpfc_send_taskmgmt(vport, cmnd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5423) i, 0, FCP_TARGET_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5425) if (status != SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5426) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5427) "0700 Bus Reset on target %d failed\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5428) i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5429) ret = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5432) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5433) * We have to clean up i/o as : they may be orphaned by the TMFs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5434) * above; or if any of the TMFs failed, they may be in an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5435) * indeterminate state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5436) * We will report success if all the i/o aborts successfully.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5437) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5439) status = lpfc_reset_flush_io_context(vport, 0, 0, LPFC_CTX_HOST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5440) if (status != SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5441) ret = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5443) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5444) "0714 SCSI layer issued Bus Reset Data: x%x\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5445) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5448) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5449) * lpfc_host_reset_handler - scsi_host_template eh_host_reset_handler entry pt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5450) * @cmnd: Pointer to scsi_cmnd data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5451) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5452) * This routine does host reset to the adaptor port. It brings the HBA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5453) * offline, performs a board restart, and then brings the board back online.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5454) * The lpfc_offline calls lpfc_sli_hba_down which will abort and local
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5455) * reject all outstanding SCSI commands to the host and error returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5456) * back to SCSI mid-level. As this will be SCSI mid-level's last resort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5457) * of error handling, it will only return error if resetting of the adapter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5458) * is not successful; in all other cases, will return success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5459) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5460) * Return code :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5461) * 0x2003 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5462) * 0x2002 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5463) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5464) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5465) lpfc_host_reset_handler(struct scsi_cmnd *cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5467) struct Scsi_Host *shost = cmnd->device->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5468) struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5469) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5470) int rc, ret = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5472) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5473) "3172 SCSI layer issued Host Reset Data:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5475) lpfc_offline_prep(phba, LPFC_MBX_WAIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5476) lpfc_offline(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5477) rc = lpfc_sli_brdrestart(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5478) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5479) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5481) rc = lpfc_online(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5482) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5483) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5485) lpfc_unblock_mgmt_io(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5487) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5488) error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5489) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5490) "3323 Failed host reset\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5491) lpfc_unblock_mgmt_io(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5492) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5495) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5496) * lpfc_slave_alloc - scsi_host_template slave_alloc entry point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5497) * @sdev: Pointer to scsi_device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5498) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5499) * This routine populates the cmds_per_lun count + 2 scsi_bufs into this host's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5500) * globally available list of scsi buffers. This routine also makes sure scsi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5501) * buffer is not allocated more than HBA limit conveyed to midlayer. This list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5502) * of scsi buffer exists for the lifetime of the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5503) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5504) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5505) * non-0 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5506) * 0 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5507) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5508) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5509) lpfc_slave_alloc(struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5510) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5511) struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5512) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5513) struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5514) uint32_t total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5515) uint32_t num_to_alloc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5516) int num_allocated = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5517) uint32_t sdev_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5518) struct lpfc_device_data *device_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5519) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5520) struct lpfc_name target_wwpn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5522) if (!rport || fc_remote_port_chkready(rport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5523) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5525) if (phba->cfg_fof) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5527) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5528) * Check to see if the device data structure for the lun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5529) * exists. If not, create one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5530) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5532) u64_to_wwn(rport->port_name, target_wwpn.u.wwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5533) spin_lock_irqsave(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5534) device_data = __lpfc_get_device_data(phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5535) &phba->luns,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5536) &vport->fc_portname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5537) &target_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5538) sdev->lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5539) if (!device_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5540) spin_unlock_irqrestore(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5541) device_data = lpfc_create_device_data(phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5542) &vport->fc_portname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5543) &target_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5544) sdev->lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5545) phba->cfg_XLanePriority,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5546) true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5547) if (!device_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5548) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5549) spin_lock_irqsave(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5550) list_add_tail(&device_data->listentry, &phba->luns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5551) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5552) device_data->rport_data = rport->dd_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5553) device_data->available = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5554) spin_unlock_irqrestore(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5555) sdev->hostdata = device_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5556) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5557) sdev->hostdata = rport->dd_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5558) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5559) sdev_cnt = atomic_inc_return(&phba->sdev_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5561) /* For SLI4, all IO buffers are pre-allocated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5562) if (phba->sli_rev == LPFC_SLI_REV4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5563) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5565) /* This code path is now ONLY for SLI3 adapters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5567) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5568) * Populate the cmds_per_lun count scsi_bufs into this host's globally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5569) * available list of scsi buffers. Don't allocate more than the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5570) * HBA limit conveyed to the midlayer via the host structure. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5571) * formula accounts for the lun_queue_depth + error handlers + 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5572) * extra. This list of scsi bufs exists for the lifetime of the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5573) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5574) total = phba->total_scsi_bufs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5575) num_to_alloc = vport->cfg_lun_queue_depth + 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5577) /* If allocated buffers are enough do nothing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5578) if ((sdev_cnt * (vport->cfg_lun_queue_depth + 2)) < total)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5579) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5581) /* Allow some exchanges to be available always to complete discovery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5582) if (total >= phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5583) lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5584) "0704 At limitation of %d preallocated "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5585) "command buffers\n", total);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5586) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5587) /* Allow some exchanges to be available always to complete discovery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5588) } else if (total + num_to_alloc >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5589) phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5590) lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5591) "0705 Allocation request of %d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5592) "command buffers will exceed max of %d. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5593) "Reducing allocation request to %d.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5594) num_to_alloc, phba->cfg_hba_queue_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5595) (phba->cfg_hba_queue_depth - total));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5596) num_to_alloc = phba->cfg_hba_queue_depth - total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5597) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5598) num_allocated = lpfc_new_scsi_buf_s3(vport, num_to_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5599) if (num_to_alloc != num_allocated) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5600) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5601) "0708 Allocation request of %d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5602) "command buffers did not succeed. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5603) "Allocated %d buffers.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5604) num_to_alloc, num_allocated);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5605) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5606) if (num_allocated > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5607) phba->total_scsi_bufs += num_allocated;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5608) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5609) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5611) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5612) * lpfc_slave_configure - scsi_host_template slave_configure entry point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5613) * @sdev: Pointer to scsi_device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5614) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5615) * This routine configures following items
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5616) * - Tag command queuing support for @sdev if supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5617) * - Enable SLI polling for fcp ring if ENABLE_FCP_RING_POLLING flag is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5618) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5619) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5620) * 0 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5621) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5622) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5623) lpfc_slave_configure(struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5624) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5625) struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5626) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5628) scsi_change_queue_depth(sdev, vport->cfg_lun_queue_depth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5630) if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5631) lpfc_sli_handle_fast_ring_event(phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5632) &phba->sli.sli3_ring[LPFC_FCP_RING], HA_R0RE_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5633) if (phba->cfg_poll & DISABLE_FCP_RING_INT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5634) lpfc_poll_rearm_timer(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5635) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5637) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5640) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5641) * lpfc_slave_destroy - slave_destroy entry point of SHT data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5642) * @sdev: Pointer to scsi_device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5643) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5644) * This routine sets @sdev hostatdata filed to null.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5645) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5646) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5647) lpfc_slave_destroy(struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5648) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5649) struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5650) struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5651) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5652) struct lpfc_device_data *device_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5654) atomic_dec(&phba->sdev_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5655) if ((phba->cfg_fof) && (device_data)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5656) spin_lock_irqsave(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5657) device_data->available = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5658) if (!device_data->oas_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5659) lpfc_delete_device_data(phba, device_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5660) spin_unlock_irqrestore(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5662) sdev->hostdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5663) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5664) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5666) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5667) * lpfc_create_device_data - creates and initializes device data structure for OAS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5668) * @pha: Pointer to host bus adapter structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5669) * @vport_wwpn: Pointer to vport's wwpn information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5670) * @target_wwpn: Pointer to target's wwpn information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5671) * @lun: Lun on target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5672) * @atomic_create: Flag to indicate if memory should be allocated using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5673) * GFP_ATOMIC flag or not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5674) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5675) * This routine creates a device data structure which will contain identifying
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5676) * information for the device (host wwpn, target wwpn, lun), state of OAS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5677) * whether or not the corresponding lun is available by the system,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5678) * and pointer to the rport data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5679) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5680) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5681) * NULL - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5682) * Pointer to lpfc_device_data - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5683) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5684) struct lpfc_device_data*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5685) lpfc_create_device_data(struct lpfc_hba *phba, struct lpfc_name *vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5686) struct lpfc_name *target_wwpn, uint64_t lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5687) uint32_t pri, bool atomic_create)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5688) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5689)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5690) struct lpfc_device_data *lun_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5691) int memory_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5693) if (unlikely(!phba) || !vport_wwpn || !target_wwpn ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5694) !(phba->cfg_fof))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5695) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5697) /* Attempt to create the device data to contain lun info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5699) if (atomic_create)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5700) memory_flags = GFP_ATOMIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5701) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5702) memory_flags = GFP_KERNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5703) lun_info = mempool_alloc(phba->device_data_mem_pool, memory_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5704) if (!lun_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5705) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5706) INIT_LIST_HEAD(&lun_info->listentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5707) lun_info->rport_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5708) memcpy(&lun_info->device_id.vport_wwpn, vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5709) sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5710) memcpy(&lun_info->device_id.target_wwpn, target_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5711) sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5712) lun_info->device_id.lun = lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5713) lun_info->oas_enabled = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5714) lun_info->priority = pri;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5715) lun_info->available = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5716) return lun_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5717) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5719) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5720) * lpfc_delete_device_data - frees a device data structure for OAS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5721) * @pha: Pointer to host bus adapter structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5722) * @lun_info: Pointer to device data structure to free.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5723) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5724) * This routine frees the previously allocated device data structure passed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5725) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5726) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5727) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5728) lpfc_delete_device_data(struct lpfc_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5729) struct lpfc_device_data *lun_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5730) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5731)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5732) if (unlikely(!phba) || !lun_info ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5733) !(phba->cfg_fof))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5734) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5736) if (!list_empty(&lun_info->listentry))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5737) list_del(&lun_info->listentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5738) mempool_free(lun_info, phba->device_data_mem_pool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5739) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5740) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5742) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5743) * __lpfc_get_device_data - returns the device data for the specified lun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5744) * @pha: Pointer to host bus adapter structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5745) * @list: Point to list to search.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5746) * @vport_wwpn: Pointer to vport's wwpn information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5747) * @target_wwpn: Pointer to target's wwpn information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5748) * @lun: Lun on target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5749) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5750) * This routine searches the list passed for the specified lun's device data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5751) * This function does not hold locks, it is the responsibility of the caller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5752) * to ensure the proper lock is held before calling the function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5753) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5754) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5755) * NULL - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5756) * Pointer to lpfc_device_data - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5757) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5758) struct lpfc_device_data*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5759) __lpfc_get_device_data(struct lpfc_hba *phba, struct list_head *list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5760) struct lpfc_name *vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5761) struct lpfc_name *target_wwpn, uint64_t lun)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5762) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5764) struct lpfc_device_data *lun_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5766) if (unlikely(!phba) || !list || !vport_wwpn || !target_wwpn ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5767) !phba->cfg_fof)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5768) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5770) /* Check to see if the lun is already enabled for OAS. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5772) list_for_each_entry(lun_info, list, listentry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5773) if ((memcmp(&lun_info->device_id.vport_wwpn, vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5774) sizeof(struct lpfc_name)) == 0) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5775) (memcmp(&lun_info->device_id.target_wwpn, target_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5776) sizeof(struct lpfc_name)) == 0) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5777) (lun_info->device_id.lun == lun))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5778) return lun_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5781) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5782) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5784) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5785) * lpfc_find_next_oas_lun - searches for the next oas lun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5786) * @pha: Pointer to host bus adapter structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5787) * @vport_wwpn: Pointer to vport's wwpn information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5788) * @target_wwpn: Pointer to target's wwpn information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5789) * @starting_lun: Pointer to the lun to start searching for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5790) * @found_vport_wwpn: Pointer to the found lun's vport wwpn information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5791) * @found_target_wwpn: Pointer to the found lun's target wwpn information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5792) * @found_lun: Pointer to the found lun.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5793) * @found_lun_status: Pointer to status of the found lun.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5794) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5795) * This routine searches the luns list for the specified lun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5796) * or the first lun for the vport/target. If the vport wwpn contains
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5797) * a zero value then a specific vport is not specified. In this case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5798) * any vport which contains the lun will be considered a match. If the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5799) * target wwpn contains a zero value then a specific target is not specified.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5800) * In this case any target which contains the lun will be considered a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5801) * match. If the lun is found, the lun, vport wwpn, target wwpn and lun status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5802) * are returned. The function will also return the next lun if available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5803) * If the next lun is not found, starting_lun parameter will be set to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5804) * NO_MORE_OAS_LUN.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5805) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5806) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5807) * non-0 - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5808) * 0 - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5809) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5810) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5811) lpfc_find_next_oas_lun(struct lpfc_hba *phba, struct lpfc_name *vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5812) struct lpfc_name *target_wwpn, uint64_t *starting_lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5813) struct lpfc_name *found_vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5814) struct lpfc_name *found_target_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5815) uint64_t *found_lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5816) uint32_t *found_lun_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5817) uint32_t *found_lun_pri)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5818) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5820) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5821) struct lpfc_device_data *lun_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5822) struct lpfc_device_id *device_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5823) uint64_t lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5824) bool found = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5826) if (unlikely(!phba) || !vport_wwpn || !target_wwpn ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5827) !starting_lun || !found_vport_wwpn ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5828) !found_target_wwpn || !found_lun || !found_lun_status ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5829) (*starting_lun == NO_MORE_OAS_LUN) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5830) !phba->cfg_fof)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5831) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5833) lun = *starting_lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5834) *found_lun = NO_MORE_OAS_LUN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5835) *starting_lun = NO_MORE_OAS_LUN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5837) /* Search for lun or the lun closet in value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5839) spin_lock_irqsave(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5840) list_for_each_entry(lun_info, &phba->luns, listentry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5841) if (((wwn_to_u64(vport_wwpn->u.wwn) == 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5842) (memcmp(&lun_info->device_id.vport_wwpn, vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5843) sizeof(struct lpfc_name)) == 0)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5844) ((wwn_to_u64(target_wwpn->u.wwn) == 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5845) (memcmp(&lun_info->device_id.target_wwpn, target_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5846) sizeof(struct lpfc_name)) == 0)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5847) (lun_info->oas_enabled)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5848) device_id = &lun_info->device_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5849) if ((!found) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5850) ((lun == FIND_FIRST_OAS_LUN) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5851) (device_id->lun == lun))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5852) *found_lun = device_id->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5853) memcpy(found_vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5854) &device_id->vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5855) sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5856) memcpy(found_target_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5857) &device_id->target_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5858) sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5859) if (lun_info->available)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5860) *found_lun_status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5861) OAS_LUN_STATUS_EXISTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5862) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5863) *found_lun_status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5864) *found_lun_pri = lun_info->priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5865) if (phba->cfg_oas_flags & OAS_FIND_ANY_VPORT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5866) memset(vport_wwpn, 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5867) sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5868) if (phba->cfg_oas_flags & OAS_FIND_ANY_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5869) memset(target_wwpn, 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5870) sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5871) found = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5872) } else if (found) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5873) *starting_lun = device_id->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5874) memcpy(vport_wwpn, &device_id->vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5875) sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5876) memcpy(target_wwpn, &device_id->target_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5877) sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5878) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5879) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5880) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5881) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5882) spin_unlock_irqrestore(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5883) return found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5884) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5886) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5887) * lpfc_enable_oas_lun - enables a lun for OAS operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5888) * @pha: Pointer to host bus adapter structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5889) * @vport_wwpn: Pointer to vport's wwpn information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5890) * @target_wwpn: Pointer to target's wwpn information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5891) * @lun: Lun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5892) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5893) * This routine enables a lun for oas operations. The routines does so by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5894) * doing the following :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5895) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5896) * 1) Checks to see if the device data for the lun has been created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5897) * 2) If found, sets the OAS enabled flag if not set and returns.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5898) * 3) Otherwise, creates a device data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5899) * 4) If successfully created, indicates the device data is for an OAS lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5900) * indicates the lun is not available and add to the list of luns.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5901) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5902) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5903) * false - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5904) * true - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5905) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5906) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5907) lpfc_enable_oas_lun(struct lpfc_hba *phba, struct lpfc_name *vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5908) struct lpfc_name *target_wwpn, uint64_t lun, uint8_t pri)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5909) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5911) struct lpfc_device_data *lun_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5912) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5914) if (unlikely(!phba) || !vport_wwpn || !target_wwpn ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5915) !phba->cfg_fof)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5916) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5918) spin_lock_irqsave(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5920) /* Check to see if the device data for the lun has been created */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5921) lun_info = __lpfc_get_device_data(phba, &phba->luns, vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5922) target_wwpn, lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5923) if (lun_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5924) if (!lun_info->oas_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5925) lun_info->oas_enabled = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5926) lun_info->priority = pri;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5927) spin_unlock_irqrestore(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5928) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5929) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5931) /* Create an lun info structure and add to list of luns */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5932) lun_info = lpfc_create_device_data(phba, vport_wwpn, target_wwpn, lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5933) pri, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5934) if (lun_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5935) lun_info->oas_enabled = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5936) lun_info->priority = pri;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5937) lun_info->available = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5938) list_add_tail(&lun_info->listentry, &phba->luns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5939) spin_unlock_irqrestore(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5940) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5941) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5942) spin_unlock_irqrestore(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5943) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5944) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5945)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5946) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5947) * lpfc_disable_oas_lun - disables a lun for OAS operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5948) * @pha: Pointer to host bus adapter structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5949) * @vport_wwpn: Pointer to vport's wwpn information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5950) * @target_wwpn: Pointer to target's wwpn information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5951) * @lun: Lun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5952) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5953) * This routine disables a lun for oas operations. The routines does so by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5954) * doing the following :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5955) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5956) * 1) Checks to see if the device data for the lun is created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5957) * 2) If present, clears the flag indicating this lun is for OAS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5958) * 3) If the lun is not available by the system, the device data is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5959) * freed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5960) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5961) * Return codes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5962) * false - Error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5963) * true - Success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5964) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5965) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5966) lpfc_disable_oas_lun(struct lpfc_hba *phba, struct lpfc_name *vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5967) struct lpfc_name *target_wwpn, uint64_t lun, uint8_t pri)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5968) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5970) struct lpfc_device_data *lun_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5971) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5973) if (unlikely(!phba) || !vport_wwpn || !target_wwpn ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5974) !phba->cfg_fof)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5975) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5977) spin_lock_irqsave(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5979) /* Check to see if the lun is available. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5980) lun_info = __lpfc_get_device_data(phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5981) &phba->luns, vport_wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5982) target_wwpn, lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5983) if (lun_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5984) lun_info->oas_enabled = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5985) lun_info->priority = pri;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5986) if (!lun_info->available)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5987) lpfc_delete_device_data(phba, lun_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5988) spin_unlock_irqrestore(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5989) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5990) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5992) spin_unlock_irqrestore(&phba->devicelock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5993) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5994) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5996) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5997) lpfc_no_command(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5998) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5999) return SCSI_MLQUEUE_HOST_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6000) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6002) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6003) lpfc_no_handler(struct scsi_cmnd *cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6004) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6005) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6006) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6008) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6009) lpfc_no_slave(struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6010) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6011) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6012) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6014) struct scsi_host_template lpfc_template_nvme = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6015) .module = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6016) .name = LPFC_DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6017) .proc_name = LPFC_DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6018) .info = lpfc_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6019) .queuecommand = lpfc_no_command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6020) .eh_abort_handler = lpfc_no_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6021) .eh_device_reset_handler = lpfc_no_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6022) .eh_target_reset_handler = lpfc_no_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6023) .eh_bus_reset_handler = lpfc_no_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6024) .eh_host_reset_handler = lpfc_no_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6025) .slave_alloc = lpfc_no_slave,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6026) .slave_configure = lpfc_no_slave,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6027) .scan_finished = lpfc_scan_finished,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6028) .this_id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6029) .sg_tablesize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6030) .cmd_per_lun = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6031) .shost_attrs = lpfc_hba_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6032) .max_sectors = 0xFFFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6033) .vendor_id = LPFC_NL_VENDOR_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6034) .track_queue_depth = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6035) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6036)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6037) struct scsi_host_template lpfc_template = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6038) .module = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6039) .name = LPFC_DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6040) .proc_name = LPFC_DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6041) .info = lpfc_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6042) .queuecommand = lpfc_queuecommand,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6043) .eh_timed_out = fc_eh_timed_out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6044) .eh_abort_handler = lpfc_abort_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6045) .eh_device_reset_handler = lpfc_device_reset_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6046) .eh_target_reset_handler = lpfc_target_reset_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6047) .eh_bus_reset_handler = lpfc_bus_reset_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6048) .eh_host_reset_handler = lpfc_host_reset_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6049) .slave_alloc = lpfc_slave_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6050) .slave_configure = lpfc_slave_configure,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6051) .slave_destroy = lpfc_slave_destroy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6052) .scan_finished = lpfc_scan_finished,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6053) .this_id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6054) .sg_tablesize = LPFC_DEFAULT_SG_SEG_CNT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6055) .cmd_per_lun = LPFC_CMD_PER_LUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6056) .shost_attrs = lpfc_hba_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6057) .max_sectors = 0xFFFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6058) .vendor_id = LPFC_NL_VENDOR_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6059) .change_queue_depth = scsi_change_queue_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6060) .track_queue_depth = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6061) };