[PATCH 5/6] tgt: move tsk_mgmt_response callback to transport class

2007-07-11 Thread FUJITA Tomonori
This moves tsk_mgmt_response callback in struct scsi_host_template to
struct scsi_transport_template since struct scsi_transport_template is
more suitable for the task management stuff.

Signed-off-by: FUJITA Tomonori [EMAIL PROTECTED]
Signed-off-by: Mike Christie [EMAIL PROTECTED]
---
 drivers/scsi/scsi_tgt_lib.c   |2 +-
 drivers/scsi/scsi_transport_srp.c |   12 ++--
 include/scsi/scsi_host.h  |3 ---
 include/scsi/scsi_transport.h |6 ++
 include/scsi/scsi_transport_srp.h |1 +
 5 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
index 7d15173..0482143 100644
--- a/drivers/scsi/scsi_tgt_lib.c
+++ b/drivers/scsi/scsi_tgt_lib.c
@@ -577,7 +577,7 @@ int scsi_tgt_kspace_tsk_mgmt(int host_no
goto done;
}
 
-   err = shost-hostt-tsk_mgmt_response(shost, itn_id, mid, result);
+   err = shost-transportt-tsk_mgmt_response(shost, itn_id, mid, result);
 done:
scsi_host_put(shost);
return err;
diff --git a/drivers/scsi/scsi_transport_srp.c 
b/drivers/scsi/scsi_transport_srp.c
index 8e5b41c..cdd001a 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -280,10 +280,17 @@ void srp_remove_host(struct Scsi_Host *s
 }
 EXPORT_SYMBOL_GPL(srp_remove_host);
 
-static int srp_it_nexus_response(struct Scsi_Host *shost, u64 id, int result)
+static int srp_tsk_mgmt_response(struct Scsi_Host *shost, u64 nexus, u64 tm_id,
+int result)
 {
struct srp_internal *i = to_srp_internal(shost-transportt);
-   return i-f-it_nexus_response(shost, id, result);
+   return i-f-tsk_mgmt_response(shost, nexus, tm_id, result);
+}
+
+static int srp_it_nexus_response(struct Scsi_Host *shost, u64 nexus, int 
result)
+{
+   struct srp_internal *i = to_srp_internal(shost-transportt);
+   return i-f-it_nexus_response(shost, nexus, result);
 }
 
 /**
@@ -300,6 +307,7 @@ srp_attach_transport(struct srp_function
if (!i)
return NULL;
 
+   i-t.tsk_mgmt_response = srp_tsk_mgmt_response;
i-t.it_nexus_response = srp_it_nexus_response;
 
i-t.host_size = sizeof(struct srp_host_attrs);
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index dcf4a20..0f482ba 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -145,9 +145,6 @@ #endif
int (* transfer_response)(struct scsi_cmnd *,
  void (*done)(struct scsi_cmnd *));
 
-   /* Used as callback for the completion of task management request. */
-   int (* tsk_mgmt_response)(struct Scsi_Host *, u64, u64 mid, int result);
-
/*
 * This is an error handling strategy routine.  You don't need to
 * define one of these if you don't want to - there is a default
diff --git a/include/scsi/scsi_transport.h b/include/scsi/scsi_transport.h
index af5b3e1..0dfef75 100644
--- a/include/scsi/scsi_transport.h
+++ b/include/scsi/scsi_transport.h
@@ -71,6 +71,12 @@ struct scsi_transport_template {
 * for target drivers.
 */
int (* it_nexus_response)(struct Scsi_Host *, u64, int);
+
+   /*
+* Used as callback for the completion of task management
+* request for target drivers.
+*/
+   int (* tsk_mgmt_response)(struct Scsi_Host *, u64, u64, int);
 };
 
 #define transport_class_to_shost(tc) \
diff --git a/include/scsi/scsi_transport_srp.h 
b/include/scsi/scsi_transport_srp.h
index a705dbc..9c60ca1 100644
--- a/include/scsi/scsi_transport_srp.h
+++ b/include/scsi/scsi_transport_srp.h
@@ -22,6 +22,7 @@ struct srp_rport {
 
 struct srp_function_template {
/* for target drivers */
+   int (* tsk_mgmt_response)(struct Scsi_Host *, u64, u64, int);
int (* it_nexus_response)(struct Scsi_Host *, u64, int);
 };
 
-- 
1.4.3.2

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] tgt: convert ibmvstgt to use transport tsk_mgmt_response callback

2007-07-11 Thread FUJITA Tomonori
This converts ibmvstgt to use transport tsk_mgmt_response callback.

Signed-off-by: FUJITA Tomonori [EMAIL PROTECTED]
Signed-off-by: Mike Christie [EMAIL PROTECTED]
---
 drivers/scsi/ibmvscsi/ibmvstgt.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c
index 4ee6e41..3db03dd 100644
--- a/drivers/scsi/ibmvscsi/ibmvstgt.c
+++ b/drivers/scsi/ibmvscsi/ibmvstgt.c
@@ -818,7 +818,6 @@ static struct scsi_host_template ibmvstg
.max_sectors= DEFAULT_MAX_SECTORS,
.transfer_response  = ibmvstgt_cmd_done,
.eh_abort_handler   = ibmvstgt_eh_abort_handler,
-   .tsk_mgmt_response  = ibmvstgt_tsk_mgmt_response,
.shost_attrs= ibmvstgt_attrs,
.proc_name  = TGT_NAME,
 };
@@ -945,6 +944,7 @@ static int get_system_info(void)
 }
 
 static struct srp_function_template ibmvstgt_transport_functions = {
+   .tsk_mgmt_response = ibmvstgt_tsk_mgmt_response,
.it_nexus_response = ibmvstgt_it_nexus_response,
 };
 
-- 
1.4.3.2

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] transport_srp: add rport roles attribute

2007-07-11 Thread FUJITA Tomonori
This adds a 'roles' attribute to rport like transport_fc. The role can
be initiator or target. That is, the initiator driver creates target
remote ports and the target driver creates initiator remote ports.

Signed-off-by: FUJITA Tomonori [EMAIL PROTECTED]
Signed-off-by: Mike Christie [EMAIL PROTECTED]
---
 drivers/infiniband/ulp/srp/ib_srp.c |1 +
 drivers/scsi/ibmvscsi/ibmvscsi.c|1 +
 drivers/scsi/scsi_transport_srp.c   |   29 -
 include/scsi/scsi_transport_srp.h   |5 +
 4 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c 
b/drivers/infiniband/ulp/srp/ib_srp.c
index d8d056e..e616c4f 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1545,6 +1545,7 @@ static int srp_add_target(struct srp_hos
 
memcpy(ids.port_id, target-id_ext, 8);
memcpy(ids.port_id + 8, target-ioc_guid, 8);
+   ids.roles = SRP_RPORT_ROLE_TARGET;
rport = srp_rport_add(target-scsi_host, ids);
if (IS_ERR(rport)) {
scsi_remove_host(target-scsi_host);
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 620e9e7..19e9592 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1650,6 +1650,7 @@ static int ibmvscsi_probe(struct vio_dev
/* we don't have a proper target_port_id so let's use the fake one */
memcpy(ids.port_id, hostdata-madapter_info.partition_name,
   sizeof(ids.port_id));
+   ids.roles = SRP_RPORT_ROLE_TARGET;
rport = srp_rport_add(host, ids);
if (IS_ERR(rport))
goto add_srp_port_failed;
diff --git a/drivers/scsi/scsi_transport_srp.c 
b/drivers/scsi/scsi_transport_srp.c
index dcb3d2a..608abd8 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -37,7 +37,7 @@ struct srp_host_attrs {
 #define to_srp_host_attrs(host)((struct srp_host_attrs 
*)(host)-shost_data)
 
 #define SRP_HOST_ATTRS 0
-#define SRP_RPORT_ATTRS 3
+#define SRP_RPORT_ATTRS 2
 
 struct srp_internal {
struct scsi_transport_template t;
@@ -107,6 +107,31 @@ show_srp_rport_id(struct class_device *c
 
 static CLASS_DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL);
 
+static const struct {
+   u32 value;
+   char *name;
+} srp_rport_role_names[] = {
+   {SRP_RPORT_ROLE_INITIATOR, SRP Initiator},
+   {SRP_RPORT_ROLE_TARGET, SRP Target},
+};
+
+static ssize_t
+show_srp_rport_roles(struct class_device *cdev, char *buf)
+{
+   struct srp_rport *rport = transport_class_to_srp_rport(cdev);
+   int i;
+   char *name = NULL;
+
+   for (i = 0; i  ARRAY_SIZE(srp_rport_role_names); i++)
+   if (srp_rport_role_names[i].value == rport-roles) {
+   name = srp_rport_role_names[i].name;
+   break;
+   }
+   return sprintf(buf, %s\n, name ? : unknown);
+}
+
+static CLASS_DEVICE_ATTR(roles, S_IRUGO, show_srp_rport_roles, NULL);
+
 static void srp_rport_release(struct device *dev)
 {
struct srp_rport *rport = dev_to_rport(dev);
@@ -182,6 +207,7 @@ struct srp_rport *srp_rport_add(struct S
rport-dev.release = srp_rport_release;
 
memcpy(rport-port_id, ids-port_id, sizeof(rport-port_id));
+   rport-roles = ids-roles;
 
id = atomic_inc_return(to_srp_host_attrs(shost)-next_port_id);
sprintf(rport-dev.bus_id, port-%d:%d, shost-host_no, id);
@@ -266,6 +292,7 @@ srp_attach_transport(struct srp_function
 
count = 0;
SETUP_RPORT_ATTRIBUTE_RD(port_id);
+   SETUP_RPORT_ATTRIBUTE_RD(roles);
i-rport_attrs[count] = NULL;
 
i-f = ft;
diff --git a/include/scsi/scsi_transport_srp.h 
b/include/scsi/scsi_transport_srp.h
index adbfca4..08b4a28 100644
--- a/include/scsi/scsi_transport_srp.h
+++ b/include/scsi/scsi_transport_srp.h
@@ -5,14 +5,19 @@ #include linux/transport_class.h
 #include linux/types.h
 #include linux/mutex.h
 
+#define SRP_RPORT_ROLE_INITIATOR 0
+#define SRP_RPORT_ROLE_TARGET 1
+
 struct srp_rport_identifiers {
u8 port_id[16];
+   u8 roles;
 };
 
 struct srp_rport {
struct device dev;
 
u8 port_id[16];
+   u8 roles;
 };
 
 struct srp_function_template {
-- 
1.4.3.2

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/6] srp_transport: add target driver support

2007-07-11 Thread FUJITA Tomonori
This adds minimum target driver support:

- srp_rport_{add,del} calls scsi_tgt_it_nexus_{create,destroy} for
target drivers.

- add a callback to notify target drivers of the nexus operation
results to srp_function_template.

Signed-off-by: FUJITA Tomonori [EMAIL PROTECTED]
Signed-off-by: Mike Christie [EMAIL PROTECTED]
---
 drivers/scsi/Kconfig  |2 +-
 drivers/scsi/scsi_transport_srp.c |   24 
 include/scsi/scsi_transport_srp.h |3 ++-
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index dfb45e7..ede8395 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -285,7 +285,7 @@ source drivers/scsi/libsas/Kconfig
 
 config SCSI_SRP_ATTRS
tristate SRP Transport Attributes
-   depends on SCSI
+   depends on SCSI  SCSI_TGT
help
  If you wish to export transport-specific information about
  each attached SRP device to sysfs, say Y.
diff --git a/drivers/scsi/scsi_transport_srp.c 
b/drivers/scsi/scsi_transport_srp.c
index 608abd8..8e5b41c 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -30,6 +30,7 @@ #include scsi/scsi_device.h
 #include scsi/scsi_host.h
 #include scsi/scsi_transport.h
 #include scsi/scsi_transport_srp.h
+#include scsi/scsi_tgt.h
 
 struct srp_host_attrs {
atomic_t next_port_id;
@@ -221,6 +222,17 @@ struct srp_rport *srp_rport_add(struct S
return ERR_PTR(ret);
}
 
+   if (ids-roles == SRP_RPORT_ROLE_INITIATOR) {
+   ret = scsi_tgt_it_nexus_create(shost, (unsigned long)rport,
+  rport-port_id);
+   if (ret) {
+   device_del(rport-dev);
+   transport_destroy_device(rport-dev);
+   put_device(rport-dev);
+   return ERR_PTR(ret);
+   }
+   }
+
transport_add_device(rport-dev);
transport_configure_device(rport-dev);
 
@@ -238,6 +250,10 @@ void srp_rport_del(struct srp_rport *rpo
 {
struct device *dev = rport-dev;
 
+   if (rport-roles == SRP_RPORT_ROLE_INITIATOR)
+   scsi_tgt_it_nexus_destroy(dev_to_shost(dev-parent),
+ (unsigned long)rport);
+
transport_remove_device(dev);
device_del(dev);
transport_destroy_device(dev);
@@ -264,6 +280,12 @@ void srp_remove_host(struct Scsi_Host *s
 }
 EXPORT_SYMBOL_GPL(srp_remove_host);
 
+static int srp_it_nexus_response(struct Scsi_Host *shost, u64 id, int result)
+{
+   struct srp_internal *i = to_srp_internal(shost-transportt);
+   return i-f-it_nexus_response(shost, id, result);
+}
+
 /**
  * srp_attach_transport  --  instantiate SRP transport template
  * @ft:SRP transport class function template
@@ -278,6 +300,8 @@ srp_attach_transport(struct srp_function
if (!i)
return NULL;
 
+   i-t.it_nexus_response = srp_it_nexus_response;
+
i-t.host_size = sizeof(struct srp_host_attrs);
i-t.host_attrs.ac.attrs = i-host_attrs[0];
i-t.host_attrs.ac.class = srp_host_class.class;
diff --git a/include/scsi/scsi_transport_srp.h 
b/include/scsi/scsi_transport_srp.h
index 08b4a28..a705dbc 100644
--- a/include/scsi/scsi_transport_srp.h
+++ b/include/scsi/scsi_transport_srp.h
@@ -21,7 +21,8 @@ struct srp_rport {
 };
 
 struct srp_function_template {
-   /* later */
+   /* for target drivers */
+   int (* it_nexus_response)(struct Scsi_Host *, u64, int);
 };
 
 extern struct scsi_transport_template *
-- 
1.4.3.2

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] tgt: convert libsrp and ibmvstgt to use srp_transport

2007-07-11 Thread FUJITA Tomonori
This converts libsrp and ibmvstgt to use srp transport.

Signed-off-by: FUJITA Tomonori [EMAIL PROTECTED]
Signed-off-by: Mike Christie [EMAIL PROTECTED]
---
 drivers/scsi/Kconfig |2 +-
 drivers/scsi/ibmvscsi/ibmvstgt.c |   58 ++
 drivers/scsi/libsrp.c|5 ++-
 include/scsi/libsrp.h|2 +-
 4 files changed, 57 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index ede8395..0a2a25a 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -838,7 +838,7 @@ config SCSI_IBMVSCSI
 
 config SCSI_IBMVSCSIS
tristate IBM Virtual SCSI Server support
-   depends on PPC_PSERIES  SCSI_TGT  SCSI_SRP
+   depends on PPC_PSERIES  SCSI_TGT  SCSI_SRP  SCSI_SRP_ATTRS
help
  This is the SRP target driver for IBM pSeries virtual environments.
 
diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c
index 8ba7dd0..4ee6e41 100644
--- a/drivers/scsi/ibmvscsi/ibmvstgt.c
+++ b/drivers/scsi/ibmvscsi/ibmvstgt.c
@@ -25,6 +25,7 @@ #include linux/interrupt.h
 #include linux/module.h
 #include scsi/scsi.h
 #include scsi/scsi_host.h
+#include scsi/scsi_transport_srp.h
 #include scsi/scsi_tgt.h
 #include scsi/libsrp.h
 #include asm/hvcall.h
@@ -68,9 +69,12 @@ struct vio_port {
unsigned long liobn;
unsigned long riobn;
struct srp_target *target;
+
+   struct srp_rport *rport;
 };
 
 static struct workqueue_struct *vtgtd;
+static struct scsi_transport_template *ibmvstgt_transport_template;
 
 /*
  * These are fixed for the system and come from the Open Firmware device tree.
@@ -188,6 +192,7 @@ static int send_rsp(struct iu_entry *iue
 static void handle_cmd_queue(struct srp_target *target)
 {
struct Scsi_Host *shost = target-shost;
+   struct srp_rport *rport = target_to_port(target)-rport;
struct iu_entry *iue;
struct srp_cmd *cmd;
unsigned long flags;
@@ -200,7 +205,8 @@ retry:
if (!test_and_set_bit(V_FLYING, iue-flags)) {
spin_unlock_irqrestore(target-lock, flags);
cmd = iue-sbuf-buf;
-   err = srp_cmd_queue(shost, cmd, iue, 0);
+   err = srp_cmd_queue(shost, cmd, iue,
+   (unsigned long)rport, 0);
if (err) {
eprintk(cannot queue cmd %p %d\n, cmd, err);
srp_iu_put(iue);
@@ -359,6 +365,16 @@ static void process_login(struct iu_entr
union viosrp_iu *iu = vio_iu(iue);
struct srp_login_rsp *rsp = iu-srp.login_rsp;
uint64_t tag = iu-srp.rsp.tag;
+   struct Scsi_Host *shost = iue-target-shost;
+   struct srp_target *target = host_to_srp_target(shost);
+   struct vio_port *vport = target_to_port(target);
+   struct srp_rport_identifiers ids;
+
+   memset(ids, 0, sizeof(ids));
+   sprintf(ids.port_id, %x, vport-dma_dev-unit_address);
+   ids.roles = SRP_RPORT_ROLE_INITIATOR;
+   if (!vport-rport)
+   vport-rport = srp_rport_add(shost, ids);
 
/* TODO handle case that requested size is wrong and
 * buffer format is wrong
@@ -412,7 +428,9 @@ static int process_tsk_mgmt(struct iu_en
fn = 0;
}
if (fn)
-   scsi_tgt_tsk_mgmt_request(iue-target-shost, fn,
+   scsi_tgt_tsk_mgmt_request(iue-target-shost,
+ (unsigned long)iue-target-shost,
+ fn,
  iu-srp.tsk_mgmt.task_tag,
  (struct scsi_lun *) 
iu-srp.tsk_mgmt.lun,
  iue);
@@ -721,7 +739,8 @@ static int ibmvstgt_eh_abort_handler(str
return 0;
 }
 
-static int ibmvstgt_tsk_mgmt_response(u64 mid, int result)
+static int ibmvstgt_tsk_mgmt_response(struct Scsi_Host *shost,
+ u64 itn_id, u64 mid, int result)
 {
struct iu_entry *iue = (struct iu_entry *) ((void *) mid);
union viosrp_iu *iu = vio_iu(iue);
@@ -747,6 +766,20 @@ static int ibmvstgt_tsk_mgmt_response(u6
return 0;
 }
 
+static int ibmvstgt_it_nexus_response(struct Scsi_Host *shost, u64 itn_id,
+ int result)
+{
+   struct srp_target *target = host_to_srp_target(shost);
+   struct vio_port *vport = target_to_port(target);
+
+   if (result) {
+   eprintk(%p %d\n, shost, result);
+   srp_rport_del(vport-rport);
+   vport-rport = NULL;
+   }
+   return 0;
+}
+
 static ssize_t system_id_show(struct class_device *cdev, char *buf)
 {
return snprintf(buf, PAGE_SIZE, %s\n, system_id);
@@ -804,6 +837,7 @@ static int ibmvstgt_probe(struct vio_dev
shost = scsi_host_alloc(ibmvstgt_sht, 

[PATCH 2/6] tgt: add I_T nexus support

2007-07-11 Thread FUJITA Tomonori
tgt uses scsi_host as I_T nexus. This works for ibmvstgt because it
creates one scsi_host for one initiator. However, other target drivers
don't work like that.

This adds I_T nexus support, which enable one scsi_host to handle
multiple initiators. New scsi_tgt_it_nexus_create/destroy functions
are expected be called transport classes. For example, ibmvstgt
creates an initiator remote port, then the srp transport calls
tgt_it_nexus_create. tgt doesn't manages I_T nexus, instead it tells
tgtd, user-space daemon, to create a new I_T nexus.

On the receiving the response from tgtd, tgt calls
shost-transportt-it_nexus_response. transports should notify a
lld. The srp transport uses it_nexus_response callback in
srp_function_template to do that.

Signed-off-by: FUJITA Tomonori [EMAIL PROTECTED]
Signed-off-by: Mike Christie [EMAIL PROTECTED]
---
 drivers/scsi/scsi_tgt_if.c|   42 +++--
 drivers/scsi/scsi_tgt_lib.c   |   83 ++--
 drivers/scsi/scsi_tgt_priv.h  |   22 +++
 include/scsi/scsi_host.h  |2 +-
 include/scsi/scsi_tgt.h   |8 ++-
 include/scsi/scsi_tgt_if.h|   35 +
 include/scsi/scsi_transport.h |6 +++
 7 files changed, 161 insertions(+), 37 deletions(-)

diff --git a/drivers/scsi/scsi_tgt_if.c b/drivers/scsi/scsi_tgt_if.c
index ca22ddf..9815a1a 100644
--- a/drivers/scsi/scsi_tgt_if.c
+++ b/drivers/scsi/scsi_tgt_if.c
@@ -102,7 +102,8 @@ static int tgt_uspace_send_event(u32 typ
return 0;
 }
 
-int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, struct scsi_lun *lun, u64 
tag)
+int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, u64 itn_id,
+struct scsi_lun *lun, u64 tag)
 {
struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd);
struct tgt_event ev;
@@ -110,6 +111,7 @@ int scsi_tgt_uspace_send_cmd(struct scsi
 
memset(ev, 0, sizeof(ev));
ev.p.cmd_req.host_no = shost-host_no;
+   ev.p.cmd_req.itn_id = itn_id;
ev.p.cmd_req.data_len = cmd-request_bufflen;
memcpy(ev.p.cmd_req.scb, cmd-cmnd, sizeof(ev.p.cmd_req.scb));
memcpy(ev.p.cmd_req.lun, lun, sizeof(ev.p.cmd_req.lun));
@@ -127,7 +129,7 @@ int scsi_tgt_uspace_send_cmd(struct scsi
return err;
 }
 
-int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 tag)
+int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 itn_id, u64 tag)
 {
struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd);
struct tgt_event ev;
@@ -135,6 +137,7 @@ int scsi_tgt_uspace_send_status(struct s
 
memset(ev, 0, sizeof(ev));
ev.p.cmd_done.host_no = shost-host_no;
+   ev.p.cmd_done.itn_id = itn_id;
ev.p.cmd_done.tag = tag;
ev.p.cmd_done.result = cmd-result;
 
@@ -149,14 +152,15 @@ int scsi_tgt_uspace_send_status(struct s
return err;
 }
 
-int scsi_tgt_uspace_send_tsk_mgmt(int host_no, int function, u64 tag,
- struct scsi_lun *scsilun, void *data)
+int scsi_tgt_uspace_send_tsk_mgmt(int host_no, u64 itn_id, int function,
+ u64 tag, struct scsi_lun *scsilun, void *data)
 {
struct tgt_event ev;
int err;
 
memset(ev, 0, sizeof(ev));
ev.p.tsk_mgmt_req.host_no = host_no;
+   ev.p.tsk_mgmt_req.itn_id = itn_id;
ev.p.tsk_mgmt_req.function = function;
ev.p.tsk_mgmt_req.tag = tag;
memcpy(ev.p.tsk_mgmt_req.lun, scsilun, sizeof(ev.p.tsk_mgmt_req.lun));
@@ -172,6 +176,29 @@ int scsi_tgt_uspace_send_tsk_mgmt(int ho
return err;
 }
 
+int scsi_tgt_uspace_send_it_nexus_request(int host_no, u64 itn_id,
+ int function, char *initiator_id)
+{
+   struct tgt_event ev;
+   int err;
+
+   memset(ev, 0, sizeof(ev));
+   ev.p.it_nexus_req.host_no = host_no;
+   ev.p.it_nexus_req.function = function;
+   ev.p.it_nexus_req.itn_id = itn_id;
+   if (initiator_id)
+   strncpy(ev.p.it_nexus_req.initiator_id, initiator_id,
+   sizeof(ev.p.it_nexus_req.initiator_id));
+
+   dprintk(%d %x %llx\n, host_no, function, (unsigned long long)itn_id);
+
+   err = tgt_uspace_send_event(TGT_KEVENT_IT_NEXUS_REQ, ev);
+   if (err)
+   eprintk(tx buf is full, could not send\n);
+
+   return err;
+}
+
 static int event_recv_msg(struct tgt_event *ev)
 {
int err = 0;
@@ -179,6 +206,7 @@ static int event_recv_msg(struct tgt_eve
switch (ev-hdr.type) {
case TGT_UEVENT_CMD_RSP:
err = scsi_tgt_kspace_exec(ev-p.cmd_rsp.host_no,
+  ev-p.cmd_rsp.itn_id,
   ev-p.cmd_rsp.result,
   ev-p.cmd_rsp.tag,
   ev-p.cmd_rsp.uaddr,
@@ -189,9 +217,15 @@ static int event_recv_msg(struct tgt_eve
break;
case 

Re: [PATCH] dtc: Coding police and printk levels

2007-07-11 Thread MikeW
Alan Cox alan at lxorguk.ukuu.org.uk writes:

 
 On Fri, 22 Jun 2007 11:00:06 -0700
 Darrick J. Wong djwong at us.ibm.com wrote:
 
  On Fri, Jun 22, 2007 at 02:26:29PM +0100, Alan Cox wrote:
at  at  -244,7 +242,7  at  at 
 if (check_signature(base + 
   signatures[sig].offset,
signatures[sig].string,
 strlen(signatures[sig].string))) {
 addr = 
   bases[current_base].address;
#if (DTCDEBUG  DTCDEBUG_INIT)
   - printk(scsi-dtc : detected 
   board.\n);
   + printk(KERB_DEBUG scsi-dtc : 
   detected board.\n);
  
  I think you meant KERN_DEBUG ?
 
 Thanks - thats a path thats not compiled and I missed that. Will fix it.
 -

I guess we should always test-compile all edited build paths to ensure
we have not broken someone else's build. That's going into my checklist !

Thanks,
MikeW




-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 2/4] Expose Power Management Policy option to users

2007-07-11 Thread Pavel Machek
Hi!

 This patch will modify the scsi subsystem to allow
 users to set a power management policy for the link.
 
 The scsi subsystem will create a new sysfs file for each
 host in /sys/class/scsi_host called link_power_management_policy.
 This file can have 3 possible values:
 
 Value Meaning
 ---
 min_power User wishes the link to conserve power as much as
   possible, even at the cost of some performance
 
 max_performance User wants priority to be on performance, not power
   savings
 
 medium_power  User wants power savings, with less performance cost
   than min_power (but less power savings as well).

Has that anything to do with HIPM vs. DIPM? 

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 2/4] Expose Power Management Policy option to users

2007-07-11 Thread Kristen Carlson Accardi
On Mon, 9 Jul 2007 19:36:04 +
Pavel Machek [EMAIL PROTECTED] wrote:

 Hi!
 
  This patch will modify the scsi subsystem to allow
  users to set a power management policy for the link.
  
  The scsi subsystem will create a new sysfs file for each
  host in /sys/class/scsi_host called link_power_management_policy.
  This file can have 3 possible values:
  
  Value   Meaning
  ---
  min_power   User wishes the link to conserve power as much as
  possible, even at the cost of some performance
  
  max_performance User wants priority to be on performance, not power
  savings
  
  medium_powerUser wants power savings, with less performance cost
  than min_power (but less power savings as well).
 
 Has that anything to do with HIPM vs. DIPM? 
 
   Pavel
Hi Pavel,
I'm not sure I'm understanding your question, but if you mean the different
levels of power savings you would get, no.  With ALPM you have the option of
instructing the link to either go into slumber or partial mode when it 
determines the link is quiet.  Slumber uses less power, but has more latency
to come out of.  So, for a SATA device, setting the link_power_managment
file to medium_power will set up the link to only go into Partial mode,
which has less power savings (about half by my informal measurement), but 
less latency, and therefore less of a performance hit.

Hopefully this answers your question.
Kristen
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: scsi, was Re: -mm merge plans for 2.6.23

2007-07-11 Thread Andrew Morton
On Wed, 11 Jul 2007 13:37:18 +0200 Christoph Hellwig [EMAIL PROTECTED] wrote:

  restore-acpi-change-for-scsi.patch
  git-scsi-misc-vs-greg-sysfs-stuff.patch
  aacraid-rename-check_reset.patch
  scsi-dont-build-scsi_dma_mapunmap-for-has_dma.patch
  drivers-scsi-small-cleanups.patch
  sym53c8xx_2-claims-cpqarray-device.patch
  drivers-scsi-wd33c93c-cleanups.patch
  make-seagate_st0x_detect-static.patch
  pci-error-recovery-symbios-scsi-base-support.patch
  pci-error-recovery-symbios-scsi-first-failure.patch
  drivers-scsi-pcmcia-nsp_csc-remove-kernel-24-code.patch
  drivers-message-i2o-devicec-remove-redundant-gfp_atomic-from-kmalloc.patch
  drivers-scsi-aic7xxx_oldc-remove-redundant-gfp_atomic-from-kmalloc.patch
  use-menuconfig-objects-ii-scsi.patch
  remove-dead-references-to-module_parm-macro.patch
  ppa-coding-police-and-printk-levels.patch
  remove-the-dead-cyberstormiii_scsi-option.patch
  config_scsi_fd_8xx-no-longer-exists.patch
  use-mutex-instead-of-semaphore-in-megaraid-mailbox-driver.patch
  
   Sent to James.
 
 Care to drop the patches James NACKed every single time?

I'm not aware of any which fit that description.

There may be a couple in there which fix real bugs in an unapproved way. 
But I keep such patches as a matter of policy, so people keep on getting
pestered about their bugs.

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH][BUG] Incorrect SCSI transfer length computation from odd sized scsi_execute_async() transfers.

2007-07-11 Thread Mike Christie

Jeremy Linton wrote:
Any function which use scsi_execute_async() and transfers odd sized 
data that doesn't align correctly with the segment sizes may have its 
transfer length padded out to the closest segment size.


For writes, this results in unnecessary data being transfered to the 
SCSI target. For reads, it affects the residual data length being 
returned to the application since the residual length will be based on 
the padded transfer size rather than the actual request size.


The easiest way to see this is by trying to read using the SG_IO ioctl a 
large (32k) buffer size from a tape device that only has a few bytes of 
data stored for the current block. The resulting resid will generally be 
incorrect.


I've fixed this simply by changing scsi_req_map_sg() so that it places 
the requested transfer length in rq-data_len rather than the sum of all 
the sg segments.


This patch applies against scsi_lib.c in 2.6.22.

Signed-off-by: Jeremy Linton [EMAIL PROTECTED]


--- linux-2.6.22/drivers/scsi/scsi_lib.c.orig   2007-07-11 
19:07:06.0 -0500
+++ linux-2.6.22/drivers/scsi/scsi_lib.c2007-07-11 
18:43:36.0 -0500

@@ -350,7 +350,7 @@ static int scsi_req_map_sg(struct reques
}

rq-buffer = rq-data = NULL;
-   rq-data_len = data_len;
+   rq-data_len = bufflen;
return 0;



I think you needed some other bits in there. See this patch 
http://marc.info/?l=linux-scsim=117392208211297w=2


I tried just setting the bufflen first, and that still had problems. 
Could you try the patch here


http://marc.info/?l=linux-scsim=117392208211297w=2
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH][BUG] Incorrect SCSI transfer length computation from odd sized scsi_execute_async() transfers.

2007-07-11 Thread Jeremy Linton

Mike Christie wrote:
I think you needed some other bits in there. See this patch 
I tried just setting the bufflen first, and that still had problems. 
Could you try the patch here


http://marc.info/?l=linux-scsim=117392208211297w=2



I just read the thread.. I didn't see any strange retries with my test 
case. I will try duplicating the problem tomorrow. Then I will apply 
your patch and rerun my test.


I'm curious if this has been known since 2.6.19 why the patch hasn't 
propagated to the main kernel tree?



-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html