zfcp_fsf.c

来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 1,995 行 · 第 1/5 页

C
1,995
字号
		zfcp_cmd_dbf_event_fsf("unsqtcbt", fsf_req,				       &fsf_req->qtcb->prefix.prot_status_qual,				       sizeof (union fsf_prot_status_qual));		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_PROT_HOST_CONNECTION_INITIALIZING:		ZFCP_LOG_FLAGS(1, "FSF_PROT_HOST_CONNECTION_INITIALIZING\n");		zfcp_cmd_dbf_event_fsf("hconinit", fsf_req,				       &fsf_req->qtcb->prefix.prot_status_qual,				       sizeof (union fsf_prot_status_qual));		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,				&(adapter->status));		debug_text_event(adapter->erp_dbf, 3, "prot_con_init");		break;	case FSF_PROT_DUPLICATE_REQUEST_ID:		ZFCP_LOG_FLAGS(0, "FSF_PROT_DUPLICATE_REQUEST_IDS\n");		if (fsf_req->qtcb) {			ZFCP_LOG_NORMAL("bug: The request identifier 0x%Lx "					"to the adapter %s is ambiguous. "					"Stopping all operations on this "					"adapter.\n",					*(unsigned long long *)					(&fsf_req->qtcb->bottom.support.					 req_handle),					zfcp_get_busid_by_adapter(adapter));		} else {			ZFCP_LOG_NORMAL("bug: The request identifier %p "					"to the adapter %s is ambiguous. "					"Stopping all operations on this "					"adapter. "					"(bug: got this for an unsolicited "					"status read request)\n",					fsf_req,					zfcp_get_busid_by_adapter(adapter));		}		debug_text_exception(adapter->erp_dbf, 0, "prot_dup_id");		zfcp_erp_adapter_shutdown(adapter, 0);		zfcp_cmd_dbf_event_fsf("dupreqid", fsf_req,				       &fsf_req->qtcb->prefix.prot_status_qual,				       sizeof (union fsf_prot_status_qual));		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_PROT_LINK_DOWN:		ZFCP_LOG_FLAGS(1, "FSF_PROT_LINK_DOWN\n");		/*		 * 'test and set' is not atomic here -		 * it's ok as long as calls to our response queue handler		 * (and thus execution of this code here) are serialized		 * by the qdio module		 */		if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,				      &adapter->status)) {			switch (fsf_req->qtcb->prefix.prot_status_qual.				locallink_error.code) {			case FSF_PSQ_LINK_NOLIGHT:				ZFCP_LOG_INFO("The local link to adapter %s "					      "is down (no light detected).\n",					      zfcp_get_busid_by_adapter(						      adapter));				break;			case FSF_PSQ_LINK_WRAPPLUG:				ZFCP_LOG_INFO("The local link to adapter %s "					      "is down (wrap plug detected).\n",					      zfcp_get_busid_by_adapter(						      adapter));				break;			case FSF_PSQ_LINK_NOFCP:				ZFCP_LOG_INFO("The local link to adapter %s "					      "is down (adjacent node on "					      "link does not support FCP).\n",					      zfcp_get_busid_by_adapter(						      adapter));				break;			default:				ZFCP_LOG_INFO("The local link to adapter %s "					      "is down "					      "(warning: unknown reason "					      "code).\n",					      zfcp_get_busid_by_adapter(						      adapter));				break;			}			/*			 * Due to the 'erp failed' flag the adapter won't			 * be recovered but will be just set to 'blocked'			 * state. All subordinary devices will have state			 * 'blocked' and 'erp failed', too.			 * Thus the adapter is still able to provide			 * 'link up' status without being flooded with			 * requests.			 * (note: even 'close port' is not permitted)			 */			ZFCP_LOG_INFO("Stopping all operations for adapter "				      "%s.\n",				      zfcp_get_busid_by_adapter(adapter));			atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |					ZFCP_STATUS_COMMON_ERP_FAILED,					&adapter->status);			zfcp_erp_adapter_reopen(adapter, 0);			debug_text_event(adapter->erp_dbf, 1, "prot_link_down");		}		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_PROT_REEST_QUEUE:		ZFCP_LOG_FLAGS(1, "FSF_PROT_REEST_QUEUE\n");		debug_text_event(adapter->erp_dbf, 1, "prot_reest_queue");		ZFCP_LOG_INFO("The local link to adapter with "			      "%s was re-plugged. "			      "Re-starting operations on this adapter.\n",			      zfcp_get_busid_by_adapter(adapter));		/* All ports should be marked as ready to run again */		zfcp_erp_modify_adapter_status(adapter,					       ZFCP_STATUS_COMMON_RUNNING,					       ZFCP_SET);		zfcp_erp_adapter_reopen(adapter,					ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED					| ZFCP_STATUS_COMMON_ERP_FAILED);		zfcp_cmd_dbf_event_fsf("reestque", fsf_req,				       &fsf_req->qtcb->prefix.prot_status_qual,				       sizeof (union fsf_prot_status_qual));		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_PROT_ERROR_STATE:		ZFCP_LOG_FLAGS(0, "FSF_PROT_ERROR_STATE\n");		ZFCP_LOG_NORMAL("error: The adapter %s "				"has entered the error state. "				"Restarting all operations on this "				"adapter.\n",				zfcp_get_busid_by_adapter(adapter));		debug_text_event(adapter->erp_dbf, 0, "prot_err_sta");		/* restart operation on this adapter */		zfcp_erp_adapter_reopen(adapter, 0);		zfcp_cmd_dbf_event_fsf("proterrs", fsf_req,				       &fsf_req->qtcb->prefix.prot_status_qual,				       sizeof (union fsf_prot_status_qual));		fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY;		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	default:		ZFCP_LOG_NORMAL("bug: Transfer protocol status information "				"provided by the adapter %s "				"is not compatible with the device driver. "				"Stopping all operations on this adapter. "				"(debug info 0x%x).\n",				zfcp_get_busid_by_adapter(adapter),				fsf_req->qtcb->prefix.prot_status);		debug_text_event(adapter->erp_dbf, 0, "prot_inval:");		debug_exception(adapter->erp_dbf, 0,				&fsf_req->qtcb->prefix.prot_status,				sizeof (u32));		zfcp_erp_adapter_shutdown(adapter, 0);		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;	} skip_protstatus:	/*	 * always call specific handlers to give them a chance to do	 * something meaningful even in error cases	 */	zfcp_fsf_fsfstatus_eval(fsf_req);	return retval;}/* * function:	zfcp_fsf_fsfstatus_eval * * purpose:	evaluates FSF status of completed FSF request *		and acts accordingly * * returns: */static intzfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *fsf_req){	int retval = 0;	if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {		goto skip_fsfstatus;	}	/* evaluate FSF Status */	switch (fsf_req->qtcb->header.fsf_status) {	case FSF_UNKNOWN_COMMAND:		ZFCP_LOG_FLAGS(0, "FSF_UNKNOWN_COMMAND\n");		ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "				"not known by the adapter %s "				"Stopping all operations on this adapter. "				"(debug info 0x%x).\n",				zfcp_get_busid_by_adapter(fsf_req->adapter),				fsf_req->qtcb->header.fsf_command);		debug_text_exception(fsf_req->adapter->erp_dbf, 0,				     "fsf_s_unknown");		zfcp_erp_adapter_shutdown(fsf_req->adapter, 0);		zfcp_cmd_dbf_event_fsf("unknownc", fsf_req,				       &fsf_req->qtcb->header.fsf_status_qual,				       sizeof (union fsf_status_qual));		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_FCP_RSP_AVAILABLE:		ZFCP_LOG_FLAGS(2, "FSF_FCP_RSP_AVAILABLE\n");		ZFCP_LOG_DEBUG("FCP Sense data will be presented to the "			       "SCSI stack.\n");		debug_text_event(fsf_req->adapter->erp_dbf, 3, "fsf_s_rsp");		break;	case FSF_ADAPTER_STATUS_AVAILABLE:		ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");		debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_astatus");		zfcp_fsf_fsfstatus_qual_eval(fsf_req);		break;	default:		break;	} skip_fsfstatus:	/*	 * always call specific handlers to give them a chance to do	 * something meaningful even in error cases	 */	zfcp_fsf_req_dispatch(fsf_req);	return retval;}/* * function:	zfcp_fsf_fsfstatus_qual_eval * * purpose:	evaluates FSF status-qualifier of completed FSF request *		and acts accordingly * * returns: */static intzfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *fsf_req){	int retval = 0;	switch (fsf_req->qtcb->header.fsf_status_qual.word[0]) {	case FSF_SQ_FCP_RSP_AVAILABLE:		ZFCP_LOG_FLAGS(2, "FSF_SQ_FCP_RSP_AVAILABLE\n");		debug_text_event(fsf_req->adapter->erp_dbf, 4, "fsf_sq_rsp");		break;	case FSF_SQ_RETRY_IF_POSSIBLE:		ZFCP_LOG_FLAGS(2, "FSF_SQ_RETRY_IF_POSSIBLE\n");		/* The SCSI-stack may now issue retries or escalate */		debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_sq_retry");		zfcp_cmd_dbf_event_fsf("sqretry", fsf_req,				       &fsf_req->qtcb->header.fsf_status_qual,				       sizeof (union fsf_status_qual));		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_SQ_COMMAND_ABORTED:		ZFCP_LOG_FLAGS(2, "FSF_SQ_COMMAND_ABORTED\n");		/* Carry the aborted state on to upper layer */		debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_sq_abort");		zfcp_cmd_dbf_event_fsf("sqabort", fsf_req,				       &fsf_req->qtcb->header.fsf_status_qual,				       sizeof (union fsf_status_qual));		fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTED;		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_SQ_NO_RECOM:		ZFCP_LOG_FLAGS(0, "FSF_SQ_NO_RECOM\n");		debug_text_exception(fsf_req->adapter->erp_dbf, 0,				     "fsf_sq_no_rec");		ZFCP_LOG_NORMAL("bug: No recommendation could be given for a"				"problem on the adapter %s "				"Stopping all operations on this adapter. ",				zfcp_get_busid_by_adapter(fsf_req->adapter));		zfcp_erp_adapter_shutdown(fsf_req->adapter, 0);		zfcp_cmd_dbf_event_fsf("sqnrecom", fsf_req,				       &fsf_req->qtcb->header.fsf_status_qual,				       sizeof (union fsf_status_qual));		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_SQ_ULP_PROGRAMMING_ERROR:		ZFCP_LOG_FLAGS(0, "FSF_SQ_ULP_PROGRAMMING_ERROR\n");		ZFCP_LOG_NORMAL("bug: An illegal amount of data was attempted "				"to be sent to the adapter %s "				"Stopping all operations on this adapter. ",				zfcp_get_busid_by_adapter(fsf_req->adapter));		debug_text_exception(fsf_req->adapter->erp_dbf, 0,				     "fsf_sq_ulp_err");		zfcp_erp_adapter_shutdown(fsf_req->adapter, 0);		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:	case FSF_SQ_NO_RETRY_POSSIBLE:	case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:		/* dealt with in the respective functions */		break;	default:		ZFCP_LOG_NORMAL("bug: Additional status info could "				"not be interpreted properly.\n");		ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,			      (char *) &fsf_req->qtcb->header.fsf_status_qual,			      sizeof (union fsf_status_qual));		debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_sq_inval:");		debug_exception(fsf_req->adapter->erp_dbf, 0,				&fsf_req->qtcb->header.fsf_status_qual.word[0],				sizeof (u32));		zfcp_cmd_dbf_event_fsf("squndef", fsf_req,				       &fsf_req->qtcb->header.fsf_status_qual,				       sizeof (union fsf_status_qual));		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	}	return retval;}/* * function:	zfcp_fsf_req_dispatch * * purpose:	calls the appropriate command specific handler * * returns:	 */static intzfcp_fsf_req_dispatch(struct zfcp_fsf_req *fsf_req){	struct zfcp_erp_action *erp_action = fsf_req->erp_action;	struct zfcp_adapter *adapter = fsf_req->adapter;	int retval = 0;	if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {		ZFCP_LOG_TRACE("fsf_req=%p, QTCB=%p\n", fsf_req, fsf_req->qtcb);		ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,			      (char *) fsf_req->qtcb, sizeof(struct fsf_qtcb));	}	switch (fsf_req->fsf_command) {	case FSF_QTCB_FCP_CMND:		ZFCP_LOG_FLAGS(3, "FSF_QTCB_FCP_CMND\n");		zfcp_fsf_send_fcp_command_handler(fsf_req);		break;	case FSF_QTCB_ABORT_FCP_CMND:		ZFCP_LOG_FLAGS(2, "FSF_QTCB_ABORT_FCP_CMND\n");		zfcp_fsf_abort_fcp_command_handler(fsf_req);		break;	case FSF_QTCB_SEND_GENERIC:		ZFCP_LOG_FLAGS(2, "FSF_QTCB_SEND_GENERIC\n");		zfcp_fsf_send_ct_handler(fsf_req);		break;	case FSF_QTCB_OPEN_PORT_WITH_DID:		ZFCP_LOG_FLAGS(2, "FSF_QTCB_OPEN_PORT_WITH_DID\n");		zfcp_fsf_open_port_handler(fsf_req);		break;	case FSF_QTCB_OPEN_LUN:		ZFCP_LOG_FLAGS(2, "FSF_QTCB_OPEN_LUN\n");		zfcp_fsf_open_unit_handler(fsf_req);		break;	case FSF_QTCB_CLOSE_LUN:		ZFCP_LOG_FLAGS(2, "FSF_QTCB_CLOSE_LUN\n");		zfcp_fsf_close_unit_handler(fsf_req);		break;	case FSF_QTCB_CLOSE_PORT:		ZFCP_LOG_FLAGS(2, "FSF_QTCB_CLOSE_PORT\n");		zfcp_fsf_close_port_handler(fsf_req);		break;	case FSF_QTCB_CLOSE_PHYSICAL_PORT:		ZFCP_LOG_FLAGS(2, "FSF_QTCB_CLOSE_PHYSICAL_PORT\n");		zfcp_fsf_close_physical_port_handler(fsf_req);		break;	case FSF_QTCB_EXCHANGE_CONFIG_DATA:		ZFCP_LOG_FLAGS(2, "FSF_QTCB_EXCHANGE_CONFIG_DATA\n");		zfcp_fsf_exchange_config_data_handler(fsf_req);		break;	case FSF_QTCB_SEND_ELS :		ZFCP_LOG_FLAGS(2, "FSF_QTCB_SEND_ELS\n");		zfcp_fsf_send_els_handler(fsf_req);		break;	case FSF_QTCB_DOWNLOAD_CONTROL_FILE:		ZFCP_LOG_FLAGS(2, "FSF_QTCB_DOWNLOAD_CONTROL_FILE\n");		zfcp_fsf_control_file_handler(fsf_req);		break;	case FSF_QTCB_UPLOAD_CONTROL_FILE:

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?