|
@@ -703,19 +703,34 @@ iser_calc_scsi_params(struct iser_conn *iser_conn,
|
|
|
unsigned int max_sectors)
|
|
unsigned int max_sectors)
|
|
|
{
|
|
{
|
|
|
struct iser_device *device = iser_conn->ib_conn.device;
|
|
struct iser_device *device = iser_conn->ib_conn.device;
|
|
|
|
|
+ struct ib_device_attr *attr = &device->ib_device->attrs;
|
|
|
unsigned short sg_tablesize, sup_sg_tablesize;
|
|
unsigned short sg_tablesize, sup_sg_tablesize;
|
|
|
|
|
+ unsigned short reserved_mr_pages;
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ * FRs without SG_GAPS or FMRs can only map up to a (device) page per
|
|
|
|
|
+ * entry, but if the first entry is misaligned we'll end up using two
|
|
|
|
|
+ * entries (head and tail) for a single page worth data, so one
|
|
|
|
|
+ * additional entry is required.
|
|
|
|
|
+ */
|
|
|
|
|
+ if ((attr->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS) &&
|
|
|
|
|
+ (attr->device_cap_flags & IB_DEVICE_SG_GAPS_REG))
|
|
|
|
|
+ reserved_mr_pages = 0;
|
|
|
|
|
+ else
|
|
|
|
|
+ reserved_mr_pages = 1;
|
|
|
|
|
|
|
|
sg_tablesize = DIV_ROUND_UP(max_sectors * 512, SIZE_4K);
|
|
sg_tablesize = DIV_ROUND_UP(max_sectors * 512, SIZE_4K);
|
|
|
- if (device->ib_device->attrs.device_cap_flags &
|
|
|
|
|
- IB_DEVICE_MEM_MGT_EXTENSIONS)
|
|
|
|
|
|
|
+ if (attr->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS)
|
|
|
sup_sg_tablesize =
|
|
sup_sg_tablesize =
|
|
|
min_t(
|
|
min_t(
|
|
|
uint, ISCSI_ISER_MAX_SG_TABLESIZE,
|
|
uint, ISCSI_ISER_MAX_SG_TABLESIZE,
|
|
|
- device->ib_device->attrs.max_fast_reg_page_list_len);
|
|
|
|
|
|
|
+ attr->max_fast_reg_page_list_len - reserved_mr_pages);
|
|
|
else
|
|
else
|
|
|
sup_sg_tablesize = ISCSI_ISER_MAX_SG_TABLESIZE;
|
|
sup_sg_tablesize = ISCSI_ISER_MAX_SG_TABLESIZE;
|
|
|
|
|
|
|
|
iser_conn->scsi_sg_tablesize = min(sg_tablesize, sup_sg_tablesize);
|
|
iser_conn->scsi_sg_tablesize = min(sg_tablesize, sup_sg_tablesize);
|
|
|
|
|
+ iser_conn->pages_per_mr =
|
|
|
|
|
+ iser_conn->scsi_sg_tablesize + reserved_mr_pages;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|