linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: target: core: Set MULTIP bit in INQUIRY
@ 2022-09-06  7:48 Dmitry Bogdanov
  2022-09-07 20:06 ` Mike Christie
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Bogdanov @ 2022-09-06  7:48 UTC (permalink / raw)
  To: Martin Petersen, target-devel
  Cc: linux-scsi, linux, Dmitry Bogdanov, Roman Bolshakov

SAM-5 4.8.3 (SCSI target device with multiple SCSI ports structure)
obligates to set MULTIP bit when there's multiple SCSI target ports:

> Each device server shall indicate the presence of multiple SCSI target
> ports by setting the MULTIP bit to one in its standard INQUIRY data
> (see SPC-4).

The change sets MULTIP bit automatically to indicate the presence of
multiple SCSI target ports within standard inquiry response data if
there are multiple target ports in all target port groups of the
se_device.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
The patch is intended for 6.1/scsi-queue branch.
---
 drivers/target/target_core_spc.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index c14441c89bed..32fb38ce98f4 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -75,6 +75,8 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
 	struct se_portal_group *tpg = lun->lun_tpg;
 	struct se_device *dev = cmd->se_dev;
 	struct se_session *sess = cmd->se_sess;
+	struct se_lun *tmp_lun;
+	size_t dev_ports = 0;
 
 	/* Set RMB (removable media) for tape devices */
 	if (dev->transport->get_device_type(dev) == TYPE_TAPE)
@@ -115,6 +117,20 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
 			buf[5] |= 0x1;
 	}
 
+	spin_lock(&dev->se_port_lock);
+	list_for_each_entry(tmp_lun, &dev->dev_sep_list, lun_dev_link) {
+		dev_ports++;
+		/* Exact number of ports does not matter for MULTIP bit */
+		if (dev_ports > 1)
+			break;
+	}
+	spin_unlock(&dev->se_port_lock);
+	/*
+	 * Set MULTIP bit to indicate presence of multiple SCSI target ports
+	 */
+	if (dev_ports > 1)
+		buf[6] |= 0x10;
+
 	buf[7] = 0x2; /* CmdQue=1 */
 
 	/*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: target: core: Set MULTIP bit in INQUIRY
  2022-09-06  7:48 [PATCH] scsi: target: core: Set MULTIP bit in INQUIRY Dmitry Bogdanov
@ 2022-09-07 20:06 ` Mike Christie
  2022-09-09  8:30   ` Dmitry Bogdanov
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Christie @ 2022-09-07 20:06 UTC (permalink / raw)
  To: Dmitry Bogdanov, Martin Petersen, target-devel
  Cc: linux-scsi, linux, Roman Bolshakov

On 9/6/22 2:48 AM, Dmitry Bogdanov wrote:
> 
> diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
> index c14441c89bed..32fb38ce98f4 100644
> --- a/drivers/target/target_core_spc.c
> +++ b/drivers/target/target_core_spc.c
> @@ -75,6 +75,8 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
>  	struct se_portal_group *tpg = lun->lun_tpg;
>  	struct se_device *dev = cmd->se_dev;
>  	struct se_session *sess = cmd->se_sess;
> +	struct se_lun *tmp_lun;
> +	size_t dev_ports = 0;
>  
>  	/* Set RMB (removable media) for tape devices */
>  	if (dev->transport->get_device_type(dev) == TYPE_TAPE)
> @@ -115,6 +117,20 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
>  			buf[5] |= 0x1;
>  	}
>  
> +	spin_lock(&dev->se_port_lock);
> +	list_for_each_entry(tmp_lun, &dev->dev_sep_list, lun_dev_link) {
> +		dev_ports++;
> +		/* Exact number of ports does not matter for MULTIP bit */
> +		if (dev_ports > 1)
> +			break;

Can you just check se_deice->export_count instead of looping?

Also, setting the bit seems fine. I was just wondering what uses it?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: target: core: Set MULTIP bit in INQUIRY
  2022-09-07 20:06 ` Mike Christie
@ 2022-09-09  8:30   ` Dmitry Bogdanov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Bogdanov @ 2022-09-09  8:30 UTC (permalink / raw)
  To: Mike Christie
  Cc: Martin Petersen, target-devel, linux-scsi, linux, Roman Bolshakov

On Wed, Sep 07, 2022 at 03:06:04PM -0500, Mike Christie wrote:
> 
> On 9/6/22 2:48 AM, Dmitry Bogdanov wrote:
> >
> > diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
> > index c14441c89bed..32fb38ce98f4 100644
> > --- a/drivers/target/target_core_spc.c
> > +++ b/drivers/target/target_core_spc.c
> > @@ -75,6 +75,8 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
> >       struct se_portal_group *tpg = lun->lun_tpg;
> >       struct se_device *dev = cmd->se_dev;
> >       struct se_session *sess = cmd->se_sess;
> > +     struct se_lun *tmp_lun;
> > +     size_t dev_ports = 0;
> >
> >       /* Set RMB (removable media) for tape devices */
> >       if (dev->transport->get_device_type(dev) == TYPE_TAPE)
> > @@ -115,6 +117,20 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
> >                       buf[5] |= 0x1;
> >       }
> >
> > +     spin_lock(&dev->se_port_lock);
> > +     list_for_each_entry(tmp_lun, &dev->dev_sep_list, lun_dev_link) {
> > +             dev_ports++;
> > +             /* Exact number of ports does not matter for MULTIP bit */
> > +             if (dev_ports > 1)
> > +                     break;
> 
> Can you just check se_deice->export_count instead of looping?
Yes, of course, dev->export_count exactly fits here.
> 
> Also, setting the bit seems fine. I was just wondering what uses it?
There is no way to find it out. At least just to conform to the
standard. May be for some archaic users like AIX.
Btw, SCST reports MULTIP=1 always.

BR,
 Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] scsi: target: core: Set MULTIP bit in INQUIRY
@ 2020-04-20  0:18 Dmitry Bogdanov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Bogdanov @ 2020-04-20  0:18 UTC (permalink / raw)
  To: Martin Petersen, target-devel
  Cc: linux-scsi, linux, Dmitry Bogdanov, Roman Bolshakov

SAM-5 4.8.3 (SCSI target device with multiple SCSI ports structure)
obligates to set MULTIP bit when there's multiple SCSI target ports:

> Each device server shall indicate the presence of multiple SCSI target
> ports by setting the MULTIP bit to one in its standard INQUIRY data
> (see SPC-4).

The change sets MULTIP bit automatically to indicate the presence of
multiple SCSI target ports within standard inquiry response data if
there are multiple target ports in all target port groups of the
se_device.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
The patch is intended for 6.1/scsi-queue branch.
---
 drivers/target/target_core_spc.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index c14441c89bed..32fb38ce98f4 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -75,6 +75,8 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
 	struct se_portal_group *tpg = lun->lun_tpg;
 	struct se_device *dev = cmd->se_dev;
 	struct se_session *sess = cmd->se_sess;
+	struct se_lun *tmp_lun;
+	size_t dev_ports = 0;
 
 	/* Set RMB (removable media) for tape devices */
 	if (dev->transport->get_device_type(dev) == TYPE_TAPE)
@@ -115,6 +117,20 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
 			buf[5] |= 0x1;
 	}
 
+	spin_lock(&dev->se_port_lock);
+	list_for_each_entry(tmp_lun, &dev->dev_sep_list, lun_dev_link) {
+		dev_ports++;
+		/* Exact number of ports does not matter for MULTIP bit */
+		if (dev_ports > 1)
+			break;
+	}
+	spin_unlock(&dev->se_port_lock);
+	/*
+	 * Set MULTIP bit to indicate presence of multiple SCSI target ports
+	 */
+	if (dev_ports > 1)
+		buf[6] |= 0x10;
+
 	buf[7] = 0x2; /* CmdQue=1 */
 
 	/*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-09  8:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06  7:48 [PATCH] scsi: target: core: Set MULTIP bit in INQUIRY Dmitry Bogdanov
2022-09-07 20:06 ` Mike Christie
2022-09-09  8:30   ` Dmitry Bogdanov
  -- strict thread matches above, loose matches on Subject: below --
2020-04-20  0:18 Dmitry Bogdanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).