From patchwork Wed Apr 18 15:01:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 10348347 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9724B60216 for ; Wed, 18 Apr 2018 15:03:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 899712040D for ; Wed, 18 Apr 2018 15:03:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87BB528653; Wed, 18 Apr 2018 15:03:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5376528712 for ; Wed, 18 Apr 2018 15:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753450AbeDRPDf (ORCPT ); Wed, 18 Apr 2018 11:03:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:39681 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753372AbeDRPD3 (ORCPT ); Wed, 18 Apr 2018 11:03:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3F726AAC3; Wed, 18 Apr 2018 15:03:25 +0000 (UTC) From: Johannes Thumshirn To: "Martin K . Petersen" Cc: Bart Van Assche , Hannes Reinecke , James Bottomley , Linux SCSI Mailinglist , Douglas Gilbert , Johannes Thumshirn Subject: [VERY EARLY RFC 03/13] scsi: add enum for host byte codes Date: Wed, 18 Apr 2018 17:01:06 +0200 Message-Id: <20180418150116.18807-4-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180418150116.18807-1-jthumshirn@suse.de> References: <20180418150116.18807-1-jthumshirn@suse.de> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add enum for host byte codes and adopt set_host_byte()'s and host_byte()'s signature. Signed-off-by: Johannes Thumshirn Suggested-by: Bart Van Assche --- drivers/scsi/dc395x.c | 3 +-- drivers/scsi/megaraid.c | 6 ++++-- drivers/scsi/scsi_error.c | 2 ++ include/scsi/scsi.h | 55 ++++++++++++++++++++++++++--------------------- include/scsi/scsi_cmnd.h | 3 ++- 5 files changed, 39 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index da28f08ae185..379a1bc37576 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c @@ -173,7 +173,6 @@ #define SET_RES_TARGET(who,tgt) { who &= ~RES_TARGET; who |= (int)(tgt); } #define SET_RES_TARGET_LNX(who,tgt) { who &= ~RES_TARGET_LNX; who |= (int)(tgt) << 1; } #define SET_RES_MSG(who,msg) { who &= ~RES_ENDMSG; who |= (int)(msg) << 8; } -#define SET_RES_DID(who,did) { who &= ~RES_DID; who |= (int)(did) << 16; } #define SET_RES_DRV(who,drv) { who &= ~RES_DRV; who |= (int)(drv) << 24; } #define TAG_NONE 255 @@ -3443,7 +3442,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, srb->adapter_status = 0; srb->target_status = 0; - SET_RES_DID(cmd->result, DID_OK); + set_host_byte(cmd, DID_OK); } } diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 4d769db4435a..284bc8c4c6d5 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -1473,7 +1473,8 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) "aborted cmd [%x] complete\n", scb->idx); - scb->cmd->result = (DID_ABORT << 16); + scb->cmd->result = 0; + set_host_byte(scb->cmd, DID_ABORT); list_add_tail(SCSI_LIST(scb->cmd), &adapter->completed_list); @@ -1492,7 +1493,8 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) "reset cmd [%x] complete\n", scb->idx); - scb->cmd->result = (DID_RESET << 16); + scb->cmd->result = 0; + set_host_byte(scb->cmd, DID_RESET); list_add_tail(SCSI_LIST(scb->cmd), &adapter->completed_list); diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 946039117bf4..7e80f457367e 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1699,6 +1699,8 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd) /* fall through */ case DID_SOFT_ERROR: return (scmd->request->cmd_flags & REQ_FAILFAST_DRIVER); + default: + break; } if (status_byte(scmd->result) != CHECK_CONDITION) diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index eb7853c1a23b..4dfc5e11a5b2 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -132,33 +132,35 @@ static inline int scsi_is_wlun(u64 lun) /* * Host byte codes */ - -#define DID_OK 0x00 /* NO error */ -#define DID_NO_CONNECT 0x01 /* Couldn't connect before timeout period */ -#define DID_BUS_BUSY 0x02 /* BUS stayed busy through time out period */ -#define DID_TIME_OUT 0x03 /* TIMED OUT for other reason */ -#define DID_BAD_TARGET 0x04 /* BAD target. */ -#define DID_ABORT 0x05 /* Told to abort for some other reason */ -#define DID_PARITY 0x06 /* Parity error */ -#define DID_ERROR 0x07 /* Internal error */ -#define DID_RESET 0x08 /* Reset by somebody. */ -#define DID_BAD_INTR 0x09 /* Got an interrupt we weren't expecting. */ -#define DID_PASSTHROUGH 0x0a /* Force command past mid-layer */ -#define DID_SOFT_ERROR 0x0b /* The low level driver just wish a retry */ -#define DID_IMM_RETRY 0x0c /* Retry without decrementing retry count */ -#define DID_REQUEUE 0x0d /* Requeue command (no immediate retry) also +enum scsi_host_byte { + DID_OK, /* NO error */ + DID_NO_CONNECT, /* Couldn't connect before timeout period */ + DID_BUS_BUSY, /* BUS stayed busy through time out period */ + DID_TIME_OUT, /* TIMED OUT for other reason */ + DID_BAD_TARGET, /* BAD target. */ + DID_ABORT, /* Told to abort for some other reason */ + DID_PARITY, /* Parity error */ + DID_ERROR, /* Internal error */ + DID_RESET, /* Reset by somebody. */ + DID_BAD_INTR, /* Got an interrupt we weren't expecting. */ + DID_PASSTHROUGH, /* Force command past mid-layer */ + DID_SOFT_ERROR, /* The low level driver just wish a retry */ + DID_IMM_RETRY, /* Retry without decrementing retry count */ + DID_REQUEUE, /* Requeue command (no immediate retry) also * without decrementing the retry count */ -#define DID_TRANSPORT_DISRUPTED 0x0e /* Transport error disrupted execution - * and the driver blocked the port to - * recover the link. Transport class will - * retry or fail IO */ -#define DID_TRANSPORT_FAILFAST 0x0f /* Transport class fastfailed the io */ -#define DID_TARGET_FAILURE 0x10 /* Permanent target failure, do not retry on + DID_TRANSPORT_DISRUPTED,/* Transport error disrupted execution + * and the driver blocked the port to + * recover the link. Transport class will + * retry or fail IO + */ + DID_TRANSPORT_FAILFAST, /* Transport class fastfailed the io */ + DID_TARGET_FAILURE, /* Permanent target failure, do not retry on * other paths */ -#define DID_NEXUS_FAILURE 0x11 /* Permanent nexus failure, retry on other + DID_NEXUS_FAILURE, /* Permanent nexus failure, retry on other * paths might yield different results */ -#define DID_ALLOC_FAILURE 0x12 /* Space allocation on the device failed */ -#define DID_MEDIUM_ERROR 0x13 /* Medium error */ + DID_ALLOC_FAILURE, /* Space allocation on the device failed */ + DID_MEDIUM_ERROR, /* Medium error */ +}; #define DRIVER_OK 0x00 /* Driver status */ /* @@ -209,7 +211,10 @@ static inline int scsi_is_wlun(u64 lun) */ #define status_byte(result) (((result) >> 1) & 0x7f) #define msg_byte(result) (((result) >> 8) & 0xff) -#define host_byte(result) (((result) >> 16) & 0xff) +static inline enum scsi_host_byte host_byte(int result) +{ + return (result >> 16) & 0xff; +} #define driver_byte(result) (((result) >> 24) & 0xff) #define sense_class(sense) (((sense) >> 4) & 0x7) diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index aaf1e971c6a3..b678cd99b12b 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -342,7 +342,8 @@ static inline void set_msg_byte(struct scsi_cmnd *cmd, char status) cmd->result = (cmd->result & 0xffff00ff) | (status << 8); } -static inline void set_host_byte(struct scsi_cmnd *cmd, char status) +static inline void set_host_byte(struct scsi_cmnd *cmd, + enum scsi_host_byte status) { cmd->result = (cmd->result & 0xff00ffff) | (status << 16); }