Commit 3236822b authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by James Bottomley

[SCSI] ib_srp: convert to use the srp transport class

This converts ib_srp to use the srp transport class.

I don't have ib hardware so I've not tested this patch.
Signed-off-by: default avatarFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 4d680419
config INFINIBAND_SRP config INFINIBAND_SRP
tristate "InfiniBand SCSI RDMA Protocol" tristate "InfiniBand SCSI RDMA Protocol"
depends on SCSI depends on SCSI
select SCSI_SRP_ATTRS
---help--- ---help---
Support for the SCSI RDMA Protocol over InfiniBand. This Support for the SCSI RDMA Protocol over InfiniBand. This
allows you to access storage devices that speak SRP over allows you to access storage devices that speak SRP over
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include <scsi/scsi_device.h> #include <scsi/scsi_device.h>
#include <scsi/scsi_dbg.h> #include <scsi/scsi_dbg.h>
#include <scsi/srp.h> #include <scsi/srp.h>
#include <scsi/scsi_transport_srp.h>
#include <rdma/ib_cache.h> #include <rdma/ib_cache.h>
...@@ -90,6 +91,8 @@ static void srp_remove_one(struct ib_device *device); ...@@ -90,6 +91,8 @@ static void srp_remove_one(struct ib_device *device);
static void srp_completion(struct ib_cq *cq, void *target_ptr); static void srp_completion(struct ib_cq *cq, void *target_ptr);
static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event); static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event);
static struct scsi_transport_template *ib_srp_transport_template;
static struct ib_client srp_client = { static struct ib_client srp_client = {
.name = "srp", .name = "srp",
.add = srp_add_one, .add = srp_add_one,
...@@ -405,6 +408,7 @@ static void srp_remove_work(struct work_struct *work) ...@@ -405,6 +408,7 @@ static void srp_remove_work(struct work_struct *work)
list_del(&target->list); list_del(&target->list);
spin_unlock(&target->srp_host->target_lock); spin_unlock(&target->srp_host->target_lock);
srp_remove_host(target->scsi_host);
scsi_remove_host(target->scsi_host); scsi_remove_host(target->scsi_host);
ib_destroy_cm_id(target->cm_id); ib_destroy_cm_id(target->cm_id);
srp_free_target_ib(target); srp_free_target_ib(target);
...@@ -1530,12 +1534,23 @@ static struct scsi_host_template srp_template = { ...@@ -1530,12 +1534,23 @@ static struct scsi_host_template srp_template = {
static int srp_add_target(struct srp_host *host, struct srp_target_port *target) static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
{ {
struct srp_rport_identifiers ids;
struct srp_rport *rport;
sprintf(target->target_name, "SRP.T10:%016llX", sprintf(target->target_name, "SRP.T10:%016llX",
(unsigned long long) be64_to_cpu(target->id_ext)); (unsigned long long) be64_to_cpu(target->id_ext));
if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device)) if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device))
return -ENODEV; return -ENODEV;
memcpy(ids.port_id, &target->id_ext, 8);
memcpy(ids.port_id + 8, &target->ioc_guid, 8);
rport = srp_rport_add(target->scsi_host, &ids);
if (IS_ERR(rport)) {
scsi_remove_host(target->scsi_host);
return PTR_ERR(rport);
}
spin_lock(&host->target_lock); spin_lock(&host->target_lock);
list_add_tail(&target->list, &host->target_list); list_add_tail(&target->list, &host->target_list);
spin_unlock(&host->target_lock); spin_unlock(&host->target_lock);
...@@ -1760,6 +1775,7 @@ static ssize_t srp_create_target(struct class_device *class_dev, ...@@ -1760,6 +1775,7 @@ static ssize_t srp_create_target(struct class_device *class_dev,
if (!target_host) if (!target_host)
return -ENOMEM; return -ENOMEM;
target_host->transportt = ib_srp_transport_template;
target_host->max_lun = SRP_MAX_LUN; target_host->max_lun = SRP_MAX_LUN;
target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb; target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb;
...@@ -2039,10 +2055,18 @@ static void srp_remove_one(struct ib_device *device) ...@@ -2039,10 +2055,18 @@ static void srp_remove_one(struct ib_device *device)
kfree(srp_dev); kfree(srp_dev);
} }
static struct srp_function_template ib_srp_transport_functions = {
};
static int __init srp_init_module(void) static int __init srp_init_module(void)
{ {
int ret; int ret;
ib_srp_transport_template =
srp_attach_transport(&ib_srp_transport_functions);
if (!ib_srp_transport_template)
return -ENOMEM;
srp_template.sg_tablesize = srp_sg_tablesize; srp_template.sg_tablesize = srp_sg_tablesize;
srp_max_iu_len = (sizeof (struct srp_cmd) + srp_max_iu_len = (sizeof (struct srp_cmd) +
sizeof (struct srp_indirect_buf) + sizeof (struct srp_indirect_buf) +
...@@ -2051,6 +2075,7 @@ static int __init srp_init_module(void) ...@@ -2051,6 +2075,7 @@ static int __init srp_init_module(void)
ret = class_register(&srp_class); ret = class_register(&srp_class);
if (ret) { if (ret) {
printk(KERN_ERR PFX "couldn't register class infiniband_srp\n"); printk(KERN_ERR PFX "couldn't register class infiniband_srp\n");
srp_release_transport(ib_srp_transport_template);
return ret; return ret;
} }
...@@ -2059,6 +2084,7 @@ static int __init srp_init_module(void) ...@@ -2059,6 +2084,7 @@ static int __init srp_init_module(void)
ret = ib_register_client(&srp_client); ret = ib_register_client(&srp_client);
if (ret) { if (ret) {
printk(KERN_ERR PFX "couldn't register IB client\n"); printk(KERN_ERR PFX "couldn't register IB client\n");
srp_release_transport(ib_srp_transport_template);
ib_sa_unregister_client(&srp_sa_client); ib_sa_unregister_client(&srp_sa_client);
class_unregister(&srp_class); class_unregister(&srp_class);
return ret; return ret;
...@@ -2072,6 +2098,7 @@ static void __exit srp_cleanup_module(void) ...@@ -2072,6 +2098,7 @@ static void __exit srp_cleanup_module(void)
ib_unregister_client(&srp_client); ib_unregister_client(&srp_client);
ib_sa_unregister_client(&srp_sa_client); ib_sa_unregister_client(&srp_sa_client);
class_unregister(&srp_class); class_unregister(&srp_class);
srp_release_transport(ib_srp_transport_template);
} }
module_init(srp_init_module); module_init(srp_init_module);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment