/* timeout for FSF requests sent during scsi_eh: abort or FCP TMF */ #define ZFCP_FSF_SCSI_ER_TIMEOUT (10*HZ) /* timeout for: exchange config/port data outside ERP, or open/close WKA port */ #define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ)
struct kmem_cache *zfcp_fsf_qtcb_cache;
staticbool ber_stop = true;
module_param(ber_stop, bool, 0600);
MODULE_PARM_DESC(ber_stop, "Shuts down FCP devices for FCP channels that report a bit-error count in excess of its threshold (default on)");
staticvoid zfcp_fsf_class_not_supp(struct zfcp_fsf_req *req)
{
dev_err(&req->adapter->ccw_device->dev, "FCP device not " "operational because of an unsupported FC class\n");
zfcp_erp_adapter_shutdown(req->adapter, 0, "fscns_1");
req->status |= ZFCP_STATUS_FSFREQ_ERROR;
}
/** * zfcp_fsf_req_free - free memory used by fsf request * @req: pointer to struct zfcp_fsf_req
*/ void zfcp_fsf_req_free(struct zfcp_fsf_req *req)
{ if (likely(req->pool)) { if (likely(!zfcp_fsf_req_is_status_read_buffer(req)))
mempool_free(req->qtcb, req->adapter->pool.qtcb_pool);
mempool_free(req, req->pool); return;
}
if (likely(!zfcp_fsf_req_is_status_read_buffer(req)))
kmem_cache_free(zfcp_fsf_qtcb_cache, req->qtcb);
kfree(req);
}
switch (link_down->error_code) { case FSF_PSQ_LINK_NO_LIGHT:
dev_warn(&req->adapter->ccw_device->dev, "There is no light signal from the local " "fibre channel cable\n"); break; case FSF_PSQ_LINK_WRAP_PLUG:
dev_warn(&req->adapter->ccw_device->dev, "There is a wrap plug instead of a fibre " "channel cable\n"); break; case FSF_PSQ_LINK_NO_FCP:
dev_warn(&req->adapter->ccw_device->dev, "The adjacent fibre channel node does not " "support FCP\n"); break; case FSF_PSQ_LINK_FIRMWARE_UPDATE:
dev_warn(&req->adapter->ccw_device->dev, "The FCP device is suspended because of a " "firmware update\n"); break; case FSF_PSQ_LINK_INVALID_WWPN:
dev_warn(&req->adapter->ccw_device->dev, "The FCP device detected a WWPN that is " "duplicate or not valid\n"); break; case FSF_PSQ_LINK_NO_NPIV_SUPPORT:
dev_warn(&req->adapter->ccw_device->dev, "The fibre channel fabric does not support NPIV\n"); break; case FSF_PSQ_LINK_NO_FCP_RESOURCES:
dev_warn(&req->adapter->ccw_device->dev, "The FCP adapter cannot support more NPIV ports\n"); break; case FSF_PSQ_LINK_NO_FABRIC_RESOURCES:
dev_warn(&req->adapter->ccw_device->dev, "The adjacent switch cannot support " "more NPIV ports\n"); break; case FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE:
dev_warn(&req->adapter->ccw_device->dev, "The FCP adapter could not log in to the " "fibre channel fabric\n"); break; case FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED:
dev_warn(&req->adapter->ccw_device->dev, "The WWPN assignment file on the FCP adapter " "has been damaged\n"); break; case FSF_PSQ_LINK_MODE_TABLE_CURRUPTED:
dev_warn(&req->adapter->ccw_device->dev, "The mode table on the FCP adapter " "has been damaged\n"); break; case FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT:
dev_warn(&req->adapter->ccw_device->dev, "All NPIV ports on the FCP adapter have " "been assigned\n"); break; default:
dev_warn(&req->adapter->ccw_device->dev, "The link between the FCP adapter and " "the FC fabric is down\n");
}
out:
zfcp_erp_set_adapter_status(adapter, ZFCP_STATUS_COMMON_ERP_FAILED);
}
switch (sr_buf->status_type) { case FSF_STATUS_READ_PORT_CLOSED:
zfcp_fsf_status_read_port_closed(req); break; case FSF_STATUS_READ_INCOMING_ELS:
zfcp_fc_incoming_els(req); break; case FSF_STATUS_READ_SENSE_DATA_AVAIL: break; case FSF_STATUS_READ_BIT_ERROR_THRESHOLD:
zfcp_dbf_hba_bit_err("fssrh_3", req); if (ber_stop) {
dev_warn(&adapter->ccw_device->dev, "All paths over this FCP device are disused because of excessive bit errors\n");
zfcp_erp_adapter_shutdown(adapter, 0, "fssrh_b");
} else {
dev_warn(&adapter->ccw_device->dev, "The error threshold for checksum statistics has been exceeded\n");
} break; case FSF_STATUS_READ_LINK_DOWN:
zfcp_fsf_status_read_link_down(req);
zfcp_fc_enqueue_event(adapter, FCH_EVT_LINKDOWN, 0); break; case FSF_STATUS_READ_LINK_UP:
dev_info(&adapter->ccw_device->dev, "The local link has been restored\n"); /* All ports should be marked as ready to run again */
zfcp_erp_set_adapter_status(adapter,
ZFCP_STATUS_COMMON_RUNNING);
zfcp_erp_adapter_reopen(adapter,
ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
ZFCP_STATUS_COMMON_ERP_FAILED, "fssrh_2");
zfcp_fc_enqueue_event(adapter, FCH_EVT_LINKUP, 0);
break; case FSF_STATUS_READ_NOTIFICATION_LOST: if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_INCOMING_ELS)
zfcp_fc_conditional_port_scan(adapter); if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_VERSION_CHANGE)
queue_work(adapter->work_queue,
&adapter->version_change_lost_work); break; case FSF_STATUS_READ_FEATURE_UPDATE_ALERT:
adapter->adapter_features = sr_buf->payload.word[0]; break; case FSF_STATUS_READ_VERSION_CHANGE:
zfcp_fsf_status_read_version_change(adapter, sr_buf); break;
}
staticvoid zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *req)
{ switch (req->qtcb->header.fsf_status_qual.word[0]) { case FSF_SQ_FCP_RSP_AVAILABLE: case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: case FSF_SQ_NO_RETRY_POSSIBLE: case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: return; case FSF_SQ_COMMAND_ABORTED: break; case FSF_SQ_NO_RECOM:
dev_err(&req->adapter->ccw_device->dev, "The FCP adapter reported a problem " "that cannot be recovered\n");
zfcp_qdio_siosl(req->adapter);
zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfsqe1"); break;
} /* all non-return stats set FSFREQ_ERROR*/
req->status |= ZFCP_STATUS_FSFREQ_ERROR;
}
staticvoid zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *req)
{ if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR)) return;
switch (req->qtcb->header.fsf_status) { case FSF_UNKNOWN_COMMAND:
dev_err(&req->adapter->ccw_device->dev, "The FCP adapter does not recognize the command 0x%x\n",
req->qtcb->header.fsf_command);
zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfse_1");
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; case FSF_ADAPTER_STATUS_AVAILABLE:
zfcp_fsf_fsfstatus_qual_eval(req); break;
}
}
if (req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
req->status |= ZFCP_STATUS_FSFREQ_ERROR; return;
}
switch (qtcb->prefix.prot_status) { case FSF_PROT_GOOD: case FSF_PROT_FSF_STATUS_PRESENTED: return; case FSF_PROT_QTCB_VERSION_ERROR:
dev_err(&adapter->ccw_device->dev, "QTCB version 0x%x not supported by FCP adapter " "(0x%x to 0x%x)\n", FSF_QTCB_CURRENT_VERSION,
psq->word[0], psq->word[1]);
zfcp_erp_adapter_shutdown(adapter, 0, "fspse_1"); break; case FSF_PROT_ERROR_STATE: case FSF_PROT_SEQ_NUMB_ERROR:
zfcp_erp_adapter_reopen(adapter, 0, "fspse_2");
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; case FSF_PROT_UNSUPP_QTCB_TYPE:
dev_err(&adapter->ccw_device->dev, "The QTCB type is not supported by the FCP adapter\n");
zfcp_erp_adapter_shutdown(adapter, 0, "fspse_3"); break; case FSF_PROT_HOST_CONNECTION_INITIALIZING:
atomic_or(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
&adapter->status); break; case FSF_PROT_DUPLICATE_REQUEST_ID:
dev_err(&adapter->ccw_device->dev, "0x%Lx is an ambiguous request identifier\n",
(unsignedlonglong)qtcb->bottom.support.req_handle);
zfcp_erp_adapter_shutdown(adapter, 0, "fspse_4"); break; case FSF_PROT_LINK_DOWN:
zfcp_fsf_link_down_info_eval(req, &psq->link_down_info); /* go through reopen to flush pending requests */
zfcp_erp_adapter_reopen(adapter, 0, "fspse_6"); break; case FSF_PROT_REEST_QUEUE: /* All ports should be marked as ready to run again */
zfcp_erp_set_adapter_status(adapter,
ZFCP_STATUS_COMMON_RUNNING);
zfcp_erp_adapter_reopen(adapter,
ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
ZFCP_STATUS_COMMON_ERP_FAILED, "fspse_8"); break; default:
dev_err(&adapter->ccw_device->dev, "0x%x is not a valid transfer protocol status\n",
qtcb->prefix.prot_status);
zfcp_qdio_siosl(adapter);
zfcp_erp_adapter_shutdown(adapter, 0, "fspse_9");
}
req->status |= ZFCP_STATUS_FSFREQ_ERROR;
}
/** * zfcp_fsf_req_complete - process completion of a FSF request * @req: The FSF request that has been completed. * * When a request has been completed either from the FCP adapter, * or it has been dismissed due to a queue shutdown, this function * is called to process the completion status and trigger further * events related to the FSF request. * Caller must ensure that the request has been removed from * adapter->req_list, to protect against concurrent modification * by zfcp_erp_strategy_check_fsfreq().
*/ staticvoid zfcp_fsf_req_complete(struct zfcp_fsf_req *req)
{ struct zfcp_erp_action *erp_action;
if (unlikely(zfcp_fsf_req_is_status_read_buffer(req))) {
zfcp_fsf_status_read_handler(req); return;
}
erp_action = req->erp_action; if (erp_action)
zfcp_erp_notify(erp_action, 0);
if (likely(req->status & ZFCP_STATUS_FSFREQ_CLEANUP))
zfcp_fsf_req_free(req); else
complete(&req->completion);
}
/** * zfcp_fsf_req_dismiss_all - dismiss all fsf requests * @adapter: pointer to struct zfcp_adapter * * Never ever call this without shutting down the adapter first. * Otherwise the adapter would continue using and corrupting s390 storage. * Included BUG_ON() call to ensure this is done. * ERP is supposed to be the only user of this function.
*/ void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter)
{ struct zfcp_fsf_req *req, *tmp;
LIST_HEAD(remove_queue);
/* no error return above here, otherwise must fix call chains */ /* do not evaluate invalid fields */ if (req->qtcb->header.fsf_status == FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE) return 0;
adapter->hydra_version = bottom->adapter_type;
switch (bottom->fc_topology) { case FSF_TOPO_P2P:
adapter->peer_d_id = ntoh24(bottom->peer_d_id);
adapter->peer_wwpn = be64_to_cpu(plogi->fl_wwpn);
adapter->peer_wwnn = be64_to_cpu(plogi->fl_wwnn); break; case FSF_TOPO_FABRIC: break; case FSF_TOPO_AL: default:
dev_err(&adapter->ccw_device->dev, "Unknown or unsupported arbitrated loop " "fibre channel topology detected\n");
zfcp_erp_adapter_shutdown(adapter, 0, "fsece_1"); return -EIO;
}
switch (qtcb->header.fsf_status) { case FSF_GOOD: /* * usually we wait with an update till the cache is too old, * but because we have the data available, update it anyway
*/
zfcp_diag_update_xdata(diag_hdr, bottom, false);
zfcp_scsi_shost_update_config_data(adapter, bottom, false); if (zfcp_fsf_exchange_config_evaluate(req)) return;
if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) {
dev_err(&adapter->ccw_device->dev, "FCP adapter maximum QTCB size (%d bytes) " "is too small\n",
bottom->max_qtcb_size);
zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh1"); return;
}
atomic_or(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
&adapter->status); break; case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
zfcp_diag_update_xdata(diag_hdr, bottom, true);
req->status |= ZFCP_STATUS_FSFREQ_XDATAINCOMPLETE;
/* avoids adapter shutdown to be able to recognize
* events such as LINK UP */
atomic_or(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
&adapter->status);
zfcp_fsf_link_down_info_eval(req,
&qtcb->header.fsf_status_qual.link_down_info);
if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)
adapter->hardware_version = bottom->hardware_version;
if (FSF_QTCB_CURRENT_VERSION < bottom->low_qtcb_version) {
dev_err(&adapter->ccw_device->dev, "The FCP adapter only supports newer " "control block versions\n");
zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh4"); return;
} if (FSF_QTCB_CURRENT_VERSION > bottom->high_qtcb_version) {
dev_err(&adapter->ccw_device->dev, "The FCP adapter only supports older " "control block versions\n");
zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh5");
}
}
/* * Mapping of FC Endpoint Security flag masks to mnemonics * * NOTE: Update macro ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH when making any * changes.
*/ staticconststruct {
u32 mask; char *name;
} zfcp_fsf_fc_security_mnemonics[] = {
{ FSF_FC_SECURITY_AUTH, "Authentication" },
{ FSF_FC_SECURITY_ENC_FCSP2 |
FSF_FC_SECURITY_ENC_ERAS, "Encryption" },
};
/* maximum strlen(zfcp_fsf_fc_security_mnemonics[...].name) + 1 */ #define ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH 15
/** * zfcp_fsf_scnprint_fc_security() - translate FC Endpoint Security flags into * mnemonics and place in a buffer * @buf : the buffer to place the translated FC Endpoint Security flag(s) * into * @size : the size of the buffer, including the trailing null space * @fc_security: one or more FC Endpoint Security flags, or zero * @fmt : specifies whether a list or a single item is to be put into the * buffer * * The Fibre Channel (FC) Endpoint Security flags are translated into mnemonics. * If the FC Endpoint Security flags are zero "none" is placed into the buffer. * * With ZFCP_FSF_PRINT_FMT_LIST the mnemonics are placed as a list separated by * a comma followed by a space into the buffer. If one or more FC Endpoint * Security flags cannot be translated into a mnemonic, as they are undefined * in zfcp_fsf_fc_security_mnemonics, their bitwise ORed value in hexadecimal * representation is placed into the buffer. * * With ZFCP_FSF_PRINT_FMT_SINGLEITEM only one single mnemonic is placed into * the buffer. If the FC Endpoint Security flag cannot be translated, as it is * undefined in zfcp_fsf_fc_security_mnemonics, its value in hexadecimal * representation is placed into the buffer. If more than one FC Endpoint * Security flag was specified, their value in hexadecimal representation is * placed into the buffer. The macro ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH * can be used to define a buffer that is large enough to hold one mnemonic. * * Return: The number of characters written into buf not including the trailing * '\0'. If size is == 0 the function returns 0.
*/
ssize_t zfcp_fsf_scnprint_fc_security(char *buf, size_t size, u32 fc_security, enum zfcp_fsf_print_fmt fmt)
{ constchar *prefix = "";
ssize_t len = 0; int i;
if (req->status & ZFCP_STATUS_FSFREQ_ERROR) return;
switch (qtcb->header.fsf_status) { case FSF_GOOD: /* * usually we wait with an update till the cache is too old, * but because we have the data available, update it anyway
*/
zfcp_diag_update_xdata(diag_hdr, bottom, false);
/* * NOTE: DO NOT TOUCH ASYNC req PAST THIS POINT. * ONLY TOUCH SYNC req AGAIN ON req->completion. * * The request might complete and be freed concurrently at any point * now. This is not protected by the QDIO-lock (req_q_lock). So any * uncontrolled access after this might result in an use-after-free bug. * Only if the request doesn't have ZFCP_STATUS_FSFREQ_CLEANUP set, and * when it is completed via req->completion, is it safe to use req * again.
*/
/* Don't increase for unsolicited status */ if (!is_srb)
adapter->fsf_req_seq_no++;
adapter->req_no++;
return 0;
}
/** * zfcp_fsf_status_read - send status read request * @qdio: pointer to struct zfcp_qdio * Returns: 0 on success, ERROR otherwise
*/ int zfcp_fsf_status_read(struct zfcp_qdio *qdio)
{ struct zfcp_adapter *adapter = qdio->adapter; struct zfcp_fsf_req *req; struct fsf_status_read_buffer *sr_buf; struct page *page; int retval = -EIO;
spin_lock_irq(&qdio->req_q_lock); if (zfcp_qdio_sbal_get(qdio)) goto out;
if (req->status & ZFCP_STATUS_FSFREQ_ERROR) goto skip_fsfstatus;
switch (header->fsf_status) { case FSF_GOOD:
ct->status = 0;
zfcp_dbf_san_res("fsscth2", req); break; case FSF_SERVICE_CLASS_NOT_SUPPORTED:
zfcp_fsf_class_not_supp(req); break; case FSF_ADAPTER_STATUS_AVAILABLE: switch (header->fsf_status_qual.word[0]){ case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break;
} break; case FSF_PORT_BOXED:
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; case FSF_PORT_HANDLE_NOT_VALID:
zfcp_erp_adapter_reopen(adapter, 0, "fsscth1");
fallthrough; case FSF_GENERIC_COMMAND_REJECTED: case FSF_PAYLOAD_SIZE_MISMATCH: case FSF_REQUEST_SIZE_TOO_LARGE: case FSF_RESPONSE_SIZE_TOO_LARGE: case FSF_SBAL_MISMATCH:
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break;
}
skip_fsfstatus: if (ct->handler)
ct->handler(ct->handler_data);
}
/* use single, unchained SBAL if it can hold the request */ if (zfcp_qdio_sg_one_sbale(sg_req) && zfcp_qdio_sg_one_sbale(sg_resp)) {
zfcp_fsf_setup_ct_els_unchained(qdio, &req->qdio_req,
sg_req, sg_resp); return 0;
}
if (!(feat & FSF_FEATURE_ELS_CT_CHAINED_SBALS)) return -EOPNOTSUPP;
if (zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sg_req)) return -EIO;
ret = zfcp_fsf_setup_ct_els_sbals(req, sg_req, sg_resp); if (ret) return ret;
/* common settings for ct/gs and els requests */ if (timeout > 255)
timeout = 255; /* max value accepted by hardware */
req->qtcb->bottom.support.service_class = FSF_CLASS_3;
req->qtcb->bottom.support.timeout = timeout;
zfcp_fsf_start_timer(req, (timeout + 10) * HZ);
return 0;
}
/** * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS) * @wka_port: pointer to zfcp WKA port to send CT/GS to * @ct: pointer to struct zfcp_fsf_ct_els with data for CT request * @pool: if non-null this mempool is used to allocate struct zfcp_fsf_req * @timeout: timeout that hardware should use, and a later software timeout
*/ int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *wka_port, struct zfcp_fsf_ct_els *ct, mempool_t *pool, unsignedint timeout)
{ struct zfcp_qdio *qdio = wka_port->adapter->qdio; struct zfcp_fsf_req *req; int ret = -EIO;
spin_lock_irq(&qdio->req_q_lock); if (zfcp_qdio_sbal_get(qdio)) goto out;
if (req->status & ZFCP_STATUS_FSFREQ_ERROR) goto skip_fsfstatus;
switch (header->fsf_status) { case FSF_GOOD:
send_els->status = 0;
zfcp_dbf_san_res("fsselh1", req); break; case FSF_SERVICE_CLASS_NOT_SUPPORTED:
zfcp_fsf_class_not_supp(req); break; case FSF_ADAPTER_STATUS_AVAILABLE: switch (header->fsf_status_qual.word[0]){ case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: case FSF_SQ_RETRY_IF_POSSIBLE:
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break;
} break; case FSF_ELS_COMMAND_REJECTED: case FSF_PAYLOAD_SIZE_MISMATCH: case FSF_REQUEST_SIZE_TOO_LARGE: case FSF_RESPONSE_SIZE_TOO_LARGE: break; case FSF_SBAL_MISMATCH: /* should never occur, avoided in zfcp_fsf_send_els */
fallthrough; default:
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break;
}
skip_fsfstatus: if (send_els->handler)
send_els->handler(send_els->handler_data);
}
/** * zfcp_fsf_send_els - initiate an ELS command (FC-FS) * @adapter: pointer to zfcp adapter * @d_id: N_Port_ID to send ELS to * @els: pointer to struct zfcp_fsf_ct_els with data for the ELS command * @timeout: timeout that hardware should use, and a later software timeout
*/ int zfcp_fsf_send_els(struct zfcp_adapter *adapter, u32 d_id, struct zfcp_fsf_ct_els *els, unsignedint timeout)
{ struct zfcp_fsf_req *req; struct zfcp_qdio *qdio = adapter->qdio; int ret = -EIO;
spin_lock_irq(&qdio->req_q_lock); if (zfcp_qdio_sbal_get(qdio)) goto out;
zfcp_fsf_start_erp_timer(req);
retval = zfcp_fsf_req_send(req); if (retval) {
zfcp_fsf_req_free(req);
erp_action->fsf_req_id = 0;
} /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
out:
spin_unlock_irq(&qdio->req_q_lock); return retval;
}
/** * zfcp_fsf_exchange_config_data_sync() - Request information about FCP channel. * @qdio: pointer to the QDIO-Queue to use for sending the command. * @data: pointer to the QTCB-Bottom for storing the result of the command, * might be %NULL. * * Returns: * * 0 - Exchange Config Data was successful, @data is complete * * -EIO - Exchange Config Data was not successful, @data is invalid * * -EAGAIN - @data contains incomplete data * * -ENOMEM - Some memory allocation failed along the way
*/ int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio, struct fsf_qtcb_bottom_config *data)
{ struct zfcp_fsf_req *req = NULL; int retval = -EIO;
spin_lock_irq(&qdio->req_q_lock); if (zfcp_qdio_sbal_get(qdio)) goto out_unlock;
/** * zfcp_fsf_exchange_port_data - request information about local port * @erp_action: ERP action for the adapter for which port data is requested * Returns: 0 on success, error otherwise
*/ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
{ struct zfcp_qdio *qdio = erp_action->adapter->qdio; struct zfcp_fsf_req *req; int retval = -EIO;
if (!(qdio->adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) return -EOPNOTSUPP;
spin_lock_irq(&qdio->req_q_lock); if (zfcp_qdio_sbal_get(qdio)) goto out;
zfcp_fsf_start_erp_timer(req);
retval = zfcp_fsf_req_send(req); if (retval) {
zfcp_fsf_req_free(req);
erp_action->fsf_req_id = 0;
} /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
out:
spin_unlock_irq(&qdio->req_q_lock); return retval;
}
/** * zfcp_fsf_exchange_port_data_sync() - Request information about local port. * @qdio: pointer to the QDIO-Queue to use for sending the command. * @data: pointer to the QTCB-Bottom for storing the result of the command, * might be %NULL. * * Returns: * * 0 - Exchange Port Data was successful, @data is complete * * -EIO - Exchange Port Data was not successful, @data is invalid * * -EAGAIN - @data contains incomplete data * * -ENOMEM - Some memory allocation failed along the way * * -EOPNOTSUPP - This operation is not supported
*/ int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio, struct fsf_qtcb_bottom_port *data)
{ struct zfcp_fsf_req *req = NULL; int retval = -EIO;
if (!(qdio->adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) return -EOPNOTSUPP;
spin_lock_irq(&qdio->req_q_lock); if (zfcp_qdio_sbal_get(qdio)) goto out_unlock;
if (strncmp(mnemonic_old, mnemonic_new,
ZFCP_FSF_MAX_FC_SECURITY_MNEMONIC_LENGTH) == 0) { /* no change in string representation, no log */ goto out;
}
if (port->connection_info_old == 0) { /* activation */
dev_info(&port->adapter->ccw_device->dev, "FC Endpoint Security of connection to remote port 0x%16llx enabled: %s\n",
port->wwpn, mnemonic_new);
} elseif (port->connection_info == 0) { /* deactivation */
dev_warn(&port->adapter->ccw_device->dev, "FC Endpoint Security of connection to remote port 0x%16llx disabled: was %s\n",
port->wwpn, mnemonic_old);
} else { /* change */
dev_warn(&port->adapter->ccw_device->dev, "FC Endpoint Security of connection to remote port 0x%16llx changed: from %s to %s\n",
port->wwpn, mnemonic_old, mnemonic_new);
}
case FSF_SQ_SECURITY_REQUIRED:
dev_warn_ratelimited(dev, "FC Endpoint Security error: FC security is required but not supported or configured on remote port 0x%016llx\n",
wwpn); break; case FSF_SQ_SECURITY_TIMEOUT:
dev_warn_ratelimited(dev, "FC Endpoint Security error: a timeout prevented opening remote port 0x%016llx\n",
wwpn); break; case FSF_SQ_SECURITY_KM_UNAVAILABLE:
dev_warn_ratelimited(dev, "FC Endpoint Security error: opening remote port 0x%016llx failed because local and external key manager cannot communicate\n",
wwpn); break; case FSF_SQ_SECURITY_RKM_UNAVAILABLE:
dev_warn_ratelimited(dev, "FC Endpoint Security error: opening remote port 0x%016llx failed because it cannot communicate with the external key manager\n",
wwpn); break; case FSF_SQ_SECURITY_AUTH_FAILURE:
dev_warn_ratelimited(dev, "FC Endpoint Security error: the device could not verify the identity of remote port 0x%016llx\n",
wwpn); break;
/* * Send FCP command error codes
*/
case FSF_SQ_SECURITY_ENC_FAILURE:
dev_warn_ratelimited(dev, "FC Endpoint Security error: FC connection to remote port 0x%016llx closed because encryption broke down\n",
wwpn); break;
/* * Unknown error codes
*/
default:
dev_warn_ratelimited(dev, "FC Endpoint Security error: the device issued an unknown error code 0x%08x related to the FC connection to remote port 0x%016llx\n",
fsf_sqw0, wwpn);
}
}
if (req->status & ZFCP_STATUS_FSFREQ_ERROR) goto out;
switch (header->fsf_status) { case FSF_PORT_ALREADY_OPEN: break; case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
dev_warn(&adapter->ccw_device->dev, "Not enough FCP adapter resources to open " "remote port 0x%016Lx\n",
(unsignedlonglong)port->wwpn);
zfcp_erp_set_port_status(port,
ZFCP_STATUS_COMMON_ERP_FAILED);
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; case FSF_SECURITY_ERROR:
zfcp_fsf_log_security_error(&req->adapter->ccw_device->dev,
header->fsf_status_qual.word[0],
port->wwpn);
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; case FSF_ADAPTER_STATUS_AVAILABLE: switch (header->fsf_status_qual.word[0]) { case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: /* no zfcp_fc_test_link() with failed open port */
fallthrough; case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: case FSF_SQ_NO_RETRY_POSSIBLE:
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break;
} break; case FSF_GOOD:
port->handle = header->port_handle; if (adapter->adapter_features & FSF_FEATURE_FC_SECURITY)
port->connection_info = bottom->connection_info; else
port->connection_info = 0;
zfcp_fsf_log_port_fc_security(port, req);
atomic_or(ZFCP_STATUS_COMMON_OPEN |
ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
atomic_andnot(ZFCP_STATUS_COMMON_ACCESS_BOXED,
&port->status); /* check whether D_ID has changed during open */ /* * FIXME: This check is not airtight, as the FCP channel does * not monitor closures of target port connections caused on * the remote side. Thus, they might miss out on invalidating * locally cached WWPNs (and other N_Port parameters) of gone * target ports. So, our heroic attempt to make things safe * could be undermined by 'open port' response data tagged with * obsolete WWPNs. Another reason to monitor potential * connection closures ourself at least (by interpreting * incoming ELS' and unsolicited status). It just crosses my * mind that one should be able to cross-check by means of * another GID_PN straight after a port has been opened. * Alternately, an ADISC/PDISC ELS should suffice, as well.
*/
plogi = (struct fc_els_flogi *) bottom->els; if (bottom->els1_length >= FSF_PLOGI_MIN_LEN)
zfcp_fc_plogi_evaluate(port, plogi); break; case FSF_UNKNOWN_OP_SUBTYPE:
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break;
}
out:
put_device(&port->dev);
}
/** * zfcp_fsf_open_port - create and send open port request * @erp_action: pointer to struct zfcp_erp_action * Returns: 0 on success, error otherwise
*/ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
{ struct zfcp_qdio *qdio = erp_action->adapter->qdio; struct zfcp_port *port = erp_action->port; struct zfcp_fsf_req *req; int retval = -EIO;
spin_lock_irq(&qdio->req_q_lock); if (zfcp_qdio_sbal_get(qdio)) goto out;
zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
retval = zfcp_fsf_req_send(req); if (retval)
zfcp_fsf_req_free(req); /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
out:
spin_unlock_irq(&qdio->req_q_lock); if (!retval)
zfcp_dbf_rec_run_wka("fsowp_1", wka_port, req_id); return retval;
}
zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
retval = zfcp_fsf_req_send(req); if (retval)
zfcp_fsf_req_free(req); /* NOTE: DO NOT TOUCH req PAST THIS POINT! */
out:
spin_unlock_irq(&qdio->req_q_lock); if (!retval)
zfcp_dbf_rec_run_wka("fscwp_1", wka_port, req_id); return retval;
}
if (req->status & ZFCP_STATUS_FSFREQ_ERROR) return;
switch (header->fsf_status) { case FSF_PORT_HANDLE_NOT_VALID:
zfcp_erp_adapter_reopen(port->adapter, 0, "fscpph1");
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; case FSF_PORT_BOXED: /* can't use generic zfcp_erp_modify_port_status because
* ZFCP_STATUS_COMMON_OPEN must not be reset for the port */
atomic_andnot(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
shost_for_each_device(sdev, port->adapter->scsi_host) if (sdev_to_zfcp(sdev)->port == port)
atomic_andnot(ZFCP_STATUS_COMMON_OPEN,
&sdev_to_zfcp(sdev)->status);
zfcp_erp_set_port_status(port, ZFCP_STATUS_COMMON_ACCESS_BOXED);
zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, "fscpph2");
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; case FSF_ADAPTER_STATUS_AVAILABLE: switch (header->fsf_status_qual.word[0]) { case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break;
} break; case FSF_GOOD: /* can't use generic zfcp_erp_modify_port_status because * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
*/
atomic_andnot(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
shost_for_each_device(sdev, port->adapter->scsi_host) if (sdev_to_zfcp(sdev)->port == port)
atomic_andnot(ZFCP_STATUS_COMMON_OPEN,
&sdev_to_zfcp(sdev)->status); break;
}
}
/** * zfcp_fsf_close_physical_port - close physical port * @erp_action: pointer to struct zfcp_erp_action * Returns: 0 on success
*/ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
{ struct zfcp_qdio *qdio = erp_action->adapter->qdio; struct zfcp_fsf_req *req; int retval = -EIO;
spin_lock_irq(&qdio->req_q_lock); if (zfcp_qdio_sbal_get(qdio)) goto out;
case FSF_PORT_HANDLE_NOT_VALID:
zfcp_erp_adapter_reopen(adapter, 0, "fsouh_1");
fallthrough; case FSF_LUN_ALREADY_OPEN: break; case FSF_PORT_BOXED:
zfcp_erp_set_port_status(zfcp_sdev->port,
ZFCP_STATUS_COMMON_ACCESS_BOXED);
zfcp_erp_port_reopen(zfcp_sdev->port,
ZFCP_STATUS_COMMON_ERP_FAILED, "fsouh_2");
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; case FSF_LUN_SHARING_VIOLATION: if (qual->word[0])
dev_warn(&zfcp_sdev->port->adapter->ccw_device->dev, "LUN 0x%016Lx on port 0x%016Lx is already in " "use by CSS%d, MIF Image ID %x\n",
zfcp_scsi_dev_lun(sdev),
(unsignedlonglong)zfcp_sdev->port->wwpn,
qual->fsf_queue_designator.cssid,
qual->fsf_queue_designator.hla);
zfcp_erp_set_lun_status(sdev,
ZFCP_STATUS_COMMON_ERP_FAILED |
ZFCP_STATUS_COMMON_ACCESS_DENIED);
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED:
dev_warn(&adapter->ccw_device->dev, "No handle is available for LUN " "0x%016Lx on port 0x%016Lx\n",
(unsignedlonglong)zfcp_scsi_dev_lun(sdev),
(unsignedlonglong)zfcp_sdev->port->wwpn);
zfcp_erp_set_lun_status(sdev, ZFCP_STATUS_COMMON_ERP_FAILED);
fallthrough; case FSF_INVALID_COMMAND_OPTION:
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; case FSF_ADAPTER_STATUS_AVAILABLE: switch (header->fsf_status_qual.word[0]) { case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
zfcp_fc_test_link(zfcp_sdev->port);
fallthrough; case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
req->status |= ZFCP_STATUS_FSFREQ_ERROR; break;
} break;
case FSF_GOOD:
zfcp_sdev->lun_handle = header->lun_handle;
atomic_or(ZFCP_STATUS_COMMON_OPEN, &zfcp_sdev->status); break;
}
}
/** * zfcp_fsf_open_lun - open LUN * @erp_action: pointer to struct zfcp_erp_action * Returns: 0 on success, error otherwise
*/ int zfcp_fsf_open_lun(struct zfcp_erp_action *erp_action)
{ struct zfcp_adapter *adapter = erp_action->adapter; struct zfcp_qdio *qdio = adapter->qdio; struct zfcp_fsf_req *req; int retval = -EIO;
spin_lock_irq(&qdio->req_q_lock); if (zfcp_qdio_sbal_get(qdio)) goto out;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.