diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2007-06-27 03:33:12 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.localdomain> | 2007-10-12 14:37:42 -0400 |
commit | 3236822b1c9b67ad10745d965515b528818f1120 (patch) | |
tree | afcffc2cd7a15f8ef362e4a114965a3e2c9d7cff /drivers | |
parent | 4d68041907b150b07640b607c6c626391cf3fe8b (diff) |
[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: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/ulp/srp/Kconfig | 1 | ||||
-rw-r--r-- | drivers/infiniband/ulp/srp/ib_srp.c | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/drivers/infiniband/ulp/srp/Kconfig b/drivers/infiniband/ulp/srp/Kconfig index 3432dce29520..c74ee9633041 100644 --- a/drivers/infiniband/ulp/srp/Kconfig +++ b/drivers/infiniband/ulp/srp/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config INFINIBAND_SRP | 1 | config INFINIBAND_SRP |
2 | tristate "InfiniBand SCSI RDMA Protocol" | 2 | tristate "InfiniBand SCSI RDMA Protocol" |
3 | depends on SCSI | 3 | depends on SCSI |
4 | select SCSI_SRP_ATTRS | ||
4 | ---help--- | 5 | ---help--- |
5 | Support for the SCSI RDMA Protocol over InfiniBand. This | 6 | Support for the SCSI RDMA Protocol over InfiniBand. This |
6 | allows you to access storage devices that speak SRP over | 7 | allows you to access storage devices that speak SRP over |
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index f01ca182f226..d8d056e004bb 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <scsi/scsi_device.h> | 47 | #include <scsi/scsi_device.h> |
48 | #include <scsi/scsi_dbg.h> | 48 | #include <scsi/scsi_dbg.h> |
49 | #include <scsi/srp.h> | 49 | #include <scsi/srp.h> |
50 | #include <scsi/scsi_transport_srp.h> | ||
50 | 51 | ||
51 | #include <rdma/ib_cache.h> | 52 | #include <rdma/ib_cache.h> |
52 | 53 | ||
@@ -90,6 +91,8 @@ static void srp_remove_one(struct ib_device *device); | |||
90 | static void srp_completion(struct ib_cq *cq, void *target_ptr); | 91 | static void srp_completion(struct ib_cq *cq, void *target_ptr); |
91 | static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event); | 92 | static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event); |
92 | 93 | ||
94 | static struct scsi_transport_template *ib_srp_transport_template; | ||
95 | |||
93 | static struct ib_client srp_client = { | 96 | static struct ib_client srp_client = { |
94 | .name = "srp", | 97 | .name = "srp", |
95 | .add = srp_add_one, | 98 | .add = srp_add_one, |
@@ -405,6 +408,7 @@ static void srp_remove_work(struct work_struct *work) | |||
405 | list_del(&target->list); | 408 | list_del(&target->list); |
406 | spin_unlock(&target->srp_host->target_lock); | 409 | spin_unlock(&target->srp_host->target_lock); |
407 | 410 | ||
411 | srp_remove_host(target->scsi_host); | ||
408 | scsi_remove_host(target->scsi_host); | 412 | scsi_remove_host(target->scsi_host); |
409 | ib_destroy_cm_id(target->cm_id); | 413 | ib_destroy_cm_id(target->cm_id); |
410 | srp_free_target_ib(target); | 414 | srp_free_target_ib(target); |
@@ -1530,12 +1534,23 @@ static struct scsi_host_template srp_template = { | |||
1530 | 1534 | ||
1531 | static int srp_add_target(struct srp_host *host, struct srp_target_port *target) | 1535 | static int srp_add_target(struct srp_host *host, struct srp_target_port *target) |
1532 | { | 1536 | { |
1537 | struct srp_rport_identifiers ids; | ||
1538 | struct srp_rport *rport; | ||
1539 | |||
1533 | sprintf(target->target_name, "SRP.T10:%016llX", | 1540 | sprintf(target->target_name, "SRP.T10:%016llX", |
1534 | (unsigned long long) be64_to_cpu(target->id_ext)); | 1541 | (unsigned long long) be64_to_cpu(target->id_ext)); |
1535 | 1542 | ||
1536 | if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device)) | 1543 | if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device)) |
1537 | return -ENODEV; | 1544 | return -ENODEV; |
1538 | 1545 | ||
1546 | memcpy(ids.port_id, &target->id_ext, 8); | ||
1547 | memcpy(ids.port_id + 8, &target->ioc_guid, 8); | ||
1548 | rport = srp_rport_add(target->scsi_host, &ids); | ||
1549 | if (IS_ERR(rport)) { | ||
1550 | scsi_remove_host(target->scsi_host); | ||
1551 | return PTR_ERR(rport); | ||
1552 | } | ||
1553 | |||
1539 | spin_lock(&host->target_lock); | 1554 | spin_lock(&host->target_lock); |
1540 | list_add_tail(&target->list, &host->target_list); | 1555 | list_add_tail(&target->list, &host->target_list); |
1541 | spin_unlock(&host->target_lock); | 1556 | spin_unlock(&host->target_lock); |
@@ -1760,6 +1775,7 @@ static ssize_t srp_create_target(struct class_device *class_dev, | |||
1760 | if (!target_host) | 1775 | if (!target_host) |
1761 | return -ENOMEM; | 1776 | return -ENOMEM; |
1762 | 1777 | ||
1778 | target_host->transportt = ib_srp_transport_template; | ||
1763 | target_host->max_lun = SRP_MAX_LUN; | 1779 | target_host->max_lun = SRP_MAX_LUN; |
1764 | target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb; | 1780 | target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb; |
1765 | 1781 | ||
@@ -2039,10 +2055,18 @@ static void srp_remove_one(struct ib_device *device) | |||
2039 | kfree(srp_dev); | 2055 | kfree(srp_dev); |
2040 | } | 2056 | } |
2041 | 2057 | ||
2058 | static struct srp_function_template ib_srp_transport_functions = { | ||
2059 | }; | ||
2060 | |||
2042 | static int __init srp_init_module(void) | 2061 | static int __init srp_init_module(void) |
2043 | { | 2062 | { |
2044 | int ret; | 2063 | int ret; |
2045 | 2064 | ||
2065 | ib_srp_transport_template = | ||
2066 | srp_attach_transport(&ib_srp_transport_functions); | ||
2067 | if (!ib_srp_transport_template) | ||
2068 | return -ENOMEM; | ||
2069 | |||
2046 | srp_template.sg_tablesize = srp_sg_tablesize; | 2070 | srp_template.sg_tablesize = srp_sg_tablesize; |
2047 | srp_max_iu_len = (sizeof (struct srp_cmd) + | 2071 | srp_max_iu_len = (sizeof (struct srp_cmd) + |
2048 | sizeof (struct srp_indirect_buf) + | 2072 | sizeof (struct srp_indirect_buf) + |
@@ -2051,6 +2075,7 @@ static int __init srp_init_module(void) | |||
2051 | ret = class_register(&srp_class); | 2075 | ret = class_register(&srp_class); |
2052 | if (ret) { | 2076 | if (ret) { |
2053 | printk(KERN_ERR PFX "couldn't register class infiniband_srp\n"); | 2077 | printk(KERN_ERR PFX "couldn't register class infiniband_srp\n"); |
2078 | srp_release_transport(ib_srp_transport_template); | ||
2054 | return ret; | 2079 | return ret; |
2055 | } | 2080 | } |
2056 | 2081 | ||
@@ -2059,6 +2084,7 @@ static int __init srp_init_module(void) | |||
2059 | ret = ib_register_client(&srp_client); | 2084 | ret = ib_register_client(&srp_client); |
2060 | if (ret) { | 2085 | if (ret) { |
2061 | printk(KERN_ERR PFX "couldn't register IB client\n"); | 2086 | printk(KERN_ERR PFX "couldn't register IB client\n"); |
2087 | srp_release_transport(ib_srp_transport_template); | ||
2062 | ib_sa_unregister_client(&srp_sa_client); | 2088 | ib_sa_unregister_client(&srp_sa_client); |
2063 | class_unregister(&srp_class); | 2089 | class_unregister(&srp_class); |
2064 | return ret; | 2090 | return ret; |
@@ -2072,6 +2098,7 @@ static void __exit srp_cleanup_module(void) | |||
2072 | ib_unregister_client(&srp_client); | 2098 | ib_unregister_client(&srp_client); |
2073 | ib_sa_unregister_client(&srp_sa_client); | 2099 | ib_sa_unregister_client(&srp_sa_client); |
2074 | class_unregister(&srp_class); | 2100 | class_unregister(&srp_class); |
2101 | srp_release_transport(ib_srp_transport_template); | ||
2075 | } | 2102 | } |
2076 | 2103 | ||
2077 | module_init(srp_init_module); | 2104 | module_init(srp_init_module); |