From: hare@suse.de (Hannes Reinecke)
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] scsi_id: Export target port group
Date: Mon, 06 Sep 2010 09:00:22 +0000 [thread overview]
Message-ID: <20100906090022.22A0B352D8@ochil.suse.de> (raw)
For ALUA support it's useful to have the target port group number
of a device. Export it.
Signed-off-by: Hannes Reinecke <hare@suse.de>
diff --git a/extras/scsi_id/scsi.h b/extras/scsi_id/scsi.h
index f5aa686..8e9ce40 100644
--- a/extras/scsi_id/scsi.h
+++ b/extras/scsi_id/scsi.h
@@ -54,6 +54,11 @@ struct scsi_ioctl_command {
#define SCSI_ID_T10_VENDOR 1
#define SCSI_ID_EUI_64 2
#define SCSI_ID_NAA 3
+#define SCSI_ID_RELPORT 4
+#define SCSI_ID_TGTGROUP 5
+#define SCSI_ID_LUNGROUP 6
+#define SCSI_ID_MD5 7
+#define SCSI_ID_NAME 8
/*
* Supported NAA values. These fit in 4 bits, so the "don't care" value
diff --git a/extras/scsi_id/scsi_id.c b/extras/scsi_id/scsi_id.c
index 3811ea5..6c88265 100644
--- a/extras/scsi_id/scsi_id.c
+++ b/extras/scsi_id/scsi_id.c
@@ -575,6 +575,9 @@ static int scsi_id(struct udev *udev, char *maj_min_dev)
printf("ID_WWN_WITH_EXTENSION=0x%s\n", dev_scsi.wwn);
}
}
+ if (dev_scsi.tgpt_group[0] != '\0') {
+ printf("ID_TARGET_PORT=%s\n", dev_scsi.tgpt_group);
+ }
if (dev_scsi.unit_serial_number[0] != '\0') {
printf("ID_SCSI_SERIAL=%s\n", dev_scsi.unit_serial_number);
}
diff --git a/extras/scsi_id/scsi_id.h b/extras/scsi_id/scsi_id.h
index 4475eac..f6c269f 100644
--- a/extras/scsi_id/scsi_id.h
+++ b/extras/scsi_id/scsi_id.h
@@ -53,6 +53,9 @@ struct scsi_id_device {
/* NULs if not set - otherwise hex encoding using lower-case e.g. '0xe00000d80000' */
char wwn_vendor_extension[17];
+
+ /* NULs if not set - otherwise decimal number */
+ char tgpt_group[8];
};
extern int scsi_std_inquiry(struct udev *udev, struct scsi_id_device *dev_scsi, const char *devname);
diff --git a/extras/scsi_id/scsi_serial.c b/extras/scsi_id/scsi_serial.c
index dd5e1fd..6f5da37 100644
--- a/extras/scsi_id/scsi_serial.c
+++ b/extras/scsi_id/scsi_serial.c
@@ -48,6 +48,7 @@
* is normally one or some small number of descriptors.
*/
static const struct scsi_id_search_values id_search_list[] = {
+ { SCSI_ID_TGTGROUP, SCSI_ID_NAA_DONT_CARE, SCSI_ID_BINARY },
{ SCSI_ID_NAA, SCSI_ID_NAA_IEEE_REG_EXTENDED, SCSI_ID_BINARY },
{ SCSI_ID_NAA, SCSI_ID_NAA_IEEE_REG_EXTENDED, SCSI_ID_ASCII },
{ SCSI_ID_NAA, SCSI_ID_NAA_IEEE_REG, SCSI_ID_BINARY },
@@ -485,16 +486,20 @@ static int check_fill_0x83_id(struct udev *udev,
struct scsi_id_device *dev_scsi,
unsigned char *page_83,
const struct scsi_id_search_values
- *id_search, char *serial, char *serial_short, int max_len,
- char *wwn,
- char *wwn_vendor_extension)
+ *id_search, char *serial, char *serial_short,
+ int max_len, char *wwn,
+ char *wwn_vendor_extension, char *tgpt_group)
{
int i, j, s, len;
/*
* ASSOCIATION must be with the device (value 0)
+ * or with the target port for SCSI_ID_TGTPORT
*/
- if ((page_83[1] & 0x30) != 0)
+ if (page_83[1] & 0x30 = 0x10)
+ if (id_search->id_type != SCSI_ID_TGTGROUP)
+ return 1;
+ else if ((page_83[1] & 0x30) != 0)
return 1;
if ((page_83[1] & 0x0f) != id_search->id_type)
@@ -536,6 +541,14 @@ static int check_fill_0x83_id(struct udev *udev,
return 1;
}
+ if (id_search->id_type = SCSI_ID_TGTGROUP && tgpt_group != NULL) {
+ unsigned int group;
+
+ group = ((unsigned int)page_83[6] << 8) | page_83[7];
+ sprintf(tgpt_group,"%x", group);
+ return 1;
+ }
+
serial[0] = hex_str[id_search->id_type];
/*
@@ -572,12 +585,13 @@ static int check_fill_0x83_id(struct udev *udev,
strcpy(serial_short, &serial[s]);
- if (id_search->id_type = SCSI_ID_NAA && wwn != NULL) {
- strncpy(wwn, &serial[s], 16);
+ if (id_search->id_type = SCSI_ID_NAA && wwn != NULL) {
+ strncpy(wwn, &serial[s], 16);
if (wwn_vendor_extension != NULL) {
strncpy(wwn_vendor_extension, &serial[s + 16], 16);
}
- }
+ }
+
return 0;
}
@@ -609,14 +623,14 @@ static int check_fill_0x83_prespc3(struct udev *udev,
static int do_scsi_page83_inquiry(struct udev *udev,
struct scsi_id_device *dev_scsi, int fd,
char *serial, char *serial_short, int len,
- char *unit_serial_number, char *wwn,
- char *wwn_vendor_extension)
+ char *unit_serial_number, char *wwn,
+ char *wwn_vendor_extension, char *tgpt_group)
{
int retval;
unsigned int id_ind, j;
unsigned char page_83[SCSI_INQ_BUFF_LEN];
- /* also pick up the page 80 serial number */
+ /* also pick up the page 80 serial number */
do_scsi_page80_inquiry(udev, dev_scsi, fd, NULL, unit_serial_number, MAX_SERIAL_LEN);
memset(page_83, 0, SCSI_INQ_BUFF_LEN);
@@ -680,8 +694,8 @@ static int do_scsi_page83_inquiry(struct udev *udev,
dev_scsi, &page_83[j],
&id_search_list[id_ind],
serial, serial_short, len,
- wwn,
- wwn_vendor_extension);
+ wwn, wwn_vendor_extension,
+ tgpt_group);
dbg(udev, "%s id desc %d/%d/%d\n", dev_scsi->kernel,
id_search_list[id_ind].id_type,
id_search_list[id_ind].naa_type,
@@ -895,7 +909,7 @@ int scsi_get_serial(struct udev *udev,
goto completed;
}
} else if (page_code = PAGE_83) {
- if (do_scsi_page83_inquiry(udev, dev_scsi, fd, dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_scsi->wwn, dev_scsi->wwn_vendor_extension)) {
+ if (do_scsi_page83_inquiry(udev, dev_scsi, fd, dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_scsi->wwn, dev_scsi->wwn_vendor_extension, dev_scsi->tgpt_group)) {
retval = 1;
goto completed;
} else {
@@ -911,7 +925,7 @@ int scsi_get_serial(struct udev *udev,
* conform to pre-SPC3 expectations.
*/
if (retval = 2) {
- if (do_scsi_page83_inquiry(udev, dev_scsi, fd, dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_scsi->wwn, dev_scsi->wwn_vendor_extension)) {
+ if (do_scsi_page83_inquiry(udev, dev_scsi, fd, dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_scsi->wwn, dev_scsi->wwn_vendor_extension, dev_scsi->tgpt_group)) {
retval = 1;
goto completed;
} else {
@@ -951,7 +965,7 @@ int scsi_get_serial(struct udev *udev,
for (ind = 4; ind <= page0[3] + 3; ind++)
if (page0[ind] = PAGE_83)
if (!do_scsi_page83_inquiry(udev, dev_scsi, fd,
- dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_scsi->wwn, dev_scsi->wwn_vendor_extension)) {
+ dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_scsi->wwn, dev_scsi->wwn_vendor_extension, dev_scsi->tgpt_group)) {
/*
* Success
*/
next reply other threads:[~2010-09-06 9:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-06 9:00 Hannes Reinecke [this message]
2010-09-07 6:24 ` [PATCH] scsi_id: Export target port group Kay Sievers
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=20100906090022.22A0B352D8@ochil.suse.de \
--to=hare@suse.de \
--cc=linux-hotplug@vger.kernel.org \
/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