diff options
| -rw-r--r-- | drivers/infiniband/ulp/iser/iscsi_iser.c | 10 | ||||
| -rw-r--r-- | drivers/infiniband/ulp/iser/iscsi_iser.h | 14 | ||||
| -rw-r--r-- | drivers/infiniband/ulp/iser/iser_initiator.c | 2 | ||||
| -rw-r--r-- | drivers/infiniband/ulp/iser/iser_memory.c | 14 | ||||
| -rw-r--r-- | drivers/infiniband/ulp/iser/iser_verbs.c | 27 |
5 files changed, 60 insertions, 7 deletions
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index 169cc3e75018..0720bb46589f 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c | |||
| @@ -93,6 +93,10 @@ static unsigned int iscsi_max_lun = 512; | |||
| 93 | module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO); | 93 | module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO); |
| 94 | MODULE_PARM_DESC(max_lun, "Max LUNs to allow per session (default:512"); | 94 | MODULE_PARM_DESC(max_lun, "Max LUNs to allow per session (default:512"); |
| 95 | 95 | ||
| 96 | unsigned int iser_max_sectors = ISER_DEF_MAX_SECTORS; | ||
| 97 | module_param_named(max_sectors, iser_max_sectors, uint, S_IRUGO | S_IWUSR); | ||
| 98 | MODULE_PARM_DESC(max_sectors, "Max number of sectors in a single scsi command (default:1024"); | ||
| 99 | |||
| 96 | bool iser_pi_enable = false; | 100 | bool iser_pi_enable = false; |
| 97 | module_param_named(pi_enable, iser_pi_enable, bool, S_IRUGO); | 101 | module_param_named(pi_enable, iser_pi_enable, bool, S_IRUGO); |
| 98 | MODULE_PARM_DESC(pi_enable, "Enable T10-PI offload support (default:disabled)"); | 102 | MODULE_PARM_DESC(pi_enable, "Enable T10-PI offload support (default:disabled)"); |
| @@ -625,6 +629,8 @@ iscsi_iser_session_create(struct iscsi_endpoint *ep, | |||
| 625 | if (ep) { | 629 | if (ep) { |
| 626 | iser_conn = ep->dd_data; | 630 | iser_conn = ep->dd_data; |
| 627 | max_cmds = iser_conn->max_cmds; | 631 | max_cmds = iser_conn->max_cmds; |
| 632 | shost->sg_tablesize = iser_conn->scsi_sg_tablesize; | ||
| 633 | shost->max_sectors = iser_conn->scsi_max_sectors; | ||
| 628 | 634 | ||
| 629 | mutex_lock(&iser_conn->state_mutex); | 635 | mutex_lock(&iser_conn->state_mutex); |
| 630 | if (iser_conn->state != ISER_CONN_UP) { | 636 | if (iser_conn->state != ISER_CONN_UP) { |
| @@ -966,8 +972,8 @@ static struct scsi_host_template iscsi_iser_sht = { | |||
| 966 | .name = "iSCSI Initiator over iSER", | 972 | .name = "iSCSI Initiator over iSER", |
| 967 | .queuecommand = iscsi_queuecommand, | 973 | .queuecommand = iscsi_queuecommand, |
| 968 | .change_queue_depth = scsi_change_queue_depth, | 974 | .change_queue_depth = scsi_change_queue_depth, |
| 969 | .sg_tablesize = ISCSI_ISER_SG_TABLESIZE, | 975 | .sg_tablesize = ISCSI_ISER_DEF_SG_TABLESIZE, |
| 970 | .max_sectors = 1024, | 976 | .max_sectors = ISER_DEF_MAX_SECTORS, |
| 971 | .cmd_per_lun = ISER_DEF_CMD_PER_LUN, | 977 | .cmd_per_lun = ISER_DEF_CMD_PER_LUN, |
| 972 | .eh_abort_handler = iscsi_eh_abort, | 978 | .eh_abort_handler = iscsi_eh_abort, |
| 973 | .eh_device_reset_handler= iscsi_eh_device_reset, | 979 | .eh_device_reset_handler= iscsi_eh_device_reset, |
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h index e9ebe0b2263d..0bdd7e77e5db 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.h +++ b/drivers/infiniband/ulp/iser/iscsi_iser.h | |||
| @@ -98,8 +98,13 @@ | |||
| 98 | #define SHIFT_4K 12 | 98 | #define SHIFT_4K 12 |
| 99 | #define SIZE_4K (1ULL << SHIFT_4K) | 99 | #define SIZE_4K (1ULL << SHIFT_4K) |
| 100 | #define MASK_4K (~(SIZE_4K-1)) | 100 | #define MASK_4K (~(SIZE_4K-1)) |
| 101 | /* support up to 512KB in one RDMA */ | 101 | |
| 102 | #define ISCSI_ISER_SG_TABLESIZE (0x80000 >> SHIFT_4K) | 102 | /* Default support is 512KB I/O size */ |
| 103 | #define ISER_DEF_MAX_SECTORS 1024 | ||
| 104 | #define ISCSI_ISER_DEF_SG_TABLESIZE ((ISER_DEF_MAX_SECTORS * 512) >> SHIFT_4K) | ||
| 105 | /* Maximum support is 8MB I/O size */ | ||
| 106 | #define ISCSI_ISER_MAX_SG_TABLESIZE ((16384 * 512) >> SHIFT_4K) | ||
| 107 | |||
| 103 | #define ISER_DEF_XMIT_CMDS_DEFAULT 512 | 108 | #define ISER_DEF_XMIT_CMDS_DEFAULT 512 |
| 104 | #if ISCSI_DEF_XMIT_CMDS_MAX > ISER_DEF_XMIT_CMDS_DEFAULT | 109 | #if ISCSI_DEF_XMIT_CMDS_MAX > ISER_DEF_XMIT_CMDS_DEFAULT |
| 105 | #define ISER_DEF_XMIT_CMDS_MAX ISCSI_DEF_XMIT_CMDS_MAX | 110 | #define ISER_DEF_XMIT_CMDS_MAX ISCSI_DEF_XMIT_CMDS_MAX |
| @@ -504,6 +509,8 @@ struct ib_conn { | |||
| 504 | * @rx_desc_head: head of rx_descs cyclic buffer | 509 | * @rx_desc_head: head of rx_descs cyclic buffer |
| 505 | * @rx_descs: rx buffers array (cyclic buffer) | 510 | * @rx_descs: rx buffers array (cyclic buffer) |
| 506 | * @num_rx_descs: number of rx descriptors | 511 | * @num_rx_descs: number of rx descriptors |
| 512 | * @scsi_sg_tablesize: scsi host sg_tablesize | ||
| 513 | * @scsi_max_sectors: scsi host max sectors | ||
| 507 | */ | 514 | */ |
| 508 | struct iser_conn { | 515 | struct iser_conn { |
| 509 | struct ib_conn ib_conn; | 516 | struct ib_conn ib_conn; |
| @@ -528,6 +535,8 @@ struct iser_conn { | |||
| 528 | unsigned int rx_desc_head; | 535 | unsigned int rx_desc_head; |
| 529 | struct iser_rx_desc *rx_descs; | 536 | struct iser_rx_desc *rx_descs; |
| 530 | u32 num_rx_descs; | 537 | u32 num_rx_descs; |
| 538 | unsigned short scsi_sg_tablesize; | ||
| 539 | unsigned int scsi_max_sectors; | ||
| 531 | }; | 540 | }; |
| 532 | 541 | ||
| 533 | /** | 542 | /** |
| @@ -583,6 +592,7 @@ extern struct iser_global ig; | |||
| 583 | extern int iser_debug_level; | 592 | extern int iser_debug_level; |
| 584 | extern bool iser_pi_enable; | 593 | extern bool iser_pi_enable; |
| 585 | extern int iser_pi_guard; | 594 | extern int iser_pi_guard; |
| 595 | extern unsigned int iser_max_sectors; | ||
| 586 | 596 | ||
| 587 | int iser_assign_reg_ops(struct iser_device *device); | 597 | int iser_assign_reg_ops(struct iser_device *device); |
| 588 | 598 | ||
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c index f1200f27b6a7..0b1f3b54a0c1 100644 --- a/drivers/infiniband/ulp/iser/iser_initiator.c +++ b/drivers/infiniband/ulp/iser/iser_initiator.c | |||
| @@ -259,7 +259,7 @@ int iser_alloc_rx_descriptors(struct iser_conn *iser_conn, | |||
| 259 | iser_conn->min_posted_rx = iser_conn->qp_max_recv_dtos >> 2; | 259 | iser_conn->min_posted_rx = iser_conn->qp_max_recv_dtos >> 2; |
| 260 | 260 | ||
| 261 | if (device->reg_ops->alloc_reg_res(ib_conn, session->scsi_cmds_max, | 261 | if (device->reg_ops->alloc_reg_res(ib_conn, session->scsi_cmds_max, |
| 262 | ISCSI_ISER_SG_TABLESIZE + 1)) | 262 | iser_conn->scsi_sg_tablesize)) |
| 263 | goto create_rdma_reg_res_failed; | 263 | goto create_rdma_reg_res_failed; |
| 264 | 264 | ||
| 265 | if (iser_alloc_login_buf(iser_conn)) | 265 | if (iser_alloc_login_buf(iser_conn)) |
diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c index b1261d5fbb9b..384fd0a49cca 100644 --- a/drivers/infiniband/ulp/iser/iser_memory.c +++ b/drivers/infiniband/ulp/iser/iser_memory.c | |||
| @@ -363,7 +363,8 @@ static int iser_sg_to_page_vec(struct iser_data_buf *data, | |||
| 363 | * consecutive SG elements are actually fragments of the same physcial page. | 363 | * consecutive SG elements are actually fragments of the same physcial page. |
| 364 | */ | 364 | */ |
| 365 | static int iser_data_buf_aligned_len(struct iser_data_buf *data, | 365 | static int iser_data_buf_aligned_len(struct iser_data_buf *data, |
| 366 | struct ib_device *ibdev) | 366 | struct ib_device *ibdev, |
| 367 | unsigned sg_tablesize) | ||
| 367 | { | 368 | { |
| 368 | struct scatterlist *sg, *sgl, *next_sg = NULL; | 369 | struct scatterlist *sg, *sgl, *next_sg = NULL; |
| 369 | u64 start_addr, end_addr; | 370 | u64 start_addr, end_addr; |
| @@ -375,6 +376,14 @@ static int iser_data_buf_aligned_len(struct iser_data_buf *data, | |||
| 375 | sgl = data->sg; | 376 | sgl = data->sg; |
| 376 | start_addr = ib_sg_dma_address(ibdev, sgl); | 377 | start_addr = ib_sg_dma_address(ibdev, sgl); |
| 377 | 378 | ||
| 379 | if (unlikely(sgl[0].offset && | ||
| 380 | data->data_len >= sg_tablesize * PAGE_SIZE)) { | ||
| 381 | iser_dbg("can't register length %lx with offset %x " | ||
| 382 | "fall to bounce buffer\n", data->data_len, | ||
| 383 | sgl[0].offset); | ||
| 384 | return 0; | ||
| 385 | } | ||
| 386 | |||
| 378 | for_each_sg(sgl, sg, data->dma_nents, i) { | 387 | for_each_sg(sgl, sg, data->dma_nents, i) { |
| 379 | if (start_check && !IS_4K_ALIGNED(start_addr)) | 388 | if (start_check && !IS_4K_ALIGNED(start_addr)) |
| 380 | break; | 389 | break; |
| @@ -790,7 +799,8 @@ iser_handle_unaligned_buf(struct iscsi_iser_task *task, | |||
| 790 | struct iser_device *device = iser_conn->ib_conn.device; | 799 | struct iser_device *device = iser_conn->ib_conn.device; |
| 791 | int err, aligned_len; | 800 | int err, aligned_len; |
| 792 | 801 | ||
| 793 | aligned_len = iser_data_buf_aligned_len(mem, device->ib_device); | 802 | aligned_len = iser_data_buf_aligned_len(mem, device->ib_device, |
| 803 | iser_conn->scsi_sg_tablesize); | ||
| 794 | if (aligned_len != mem->dma_nents) { | 804 | if (aligned_len != mem->dma_nents) { |
| 795 | err = fall_to_bounce_buf(task, mem, dir); | 805 | err = fall_to_bounce_buf(task, mem, dir); |
| 796 | if (err) | 806 | if (err) |
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index 0ade0e876c79..187c7125a4b9 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c | |||
| @@ -756,6 +756,31 @@ static void iser_connect_error(struct rdma_cm_id *cma_id) | |||
| 756 | iser_conn->state = ISER_CONN_TERMINATING; | 756 | iser_conn->state = ISER_CONN_TERMINATING; |
| 757 | } | 757 | } |
| 758 | 758 | ||
| 759 | static void | ||
| 760 | iser_calc_scsi_params(struct iser_conn *iser_conn, | ||
| 761 | unsigned int max_sectors) | ||
| 762 | { | ||
| 763 | struct iser_device *device = iser_conn->ib_conn.device; | ||
| 764 | unsigned short sg_tablesize, sup_sg_tablesize; | ||
| 765 | |||
| 766 | sg_tablesize = DIV_ROUND_UP(max_sectors * 512, SIZE_4K); | ||
| 767 | sup_sg_tablesize = min_t(unsigned, ISCSI_ISER_MAX_SG_TABLESIZE, | ||
| 768 | device->dev_attr.max_fast_reg_page_list_len); | ||
| 769 | |||
| 770 | if (sg_tablesize > sup_sg_tablesize) { | ||
| 771 | sg_tablesize = sup_sg_tablesize; | ||
| 772 | iser_conn->scsi_max_sectors = sg_tablesize * SIZE_4K / 512; | ||
| 773 | } else { | ||
| 774 | iser_conn->scsi_max_sectors = max_sectors; | ||
| 775 | } | ||
| 776 | |||
| 777 | iser_conn->scsi_sg_tablesize = sg_tablesize; | ||
| 778 | |||
| 779 | iser_dbg("iser_conn %p, sg_tablesize %u, max_sectors %u\n", | ||
| 780 | iser_conn, iser_conn->scsi_sg_tablesize, | ||
| 781 | iser_conn->scsi_max_sectors); | ||
| 782 | } | ||
| 783 | |||
| 759 | /** | 784 | /** |
| 760 | * Called with state mutex held | 785 | * Called with state mutex held |
| 761 | **/ | 786 | **/ |
| @@ -794,6 +819,8 @@ static void iser_addr_handler(struct rdma_cm_id *cma_id) | |||
| 794 | } | 819 | } |
