ieee1394: sbp2: offer SAM-conforming target port ID in sysfs
PATCH 1/1 ieee1394: sbp2: offer SAM-conforming target port ID in sysfs
With "modprobe sbp2 long_ieee1394_id=y", the format of /sys/bus/scsi/devices/*:*:*:*/ieee1394_id is changed from e.g. 0001041010004beb:0:0 to 0001041010004beb:00042c:0000.
The longer format fully conforms to object identifier sizes as per SAM(-2...4) and reflects what the SAM target port identifier is meant to
contain: A Discovery ID allegedly specified by ISO/IEC 13213:1994 --- however there is no such thing; the authors of SAM probably meant Directory ID). Especially target nodes with multiple dynamically added targets may use Directory IDs to persistently identify target ports.
The new format is independent of implementation details of nodemgr. Thus the same ieee1394_id attribute format can be implemented in the new firewire stack.
The ieee1394_id is typically used to create persistently named links in /dev/disk/by-id.
---
Requires patch 'ieee1394: fix calculation of sysfs attribute "address"'.
drivers/ieee1394/nodemgr.c | 5 +++++ drivers/ieee1394/nodemgr.h | 1 + drivers/ieee1394/sbp2.c | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-)
drivers/ieee1394/sbp2.c +30 -2
@@ -194,6 +194,28 @@ MODULE_PARM_DESC(workarounds, "Work arou ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE) ", or a combination)"); +/* +* This influences the format of the sysfs attribute +* /sys/bus/scsi/devices/.../ieee1394_id. +* +* The default format is like in older kernels: %016Lx:%d:%d +* It contains the target's EUI-64, a number given to the logical unit by +* the ieee1394 driver's nodemgr (starting at 0), and the LUN. +* +* The long format is: %016Lx:%06x:%04x +* It contains the target's EUI-64, the unit directory's directory_ID as per +* IEEE 1212 clause 7.7.19, and the LUN. This format comes closest to the +* format of SBP(-3) target port and logical unit identifier as per SAM (SCSI +* Architecture Model) rev.2 to 4 annex A. Therefore and because it is +* independent of the implementation of the ieee1394 nodemgr, the longer format +* is recommended for future use. +* +*/ +static int sbp2_long_sysfs_ieee1394_id; +module_param_named (long_ieee1394_id, sbp2_long_sysfs_ieee1394_id, bool,0644 ); +MODULE_PARM_DESC (long_ieee1394_id,"8+3+2 bytes format of ieee1394_id in sysfs " +"(default = backwards-compatible = N, SAM-conforming = Y)" ); + #define SBP2_INFO(fmt, args...) HPSB_INFO("sbp2: "fmt, ## args) #define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args)
@@ -2100,8 +2122,14 @@ static ssize_t sbp2_sysfs_ieee1394_id_shif (!(lu = (struct sbp2_lu *)sdev->host->hostdata[0 ]))return 0 ; -return sprintf (buf,"%016Lx:%d:%d\n" , (unsigned long long )lu->ne->guid, - lu->ud->id,ORB_SET_LUN (lu->lun)); +if (sbp2_long_sysfs_ieee1394_id) +return sprintf (buf,"%016Lx:%06x:%04x\n" , + (unsigned long long )lu->ne->guid, + lu->ud->directory_id,ORB_SET_LUN (lu->lun)); +else +return sprintf (buf,"%016Lx:%d:%d\n" , + (unsigned long long )lu->ne->guid, + lu->ud->id,ORB_SET_LUN (lu->lun)); }MODULE_AUTHOR ("Ben Collins <[email protected]>" );
drivers/ieee1394/nodemgr.c +5 -0
@@ -977,6 +977,7 @@ static struct unit_directory *nodemgr_pr ud->ne = ne; ud->ignore_driver = ignore_drivers; ud->address = ud_kv->offset +CSR1212_REGISTER_SPACE_BASE ; + ud->directory_id = ud->address &0xffffff ; ud->ud_kv = ud_kv; ud->id = (*id)++;
@@ -1085,6 +1086,10 @@ static struct unit_directory *nodemgr_prbreak ; +case CSR1212_KV_ID_DIRECTORY_ID : + ud->directory_id = kv->value.immediate; +break ; +default :break ; }
drivers/ieee1394/nodemgr.h +1 -0
@@ -75,6 +75,7 @@ struct unit_directory {struct csr1212_keyval *model_name_kv;quadlet_t specifier_id;quadlet_t version; +quadlet_t directory_id;unsigned int id;
Signature · 3 lines
Stefan Richter -=====-=-=== -=-= ==-== http://arcgraph.de/sr/
PATCH 1/1 firewire: fw-sbp2: implement sysfs ieee1394_id
The attribute /sys/bus/scsi/devices/*:*:*:*/ieee1394_id, as generated by the old sbp2 driver, is typically used to create persistently named links in /dev/disk/by-id.
--- drivers/firewire/fw-device.h | 1 drivers/firewire/fw-sbp2.c | 53 +++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
drivers/firewire/fw-sbp2.c +53 -0
@@ -1102,6 +1102,58 @@ static int sbp2_scsi_abort(struct scsi_creturn SUCCESS ; } +/* +* Format of /sys/bus/scsi/devices/.../ieee1394_id: +* u64 EUI-64 : u24 directory_ID : u16 LUN (all printed in hexadecimal) +* +* This is the concatenation of target port identifier and logical unit +* identifier as per SAM-2...SAM-4 annex A. +*/ +static ssize_t +sbp2_sysfs_ieee1394_id_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct scsi_device *sdev =to_scsi_device (dev); +struct sbp2_device *sd; +struct fw_unit *unit; +struct fw_device *device; +u32 directory_id; +struct fw_csr_iterator ci; +int key, value, lun; + +if (!sdev) +return 0 ; + sd = (struct sbp2_device *)sdev->host->hostdata; + unit = sd->unit; + device =fw_device (unit->device.parent); + +/* implicit directory ID */ + directory_id = ((unit->directory - device->config_rom) *4 + +CSR_CONFIG_ROM ) &0xffffff ; + +/* explicit directory ID, overrides implicit ID if present */ +fw_csr_iterator_init (&ci, unit->directory); +while (fw_csr_iterator_next (&ci, &key, &value)) +if (key ==CSR_DIRECTORY_ID ) { + directory_id = value; +break ; + } + +/* FIXME: Make this work for multi-lun devices. */ + lun =0 ; + +return sprintf (buf,"%08x%08x:%06x:%04x\n" , + device->config_rom[3 ], device->config_rom[4 ], + directory_id, lun); +} + +static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL); + +static struct device_attribute *sbp2_scsi_sysfs_attrs[] = { + &dev_attr_ieee1394_id, +NULL +}; +static struct scsi_host_template scsi_driver_template = { .module =THIS_MODULE , .name ="SBP-2 IEEE-1394" ,
@@ -1115,6 +1167,7 @@ static struct scsi_host_template scsi_dr .use_clustering = ENABLE_CLUSTERING, .cmd_per_lun = 1, .can_queue = 1, + .sdev_attrs = sbp2_scsi_sysfs_attrs, };MODULE_AUTHOR ("Kristian Hoegsberg <[email protected]>" );
drivers/firewire/fw-device.h +1 -0
@@ -99,6 +99,7 @@ fw_unit(struct device *dev)#define CSR_DEPENDENT_INFO 0x14#define CSR_MODEL 0x17#define CSR_INSTANCE 0x18 +#define CSR_DIRECTORY_ID 0x20#define SBP2_COMMAND_SET_SPECIFIER 0x38#define SBP2_COMMAND_SET 0x39
Signature · 3 lines
Stefan Richter -=====-=-=== -=-= ==-== http://arcgraph.de/sr/
Re: [PATCH] firewire: fw-sbp2: implement sysfs ieee1394_id
Quoted 5 lines · Stefan Richter
The attribute /sys/bus/scsi/devices/*:*:*:*/ieee1394_id, as generated by the old sbp2 driver, is typically used to create persistently named links in
/dev/disk/by-id.Signed-off-by Stefan Richter <[email protected]>
Looks good to me.
Quoted 104 lines
--- drivers/firewire/fw-device.h | 1 drivers/firewire/fw-sbp2.c | 53 +++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)Index:
linux/drivers/firewire/fw-sbp2.c
===================================================================drivers/firewire/fw-sbp2.c +53
-0@@ -1102,6 +1102,58 @@ static int sbp2_scsi_abort(struct scsi_creturn SUCCESS ; } +/* +* Format of /sys/bus/scsi/devices/.../ieee1394_id: +* u64 EUI-64 : u24 directory_ID : u16 LUN (all printed in hexadecimal) +* +* This is the concatenation of target port identifier and logical unit +* identifier as per SAM-2...SAM-4 annex A. +*/ +static ssize_t +sbp2_sysfs_ieee1394_id_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct scsi_device *sdev =to_scsi_device (dev); +struct sbp2_device *sd; +struct fw_unit *unit; +struct fw_device *device; +u32 directory_id; +struct fw_csr_iterator ci; +int key, value, lun; + +if (!sdev) +return 0 ; + sd = (struct sbp2_device *)sdev->host->hostdata; + unit = sd->unit; + device =fw_device (unit->device.parent); + +/* implicit directory ID */ + directory_id = ((unit->directory - device->config_rom) *4 + +CSR_CONFIG_ROM ) &0xffffff ; + +/* explicit directory ID, overrides implicit ID if present */ +fw_csr_iterator_init (&ci, unit->directory); +while (fw_csr_iterator_next (&ci, &key, &value)) +if (key ==CSR_DIRECTORY_ID ) { + directory_id = value; +break ; + } + +/* FIXME: Make this work for multi-lun devices. */ + lun =0 ; + +return sprintf (buf,"%08x%08x:%06x:%04x\n" , + device->config_rom[3 ], device->config_rom[4 ], + directory_id, lun); +} + +static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL); + +static struct device_attribute *sbp2_scsi_sysfs_attrs[] = { + &dev_attr_ieee1394_id, +NULL +}; +static struct scsi_host_template scsi_driver_template = { .module =THIS_MODULE , .name ="SBP-2 IEEE-1394" ,@@ -1115,6 +1167,7 @@ static struct scsi_host_template scsi_dr .use_clustering = ENABLE_CLUSTERING, .cmd_per_lun = 1, .can_queue = 1, + .sdev_attrs = sbp2_scsi_sysfs_attrs, };MODULE_AUTHOR ("Kristian Hoegsberg <[email protected]>" );Index:
linux/drivers/firewire/fw-device.h
===================================================================drivers/firewire/fw-device.h +1
-1@@ -99,6 +99,7 @@ fw_unit(struct device *dev)#define CSR_DEPENDENT_INFO 0x14#define CSR_MODEL 0x17#define CSR_INSTANCE 0x18 +#define CSR_DIRECTORY_ID 0x20#define SBP2_COMMAND_SET_SPECIFIER 0x38#define SBP2_COMMAND_SET 0x39 --Stefan Richter
-=====-=-=== -=-= ==-==
http://arcgraph.de/sr/-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux1394-devel