aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/Kconfig2
-rw-r--r--drivers/scsi/scsi_transport_srp.c24
-rw-r--r--include/scsi/scsi_transport_srp.h3
3 files changed, 27 insertions, 2 deletions
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 778dc0fb1e4f..8d4057ea27b1 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -291,7 +291,7 @@ source "drivers/scsi/libsas/Kconfig"
291 291
292config SCSI_SRP_ATTRS 292config SCSI_SRP_ATTRS
293 tristate "SRP Transport Attributes" 293 tristate "SRP Transport Attributes"
294 depends on SCSI 294 depends on SCSI && SCSI_TGT
295 help 295 help
296 If you wish to export transport-specific information about 296 If you wish to export transport-specific information about
297 each attached SRP device to sysfs, say Y. 297 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 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;
diff --git a/include/scsi/scsi_transport_srp.h b/include/scsi/scsi_transport_srp.h
index 08b4a28a77b8..a705dbc016b3 100644
--- a/include/scsi/scsi_transport_srp.h
+++ b/include/scsi/scsi_transport_srp.h
@@ -21,7 +21,8 @@ struct srp_rport {
21}; 21};
22 22
23struct srp_function_template { 23struct srp_function_template {
24 /* later */ 24 /* for target drivers */
25 int (* it_nexus_response)(struct Scsi_Host *, u64, int);
25}; 26};
26 27
27extern struct scsi_transport_template * 28extern struct scsi_transport_template *