Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 173751
b: refs/heads/master
c: 4318e08
h: refs/heads/master
i:
  173749: 31a0d96
  173747: f438b44
  173743: 990200a
v: v3
  • Loading branch information
Christof Schmitt authored and James Bottomley committed Dec 4, 2009
1 parent 76f3675 commit 281fc3d
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 170 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8830271c4819d86d8e87202a1fe8da0bb58912a2
refs/heads/master: 4318e08c84e4916ac463002ffb7f9901ddb3c385
35 changes: 19 additions & 16 deletions trunk/drivers/s390/scsi/zfcp_dbf.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,9 @@ void _zfcp_dbf_scsi(const char *tag, const char *tag2, int level,
struct zfcp_dbf_scsi_record *rec = &dbf->scsi_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;
struct fcp_resp_with_ext *fcp_rsp;
struct fcp_resp_rsp_info *fcp_rsp_info = NULL;
char *fcp_sns_info = NULL;
int offset = 0, buflen = 0;

spin_lock_irqsave(&dbf->scsi_lock, flags);
Expand All @@ -895,20 +896,22 @@ void _zfcp_dbf_scsi(const char *tag, const char *tag2, int level,
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 = (unsigned char *) &fcp_rsp[1];
fcp_sns_info =
zfcp_get_fcp_sns_info_ptr(fcp_rsp);

rec->rsp_validity = fcp_rsp->validity.value;
rec->rsp_scsi_status = fcp_rsp->scsi_status;
rec->rsp_resid = fcp_rsp->fcp_resid;
if (fcp_rsp->validity.bits.fcp_rsp_len_valid)
rec->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);
fcp_rsp = (struct fcp_resp_with_ext *)
&(fsf_req->qtcb->bottom.io.fcp_rsp);
fcp_rsp_info = (struct fcp_resp_rsp_info *)
&fcp_rsp[1];
fcp_sns_info = (char *) &fcp_rsp[1];
if (fcp_rsp->resp.fr_flags & FCP_RSP_LEN_VAL)
fcp_sns_info += fcp_rsp->ext.fr_sns_len;

rec->rsp_validity = fcp_rsp->resp.fr_flags;
rec->rsp_scsi_status = fcp_rsp->resp.fr_status;
rec->rsp_resid = fcp_rsp->ext.fr_resid;
if (fcp_rsp->resp.fr_flags & FCP_RSP_LEN_VAL)
rec->rsp_code = fcp_rsp_info->rsp_code;
if (fcp_rsp->resp.fr_flags & FCP_SNS_LEN_VAL) {
buflen = min(fcp_rsp->ext.fr_sns_len,
(u32)ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO);
rec->sns_info_len = buflen;
memcpy(rec->sns_info, fcp_sns_info,
min(buflen,
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/s390/scsi/zfcp_dbf.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#ifndef ZFCP_DBF_H
#define ZFCP_DBF_H

#include <scsi/fc/fc_fcp.h>
#include "zfcp_ext.h"
#include "zfcp_fsf.h"
#include "zfcp_def.h"
Expand Down Expand Up @@ -343,7 +344,7 @@ static inline
void zfcp_dbf_scsi_devreset(const char *tag, u8 flag, struct zfcp_unit *unit,
struct scsi_cmnd *scsi_cmnd)
{
zfcp_dbf_scsi(flag == FCP_TARGET_RESET ? "trst" : "lrst", tag, 1,
zfcp_dbf_scsi(flag == FCP_TMF_TGT_RESET ? "trst" : "lrst", tag, 1,
unit->port->adapter->dbf, scsi_cmnd, NULL, 0);
}

Expand Down
57 changes: 0 additions & 57 deletions trunk/drivers/s390/scsi/zfcp_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,65 +73,8 @@

/*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/

/* task attribute values in FCP-2 FCP_CMND IU */
#define SIMPLE_Q 0
#define HEAD_OF_Q 1
#define ORDERED_Q 2
#define ACA_Q 4
#define UNTAGGED 5

/* task management flags in FCP-2 FCP_CMND IU */
#define FCP_CLEAR_ACA 0x40
#define FCP_TARGET_RESET 0x20
#define FCP_LOGICAL_UNIT_RESET 0x10
#define FCP_CLEAR_TASK_SET 0x04
#define FCP_ABORT_TASK_SET 0x02

#define FCP_CDB_LENGTH 16

#define ZFCP_DID_MASK 0x00FFFFFF

/* FCP(-2) FCP_CMND IU */
struct fcp_cmnd_iu {
u64 fcp_lun; /* FCP logical unit number */
u8 crn; /* command reference number */
u8 reserved0:5; /* reserved */
u8 task_attribute:3; /* task attribute */
u8 task_management_flags; /* task management flags */
u8 add_fcp_cdb_length:6; /* additional FCP_CDB length */
u8 rddata:1; /* read data */
u8 wddata:1; /* write data */
u8 fcp_cdb[FCP_CDB_LENGTH];
} __attribute__((packed));

/* FCP(-2) FCP_RSP IU */
struct fcp_rsp_iu {
u8 reserved0[10];
union {
struct {
u8 reserved1:3;
u8 fcp_conf_req:1;
u8 fcp_resid_under:1;
u8 fcp_resid_over:1;
u8 fcp_sns_len_valid:1;
u8 fcp_rsp_len_valid:1;
} bits;
u8 value;
} validity;
u8 scsi_status;
u32 fcp_resid;
u32 fcp_sns_len;
u32 fcp_rsp_len;
} __attribute__((packed));


#define RSP_CODE_GOOD 0
#define RSP_CODE_LENGTH_MISMATCH 1
#define RSP_CODE_FIELD_INVALID 2
#define RSP_CODE_RO_MISMATCH 3
#define RSP_CODE_TASKMAN_UNSUPP 4
#define RSP_CODE_TASKMAN_FAILED 5

/* see fc-fs */
#define LS_RSCN 0x61
#define LS_LOGO 0x05
Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/s390/scsi/zfcp_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ extern void zfcp_qdio_close(struct zfcp_qdio *);
extern struct zfcp_data zfcp_data;
extern int zfcp_adapter_scsi_register(struct zfcp_adapter *);
extern void zfcp_adapter_scsi_unregister(struct zfcp_adapter *);
extern char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *);
extern struct fc_function_template zfcp_transport_functions;
extern void zfcp_scsi_rport_work(struct work_struct *);
extern void zfcp_scsi_schedule_rport_register(struct zfcp_port *);
Expand Down
112 changes: 112 additions & 0 deletions trunk/drivers/s390/scsi/zfcp_fc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* zfcp device driver
*
* Fibre Channel related definitions and inline functions for the zfcp
* device driver
*
* Copyright IBM Corporation 2009
*/

#ifndef ZFCP_FC_H
#define ZFCP_FC_H

#include <scsi/fc/fc_fcp.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_tcq.h>

/**
* zfcp_fc_scsi_to_fcp - setup FCP command with data from scsi_cmnd
* @fcp: fcp_cmnd to setup
* @scsi: scsi_cmnd where to get LUN, task attributes/flags and CDB
*/
static inline
void zfcp_fc_scsi_to_fcp(struct fcp_cmnd *fcp, struct scsi_cmnd *scsi)
{
char tag[2];

int_to_scsilun(scsi->device->lun, (struct scsi_lun *) &fcp->fc_lun);

if (scsi_populate_tag_msg(scsi, tag)) {
switch (tag[0]) {
case MSG_ORDERED_TAG:
fcp->fc_pri_ta |= FCP_PTA_ORDERED;
break;
case MSG_SIMPLE_TAG:
fcp->fc_pri_ta |= FCP_PTA_SIMPLE;
break;
};
} else
fcp->fc_pri_ta = FCP_PTA_SIMPLE;

if (scsi->sc_data_direction == DMA_FROM_DEVICE)
fcp->fc_flags |= FCP_CFL_RDDATA;
if (scsi->sc_data_direction == DMA_TO_DEVICE)
fcp->fc_flags |= FCP_CFL_WRDATA;

memcpy(fcp->fc_cdb, scsi->cmnd, scsi->cmd_len);

fcp->fc_dl = scsi_bufflen(scsi);
}

/**
* zfcp_fc_fcp_tm - setup FCP command as task management command
* @fcp: fcp_cmnd to setup
* @dev: scsi_device where to send the task management command
* @tm: task management flags to setup tm command
*/
static inline
void zfcp_fc_fcp_tm(struct fcp_cmnd *fcp, struct scsi_device *dev, u8 tm_flags)
{
int_to_scsilun(dev->lun, (struct scsi_lun *) &fcp->fc_lun);
fcp->fc_tm_flags |= tm_flags;
}

/**
* zfcp_fc_evap_fcp_rsp - evaluate FCP RSP IU and update scsi_cmnd accordingly
* @fcp_rsp: FCP RSP IU to evaluate
* @scsi: SCSI command where to update status and sense buffer
*/
static inline
void zfcp_fc_eval_fcp_rsp(struct fcp_resp_with_ext *fcp_rsp,
struct scsi_cmnd *scsi)
{
struct fcp_resp_rsp_info *rsp_info;
char *sense;
u32 sense_len, resid;
u8 rsp_flags;

set_msg_byte(scsi, COMMAND_COMPLETE);
scsi->result |= fcp_rsp->resp.fr_status;

rsp_flags = fcp_rsp->resp.fr_flags;

if (unlikely(rsp_flags & FCP_RSP_LEN_VAL)) {
rsp_info = (struct fcp_resp_rsp_info *) &fcp_rsp[1];
if (rsp_info->rsp_code == FCP_TMF_CMPL)
set_host_byte(scsi, DID_OK);
else {
set_host_byte(scsi, DID_ERROR);
return;
}
}

if (unlikely(rsp_flags & FCP_SNS_LEN_VAL)) {
sense = (char *) &fcp_rsp[1];
if (rsp_flags & FCP_RSP_LEN_VAL)
sense += fcp_rsp->ext.fr_sns_len;
sense_len = min(fcp_rsp->ext.fr_sns_len,
(u32) SCSI_SENSE_BUFFERSIZE);
memcpy(scsi->sense_buffer, sense, sense_len);
}

if (unlikely(rsp_flags & FCP_RESID_UNDER)) {
resid = fcp_rsp->ext.fr_resid;
scsi_set_resid(scsi, resid);
if (scsi_bufflen(scsi) - resid < scsi->underflow &&
!(rsp_flags & FCP_SNS_LEN_VAL) &&
fcp_rsp->resp.fr_status == SAM_STAT_GOOD)
set_host_byte(scsi, DID_ERROR);
}
}

#endif
Loading

0 comments on commit 281fc3d

Please sign in to comment.