⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zfcp_dbf.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 3 页
字号:
				     rec->type.ct.type.request.max_res_size);		total = rec->type.ct.payload_size;		buffer = rec->type.ct.payload;		buflen = min(total, ZFCP_DBF_CT_PAYLOAD);	} else if (strncmp(rec->tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) {		len += zfcp_dbf_view(out_buf + len, "cmd_rsp_code", "0x%04x",				     rec->type.ct.type.response.cmd_rsp_code);		len += zfcp_dbf_view(out_buf + len, "revision", "0x%02x",				     rec->type.ct.type.response.revision);		len += zfcp_dbf_view(out_buf + len, "reason_code", "0x%02x",				     rec->type.ct.type.response.reason_code);		len +=		    zfcp_dbf_view(out_buf + len, "reason_code_expl", "0x%02x",				  rec->type.ct.type.response.reason_code_expl);		len +=		    zfcp_dbf_view(out_buf + len, "vendor_unique", "0x%02x",				  rec->type.ct.type.response.vendor_unique);		total = rec->type.ct.payload_size;		buffer = rec->type.ct.payload;		buflen = min(total, ZFCP_DBF_CT_PAYLOAD);	} else if (strncmp(rec->tag, "oels", ZFCP_DBF_TAG_SIZE) == 0 ||		   strncmp(rec->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 ||		   strncmp(rec->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) {		len += zfcp_dbf_view(out_buf + len, "ls_code", "0x%02x",				     rec->type.els.ls_code);		total = rec->type.els.payload_size;		buffer = rec->type.els.payload;		buflen = min(total, ZFCP_DBF_ELS_PAYLOAD);	}	len += zfcp_dbf_view_dump(out_buf + len, "payload",				  buffer, buflen, 0, total);	if (buflen == total)		len += sprintf(out_buf + len, "\n");	return len;}struct debug_view zfcp_san_dbf_view = {	"structured",	NULL,	&zfcp_dbf_view_header,	&zfcp_san_dbf_view_format,	NULL,	NULL};static inline void_zfcp_scsi_dbf_event_common(const char *tag, const char *tag2, int level,			    struct zfcp_adapter *adapter,			    struct scsi_cmnd *scsi_cmnd,			    struct zfcp_fsf_req *new_fsf_req){	struct zfcp_fsf_req *fsf_req =	    (struct zfcp_fsf_req *)scsi_cmnd->host_scribble;	struct zfcp_scsi_dbf_record *rec = &adapter->scsi_dbf_buf;	struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec;	unsigned long flags;	struct fcp_rsp_iu *fcp_rsp;	char *fcp_rsp_info = NULL, *fcp_sns_info = NULL;	int offset = 0, buflen = 0;	spin_lock_irqsave(&adapter->scsi_dbf_lock, flags);	do {		memset(rec, 0, sizeof(struct zfcp_scsi_dbf_record));		if (offset == 0) {			strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);			strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE);			if (scsi_cmnd->device) {				rec->scsi_id = scsi_cmnd->device->id;				rec->scsi_lun = scsi_cmnd->device->lun;			}			rec->scsi_result = scsi_cmnd->result;			rec->scsi_cmnd = (unsigned long)scsi_cmnd;			rec->scsi_serial = scsi_cmnd->serial_number;			memcpy(rec->scsi_opcode,			       &scsi_cmnd->cmnd,			       min((int)scsi_cmnd->cmd_len,				   ZFCP_DBF_SCSI_OPCODE));			rec->scsi_retries = scsi_cmnd->retries;			rec->scsi_allowed = scsi_cmnd->allowed;			if (fsf_req != NULL) {				fcp_rsp = (struct fcp_rsp_iu *)				    &(fsf_req->qtcb->bottom.io.fcp_rsp);				fcp_rsp_info =				    zfcp_get_fcp_rsp_info_ptr(fcp_rsp);				fcp_sns_info =				    zfcp_get_fcp_sns_info_ptr(fcp_rsp);				rec->type.fcp.rsp_validity =				    fcp_rsp->validity.value;				rec->type.fcp.rsp_scsi_status =				    fcp_rsp->scsi_status;				rec->type.fcp.rsp_resid = fcp_rsp->fcp_resid;				if (fcp_rsp->validity.bits.fcp_rsp_len_valid)					rec->type.fcp.rsp_code =					    *(fcp_rsp_info + 3);				if (fcp_rsp->validity.bits.fcp_sns_len_valid) {					buflen = min((int)fcp_rsp->fcp_sns_len,						     ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO);					rec->type.fcp.sns_info_len = buflen;					memcpy(rec->type.fcp.sns_info,					       fcp_sns_info,					       min(buflen,						   ZFCP_DBF_SCSI_FCP_SNS_INFO));					offset += min(buflen,						      ZFCP_DBF_SCSI_FCP_SNS_INFO);				}				rec->fsf_reqid = (unsigned long)fsf_req;				rec->fsf_seqno = fsf_req->seq_no;				rec->fsf_issued = fsf_req->issued;			}			if (new_fsf_req != NULL) {				rec->type.new_fsf_req.fsf_reqid =				    (unsigned long)				    new_fsf_req;				rec->type.new_fsf_req.fsf_seqno =				    new_fsf_req->seq_no;				rec->type.new_fsf_req.fsf_issued =				    new_fsf_req->issued;			}		} else {			strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE);			dump->total_size = buflen;			dump->offset = offset;			dump->size = min(buflen - offset,					 (int)sizeof(struct						     zfcp_scsi_dbf_record) -					 (int)sizeof(struct zfcp_dbf_dump));			memcpy(dump->data, fcp_sns_info + offset, dump->size);			offset += dump->size;		}		debug_event(adapter->scsi_dbf, level,			    rec, sizeof(struct zfcp_scsi_dbf_record));	} while (offset < buflen);	spin_unlock_irqrestore(&adapter->scsi_dbf_lock, flags);}inline voidzfcp_scsi_dbf_event_result(const char *tag, int level,			   struct zfcp_adapter *adapter,			   struct scsi_cmnd *scsi_cmnd){	_zfcp_scsi_dbf_event_common("rslt",				    tag, level, adapter, scsi_cmnd, NULL);}inline voidzfcp_scsi_dbf_event_abort(const char *tag, struct zfcp_adapter *adapter,			  struct scsi_cmnd *scsi_cmnd,			  struct zfcp_fsf_req *new_fsf_req){	_zfcp_scsi_dbf_event_common("abrt",				    tag, 1, adapter, scsi_cmnd, new_fsf_req);}inline voidzfcp_scsi_dbf_event_devreset(const char *tag, u8 flag, struct zfcp_unit *unit,			     struct scsi_cmnd *scsi_cmnd){	struct zfcp_adapter *adapter = unit->port->adapter;	_zfcp_scsi_dbf_event_common(flag == FCP_TARGET_RESET ? "trst" : "lrst",				    tag, 1, adapter, scsi_cmnd, NULL);}static intzfcp_scsi_dbf_view_format(debug_info_t * id, struct debug_view *view,			  char *out_buf, const char *in_buf){	struct zfcp_scsi_dbf_record *rec =	    (struct zfcp_scsi_dbf_record *)in_buf;	int len = 0;	if (strncmp(rec->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)		return 0;	len += zfcp_dbf_tag(out_buf + len, "tag", rec->tag);	len += zfcp_dbf_tag(out_buf + len, "tag2", rec->tag2);	len += zfcp_dbf_view(out_buf + len, "scsi_id", "0x%08x", rec->scsi_id);	len += zfcp_dbf_view(out_buf + len, "scsi_lun", "0x%08x",			     rec->scsi_lun);	len += zfcp_dbf_view(out_buf + len, "scsi_result", "0x%08x",			     rec->scsi_result);	len += zfcp_dbf_view(out_buf + len, "scsi_cmnd", "0x%0Lx",			     rec->scsi_cmnd);	len += zfcp_dbf_view(out_buf + len, "scsi_serial", "0x%016Lx",			     rec->scsi_serial);	len += zfcp_dbf_view_dump(out_buf + len, "scsi_opcode",				  rec->scsi_opcode,				  ZFCP_DBF_SCSI_OPCODE,				  0, ZFCP_DBF_SCSI_OPCODE);	len += zfcp_dbf_view(out_buf + len, "scsi_retries", "0x%02x",			     rec->scsi_retries);	len += zfcp_dbf_view(out_buf + len, "scsi_allowed", "0x%02x",			     rec->scsi_allowed);	len += zfcp_dbf_view(out_buf + len, "fsf_reqid", "0x%0Lx",			     rec->fsf_reqid);	len += zfcp_dbf_view(out_buf + len, "fsf_seqno", "0x%08x",			     rec->fsf_seqno);	len += zfcp_dbf_stck(out_buf + len, "fsf_issued", rec->fsf_issued);	if (strncmp(rec->tag, "rslt", ZFCP_DBF_TAG_SIZE) == 0) {		len +=		    zfcp_dbf_view(out_buf + len, "fcp_rsp_validity", "0x%02x",				  rec->type.fcp.rsp_validity);		len +=		    zfcp_dbf_view(out_buf + len, "fcp_rsp_scsi_status",				  "0x%02x", rec->type.fcp.rsp_scsi_status);		len +=		    zfcp_dbf_view(out_buf + len, "fcp_rsp_resid", "0x%08x",				  rec->type.fcp.rsp_resid);		len +=		    zfcp_dbf_view(out_buf + len, "fcp_rsp_code", "0x%08x",				  rec->type.fcp.rsp_code);		len +=		    zfcp_dbf_view(out_buf + len, "fcp_sns_info_len", "0x%08x",				  rec->type.fcp.sns_info_len);		len +=		    zfcp_dbf_view_dump(out_buf + len, "fcp_sns_info",				       rec->type.fcp.sns_info,				       min((int)rec->type.fcp.sns_info_len,					   ZFCP_DBF_SCSI_FCP_SNS_INFO), 0,				       rec->type.fcp.sns_info_len);	} else if (strncmp(rec->tag, "abrt", ZFCP_DBF_TAG_SIZE) == 0) {		len += zfcp_dbf_view(out_buf + len, "fsf_reqid_abort", "0x%0Lx",				     rec->type.new_fsf_req.fsf_reqid);		len += zfcp_dbf_view(out_buf + len, "fsf_seqno_abort", "0x%08x",				     rec->type.new_fsf_req.fsf_seqno);		len += zfcp_dbf_stck(out_buf + len, "fsf_issued",				     rec->type.new_fsf_req.fsf_issued);	} else if ((strncmp(rec->tag, "trst", ZFCP_DBF_TAG_SIZE) == 0) ||		   (strncmp(rec->tag, "lrst", ZFCP_DBF_TAG_SIZE) == 0)) {		len += zfcp_dbf_view(out_buf + len, "fsf_reqid_reset", "0x%0Lx",				     rec->type.new_fsf_req.fsf_reqid);		len += zfcp_dbf_view(out_buf + len, "fsf_seqno_reset", "0x%08x",				     rec->type.new_fsf_req.fsf_seqno);		len += zfcp_dbf_stck(out_buf + len, "fsf_issued",				     rec->type.new_fsf_req.fsf_issued);	}	len += sprintf(out_buf + len, "\n");	return len;}struct debug_view zfcp_scsi_dbf_view = {	"structured",	NULL,	&zfcp_dbf_view_header,	&zfcp_scsi_dbf_view_format,	NULL,	NULL};/** * zfcp_adapter_debug_register - registers debug feature for an adapter * @adapter: pointer to adapter for which debug features should be registered * return: -ENOMEM on error, 0 otherwise */int zfcp_adapter_debug_register(struct zfcp_adapter *adapter){	char dbf_name[DEBUG_MAX_NAME_LEN];	/* debug feature area which records recovery activity */	sprintf(dbf_name, "zfcp_%s_erp", zfcp_get_busid_by_adapter(adapter));	adapter->erp_dbf = debug_register(dbf_name, dbfsize, 2,					  sizeof(struct zfcp_erp_dbf_record));	if (!adapter->erp_dbf)		goto failed;	debug_register_view(adapter->erp_dbf, &debug_hex_ascii_view);	debug_set_level(adapter->erp_dbf, 3);	/* debug feature area which records HBA (FSF and QDIO) conditions */	sprintf(dbf_name, "zfcp_%s_hba", zfcp_get_busid_by_adapter(adapter));	adapter->hba_dbf = debug_register(dbf_name, dbfsize, 1,					  sizeof(struct zfcp_hba_dbf_record));	if (!adapter->hba_dbf)		goto failed;	debug_register_view(adapter->hba_dbf, &debug_hex_ascii_view);	debug_register_view(adapter->hba_dbf, &zfcp_hba_dbf_view);	debug_set_level(adapter->hba_dbf, 3);	/* debug feature area which records SAN command failures and recovery */	sprintf(dbf_name, "zfcp_%s_san", zfcp_get_busid_by_adapter(adapter));	adapter->san_dbf = debug_register(dbf_name, dbfsize, 1,					  sizeof(struct zfcp_san_dbf_record));	if (!adapter->san_dbf)		goto failed;	debug_register_view(adapter->san_dbf, &debug_hex_ascii_view);	debug_register_view(adapter->san_dbf, &zfcp_san_dbf_view);	debug_set_level(adapter->san_dbf, 6);	/* debug feature area which records SCSI command failures and recovery */	sprintf(dbf_name, "zfcp_%s_scsi", zfcp_get_busid_by_adapter(adapter));	adapter->scsi_dbf = debug_register(dbf_name, dbfsize, 1,					   sizeof(struct zfcp_scsi_dbf_record));	if (!adapter->scsi_dbf)		goto failed;	debug_register_view(adapter->scsi_dbf, &debug_hex_ascii_view);	debug_register_view(adapter->scsi_dbf, &zfcp_scsi_dbf_view);	debug_set_level(adapter->scsi_dbf, 3);	return 0; failed:	zfcp_adapter_debug_unregister(adapter);	return -ENOMEM;}/** * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter * @adapter: pointer to adapter for which debug features should be unregistered */void zfcp_adapter_debug_unregister(struct zfcp_adapter *adapter){	debug_unregister(adapter->scsi_dbf);	debug_unregister(adapter->san_dbf);	debug_unregister(adapter->hba_dbf);	debug_unregister(adapter->erp_dbf);	adapter->scsi_dbf = NULL;	adapter->san_dbf = NULL;	adapter->hba_dbf = NULL;	adapter->erp_dbf = NULL;}#undef ZFCP_LOG_AREA

⌨️ 快捷键说明

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