aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2016-02-24 12:24:05 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2016-03-11 00:48:44 -0500
commit5adabdd122e471fe978d49471624bab08b5373a7 (patch)
tree83ae3d0ff9c3263ad1c347419800397d7ed5ccff
parented1083b251f0ed992e90739994c31cffa597abfa (diff)
iser-target: Split and properly type the login buffer
The login receive buffer is used as a iser_rx_desc, so type it as such in struct isert_conn and allocate the exactly right space for it. The TX buffer is moved to a separate variable and properly sized as well. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/infiniband/ulp/isert/ib_isert.c56
-rw-r--r--drivers/infiniband/ulp/isert/ib_isert.h3
2 files changed, 29 insertions, 30 deletions
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 838d16ded772..ac3e80c55965 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -597,10 +597,12 @@ isert_free_login_buf(struct isert_conn *isert_conn)
597 597
598 ib_dma_unmap_single(ib_dev, isert_conn->login_rsp_dma, 598 ib_dma_unmap_single(ib_dev, isert_conn->login_rsp_dma,
599 ISER_RX_PAYLOAD_SIZE, DMA_TO_DEVICE); 599 ISER_RX_PAYLOAD_SIZE, DMA_TO_DEVICE);
600 kfree(isert_conn->login_rsp_buf);
601
600 ib_dma_unmap_single(ib_dev, isert_conn->login_req_dma, 602 ib_dma_unmap_single(ib_dev, isert_conn->login_req_dma,
601 ISCSI_DEF_MAX_RECV_SEG_LEN, 603 ISER_RX_PAYLOAD_SIZE,
602 DMA_FROM_DEVICE); 604 DMA_FROM_DEVICE);
603 kfree(isert_conn->login_buf); 605 kfree(isert_conn->login_req_buf);
604} 606}
605 607
606static int 608static int
@@ -609,50 +611,48 @@ isert_alloc_login_buf(struct isert_conn *isert_conn,
609{ 611{
610 int ret; 612 int ret;
611 613
612 isert_conn->login_buf = kzalloc(ISCSI_DEF_MAX_RECV_SEG_LEN + 614 isert_conn->login_req_buf = kzalloc(sizeof(*isert_conn->login_req_buf),
613 ISER_RX_PAYLOAD_SIZE, GFP_KERNEL); 615 GFP_KERNEL);
614 if (!isert_conn->login_buf) { 616 if (!isert_conn->login_req_buf) {
615 isert_err("Unable to allocate isert_conn->login_buf\n"); 617 isert_err("Unable to allocate isert_conn->login_buf\n");
616 return -ENOMEM; 618 return -ENOMEM;
617 } 619 }
618 620
619 isert_conn->login_req_buf = isert_conn->login_buf;
620 isert_conn->login_rsp_buf = isert_conn->login_buf +
621 ISCSI_DEF_MAX_RECV_SEG_LEN;
622
623 isert_dbg("Set login_buf: %p login_req_buf: %p login_rsp_buf: %p\n",
624 isert_conn->login_buf, isert_conn->login_req_buf,
625 isert_conn->login_rsp_buf);
626
627 isert_conn->login_req_dma = ib_dma_map_single(ib_dev, 621 isert_conn->login_req_dma = ib_dma_map_single(ib_dev,
628 (void *)isert_conn->login_req_buf, 622 isert_conn->login_req_buf,
629 ISCSI_DEF_MAX_RECV_SEG_LEN, DMA_FROM_DEVICE); 623 ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
630
631 ret = ib_dma_mapping_error(ib_dev, isert_conn->login_req_dma); 624 ret = ib_dma_mapping_error(ib_dev, isert_conn->login_req_dma);
632 if (ret) { 625 if (ret) {
633 isert_err("login_req_dma mapping error: %d\n", ret); 626 isert_err("login_req_dma mapping error: %d\n", ret);
634 isert_conn->login_req_dma = 0; 627 isert_conn->login_req_dma = 0;
635 goto out_login_buf; 628 goto out_free_login_req_buf;
629 }
630
631 isert_conn->login_rsp_buf = kzalloc(ISER_RX_PAYLOAD_SIZE, GFP_KERNEL);
632 if (!isert_conn->login_rsp_buf) {
633 isert_err("Unable to allocate isert_conn->login_rspbuf\n");
634 goto out_unmap_login_req_buf;
636 } 635 }
637 636
638 isert_conn->login_rsp_dma = ib_dma_map_single(ib_dev, 637 isert_conn->login_rsp_dma = ib_dma_map_single(ib_dev,
639 (void *)isert_conn->login_rsp_buf, 638 isert_conn->login_rsp_buf,
640 ISER_RX_PAYLOAD_SIZE, DMA_TO_DEVICE); 639 ISER_RX_PAYLOAD_SIZE, DMA_TO_DEVICE);
641
642 ret = ib_dma_mapping_error(ib_dev, isert_conn->login_rsp_dma); 640 ret = ib_dma_mapping_error(ib_dev, isert_conn->login_rsp_dma);
643 if (ret) { 641 if (ret) {
644 isert_err("login_rsp_dma mapping error: %d\n", ret); 642 isert_err("login_rsp_dma mapping error: %d\n", ret);
645 isert_conn->login_rsp_dma = 0; 643 isert_conn->login_rsp_dma = 0;
646 goto out_req_dma_map; 644 goto out_free_login_rsp_buf;
647 } 645 }
648 646
649 return 0; 647 return 0;
650 648
651out_req_dma_map: 649out_free_login_rsp_buf:
650 kfree(isert_conn->login_rsp_buf);
651out_unmap_login_req_buf:
652 ib_dma_unmap_single(ib_dev, isert_conn->login_req_dma, 652 ib_dma_unmap_single(ib_dev, isert_conn->login_req_dma,
653 ISCSI_DEF_MAX_RECV_SEG_LEN, DMA_FROM_DEVICE); 653 ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
654out_login_buf: 654out_free_login_req_buf:
655 kfree(isert_conn->login_buf); 655 kfree(isert_conn->login_req_buf);
656 return ret; 656 return ret;
657} 657}
658 658
@@ -773,7 +773,7 @@ isert_connect_release(struct isert_conn *isert_conn)
773 ib_destroy_qp(isert_conn->qp); 773 ib_destroy_qp(isert_conn->qp);
774 } 774 }
775 775
776 if (isert_conn->login_buf) 776 if (isert_conn->login_req_buf)
777 isert_free_login_buf(isert_conn); 777 isert_free_login_buf(isert_conn);
778 778
779 isert_device_put(device); 779 isert_device_put(device);
@@ -1216,7 +1216,7 @@ post_send:
1216static void 1216static void
1217isert_rx_login_req(struct isert_conn *isert_conn) 1217isert_rx_login_req(struct isert_conn *isert_conn)
1218{ 1218{
1219 struct iser_rx_desc *rx_desc = (void *)isert_conn->login_req_buf; 1219 struct iser_rx_desc *rx_desc = isert_conn->login_req_buf;
1220 int rx_buflen = isert_conn->login_req_len; 1220 int rx_buflen = isert_conn->login_req_len;
1221 struct iscsi_conn *conn = isert_conn->conn; 1221 struct iscsi_conn *conn = isert_conn->conn;
1222 struct iscsi_login *login = conn->conn_login; 1222 struct iscsi_login *login = conn->conn_login;
@@ -1594,7 +1594,7 @@ isert_rcv_completion(struct iser_rx_desc *desc,
1594 u64 rx_dma; 1594 u64 rx_dma;
1595 int rx_buflen; 1595 int rx_buflen;
1596 1596
1597 if ((char *)desc == isert_conn->login_req_buf) { 1597 if (desc == isert_conn->login_req_buf) {
1598 rx_dma = isert_conn->login_req_dma; 1598 rx_dma = isert_conn->login_req_dma;
1599 rx_buflen = ISER_RX_PAYLOAD_SIZE; 1599 rx_buflen = ISER_RX_PAYLOAD_SIZE;
1600 isert_dbg("login_buf: Using rx_dma: 0x%llx, rx_buflen: %d\n", 1600 isert_dbg("login_buf: Using rx_dma: 0x%llx, rx_buflen: %d\n",
@@ -1613,7 +1613,7 @@ isert_rcv_completion(struct iser_rx_desc *desc,
1613 hdr->opcode, hdr->itt, hdr->flags, 1613 hdr->opcode, hdr->itt, hdr->flags,
1614 (int)(xfer_len - ISER_HEADERS_LEN)); 1614 (int)(xfer_len - ISER_HEADERS_LEN));
1615 1615
1616 if ((char *)desc == isert_conn->login_req_buf) { 1616 if (desc == isert_conn->login_req_buf) {
1617 isert_conn->login_req_len = xfer_len - ISER_HEADERS_LEN; 1617 isert_conn->login_req_len = xfer_len - ISER_HEADERS_LEN;
1618 if (isert_conn->conn) { 1618 if (isert_conn->conn) {
1619 struct iscsi_login *login = isert_conn->conn->conn_login; 1619 struct iscsi_login *login = isert_conn->conn->conn_login;
diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h
index 2ef2d6cdbe52..6c2c5fa85d2f 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.h
+++ b/drivers/infiniband/ulp/isert/ib_isert.h
@@ -182,8 +182,7 @@ struct isert_conn {
182 u32 initiator_depth; 182 u32 initiator_depth;
183 bool pi_support; 183 bool pi_support;
184 u32 max_sge; 184 u32 max_sge;
185 char *login_buf; 185 struct iser_rx_desc *login_req_buf;
186 char *login_req_buf;
187 char *login_rsp_buf; 186 char *login_rsp_buf;
188 u64 login_req_dma; 187 u64 login_req_dma;
189 int login_req_len; 188 int login_req_len;