diff options
-rw-r--r-- | drivers/infiniband/ulp/srp/ib_srp.c | 49 | ||||
-rw-r--r-- | drivers/infiniband/ulp/srp/ib_srp.h | 2 |
2 files changed, 27 insertions, 24 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 125765aa9d59..99a110660040 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
@@ -139,8 +139,9 @@ static struct srp_iu *srp_alloc_iu(struct srp_host *host, size_t size, | |||
139 | if (!iu->buf) | 139 | if (!iu->buf) |
140 | goto out_free_iu; | 140 | goto out_free_iu; |
141 | 141 | ||
142 | iu->dma = ib_dma_map_single(host->dev->dev, iu->buf, size, direction); | 142 | iu->dma = ib_dma_map_single(host->srp_dev->dev, iu->buf, size, |
143 | if (ib_dma_mapping_error(host->dev->dev, iu->dma)) | 143 | direction); |
144 | if (ib_dma_mapping_error(host->srp_dev->dev, iu->dma)) | ||
144 | goto out_free_buf; | 145 | goto out_free_buf; |
145 | 146 | ||
146 | iu->size = size; | 147 | iu->size = size; |
@@ -161,7 +162,8 @@ static void srp_free_iu(struct srp_host *host, struct srp_iu *iu) | |||
161 | if (!iu) | 162 | if (!iu) |
162 | return; | 163 | return; |
163 | 164 | ||
164 | ib_dma_unmap_single(host->dev->dev, iu->dma, iu->size, iu->direction); | 165 | ib_dma_unmap_single(host->srp_dev->dev, iu->dma, iu->size, |
166 | iu->direction); | ||
165 | kfree(iu->buf); | 167 | kfree(iu->buf); |
166 | kfree(iu); | 168 | kfree(iu); |
167 | } | 169 | } |
@@ -181,7 +183,7 @@ static int srp_init_qp(struct srp_target_port *target, | |||
181 | if (!attr) | 183 | if (!attr) |
182 | return -ENOMEM; | 184 | return -ENOMEM; |
183 | 185 | ||
184 | ret = ib_find_cached_pkey(target->srp_host->dev->dev, | 186 | ret = ib_find_cached_pkey(target->srp_host->srp_dev->dev, |
185 | target->srp_host->port, | 187 | target->srp_host->port, |
186 | be16_to_cpu(target->path.pkey), | 188 | be16_to_cpu(target->path.pkey), |
187 | &attr->pkey_index); | 189 | &attr->pkey_index); |
@@ -208,7 +210,7 @@ static int srp_new_cm_id(struct srp_target_port *target) | |||
208 | { | 210 | { |
209 | struct ib_cm_id *new_cm_id; | 211 | struct ib_cm_id *new_cm_id; |
210 | 212 | ||
211 | new_cm_id = ib_create_cm_id(target->srp_host->dev->dev, | 213 | new_cm_id = ib_create_cm_id(target->srp_host->srp_dev->dev, |
212 | srp_cm_handler, target); | 214 | srp_cm_handler, target); |
213 | if (IS_ERR(new_cm_id)) | 215 | if (IS_ERR(new_cm_id)) |
214 | return PTR_ERR(new_cm_id); | 216 | return PTR_ERR(new_cm_id); |
@@ -229,8 +231,8 @@ static int srp_create_target_ib(struct srp_target_port *target) | |||
229 | if (!init_attr) | 231 | if (!init_attr) |
230 | return -ENOMEM; | 232 | return -ENOMEM; |
231 | 233 | ||
232 | target->cq = ib_create_cq(target->srp_host->dev->dev, srp_completion, | 234 | target->cq = ib_create_cq(target->srp_host->srp_dev->dev, |
233 | NULL, target, SRP_CQ_SIZE, 0); | 235 | srp_completion, NULL, target, SRP_CQ_SIZE, 0); |
234 | if (IS_ERR(target->cq)) { | 236 | if (IS_ERR(target->cq)) { |
235 | ret = PTR_ERR(target->cq); | 237 | ret = PTR_ERR(target->cq); |
236 | goto out; | 238 | goto out; |
@@ -248,7 +250,7 @@ static int srp_create_target_ib(struct srp_target_port *target) | |||
248 | init_attr->send_cq = target->cq; | 250 | init_attr->send_cq = target->cq; |
249 | init_attr->recv_cq = target->cq; | 251 | init_attr->recv_cq = target->cq; |
250 | 252 | ||
251 | target->qp = ib_create_qp(target->srp_host->dev->pd, init_attr); | 253 | target->qp = ib_create_qp(target->srp_host->srp_dev->pd, init_attr); |
252 | if (IS_ERR(target->qp)) { | 254 | if (IS_ERR(target->qp)) { |
253 | ret = PTR_ERR(target->qp); | 255 | ret = PTR_ERR(target->qp); |
254 | ib_destroy_cq(target->cq); | 256 | ib_destroy_cq(target->cq); |
@@ -302,7 +304,7 @@ static int srp_lookup_path(struct srp_target_port *target) | |||
302 | init_completion(&target->done); | 304 | init_completion(&target->done); |
303 | 305 | ||
304 | target->path_query_id = ib_sa_path_rec_get(&srp_sa_client, | 306 | target->path_query_id = ib_sa_path_rec_get(&srp_sa_client, |
305 | target->srp_host->dev->dev, | 307 | target->srp_host->srp_dev->dev, |
306 | target->srp_host->port, | 308 | target->srp_host->port, |
307 | &target->path, | 309 | &target->path, |
308 | IB_SA_PATH_REC_SERVICE_ID | | 310 | IB_SA_PATH_REC_SERVICE_ID | |
@@ -403,7 +405,7 @@ static int srp_send_req(struct srp_target_port *target) | |||
403 | (unsigned long long) be64_to_cpu(target->ioc_guid)); | 405 | (unsigned long long) be64_to_cpu(target->ioc_guid)); |
404 | memset(req->priv.initiator_port_id, 0, 8); | 406 | memset(req->priv.initiator_port_id, 0, 8); |
405 | memcpy(req->priv.initiator_port_id + 8, | 407 | memcpy(req->priv.initiator_port_id + 8, |
406 | &target->srp_host->dev->dev->node_guid, 8); | 408 | &target->srp_host->srp_dev->dev->node_guid, 8); |
407 | } | 409 | } |
408 | 410 | ||
409 | status = ib_send_cm_req(target->cm_id, &req->param); | 411 | status = ib_send_cm_req(target->cm_id, &req->param); |
@@ -520,7 +522,7 @@ static void srp_unmap_data(struct scsi_cmnd *scmnd, | |||
520 | req->fmr = NULL; | 522 | req->fmr = NULL; |
521 | } | 523 | } |
522 | 524 | ||
523 | ib_dma_unmap_sg(target->srp_host->dev->dev, scsi_sglist(scmnd), | 525 | ib_dma_unmap_sg(target->srp_host->srp_dev->dev, scsi_sglist(scmnd), |
524 | scsi_sg_count(scmnd), scmnd->sc_data_direction); | 526 | scsi_sg_count(scmnd), scmnd->sc_data_direction); |
525 | } | 527 | } |
526 | 528 | ||
@@ -628,7 +630,7 @@ static int srp_map_fmr(struct srp_target_port *target, struct scatterlist *scat, | |||
628 | int page_cnt; | 630 | int page_cnt; |
629 | int i, j; | 631 | int i, j; |
630 | int ret; | 632 | int ret; |
631 | struct srp_device *dev = target->srp_host->dev; | 633 | struct srp_device *dev = target->srp_host->srp_dev; |
632 | struct ib_device *ibdev = dev->dev; | 634 | struct ib_device *ibdev = dev->dev; |
633 | struct scatterlist *sg; | 635 | struct scatterlist *sg; |
634 | 636 | ||
@@ -723,7 +725,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target, | |||
723 | nents = scsi_sg_count(scmnd); | 725 | nents = scsi_sg_count(scmnd); |
724 | scat = scsi_sglist(scmnd); | 726 | scat = scsi_sglist(scmnd); |
725 | 727 | ||
726 | dev = target->srp_host->dev; | 728 | dev = target->srp_host->srp_dev; |
727 | ibdev = dev->dev; | 729 | ibdev = dev->dev; |
728 | 730 | ||
729 | count = ib_dma_map_sg(ibdev, scat, nents, scmnd->sc_data_direction); | 731 | count = ib_dma_map_sg(ibdev, scat, nents, scmnd->sc_data_direction); |
@@ -779,7 +781,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target, | |||
779 | buf->table_desc.va = | 781 | buf->table_desc.va = |
780 | cpu_to_be64(req->cmd->dma + sizeof *cmd + sizeof *buf); | 782 | cpu_to_be64(req->cmd->dma + sizeof *cmd + sizeof *buf); |
781 | buf->table_desc.key = | 783 | buf->table_desc.key = |
782 | cpu_to_be32(target->srp_host->dev->mr->rkey); | 784 | cpu_to_be32(target->srp_host->srp_dev->mr->rkey); |
783 | buf->table_desc.len = | 785 | buf->table_desc.len = |
784 | cpu_to_be32(count * sizeof (struct srp_direct_buf)); | 786 | cpu_to_be32(count * sizeof (struct srp_direct_buf)); |
785 | 787 | ||
@@ -855,7 +857,7 @@ static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc) | |||
855 | 857 | ||
856 | iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV]; | 858 | iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV]; |
857 | 859 | ||
858 | dev = target->srp_host->dev->dev; | 860 | dev = target->srp_host->srp_dev->dev; |
859 | ib_dma_sync_single_for_cpu(dev, iu->dma, target->max_ti_iu_len, | 861 | ib_dma_sync_single_for_cpu(dev, iu->dma, target->max_ti_iu_len, |
860 | DMA_FROM_DEVICE); | 862 | DMA_FROM_DEVICE); |
861 | 863 | ||
@@ -937,7 +939,7 @@ static int __srp_post_recv(struct srp_target_port *target) | |||
937 | 939 | ||
938 | list.addr = iu->dma; | 940 | list.addr = iu->dma; |
939 | list.length = iu->size; | 941 | list.length = iu->size; |
940 | list.lkey = target->srp_host->dev->mr->lkey; | 942 | list.lkey = target->srp_host->srp_dev->mr->lkey; |
941 | 943 | ||
942 | wr.next = NULL; | 944 | wr.next = NULL; |
943 | wr.sg_list = &list; | 945 | wr.sg_list = &list; |
@@ -996,7 +998,7 @@ static int __srp_post_send(struct srp_target_port *target, | |||
996 | 998 | ||
997 | list.addr = iu->dma; | 999 | list.addr = iu->dma; |
998 | list.length = len; | 1000 | list.length = len; |
999 | list.lkey = target->srp_host->dev->mr->lkey; | 1001 | list.lkey = target->srp_host->srp_dev->mr->lkey; |
1000 | 1002 | ||
1001 | wr.next = NULL; | 1003 | wr.next = NULL; |
1002 | wr.wr_id = target->tx_head & SRP_SQ_SIZE; | 1004 | wr.wr_id = target->tx_head & SRP_SQ_SIZE; |
@@ -1039,7 +1041,7 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd, | |||
1039 | if (!iu) | 1041 | if (!iu) |
1040 | goto err; | 1042 | goto err; |
1041 | 1043 | ||
1042 | dev = target->srp_host->dev->dev; | 1044 | dev = target->srp_host->srp_dev->dev; |
1043 | ib_dma_sync_single_for_cpu(dev, iu->dma, srp_max_iu_len, | 1045 | ib_dma_sync_single_for_cpu(dev, iu->dma, srp_max_iu_len, |
1044 | DMA_TO_DEVICE); | 1046 | DMA_TO_DEVICE); |
1045 | 1047 | ||
@@ -1563,7 +1565,7 @@ static ssize_t show_local_ib_device(struct class_device *cdev, char *buf) | |||
1563 | { | 1565 | { |
1564 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1566 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); |
1565 | 1567 | ||
1566 | return sprintf(buf, "%s\n", target->srp_host->dev->dev->name); | 1568 | return sprintf(buf, "%s\n", target->srp_host->srp_dev->dev->name); |
1567 | } | 1569 | } |
1568 | 1570 | ||
1569 | static CLASS_DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL); | 1571 | static CLASS_DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL); |
@@ -1613,7 +1615,7 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target) | |||
1613 | sprintf(target->target_name, "SRP.T10:%016llX", | 1615 | sprintf(target->target_name, "SRP.T10:%016llX", |
1614 | (unsigned long long) be64_to_cpu(target->id_ext)); | 1616 | (unsigned long long) be64_to_cpu(target->id_ext)); |
1615 | 1617 | ||
1616 | if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device)) | 1618 | if (scsi_add_host(target->scsi_host, host->srp_dev->dev->dma_device)) |
1617 | return -ENODEV; | 1619 | return -ENODEV; |
1618 | 1620 | ||
1619 | memcpy(ids.port_id, &target->id_ext, 8); | 1621 | memcpy(ids.port_id, &target->id_ext, 8); |
@@ -1871,7 +1873,8 @@ static ssize_t srp_create_target(struct class_device *class_dev, | |||
1871 | if (ret) | 1873 | if (ret) |
1872 | goto err; | 1874 | goto err; |
1873 | 1875 | ||
1874 | ib_get_cached_gid(host->dev->dev, host->port, 0, &target->path.sgid); | 1876 | ib_get_cached_gid(host->srp_dev->dev, host->port, 0, |
1877 | &target->path.sgid); | ||
1875 | 1878 | ||
1876 | shost_printk(KERN_DEBUG, target->scsi_host, PFX | 1879 | shost_printk(KERN_DEBUG, target->scsi_host, PFX |
1877 | "new target: id_ext %016llx ioc_guid %016llx pkey %04x " | 1880 | "new target: id_ext %016llx ioc_guid %016llx pkey %04x " |
@@ -1933,7 +1936,7 @@ static ssize_t show_ibdev(struct class_device *class_dev, char *buf) | |||
1933 | struct srp_host *host = | 1936 | struct srp_host *host = |
1934 | container_of(class_dev, struct srp_host, class_dev); | 1937 | container_of(class_dev, struct srp_host, class_dev); |
1935 | 1938 | ||
1936 | return sprintf(buf, "%s\n", host->dev->dev->name); | 1939 | return sprintf(buf, "%s\n", host->srp_dev->dev->name); |
1937 | } | 1940 | } |
1938 | 1941 | ||
1939 | static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); | 1942 | static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); |
@@ -1959,7 +1962,7 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port) | |||
1959 | INIT_LIST_HEAD(&host->target_list); | 1962 | INIT_LIST_HEAD(&host->target_list); |
1960 | spin_lock_init(&host->target_lock); | 1963 | spin_lock_init(&host->target_lock); |
1961 | init_completion(&host->released); | 1964 | init_completion(&host->released); |
1962 | host->dev = device; | 1965 | host->srp_dev = device; |
1963 | host->port = port; | 1966 | host->port = port; |
1964 | 1967 | ||
1965 | host->class_dev.class = &srp_class; | 1968 | host->class_dev.class = &srp_class; |
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h index cb6eb816024a..67e17c336a50 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.h +++ b/drivers/infiniband/ulp/srp/ib_srp.h | |||
@@ -97,7 +97,7 @@ struct srp_device { | |||
97 | }; | 97 | }; |
98 | 98 | ||
99 | struct srp_host { | 99 | struct srp_host { |
100 | struct srp_device *dev; | 100 | struct srp_device *srp_dev; |
101 | u8 port; | 101 | u8 port; |
102 | struct class_device class_dev; | 102 | struct class_device class_dev; |
103 | struct list_head target_list; | 103 | struct list_head target_list; |