^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * zfcp device driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Implementation of FSF commands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright IBM Corp. 2002, 2020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define KMSG_COMPONENT "zfcp"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/blktrace_api.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/jiffies.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <scsi/fc/fc_els.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "zfcp_ext.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "zfcp_fc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include "zfcp_dbf.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "zfcp_qdio.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include "zfcp_reqlist.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include "zfcp_diag.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) /* timeout for FSF requests sent during scsi_eh: abort or FCP TMF */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define ZFCP_FSF_SCSI_ER_TIMEOUT (10*HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /* timeout for: exchange config/port data outside ERP, or open/close WKA port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct kmem_cache *zfcp_fsf_qtcb_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static bool ber_stop = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) module_param(ber_stop, bool, 0600);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) MODULE_PARM_DESC(ber_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) "Shuts down FCP devices for FCP channels that report a bit-error count in excess of its threshold (default on)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static void zfcp_fsf_request_timeout_handler(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct zfcp_fsf_req *fsf_req = from_timer(fsf_req, t, timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct zfcp_adapter *adapter = fsf_req->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) zfcp_qdio_siosl(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) "fsrth_1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static void zfcp_fsf_start_timer(struct zfcp_fsf_req *fsf_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) unsigned long timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) fsf_req->timer.function = zfcp_fsf_request_timeout_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) fsf_req->timer.expires = jiffies + timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) add_timer(&fsf_req->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static void zfcp_fsf_start_erp_timer(struct zfcp_fsf_req *fsf_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) BUG_ON(!fsf_req->erp_action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) fsf_req->timer.function = zfcp_erp_timeout_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) fsf_req->timer.expires = jiffies + 30 * HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) add_timer(&fsf_req->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* association between FSF command and FSF QTCB type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static u32 fsf_qtcb_type[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) [FSF_QTCB_FCP_CMND] = FSF_IO_COMMAND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) [FSF_QTCB_ABORT_FCP_CMND] = FSF_SUPPORT_COMMAND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) [FSF_QTCB_OPEN_PORT_WITH_DID] = FSF_SUPPORT_COMMAND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) [FSF_QTCB_OPEN_LUN] = FSF_SUPPORT_COMMAND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) [FSF_QTCB_CLOSE_LUN] = FSF_SUPPORT_COMMAND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) [FSF_QTCB_CLOSE_PORT] = FSF_SUPPORT_COMMAND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) [FSF_QTCB_CLOSE_PHYSICAL_PORT] = FSF_SUPPORT_COMMAND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) [FSF_QTCB_SEND_ELS] = FSF_SUPPORT_COMMAND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) [FSF_QTCB_SEND_GENERIC] = FSF_SUPPORT_COMMAND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) [FSF_QTCB_EXCHANGE_CONFIG_DATA] = FSF_CONFIG_COMMAND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) [FSF_QTCB_EXCHANGE_PORT_DATA] = FSF_PORT_COMMAND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) [FSF_QTCB_DOWNLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) [FSF_QTCB_UPLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) static void zfcp_fsf_class_not_supp(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) dev_err(&req->adapter->ccw_device->dev, "FCP device not "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) "operational because of an unsupported FC class\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) zfcp_erp_adapter_shutdown(req->adapter, 0, "fscns_1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * zfcp_fsf_req_free - free memory used by fsf request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * @req: pointer to struct zfcp_fsf_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) void zfcp_fsf_req_free(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if (likely(req->pool)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (likely(!zfcp_fsf_req_is_status_read_buffer(req)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) mempool_free(req->qtcb, req->adapter->pool.qtcb_pool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) mempool_free(req, req->pool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if (likely(!zfcp_fsf_req_is_status_read_buffer(req)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) kmem_cache_free(zfcp_fsf_qtcb_cache, req->qtcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) kfree(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static void zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct fsf_status_read_buffer *sr_buf = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct zfcp_adapter *adapter = req->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct zfcp_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) int d_id = ntoh24(sr_buf->d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) read_lock_irqsave(&adapter->port_list_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) list_for_each_entry(port, &adapter->port_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) if (port->d_id == d_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) zfcp_erp_port_reopen(port, 0, "fssrpc1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) read_unlock_irqrestore(&adapter->port_list_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) void zfcp_fsf_fc_host_link_down(struct zfcp_adapter *adapter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct Scsi_Host *shost = adapter->scsi_host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) adapter->hydra_version = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) adapter->peer_wwpn = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) adapter->peer_wwnn = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) adapter->peer_d_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /* if there is no shost yet, we have nothing to zero-out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) if (shost == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) fc_host_port_id(shost) = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) fc_host_fabric_name(shost) = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) snprintf(fc_host_model(shost), FC_SYMBOLIC_NAME_SIZE, "0x%04x", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) memset(fc_host_active_fc4s(shost), 0, FC_FC4_LIST_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct fsf_link_down_info *link_down)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct zfcp_adapter *adapter = req->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) if (atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) atomic_or(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) zfcp_scsi_schedule_rports_block(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) zfcp_fsf_fc_host_link_down(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) if (!link_down)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) switch (link_down->error_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) case FSF_PSQ_LINK_NO_LIGHT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) "There is no light signal from the local "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) "fibre channel cable\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) case FSF_PSQ_LINK_WRAP_PLUG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) "There is a wrap plug instead of a fibre "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) "channel cable\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) case FSF_PSQ_LINK_NO_FCP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) "The adjacent fibre channel node does not "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) "support FCP\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) case FSF_PSQ_LINK_FIRMWARE_UPDATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) "The FCP device is suspended because of a "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) "firmware update\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) case FSF_PSQ_LINK_INVALID_WWPN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) "The FCP device detected a WWPN that is "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) "duplicate or not valid\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) case FSF_PSQ_LINK_NO_NPIV_SUPPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) "The fibre channel fabric does not support NPIV\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) case FSF_PSQ_LINK_NO_FCP_RESOURCES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) "The FCP adapter cannot support more NPIV ports\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) case FSF_PSQ_LINK_NO_FABRIC_RESOURCES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) "The adjacent switch cannot support "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) "more NPIV ports\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) case FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) "The FCP adapter could not log in to the "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) "fibre channel fabric\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) case FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) "The WWPN assignment file on the FCP adapter "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) "has been damaged\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) case FSF_PSQ_LINK_MODE_TABLE_CURRUPTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) "The mode table on the FCP adapter "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) "has been damaged\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) case FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) "All NPIV ports on the FCP adapter have "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) "been assigned\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) "The link between the FCP adapter and "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) "the FC fabric is down\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) zfcp_erp_set_adapter_status(adapter, ZFCP_STATUS_COMMON_ERP_FAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) static void zfcp_fsf_status_read_link_down(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct fsf_status_read_buffer *sr_buf = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) struct fsf_link_down_info *ldi =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) (struct fsf_link_down_info *) &sr_buf->payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) switch (sr_buf->status_subtype) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) case FSF_STATUS_READ_SUB_FDISC_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) zfcp_fsf_link_down_info_eval(req, ldi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) zfcp_fsf_link_down_info_eval(req, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static void zfcp_fsf_status_read_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) struct zfcp_adapter *adapter = req->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) struct fsf_status_read_buffer *sr_buf = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) if (req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) zfcp_dbf_hba_fsf_uss("fssrh_1", req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) mempool_free(virt_to_page(sr_buf), adapter->pool.sr_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) zfcp_dbf_hba_fsf_uss("fssrh_4", req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) switch (sr_buf->status_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) case FSF_STATUS_READ_PORT_CLOSED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) zfcp_fsf_status_read_port_closed(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) case FSF_STATUS_READ_INCOMING_ELS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) zfcp_fc_incoming_els(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) case FSF_STATUS_READ_SENSE_DATA_AVAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) case FSF_STATUS_READ_BIT_ERROR_THRESHOLD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) zfcp_dbf_hba_bit_err("fssrh_3", req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) if (ber_stop) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) dev_warn(&adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) "All paths over this FCP device are disused because of excessive bit errors\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) zfcp_erp_adapter_shutdown(adapter, 0, "fssrh_b");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) dev_warn(&adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) "The error threshold for checksum statistics has been exceeded\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) case FSF_STATUS_READ_LINK_DOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) zfcp_fsf_status_read_link_down(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) zfcp_fc_enqueue_event(adapter, FCH_EVT_LINKDOWN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) case FSF_STATUS_READ_LINK_UP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) dev_info(&adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) "The local link has been restored\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) /* All ports should be marked as ready to run again */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) zfcp_erp_set_adapter_status(adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) ZFCP_STATUS_COMMON_RUNNING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) zfcp_erp_adapter_reopen(adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) ZFCP_STATUS_COMMON_ERP_FAILED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) "fssrh_2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) zfcp_fc_enqueue_event(adapter, FCH_EVT_LINKUP, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) case FSF_STATUS_READ_NOTIFICATION_LOST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_INCOMING_ELS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) zfcp_fc_conditional_port_scan(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) case FSF_STATUS_READ_FEATURE_UPDATE_ALERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) adapter->adapter_features = sr_buf->payload.word[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) mempool_free(virt_to_page(sr_buf), adapter->pool.sr_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) atomic_inc(&adapter->stat_miss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) queue_work(adapter->work_queue, &adapter->stat_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) static void zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) switch (req->qtcb->header.fsf_status_qual.word[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) case FSF_SQ_FCP_RSP_AVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) case FSF_SQ_NO_RETRY_POSSIBLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) case FSF_SQ_COMMAND_ABORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) case FSF_SQ_NO_RECOM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) dev_err(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) "The FCP adapter reported a problem "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) "that cannot be recovered\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) zfcp_qdio_siosl(req->adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfsqe1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) /* all non-return stats set FSFREQ_ERROR*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) static void zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) switch (req->qtcb->header.fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) case FSF_UNKNOWN_COMMAND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) dev_err(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) "The FCP adapter does not recognize the command 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) req->qtcb->header.fsf_command);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfse_1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) case FSF_ADAPTER_STATUS_AVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) zfcp_fsf_fsfstatus_qual_eval(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) static void zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) struct zfcp_adapter *adapter = req->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) struct fsf_qtcb *qtcb = req->qtcb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) union fsf_prot_status_qual *psq = &qtcb->prefix.prot_status_qual;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) zfcp_dbf_hba_fsf_response(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) if (req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) switch (qtcb->prefix.prot_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) case FSF_PROT_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) case FSF_PROT_FSF_STATUS_PRESENTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) case FSF_PROT_QTCB_VERSION_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) dev_err(&adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) "QTCB version 0x%x not supported by FCP adapter "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) "(0x%x to 0x%x)\n", FSF_QTCB_CURRENT_VERSION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) psq->word[0], psq->word[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) zfcp_erp_adapter_shutdown(adapter, 0, "fspse_1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) case FSF_PROT_ERROR_STATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) case FSF_PROT_SEQ_NUMB_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) zfcp_erp_adapter_reopen(adapter, 0, "fspse_2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) case FSF_PROT_UNSUPP_QTCB_TYPE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) dev_err(&adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) "The QTCB type is not supported by the FCP adapter\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) zfcp_erp_adapter_shutdown(adapter, 0, "fspse_3");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) case FSF_PROT_HOST_CONNECTION_INITIALIZING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) atomic_or(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) &adapter->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) case FSF_PROT_DUPLICATE_REQUEST_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) dev_err(&adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) "0x%Lx is an ambiguous request identifier\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) (unsigned long long)qtcb->bottom.support.req_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) zfcp_erp_adapter_shutdown(adapter, 0, "fspse_4");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) case FSF_PROT_LINK_DOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) zfcp_fsf_link_down_info_eval(req, &psq->link_down_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) /* go through reopen to flush pending requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) zfcp_erp_adapter_reopen(adapter, 0, "fspse_6");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) case FSF_PROT_REEST_QUEUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) /* All ports should be marked as ready to run again */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) zfcp_erp_set_adapter_status(adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) ZFCP_STATUS_COMMON_RUNNING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) zfcp_erp_adapter_reopen(adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) ZFCP_STATUS_COMMON_ERP_FAILED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) "fspse_8");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) dev_err(&adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) "0x%x is not a valid transfer protocol status\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) qtcb->prefix.prot_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) zfcp_qdio_siosl(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) zfcp_erp_adapter_shutdown(adapter, 0, "fspse_9");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) * zfcp_fsf_req_complete - process completion of a FSF request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) * @req: The FSF request that has been completed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) * When a request has been completed either from the FCP adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) * or it has been dismissed due to a queue shutdown, this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) * is called to process the completion status and trigger further
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) * events related to the FSF request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) * Caller must ensure that the request has been removed from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) * adapter->req_list, to protect against concurrent modification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) * by zfcp_erp_strategy_check_fsfreq().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) static void zfcp_fsf_req_complete(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) struct zfcp_erp_action *erp_action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) if (unlikely(zfcp_fsf_req_is_status_read_buffer(req))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) zfcp_fsf_status_read_handler(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) del_timer_sync(&req->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) zfcp_fsf_protstatus_eval(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) zfcp_fsf_fsfstatus_eval(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) req->handler(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) erp_action = req->erp_action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) if (erp_action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) zfcp_erp_notify(erp_action, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) if (likely(req->status & ZFCP_STATUS_FSFREQ_CLEANUP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) complete(&req->completion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) }
^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) * zfcp_fsf_req_dismiss_all - dismiss all fsf requests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) * @adapter: pointer to struct zfcp_adapter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) * Never ever call this without shutting down the adapter first.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) * Otherwise the adapter would continue using and corrupting s390 storage.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) * Included BUG_ON() call to ensure this is done.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) * ERP is supposed to be the only user of this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) struct zfcp_fsf_req *req, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) LIST_HEAD(remove_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) BUG_ON(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) zfcp_reqlist_move(adapter->req_list, &remove_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) list_for_each_entry_safe(req, tmp, &remove_queue, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) list_del(&req->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) zfcp_fsf_req_complete(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) #define ZFCP_FSF_PORTSPEED_1GBIT (1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) #define ZFCP_FSF_PORTSPEED_2GBIT (1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) #define ZFCP_FSF_PORTSPEED_4GBIT (1 << 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) #define ZFCP_FSF_PORTSPEED_10GBIT (1 << 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) #define ZFCP_FSF_PORTSPEED_8GBIT (1 << 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) #define ZFCP_FSF_PORTSPEED_16GBIT (1 << 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) #define ZFCP_FSF_PORTSPEED_32GBIT (1 << 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) #define ZFCP_FSF_PORTSPEED_64GBIT (1 << 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) #define ZFCP_FSF_PORTSPEED_128GBIT (1 << 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) #define ZFCP_FSF_PORTSPEED_NOT_NEGOTIATED (1 << 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) u32 zfcp_fsf_convert_portspeed(u32 fsf_speed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) u32 fdmi_speed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) if (fsf_speed & ZFCP_FSF_PORTSPEED_1GBIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) fdmi_speed |= FC_PORTSPEED_1GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) if (fsf_speed & ZFCP_FSF_PORTSPEED_2GBIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) fdmi_speed |= FC_PORTSPEED_2GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) if (fsf_speed & ZFCP_FSF_PORTSPEED_4GBIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) fdmi_speed |= FC_PORTSPEED_4GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) if (fsf_speed & ZFCP_FSF_PORTSPEED_10GBIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) fdmi_speed |= FC_PORTSPEED_10GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) if (fsf_speed & ZFCP_FSF_PORTSPEED_8GBIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) fdmi_speed |= FC_PORTSPEED_8GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) if (fsf_speed & ZFCP_FSF_PORTSPEED_16GBIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) fdmi_speed |= FC_PORTSPEED_16GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) if (fsf_speed & ZFCP_FSF_PORTSPEED_32GBIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) fdmi_speed |= FC_PORTSPEED_32GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) if (fsf_speed & ZFCP_FSF_PORTSPEED_64GBIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) fdmi_speed |= FC_PORTSPEED_64GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) if (fsf_speed & ZFCP_FSF_PORTSPEED_128GBIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) fdmi_speed |= FC_PORTSPEED_128GBIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) if (fsf_speed & ZFCP_FSF_PORTSPEED_NOT_NEGOTIATED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) fdmi_speed |= FC_PORTSPEED_NOT_NEGOTIATED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) return fdmi_speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) struct fsf_qtcb_bottom_config *bottom = &req->qtcb->bottom.config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) struct zfcp_adapter *adapter = req->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) struct fc_els_flogi *plogi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) /* adjust pointers for missing command code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) plogi = (struct fc_els_flogi *) ((u8 *)&bottom->plogi_payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) - sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) if (req->data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) memcpy(req->data, bottom, sizeof(*bottom));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) adapter->timer_ticks = bottom->timer_interval & ZFCP_FSF_TIMER_INT_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) adapter->stat_read_buf_num = max(bottom->status_read_buf_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) (u16)FSF_STATUS_READS_RECOM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) /* no error return above here, otherwise must fix call chains */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) /* do not evaluate invalid fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) if (req->qtcb->header.fsf_status == FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) adapter->hydra_version = bottom->adapter_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) switch (bottom->fc_topology) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) case FSF_TOPO_P2P:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) adapter->peer_d_id = ntoh24(bottom->peer_d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) adapter->peer_wwpn = be64_to_cpu(plogi->fl_wwpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) adapter->peer_wwnn = be64_to_cpu(plogi->fl_wwnn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) case FSF_TOPO_FABRIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) case FSF_TOPO_AL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) dev_err(&adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) "Unknown or unsupported arbitrated loop "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) "fibre channel topology detected\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) zfcp_erp_adapter_shutdown(adapter, 0, "fsece_1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) return -EIO;
^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) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) static void zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) struct zfcp_adapter *adapter = req->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) struct zfcp_diag_header *const diag_hdr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) &adapter->diagnostics->config_data.header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) struct fsf_qtcb *qtcb = req->qtcb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) struct fsf_qtcb_bottom_config *bottom = &qtcb->bottom.config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) adapter->fsf_lic_version = bottom->lic_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) adapter->adapter_features = bottom->adapter_features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) adapter->connection_features = bottom->connection_features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) adapter->peer_wwpn = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) adapter->peer_wwnn = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) adapter->peer_d_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) switch (qtcb->header.fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) case FSF_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) * usually we wait with an update till the cache is too old,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) * but because we have the data available, update it anyway
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) zfcp_diag_update_xdata(diag_hdr, bottom, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) zfcp_scsi_shost_update_config_data(adapter, bottom, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) if (zfcp_fsf_exchange_config_evaluate(req))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) dev_err(&adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) "FCP adapter maximum QTCB size (%d bytes) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) "is too small\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) bottom->max_qtcb_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) atomic_or(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) &adapter->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) zfcp_diag_update_xdata(diag_hdr, bottom, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) req->status |= ZFCP_STATUS_FSFREQ_XDATAINCOMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) /* avoids adapter shutdown to be able to recognize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) * events such as LINK UP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) atomic_or(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) &adapter->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) zfcp_fsf_link_down_info_eval(req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) &qtcb->header.fsf_status_qual.link_down_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) zfcp_scsi_shost_update_config_data(adapter, bottom, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) if (zfcp_fsf_exchange_config_evaluate(req))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh3");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) adapter->hardware_version = bottom->hardware_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) if (FSF_QTCB_CURRENT_VERSION < bottom->low_qtcb_version) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) dev_err(&adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) "The FCP adapter only supports newer "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) "control block versions\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh4");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) if (FSF_QTCB_CURRENT_VERSION > bottom->high_qtcb_version) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) dev_err(&adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) "The FCP adapter only supports older "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) "control block versions\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh5");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) * Mapping of FC Endpoint Security flag masks to mnemonics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) * NOTE: Update macro ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH when making any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) * changes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) static const struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) u32 mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) } zfcp_fsf_fc_security_mnemonics[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) { FSF_FC_SECURITY_AUTH, "Authentication" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) { FSF_FC_SECURITY_ENC_FCSP2 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) FSF_FC_SECURITY_ENC_ERAS, "Encryption" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) /* maximum strlen(zfcp_fsf_fc_security_mnemonics[...].name) + 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) #define ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH 15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) * zfcp_fsf_scnprint_fc_security() - translate FC Endpoint Security flags into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) * mnemonics and place in a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) * @buf : the buffer to place the translated FC Endpoint Security flag(s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) * into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) * @size : the size of the buffer, including the trailing null space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) * @fc_security: one or more FC Endpoint Security flags, or zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) * @fmt : specifies whether a list or a single item is to be put into the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) * buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) * The Fibre Channel (FC) Endpoint Security flags are translated into mnemonics.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) * If the FC Endpoint Security flags are zero "none" is placed into the buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) * With ZFCP_FSF_PRINT_FMT_LIST the mnemonics are placed as a list separated by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) * a comma followed by a space into the buffer. If one or more FC Endpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) * Security flags cannot be translated into a mnemonic, as they are undefined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) * in zfcp_fsf_fc_security_mnemonics, their bitwise ORed value in hexadecimal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) * representation is placed into the buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) * With ZFCP_FSF_PRINT_FMT_SINGLEITEM only one single mnemonic is placed into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) * the buffer. If the FC Endpoint Security flag cannot be translated, as it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) * undefined in zfcp_fsf_fc_security_mnemonics, its value in hexadecimal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) * representation is placed into the buffer. If more than one FC Endpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) * Security flag was specified, their value in hexadecimal representation is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) * placed into the buffer. The macro ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) * can be used to define a buffer that is large enough to hold one mnemonic.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) * Return: The number of characters written into buf not including the trailing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) * '\0'. If size is == 0 the function returns 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) ssize_t zfcp_fsf_scnprint_fc_security(char *buf, size_t size, u32 fc_security,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) enum zfcp_fsf_print_fmt fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) const char *prefix = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) ssize_t len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) if (fc_security == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) return scnprintf(buf, size, "none");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) if (fmt == ZFCP_FSF_PRINT_FMT_SINGLEITEM && hweight32(fc_security) != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) return scnprintf(buf, size, "0x%08x", fc_security);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) for (i = 0; i < ARRAY_SIZE(zfcp_fsf_fc_security_mnemonics); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) if (!(fc_security & zfcp_fsf_fc_security_mnemonics[i].mask))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) len += scnprintf(buf + len, size - len, "%s%s", prefix,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) zfcp_fsf_fc_security_mnemonics[i].name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) prefix = ", ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) fc_security &= ~zfcp_fsf_fc_security_mnemonics[i].mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) if (fc_security != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) len += scnprintf(buf + len, size - len, "%s0x%08x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) prefix, fc_security);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) static void zfcp_fsf_dbf_adapter_fc_security(struct zfcp_adapter *adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) if (adapter->fc_security_algorithms ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) adapter->fc_security_algorithms_old) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) /* no change, no trace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) zfcp_dbf_hba_fsf_fces("fsfcesa", req, ZFCP_DBF_INVALID_WWPN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) adapter->fc_security_algorithms_old,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) adapter->fc_security_algorithms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) adapter->fc_security_algorithms_old = adapter->fc_security_algorithms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) static void zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) struct zfcp_adapter *adapter = req->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) struct fsf_qtcb_bottom_port *bottom = &req->qtcb->bottom.port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) if (req->data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) memcpy(req->data, bottom, sizeof(*bottom));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) if (adapter->adapter_features & FSF_FEATURE_FC_SECURITY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) adapter->fc_security_algorithms =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) bottom->fc_security_algorithms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) adapter->fc_security_algorithms = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) zfcp_fsf_dbf_adapter_fc_security(adapter, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) struct zfcp_diag_header *const diag_hdr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) &req->adapter->diagnostics->port_data.header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) struct fsf_qtcb *qtcb = req->qtcb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) struct fsf_qtcb_bottom_port *bottom = &qtcb->bottom.port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) switch (qtcb->header.fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) case FSF_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) * usually we wait with an update till the cache is too old,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) * but because we have the data available, update it anyway
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) zfcp_diag_update_xdata(diag_hdr, bottom, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) zfcp_scsi_shost_update_port_data(req->adapter, bottom);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) zfcp_fsf_exchange_port_evaluate(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) zfcp_diag_update_xdata(diag_hdr, bottom, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) req->status |= ZFCP_STATUS_FSFREQ_XDATAINCOMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) zfcp_fsf_link_down_info_eval(req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) &qtcb->header.fsf_status_qual.link_down_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) zfcp_scsi_shost_update_port_data(req->adapter, bottom);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) zfcp_fsf_exchange_port_evaluate(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) static struct zfcp_fsf_req *zfcp_fsf_alloc(mempool_t *pool)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) if (likely(pool))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) req = mempool_alloc(pool, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) req = kmalloc(sizeof(*req), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) if (unlikely(!req))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) memset(req, 0, sizeof(*req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) req->pool = pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) return req;
^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) static struct fsf_qtcb *zfcp_fsf_qtcb_alloc(mempool_t *pool)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) struct fsf_qtcb *qtcb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) if (likely(pool))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) qtcb = mempool_alloc(pool, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) qtcb = kmem_cache_alloc(zfcp_fsf_qtcb_cache, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) if (unlikely(!qtcb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) memset(qtcb, 0, sizeof(*qtcb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) return qtcb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) u32 fsf_cmd, u8 sbtype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) mempool_t *pool)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) struct zfcp_adapter *adapter = qdio->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) struct zfcp_fsf_req *req = zfcp_fsf_alloc(pool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) if (unlikely(!req))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) if (adapter->req_no == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) adapter->req_no++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) INIT_LIST_HEAD(&req->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) timer_setup(&req->timer, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) init_completion(&req->completion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) req->adapter = adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) req->req_id = adapter->req_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) if (likely(fsf_cmd != FSF_QTCB_UNSOLICITED_STATUS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) if (likely(pool))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) req->qtcb = zfcp_fsf_qtcb_alloc(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) adapter->pool.qtcb_pool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) req->qtcb = zfcp_fsf_qtcb_alloc(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) if (unlikely(!req->qtcb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) return ERR_PTR(-ENOMEM);
^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) req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) req->qtcb->prefix.req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) req->qtcb->prefix.ulp_info = 26;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) req->qtcb->prefix.qtcb_type = fsf_qtcb_type[fsf_cmd];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) req->qtcb->prefix.qtcb_version = FSF_QTCB_CURRENT_VERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) req->qtcb->header.req_handle = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) req->qtcb->header.fsf_command = fsf_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) zfcp_qdio_req_init(adapter->qdio, &req->qdio_req, req->req_id, sbtype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) req->qtcb, sizeof(struct fsf_qtcb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) return req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) const bool is_srb = zfcp_fsf_req_is_status_read_buffer(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) struct zfcp_adapter *adapter = req->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) struct zfcp_qdio *qdio = adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) int req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) zfcp_reqlist_add(adapter->req_list, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) req->qdio_req.qdio_outb_usage = atomic_read(&qdio->req_q_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) req->issued = get_tod_clock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) if (zfcp_qdio_send(qdio, &req->qdio_req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) del_timer_sync(&req->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) /* lookup request again, list might have changed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) zfcp_reqlist_find_rm(adapter->req_list, req_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) zfcp_erp_adapter_reopen(adapter, 0, "fsrs__1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) * NOTE: DO NOT TOUCH ASYNC req PAST THIS POINT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) * ONLY TOUCH SYNC req AGAIN ON req->completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) * The request might complete and be freed concurrently at any point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) * now. This is not protected by the QDIO-lock (req_q_lock). So any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) * uncontrolled access after this might result in an use-after-free bug.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) * Only if the request doesn't have ZFCP_STATUS_FSFREQ_CLEANUP set, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) * when it is completed via req->completion, is it safe to use req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) * again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) /* Don't increase for unsolicited status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) if (!is_srb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) adapter->fsf_req_seq_no++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) adapter->req_no++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) * zfcp_fsf_status_read - send status read request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) * @qdio: pointer to struct zfcp_qdio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) * Returns: 0 on success, ERROR otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) int zfcp_fsf_status_read(struct zfcp_qdio *qdio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) struct zfcp_adapter *adapter = qdio->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) struct fsf_status_read_buffer *sr_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) struct page *page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) int retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) req = zfcp_fsf_req_create(qdio, FSF_QTCB_UNSOLICITED_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) SBAL_SFLAGS0_TYPE_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) adapter->pool.status_read_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) retval = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) page = mempool_alloc(adapter->pool.sr_data, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) if (!page) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) retval = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) goto failed_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) sr_buf = page_address(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) memset(sr_buf, 0, sizeof(*sr_buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) req->data = sr_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) zfcp_qdio_fill_next(qdio, &req->qdio_req, sr_buf, sizeof(*sr_buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) retval = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) goto failed_req_send;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) failed_req_send:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) req->data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) mempool_free(virt_to_page(sr_buf), adapter->pool.sr_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) failed_buf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) zfcp_dbf_hba_fsf_uss("fssr__1", req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) struct scsi_device *sdev = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) struct zfcp_scsi_dev *zfcp_sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) union fsf_status_qual *fsq = &req->qtcb->header.fsf_status_qual;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) zfcp_sdev = sdev_to_zfcp(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) switch (req->qtcb->header.fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) case FSF_PORT_HANDLE_NOT_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) if (fsq->word[0] == fsq->word[1]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) zfcp_erp_adapter_reopen(zfcp_sdev->port->adapter, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) "fsafch1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) case FSF_LUN_HANDLE_NOT_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) if (fsq->word[0] == fsq->word[1]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) zfcp_erp_port_reopen(zfcp_sdev->port, 0, "fsafch2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) case FSF_FCP_COMMAND_DOES_NOT_EXIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) case FSF_PORT_BOXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) zfcp_erp_set_port_status(zfcp_sdev->port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) ZFCP_STATUS_COMMON_ACCESS_BOXED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) zfcp_erp_port_reopen(zfcp_sdev->port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) ZFCP_STATUS_COMMON_ERP_FAILED, "fsafch3");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) case FSF_LUN_BOXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) zfcp_erp_set_lun_status(sdev, ZFCP_STATUS_COMMON_ACCESS_BOXED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) zfcp_erp_lun_reopen(sdev, ZFCP_STATUS_COMMON_ERP_FAILED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) "fsafch4");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) case FSF_ADAPTER_STATUS_AVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) switch (fsq->word[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) zfcp_fc_test_link(zfcp_sdev->port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) case FSF_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) req->status |= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) * zfcp_fsf_abort_fcp_cmnd - abort running SCSI command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) * @scmnd: The SCSI command to abort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) * Returns: pointer to struct zfcp_fsf_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) struct zfcp_fsf_req *zfcp_fsf_abort_fcp_cmnd(struct scsi_cmnd *scmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) struct zfcp_fsf_req *req = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) struct scsi_device *sdev = scmnd->device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) struct zfcp_qdio *qdio = zfcp_sdev->port->adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) unsigned long old_req_id = (unsigned long) scmnd->host_scribble;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) req = zfcp_fsf_req_create(qdio, FSF_QTCB_ABORT_FCP_CMND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) SBAL_SFLAGS0_TYPE_READ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) qdio->adapter->pool.scsi_abort);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) req = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) if (unlikely(!(atomic_read(&zfcp_sdev->status) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) ZFCP_STATUS_COMMON_UNBLOCKED)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) goto out_error_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) req->data = sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) req->handler = zfcp_fsf_abort_fcp_command_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) req->qtcb->header.port_handle = zfcp_sdev->port->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) req->qtcb->bottom.support.req_handle = (u64) old_req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) zfcp_fsf_start_timer(req, ZFCP_FSF_SCSI_ER_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) if (!zfcp_fsf_req_send(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) /* NOTE: DO NOT TOUCH req, UNTIL IT COMPLETES! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) out_error_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) req = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) return req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) struct zfcp_adapter *adapter = req->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) struct zfcp_fsf_ct_els *ct = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) struct fsf_qtcb_header *header = &req->qtcb->header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) ct->status = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) goto skip_fsfstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) switch (header->fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) case FSF_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) ct->status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) zfcp_dbf_san_res("fsscth2", req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) case FSF_SERVICE_CLASS_NOT_SUPPORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) zfcp_fsf_class_not_supp(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) case FSF_ADAPTER_STATUS_AVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) switch (header->fsf_status_qual.word[0]){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) case FSF_PORT_BOXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) case FSF_PORT_HANDLE_NOT_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) zfcp_erp_adapter_reopen(adapter, 0, "fsscth1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) case FSF_GENERIC_COMMAND_REJECTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) case FSF_PAYLOAD_SIZE_MISMATCH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) case FSF_REQUEST_SIZE_TOO_LARGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) case FSF_RESPONSE_SIZE_TOO_LARGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) case FSF_SBAL_MISMATCH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) skip_fsfstatus:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) if (ct->handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) ct->handler(ct->handler_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) static void zfcp_fsf_setup_ct_els_unchained(struct zfcp_qdio *qdio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) struct zfcp_qdio_req *q_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) struct scatterlist *sg_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) struct scatterlist *sg_resp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) zfcp_qdio_fill_next(qdio, q_req, sg_virt(sg_req), sg_req->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) zfcp_qdio_fill_next(qdio, q_req, sg_virt(sg_resp), sg_resp->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) zfcp_qdio_set_sbale_last(qdio, q_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) struct scatterlist *sg_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) struct scatterlist *sg_resp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) struct zfcp_adapter *adapter = req->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) struct zfcp_qdio *qdio = adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) struct fsf_qtcb *qtcb = req->qtcb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) u32 feat = adapter->adapter_features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) if (zfcp_adapter_multi_buffer_active(adapter)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) if (zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sg_req))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) qtcb->bottom.support.req_buf_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) zfcp_qdio_real_bytes(sg_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) if (zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sg_resp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) qtcb->bottom.support.resp_buf_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) zfcp_qdio_real_bytes(sg_resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) zfcp_qdio_set_data_div(qdio, &req->qdio_req, sg_nents(sg_req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) zfcp_qdio_set_scount(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) /* use single, unchained SBAL if it can hold the request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) if (zfcp_qdio_sg_one_sbale(sg_req) && zfcp_qdio_sg_one_sbale(sg_resp)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) zfcp_fsf_setup_ct_els_unchained(qdio, &req->qdio_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) sg_req, sg_resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) if (!(feat & FSF_FEATURE_ELS_CT_CHAINED_SBALS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) if (zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sg_req))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) qtcb->bottom.support.req_buf_length = zfcp_qdio_real_bytes(sg_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) zfcp_qdio_skip_to_last_sbale(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) if (zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sg_resp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) qtcb->bottom.support.resp_buf_length = zfcp_qdio_real_bytes(sg_resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) static int zfcp_fsf_setup_ct_els(struct zfcp_fsf_req *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) struct scatterlist *sg_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) struct scatterlist *sg_resp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) unsigned int timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) ret = zfcp_fsf_setup_ct_els_sbals(req, sg_req, sg_resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) /* common settings for ct/gs and els requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) if (timeout > 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) timeout = 255; /* max value accepted by hardware */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) req->qtcb->bottom.support.service_class = FSF_CLASS_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) req->qtcb->bottom.support.timeout = timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) zfcp_fsf_start_timer(req, (timeout + 10) * HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) * @wka_port: pointer to zfcp WKA port to send CT/GS to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) * @ct: pointer to struct zfcp_send_ct with data for request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) * @pool: if non-null this mempool is used to allocate struct zfcp_fsf_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) * @timeout: timeout that hardware should use, and a later software timeout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *wka_port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) struct zfcp_fsf_ct_els *ct, mempool_t *pool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) unsigned int timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) struct zfcp_qdio *qdio = wka_port->adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) int ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_GENERIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) SBAL_SFLAGS0_TYPE_WRITE_READ, pool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) ret = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) ret = zfcp_fsf_setup_ct_els(req, ct->req, ct->resp, timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) goto failed_send;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) req->handler = zfcp_fsf_send_ct_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) req->qtcb->header.port_handle = wka_port->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) ct->d_id = wka_port->d_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) req->data = ct;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) zfcp_dbf_san_req("fssct_1", req, wka_port->d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) ret = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) goto failed_send;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) failed_send:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) static void zfcp_fsf_send_els_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) struct zfcp_fsf_ct_els *send_els = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) struct fsf_qtcb_header *header = &req->qtcb->header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) send_els->status = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) goto skip_fsfstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) switch (header->fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) case FSF_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) send_els->status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) zfcp_dbf_san_res("fsselh1", req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) case FSF_SERVICE_CLASS_NOT_SUPPORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) zfcp_fsf_class_not_supp(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) case FSF_ADAPTER_STATUS_AVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) switch (header->fsf_status_qual.word[0]){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) case FSF_SQ_RETRY_IF_POSSIBLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) case FSF_ELS_COMMAND_REJECTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) case FSF_PAYLOAD_SIZE_MISMATCH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) case FSF_REQUEST_SIZE_TOO_LARGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) case FSF_RESPONSE_SIZE_TOO_LARGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) case FSF_SBAL_MISMATCH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) /* should never occur, avoided in zfcp_fsf_send_els */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) skip_fsfstatus:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) if (send_els->handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) send_els->handler(send_els->handler_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) * zfcp_fsf_send_els - initiate an ELS command (FC-FS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) * @adapter: pointer to zfcp adapter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) * @d_id: N_Port_ID to send ELS to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) * @els: pointer to struct zfcp_send_els with data for the command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) * @timeout: timeout that hardware should use, and a later software timeout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) int zfcp_fsf_send_els(struct zfcp_adapter *adapter, u32 d_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) struct zfcp_fsf_ct_els *els, unsigned int timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) struct zfcp_qdio *qdio = adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) int ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_ELS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) SBAL_SFLAGS0_TYPE_WRITE_READ, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) ret = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) if (!zfcp_adapter_multi_buffer_active(adapter))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) zfcp_qdio_sbal_limit(qdio, &req->qdio_req, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) ret = zfcp_fsf_setup_ct_els(req, els->req, els->resp, timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) goto failed_send;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) hton24(req->qtcb->bottom.support.d_id, d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) req->handler = zfcp_fsf_send_els_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) els->d_id = d_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) req->data = els;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) zfcp_dbf_san_req("fssels1", req, d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) ret = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) goto failed_send;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) failed_send:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) struct zfcp_qdio *qdio = erp_action->adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) int retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) SBAL_SFLAGS0_TYPE_READ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) qdio->adapter->pool.erp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) retval = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) req->qtcb->bottom.config.feature_selection =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) FSF_FEATURE_NOTIFICATION_LOST |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) FSF_FEATURE_UPDATE_ALERT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) FSF_FEATURE_REQUEST_SFP_DATA |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) FSF_FEATURE_FC_SECURITY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) req->erp_action = erp_action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) req->handler = zfcp_fsf_exchange_config_data_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) erp_action->fsf_req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) zfcp_fsf_start_erp_timer(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) retval = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) erp_action->fsf_req_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) * zfcp_fsf_exchange_config_data_sync() - Request information about FCP channel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) * @qdio: pointer to the QDIO-Queue to use for sending the command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) * @data: pointer to the QTCB-Bottom for storing the result of the command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) * might be %NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) * * 0 - Exchange Config Data was successful, @data is complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) * * -EIO - Exchange Config Data was not successful, @data is invalid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) * * -EAGAIN - @data contains incomplete data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) * * -ENOMEM - Some memory allocation failed along the way
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) struct fsf_qtcb_bottom_config *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) struct zfcp_fsf_req *req = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) int retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) SBAL_SFLAGS0_TYPE_READ, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) retval = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) goto out_unlock;
^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) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) req->handler = zfcp_fsf_exchange_config_data_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) req->qtcb->bottom.config.feature_selection =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) FSF_FEATURE_NOTIFICATION_LOST |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) FSF_FEATURE_UPDATE_ALERT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) FSF_FEATURE_REQUEST_SFP_DATA |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) FSF_FEATURE_FC_SECURITY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) if (data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) req->data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) retval = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) if (!retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) /* NOTE: ONLY TOUCH SYNC req AGAIN ON req->completion. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) wait_for_completion(&req->completion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) if (req->status &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) (ZFCP_STATUS_FSFREQ_ERROR | ZFCP_STATUS_FSFREQ_DISMISSED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) else if (req->status & ZFCP_STATUS_FSFREQ_XDATAINCOMPLETE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) retval = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) out_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) * zfcp_fsf_exchange_port_data - request information about local port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) * @erp_action: ERP action for the adapter for which port data is requested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) * Returns: 0 on success, error otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) struct zfcp_qdio *qdio = erp_action->adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) int retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) if (!(qdio->adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) SBAL_SFLAGS0_TYPE_READ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) qdio->adapter->pool.erp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) retval = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) req->handler = zfcp_fsf_exchange_port_data_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) req->erp_action = erp_action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) erp_action->fsf_req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) zfcp_fsf_start_erp_timer(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) retval = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) erp_action->fsf_req_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) * zfcp_fsf_exchange_port_data_sync() - Request information about local port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) * @qdio: pointer to the QDIO-Queue to use for sending the command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) * @data: pointer to the QTCB-Bottom for storing the result of the command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) * might be %NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) * * 0 - Exchange Port Data was successful, @data is complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) * * -EIO - Exchange Port Data was not successful, @data is invalid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) * * -EAGAIN - @data contains incomplete data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) * * -ENOMEM - Some memory allocation failed along the way
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) * * -EOPNOTSUPP - This operation is not supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) struct fsf_qtcb_bottom_port *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) struct zfcp_fsf_req *req = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) int retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) if (!(qdio->adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) SBAL_SFLAGS0_TYPE_READ, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) retval = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) if (data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) req->data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) req->handler = zfcp_fsf_exchange_port_data_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) retval = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) if (!retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) /* NOTE: ONLY TOUCH SYNC req AGAIN ON req->completion. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) wait_for_completion(&req->completion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) if (req->status &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) (ZFCP_STATUS_FSFREQ_ERROR | ZFCP_STATUS_FSFREQ_DISMISSED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) else if (req->status & ZFCP_STATUS_FSFREQ_XDATAINCOMPLETE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) retval = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) out_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) static void zfcp_fsf_log_port_fc_security(struct zfcp_port *port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) char mnemonic_old[ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) char mnemonic_new[ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) if (port->connection_info == port->connection_info_old) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) /* no change, no log nor trace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) zfcp_dbf_hba_fsf_fces("fsfcesp", req, port->wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) port->connection_info_old,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) port->connection_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) zfcp_fsf_scnprint_fc_security(mnemonic_old, sizeof(mnemonic_old),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) port->connection_info_old,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) ZFCP_FSF_PRINT_FMT_SINGLEITEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) zfcp_fsf_scnprint_fc_security(mnemonic_new, sizeof(mnemonic_new),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) port->connection_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) ZFCP_FSF_PRINT_FMT_SINGLEITEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) if (strncmp(mnemonic_old, mnemonic_new,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) /* no change in string representation, no log */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) if (port->connection_info_old == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) /* activation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) dev_info(&port->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) "FC Endpoint Security of connection to remote port 0x%16llx enabled: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) port->wwpn, mnemonic_new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) } else if (port->connection_info == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) /* deactivation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) dev_warn(&port->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) "FC Endpoint Security of connection to remote port 0x%16llx disabled: was %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) port->wwpn, mnemonic_old);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) /* change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) dev_warn(&port->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) "FC Endpoint Security of connection to remote port 0x%16llx changed: from %s to %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) port->wwpn, mnemonic_old, mnemonic_new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) port->connection_info_old = port->connection_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) static void zfcp_fsf_log_security_error(const struct device *dev, u32 fsf_sqw0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) u64 wwpn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) switch (fsf_sqw0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) * Open Port command error codes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) case FSF_SQ_SECURITY_REQUIRED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) dev_warn_ratelimited(dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) "FC Endpoint Security error: FC security is required but not supported or configured on remote port 0x%016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) wwpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) case FSF_SQ_SECURITY_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) dev_warn_ratelimited(dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) "FC Endpoint Security error: a timeout prevented opening remote port 0x%016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) wwpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) case FSF_SQ_SECURITY_KM_UNAVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) dev_warn_ratelimited(dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) "FC Endpoint Security error: opening remote port 0x%016llx failed because local and external key manager cannot communicate\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) wwpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) case FSF_SQ_SECURITY_RKM_UNAVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) dev_warn_ratelimited(dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) "FC Endpoint Security error: opening remote port 0x%016llx failed because it cannot communicate with the external key manager\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) wwpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) case FSF_SQ_SECURITY_AUTH_FAILURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) dev_warn_ratelimited(dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) "FC Endpoint Security error: the device could not verify the identity of remote port 0x%016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) wwpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) * Send FCP command error codes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) case FSF_SQ_SECURITY_ENC_FAILURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) dev_warn_ratelimited(dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) "FC Endpoint Security error: FC connection to remote port 0x%016llx closed because encryption broke down\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) wwpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) break;
^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) * Unknown error codes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) dev_warn_ratelimited(dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) "FC Endpoint Security error: the device issued an unknown error code 0x%08x related to the FC connection to remote port 0x%016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) fsf_sqw0, wwpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) struct zfcp_adapter *adapter = req->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) struct zfcp_port *port = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) struct fsf_qtcb_header *header = &req->qtcb->header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) struct fsf_qtcb_bottom_support *bottom = &req->qtcb->bottom.support;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) struct fc_els_flogi *plogi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) switch (header->fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) case FSF_PORT_ALREADY_OPEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) dev_warn(&adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) "Not enough FCP adapter resources to open "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) "remote port 0x%016Lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) (unsigned long long)port->wwpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) zfcp_erp_set_port_status(port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) ZFCP_STATUS_COMMON_ERP_FAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) case FSF_SECURITY_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) zfcp_fsf_log_security_error(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) header->fsf_status_qual.word[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) port->wwpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) case FSF_ADAPTER_STATUS_AVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) switch (header->fsf_status_qual.word[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) /* no zfcp_fc_test_link() with failed open port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) case FSF_SQ_NO_RETRY_POSSIBLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) case FSF_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) port->handle = header->port_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) if (adapter->adapter_features & FSF_FEATURE_FC_SECURITY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) port->connection_info = bottom->connection_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) port->connection_info = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) zfcp_fsf_log_port_fc_security(port, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) atomic_or(ZFCP_STATUS_COMMON_OPEN |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) atomic_andnot(ZFCP_STATUS_COMMON_ACCESS_BOXED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) &port->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) /* check whether D_ID has changed during open */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) * FIXME: This check is not airtight, as the FCP channel does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) * not monitor closures of target port connections caused on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) * the remote side. Thus, they might miss out on invalidating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) * locally cached WWPNs (and other N_Port parameters) of gone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) * target ports. So, our heroic attempt to make things safe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) * could be undermined by 'open port' response data tagged with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) * obsolete WWPNs. Another reason to monitor potential
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) * connection closures ourself at least (by interpreting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) * incoming ELS' and unsolicited status). It just crosses my
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) * mind that one should be able to cross-check by means of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) * another GID_PN straight after a port has been opened.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) * Alternately, an ADISC/PDISC ELS should suffice, as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) plogi = (struct fc_els_flogi *) bottom->els;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) if (bottom->els1_length >= FSF_PLOGI_MIN_LEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) zfcp_fc_plogi_evaluate(port, plogi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) case FSF_UNKNOWN_OP_SUBTYPE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) put_device(&port->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) * zfcp_fsf_open_port - create and send open port request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) * @erp_action: pointer to struct zfcp_erp_action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) * Returns: 0 on success, error otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) struct zfcp_qdio *qdio = erp_action->adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) struct zfcp_port *port = erp_action->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) int retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) SBAL_SFLAGS0_TYPE_READ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) qdio->adapter->pool.erp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) retval = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) req->handler = zfcp_fsf_open_port_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) hton24(req->qtcb->bottom.support.d_id, port->d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) req->data = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) req->erp_action = erp_action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) erp_action->fsf_req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) get_device(&port->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) zfcp_fsf_start_erp_timer(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) retval = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) erp_action->fsf_req_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) put_device(&port->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) static void zfcp_fsf_close_port_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) struct zfcp_port *port = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) switch (req->qtcb->header.fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) case FSF_PORT_HANDLE_NOT_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) zfcp_erp_adapter_reopen(port->adapter, 0, "fscph_1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) case FSF_ADAPTER_STATUS_AVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) case FSF_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) zfcp_erp_clear_port_status(port, ZFCP_STATUS_COMMON_OPEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) * zfcp_fsf_close_port - create and send close port request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) * @erp_action: pointer to struct zfcp_erp_action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) * Returns: 0 on success, error otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) struct zfcp_qdio *qdio = erp_action->adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) int retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) SBAL_SFLAGS0_TYPE_READ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) qdio->adapter->pool.erp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) retval = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) req->handler = zfcp_fsf_close_port_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) req->data = erp_action->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) req->erp_action = erp_action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) req->qtcb->header.port_handle = erp_action->port->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) erp_action->fsf_req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) zfcp_fsf_start_erp_timer(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) retval = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) erp_action->fsf_req_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) static void zfcp_fsf_open_wka_port_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) struct zfcp_fc_wka_port *wka_port = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) struct fsf_qtcb_header *header = &req->qtcb->header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) if (req->status & ZFCP_STATUS_FSFREQ_ERROR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) switch (header->fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) dev_warn(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) "Opening WKA port 0x%x failed\n", wka_port->d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) case FSF_ADAPTER_STATUS_AVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) case FSF_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) wka_port->handle = header->port_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) case FSF_PORT_ALREADY_OPEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) wka_port->status = ZFCP_FC_WKA_PORT_ONLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) wake_up(&wka_port->completion_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) }
^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) * zfcp_fsf_open_wka_port - create and send open wka-port request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) * @wka_port: pointer to struct zfcp_fc_wka_port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) * Returns: 0 on success, error otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) struct zfcp_qdio *qdio = wka_port->adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) unsigned long req_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) int retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) SBAL_SFLAGS0_TYPE_READ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) qdio->adapter->pool.erp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) retval = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) req->handler = zfcp_fsf_open_wka_port_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) hton24(req->qtcb->bottom.support.d_id, wka_port->d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) req->data = wka_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) retval = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) if (!retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) zfcp_dbf_rec_run_wka("fsowp_1", wka_port, req_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) struct zfcp_fc_wka_port *wka_port = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) if (req->qtcb->header.fsf_status == FSF_PORT_HANDLE_NOT_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) zfcp_erp_adapter_reopen(wka_port->adapter, 0, "fscwph1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) wake_up(&wka_port->completion_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) * zfcp_fsf_close_wka_port - create and send close wka port request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) * @wka_port: WKA port to open
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) * Returns: 0 on success, error otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) struct zfcp_qdio *qdio = wka_port->adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) unsigned long req_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) int retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) SBAL_SFLAGS0_TYPE_READ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) qdio->adapter->pool.erp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) retval = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) req->handler = zfcp_fsf_close_wka_port_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) req->data = wka_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) req->qtcb->header.port_handle = wka_port->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) retval = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) if (!retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) zfcp_dbf_rec_run_wka("fscwp_1", wka_port, req_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) struct zfcp_port *port = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) struct fsf_qtcb_header *header = &req->qtcb->header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) switch (header->fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) case FSF_PORT_HANDLE_NOT_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) zfcp_erp_adapter_reopen(port->adapter, 0, "fscpph1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) case FSF_PORT_BOXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) /* can't use generic zfcp_erp_modify_port_status because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) * ZFCP_STATUS_COMMON_OPEN must not be reset for the port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) atomic_andnot(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) shost_for_each_device(sdev, port->adapter->scsi_host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) if (sdev_to_zfcp(sdev)->port == port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) atomic_andnot(ZFCP_STATUS_COMMON_OPEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) &sdev_to_zfcp(sdev)->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) zfcp_erp_set_port_status(port, ZFCP_STATUS_COMMON_ACCESS_BOXED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) "fscpph2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) case FSF_ADAPTER_STATUS_AVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) switch (header->fsf_status_qual.word[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) case FSF_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) /* can't use generic zfcp_erp_modify_port_status because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) atomic_andnot(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) shost_for_each_device(sdev, port->adapter->scsi_host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) if (sdev_to_zfcp(sdev)->port == port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) atomic_andnot(ZFCP_STATUS_COMMON_OPEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) &sdev_to_zfcp(sdev)->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) * zfcp_fsf_close_physical_port - close physical port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) * @erp_action: pointer to struct zfcp_erp_action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) * Returns: 0 on success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) struct zfcp_qdio *qdio = erp_action->adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) int retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PHYSICAL_PORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) SBAL_SFLAGS0_TYPE_READ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) qdio->adapter->pool.erp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) retval = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) req->data = erp_action->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) req->qtcb->header.port_handle = erp_action->port->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) req->erp_action = erp_action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) req->handler = zfcp_fsf_close_physical_port_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) erp_action->fsf_req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) zfcp_fsf_start_erp_timer(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) retval = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) erp_action->fsf_req_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) static void zfcp_fsf_open_lun_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) struct zfcp_adapter *adapter = req->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) struct scsi_device *sdev = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) struct zfcp_scsi_dev *zfcp_sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) struct fsf_qtcb_header *header = &req->qtcb->header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) union fsf_status_qual *qual = &header->fsf_status_qual;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) zfcp_sdev = sdev_to_zfcp(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) atomic_andnot(ZFCP_STATUS_COMMON_ACCESS_DENIED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) ZFCP_STATUS_COMMON_ACCESS_BOXED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) &zfcp_sdev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) switch (header->fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) case FSF_PORT_HANDLE_NOT_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) zfcp_erp_adapter_reopen(adapter, 0, "fsouh_1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) case FSF_LUN_ALREADY_OPEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) case FSF_PORT_BOXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) zfcp_erp_set_port_status(zfcp_sdev->port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) ZFCP_STATUS_COMMON_ACCESS_BOXED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) zfcp_erp_port_reopen(zfcp_sdev->port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) ZFCP_STATUS_COMMON_ERP_FAILED, "fsouh_2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) case FSF_LUN_SHARING_VIOLATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) if (qual->word[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) dev_warn(&zfcp_sdev->port->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) "LUN 0x%016Lx on port 0x%016Lx is already in "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) "use by CSS%d, MIF Image ID %x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) zfcp_scsi_dev_lun(sdev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) (unsigned long long)zfcp_sdev->port->wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) qual->fsf_queue_designator.cssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) qual->fsf_queue_designator.hla);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) zfcp_erp_set_lun_status(sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) ZFCP_STATUS_COMMON_ERP_FAILED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) ZFCP_STATUS_COMMON_ACCESS_DENIED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) dev_warn(&adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) "No handle is available for LUN "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) "0x%016Lx on port 0x%016Lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) (unsigned long long)zfcp_scsi_dev_lun(sdev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) (unsigned long long)zfcp_sdev->port->wwpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) zfcp_erp_set_lun_status(sdev, ZFCP_STATUS_COMMON_ERP_FAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) case FSF_INVALID_COMMAND_OPTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) case FSF_ADAPTER_STATUS_AVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) switch (header->fsf_status_qual.word[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) zfcp_fc_test_link(zfcp_sdev->port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) case FSF_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) zfcp_sdev->lun_handle = header->lun_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) atomic_or(ZFCP_STATUS_COMMON_OPEN, &zfcp_sdev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) * zfcp_fsf_open_lun - open LUN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) * @erp_action: pointer to struct zfcp_erp_action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) * Returns: 0 on success, error otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) int zfcp_fsf_open_lun(struct zfcp_erp_action *erp_action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) struct zfcp_adapter *adapter = erp_action->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) struct zfcp_qdio *qdio = adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) int retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_LUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) SBAL_SFLAGS0_TYPE_READ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) adapter->pool.erp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) retval = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) req->qtcb->header.port_handle = erp_action->port->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) req->qtcb->bottom.support.fcp_lun = zfcp_scsi_dev_lun(erp_action->sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) req->handler = zfcp_fsf_open_lun_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) req->data = erp_action->sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) req->erp_action = erp_action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) erp_action->fsf_req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) req->qtcb->bottom.support.option = FSF_OPEN_LUN_SUPPRESS_BOXING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) zfcp_fsf_start_erp_timer(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) retval = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) erp_action->fsf_req_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) return retval;
^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) static void zfcp_fsf_close_lun_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) struct scsi_device *sdev = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) struct zfcp_scsi_dev *zfcp_sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) zfcp_sdev = sdev_to_zfcp(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) switch (req->qtcb->header.fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) case FSF_PORT_HANDLE_NOT_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) zfcp_erp_adapter_reopen(zfcp_sdev->port->adapter, 0, "fscuh_1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) case FSF_LUN_HANDLE_NOT_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) zfcp_erp_port_reopen(zfcp_sdev->port, 0, "fscuh_2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) case FSF_PORT_BOXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) zfcp_erp_set_port_status(zfcp_sdev->port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) ZFCP_STATUS_COMMON_ACCESS_BOXED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) zfcp_erp_port_reopen(zfcp_sdev->port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) ZFCP_STATUS_COMMON_ERP_FAILED, "fscuh_3");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) case FSF_ADAPTER_STATUS_AVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) switch (req->qtcb->header.fsf_status_qual.word[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) zfcp_fc_test_link(zfcp_sdev->port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) case FSF_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) atomic_andnot(ZFCP_STATUS_COMMON_OPEN, &zfcp_sdev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) * zfcp_fsf_close_LUN - close LUN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) * @erp_action: pointer to erp_action triggering the "close LUN"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) * Returns: 0 on success, error otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) int zfcp_fsf_close_lun(struct zfcp_erp_action *erp_action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) struct zfcp_qdio *qdio = erp_action->adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(erp_action->sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) int retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_LUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) SBAL_SFLAGS0_TYPE_READ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) qdio->adapter->pool.erp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) retval = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) req->qtcb->header.port_handle = erp_action->port->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) req->handler = zfcp_fsf_close_lun_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) req->data = erp_action->sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) req->erp_action = erp_action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) erp_action->fsf_req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) zfcp_fsf_start_erp_timer(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) retval = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) erp_action->fsf_req_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) static void zfcp_fsf_update_lat(struct zfcp_latency_record *lat_rec, u32 lat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) lat_rec->sum += lat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) lat_rec->min = min(lat_rec->min, lat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) lat_rec->max = max(lat_rec->max, lat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) struct fsf_qual_latency_info *lat_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) struct zfcp_latency_cont *lat = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) struct zfcp_scsi_dev *zfcp_sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) struct zfcp_blk_drv_data blktrc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) int ticks = req->adapter->timer_ticks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) lat_in = &req->qtcb->prefix.prot_status_qual.latency_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) blktrc.flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) blktrc.magic = ZFCP_BLK_DRV_DATA_MAGIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) blktrc.flags |= ZFCP_BLK_REQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) blktrc.inb_usage = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) blktrc.outb_usage = req->qdio_req.qdio_outb_usage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) if (req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) !(req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) zfcp_sdev = sdev_to_zfcp(scsi->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) blktrc.flags |= ZFCP_BLK_LAT_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) blktrc.channel_lat = lat_in->channel_lat * ticks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) blktrc.fabric_lat = lat_in->fabric_lat * ticks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) switch (req->qtcb->bottom.io.data_direction) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) case FSF_DATADIR_DIF_READ_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) case FSF_DATADIR_DIF_READ_CONVERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) case FSF_DATADIR_READ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) lat = &zfcp_sdev->latencies.read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) case FSF_DATADIR_DIF_WRITE_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) case FSF_DATADIR_DIF_WRITE_CONVERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) case FSF_DATADIR_WRITE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) lat = &zfcp_sdev->latencies.write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) case FSF_DATADIR_CMND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) lat = &zfcp_sdev->latencies.cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) if (lat) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) spin_lock(&zfcp_sdev->latencies.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) zfcp_fsf_update_lat(&lat->channel, lat_in->channel_lat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) zfcp_fsf_update_lat(&lat->fabric, lat_in->fabric_lat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) lat->counter++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) spin_unlock(&zfcp_sdev->latencies.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) blk_add_driver_data(scsi->request->q, scsi->request, &blktrc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) sizeof(blktrc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) * zfcp_fsf_fcp_handler_common() - FCP response handler common to I/O and TMF.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) * @req: Pointer to FSF request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) * @sdev: Pointer to SCSI device as request context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) static void zfcp_fsf_fcp_handler_common(struct zfcp_fsf_req *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) struct zfcp_scsi_dev *zfcp_sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) struct fsf_qtcb_header *header = &req->qtcb->header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) zfcp_sdev = sdev_to_zfcp(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) switch (header->fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) case FSF_HANDLE_MISMATCH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) case FSF_PORT_HANDLE_NOT_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) zfcp_erp_adapter_reopen(req->adapter, 0, "fssfch1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) case FSF_FCPLUN_NOT_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) case FSF_LUN_HANDLE_NOT_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) zfcp_erp_port_reopen(zfcp_sdev->port, 0, "fssfch2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) case FSF_SERVICE_CLASS_NOT_SUPPORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) zfcp_fsf_class_not_supp(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) case FSF_DIRECTION_INDICATOR_NOT_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) dev_err(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) "Incorrect direction %d, LUN 0x%016Lx on port "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) "0x%016Lx closed\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) req->qtcb->bottom.io.data_direction,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) (unsigned long long)zfcp_scsi_dev_lun(sdev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) (unsigned long long)zfcp_sdev->port->wwpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) zfcp_erp_adapter_shutdown(req->adapter, 0, "fssfch3");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) case FSF_CMND_LENGTH_NOT_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) dev_err(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) "Incorrect FCP_CMND length %d, FCP device closed\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) req->qtcb->bottom.io.fcp_cmnd_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) zfcp_erp_adapter_shutdown(req->adapter, 0, "fssfch4");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) case FSF_PORT_BOXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) zfcp_erp_set_port_status(zfcp_sdev->port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) ZFCP_STATUS_COMMON_ACCESS_BOXED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) zfcp_erp_port_reopen(zfcp_sdev->port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) ZFCP_STATUS_COMMON_ERP_FAILED, "fssfch5");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) case FSF_LUN_BOXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) zfcp_erp_set_lun_status(sdev, ZFCP_STATUS_COMMON_ACCESS_BOXED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) zfcp_erp_lun_reopen(sdev, ZFCP_STATUS_COMMON_ERP_FAILED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) "fssfch6");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) case FSF_ADAPTER_STATUS_AVAILABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) if (header->fsf_status_qual.word[0] ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) FSF_SQ_INVOKE_LINK_TEST_PROCEDURE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) zfcp_fc_test_link(zfcp_sdev->port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) case FSF_SECURITY_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) zfcp_fsf_log_security_error(&req->adapter->ccw_device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) header->fsf_status_qual.word[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) zfcp_sdev->port->wwpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) zfcp_erp_port_forced_reopen(zfcp_sdev->port, 0, "fssfch7");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) req->status |= ZFCP_STATUS_FSFREQ_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) static void zfcp_fsf_fcp_cmnd_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) struct scsi_cmnd *scpnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) struct fcp_resp_with_ext *fcp_rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) read_lock_irqsave(&req->adapter->abort_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) scpnt = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) if (unlikely(!scpnt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) read_unlock_irqrestore(&req->adapter->abort_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) zfcp_fsf_fcp_handler_common(req, scpnt->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) set_host_byte(scpnt, DID_TRANSPORT_DISRUPTED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) goto skip_fsfstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) switch (req->qtcb->header.fsf_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) case FSF_INCONSISTENT_PROT_DATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) case FSF_INVALID_PROT_PARM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) set_host_byte(scpnt, DID_ERROR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) goto skip_fsfstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) case FSF_BLOCK_GUARD_CHECK_FAILURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) zfcp_scsi_dif_sense_error(scpnt, 0x1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) goto skip_fsfstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) case FSF_APP_TAG_CHECK_FAILURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) zfcp_scsi_dif_sense_error(scpnt, 0x2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) goto skip_fsfstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) case FSF_REF_TAG_CHECK_FAILURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) zfcp_scsi_dif_sense_error(scpnt, 0x3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) goto skip_fsfstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) BUILD_BUG_ON(sizeof(struct fcp_resp_with_ext) > FSF_FCP_RSP_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) fcp_rsp = &req->qtcb->bottom.io.fcp_rsp.iu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) zfcp_fc_eval_fcp_rsp(fcp_rsp, scpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) skip_fsfstatus:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) zfcp_fsf_req_trace(req, scpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) zfcp_dbf_scsi_result(scpnt, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) scpnt->host_scribble = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) (scpnt->scsi_done) (scpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) * We must hold this lock until scsi_done has been called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) * Otherwise we may call scsi_done after abort regarding this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) * command has completed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) * Note: scsi_done must not block!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) read_unlock_irqrestore(&req->adapter->abort_lock, flags);
^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) static int zfcp_fsf_set_data_dir(struct scsi_cmnd *scsi_cmnd, u32 *data_dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) switch (scsi_get_prot_op(scsi_cmnd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) case SCSI_PROT_NORMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) switch (scsi_cmnd->sc_data_direction) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) case DMA_NONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) *data_dir = FSF_DATADIR_CMND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) case DMA_FROM_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) *data_dir = FSF_DATADIR_READ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) case DMA_TO_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) *data_dir = FSF_DATADIR_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) case DMA_BIDIRECTIONAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) case SCSI_PROT_READ_STRIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) *data_dir = FSF_DATADIR_DIF_READ_STRIP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) case SCSI_PROT_WRITE_INSERT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) *data_dir = FSF_DATADIR_DIF_WRITE_INSERT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) case SCSI_PROT_READ_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) *data_dir = FSF_DATADIR_DIF_READ_CONVERT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) case SCSI_PROT_WRITE_PASS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) *data_dir = FSF_DATADIR_DIF_WRITE_CONVERT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) return 0;
^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) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) * zfcp_fsf_fcp_cmnd - initiate an FCP command (for a SCSI command)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) * @scsi_cmnd: scsi command to be sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) int zfcp_fsf_fcp_cmnd(struct scsi_cmnd *scsi_cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) struct zfcp_fsf_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) struct fcp_cmnd *fcp_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) u8 sbtype = SBAL_SFLAGS0_TYPE_READ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) int retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) struct scsi_device *sdev = scsi_cmnd->device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) struct zfcp_qdio *qdio = adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) struct fsf_qtcb_bottom_io *io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) if (unlikely(!(atomic_read(&zfcp_sdev->status) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) ZFCP_STATUS_COMMON_UNBLOCKED)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) spin_lock_irqsave(&qdio->req_q_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) if (atomic_read(&qdio->req_q_free) <= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) atomic_inc(&qdio->req_q_full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) if (scsi_cmnd->sc_data_direction == DMA_TO_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) sbtype = SBAL_SFLAGS0_TYPE_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) sbtype, adapter->pool.scsi_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) retval = PTR_ERR(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) scsi_cmnd->host_scribble = (unsigned char *) req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) io = &req->qtcb->bottom.io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) req->data = scsi_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) req->handler = zfcp_fsf_fcp_cmnd_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) req->qtcb->header.port_handle = zfcp_sdev->port->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) io->service_class = FSF_CLASS_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) io->fcp_cmnd_length = FCP_CMND_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) if (scsi_get_prot_op(scsi_cmnd) != SCSI_PROT_NORMAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) io->data_block_length = scsi_cmnd->device->sector_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) io->ref_tag_value = scsi_get_lba(scsi_cmnd) & 0xFFFFFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) if (zfcp_fsf_set_data_dir(scsi_cmnd, &io->data_direction))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) goto failed_scsi_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) BUILD_BUG_ON(sizeof(struct fcp_cmnd) > FSF_FCP_CMND_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) fcp_cmnd = &req->qtcb->bottom.io.fcp_cmnd.iu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) if ((scsi_get_prot_op(scsi_cmnd) != SCSI_PROT_NORMAL) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) scsi_prot_sg_count(scsi_cmnd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) zfcp_qdio_set_data_div(qdio, &req->qdio_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) scsi_prot_sg_count(scsi_cmnd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) retval = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) scsi_prot_sglist(scsi_cmnd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) goto failed_scsi_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) io->prot_data_length = zfcp_qdio_real_bytes(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) scsi_prot_sglist(scsi_cmnd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) retval = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) scsi_sglist(scsi_cmnd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) if (unlikely(retval))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) goto failed_scsi_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) zfcp_qdio_set_sbale_last(adapter->qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) if (zfcp_adapter_multi_buffer_active(adapter))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) zfcp_qdio_set_scount(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) retval = zfcp_fsf_req_send(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) if (unlikely(retval))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) goto failed_scsi_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) failed_scsi_cmnd:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) scsi_cmnd->host_scribble = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) spin_unlock_irqrestore(&qdio->req_q_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) static void zfcp_fsf_fcp_task_mgmt_handler(struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) struct scsi_device *sdev = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) struct fcp_resp_with_ext *fcp_rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) struct fcp_resp_rsp_info *rsp_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) zfcp_fsf_fcp_handler_common(req, sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) fcp_rsp = &req->qtcb->bottom.io.fcp_rsp.iu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) rsp_info = (struct fcp_resp_rsp_info *) &fcp_rsp[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) if ((rsp_info->rsp_code != FCP_TMF_CMPL) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) (req->status & ZFCP_STATUS_FSFREQ_ERROR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) * zfcp_fsf_fcp_task_mgmt() - Send SCSI task management command (TMF).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) * @sdev: Pointer to SCSI device to send the task management command to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) * @tm_flags: Unsigned byte for task management flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) * Return: On success pointer to struct zfcp_fsf_req, %NULL otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) struct zfcp_fsf_req *zfcp_fsf_fcp_task_mgmt(struct scsi_device *sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) u8 tm_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) struct zfcp_fsf_req *req = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) struct fcp_cmnd *fcp_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) struct zfcp_qdio *qdio = zfcp_sdev->port->adapter->qdio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) if (unlikely(!(atomic_read(&zfcp_sdev->status) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) ZFCP_STATUS_COMMON_UNBLOCKED)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) spin_lock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) if (zfcp_qdio_sbal_get(qdio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671) req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672) SBAL_SFLAGS0_TYPE_WRITE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) qdio->adapter->pool.scsi_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) if (IS_ERR(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) req = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) req->data = sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) req->handler = zfcp_fsf_fcp_task_mgmt_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) req->qtcb->header.port_handle = zfcp_sdev->port->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) req->qtcb->bottom.io.service_class = FSF_CLASS_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) fcp_cmnd = &req->qtcb->bottom.io.fcp_cmnd.iu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) zfcp_fc_fcp_tm(fcp_cmnd, sdev, tm_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) zfcp_fsf_start_timer(req, ZFCP_FSF_SCSI_ER_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) if (!zfcp_fsf_req_send(req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) /* NOTE: DO NOT TOUCH req, UNTIL IT COMPLETES! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) zfcp_fsf_req_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) req = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) spin_unlock_irq(&qdio->req_q_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) return req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) }
^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) * zfcp_fsf_reqid_check - validate req_id contained in SBAL returned by QDIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) * @qdio: pointer to struct zfcp_qdio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) * @sbal_idx: response queue index of SBAL to be processed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) void zfcp_fsf_reqid_check(struct zfcp_qdio *qdio, int sbal_idx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) struct zfcp_adapter *adapter = qdio->adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) struct qdio_buffer *sbal = qdio->res_q[sbal_idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) struct qdio_buffer_element *sbale;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) struct zfcp_fsf_req *fsf_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) unsigned long req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) for (idx = 0; idx < QDIO_MAX_ELEMENTS_PER_BUFFER; idx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) sbale = &sbal->element[idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) req_id = sbale->addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) fsf_req = zfcp_reqlist_find_rm(adapter->req_list, req_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) if (!fsf_req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) * Unknown request means that we have potentially memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) * corruption and must stop the machine immediately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) zfcp_qdio_siosl(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) panic("error: unknown req_id (%lx) on adapter %s.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) req_id, dev_name(&adapter->ccw_device->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) zfcp_fsf_req_complete(fsf_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) if (likely(sbale->eflags & SBAL_EFLAGS_LAST_ENTRY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) }