ZFCP_LOG_FLAGS(2, "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n"); 
zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req){	int retval = -EINVAL;	struct zfcp_adapter *adapter;	struct zfcp_unit *unit;	struct fsf_qtcb_header *header;	struct fsf_qtcb_bottom_support *bottom;	struct fsf_queue_designator *queue_designator;	u16 subtable, rule, counter;	u32 allowed, exclusive, readwrite;	unit = fsf_req->data.open_unit.unit;	if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {		/* don't change unit status in our bookkeeping */		goto skip_fsfstatus;	}	adapter = fsf_req->adapter;	header = &fsf_req->qtcb->header;	bottom = &fsf_req->qtcb->bottom.support;	queue_designator = &header->fsf_status_qual.fsf_queue_designator;	allowed   = bottom->lun_access_info & FSF_UNIT_ACCESS_OPEN_LUN_ALLOWED;	exclusive = bottom->lun_access_info & FSF_UNIT_ACCESS_EXCLUSIVE;	readwrite = bottom->lun_access_info & FSF_UNIT_ACCESS_OUTBOUND_TRANSFER;	atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |			  ZFCP_STATUS_UNIT_SHARED |			  ZFCP_STATUS_UNIT_READONLY,			  &unit->status);	/* evaluate FSF status in QTCB */	switch (header->fsf_status) {	case FSF_PORT_HANDLE_NOT_VALID:		ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n");		ZFCP_LOG_INFO("Temporary port identifier 0x%x "			      "for port 0x%016Lx on adapter %s invalid "			      "This may happen occasionally\n",			      unit->port->handle,			      unit->port->wwpn, zfcp_get_busid_by_unit(unit));		ZFCP_LOG_DEBUG("status qualifier:\n");		ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,			      (char *) &header->fsf_status_qual,			      sizeof (union fsf_status_qual));		debug_text_event(adapter->erp_dbf, 1, "fsf_s_ph_nv");		zfcp_erp_adapter_reopen(unit->port->adapter, 0);		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_LUN_ALREADY_OPEN:		ZFCP_LOG_FLAGS(0, "FSF_LUN_ALREADY_OPEN\n");		ZFCP_LOG_NORMAL("bug: Attempted to open unit 0x%016Lx on "				"remote port 0x%016Lx on adapter %s twice.\n",				unit->fcp_lun,				unit->port->wwpn, zfcp_get_busid_by_unit(unit));		debug_text_exception(adapter->erp_dbf, 0,				     "fsf_s_uopen");		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_ACCESS_DENIED:		ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");		ZFCP_LOG_NORMAL("Access denied, cannot open unit 0x%016Lx on "				"remote port 0x%016Lx on adapter %s\n",				unit->fcp_lun, unit->port->wwpn,				zfcp_get_busid_by_unit(unit));		for (counter = 0; counter < 2; counter++) {			subtable = header->fsf_status_qual.halfword[counter * 2];			rule = header->fsf_status_qual.halfword[counter * 2 + 1];			switch (subtable) {			case FSF_SQ_CFDC_SUBTABLE_OS:			case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:			case FSF_SQ_CFDC_SUBTABLE_PORT_DID:			case FSF_SQ_CFDC_SUBTABLE_LUN:				ZFCP_LOG_INFO("Access denied (%s rule %d)\n",					zfcp_act_subtable_type[subtable], rule);				break;			}		}		debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");		zfcp_erp_unit_access_denied(unit);		atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);                atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_PORT_BOXED:		ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n");		ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "			       "needs to be reopened\n",			       unit->port->wwpn, zfcp_get_busid_by_unit(unit));		debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed");		zfcp_erp_port_reopen(unit->port, 0);		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |			ZFCP_STATUS_FSFREQ_RETRY;		break;	case FSF_LUN_SHARING_VIOLATION:		ZFCP_LOG_FLAGS(2, "FSF_LUN_SHARING_VIOLATION\n");		if (header->fsf_status_qual.word[0] != 0) {			ZFCP_LOG_NORMAL("FCP-LUN 0x%Lx at the remote port "					"with WWPN 0x%Lx "					"connected to the adapter %s "					"is already in use in LPAR%d, CSS%d\n",					unit->fcp_lun,					unit->port->wwpn,					zfcp_get_busid_by_unit(unit),					queue_designator->hla,					queue_designator->cssid);		} else {			subtable = header->fsf_status_qual.halfword[4];			rule = header->fsf_status_qual.halfword[5];			switch (subtable) {			case FSF_SQ_CFDC_SUBTABLE_OS:			case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:			case FSF_SQ_CFDC_SUBTABLE_PORT_DID:			case FSF_SQ_CFDC_SUBTABLE_LUN:				ZFCP_LOG_NORMAL("Access to FCP-LUN 0x%Lx at the "						"remote port with WWPN 0x%Lx "						"connected to the adapter %s "						"is denied (%s rule %d)\n",						unit->fcp_lun,						unit->port->wwpn,						zfcp_get_busid_by_unit(unit),						zfcp_act_subtable_type[subtable],						rule);				break;			}		}		ZFCP_LOG_DEBUG("status qualifier:\n");		ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,			      (char *) &header->fsf_status_qual,			      sizeof (union fsf_status_qual));		debug_text_event(adapter->erp_dbf, 2,				 "fsf_s_l_sh_vio");		zfcp_erp_unit_access_denied(unit);		atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);		atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED:		ZFCP_LOG_FLAGS(1, "FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED\n");		ZFCP_LOG_INFO("error: The adapter ran out of resources. "			      "There is no handle (temporary port identifier) "			      "available for unit 0x%016Lx on port 0x%016Lx "			      "on adapter %s\n",			      unit->fcp_lun,			      unit->port->wwpn,			      zfcp_get_busid_by_unit(unit));		debug_text_event(adapter->erp_dbf, 1,				 "fsf_s_max_units");		zfcp_erp_unit_failed(unit);		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		break;	case FSF_ADAPTER_STATUS_AVAILABLE:		ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");		switch (header->fsf_status_qual.word[0]) {		case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:			ZFCP_LOG_FLAGS(2,				       "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");			/* Re-establish link to port */			debug_text_event(adapter->erp_dbf, 1,					 "fsf_sq_ltest");			zfcp_erp_port_reopen(unit->port, 0);			fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;			break;		case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:			ZFCP_LOG_FLAGS(2,				       "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");			/* ERP strategy will escalate */			debug_text_event(adapter->erp_dbf, 1,					 "fsf_sq_ulp");			fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;			break;		default:			ZFCP_LOG_NORMAL			    ("bug: Wrong status qualifier 0x%x arrived.\n",			     header->fsf_status_qual.word[0]);			debug_text_event(adapter->erp_dbf, 0,					 "fsf_sq_inval:");			debug_exception(adapter->erp_dbf, 0,					&header->fsf_status_qual.word[0],				sizeof (u32));		}		break;	case FSF_INVALID_COMMAND_OPTION:		ZFCP_LOG_FLAGS(2, "FSF_INVALID_COMMAND_OPTION\n");		ZFCP_LOG_NORMAL(			"Invalid option 0x%x has been specified "			"in QTCB bottom sent to the adapter %s\n",			bottom->option,			zfcp_get_busid_by_adapter(adapter));		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;		retval = -EINVAL;		break;	case FSF_GOOD:		ZFCP_LOG_FLAGS(3, "FSF_GOOD\n");		/* save LUN handle assigned by FSF */		unit->handle = header->lun_handle;		ZFCP_LOG_TRACE("unit 0x%016Lx on remote port 0x%016Lx on "			       "adapter %s opened, port handle 0x%x\n",			       unit->fcp_lun,			       unit->port->wwpn,			       zfcp_get_busid_by_unit(unit),			       unit->handle);		/* mark unit as open */		atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);		if (adapter->supported_features & FSF_FEATURE_LUN_SHARING){			if (!exclusive)		                atomic_set_mask(ZFCP_STATUS_UNIT_SHARED,						&unit->status);			if (!readwrite) {                		atomic_set_mask(ZFCP_STATUS_UNIT_READONLY,						&unit->status);                		ZFCP_LOG_NORMAL("read-only access for unit "						"(adapter %s, wwpn=0x%016Lx, "						"fcp_lun=0x%016Lx)\n",						zfcp_get_busid_by_unit(unit),						unit->port->wwpn,						unit->fcp_lun);        		}        		if (exclusive && !readwrite) {                		ZFCP_LOG_NORMAL("exclusive access of read-only "						"unit not supported\n");				zfcp_erp_unit_failed(unit);				fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;				zfcp_erp_unit_shutdown(unit, 0);        		} else if (!exclusive && readwrite) {                		ZFCP_LOG_NORMAL("shared access of read-write "						"unit not supported\n");                		zfcp_erp_unit_failed(unit);				fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;				zfcp_erp_unit_shutdown(unit, 0);        		}		}		retval = 0;		break;	default:		ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "				"(debug info 0x%x)\n",				header->fsf_status);		debug_text_event(adapter->erp_dbf, 0, "fsf_s_inval:");		debug_exception(adapter->erp_dbf, 0,				&header->fsf_status, sizeof (u32));		break;	} skip_fsfstatus:	atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING, &unit->status);	return retval;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/6bc9dace767f1fffdf975b3398b3c4e37cd5ae18/zfcp_fsf.c/clean/drivers/s390/scsi/zfcp_fsf.c