diff options
Diffstat (limited to 'drivers/infiniband/ulp/srp/ib_srp.c')
-rw-r--r-- | drivers/infiniband/ulp/srp/ib_srp.c | 181 |
1 files changed, 97 insertions, 84 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 125765aa9d59..435145709dd6 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 | ||
@@ -1456,9 +1458,10 @@ static int srp_reset_host(struct scsi_cmnd *scmnd) | |||
1456 | return ret; | 1458 | return ret; |
1457 | } | 1459 | } |
1458 | 1460 | ||
1459 | static ssize_t show_id_ext(struct class_device *cdev, char *buf) | 1461 | static ssize_t show_id_ext(struct device *dev, struct device_attribute *attr, |
1462 | char *buf) | ||
1460 | { | 1463 | { |
1461 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1464 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1462 | 1465 | ||
1463 | if (target->state == SRP_TARGET_DEAD || | 1466 | if (target->state == SRP_TARGET_DEAD || |
1464 | target->state == SRP_TARGET_REMOVED) | 1467 | target->state == SRP_TARGET_REMOVED) |
@@ -1468,9 +1471,10 @@ static ssize_t show_id_ext(struct class_device *cdev, char *buf) | |||
1468 | (unsigned long long) be64_to_cpu(target->id_ext)); | 1471 | (unsigned long long) be64_to_cpu(target->id_ext)); |
1469 | } | 1472 | } |
1470 | 1473 | ||
1471 | static ssize_t show_ioc_guid(struct class_device *cdev, char *buf) | 1474 | static ssize_t show_ioc_guid(struct device *dev, struct device_attribute *attr, |
1475 | char *buf) | ||
1472 | { | 1476 | { |
1473 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1477 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1474 | 1478 | ||
1475 | if (target->state == SRP_TARGET_DEAD || | 1479 | if (target->state == SRP_TARGET_DEAD || |
1476 | target->state == SRP_TARGET_REMOVED) | 1480 | target->state == SRP_TARGET_REMOVED) |
@@ -1480,9 +1484,10 @@ static ssize_t show_ioc_guid(struct class_device *cdev, char *buf) | |||
1480 | (unsigned long long) be64_to_cpu(target->ioc_guid)); | 1484 | (unsigned long long) be64_to_cpu(target->ioc_guid)); |
1481 | } | 1485 | } |
1482 | 1486 | ||
1483 | static ssize_t show_service_id(struct class_device *cdev, char *buf) | 1487 | static ssize_t show_service_id(struct device *dev, |
1488 | struct device_attribute *attr, char *buf) | ||
1484 | { | 1489 | { |
1485 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1490 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1486 | 1491 | ||
1487 | if (target->state == SRP_TARGET_DEAD || | 1492 | if (target->state == SRP_TARGET_DEAD || |
1488 | target->state == SRP_TARGET_REMOVED) | 1493 | target->state == SRP_TARGET_REMOVED) |
@@ -1492,9 +1497,10 @@ static ssize_t show_service_id(struct class_device *cdev, char *buf) | |||
1492 | (unsigned long long) be64_to_cpu(target->service_id)); | 1497 | (unsigned long long) be64_to_cpu(target->service_id)); |
1493 | } | 1498 | } |
1494 | 1499 | ||
1495 | static ssize_t show_pkey(struct class_device *cdev, char *buf) | 1500 | static ssize_t show_pkey(struct device *dev, struct device_attribute *attr, |
1501 | char *buf) | ||
1496 | { | 1502 | { |
1497 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1503 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1498 | 1504 | ||
1499 | if (target->state == SRP_TARGET_DEAD || | 1505 | if (target->state == SRP_TARGET_DEAD || |
1500 | target->state == SRP_TARGET_REMOVED) | 1506 | target->state == SRP_TARGET_REMOVED) |
@@ -1503,9 +1509,10 @@ static ssize_t show_pkey(struct class_device *cdev, char *buf) | |||
1503 | return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey)); | 1509 | return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey)); |
1504 | } | 1510 | } |
1505 | 1511 | ||
1506 | static ssize_t show_dgid(struct class_device *cdev, char *buf) | 1512 | static ssize_t show_dgid(struct device *dev, struct device_attribute *attr, |
1513 | char *buf) | ||
1507 | { | 1514 | { |
1508 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1515 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1509 | 1516 | ||
1510 | if (target->state == SRP_TARGET_DEAD || | 1517 | if (target->state == SRP_TARGET_DEAD || |
1511 | target->state == SRP_TARGET_REMOVED) | 1518 | target->state == SRP_TARGET_REMOVED) |
@@ -1522,9 +1529,10 @@ static ssize_t show_dgid(struct class_device *cdev, char *buf) | |||
1522 | be16_to_cpu(((__be16 *) target->path.dgid.raw)[7])); | 1529 | be16_to_cpu(((__be16 *) target->path.dgid.raw)[7])); |
1523 | } | 1530 | } |
1524 | 1531 | ||
1525 | static ssize_t show_orig_dgid(struct class_device *cdev, char *buf) | 1532 | static ssize_t show_orig_dgid(struct device *dev, |
1533 | struct device_attribute *attr, char *buf) | ||
1526 | { | 1534 | { |
1527 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1535 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1528 | 1536 | ||
1529 | if (target->state == SRP_TARGET_DEAD || | 1537 | if (target->state == SRP_TARGET_DEAD || |
1530 | target->state == SRP_TARGET_REMOVED) | 1538 | target->state == SRP_TARGET_REMOVED) |
@@ -1541,9 +1549,10 @@ static ssize_t show_orig_dgid(struct class_device *cdev, char *buf) | |||
1541 | be16_to_cpu(target->orig_dgid[7])); | 1549 | be16_to_cpu(target->orig_dgid[7])); |
1542 | } | 1550 | } |
1543 | 1551 | ||
1544 | static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf) | 1552 | static ssize_t show_zero_req_lim(struct device *dev, |
1553 | struct device_attribute *attr, char *buf) | ||
1545 | { | 1554 | { |
1546 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1555 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1547 | 1556 | ||
1548 | if (target->state == SRP_TARGET_DEAD || | 1557 | if (target->state == SRP_TARGET_DEAD || |
1549 | target->state == SRP_TARGET_REMOVED) | 1558 | target->state == SRP_TARGET_REMOVED) |
@@ -1552,40 +1561,42 @@ static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf) | |||
1552 | return sprintf(buf, "%d\n", target->zero_req_lim); | 1561 | return sprintf(buf, "%d\n", target->zero_req_lim); |
1553 | } | 1562 | } |
1554 | 1563 | ||
1555 | static ssize_t show_local_ib_port(struct class_device *cdev, char *buf) | 1564 | static ssize_t show_local_ib_port(struct device *dev, |
1565 | struct device_attribute *attr, char *buf) | ||
1556 | { | 1566 | { |
1557 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1567 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1558 | 1568 | ||
1559 | return sprintf(buf, "%d\n", target->srp_host->port); | 1569 | return sprintf(buf, "%d\n", target->srp_host->port); |
1560 | } | 1570 | } |
1561 | 1571 | ||
1562 | static ssize_t show_local_ib_device(struct class_device *cdev, char *buf) | 1572 | static ssize_t show_local_ib_device(struct device *dev, |
1573 | struct device_attribute *attr, char *buf) | ||
1563 | { | 1574 | { |
1564 | struct srp_target_port *target = host_to_target(class_to_shost(cdev)); | 1575 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); |
1565 | 1576 | ||
1566 | return sprintf(buf, "%s\n", target->srp_host->dev->dev->name); | 1577 | return sprintf(buf, "%s\n", target->srp_host->srp_dev->dev->name); |
1567 | } | 1578 | } |
1568 | 1579 | ||
1569 | static CLASS_DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL); | 1580 | static DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL); |
1570 | static CLASS_DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL); | 1581 | static DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL); |
1571 | static CLASS_DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL); | 1582 | static DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL); |
1572 | static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); | 1583 | static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); |
1573 | static CLASS_DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL); | 1584 | static DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL); |
1574 | static CLASS_DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL); | 1585 | static DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL); |
1575 | static CLASS_DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL); | 1586 | static DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL); |
1576 | static CLASS_DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL); | 1587 | static DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL); |
1577 | static CLASS_DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL); | 1588 | static DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL); |
1578 | 1589 | ||
1579 | static struct class_device_attribute *srp_host_attrs[] = { | 1590 | static struct device_attribute *srp_host_attrs[] = { |
1580 | &class_device_attr_id_ext, | 1591 | &dev_attr_id_ext, |
1581 | &class_device_attr_ioc_guid, | 1592 | &dev_attr_ioc_guid, |
1582 | &class_device_attr_service_id, | 1593 | &dev_attr_service_id, |
1583 | &class_device_attr_pkey, | 1594 | &dev_attr_pkey, |
1584 | &class_device_attr_dgid, | 1595 | &dev_attr_dgid, |
1585 | &class_device_attr_orig_dgid, | 1596 | &dev_attr_orig_dgid, |
1586 | &class_device_attr_zero_req_lim, | 1597 | &dev_attr_zero_req_lim, |
1587 | &class_device_attr_local_ib_port, | 1598 | &dev_attr_local_ib_port, |
1588 | &class_device_attr_local_ib_device, | 1599 | &dev_attr_local_ib_device, |
1589 | NULL | 1600 | NULL |
1590 | }; | 1601 | }; |
1591 | 1602 | ||
@@ -1613,7 +1624,7 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target) | |||
1613 | sprintf(target->target_name, "SRP.T10:%016llX", | 1624 | sprintf(target->target_name, "SRP.T10:%016llX", |
1614 | (unsigned long long) be64_to_cpu(target->id_ext)); | 1625 | (unsigned long long) be64_to_cpu(target->id_ext)); |
1615 | 1626 | ||
1616 | if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device)) | 1627 | if (scsi_add_host(target->scsi_host, host->srp_dev->dev->dma_device)) |
1617 | return -ENODEV; | 1628 | return -ENODEV; |
1618 | 1629 | ||
1619 | memcpy(ids.port_id, &target->id_ext, 8); | 1630 | memcpy(ids.port_id, &target->id_ext, 8); |
@@ -1637,17 +1648,17 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target) | |||
1637 | return 0; | 1648 | return 0; |
1638 | } | 1649 | } |
1639 | 1650 | ||
1640 | static void srp_release_class_dev(struct class_device *class_dev) | 1651 | static void srp_release_dev(struct device *dev) |
1641 | { | 1652 | { |
1642 | struct srp_host *host = | 1653 | struct srp_host *host = |
1643 | container_of(class_dev, struct srp_host, class_dev); | 1654 | container_of(dev, struct srp_host, dev); |
1644 | 1655 | ||
1645 | complete(&host->released); | 1656 | complete(&host->released); |
1646 | } | 1657 | } |
1647 | 1658 | ||
1648 | static struct class srp_class = { | 1659 | static struct class srp_class = { |
1649 | .name = "infiniband_srp", | 1660 | .name = "infiniband_srp", |
1650 | .release = srp_release_class_dev | 1661 | .dev_release = srp_release_dev |
1651 | }; | 1662 | }; |
1652 | 1663 | ||
1653 | /* | 1664 | /* |
@@ -1835,11 +1846,12 @@ out: | |||
1835 | return ret; | 1846 | return ret; |
1836 | } | 1847 | } |
1837 | 1848 | ||
1838 | static ssize_t srp_create_target(struct class_device *class_dev, | 1849 | static ssize_t srp_create_target(struct device *dev, |
1850 | struct device_attribute *attr, | ||
1839 | const char *buf, size_t count) | 1851 | const char *buf, size_t count) |
1840 | { | 1852 | { |
1841 | struct srp_host *host = | 1853 | struct srp_host *host = |
1842 | container_of(class_dev, struct srp_host, class_dev); | 1854 | container_of(dev, struct srp_host, dev); |
1843 | struct Scsi_Host *target_host; | 1855 | struct Scsi_Host *target_host; |
1844 | struct srp_target_port *target; | 1856 | struct srp_target_port *target; |
1845 | int ret; | 1857 | int ret; |
@@ -1871,7 +1883,8 @@ static ssize_t srp_create_target(struct class_device *class_dev, | |||
1871 | if (ret) | 1883 | if (ret) |
1872 | goto err; | 1884 | goto err; |
1873 | 1885 | ||
1874 | ib_get_cached_gid(host->dev->dev, host->port, 0, &target->path.sgid); | 1886 | ib_get_cached_gid(host->srp_dev->dev, host->port, 0, |
1887 | &target->path.sgid); | ||
1875 | 1888 | ||
1876 | shost_printk(KERN_DEBUG, target->scsi_host, PFX | 1889 | shost_printk(KERN_DEBUG, target->scsi_host, PFX |
1877 | "new target: id_ext %016llx ioc_guid %016llx pkey %04x " | 1890 | "new target: id_ext %016llx ioc_guid %016llx pkey %04x " |
@@ -1926,27 +1939,27 @@ err: | |||
1926 | return ret; | 1939 | return ret; |
1927 | } | 1940 | } |
1928 | 1941 | ||
1929 | static CLASS_DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target); | 1942 | static DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target); |
1930 | 1943 | ||
1931 | static ssize_t show_ibdev(struct class_device *class_dev, char *buf) | 1944 | static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr, |
1945 | char *buf) | ||
1932 | { | 1946 | { |
1933 | struct srp_host *host = | 1947 | struct srp_host *host = container_of(dev, struct srp_host, dev); |
1934 | container_of(class_dev, struct srp_host, class_dev); | ||
1935 | 1948 | ||
1936 | return sprintf(buf, "%s\n", host->dev->dev->name); | 1949 | return sprintf(buf, "%s\n", host->srp_dev->dev->name); |
1937 | } | 1950 | } |
1938 | 1951 | ||
1939 | static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); | 1952 | static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); |
1940 | 1953 | ||
1941 | static ssize_t show_port(struct class_device *class_dev, char *buf) | 1954 | static ssize_t show_port(struct device *dev, struct device_attribute *attr, |
1955 | char *buf) | ||
1942 | { | 1956 | { |
1943 | struct srp_host *host = | 1957 | struct srp_host *host = container_of(dev, struct srp_host, dev); |
1944 | container_of(class_dev, struct srp_host, class_dev); | ||
1945 | 1958 | ||
1946 | return sprintf(buf, "%d\n", host->port); | 1959 | return sprintf(buf, "%d\n", host->port); |
1947 | } | 1960 | } |
1948 | 1961 | ||
1949 | static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); | 1962 | static DEVICE_ATTR(port, S_IRUGO, show_port, NULL); |
1950 | 1963 | ||
1951 | static struct srp_host *srp_add_port(struct srp_device *device, u8 port) | 1964 | static struct srp_host *srp_add_port(struct srp_device *device, u8 port) |
1952 | { | 1965 | { |
@@ -1959,27 +1972,27 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port) | |||
1959 | INIT_LIST_HEAD(&host->target_list); | 1972 | INIT_LIST_HEAD(&host->target_list); |
1960 | spin_lock_init(&host->target_lock); | 1973 | spin_lock_init(&host->target_lock); |
1961 | init_completion(&host->released); | 1974 | init_completion(&host->released); |
1962 | host->dev = device; | 1975 | host->srp_dev = device; |
1963 | host->port = port; | 1976 | host->port = port; |
1964 | 1977 | ||
1965 | host->class_dev.class = &srp_class; | 1978 | host->dev.class = &srp_class; |
1966 | host->class_dev.dev = device->dev->dma_device; | 1979 | host->dev.parent = device->dev->dma_device; |
1967 | snprintf(host->class_dev.class_id, BUS_ID_SIZE, "srp-%s-%d", | 1980 | snprintf(host->dev.bus_id, BUS_ID_SIZE, "srp-%s-%d", |
1968 | device->dev->name, port); | 1981 | device->dev->name, port); |
1969 | 1982 | ||
1970 | if (class_device_register(&host->class_dev)) | 1983 | if (device_register(&host->dev)) |
1971 | goto free_host; | 1984 | goto free_host; |
1972 | if (class_device_create_file(&host->class_dev, &class_device_attr_add_target)) | 1985 | if (device_create_file(&host->dev, &dev_attr_add_target)) |
1973 | goto err_class; | 1986 | goto err_class; |
1974 | if (class_device_create_file(&host->class_dev, &class_device_attr_ibdev)) | 1987 | if (device_create_file(&host->dev, &dev_attr_ibdev)) |
1975 | goto err_class; | 1988 | goto err_class; |
1976 | if (class_device_create_file(&host->class_dev, &class_device_attr_port)) | 1989 | if (device_create_file(&host->dev, &dev_attr_port)) |
1977 | goto err_class; | 1990 | goto err_class; |
1978 | 1991 | ||
1979 | return host; | 1992 | return host; |
1980 | 1993 | ||
1981 | err_class: | 1994 | err_class: |
1982 | class_device_unregister(&host->class_dev); | 1995 | device_unregister(&host->dev); |
1983 | 1996 | ||
1984 | free_host: | 1997 | free_host: |
1985 | kfree(host); | 1998 | kfree(host); |
@@ -2084,7 +2097,7 @@ static void srp_remove_one(struct ib_device *device) | |||
2084 | srp_dev = ib_get_client_data(device, &srp_client); | 2097 | srp_dev = ib_get_client_data(device, &srp_client); |
2085 | 2098 | ||
2086 | list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { | 2099 | list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { |
2087 | class_device_unregister(&host->class_dev); | 2100 | device_unregister(&host->dev); |
2088 | /* | 2101 | /* |
2089 | * Wait for the sysfs entry to go away, so that no new | 2102 | * Wait for the sysfs entry to go away, so that no new |
2090 | * target ports can be created. | 2103 | * target ports can be created. |