From: John Meneghini <jmeneghi@redhat.com>
To: "Kai Mäkisara" <Kai.Makisara@kolumbus.fi>,
linux-scsi@vger.kernel.org, dgilbert@interlog.com
Cc: martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com
Subject: Re: [PATCH v2 5/7] scsi: scsi_debug: Add compression mode page for tapes
Date: Wed, 19 Feb 2025 16:58:00 -0500 [thread overview]
Message-ID: <f81d5709-ec8a-4d3a-a37e-e9c9a60f5099@redhat.com> (raw)
In-Reply-To: <20250213092636.2510-6-Kai.Makisara@kolumbus.fi>
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Tested-by: John Meneghini <jmeneghi@redhat.com>
On 2/13/25 4:26 AM, Kai Mäkisara wrote:
> Add support for compression mode page. The compression status
> is saved and returned. No UA is generated.
>
> Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
> ---
> drivers/scsi/scsi_debug.c | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 29a9aea30d22..0a5cd35c41de 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -405,6 +405,7 @@ struct sdebug_dev_info {
> unsigned int tape_density;
> unsigned char tape_partition;
> unsigned char tape_nbr_partitions;
> + unsigned char tape_dce;
> unsigned int tape_location[TAPE_MAX_PARTITIONS];
> unsigned int tape_eop[TAPE_MAX_PARTITIONS];
> struct tape_block *tape_blocks[TAPE_MAX_PARTITIONS];
> @@ -2843,6 +2844,20 @@ static int resp_partition_m_pg(unsigned char *p, int pcontrol, int target)
> return sizeof(partition_pg);
> }
>
> +static int resp_compression_m_pg(unsigned char *p, int pcontrol, int target,
> + unsigned char dce)
> +{ /* Compression page for mode_sense (tape) */
> + unsigned char compression_pg[] = {0x0f, 14, 0x40, 0, 0, 0, 0, 0,
> + 0, 0, 0, 0, 00, 00};
> +
> + memcpy(p, compression_pg, sizeof(compression_pg));
> + if (dce)
> + p[2] |= 0x80;
> + if (pcontrol == 1)
> + memset(p + 2, 0, sizeof(compression_pg) - 2);
> + return sizeof(compression_pg);
> +}
> +
> /* PAGE_SIZE is more than necessary but provides room for future expansion. */
> #define SDEBUG_MAX_MSENSE_SZ PAGE_SIZE
>
> @@ -2983,6 +2998,12 @@ static int resp_mode_sense(struct scsi_cmnd *scp,
> }
> offset += len;
> break;
> + case 0xf: /* Compression Mode Page (tape) */
> + if (!is_tape)
> + goto bad_pcode;
> + len += resp_compression_m_pg(ap, pcontrol, target, devip->tape_dce);
> + offset += len;
> + break;
> case 0x11: /* Partition Mode Page (tape) */
> if (!is_tape)
> goto bad_pcode;
> @@ -3143,6 +3164,14 @@ static int resp_mode_select(struct scsi_cmnd *scp,
> goto set_mode_changed_ua;
> }
> break;
> + case 0xf: /* Compression mode page */
> + if (sdebug_ptype != TYPE_TAPE)
> + goto bad_pcode;
> + if ((arr[off + 2] & 0x40) != 0) {
> + devip->tape_dce = (arr[off + 2] & 0x80) != 0;
> + return 0;
> + }
> + break;
> case 0x1c: /* Informational Exceptions Mode page */
> if (iec_m_pg[1] == arr[off + 1]) {
> memcpy(iec_m_pg + 2, arr + off + 2,
> @@ -3158,6 +3187,10 @@ static int resp_mode_select(struct scsi_cmnd *scp,
> set_mode_changed_ua:
> set_bit(SDEBUG_UA_MODE_CHANGED, devip->uas_bm);
> return 0;
> +
> +bad_pcode:
> + mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5);
> + return check_condition_result;
> }
>
> static int resp_temp_l_pg(unsigned char *arr)
next prev parent reply other threads:[~2025-02-19 21:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-13 9:26 [PATCH v2 0/7] scsi: scsi_debug: Add more tape support Kai Mäkisara
2025-02-13 9:26 ` [PATCH v2 1/7] scsi: scsi_debug: First fixes for tapes Kai Mäkisara
2025-02-19 16:03 ` John Meneghini
2025-02-13 9:26 ` [PATCH v2 2/7] scsi: scsi_debug: Add READ BLOCK LIMITS and modify LOAD " Kai Mäkisara
2025-02-19 21:16 ` John Meneghini
2025-02-13 9:26 ` [PATCH v2 3/7] scsi: scsi_debug: Add write support with block lengths and 4 bytes of data Kai Mäkisara
2025-02-19 21:45 ` John Meneghini
2025-02-13 9:26 ` [PATCH v2 4/7] scsi: scsi_debug: Add read support and update locate for tapes Kai Mäkisara
2025-02-19 21:56 ` John Meneghini
2025-02-13 9:26 ` [PATCH v2 5/7] scsi: scsi_debug: Add compression mode page " Kai Mäkisara
2025-02-19 21:58 ` John Meneghini [this message]
2025-02-13 9:26 ` [PATCH v2 6/7] scsi: scsi_debug: Reset tape setting at device reset Kai Mäkisara
2025-02-19 21:58 ` John Meneghini
2025-02-13 9:26 ` [PATCH v2 7/7] scsi: scsi_debug: Add support for partitioning the tape Kai Mäkisara
2025-02-19 22:17 ` John Meneghini
2025-02-13 16:12 ` [PATCH v2 0/7] scsi: scsi_debug: Add more tape support John Meneghini
2025-02-19 22:32 ` John Meneghini
2025-02-24 3:19 ` Martin K. Petersen
2025-02-24 15:13 ` "Kai Mäkisara (Kolumbus)"
2025-02-25 1:44 ` Martin K. Petersen
2025-03-04 3:19 ` Martin K. Petersen
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=f81d5709-ec8a-4d3a-a37e-e9c9a60f5099@redhat.com \
--to=jmeneghi@redhat.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=Kai.Makisara@kolumbus.fi \
--cc=dgilbert@interlog.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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