Skip to contentSkip to conversation

: Make RELATIVE TARGET PORT IDENTIFER assignment always non zero

PATCH New Nicholas A. Bellinger 1 participant 1 message Feb 4, 2009 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Make RELATIVE TARGET PORT IDENTIFER assignment always non zero

Greetings all,

This patch makes RELATIVE TARGET PORT IDENTIFER assignment always a non zero value. This SCSI device unique 16-bit counter is allocated each time a new port is created, and is unique within a SCSI device.

Using a zero value is defined as Reserved in spc4r17 section 7.7.3.8.

This patch is made against lio-core-2.6.git/master
and tested on v2.6.29-rc2 x86 32-bit HVM. The lio-core-2.6.git tree can be found at:

http://git.kernel.org/?p=linux/kernel/git/nab/lio-core-2.6.git;a=summary

Signed-off-by Nicholas A. Bellinger
---
 drivers/lio-core/target_core_device.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
drivers/lio-core/target_core_device.c +15 -1
index ced583a..9f1503c 100644
@@ -508,7 +508,21 @@ extern se_port_t *core_alloc_port (se_device_t *dev)
 		return(NULL);
 	}
 again:
-	port->sep_rtpi = dev->dev_rpti_counter++;
+	/*
+	 * Allocate the next RELATIVE TARGET PORT IDENTIFER for this se_device_t.
+	 * Here is the table from spc4r17 section 7.7.3.8.
+	 * 
+	 *    Table 473 -- RELATIVE TARGET PORT IDENTIFIER field
+	 *
+	 * Code      Description
+	 * 0h        Reserved
+	 * 1h        Relative port 1, historically known as port A
+	 * 2h        Relative port 2, historically known as port B
+	 * 3h to FFFFh    Relative port 3 through 65 535
+	 */
+	if (!(port->sep_rtpi = dev->dev_rpti_counter++))
+		goto again;
+
 	list_for_each_entry(port_tmp, &dev->dev_sep_list, sep_list) {
 		/*
 		 * Make sure RELATIVE TARGET PORT IDENTIFER is unique
Signature · 1 line
1.5.4.1