diff options
Diffstat (limited to 'drivers/infiniband/ulp')
-rw-r--r-- | drivers/infiniband/ulp/iser/iser_initiator.c | 2 | ||||
-rw-r--r-- | drivers/infiniband/ulp/srp/ib_srp.c | 118 |
2 files changed, 61 insertions, 59 deletions
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c index 0b9ef0716588..95a08a8ca8aa 100644 --- a/drivers/infiniband/ulp/iser/iser_initiator.c +++ b/drivers/infiniband/ulp/iser/iser_initiator.c | |||
@@ -170,7 +170,7 @@ static void iser_create_send_desc(struct iser_conn *ib_conn, | |||
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | int iser_alloc_rx_descriptors(struct iser_conn *ib_conn) | 173 | static int iser_alloc_rx_descriptors(struct iser_conn *ib_conn) |
174 | { | 174 | { |
175 | int i, j; | 175 | int i, j; |
176 | u64 dma_addr; | 176 | u64 dma_addr; |
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index ed3f9ebae882..7f8f16bad753 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
@@ -811,6 +811,38 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target, | |||
811 | return len; | 811 | return len; |
812 | } | 812 | } |
813 | 813 | ||
814 | static int srp_post_recv(struct srp_target_port *target) | ||
815 | { | ||
816 | unsigned long flags; | ||
817 | struct srp_iu *iu; | ||
818 | struct ib_sge list; | ||
819 | struct ib_recv_wr wr, *bad_wr; | ||
820 | unsigned int next; | ||
821 | int ret; | ||
822 | |||
823 | spin_lock_irqsave(target->scsi_host->host_lock, flags); | ||
824 | |||
825 | next = target->rx_head & (SRP_RQ_SIZE - 1); | ||
826 | wr.wr_id = next; | ||
827 | iu = target->rx_ring[next]; | ||
828 | |||
829 | list.addr = iu->dma; | ||
830 | list.length = iu->size; | ||
831 | list.lkey = target->srp_host->srp_dev->mr->lkey; | ||
832 | |||
833 | wr.next = NULL; | ||
834 | wr.sg_list = &list; | ||
835 | wr.num_sge = 1; | ||
836 | |||
837 | ret = ib_post_recv(target->qp, &wr, &bad_wr); | ||
838 | if (!ret) | ||
839 | ++target->rx_head; | ||
840 | |||
841 | spin_unlock_irqrestore(target->scsi_host->host_lock, flags); | ||
842 | |||
843 | return ret; | ||
844 | } | ||
845 | |||
814 | static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp) | 846 | static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp) |
815 | { | 847 | { |
816 | struct srp_request *req; | 848 | struct srp_request *req; |
@@ -868,6 +900,7 @@ static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc) | |||
868 | { | 900 | { |
869 | struct ib_device *dev; | 901 | struct ib_device *dev; |
870 | struct srp_iu *iu; | 902 | struct srp_iu *iu; |
903 | int res; | ||
871 | u8 opcode; | 904 | u8 opcode; |
872 | 905 | ||
873 | iu = target->rx_ring[wc->wr_id]; | 906 | iu = target->rx_ring[wc->wr_id]; |
@@ -879,21 +912,10 @@ static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc) | |||
879 | opcode = *(u8 *) iu->buf; | 912 | opcode = *(u8 *) iu->buf; |
880 | 913 | ||
881 | if (0) { | 914 | if (0) { |
882 | int i; | ||
883 | |||
884 | shost_printk(KERN_ERR, target->scsi_host, | 915 | shost_printk(KERN_ERR, target->scsi_host, |
885 | PFX "recv completion, opcode 0x%02x\n", opcode); | 916 | PFX "recv completion, opcode 0x%02x\n", opcode); |
886 | 917 | print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 8, 1, | |
887 | for (i = 0; i < wc->byte_len; ++i) { | 918 | iu->buf, wc->byte_len, true); |
888 | if (i % 8 == 0) | ||
889 | printk(KERN_ERR " [%02x] ", i); | ||
890 | printk(" %02x", ((u8 *) iu->buf)[i]); | ||
891 | if ((i + 1) % 8 == 0) | ||
892 | printk("\n"); | ||
893 | } | ||
894 | |||
895 | if (wc->byte_len % 8) | ||
896 | printk("\n"); | ||
897 | } | 919 | } |
898 | 920 | ||
899 | switch (opcode) { | 921 | switch (opcode) { |
@@ -915,6 +937,11 @@ static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc) | |||
915 | 937 | ||
916 | ib_dma_sync_single_for_device(dev, iu->dma, target->max_ti_iu_len, | 938 | ib_dma_sync_single_for_device(dev, iu->dma, target->max_ti_iu_len, |
917 | DMA_FROM_DEVICE); | 939 | DMA_FROM_DEVICE); |
940 | |||
941 | res = srp_post_recv(target); | ||
942 | if (res != 0) | ||
943 | shost_printk(KERN_ERR, target->scsi_host, | ||
944 | PFX "Recv failed with error code %d\n", res); | ||
918 | } | 945 | } |
919 | 946 | ||
920 | static void srp_recv_completion(struct ib_cq *cq, void *target_ptr) | 947 | static void srp_recv_completion(struct ib_cq *cq, void *target_ptr) |
@@ -954,45 +981,6 @@ static void srp_send_completion(struct ib_cq *cq, void *target_ptr) | |||
954 | } | 981 | } |
955 | } | 982 | } |
956 | 983 | ||
957 | static int __srp_post_recv(struct srp_target_port *target) | ||
958 | { | ||
959 | struct srp_iu *iu; | ||
960 | struct ib_sge list; | ||
961 | struct ib_recv_wr wr, *bad_wr; | ||
962 | unsigned int next; | ||
963 | int ret; | ||
964 | |||
965 | next = target->rx_head & (SRP_RQ_SIZE - 1); | ||
966 | wr.wr_id = next; | ||
967 | iu = target->rx_ring[next]; | ||
968 | |||
969 | list.addr = iu->dma; | ||
970 | list.length = iu->size; | ||
971 | list.lkey = target->srp_host->srp_dev->mr->lkey; | ||
972 | |||
973 | wr.next = NULL; | ||
974 | wr.sg_list = &list; | ||
975 | wr.num_sge = 1; | ||
976 | |||
977 | ret = ib_post_recv(target->qp, &wr, &bad_wr); | ||
978 | if (!ret) | ||
979 | ++target->rx_head; | ||
980 | |||
981 | return ret; | ||
982 | } | ||
983 | |||
984 | static int srp_post_recv(struct srp_target_port *target) | ||
985 | { | ||
986 | unsigned long flags; | ||
987 | int ret; | ||
988 | |||
989 | spin_lock_irqsave(target->scsi_host->host_lock, flags); | ||
990 | ret = __srp_post_recv(target); | ||
991 | spin_unlock_irqrestore(target->scsi_host->host_lock, flags); | ||
992 | |||
993 | return ret; | ||
994 | } | ||
995 | |||
996 | /* | 984 | /* |
997 | * Must be called with target->scsi_host->host_lock held to protect | 985 | * Must be called with target->scsi_host->host_lock held to protect |
998 | * req_lim and tx_head. Lock cannot be dropped between call here and | 986 | * req_lim and tx_head. Lock cannot be dropped between call here and |
@@ -1102,11 +1090,6 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd, | |||
1102 | goto err; | 1090 | goto err; |
1103 | } | 1091 | } |
1104 | 1092 | ||
1105 | if (__srp_post_recv(target)) { | ||
1106 | shost_printk(KERN_ERR, target->scsi_host, PFX "Recv failed\n"); | ||
1107 | goto err_unmap; | ||
1108 | } | ||
1109 | |||
1110 | ib_dma_sync_single_for_device(dev, iu->dma, srp_max_iu_len, | 1093 | ib_dma_sync_single_for_device(dev, iu->dma, srp_max_iu_len, |
1111 | DMA_TO_DEVICE); | 1094 | DMA_TO_DEVICE); |
1112 | 1095 | ||
@@ -1249,6 +1232,7 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) | |||
1249 | int attr_mask = 0; | 1232 | int attr_mask = 0; |
1250 | int comp = 0; | 1233 | int comp = 0; |
1251 | int opcode = 0; | 1234 | int opcode = 0; |
1235 | int i; | ||
1252 | 1236 | ||
1253 | switch (event->event) { | 1237 | switch (event->event) { |
1254 | case IB_CM_REQ_ERROR: | 1238 | case IB_CM_REQ_ERROR: |
@@ -1298,7 +1282,11 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) | |||
1298 | if (target->status) | 1282 | if (target->status) |
1299 | break; | 1283 | break; |
1300 | 1284 | ||
1301 | target->status = srp_post_recv(target); | 1285 | for (i = 0; i < SRP_RQ_SIZE; i++) { |
1286 | target->status = srp_post_recv(target); | ||
1287 | if (target->status) | ||
1288 | break; | ||
1289 | } | ||
1302 | if (target->status) | 1290 | if (target->status) |
1303 | break; | 1291 | break; |
1304 | 1292 | ||
@@ -1564,6 +1552,18 @@ static ssize_t show_orig_dgid(struct device *dev, | |||
1564 | return sprintf(buf, "%pI6\n", target->orig_dgid); | 1552 | return sprintf(buf, "%pI6\n", target->orig_dgid); |
1565 | } | 1553 | } |
1566 | 1554 | ||
1555 | static ssize_t show_req_lim(struct device *dev, | ||
1556 | struct device_attribute *attr, char *buf) | ||
1557 | { | ||
1558 | struct srp_target_port *target = host_to_target(class_to_shost(dev)); | ||
1559 | |||
1560 | if (target->state == SRP_TARGET_DEAD || | ||
1561 | target->state == SRP_TARGET_REMOVED) | ||
1562 | return -ENODEV; | ||
1563 | |||
1564 | return sprintf(buf, "%d\n", target->req_lim); | ||
1565 | } | ||
1566 | |||
1567 | static ssize_t show_zero_req_lim(struct device *dev, | 1567 | static ssize_t show_zero_req_lim(struct device *dev, |
1568 | struct device_attribute *attr, char *buf) | 1568 | struct device_attribute *attr, char *buf) |
1569 | { | 1569 | { |
@@ -1598,6 +1598,7 @@ static DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL); | |||
1598 | static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); | 1598 | static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); |
1599 | static DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL); | 1599 | static DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL); |
1600 | static DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL); | 1600 | static DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL); |
1601 | static DEVICE_ATTR(req_lim, S_IRUGO, show_req_lim, NULL); | ||
1601 | static DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL); | 1602 | static DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL); |
1602 | static DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL); | 1603 | static DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL); |
1603 | static DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL); | 1604 | static DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL); |
@@ -1609,6 +1610,7 @@ static struct device_attribute *srp_host_attrs[] = { | |||
1609 | &dev_attr_pkey, | 1610 | &dev_attr_pkey, |
1610 | &dev_attr_dgid, | 1611 | &dev_attr_dgid, |
1611 | &dev_attr_orig_dgid, | 1612 | &dev_attr_orig_dgid, |
1613 | &dev_attr_req_lim, | ||
1612 | &dev_attr_zero_req_lim, | 1614 | &dev_attr_zero_req_lim, |
1613 | &dev_attr_local_ib_port, | 1615 | &dev_attr_local_ib_port, |
1614 | &dev_attr_local_ib_device, | 1616 | &dev_attr_local_ib_device, |