* Transport Attributes -- attempt#4
@ 2004-01-20 21:56 Martin Hicks
2004-01-20 23:48 ` Patrick Mansfield
2004-02-24 0:17 ` James Bottomley
0 siblings, 2 replies; 8+ messages in thread
From: Martin Hicks @ 2004-01-20 21:56 UTC (permalink / raw)
To: linux-scsi, James Bottomley
[-- Attachment #1: Type: text/plain, Size: 512 bytes --]
Hi again,
Updated patches against Linus' bk tree from earlier today. The patch
that fixes up the scsi_sysfs.c error path, that was sent out by me on
Jan 16, is required for the core patch to apply cleanly.
I think I've addressed all the comments from the last round with the
exception of doing Lazy registration of the transport classes. I'm
still not totally convinced that this is really required.
thanks
mh
--
Martin Hicks Wild Open Source Inc.
mort@wildopensource.com 613-266-2296
[-- Attachment #2: scsi-transport-class-attr-core-v5-1.diff --]
[-- Type: text/plain, Size: 21621 bytes --]
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1494 -> 1.1495
# include/scsi/scsi_device.h 1.11 -> 1.12
# include/scsi/scsi_host.h 1.13 -> 1.14
# drivers/scsi/scsi_sysfs.c 1.39 -> 1.40
# drivers/scsi/scsi_priv.h 1.30 -> 1.31
# drivers/scsi/scsi_scan.c 1.115 -> 1.116
# drivers/scsi/Makefile 1.51 -> 1.52
# drivers/scsi/Kconfig 1.48 -> 1.49
# (new) -> 1.1 include/scsi/scsi_transport_spi.h
# (new) -> 1.1 drivers/scsi/scsi_transport_spi.c
# (new) -> 1.1 include/scsi/scsi_transport.h
# (new) -> 1.1 drivers/scsi/scsi_transport_fc.c
# (new) -> 1.1 include/scsi/scsi_transport_fc.h
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/01/20 mort@green.i.bork.org 1.1495
# Transport Attributes core patch
# --------------------------------------------
#
diff -Nru a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
--- a/drivers/scsi/Kconfig Tue Jan 20 15:52:29 2004
+++ b/drivers/scsi/Kconfig Tue Jan 20 15:52:29 2004
@@ -196,6 +196,25 @@
there should be no noticeable performance impact as long as you have
logging turned off.
+menu "SCSI Transport Attributes"
+ depends on SCSI
+
+config SCSI_SPI_ATTRS
+ bool "Parallel SCSI (SPI) Transport Attributes"
+ depends on SCSI
+ help
+ If you wish to export transport-specific information about
+ each attached SCSI device to sysfs, say Y. Otherwise, say N.
+
+config SCSI_FC_ATTRS
+ bool "FiberChannel Transport Attributes"
+ depends on SCSI
+ help
+ If you wish to export transport-specific information about
+ each attached FiberChannel device to sysfs, say Y.
+ Otherwise, say N.
+
+endmenu
menu "SCSI low-level drivers"
depends on SCSI!=n
diff -Nru a/drivers/scsi/Makefile b/drivers/scsi/Makefile
--- a/drivers/scsi/Makefile Tue Jan 20 15:52:29 2004
+++ b/drivers/scsi/Makefile Tue Jan 20 15:52:29 2004
@@ -131,7 +131,9 @@
scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o
scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o
scsi_mod-$(CONFIG_X86_PC9800) += scsi_pc98.o
-
+scsi_mod-$(CONFIG_SCSI_SPI_ATTRS) += scsi_transport_spi.o
+scsi_mod-$(CONFIG_SCSI_FC_ATTRS) += scsi_transport_fc.o
+
sd_mod-objs := sd.o
sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o
initio-objs := ini9100u.o i91uscsi.o
diff -Nru a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
--- a/drivers/scsi/scsi_priv.h Tue Jan 20 15:52:29 2004
+++ b/drivers/scsi/scsi_priv.h Tue Jan 20 15:52:29 2004
@@ -156,6 +156,7 @@
extern int scsi_sysfs_add_host(struct Scsi_Host *);
extern int scsi_sysfs_register(void);
extern void scsi_sysfs_unregister(void);
+extern struct scsi_transport_template blank_transport_template;
extern struct class sdev_class;
extern struct bus_type scsi_bus_type;
diff -Nru a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
--- a/drivers/scsi/scsi_scan.c Tue Jan 20 15:52:29 2004
+++ b/drivers/scsi/scsi_scan.c Tue Jan 20 15:52:29 2004
@@ -35,6 +35,7 @@
#include <scsi/scsi_driver.h>
#include <scsi/scsi_devinfo.h>
#include <scsi/scsi_host.h>
+#include <scsi/scsi_transport.h>
#include "scsi.h"
#include "scsi_priv.h"
@@ -237,6 +238,16 @@
goto out_free_queue;
}
+ /* Give each shost a default transportt if the driver
+ * doesn't yet support Transport Attributes */
+ if (!shost->transportt)
+ shost->transportt = &blank_transport_template;
+
+ if (shost->transportt->setup) {
+ if (shost->transportt->setup(sdev))
+ goto out_cleanup_slave;
+ }
+
if (get_device(&sdev->host->shost_gendev)) {
device_initialize(&sdev->sdev_gendev);
@@ -253,8 +264,15 @@
snprintf(sdev->sdev_classdev.class_id, BUS_ID_SIZE,
"%d:%d:%d:%d", sdev->host->host_no,
sdev->channel, sdev->id, sdev->lun);
+
+ class_device_initialize(&sdev->transport_classdev);
+ sdev->transport_classdev.dev = &sdev->sdev_gendev;
+ sdev->transport_classdev.class = sdev->host->transportt->class;
+ snprintf(sdev->transport_classdev.class_id, BUS_ID_SIZE,
+ "%d:%d:%d:%d", sdev->host->host_no,
+ sdev->channel, sdev->id, sdev->lun);
} else
- goto out_cleanup_slave;
+ goto out_cleanup_transport;
/*
* If there are any same target siblings, add this to the
@@ -283,6 +301,9 @@
spin_unlock_irqrestore(shost->host_lock, flags);
return sdev;
+out_cleanup_transport:
+ if (shost->transportt->cleanup)
+ shost->transportt->cleanup(sdev);
out_cleanup_slave:
if (shost->hostt->slave_destroy)
shost->hostt->slave_destroy(sdev);
@@ -744,6 +765,8 @@
} else {
if (sdev->host->hostt->slave_destroy)
sdev->host->hostt->slave_destroy(sdev);
+ if (sdev->host->transportt->cleanup)
+ sdev->host->transportt->cleanup(sdev);
put_device(&sdev->sdev_gendev);
}
out:
@@ -1300,5 +1323,7 @@
if (sdev->host->hostt->slave_destroy)
sdev->host->hostt->slave_destroy(sdev);
+ if (sdev->host->transportt->cleanup)
+ sdev->host->transportt->cleanup(sdev);
put_device(&sdev->sdev_gendev);
}
diff -Nru a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
--- a/drivers/scsi/scsi_sysfs.c Tue Jan 20 15:52:29 2004
+++ b/drivers/scsi/scsi_sysfs.c Tue Jan 20 15:52:29 2004
@@ -13,6 +13,9 @@
#include <linux/device.h>
#include <scsi/scsi_host.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_spi.h>
+#include <scsi/scsi_transport_fc.h>
#include "scsi.h"
#include "scsi_priv.h"
@@ -162,13 +165,31 @@
int error;
error = bus_register(&scsi_bus_type);
- if (!error) {
- error = class_register(&sdev_class);
- if (error)
- bus_unregister(&scsi_bus_type);
- }
+ if (error)
+ return error;
+
+ error = class_register(&sdev_class);
+ if (error)
+ goto undo_bus;
+
+ error = scsi_spi_transport_init();
+ if (error)
+ goto undo_sdev;
+
+ error = scsi_fc_transport_init();
+ if (error)
+ goto undo_all;
+ out:
return error;
+
+ undo_all:
+ scsi_spi_transport_exit();
+ undo_sdev:
+ class_unregister(&sdev_class);
+ undo_bus:
+ bus_unregister(&scsi_bus_type);
+ goto out;
}
void scsi_sysfs_unregister(void)
@@ -344,6 +365,7 @@
**/
int scsi_sysfs_add_sdev(struct scsi_device *sdev)
{
+ struct class_device_attribute **attrs;
int error = -EINVAL, i;
if (sdev->sdev_state != SDEV_CREATED)
@@ -363,6 +385,12 @@
goto clean_device;
}
+ if (sdev->transport_classdev.class) {
+ error = class_device_add(&sdev->transport_classdev);
+ if (error)
+ goto clean_device2;
+ }
+
get_device(&sdev->sdev_gendev);
if (sdev->host->hostt->sdev_attrs) {
@@ -388,10 +416,24 @@
}
}
+ if (sdev->transport_classdev.class) {
+ attrs = sdev->host->transportt->attrs;
+ for (i = 0; attrs[i]; i++) {
+ error = class_device_create_file(&sdev->transport_classdev,
+ attrs[i]);
+ if (error) {
+ scsi_remove_device(sdev);
+ goto out;
+ }
+ }
+ }
+
out:
return error;
-clean_device:
+ clean_device2:
+ class_device_del(&sdev->sdev_classdev);
+ clean_device:
sdev->sdev_state = SDEV_CANCEL;
device_del(&sdev->sdev_gendev);
@@ -409,9 +451,12 @@
if (sdev->sdev_state == SDEV_RUNNING || sdev->sdev_state == SDEV_CANCEL) {
sdev->sdev_state = SDEV_DEL;
class_device_unregister(&sdev->sdev_classdev);
+ class_device_unregister(&sdev->transport_classdev);
device_del(&sdev->sdev_gendev);
if (sdev->host->hostt->slave_destroy)
sdev->host->hostt->slave_destroy(sdev);
+ if (sdev->host->transportt->cleanup)
+ sdev->host->transportt->cleanup(sdev);
put_device(&sdev->sdev_gendev);
}
}
@@ -498,3 +543,7 @@
return 0;
}
+
+/* A blank transport template that is used in drivers that don't
+ * yet implement Transport Attributes */
+struct scsi_transport_template blank_transport_template;
diff -Nru a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/drivers/scsi/scsi_transport_fc.c Tue Jan 20 15:52:29 2004
@@ -0,0 +1,116 @@
+/*
+ * FiberChannel transport specific attributes exported to sysfs.
+ *
+ * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_fc.h>
+
+static void transport_class_release(struct class_device *class_dev);
+
+struct class fc_transport_class = {
+ .name = "fc_transport",
+ .release = transport_class_release,
+};
+
+
+int scsi_fc_transport_init(void)
+{
+ return class_register(&fc_transport_class);
+}
+
+void scsi_fc_tranport_exit(void)
+{
+ class_unregister(&fc_transport_class);
+}
+
+/* Allocates the struct to place the attribute values in.
+ * Usually called from the scsi host driver's slave_alloc
+ * function.
+ */
+static int fc_alloc_transport_attrs(struct scsi_device *sdev)
+{
+ sdev->transport_attr_values = kmalloc(sizeof(struct fc_transport_attrs),
+ GFP_ATOMIC);
+ if (!sdev->transport_attr_values)
+ return -ENOMEM;
+
+ memcpy(sdev->transport_attr_values, sdev->host->transportt->default_attr_values,
+ sizeof(struct fc_transport_attrs));
+
+ return 0;
+}
+
+static void fc_destroy_transport_attrs(struct scsi_device *sdev)
+{
+ kfree(sdev->transport_attr_values);
+}
+
+static void transport_class_release(struct class_device *class_dev)
+{
+ struct scsi_device *sdev = transport_class_to_sdev(class_dev);
+ put_device(&sdev->sdev_gendev);
+}
+
+#define fc_transport_show_function(field, format_string, cast) \
+static ssize_t \
+show_fc_transport_##field (struct class_device *cdev, char *buf) \
+{ \
+ struct scsi_device *sdev = transport_class_to_sdev(cdev); \
+ struct fc_transport_attrs *tp; \
+ tp = (struct fc_transport_attrs *)sdev->transport_attr_values; \
+ return snprintf(buf, 20, format_string, cast tp->field); \
+}
+
+#define fc_transport_rd_attr(field, format_string) \
+ fc_transport_show_function(field, format_string, ) \
+static CLASS_DEVICE_ATTR( field, S_IRUGO, show_fc_transport_##field, NULL)
+
+#define fc_transport_rd_attr_cast(field, format_string, cast) \
+ fc_transport_show_function(field, format_string, (cast)) \
+static CLASS_DEVICE_ATTR( field, S_IRUGO, show_fc_transport_##field, NULL)
+
+
+/* the FiberChannel Tranport Attributes: */
+fc_transport_rd_attr_cast(node_name, "0x%llx\n", unsigned long long);
+fc_transport_rd_attr_cast(port_name, "0x%llx\n", unsigned long long);
+fc_transport_rd_attr(port_id, "0x%06x\n");
+
+struct class_device_attribute *fc_transport_attrs[] = {
+ &class_device_attr_node_name,
+ &class_device_attr_port_name,
+ &class_device_attr_port_id,
+ NULL
+};
+
+struct fc_transport_attrs fc_transport_attr_defaults = {
+ .node_name = -1,
+ .port_name = -1,
+ .port_id = -1,
+};
+
+struct scsi_transport_template fc_transport_template = {
+ .attrs = fc_transport_attrs,
+ .class = &fc_transport_class,
+ .setup = &fc_alloc_transport_attrs,
+ .cleanup = &fc_destroy_transport_attrs,
+ .default_attr_values = &fc_transport_attr_defaults,
+};
+EXPORT_SYMBOL(fc_transport_template);
diff -Nru a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/drivers/scsi/scsi_transport_spi.c Tue Jan 20 15:52:29 2004
@@ -0,0 +1,104 @@
+/*
+ * Parallel SCSI (SPI) transport specific attributes exported to sysfs.
+ *
+ * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_spi.h>
+
+static void transport_class_release(struct class_device *class_dev);
+
+struct class spi_transport_class = {
+ .name = "spi_transport",
+ .release = transport_class_release,
+};
+
+int scsi_spi_transport_init(void)
+{
+ return class_register(&spi_transport_class);
+}
+
+void scsi_spi_transport_exit(void)
+{
+ class_unregister(&spi_transport_class);
+}
+
+static int spi_alloc_transport_attrs(struct scsi_device *sdev)
+{
+ sdev->transport_attr_values = kmalloc(sizeof(struct spi_transport_attrs),
+ GFP_ATOMIC);
+ if (!sdev->transport_attr_values)
+ return -ENOMEM;
+
+ memcpy(sdev->transport_attr_values, sdev->host->transportt->default_attr_values,
+ sizeof(struct spi_transport_attrs));
+
+ return 0;
+}
+
+static void spi_destroy_transport_attrs(struct scsi_device *sdev)
+{
+ kfree(sdev->transport_attr_values);
+}
+
+static void transport_class_release(struct class_device *class_dev)
+{
+ struct scsi_device *sdev = transport_class_to_sdev(class_dev);
+ put_device(&sdev->sdev_gendev);
+}
+
+#define spi_transport_show_function(field, format_string) \
+static ssize_t \
+show_spi_transport_##field (struct class_device *cdev, char *buf) \
+{ \
+ struct scsi_device *sdev = transport_class_to_sdev(cdev); \
+ struct spi_transport_attrs *tp; \
+ tp = (struct spi_transport_attrs *)sdev->transport_attr_values; \
+ return snprintf(buf, 20, format_string, tp->field); \
+}
+
+#define spi_transport_rd_attr(field, format_string) \
+ spi_transport_show_function(field, format_string) \
+static CLASS_DEVICE_ATTR( field, S_IRUGO, show_spi_transport_##field, NULL)
+
+
+/* The Parallel SCSI Tranport Attributes: */
+spi_transport_rd_attr(period, "%d\n");
+spi_transport_rd_attr(offset, "%d\n");
+
+struct class_device_attribute *spi_transport_attrs[] = {
+ &class_device_attr_period,
+ &class_device_attr_offset,
+ NULL
+};
+
+struct spi_transport_attrs spi_transport_attr_defaults = {
+ .period = -1,
+ .offset = -1,
+};
+
+struct scsi_transport_template spi_transport_template = {
+ .attrs = spi_transport_attrs,
+ .class = &spi_transport_class,
+ .setup = &spi_alloc_transport_attrs,
+ .cleanup = &spi_destroy_transport_attrs,
+ .default_attr_values = &spi_transport_attr_defaults,
+};
+EXPORT_SYMBOL(spi_transport_template);
diff -Nru a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
--- a/include/scsi/scsi_device.h Tue Jan 20 15:52:29 2004
+++ b/include/scsi/scsi_device.h Tue Jan 20 15:52:29 2004
@@ -103,12 +103,17 @@
struct device sdev_gendev;
struct class_device sdev_classdev;
+ void *transport_attr_values;
+ struct class_device transport_classdev;
+
enum scsi_device_state sdev_state;
};
#define to_scsi_device(d) \
container_of(d, struct scsi_device, sdev_gendev)
#define class_to_sdev(d) \
container_of(d, struct scsi_device, sdev_classdev)
+#define transport_class_to_sdev(class_dev) \
+ container_of(class_dev, struct scsi_device, transport_classdev)
extern struct scsi_device *scsi_add_device(struct Scsi_Host *,
uint, uint, uint);
diff -Nru a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
--- a/include/scsi/scsi_host.h Tue Jan 20 15:52:29 2004
+++ b/include/scsi/scsi_host.h Tue Jan 20 15:52:29 2004
@@ -11,6 +11,7 @@
struct scsi_device;
struct Scsi_Host;
struct scsi_host_cmd_pool;
+struct scsi_transport_template;
/*
@@ -395,6 +396,7 @@
unsigned int eh_kill:1; /* set when killing the eh thread */
wait_queue_head_t host_wait;
struct scsi_host_template *hostt;
+ struct scsi_transport_template *transportt;
volatile unsigned short host_busy; /* commands actually active on low-level */
volatile unsigned short host_failed; /* commands that failed. */
diff -Nru a/include/scsi/scsi_transport.h b/include/scsi/scsi_transport.h
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/include/scsi/scsi_transport.h Tue Jan 20 15:52:29 2004
@@ -0,0 +1,40 @@
+/*
+ * Transport specific attributes.
+ *
+ * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef SCSI_TRANSPORT_H
+#define SCSI_TRANSPORT_H
+
+struct scsi_transport_template {
+ /* The NULL terminated list of transport attributes
+ * that should be exported.
+ */
+ struct class_device_attribute **attrs;
+
+ /* The transport class that the device is in */
+ struct class *class;
+
+ /* Constructor/Destructor functions */
+ int (* setup)(struct scsi_device *);
+ void (* cleanup)(struct scsi_device *);
+
+ /* Default values for the transport attributes */
+ void *default_attr_values;
+};
+
+#endif /* SCSI_TRANSPORT_H */
diff -Nru a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/include/scsi/scsi_transport_fc.h Tue Jan 20 15:52:29 2004
@@ -0,0 +1,41 @@
+/*
+ * FiberChannel transport specific attributes exported to sysfs.
+ *
+ * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef SCSI_TRANSPORT_FC_H
+#define SCSI_TRANSPORT_FC_H
+
+struct scsi_transport_template;
+
+struct fc_transport_attrs {
+ int port_id;
+ uint64_t node_name;
+ uint64_t port_name;
+};
+
+extern struct scsi_transport_template fc_transport_template;
+
+#ifdef CONFIG_SCSI_FC_ATTRS
+extern int scsi_fc_transport_init(void);
+extern void scsi_fc_transport_exit(void);
+#else
+# define scsi_fc_transport_init() 0
+# define scsi_fc_transport_exit()
+#endif
+
+#endif /* SCSI_TRANSPORT_FC_H */
diff -Nru a/include/scsi/scsi_transport_spi.h b/include/scsi/scsi_transport_spi.h
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/include/scsi/scsi_transport_spi.h Tue Jan 20 15:52:29 2004
@@ -0,0 +1,42 @@
+/*
+ * Parallel SCSI (SPI) transport specific attributes exported to sysfs.
+ *
+ * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef SCSI_TRANSPORT_SPI_H
+#define SCSI_TRANSPORT_SPI_H
+
+#include <linux/config.h>
+
+struct scsi_transport_template;
+
+struct spi_transport_attrs {
+ int period;
+ int offset;
+};
+
+extern struct scsi_transport_template spi_transport_template;
+
+#ifdef CONFIG_SCSI_SPI_ATTRS
+extern int scsi_spi_transport_init(void);
+extern void scsi_spi_transport_exit(void);
+#else
+# define scsi_spi_transport_init() 0
+# define scsi_spi_transport_exit()
+#endif
+
+#endif /* SCSI_TRANSPORT_SPI_H */
[-- Attachment #3: scsi-transport-class-attr-qla1280-v5-1.diff --]
[-- Type: text/plain, Size: 2951 bytes --]
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1496 -> 1.1497
# drivers/scsi/Kconfig 1.49 -> 1.50
# drivers/scsi/qla1280.c 1.53 -> 1.54
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/01/20 mort@green.i.bork.org 1.1497
# Transport Attributes for qla1280
# --------------------------------------------
#
diff -Nru a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
--- a/drivers/scsi/Kconfig Tue Jan 20 15:50:46 2004
+++ b/drivers/scsi/Kconfig Tue Jan 20 15:50:46 2004
@@ -1210,7 +1210,7 @@
config SCSI_QLOGIC_1280
tristate "Qlogic QLA 1280 SCSI support"
- depends on PCI && SCSI
+ depends on PCI && SCSI && SCSI_SPI_ATTRS
help
Say Y if you have a QLogic ISP1x80/1x160 SCSI host adapter.
diff -Nru a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
--- a/drivers/scsi/qla1280.c Tue Jan 20 15:50:46 2004
+++ b/drivers/scsi/qla1280.c Tue Jan 20 15:50:46 2004
@@ -347,6 +347,8 @@
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_tcq.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_spi.h>
#include "scsi.h"
#else
#include <linux/blk.h>
@@ -1400,12 +1402,14 @@
qla1280_slave_configure(struct scsi_device *device)
{
struct scsi_qla_host *ha;
+ struct spi_transport_attrs *attrs;
int default_depth = 3;
int bus = device->channel;
int target = device->id;
int status = 0;
struct nvram *nv;
unsigned long flags;
+ int is1x160;
ha = (struct scsi_qla_host *)device->host->hostdata;
nv = &ha->nvram;
@@ -1413,6 +1417,12 @@
if (qla1280_check_for_dead_scsi_bus(ha, bus))
return 1;
+ if (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
+ ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP10160)
+ is1x160 = 1;
+ else
+ is1x160 = 0;
+
if (device->tagged_supported &&
(ha->bus_settings[bus].qtag_enables & (BIT_0 << target))) {
scsi_adjust_queue_depth(device, MSG_ORDERED_TAG,
@@ -1448,6 +1458,17 @@
status = qla1280_set_target_parameters(ha, bus, target);
qla1280_get_target_parameters(ha, device);
spin_unlock_irqrestore(HOST_LOCK, flags);
+
+ /* Set the parallel scsi transport attributes */
+ attrs = (struct spi_transport_attrs *)device->transport_attr_values;
+ attrs->period = nv->bus[bus].target[target].sync_period;
+ if (is1x160)
+ attrs->offset = nv->bus[bus].target[target].flags.
+ flags1x160.sync_offset;
+ else
+ attrs->offset = nv->bus[bus].target[target].flags.
+ flags1x80.sync_offset;
+
return status;
}
@@ -4713,6 +4734,7 @@
host->max_id = MAX_TARGETS;
host->max_sectors = 1024;
host->unique_id = host->host_no;
+ host->transportt = &spi_transport_template;
#if LINUX_VERSION_CODE < 0x020545
host->select_queue_depths = qla1280_select_queue_depth;
[-- Attachment #4: scsi-transport-class-attr-qla2xxx-v5-1.diff --]
[-- Type: text/plain, Size: 3382 bytes --]
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1495 -> 1.1496
# drivers/scsi/qla2xxx/qla_os.h 1.1 -> 1.2
# drivers/scsi/qla2xxx/qla_os.c 1.1 -> 1.2
# drivers/scsi/qla2xxx/Kconfig 1.2 -> 1.3
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/01/20 mort@green.i.bork.org 1.1496
# Transport Attributes for qla2xxx
# --------------------------------------------
#
diff -Nru a/drivers/scsi/qla2xxx/Kconfig b/drivers/scsi/qla2xxx/Kconfig
--- a/drivers/scsi/qla2xxx/Kconfig Tue Jan 20 15:52:05 2004
+++ b/drivers/scsi/qla2xxx/Kconfig Tue Jan 20 15:52:05 2004
@@ -1,7 +1,7 @@
config SCSI_QLA2XXX_CONFIG
tristate
default (SCSI && PCI)
- depends on SCSI && PCI
+ depends on SCSI && PCI && SCSI_FC_ATTRS
config SCSI_QLA2XXX
tristate
diff -Nru a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
--- a/drivers/scsi/qla2xxx/qla_os.c Tue Jan 20 15:52:05 2004
+++ b/drivers/scsi/qla2xxx/qla_os.c Tue Jan 20 15:52:05 2004
@@ -1800,7 +1800,7 @@
}
/**************************************************************************
-* qla2x00_slave_configure
+* qla2xxx_slave_configure
*
* Description:
**************************************************************************/
@@ -1808,6 +1808,8 @@
qla2xxx_slave_configure(struct scsi_device *sdev)
{
scsi_qla_host_t *ha = to_qla_host(sdev->host);
+ struct fc_transport_attrs *attrs;
+ struct fc_port *fc;
int queue_depth;
if (IS_QLA2100(ha) || IS_QLA2200(ha))
@@ -1834,9 +1836,21 @@
sdev->host->hostt->cmd_per_lun /* 3 */);
}
- return (0);
-}
+ attrs = (struct fc_transport_attrs *)sdev->transport_attr_values;
+ list_for_each_entry(fc, &ha->fcports, list) {
+ if (fc->os_target_id == sdev->id) {
+ attrs->port_name = __be64_to_cpu(*(uint64_t *)fc->port_name);
+ attrs->node_name = __be64_to_cpu(*(uint64_t *)fc->node_name);
+ attrs->port_id = fc->d_id.b.domain << 16 |
+ fc->d_id.b.area << 8 |
+ fc->d_id.b.al_pa;
+ break;
+ }
+ }
+ return 0;
+}
+
/**
* qla2x00_config_dma_addressing() - Configure OS DMA addressing method.
* @ha: HA context
@@ -1949,10 +1963,10 @@
ha->mmio_length = mmio_len;
#endif
- return (0);
+ return 0;
iospace_error_exit:
- return (-ENOMEM);
+ return -ENOMEM;
}
/*
@@ -2179,6 +2193,8 @@
sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr);
sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr);
+
+ host->transportt = &fc_transport_template;
qla_printk(KERN_INFO, ha, "\n"
" QLogic ISP2xxx PCI/PCI-X Fibre Channel HBA Driver: %s\n"
diff -Nru a/drivers/scsi/qla2xxx/qla_os.h b/drivers/scsi/qla2xxx/qla_os.h
--- a/drivers/scsi/qla2xxx/qla_os.h Tue Jan 20 15:52:05 2004
+++ b/drivers/scsi/qla2xxx/qla_os.h Tue Jan 20 15:52:05 2004
@@ -26,6 +26,7 @@
#include <linux/module.h>
#include <linux/version.h>
#include <linux/init.h>
+#include <linux/list.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/kernel.h>
@@ -61,7 +62,8 @@
#include "scsi.h"
#include "hosts.h"
-
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_fc.h>
#include <scsi/scsicam.h>
#include <scsi/scsi_ioctl.h>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: Transport Attributes -- attempt#4
2004-01-20 21:56 Transport Attributes -- attempt#4 Martin Hicks
@ 2004-01-20 23:48 ` Patrick Mansfield
2004-02-24 0:17 ` James Bottomley
1 sibling, 0 replies; 8+ messages in thread
From: Patrick Mansfield @ 2004-01-20 23:48 UTC (permalink / raw)
To: Martin Hicks; +Cc: linux-scsi, James Bottomley
On Tue, Jan 20, 2004 at 04:56:45PM -0500, Martin Hicks wrote:
>
> Hi again,
>
> Updated patches against Linus' bk tree from earlier today. The patch
> that fixes up the scsi_sysfs.c error path, that was sent out by me on
> Jan 16, is required for the core patch to apply cleanly.
>
> I think I've addressed all the comments from the last round with the
> exception of doing Lazy registration of the transport classes. I'm
> still not totally convinced that this is really required.
It's certainly are not required, but makes it easier to add other
transports, and is in line with allocating resources as needed. Making
them modules means the code is only loaded when required by an adapter, it
is not always loaded with scsi core.
We could potentially have iSCSI and maybe others per SCSI standards. Then
we have USB, ieee1394, and raid cards that might want to add their own bus
and attributes, though these ones might more easily add them via scsi_host
attributes.
-- Patrick Mansfield
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Transport Attributes -- attempt#4
2004-01-20 21:56 Transport Attributes -- attempt#4 Martin Hicks
2004-01-20 23:48 ` Patrick Mansfield
@ 2004-02-24 0:17 ` James Bottomley
2004-02-24 5:58 ` Jeremy Higdon
2004-03-04 16:14 ` Martin Hicks
1 sibling, 2 replies; 8+ messages in thread
From: James Bottomley @ 2004-02-24 0:17 UTC (permalink / raw)
To: Martin Hicks; +Cc: SCSI Mailing List
[-- Attachment #1: Type: text/plain, Size: 1637 bytes --]
On Tue, 2004-01-20 at 15:56, Martin Hicks wrote:
> Updated patches against Linus' bk tree from earlier today. The patch
> that fixes up the scsi_sysfs.c error path, that was sent out by me on
> Jan 16, is required for the core patch to apply cleanly.
>
> I think I've addressed all the comments from the last round with the
> exception of doing Lazy registration of the transport classes. I'm
> still not totally convinced that this is really required.
OK, I finally found time to look at all this and try it out.
My big objection is still that the scsi mid-layer needs to know about
the transports. In testing, I recoded this so that no mid-layer
transport knowledge is necessary (patch attached). I didn't opt for a
transport registration API in the mid-layer, but I could see that such a
thing might have been a better solution.
I also see no necessity to allow hosts to add arbitrary transport
attributes: they can simply add extra device attributes to the same
effect. This means that the attribute list is fixed, and we develop a
private API between the transport and the device driver to update
attributes (I didn't code this, but you can see where I'm going with
it).
There were a few other initialisation touches (Like making the
attributes part of the host structure directly), and initialising the
default transportt correctly in the host_alloc.
I did my implementation for the 53c700 which is the driver I can readily
use. As you can see, the other half of this is shifting the driver
internally to use the transport attribute values (so that whatever we
find there can be directly exported to the user).
James
[-- Attachment #2: xprt.diff --]
[-- Type: text/plain, Size: 7313 bytes --]
===== drivers/scsi/Kconfig 1.57 vs edited =====
--- 1.57/drivers/scsi/Kconfig Mon Feb 23 14:41:38 2004
+++ edited/drivers/scsi/Kconfig Mon Feb 23 15:51:15 2004
@@ -200,14 +200,14 @@
depends on SCSI
config SCSI_SPI_ATTRS
- bool "Parallel SCSI (SPI) Transport Attributes"
+ tristate "Parallel SCSI (SPI) Transport Attributes"
depends on SCSI
help
If you wish to export transport-specific information about
each attached SCSI device to sysfs, say Y. Otherwise, say N.
config SCSI_FC_ATTRS
- bool "FiberChannel Transport Attributes"
+ tristate "FiberChannel Transport Attributes"
depends on SCSI
help
If you wish to export transport-specific information about
===== drivers/scsi/Makefile 1.56 vs edited =====
--- 1.56/drivers/scsi/Makefile Mon Feb 23 14:59:02 2004
+++ edited/drivers/scsi/Makefile Mon Feb 23 15:53:07 2004
@@ -22,6 +22,14 @@
obj-$(CONFIG_SCSI) += scsi_mod.o
+# --- NOTE ORDERING HERE ---
+# For kernel non-modular link, transport attributes need to
+# be initialised before drivers
+# --------------------------
+obj-$(CONFIG_SCSI_SPI_ATTRS) += scsi_transport_spi.o
+obj-$(CONFIG_SCSI_FC_ATTRS) += scsi_transport_fc.o
+
+
obj-$(CONFIG_SCSI_AMIGA7XX) += amiga7xx.o 53c7xx.o
obj-$(CONFIG_A3000_SCSI) += a3000.o wd33c93.o
obj-$(CONFIG_A2091_SCSI) += a2091.o wd33c93.o
@@ -130,8 +138,6 @@
scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o
scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o
scsi_mod-$(CONFIG_X86_PC9800) += scsi_pc98.o
-scsi_mod-$(CONFIG_SCSI_SPI_ATTRS) += scsi_transport_spi.o
-scsi_mod-$(CONFIG_SCSI_FC_ATTRS) += scsi_transport_fc.o
sd_mod-objs := sd.o
sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o
===== drivers/scsi/hosts.c 1.96 vs edited =====
--- 1.96/drivers/scsi/hosts.c Mon Dec 29 15:38:10 2003
+++ edited/drivers/scsi/hosts.c Mon Feb 23 17:22:26 2004
@@ -32,6 +32,7 @@
#include <linux/unistd.h>
#include <scsi/scsi_host.h>
+#include <scsi/scsi_transport.h>
#include "scsi.h"
#include "scsi_priv.h"
@@ -221,6 +222,11 @@
shost->max_channel = 0;
shost->max_id = 8;
shost->max_lun = 8;
+
+ /* Give each shost a default transportt if the driver
+ * doesn't yet support Transport Attributes */
+ if (!shost->transportt)
+ shost->transportt = &blank_transport_template;
/*
* All drivers right now should be able to handle 12 byte
===== drivers/scsi/scsi_scan.c 1.116 vs edited =====
--- 1.116/drivers/scsi/scsi_scan.c Mon Feb 23 14:41:38 2004
+++ edited/drivers/scsi/scsi_scan.c Mon Feb 23 17:22:08 2004
@@ -193,7 +193,7 @@
struct scsi_device *sdev, *device;
unsigned long flags;
- sdev = kmalloc(sizeof(*sdev), GFP_ATOMIC);
+ sdev = kmalloc(sizeof(*sdev) + shost->transportt->size, GFP_ATOMIC);
if (!sdev)
goto out;
@@ -237,11 +237,6 @@
if (shost->hostt->slave_alloc(sdev))
goto out_free_queue;
}
-
- /* Give each shost a default transportt if the driver
- * doesn't yet support Transport Attributes */
- if (!shost->transportt)
- shost->transportt = &blank_transport_template;
if (shost->transportt->setup) {
if (shost->transportt->setup(sdev))
===== drivers/scsi/scsi_sysfs.c 1.40 vs edited =====
--- 1.40/drivers/scsi/scsi_sysfs.c Mon Feb 23 14:41:38 2004
+++ edited/drivers/scsi/scsi_sysfs.c Mon Feb 23 15:34:41 2004
@@ -14,8 +14,6 @@
#include <scsi/scsi_host.h>
#include <scsi/scsi_transport.h>
-#include <scsi/scsi_transport_spi.h>
-#include <scsi/scsi_transport_fc.h>
#include "scsi.h"
#include "scsi_priv.h"
@@ -165,31 +163,13 @@
int error;
error = bus_register(&scsi_bus_type);
- if (error)
- return error;
-
- error = class_register(&sdev_class);
- if (error)
- goto undo_bus;
-
- error = scsi_spi_transport_init();
- if (error)
- goto undo_sdev;
-
- error = scsi_fc_transport_init();
- if (error)
- goto undo_all;
+ if (!error) {
+ error = class_register(&sdev_class);
+ if (error)
+ bus_unregister(&scsi_bus_type);
+ }
- out:
return error;
-
- undo_all:
- scsi_spi_transport_exit();
- undo_sdev:
- class_unregister(&sdev_class);
- undo_bus:
- bus_unregister(&scsi_bus_type);
- goto out;
}
void scsi_sysfs_unregister(void)
@@ -546,4 +526,4 @@
/* A blank transport template that is used in drivers that don't
* yet implement Transport Attributes */
-struct scsi_transport_template blank_transport_template;
+struct scsi_transport_template blank_transport_template = { 0, };
===== drivers/scsi/scsi_transport_spi.c 1.1 vs edited =====
--- 1.1/drivers/scsi/scsi_transport_spi.c Mon Feb 23 14:41:41 2004
+++ edited/drivers/scsi/scsi_transport_spi.c Mon Feb 23 16:27:08 2004
@@ -17,7 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
+#include <linux/module.h>
+#include <linux/init.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_transport.h>
@@ -30,34 +31,25 @@
.release = transport_class_release,
};
-int scsi_spi_transport_init(void)
+static __init int scsi_spi_transport_init(void)
{
return class_register(&spi_transport_class);
}
-void scsi_spi_transport_exit(void)
+static void __exit scsi_spi_transport_exit(void)
{
class_unregister(&spi_transport_class);
}
-static int spi_alloc_transport_attrs(struct scsi_device *sdev)
+static int spi_setup_transport_attrs(struct scsi_device *sdev)
{
- sdev->transport_attr_values = kmalloc(sizeof(struct spi_transport_attrs),
- GFP_ATOMIC);
- if (!sdev->transport_attr_values)
- return -ENOMEM;
-
- memcpy(sdev->transport_attr_values, sdev->host->transportt->default_attr_values,
- sizeof(struct spi_transport_attrs));
+ /* FIXME: should callback into the driver to get these values */
+ spi_period(sdev) = -1;
+ spi_offset(sdev) = -1;
return 0;
}
-static void spi_destroy_transport_attrs(struct scsi_device *sdev)
-{
- kfree(sdev->transport_attr_values);
-}
-
static void transport_class_release(struct class_device *class_dev)
{
struct scsi_device *sdev = transport_class_to_sdev(class_dev);
@@ -70,7 +62,7 @@
{ \
struct scsi_device *sdev = transport_class_to_sdev(cdev); \
struct spi_transport_attrs *tp; \
- tp = (struct spi_transport_attrs *)sdev->transport_attr_values; \
+ tp = (struct spi_transport_attrs *)&sdev->transport_data; \
return snprintf(buf, 20, format_string, tp->field); \
}
@@ -89,16 +81,18 @@
NULL
};
-struct spi_transport_attrs spi_transport_attr_defaults = {
- .period = -1,
- .offset = -1,
-};
-
struct scsi_transport_template spi_transport_template = {
.attrs = spi_transport_attrs,
.class = &spi_transport_class,
- .setup = &spi_alloc_transport_attrs,
- .cleanup = &spi_destroy_transport_attrs,
- .default_attr_values = &spi_transport_attr_defaults,
+ .setup = &spi_setup_transport_attrs,
+ .cleanup = NULL,
+ .size = sizeof(struct spi_transport_attrs) - sizeof(unsigned long),
};
EXPORT_SYMBOL(spi_transport_template);
+
+MODULE_AUTHOR("Martin Hicks");
+MODULE_DESCRIPTION("SPI Transport Attributes");
+MODULE_LICENSE("GPL");
+
+module_init(scsi_spi_transport_init);
+module_exit(scsi_spi_transport_exit);
[-- Attachment #3: xprt-53c700.diff --]
[-- Type: text/plain, Size: 6187 bytes --]
===== drivers/scsi/53c700.c 1.45 vs edited =====
--- 1.45/drivers/scsi/53c700.c Wed Nov 12 08:15:46 2003
+++ edited/drivers/scsi/53c700.c Mon Feb 23 16:25:03 2004
@@ -137,6 +137,9 @@
#include "scsi.h"
#include "hosts.h"
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_spi.h>
+
#include "53c700.h"
/* NOTE: For 64 bit drivers there are points in the code where we use
@@ -236,6 +239,51 @@
NCR_700_MAX_OFFSET
};
+/* This translates the SDTR message offset and period to a value
+ * which can be loaded into the SXFER_REG.
+ *
+ * NOTE: According to SCSI-2, the true transfer period (in ns) is
+ * actually four times this period value */
+static inline __u8
+NCR_700_offset_period_to_sxfer(struct NCR_700_Host_Parameters *hostdata,
+ __u8 offset, __u8 period)
+{
+ int XFERP;
+
+ __u8 min_xferp = (hostdata->chip710
+ ? NCR_710_MIN_XFERP : NCR_700_MIN_XFERP);
+ __u8 max_offset = (hostdata->chip710
+ ? NCR_710_MAX_OFFSET : NCR_700_MAX_OFFSET);
+ /* NOTE: NCR_700_SDTR_msg[3] contains our offer of the minimum
+ * period. It is set in NCR_700_chip_setup() */
+ if(period < NCR_700_SDTR_msg[3]) {
+ printk(KERN_WARNING "53c700: Period %dns is less than this chip's minimum, setting to %d\n", period*4, NCR_700_SDTR_msg[3]*4);
+ period = NCR_700_SDTR_msg[3];
+ }
+ XFERP = (period*4 * hostdata->sync_clock)/1000 - 4;
+ if(offset > max_offset) {
+ printk(KERN_WARNING "53c700: Offset %d exceeds chip maximum, setting to %d\n",
+ offset, max_offset);
+ offset = max_offset;
+ }
+ if(XFERP < min_xferp) {
+ printk(KERN_WARNING "53c700: XFERP %d is less than minium, setting to %d\n",
+ XFERP, min_xferp);
+ XFERP = min_xferp;
+ }
+ return (offset & 0x0f) | (XFERP & 0x07)<<4;
+}
+
+static inline __u8
+NCR_700_get_SXFER(Scsi_Device *SDp)
+{
+ struct NCR_700_Host_Parameters *hostdata =
+ (struct NCR_700_Host_Parameters *)SDp->host->hostdata[0];
+
+ return NCR_700_offset_period_to_sxfer(hostdata, spi_offset(SDp),
+ spi_period(SDp));
+}
+
struct Scsi_Host *
NCR_700_detect(Scsi_Host_Template *tpnt,
struct NCR_700_Host_Parameters *hostdata)
@@ -326,6 +374,7 @@
hostdata->cmd = NULL;
host->max_id = 7;
host->max_lun = NCR_700_MAX_LUNS;
+ host->transportt = &spi_transport_template;
host->unique_id = hostdata->base;
host->base = hostdata->base;
hostdata->eh_complete = NULL;
@@ -520,40 +569,6 @@
hostdata->cmd = NULL;
}
-/* This translates the SDTR message offset and period to a value
- * which can be loaded into the SXFER_REG.
- *
- * NOTE: According to SCSI-2, the true transfer period (in ns) is
- * actually four times this period value */
-STATIC inline __u8
-NCR_700_offset_period_to_sxfer(struct NCR_700_Host_Parameters *hostdata,
- __u8 offset, __u8 period)
-{
- int XFERP;
- __u8 min_xferp = (hostdata->chip710
- ? NCR_710_MIN_XFERP : NCR_700_MIN_XFERP);
- __u8 max_offset = (hostdata->chip710
- ? NCR_710_MAX_OFFSET : NCR_700_MAX_OFFSET);
- /* NOTE: NCR_700_SDTR_msg[3] contains our offer of the minimum
- * period. It is set in NCR_700_chip_setup() */
- if(period < NCR_700_SDTR_msg[3]) {
- printk(KERN_WARNING "53c700: Period %dns is less than this chip's minimum, setting to %d\n", period*4, NCR_700_SDTR_msg[3]*4);
- period = NCR_700_SDTR_msg[3];
- }
- XFERP = (period*4 * hostdata->sync_clock)/1000 - 4;
- if(offset > max_offset) {
- printk(KERN_WARNING "53c700: Offset %d exceeds chip maximum, setting to %d\n",
- offset, max_offset);
- offset = max_offset;
- }
- if(XFERP < min_xferp) {
- printk(KERN_WARNING "53c700: XFERP %d is less than minium, setting to %d\n",
- XFERP, min_xferp);
- XFERP = min_xferp;
- }
- return (offset & 0x0f) | (XFERP & 0x07)<<4;
-}
-
STATIC inline void
NCR_700_unmap(struct NCR_700_Host_Parameters *hostdata, Scsi_Cmnd *SCp,
struct NCR_700_command_slot *slot)
@@ -777,19 +792,19 @@
if(SCp != NULL && NCR_700_is_flag_set(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION)) {
__u8 period = hostdata->msgin[3];
__u8 offset = hostdata->msgin[4];
- __u8 sxfer;
- if(offset != 0 && period != 0)
- sxfer = NCR_700_offset_period_to_sxfer(hostdata, offset, period);
- else
- sxfer = 0;
+ if(offset == 0 || period == 0) {
+ offset = 0;
+ period = 0;
+ }
- if(sxfer != NCR_700_get_SXFER(SCp->device)) {
+ if(offset != spi_offset(SCp->device) || period != spi_period(SCp->device)) {
printk(KERN_INFO "scsi%d: (%d:%d) Synchronous at offset %d, period %dns\n",
host->host_no, pun, lun,
offset, period*4);
- NCR_700_set_SXFER(SCp->device, sxfer);
+ spi_offset(SCp->device) = offset;
+ spi_period(SCp->device) = period;
}
@@ -870,7 +885,7 @@
case A_REJECT_MSG:
if(SCp != NULL && NCR_700_is_flag_set(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION)) {
/* Rejected our sync negotiation attempt */
- NCR_700_set_SXFER(SCp->device, 0);
+ spi_period(SCp->device) = spi_offset(SCp->device) = 0;
NCR_700_set_flag(SCp->device, NCR_700_DEV_NEGOTIATED_SYNC);
NCR_700_clear_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION);
} else if(SCp != NULL && NCR_700_is_flag_set(SCp->device, NCR_700_DEV_BEGIN_TAG_QUEUEING)) {
===== drivers/scsi/53c700.h 1.15 vs edited =====
--- 1.15/drivers/scsi/53c700.h Sun Feb 22 12:05:18 2004
+++ edited/drivers/scsi/53c700.h Mon Feb 23 16:20:23 2004
@@ -101,16 +101,6 @@
#define NCR_700_DEV_TAG_STARVATION_WARNED (1<<19)
static inline void
-NCR_700_set_SXFER(Scsi_Device *SDp, __u8 sxfer)
-{
- SDp->hostdata = (void *)(((long)SDp->hostdata & 0xffffff00) |
- (sxfer & 0xff));
-}
-static inline __u8 NCR_700_get_SXFER(Scsi_Device *SDp)
-{
- return (((unsigned long)SDp->hostdata) & 0xff);
-}
-static inline void
NCR_700_set_depth(Scsi_Device *SDp, __u8 depth)
{
long l = (long)SDp->hostdata;
@@ -437,6 +427,7 @@
#symbol, A_##symbol##_used[i], val)); \
} \
}
+
static inline __u8
NCR_700_mem_readb(struct Scsi_Host *host, __u32 reg)
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: Transport Attributes -- attempt#4
2004-02-24 0:17 ` James Bottomley
@ 2004-02-24 5:58 ` Jeremy Higdon
2004-02-24 15:02 ` James Bottomley
2004-03-04 16:14 ` Martin Hicks
1 sibling, 1 reply; 8+ messages in thread
From: Jeremy Higdon @ 2004-02-24 5:58 UTC (permalink / raw)
To: James Bottomley; +Cc: Martin Hicks, SCSI Mailing List
On Mon, Feb 23, 2004 at 06:17:11PM -0600, James Bottomley wrote:
>
> OK, I finally found time to look at all this and try it out.
>
> My big objection is still that the scsi mid-layer needs to know about
> the transports. In testing, I recoded this so that no mid-layer
> transport knowledge is necessary (patch attached). I didn't opt for a
> transport registration API in the mid-layer, but I could see that such a
> thing might have been a better solution.
James, was scsi/scsi_transport.h supposed to be patched also?
There is a new "size" member of the scsi_transport_template
structure, but no patch to the data structure itself. Did you
replace attributes with size?
Also, Martin is on vacation this week, I believe, so he probably
won't respond until next week.
thanks
jeremy
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Transport Attributes -- attempt#4
2004-02-24 5:58 ` Jeremy Higdon
@ 2004-02-24 15:02 ` James Bottomley
2004-02-25 7:08 ` Jeremy Higdon
0 siblings, 1 reply; 8+ messages in thread
From: James Bottomley @ 2004-02-24 15:02 UTC (permalink / raw)
To: Jeremy Higdon; +Cc: Martin Hicks, SCSI Mailing List
On Mon, 2004-02-23 at 23:58, Jeremy Higdon wrote:
> James, was scsi/scsi_transport.h supposed to be patched also?
> There is a new "size" member of the scsi_transport_template
> structure, but no patch to the data structure itself. Did you
> replace attributes with size?
Well, not really. The patch I provided is a sketch only of what I want
done. It compiles and works on the 53c700 which is where I tested it.
Really, I just want transport and core separated and transport
attributes to be fixed (so there's some way of defining a transport
private API for updating them).
Even with just offset and period as the transport attributes for SPI,
that gives enough to move domain validation out of all the drivers into
the SPI transport layer.
> Also, Martin is on vacation this week, I believe, so he probably
> won't respond until next week.
Yes, I know, It's just that I've been promising to look at this for
weeks, so I didn't want to delay any further.
James
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Transport Attributes -- attempt#4
2004-02-24 15:02 ` James Bottomley
@ 2004-02-25 7:08 ` Jeremy Higdon
2004-02-25 16:42 ` James Bottomley
0 siblings, 1 reply; 8+ messages in thread
From: Jeremy Higdon @ 2004-02-25 7:08 UTC (permalink / raw)
To: James Bottomley; +Cc: Martin Hicks, SCSI Mailing List
On Tue, Feb 24, 2004 at 09:02:56AM -0600, James Bottomley wrote:
> On Mon, 2004-02-23 at 23:58, Jeremy Higdon wrote:
> > James, was scsi/scsi_transport.h supposed to be patched also?
> > There is a new "size" member of the scsi_transport_template
> > structure, but no patch to the data structure itself. Did you
> > replace attributes with size?
>
> Well, not really. The patch I provided is a sketch only of what I want
> done. It compiles and works on the 53c700 which is where I tested it.
>
> Really, I just want transport and core separated and transport
> attributes to be fixed (so there's some way of defining a transport
> private API for updating them).
>
> Even with just offset and period as the transport attributes for SPI,
> that gives enough to move domain validation out of all the drivers into
> the SPI transport layer.
Okay, that's fine.
What I meant to say is that I get a compile error at the following
line in scsi_scan.c:
sdev = kmalloc(sizeof(*sdev) + shost->transportt->size, GFP_ATOMIC);
In Martin's version of scsi_transport.h, there is no "size" member of
struct scsi_transport_template.
So I figured you must have left it out of your patch. I also saw this
in your patch, which makes it look as though default_attr_values (mistakenly
called "attributes" by me above) was replaced by size:
struct scsi_transport_template spi_transport_template = {
.attrs = spi_transport_attrs,
.class = &spi_transport_class,
- .setup = &spi_alloc_transport_attrs,
- .cleanup = &spi_destroy_transport_attrs,
- .default_attr_values = &spi_transport_attr_defaults,
+ .setup = &spi_setup_transport_attrs,
+ .cleanup = NULL,
+ .size = sizeof(struct spi_transport_attrs) - sizeof(unsigned long),
};
thanks
jeremy
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: Transport Attributes -- attempt#4
2004-02-25 7:08 ` Jeremy Higdon
@ 2004-02-25 16:42 ` James Bottomley
0 siblings, 0 replies; 8+ messages in thread
From: James Bottomley @ 2004-02-25 16:42 UTC (permalink / raw)
To: Jeremy Higdon; +Cc: Martin Hicks, SCSI Mailing List
[-- Attachment #1: Type: text/plain, Size: 309 bytes --]
On Wed, 2004-02-25 at 01:08, Jeremy Higdon wrote:
> What I meant to say is that I get a compile error at the following
> line in scsi_scan.c:
>
> sdev = kmalloc(sizeof(*sdev) + shost->transportt->size, GFP_ATOMIC);
Er, oops, I forgot to do a bk diff in include/scsi. It should be
attached, sorry.
James
[-- Attachment #2: tmp.diff --]
[-- Type: text/plain, Size: 2051 bytes --]
===== include/scsi/scsi_device.h 1.12 vs edited =====
--- 1.12/include/scsi/scsi_device.h Mon Feb 23 14:41:39 2004
+++ edited/include/scsi/scsi_device.h Mon Feb 23 15:39:55 2004
@@ -103,11 +103,11 @@
struct device sdev_gendev;
struct class_device sdev_classdev;
- void *transport_attr_values;
struct class_device transport_classdev;
enum scsi_device_state sdev_state;
-};
+ unsigned long transport_data[0];
+} __attribute__((aligned(sizeof(unsigned long))));
#define to_scsi_device(d) \
container_of(d, struct scsi_device, sdev_gendev)
#define class_to_sdev(d) \
===== include/scsi/scsi_transport.h 1.1 vs edited =====
--- 1.1/include/scsi/scsi_transport.h Mon Feb 23 14:41:44 2004
+++ edited/include/scsi/scsi_transport.h Mon Feb 23 15:32:33 2004
@@ -32,9 +32,10 @@
/* Constructor/Destructor functions */
int (* setup)(struct scsi_device *);
void (* cleanup)(struct scsi_device *);
-
- /* Default values for the transport attributes */
- void *default_attr_values;
+ /* The size of the specific transport attribute structure (a
+ * space of this size will be left at the end of the
+ * scsi_device structure */
+ int size;
};
#endif /* SCSI_TRANSPORT_H */
===== include/scsi/scsi_transport_spi.h 1.1 vs edited =====
--- 1.1/include/scsi/scsi_transport_spi.h Mon Feb 23 14:41:48 2004
+++ edited/include/scsi/scsi_transport_spi.h Mon Feb 23 15:56:50 2004
@@ -29,14 +29,10 @@
int offset;
};
-extern struct scsi_transport_template spi_transport_template;
+/* accessor functions */
+#define spi_period(x) (((struct spi_transport_attrs *)&(x)->transport_data)->period)
+#define spi_offset(x) (((struct spi_transport_attrs *)&(x)->transport_data)->offset)
-#ifdef CONFIG_SCSI_SPI_ATTRS
-extern int scsi_spi_transport_init(void);
-extern void scsi_spi_transport_exit(void);
-#else
-# define scsi_spi_transport_init() 0
-# define scsi_spi_transport_exit()
-#endif
+extern struct scsi_transport_template spi_transport_template;
#endif /* SCSI_TRANSPORT_SPI_H */
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Transport Attributes -- attempt#4
2004-02-24 0:17 ` James Bottomley
2004-02-24 5:58 ` Jeremy Higdon
@ 2004-03-04 16:14 ` Martin Hicks
1 sibling, 0 replies; 8+ messages in thread
From: Martin Hicks @ 2004-03-04 16:14 UTC (permalink / raw)
To: James Bottomley; +Cc: SCSI Mailing List
[-- Attachment #1: Type: text/plain, Size: 2312 bytes --]
On Mon, Feb 23, 2004 at 06:17:11PM -0600, James Bottomley wrote:
> On Tue, 2004-01-20 at 15:56, Martin Hicks wrote:
> > Updated patches against Linus' bk tree from earlier today. The patch
> > that fixes up the scsi_sysfs.c error path, that was sent out by me on
> > Jan 16, is required for the core patch to apply cleanly.
> >
> > I think I've addressed all the comments from the last round with the
> > exception of doing Lazy registration of the transport classes. I'm
> > still not totally convinced that this is really required.
>
> OK, I finally found time to look at all this and try it out.
Thanks!
>
> My big objection is still that the scsi mid-layer needs to know about
> the transports. In testing, I recoded this so that no mid-layer
> transport knowledge is necessary (patch attached). I didn't opt for a
> transport registration API in the mid-layer, but I could see that such a
> thing might have been a better solution.
Agreed. Thanks for getting the cruft out of the midlayer.
> I also see no necessity to allow hosts to add arbitrary transport
> attributes: they can simply add extra device attributes to the same
> effect. This means that the attribute list is fixed, and we develop a
> private API between the transport and the device driver to update
> attributes (I didn't code this, but you can see where I'm going with
> it).
This is a future-needs thing, as far as I can see. I'm going to leave
it as-is for now. When the time comes that we want r/w sysfs attributes
to callback into the drivers it can be added then.
> There were a few other initialisation touches (Like making the
> attributes part of the host structure directly), and initialising the
> default transportt correctly in the host_alloc.
These are great. Thanks.
> I did my implementation for the 53c700 which is the driver I can readily
> use. As you can see, the other half of this is shifting the driver
> internally to use the transport attribute values (so that whatever we
> find there can be directly exported to the user).
I've expanded your changes to fix up the Fiber Channel transport
attributes using your new ideas. I've also attached driver updates
for qla2xxx and qla1280.
thanks
mh
--
Martin Hicks Wild Open Source Inc.
mort@wildopensource.com 613-266-2296
[-- Attachment #2: xprt-qla1280.diff --]
[-- Type: text/plain, Size: 2644 bytes --]
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1635 -> 1.1636
# drivers/scsi/Kconfig 1.58 -> 1.59
# drivers/scsi/qla1280.c 1.55 -> 1.56
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/03/04 mort@green.i.bork.org 1.1636
# SPI transport attributes for qla1280
# --------------------------------------------
#
diff -Nru a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
--- a/drivers/scsi/Kconfig Thu Mar 4 10:57:37 2004
+++ b/drivers/scsi/Kconfig Thu Mar 4 10:57:37 2004
@@ -1193,7 +1193,7 @@
config SCSI_QLOGIC_1280
tristate "Qlogic QLA 1280 SCSI support"
- depends on PCI && SCSI
+ depends on PCI && SCSI && SCSI_SPI_ATTRS
help
Say Y if you have a QLogic ISP1x80/1x160 SCSI host adapter.
diff -Nru a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
--- a/drivers/scsi/qla1280.c Thu Mar 4 10:57:37 2004
+++ b/drivers/scsi/qla1280.c Thu Mar 4 10:57:37 2004
@@ -353,6 +353,8 @@
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_tcq.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_spi.h>
#include "scsi.h"
#else
#include <linux/blk.h>
@@ -1447,6 +1449,7 @@
int status = 0;
struct nvram *nv;
unsigned long flags;
+ int is1x160;
ha = (struct scsi_qla_host *)device->host->hostdata;
nv = &ha->nvram;
@@ -1454,6 +1457,12 @@
if (qla1280_check_for_dead_scsi_bus(ha, bus))
return 1;
+ if (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
+ ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP10160)
+ is1x160 = 1;
+ else
+ is1x160 = 0;
+
if (device->tagged_supported &&
(ha->bus_settings[bus].qtag_enables & (BIT_0 << target))) {
scsi_adjust_queue_depth(device, MSG_ORDERED_TAG,
@@ -1489,6 +1498,15 @@
status = qla1280_set_target_parameters(ha, bus, target);
qla1280_get_target_parameters(ha, device);
spin_unlock_irqrestore(HOST_LOCK, flags);
+
+ spi_period(device) = nv->bus[bus].target[target].sync_period;
+ if (is1x160)
+ spi_offset(device) = nv->bus[bus].target[target].flags.
+ flags1x160.sync_offset;
+ else
+ spi_offset(device) = nv->bus[bus].target[target].flags.
+ flags1x80.sync_offset;
+
return status;
}
@@ -4755,6 +4773,7 @@
host->max_id = MAX_TARGETS;
host->max_sectors = 1024;
host->unique_id = host->host_no;
+ host->transportt = &spi_transport_template;
#if LINUX_VERSION_CODE < 0x020545
host->select_queue_depths = qla1280_select_queue_depth;
[-- Attachment #3: xprt-qla2xxx.diff --]
[-- Type: text/plain, Size: 4150 bytes --]
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1636 -> 1.1637
# drivers/scsi/qla2xxx/qla_os.h 1.2 -> 1.3
# drivers/scsi/qla2xxx/qla_os.c 1.6 -> 1.7
# drivers/scsi/qla2xxx/Kconfig 1.5 -> 1.6
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/03/04 mort@green.i.bork.org 1.1637
# Transport Attributes for qla2xxx
# --------------------------------------------
#
diff -Nru a/drivers/scsi/qla2xxx/Kconfig b/drivers/scsi/qla2xxx/Kconfig
--- a/drivers/scsi/qla2xxx/Kconfig Thu Mar 4 11:05:55 2004
+++ b/drivers/scsi/qla2xxx/Kconfig Thu Mar 4 11:05:55 2004
@@ -1,41 +1,41 @@
config SCSI_QLA2XXX
tristate
default (SCSI && PCI)
- depends on SCSI && PCI
+ depends on SCSI && PCI && SCSI_FC_ATTRS
config SCSI_QLA21XX
tristate "QLogic ISP2100 host adapter family support"
- depends on SCSI_QLA2XXX
+ depends on SCSI_QLA2XXX && SCSI_FC_ATTRS
---help---
This driver supports the QLogic 21xx (ISP2100) host adapter family.
config SCSI_QLA22XX
tristate "QLogic ISP2200 host adapter family support"
- depends on SCSI_QLA2XXX
+ depends on SCSI_QLA2XXX && SCSI_FC_ATTRS
---help---
This driver supports the QLogic 22xx (ISP2200) host adapter family.
config SCSI_QLA2300
tristate "QLogic ISP2300 host adapter family support"
- depends on SCSI_QLA2XXX
+ depends on SCSI_QLA2XXX && SCSI_FC_ATTRS
---help---
This driver supports the QLogic 2300 (ISP2300, and ISP2312) host
adapter family.
config SCSI_QLA2322
tristate "QLogic ISP2322 host adapter family support"
- depends on SCSI_QLA2XXX
+ depends on SCSI_QLA2XXX && SCSI_FC_ATTRS
---help---
This driver supports the QLogic 2322 (ISP2322) host adapter family.
config SCSI_QLA6312
tristate "QLogic ISP6312 host adapter family support"
- depends on SCSI_QLA2XXX
+ depends on SCSI_QLA2XXX && SCSI_FC_ATTRS
---help---
This driver supports the QLogic 6312 (ISP6312) host adapter family.
config SCSI_QLA6322
tristate "QLogic ISP6322 host adapter family support"
- depends on SCSI_QLA2XXX
+ depends on SCSI_QLA2XXX && SCSI_FC_ATTRS
---help---
This driver supports the QLogic 6322 (ISP6322) host adapter family.
diff -Nru a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
--- a/drivers/scsi/qla2xxx/qla_os.c Thu Mar 4 11:05:55 2004
+++ b/drivers/scsi/qla2xxx/qla_os.c Thu Mar 4 11:05:55 2004
@@ -1766,7 +1766,7 @@
}
/**************************************************************************
-* qla2x00_slave_configure
+* qla2xxx_slave_configure
*
* Description:
**************************************************************************/
@@ -1774,6 +1774,7 @@
qla2xxx_slave_configure(struct scsi_device *sdev)
{
scsi_qla_host_t *ha = to_qla_host(sdev->host);
+ struct fc_port *fc;
int queue_depth;
if (IS_QLA2100(ha) || IS_QLA2200(ha))
@@ -1800,7 +1801,18 @@
sdev->host->hostt->cmd_per_lun /* 3 */);
}
- return (0);
+ list_for_each_entry(fc, &ha->fcports, list) {
+ if (fc->os_target_id == sdev->id) {
+ fc_port_name(sdev) = __be64_to_cpu(*(uint64_t *)fc->port_name);
+ fc_node_name(sdev) = __be64_to_cpu(*(uint64_t *)fc->node_name);
+ fc_port_id(sdev) = fc->d_id.b.domain << 16 |
+ fc->d_id.b.area << 8 |
+ fc->d_id.b.al_pa;
+ break;
+ }
+ }
+
+ return 0;
}
/**
@@ -2140,6 +2152,8 @@
sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr);
sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr);
+
+ host->transportt = &fc_transport_template;
qla_printk(KERN_INFO, ha, "\n"
" QLogic Fibre Channel HBA Driver: %s\n"
diff -Nru a/drivers/scsi/qla2xxx/qla_os.h b/drivers/scsi/qla2xxx/qla_os.h
--- a/drivers/scsi/qla2xxx/qla_os.h Thu Mar 4 11:05:55 2004
+++ b/drivers/scsi/qla2xxx/qla_os.h Thu Mar 4 11:05:55 2004
@@ -62,6 +62,8 @@
#include <scsi/scsicam.h>
#include <scsi/scsi_ioctl.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_fc.h>
//TODO Fix this!!!
/*
[-- Attachment #4: xprt.diff --]
[-- Type: text/plain, Size: 21944 bytes --]
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1632 -> 1.1634
# include/scsi/scsi_device.h 1.11 -> 1.13
# drivers/scsi/hosts.c 1.96 -> 1.97
# include/scsi/scsi_host.h 1.13 -> 1.14
# drivers/scsi/scsi_sysfs.c 1.39 -> 1.41
# drivers/scsi/scsi_priv.h 1.31 -> 1.32
# drivers/scsi/scsi_scan.c 1.115 -> 1.117
# drivers/scsi/Makefile 1.54 -> 1.56
# drivers/scsi/Kconfig 1.56 -> 1.58
# (new) -> 1.2 drivers/scsi/scsi_transport_fc.c
# (new) -> 1.2 include/scsi/scsi_transport.h
# (new) -> 1.2 include/scsi/scsi_transport_fc.h
# (new) -> 1.2 include/scsi/scsi_transport_spi.h
# (new) -> 1.2 drivers/scsi/scsi_transport_spi.c
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/03/02 mort@green.i.bork.org 1.1633
# scsi-transport-class-attr-core-v5-1.diff
# --------------------------------------------
# 04/03/03 mort@green.i.bork.org 1.1634
# Updates to the Transport Attributes core to include James Bottomley's
# patch.
# --------------------------------------------
#
diff -Nru a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
--- a/drivers/scsi/Kconfig Thu Mar 4 10:26:56 2004
+++ b/drivers/scsi/Kconfig Thu Mar 4 10:26:56 2004
@@ -196,6 +196,25 @@
there should be no noticeable performance impact as long as you have
logging turned off.
+menu "SCSI Transport Attributes"
+ depends on SCSI
+
+config SCSI_SPI_ATTRS
+ tristate "Parallel SCSI (SPI) Transport Attributes"
+ depends on SCSI
+ help
+ If you wish to export transport-specific information about
+ each attached SCSI device to sysfs, say Y. Otherwise, say N.
+
+config SCSI_FC_ATTRS
+ tristate "FiberChannel Transport Attributes"
+ depends on SCSI
+ help
+ If you wish to export transport-specific information about
+ each attached FiberChannel device to sysfs, say Y.
+ Otherwise, say N.
+
+endmenu
menu "SCSI low-level drivers"
depends on SCSI!=n
diff -Nru a/drivers/scsi/Makefile b/drivers/scsi/Makefile
--- a/drivers/scsi/Makefile Thu Mar 4 10:26:56 2004
+++ b/drivers/scsi/Makefile Thu Mar 4 10:26:56 2004
@@ -22,6 +22,14 @@
obj-$(CONFIG_SCSI) += scsi_mod.o
+# --- NOTE ORDERING HERE ---
+# For kernel non-modular link, transport attributes need to
+# be initialised before drivers
+# --------------------------
+obj-$(CONFIG_SCSI_SPI_ATTRS) += scsi_transport_spi.o
+obj-$(CONFIG_SCSI_FC_ATTRS) += scsi_transport_fc.o
+
+
obj-$(CONFIG_SCSI_AMIGA7XX) += amiga7xx.o 53c7xx.o
obj-$(CONFIG_A3000_SCSI) += a3000.o wd33c93.o
obj-$(CONFIG_A2091_SCSI) += a2091.o wd33c93.o
@@ -130,7 +138,7 @@
scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o
scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o
scsi_mod-$(CONFIG_X86_PC9800) += scsi_pc98.o
-
+
sd_mod-objs := sd.o
sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o
initio-objs := ini9100u.o i91uscsi.o
diff -Nru a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
--- a/drivers/scsi/hosts.c Thu Mar 4 10:26:56 2004
+++ b/drivers/scsi/hosts.c Thu Mar 4 10:26:56 2004
@@ -32,6 +32,7 @@
#include <linux/unistd.h>
#include <scsi/scsi_host.h>
+#include <scsi/scsi_transport.h>
#include "scsi.h"
#include "scsi_priv.h"
@@ -221,6 +222,11 @@
shost->max_channel = 0;
shost->max_id = 8;
shost->max_lun = 8;
+
+ /* Give each shost a default transportt if the driver
+ * doesn't yet support Transport Attributes */
+ if (!shost->transportt)
+ shost->transportt = &blank_transport_template;
/*
* All drivers right now should be able to handle 12 byte
diff -Nru a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
--- a/drivers/scsi/scsi_priv.h Thu Mar 4 10:26:56 2004
+++ b/drivers/scsi/scsi_priv.h Thu Mar 4 10:26:56 2004
@@ -155,6 +155,7 @@
extern int scsi_sysfs_add_host(struct Scsi_Host *);
extern int scsi_sysfs_register(void);
extern void scsi_sysfs_unregister(void);
+extern struct scsi_transport_template blank_transport_template;
extern struct class sdev_class;
extern struct bus_type scsi_bus_type;
diff -Nru a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
--- a/drivers/scsi/scsi_scan.c Thu Mar 4 10:26:56 2004
+++ b/drivers/scsi/scsi_scan.c Thu Mar 4 10:26:56 2004
@@ -35,6 +35,7 @@
#include <scsi/scsi_driver.h>
#include <scsi/scsi_devinfo.h>
#include <scsi/scsi_host.h>
+#include <scsi/scsi_transport.h>
#include "scsi.h"
#include "scsi_priv.h"
@@ -192,7 +193,7 @@
struct scsi_device *sdev, *device;
unsigned long flags;
- sdev = kmalloc(sizeof(*sdev), GFP_ATOMIC);
+ sdev = kmalloc(sizeof(*sdev) + shost->transportt->size, GFP_ATOMIC);
if (!sdev)
goto out;
@@ -237,6 +238,11 @@
goto out_free_queue;
}
+ if (shost->transportt->setup) {
+ if (shost->transportt->setup(sdev))
+ goto out_cleanup_slave;
+ }
+
if (get_device(&sdev->host->shost_gendev)) {
device_initialize(&sdev->sdev_gendev);
@@ -253,8 +259,15 @@
snprintf(sdev->sdev_classdev.class_id, BUS_ID_SIZE,
"%d:%d:%d:%d", sdev->host->host_no,
sdev->channel, sdev->id, sdev->lun);
+
+ class_device_initialize(&sdev->transport_classdev);
+ sdev->transport_classdev.dev = &sdev->sdev_gendev;
+ sdev->transport_classdev.class = sdev->host->transportt->class;
+ snprintf(sdev->transport_classdev.class_id, BUS_ID_SIZE,
+ "%d:%d:%d:%d", sdev->host->host_no,
+ sdev->channel, sdev->id, sdev->lun);
} else
- goto out_cleanup_slave;
+ goto out_cleanup_transport;
/*
* If there are any same target siblings, add this to the
@@ -283,6 +296,9 @@
spin_unlock_irqrestore(shost->host_lock, flags);
return sdev;
+out_cleanup_transport:
+ if (shost->transportt->cleanup)
+ shost->transportt->cleanup(sdev);
out_cleanup_slave:
if (shost->hostt->slave_destroy)
shost->hostt->slave_destroy(sdev);
@@ -744,6 +760,8 @@
} else {
if (sdev->host->hostt->slave_destroy)
sdev->host->hostt->slave_destroy(sdev);
+ if (sdev->host->transportt->cleanup)
+ sdev->host->transportt->cleanup(sdev);
put_device(&sdev->sdev_gendev);
}
out:
@@ -1300,5 +1318,7 @@
if (sdev->host->hostt->slave_destroy)
sdev->host->hostt->slave_destroy(sdev);
+ if (sdev->host->transportt->cleanup)
+ sdev->host->transportt->cleanup(sdev);
put_device(&sdev->sdev_gendev);
}
diff -Nru a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
--- a/drivers/scsi/scsi_sysfs.c Thu Mar 4 10:26:56 2004
+++ b/drivers/scsi/scsi_sysfs.c Thu Mar 4 10:26:56 2004
@@ -13,6 +13,7 @@
#include <linux/device.h>
#include <scsi/scsi_host.h>
+#include <scsi/scsi_transport.h>
#include "scsi.h"
#include "scsi_priv.h"
@@ -344,6 +345,7 @@
**/
int scsi_sysfs_add_sdev(struct scsi_device *sdev)
{
+ struct class_device_attribute **attrs;
int error = -EINVAL, i;
if (sdev->sdev_state != SDEV_CREATED)
@@ -363,6 +365,12 @@
goto clean_device;
}
+ if (sdev->transport_classdev.class) {
+ error = class_device_add(&sdev->transport_classdev);
+ if (error)
+ goto clean_device2;
+ }
+
get_device(&sdev->sdev_gendev);
if (sdev->host->hostt->sdev_attrs) {
@@ -388,10 +396,24 @@
}
}
+ if (sdev->transport_classdev.class) {
+ attrs = sdev->host->transportt->attrs;
+ for (i = 0; attrs[i]; i++) {
+ error = class_device_create_file(&sdev->transport_classdev,
+ attrs[i]);
+ if (error) {
+ scsi_remove_device(sdev);
+ goto out;
+ }
+ }
+ }
+
out:
return error;
-clean_device:
+ clean_device2:
+ class_device_del(&sdev->sdev_classdev);
+ clean_device:
sdev->sdev_state = SDEV_CANCEL;
device_del(&sdev->sdev_gendev);
@@ -409,9 +431,12 @@
if (sdev->sdev_state == SDEV_RUNNING || sdev->sdev_state == SDEV_CANCEL) {
sdev->sdev_state = SDEV_DEL;
class_device_unregister(&sdev->sdev_classdev);
+ class_device_unregister(&sdev->transport_classdev);
device_del(&sdev->sdev_gendev);
if (sdev->host->hostt->slave_destroy)
sdev->host->hostt->slave_destroy(sdev);
+ if (sdev->host->transportt->cleanup)
+ sdev->host->transportt->cleanup(sdev);
put_device(&sdev->sdev_gendev);
}
}
@@ -498,3 +523,7 @@
return 0;
}
+
+/* A blank transport template that is used in drivers that don't
+ * yet implement Transport Attributes */
+struct scsi_transport_template blank_transport_template = { 0, };
diff -Nru a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/drivers/scsi/scsi_transport_fc.c Thu Mar 4 10:26:56 2004
@@ -0,0 +1,104 @@
+/*
+ * FiberChannel transport specific attributes exported to sysfs.
+ *
+ * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_fc.h>
+
+static void transport_class_release(struct class_device *class_dev);
+
+struct class fc_transport_class = {
+ .name = "fc_transport",
+ .release = transport_class_release,
+};
+
+static __init int fc_transport_init(void)
+{
+ return class_register(&fc_transport_class);
+}
+
+static void __exit fc_transport_exit(void)
+{
+ class_unregister(&fc_transport_class);
+}
+
+static int fc_setup_transport_attrs(struct scsi_device *sdev)
+{
+ /* FIXME: Callback into the driver */
+ fc_node_name(sdev) = -1;
+ fc_port_name(sdev) = -1;
+ fc_port_id(sdev) = -1;
+
+ return 0;
+}
+
+static void transport_class_release(struct class_device *class_dev)
+{
+ struct scsi_device *sdev = transport_class_to_sdev(class_dev);
+ put_device(&sdev->sdev_gendev);
+}
+
+#define fc_transport_show_function(field, format_string, cast) \
+static ssize_t \
+show_fc_transport_##field (struct class_device *cdev, char *buf) \
+{ \
+ struct scsi_device *sdev = transport_class_to_sdev(cdev); \
+ struct fc_transport_attrs *tp; \
+ tp = (struct fc_transport_attrs *)&sdev->transport_data; \
+ return snprintf(buf, 20, format_string, cast tp->field); \
+}
+
+#define fc_transport_rd_attr(field, format_string) \
+ fc_transport_show_function(field, format_string, ) \
+static CLASS_DEVICE_ATTR( field, S_IRUGO, show_fc_transport_##field, NULL)
+
+#define fc_transport_rd_attr_cast(field, format_string, cast) \
+ fc_transport_show_function(field, format_string, (cast)) \
+static CLASS_DEVICE_ATTR( field, S_IRUGO, show_fc_transport_##field, NULL)
+
+/* the FiberChannel Tranport Attributes: */
+fc_transport_rd_attr_cast(node_name, "0x%llx\n", unsigned long long);
+fc_transport_rd_attr_cast(port_name, "0x%llx\n", unsigned long long);
+fc_transport_rd_attr(port_id, "0x%06x\n");
+
+struct class_device_attribute *fc_transport_attrs[] = {
+ &class_device_attr_node_name,
+ &class_device_attr_port_name,
+ &class_device_attr_port_id,
+ NULL
+};
+
+struct scsi_transport_template fc_transport_template = {
+ .attrs = fc_transport_attrs,
+ .class = &fc_transport_class,
+ .setup = &fc_setup_transport_attrs,
+ .cleanup = NULL,
+ .size = sizeof(struct fc_transport_attrs) - sizeof(unsigned long),
+};
+EXPORT_SYMBOL(fc_transport_template);
+
+MODULE_AUTHOR("Martin Hicks");
+MODULE_DESCRIPTION("FC Transport Attributes");
+MODULE_LICENSE("GPL");
+
+module_init(fc_transport_init);
+module_exit(fc_transport_exit);
diff -Nru a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/drivers/scsi/scsi_transport_spi.c Thu Mar 4 10:26:56 2004
@@ -0,0 +1,97 @@
+/*
+ * Parallel SCSI (SPI) transport specific attributes exported to sysfs.
+ *
+ * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_spi.h>
+
+static void transport_class_release(struct class_device *class_dev);
+
+struct class spi_transport_class = {
+ .name = "spi_transport",
+ .release = transport_class_release,
+};
+
+static __init int spi_transport_init(void)
+{
+ return class_register(&spi_transport_class);
+}
+
+static void __exit spi_transport_exit(void)
+{
+ class_unregister(&spi_transport_class);
+}
+
+static int spi_setup_transport_attrs(struct scsi_device *sdev)
+{
+ /* FIXME: should callback into the driver to get these values */
+ spi_period(sdev) = -1;
+ spi_offset(sdev) = -1;
+
+ return 0;
+}
+
+static void transport_class_release(struct class_device *class_dev)
+{
+ struct scsi_device *sdev = transport_class_to_sdev(class_dev);
+ put_device(&sdev->sdev_gendev);
+}
+
+#define spi_transport_show_function(field, format_string) \
+static ssize_t \
+show_spi_transport_##field (struct class_device *cdev, char *buf) \
+{ \
+ struct scsi_device *sdev = transport_class_to_sdev(cdev); \
+ struct spi_transport_attrs *tp; \
+ tp = (struct spi_transport_attrs *)&sdev->transport_data; \
+ return snprintf(buf, 20, format_string, tp->field); \
+}
+
+#define spi_transport_rd_attr(field, format_string) \
+ spi_transport_show_function(field, format_string) \
+static CLASS_DEVICE_ATTR( field, S_IRUGO, show_spi_transport_##field, NULL)
+
+/* The Parallel SCSI Tranport Attributes: */
+spi_transport_rd_attr(period, "%d\n");
+spi_transport_rd_attr(offset, "%d\n");
+
+struct class_device_attribute *spi_transport_attrs[] = {
+ &class_device_attr_period,
+ &class_device_attr_offset,
+ NULL
+};
+
+struct scsi_transport_template spi_transport_template = {
+ .attrs = spi_transport_attrs,
+ .class = &spi_transport_class,
+ .setup = &spi_setup_transport_attrs,
+ .cleanup = NULL,
+ .size = sizeof(struct spi_transport_attrs) - sizeof(unsigned long),
+};
+EXPORT_SYMBOL(spi_transport_template);
+
+MODULE_AUTHOR("Martin Hicks");
+MODULE_DESCRIPTION("SPI Transport Attributes");
+MODULE_LICENSE("GPL");
+
+module_init(spi_transport_init);
+module_exit(spi_transport_exit);
diff -Nru a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
--- a/include/scsi/scsi_device.h Thu Mar 4 10:26:56 2004
+++ b/include/scsi/scsi_device.h Thu Mar 4 10:26:56 2004
@@ -103,12 +103,17 @@
struct device sdev_gendev;
struct class_device sdev_classdev;
+ struct class_device transport_classdev;
+
enum scsi_device_state sdev_state;
-};
+ unsigned long transport_data[0];
+} __attribute__((aligned(sizeof(unsigned long))));
#define to_scsi_device(d) \
container_of(d, struct scsi_device, sdev_gendev)
#define class_to_sdev(d) \
container_of(d, struct scsi_device, sdev_classdev)
+#define transport_class_to_sdev(class_dev) \
+ container_of(class_dev, struct scsi_device, transport_classdev)
extern struct scsi_device *scsi_add_device(struct Scsi_Host *,
uint, uint, uint);
diff -Nru a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
--- a/include/scsi/scsi_host.h Thu Mar 4 10:26:56 2004
+++ b/include/scsi/scsi_host.h Thu Mar 4 10:26:56 2004
@@ -11,6 +11,7 @@
struct scsi_device;
struct Scsi_Host;
struct scsi_host_cmd_pool;
+struct scsi_transport_template;
/*
@@ -395,6 +396,7 @@
unsigned int eh_kill:1; /* set when killing the eh thread */
wait_queue_head_t host_wait;
struct scsi_host_template *hostt;
+ struct scsi_transport_template *transportt;
volatile unsigned short host_busy; /* commands actually active on low-level */
volatile unsigned short host_failed; /* commands that failed. */
diff -Nru a/include/scsi/scsi_transport.h b/include/scsi/scsi_transport.h
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/include/scsi/scsi_transport.h Thu Mar 4 10:26:56 2004
@@ -0,0 +1,41 @@
+/*
+ * Transport specific attributes.
+ *
+ * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef SCSI_TRANSPORT_H
+#define SCSI_TRANSPORT_H
+
+struct scsi_transport_template {
+ /* The NULL terminated list of transport attributes
+ * that should be exported.
+ */
+ struct class_device_attribute **attrs;
+
+ /* The transport class that the device is in */
+ struct class *class;
+
+ /* Constructor/Destructor functions */
+ int (* setup)(struct scsi_device *);
+ void (* cleanup)(struct scsi_device *);
+ /* The size of the specific transport attribute structure (a
+ * space of this size will be left at the end of the
+ * scsi_device structure */
+ int size;
+};
+
+#endif /* SCSI_TRANSPORT_H */
diff -Nru a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/include/scsi/scsi_transport_fc.h Thu Mar 4 10:26:56 2004
@@ -0,0 +1,38 @@
+/*
+ * FiberChannel transport specific attributes exported to sysfs.
+ *
+ * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef SCSI_TRANSPORT_FC_H
+#define SCSI_TRANSPORT_FC_H
+
+struct scsi_transport_template;
+
+struct fc_transport_attrs {
+ int port_id;
+ uint64_t node_name;
+ uint64_t port_name;
+};
+
+/* accessor functions */
+#define fc_port_id(x) (((struct fc_transport_attrs *)&(x)->transport_data)->port_id)
+#define fc_node_name(x) (((struct fc_transport_attrs *)&(x)->transport_data)->node_name)
+#define fc_port_name(x) (((struct fc_transport_attrs *)&(x)->transport_data)->port_name)
+
+extern struct scsi_transport_template fc_transport_template;
+
+#endif /* SCSI_TRANSPORT_FC_H */
diff -Nru a/include/scsi/scsi_transport_spi.h b/include/scsi/scsi_transport_spi.h
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/include/scsi/scsi_transport_spi.h Thu Mar 4 10:26:56 2004
@@ -0,0 +1,38 @@
+/*
+ * Parallel SCSI (SPI) transport specific attributes exported to sysfs.
+ *
+ * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef SCSI_TRANSPORT_SPI_H
+#define SCSI_TRANSPORT_SPI_H
+
+#include <linux/config.h>
+
+struct scsi_transport_template;
+
+struct spi_transport_attrs {
+ int period;
+ int offset;
+};
+
+/* accessor functions */
+#define spi_period(x) (((struct spi_transport_attrs *)&(x)->transport_data)->period)
+#define spi_offset(x) (((struct spi_transport_attrs *)&(x)->transport_data)->offset)
+
+extern struct scsi_transport_template spi_transport_template;
+
+#endif /* SCSI_TRANSPORT_SPI_H */
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-03-04 16:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-20 21:56 Transport Attributes -- attempt#4 Martin Hicks
2004-01-20 23:48 ` Patrick Mansfield
2004-02-24 0:17 ` James Bottomley
2004-02-24 5:58 ` Jeremy Higdon
2004-02-24 15:02 ` James Bottomley
2004-02-25 7:08 ` Jeremy Higdon
2004-02-25 16:42 ` James Bottomley
2004-03-04 16:14 ` Martin Hicks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox