aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_transport_srp.c
diff options
context:
space:
mode:
authorFUJITA Tomonori <tomof@acm.org>2007-07-11 02:08:19 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:37:53 -0400
commit62fe88261b9d865264d857777cf58a0335513151 (patch)
treedb111392d242cabfddebbee7eae6b6d971eec35e /drivers/scsi/scsi_transport_srp.c
parent2c47f9efbedbe5749b6bb16e59bc11d6e460855f (diff)
[SCSI] srp_transport: add target driver support
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 <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/scsi_transport_srp.c')
-rw-r--r--drivers/scsi/scsi_transport_srp.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index 608abd8aef20..8e5b41ca181d 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -30,6 +30,7 @@
30#include <scsi/scsi_host.h> 30#include <scsi/scsi_host.h>
31#include <scsi/scsi_transport.h> 31#include <scsi/scsi_transport.h>
32#include <scsi/scsi_transport_srp.h> 32#include <scsi/scsi_transport_srp.h>
33#include <scsi/scsi_tgt.h>
33 34
34struct srp_host_attrs { 35struct srp_host_attrs {
35 atomic_t next_port_id; 36 atomic_t next_port_id;
@@ -221,6 +222,17 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
221 return ERR_PTR(ret); 222 return ERR_PTR(ret);
222 } 223 }
223 224
225 if (ids->roles == SRP_RPORT_ROLE_INITIATOR) {
226 ret = scsi_tgt_it_nexus_create(shost, (unsigned long)rport,
227 rport->port_id);
228 if (ret) {
229 device_del(&rport->dev);
230 transport_destroy_device(&rport->dev);
231 put_device(&rport->dev);
232 return ERR_PTR(ret);
233 }
234 }
235
224 transport_add_device(&rport->dev); 236 transport_add_device(&rport->dev);
225 transport_configure_device(&rport->dev); 237 transport_configure_device(&rport->dev);
226 238
@@ -238,6 +250,10 @@ void srp_rport_del(struct srp_rport *rport)
238{ 250{
239 struct device *dev = &rport->dev; 251 struct device *dev = &rport->dev;
240 252
253 if (rport->roles == SRP_RPORT_ROLE_INITIATOR)
254 scsi_tgt_it_nexus_destroy(dev_to_shost(dev->parent),
255 (unsigned long)rport);
256
241 transport_remove_device(dev); 257 transport_remove_device(dev);
242 device_del(dev); 258 device_del(dev);
243 transport_destroy_device(dev); 259 transport_destroy_device(dev);
@@ -264,6 +280,12 @@ void srp_remove_host(struct Scsi_Host *shost)
264} 280}
265EXPORT_SYMBOL_GPL(srp_remove_host); 281EXPORT_SYMBOL_GPL(srp_remove_host);
266 282
283static int srp_it_nexus_response(struct Scsi_Host *shost, u64 id, int result)
284{
285 struct srp_internal *i = to_srp_internal(shost->transportt);
286 return i->f->it_nexus_response(shost, id, result);
287}
288
267/** 289/**
268 * srp_attach_transport -- instantiate SRP transport template 290 * srp_attach_transport -- instantiate SRP transport template
269 * @ft: SRP transport class function template 291 * @ft: SRP transport class function template
@@ -278,6 +300,8 @@ srp_attach_transport(struct srp_function_template *ft)
278 if (!i) 300 if (!i)
279 return NULL; 301 return NULL;
280 302
303 i->t.it_nexus_response = srp_it_nexus_response;
304
281 i->t.host_size = sizeof(struct srp_host_attrs); 305 i->t.host_size = sizeof(struct srp_host_attrs);
282 i->t.host_attrs.ac.attrs = &i->host_attrs[0]; 306 i->t.host_attrs.ac.attrs = &i->host_attrs[0];
283 i->t.host_attrs.ac.class = &srp_host_class.class; 307 i->t.host_attrs.ac.class = &srp_host_class.class;