public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Douglas Gilbert <dgilbert@interlog.com>
To: Hannes Reinecke <hare@suse.de>,
	James Bottomley <jbottomley@parallels.com>
Cc: Ewan Milne <emilne@redhat.com>,
	Christoph Hellwig <hch@infradead.org>,
	linux-scsi@vger.kernel.org, Robert Elliot <elliot@hp.com>,
	Yoshihiro Yunomae <yoshihiro.ynomae.ez@hitachi.com>
Subject: Re: [PATCH 11/22] Implement scsi_opcode_sa_name
Date: Thu, 28 Aug 2014 19:50:27 -0400	[thread overview]
Message-ID: <53FFC043.4020608@interlog.com> (raw)
In-Reply-To: <1409247216-76074-12-git-send-email-hare@suse.de>

On 14-08-28 01:33 PM, Hannes Reinecke wrote:
> Implement a lookup array for SERVICE ACTION commands instead
> of hardcoding it in a large switch statement.
>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>   drivers/scsi/constants.c | 130 +++++++++++++++++++----------------------------
>   1 file changed, 53 insertions(+), 77 deletions(-)
>
> diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
> index 323e944..813c482 100644
> --- a/drivers/scsi/constants.c
> +++ b/drivers/scsi/constants.c
> @@ -244,102 +244,77 @@ static const struct value_name_pair variable_length_arr[] = {
>   };
>   #define VARIABLE_LENGTH_SZ ARRAY_SIZE(variable_length_arr)
>
> -static const char * get_sa_name(const struct value_name_pair * arr,
> -			        int arr_sz, int service_action)
> +struct sa_name_list {
> +	int cmd;
> +	const struct value_name_pair *arr;
> +	int arr_sz;
> +};
> +
> +static struct sa_name_list sa_names_arr[] = {
> +	{VARIABLE_LENGTH_CMD, variable_length_arr, VARIABLE_LENGTH_SZ},
> +	{MAINTENANCE_IN, maint_in_arr, MAINT_IN_SZ},
> +	{MAINTENANCE_OUT, maint_out_arr, MAINT_OUT_SZ},
> +	{PERSISTENT_RESERVE_IN, pr_in_arr, PR_IN_SZ},
> +	{PERSISTENT_RESERVE_OUT, pr_out_arr, PR_OUT_SZ},
> +	{SERVICE_ACTION_IN_12, serv_in12_arr, SERV_IN12_SZ},
> +	{SERVICE_ACTION_OUT_12, serv_out12_arr, SERV_OUT12_SZ},
> +	{SERVICE_ACTION_BIDIRECTIONAL, serv_bidi_arr, SERV_BIDI_SZ},
> +	{SERVICE_ACTION_IN_16, serv_in16_arr, SERV_IN16_SZ},
> +	{SERVICE_ACTION_OUT_16, serv_out16_arr, SERV_OUT16_SZ},
> +	{THIRD_PARTY_COPY_IN, tpc_in_arr, TPC_IN_SZ},
> +	{THIRD_PARTY_COPY_OUT, tpc_out_arr, TPC_OUT_SZ},
> +	{0, NULL, 0},
> +};

Plus I added these recently (after observing the output from
REPORT SUPPORTED OPERATION CODES):
     READ BUFFER
     WRITE BUFFER
     SANITIZE

[And I'll take your lead and remove the big switch
  statement from sg3_utils.]

Doug Gilbert



/* Read buffer [0x3c] service actions */
struct sg_lib_value_name_t sg_lib_read_buff_arr[] = {
     {0x0, 0, "combined header and data [or multiple modes]"},
     {0x2, 0, "data"},
     {0x3, 0, "descriptor"},
     {0xa, 0, "read data from echo buffer"},
     {0xb, 0, "echo buffer descriptor"},
     {0x1a, 0, "enable expander comms protocol and echo buffer"},
     {0x1c, 0, "error history"},
     {0xffff, 0, NULL},
};

/* Write buffer [0x3b] service actions */
struct sg_lib_value_name_t sg_lib_write_buff_arr[] = {
     {0x0, 0, "combined header and data [or multiple modes]"},
     {0x2, 0, "data"},
     {0x4, 0, "download microcode and activate"},
     {0x5, 0, "download microcode, save, and activate"},
     {0x6, 0, "download microcode with offsets and activate"},
     {0x7, 0, "download microcode with offsets, save, and activate"},
     {0xa, 0, "write data to echo buffer"},
     {0xd, 0, "download microcode with offsets, select activation events, "
              "save and defer activate"},
     {0xe, 0, "download microcode with offsets, save and defer activate"},
     {0xf, 0, "activate deferred microcode"},
     {0x1a, 0, "enable expander comms protocol and echo buffer"},
     {0x1b, 0, "disable expander comms protocol"},
     {0x1c, 0, "download application client error history"},
     {0xffff, 0, NULL},
};

/* Sanitize [0x48] service actions */
struct sg_lib_value_name_t sg_lib_sanitize_sa_arr[] = {
     {0x1, 0, "Sanitize, overwrite"},
     {0x2, 0, "Sanitize, block erase"},
     {0x3, 0, "Sanitize, cryptographic erase"},
     {0x1f, 0, "Sanitize, exit failure mode"},
     {0xffff, 0, NULL},
};


  reply	other threads:[~2014-08-28 23:50 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-28 17:33 [PATCH 00/22] scsi logging update Hannes Reinecke
2014-08-28 17:33 ` [PATCH 01/22] Remove scsi_cmd_print_sense_hdr() Hannes Reinecke
2014-08-31 21:39   ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 02/22] aha152x: Remove #ifdef 0 section Hannes Reinecke
2014-08-31 21:40   ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 03/22] sd: Remove scsi_print_sense() in sd_done() Hannes Reinecke
2014-08-31 21:40   ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 04/22] scsi: introduce sdev_prefix_printk() Hannes Reinecke
2014-08-31 21:43   ` Christoph Hellwig
2014-09-01  7:54     ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 05/22] scsi: Use sdev as argument for sense code printing Hannes Reinecke
2014-08-31 21:55   ` Christoph Hellwig
2014-09-01  8:00     ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 06/22] scsi: stop decoding if scsi_normalize_sense() fails Hannes Reinecke
2014-08-31 22:00   ` Christoph Hellwig
2014-09-01  8:06     ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 07/22] scsi: do not decode sense extras Hannes Reinecke
2014-08-31 22:06   ` Christoph Hellwig
2014-09-01  8:10     ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 08/22] scsi: dump sense buffer only for debugging Hannes Reinecke
2014-08-31 22:09   ` Christoph Hellwig
2014-09-01  8:26     ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 09/22] Use sdev as argument for scsi_print_result Hannes Reinecke
2014-08-31 22:11   ` Christoph Hellwig
2014-09-01  8:43     ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 10/22] scsi: consolidate scsi_print_status() Hannes Reinecke
2014-08-31 22:14   ` Christoph Hellwig
2014-09-01  8:46     ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 11/22] Implement scsi_opcode_sa_name Hannes Reinecke
2014-08-28 23:50   ` Douglas Gilbert [this message]
2014-08-31 22:16   ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 12/22] scsi: remove obsolete __scsi_print_command() usages Hannes Reinecke
2014-08-31 22:18   ` Christoph Hellwig
2014-09-01  6:56     ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 13/22] scsi: use local buffer for printing the opcode Hannes Reinecke
2014-08-31 22:19   ` Christoph Hellwig
2014-09-01  8:57     ` Hannes Reinecke
2014-09-01 14:42       ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 14/22] scsi: pass in string buffer to __scsi_print_command() Hannes Reinecke
2014-08-28 17:33 ` [PATCH 15/22] scsi: use dev_printk() variants in scsi_print_command() Hannes Reinecke
2014-08-28 17:33 ` [PATCH 16/22] libata: use __scsi_print_command() Hannes Reinecke
2014-08-28 17:33 ` [PATCH 17/22] scsi: print disposition in scsi_print_result() Hannes Reinecke
2014-08-31 22:23   ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 18/22] scsi_error: format abort error message Hannes Reinecke
2014-08-31 22:25   ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 19/22] scsi: use local buffer for scsi_log_(send|completion) Hannes Reinecke
2014-08-28 17:33 ` [PATCH 20/22] scsi: align logging messages Hannes Reinecke
2014-08-31 22:25   ` Christoph Hellwig
2014-09-01  1:00     ` Elliott, Robert (Server Storage)
2014-09-06  0:34       ` Christoph Hellwig
2014-09-18 23:58         ` Elliott, Robert (Server Storage)
2014-09-19  6:26           ` Hannes Reinecke
2014-09-19 11:35             ` Christoph Hellwig
2014-09-19 11:56               ` Hannes Reinecke
2014-08-28 17:33 ` [PATCH 21/22] scsi: reduce messages for command failure Hannes Reinecke
2014-08-31 22:28   ` Christoph Hellwig
2014-09-01  1:14     ` Elliott, Robert (Server Storage)
2014-09-06  0:35       ` Christoph Hellwig
2014-08-28 17:33 ` [PATCH 22/22] sd: Reduce logging output Hannes Reinecke
2014-08-31 22:29   ` Christoph Hellwig
2014-09-03  7:58     ` Hannes Reinecke
2014-08-28 19:24 ` [PATCH 00/22] scsi logging update Douglas Gilbert
2014-08-29  9:48   ` Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53FFC043.4020608@interlog.com \
    --to=dgilbert@interlog.com \
    --cc=elliot@hp.com \
    --cc=emilne@redhat.com \
    --cc=hare@suse.de \
    --cc=hch@infradead.org \
    --cc=jbottomley@parallels.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=yoshihiro.ynomae.ez@hitachi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox