From patchwork Thu Oct 5 19:40:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 729925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90BD0E92734 for ; Thu, 5 Oct 2023 19:42:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232043AbjJETmy (ORCPT ); Thu, 5 Oct 2023 15:42:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231671AbjJETmc (ORCPT ); Thu, 5 Oct 2023 15:42:32 -0400 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5066C11D; Thu, 5 Oct 2023 12:42:20 -0700 (PDT) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1c61acd1285so9960065ad.2; Thu, 05 Oct 2023 12:42:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696534939; x=1697139739; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UM8sqysXvoRJ5DMnsmYXvV6LHJ7K767rwmBQQL3CWG0=; b=Gwzf7bmbfsaE5uLTQIqr0b2lfW/rf6tJtN3k2YbcBwNS3AbFGqmbVcp46yUJtmBf+g r+KvaZor2NZA5ViuCtx/ftT0FCy3sEMUY+7sUc3Pv78QC9/0/Yyd81MzrmmN3dwsmDaw P9G44yICoDzV96+ioAThZYj/Z94N+ny6UC3QgC3YyL3A98Fu2q3W8DjR5ew5LkkRzQU3 Ik/GbAshgkqSMcpCn2xTIgVOoN/Xx9NQ6gRjvvdzAf8ANsTlzaL93O7u8ZT7wWk7j5wZ I2r+uBAJQ0tIHZ5Fal2bCW5469GYWnxP6o5Bs1zfKGMMjZnJ3+58fqbM5yP9vH9LUiEL bkFA== X-Gm-Message-State: AOJu0Yz7yC1bMlnA8AXK4iKpeGRhZ/nv1j/c+37ZmMuhUstDLli6MOQ4 9IPfncz4hlTzDpkpAaB94TI= X-Google-Smtp-Source: AGHT+IEu/IGDuVYMghR7GQP904jaIixAkzQKOK4CDMm3WbuLdPwpdMq8uO1o87X5a1sw5D4i7q5ATA== X-Received: by 2002:a17:902:7682:b0:1c7:249f:5e33 with SMTP id m2-20020a170902768200b001c7249f5e33mr5863483pll.46.1696534939630; Thu, 05 Oct 2023 12:42:19 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:ca3e:70ef:bad:2f]) by smtp.gmail.com with ESMTPSA id u4-20020a170902e5c400b001a9b29b6759sm2129596plf.183.2023.10.05.12.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 12:42:19 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Martin K . Petersen" , Christoph Hellwig , Niklas Cassel , Avri Altman , Bean Huo , Daejun Park , Bart Van Assche , Douglas Gilbert , "James E.J. Bottomley" Subject: [PATCH v2 13/15] scsi_debug: Implement the IO Advice Hints Grouping mode page Date: Thu, 5 Oct 2023 12:40:59 -0700 Message-ID: <20231005194129.1882245-14-bvanassche@acm.org> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog In-Reply-To: <20231005194129.1882245-1-bvanassche@acm.org> References: <20231005194129.1882245-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Implement an IO Advice Hints Grouping mode page with three permanent streams. A permanent stream is a stream for which the device server does not allow closing or otherwise modifying the configuration of that stream. The stream identifier enable (ST_ENBLE) bit specifies whether the stream identifier may be used in the GROUP NUMBER field of SCSI WRITE commands. Cc: Martin K. Petersen Cc: Douglas Gilbert Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_debug.c | 42 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index a96eb0d10346..d56989e94c4a 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -2241,6 +2241,36 @@ static int resp_ctrl_m_pg(unsigned char *p, int pcontrol, int target) return sizeof(ctrl_m_pg); } +enum { MAXIMUM_NUMBER_OF_STREAMS = 4 }; + +/* IO Advice Hints Grouping mode page */ +static int resp_grouping_m_pg(unsigned char *p, int pcontrol, int target) +{ + /* IO Advice Hints Grouping mode page */ + struct grouping_m_pg { + u8 page_code; + u8 subpage_code; + __be16 page_length; + u8 reserved[12]; + struct scsi_io_group_descriptor + descr[MAXIMUM_NUMBER_OF_STREAMS]; + }; + static const struct grouping_m_pg gr_m_pg = { + .page_code = 0xa, + .subpage_code = 5, + .page_length = cpu_to_be16(sizeof(gr_m_pg) - 4), + .descr = { + { .st_enble = 1 }, + { .st_enble = 1 }, + { .st_enble = 1 }, + { .st_enble = 0 }, + } + }; + + BUILD_BUG_ON(sizeof(struct grouping_m_pg) != 16 + 4 * 16); + memcpy(p, &gr_m_pg, sizeof(gr_m_pg)); + return sizeof(gr_m_pg); +} static int resp_iec_m_pg(unsigned char *p, int pcontrol, int target) { /* Informational Exceptions control mode page for mode_sense */ @@ -2420,9 +2450,17 @@ static int resp_mode_sense(struct scsi_cmnd *scp, } break; case 0xa: /* Control Mode page, all devices */ - if (subpcode > 0x0 && subpcode < 0xff) + switch (subpcode) { + case 0: + case 0xff: + len = resp_ctrl_m_pg(ap, pcontrol, target); + break; + case 0x05: + len = resp_grouping_m_pg(ap, pcontrol, target); + break; + default: goto bad_subpcode; - len = resp_ctrl_m_pg(ap, pcontrol, target); + } offset += len; break; case 0x19: /* if spc==1 then sas phy, control+discover */