forked from luck/tmp_suning_uos_patched
[IB] uverbs: have kernel return QP capabilities
Move the computation of QP capabilities (max scatter/gather entries, max inline data, etc) into the kernel, and have the uverbs module return the values as part of the create QP response. This keeps precise knowledge of device limits in the low-level kernel driver. This requires an ABI bump, so while we're making changes, get rid of the max_sge parameter for the modify SRQ command -- it's not used and shouldn't be there. Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il> Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il> Signed-off-by: Roland Dreier <rolandd@cisco.com>
This commit is contained in:
parent
ec914c52d6
commit
77369ed31d
|
@ -708,7 +708,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
|
||||||
resp->wc[i].opcode = wc[i].opcode;
|
resp->wc[i].opcode = wc[i].opcode;
|
||||||
resp->wc[i].vendor_err = wc[i].vendor_err;
|
resp->wc[i].vendor_err = wc[i].vendor_err;
|
||||||
resp->wc[i].byte_len = wc[i].byte_len;
|
resp->wc[i].byte_len = wc[i].byte_len;
|
||||||
resp->wc[i].imm_data = wc[i].imm_data;
|
resp->wc[i].imm_data = (__u32 __force) wc[i].imm_data;
|
||||||
resp->wc[i].qp_num = wc[i].qp_num;
|
resp->wc[i].qp_num = wc[i].qp_num;
|
||||||
resp->wc[i].src_qp = wc[i].src_qp;
|
resp->wc[i].src_qp = wc[i].src_qp;
|
||||||
resp->wc[i].wc_flags = wc[i].wc_flags;
|
resp->wc[i].wc_flags = wc[i].wc_flags;
|
||||||
|
@ -908,7 +908,12 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_destroy;
|
goto err_destroy;
|
||||||
|
|
||||||
resp.qp_handle = uobj->uobject.id;
|
resp.qp_handle = uobj->uobject.id;
|
||||||
|
resp.max_recv_sge = attr.cap.max_recv_sge;
|
||||||
|
resp.max_send_sge = attr.cap.max_send_sge;
|
||||||
|
resp.max_recv_wr = attr.cap.max_recv_wr;
|
||||||
|
resp.max_send_wr = attr.cap.max_send_wr;
|
||||||
|
resp.max_inline_data = attr.cap.max_inline_data;
|
||||||
|
|
||||||
if (copy_to_user((void __user *) (unsigned long) cmd.response,
|
if (copy_to_user((void __user *) (unsigned long) cmd.response,
|
||||||
&resp, sizeof resp)) {
|
&resp, sizeof resp)) {
|
||||||
|
@ -1135,7 +1140,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
|
||||||
next->num_sge = user_wr->num_sge;
|
next->num_sge = user_wr->num_sge;
|
||||||
next->opcode = user_wr->opcode;
|
next->opcode = user_wr->opcode;
|
||||||
next->send_flags = user_wr->send_flags;
|
next->send_flags = user_wr->send_flags;
|
||||||
next->imm_data = user_wr->imm_data;
|
next->imm_data = (__be32 __force) user_wr->imm_data;
|
||||||
|
|
||||||
if (qp->qp_type == IB_QPT_UD) {
|
if (qp->qp_type == IB_QPT_UD) {
|
||||||
next->wr.ud.ah = idr_find(&ib_uverbs_ah_idr,
|
next->wr.ud.ah = idr_find(&ib_uverbs_ah_idr,
|
||||||
|
@ -1701,7 +1706,6 @@ ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file,
|
||||||
}
|
}
|
||||||
|
|
||||||
attr.max_wr = cmd.max_wr;
|
attr.max_wr = cmd.max_wr;
|
||||||
attr.max_sge = cmd.max_sge;
|
|
||||||
attr.srq_limit = cmd.srq_limit;
|
attr.srq_limit = cmd.srq_limit;
|
||||||
|
|
||||||
ret = ib_modify_srq(srq, &attr, cmd.attr_mask);
|
ret = ib_modify_srq(srq, &attr, cmd.attr_mask);
|
||||||
|
|
|
@ -1060,6 +1060,8 @@ int mthca_QUERY_DEV_LIM(struct mthca_dev *dev,
|
||||||
dev_lim->hca.arbel.resize_srq = field & 1;
|
dev_lim->hca.arbel.resize_srq = field & 1;
|
||||||
MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SG_RQ_OFFSET);
|
MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SG_RQ_OFFSET);
|
||||||
dev_lim->max_sg = min_t(int, field, dev_lim->max_sg);
|
dev_lim->max_sg = min_t(int, field, dev_lim->max_sg);
|
||||||
|
MTHCA_GET(size, outbox, QUERY_DEV_LIM_MAX_DESC_SZ_RQ_OFFSET);
|
||||||
|
dev_lim->max_desc_sz = min_t(int, size, dev_lim->max_desc_sz);
|
||||||
MTHCA_GET(size, outbox, QUERY_DEV_LIM_MPT_ENTRY_SZ_OFFSET);
|
MTHCA_GET(size, outbox, QUERY_DEV_LIM_MPT_ENTRY_SZ_OFFSET);
|
||||||
dev_lim->mpt_entry_sz = size;
|
dev_lim->mpt_entry_sz = size;
|
||||||
MTHCA_GET(field, outbox, QUERY_DEV_LIM_PBL_SZ_OFFSET);
|
MTHCA_GET(field, outbox, QUERY_DEV_LIM_PBL_SZ_OFFSET);
|
||||||
|
|
|
@ -131,6 +131,7 @@ struct mthca_limits {
|
||||||
int max_sg;
|
int max_sg;
|
||||||
int num_qps;
|
int num_qps;
|
||||||
int max_wqes;
|
int max_wqes;
|
||||||
|
int max_desc_sz;
|
||||||
int max_qp_init_rdma;
|
int max_qp_init_rdma;
|
||||||
int reserved_qps;
|
int reserved_qps;
|
||||||
int num_srqs;
|
int num_srqs;
|
||||||
|
|
|
@ -168,6 +168,7 @@ static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim
|
||||||
mdev->limits.max_srq_wqes = dev_lim->max_srq_sz;
|
mdev->limits.max_srq_wqes = dev_lim->max_srq_sz;
|
||||||
mdev->limits.reserved_srqs = dev_lim->reserved_srqs;
|
mdev->limits.reserved_srqs = dev_lim->reserved_srqs;
|
||||||
mdev->limits.reserved_eecs = dev_lim->reserved_eecs;
|
mdev->limits.reserved_eecs = dev_lim->reserved_eecs;
|
||||||
|
mdev->limits.max_desc_sz = dev_lim->max_desc_sz;
|
||||||
/*
|
/*
|
||||||
* Subtract 1 from the limit because we need to allocate a
|
* Subtract 1 from the limit because we need to allocate a
|
||||||
* spare CQE so the HCA HW can tell the difference between an
|
* spare CQE so the HCA HW can tell the difference between an
|
||||||
|
|
|
@ -616,11 +616,11 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd,
|
||||||
return ERR_PTR(err);
|
return ERR_PTR(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
init_attr->cap.max_inline_data = 0;
|
|
||||||
init_attr->cap.max_send_wr = qp->sq.max;
|
init_attr->cap.max_send_wr = qp->sq.max;
|
||||||
init_attr->cap.max_recv_wr = qp->rq.max;
|
init_attr->cap.max_recv_wr = qp->rq.max;
|
||||||
init_attr->cap.max_send_sge = qp->sq.max_gs;
|
init_attr->cap.max_send_sge = qp->sq.max_gs;
|
||||||
init_attr->cap.max_recv_sge = qp->rq.max_gs;
|
init_attr->cap.max_recv_sge = qp->rq.max_gs;
|
||||||
|
init_attr->cap.max_inline_data = qp->max_inline_data;
|
||||||
|
|
||||||
return &qp->ibqp;
|
return &qp->ibqp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,6 +251,7 @@ struct mthca_qp {
|
||||||
struct mthca_wq sq;
|
struct mthca_wq sq;
|
||||||
enum ib_sig_type sq_policy;
|
enum ib_sig_type sq_policy;
|
||||||
int send_wqe_offset;
|
int send_wqe_offset;
|
||||||
|
int max_inline_data;
|
||||||
|
|
||||||
u64 *wrid;
|
u64 *wrid;
|
||||||
union mthca_buf queue;
|
union mthca_buf queue;
|
||||||
|
|
|
@ -885,6 +885,48 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mthca_adjust_qp_caps(struct mthca_dev *dev,
|
||||||
|
struct mthca_pd *pd,
|
||||||
|
struct mthca_qp *qp)
|
||||||
|
{
|
||||||
|
int max_data_size;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Calculate the maximum size of WQE s/g segments, excluding
|
||||||
|
* the next segment and other non-data segments.
|
||||||
|
*/
|
||||||
|
max_data_size = min(dev->limits.max_desc_sz, 1 << qp->sq.wqe_shift) -
|
||||||
|
sizeof (struct mthca_next_seg);
|
||||||
|
|
||||||
|
switch (qp->transport) {
|
||||||
|
case MLX:
|
||||||
|
max_data_size -= 2 * sizeof (struct mthca_data_seg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UD:
|
||||||
|
if (mthca_is_memfree(dev))
|
||||||
|
max_data_size -= sizeof (struct mthca_arbel_ud_seg);
|
||||||
|
else
|
||||||
|
max_data_size -= sizeof (struct mthca_tavor_ud_seg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
max_data_size -= sizeof (struct mthca_raddr_seg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We don't support inline data for kernel QPs (yet). */
|
||||||
|
if (!pd->ibpd.uobject)
|
||||||
|
qp->max_inline_data = 0;
|
||||||
|
else
|
||||||
|
qp->max_inline_data = max_data_size - MTHCA_INLINE_HEADER_SIZE;
|
||||||
|
|
||||||
|
qp->sq.max_gs = max_data_size / sizeof (struct mthca_data_seg);
|
||||||
|
qp->rq.max_gs = (min(dev->limits.max_desc_sz, 1 << qp->rq.wqe_shift) -
|
||||||
|
sizeof (struct mthca_next_seg)) /
|
||||||
|
sizeof (struct mthca_data_seg);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate and register buffer for WQEs. qp->rq.max, sq.max,
|
* Allocate and register buffer for WQEs. qp->rq.max, sq.max,
|
||||||
* rq.max_gs and sq.max_gs must all be assigned.
|
* rq.max_gs and sq.max_gs must all be assigned.
|
||||||
|
@ -902,27 +944,53 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev,
|
||||||
size = sizeof (struct mthca_next_seg) +
|
size = sizeof (struct mthca_next_seg) +
|
||||||
qp->rq.max_gs * sizeof (struct mthca_data_seg);
|
qp->rq.max_gs * sizeof (struct mthca_data_seg);
|
||||||
|
|
||||||
|
if (size > dev->limits.max_desc_sz)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
for (qp->rq.wqe_shift = 6; 1 << qp->rq.wqe_shift < size;
|
for (qp->rq.wqe_shift = 6; 1 << qp->rq.wqe_shift < size;
|
||||||
qp->rq.wqe_shift++)
|
qp->rq.wqe_shift++)
|
||||||
; /* nothing */
|
; /* nothing */
|
||||||
|
|
||||||
size = sizeof (struct mthca_next_seg) +
|
size = qp->sq.max_gs * sizeof (struct mthca_data_seg);
|
||||||
qp->sq.max_gs * sizeof (struct mthca_data_seg);
|
|
||||||
switch (qp->transport) {
|
switch (qp->transport) {
|
||||||
case MLX:
|
case MLX:
|
||||||
size += 2 * sizeof (struct mthca_data_seg);
|
size += 2 * sizeof (struct mthca_data_seg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UD:
|
case UD:
|
||||||
if (mthca_is_memfree(dev))
|
size += mthca_is_memfree(dev) ?
|
||||||
size += sizeof (struct mthca_arbel_ud_seg);
|
sizeof (struct mthca_arbel_ud_seg) :
|
||||||
else
|
sizeof (struct mthca_tavor_ud_seg);
|
||||||
size += sizeof (struct mthca_tavor_ud_seg);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case UC:
|
||||||
|
size += sizeof (struct mthca_raddr_seg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RC:
|
||||||
|
size += sizeof (struct mthca_raddr_seg);
|
||||||
|
/*
|
||||||
|
* An atomic op will require an atomic segment, a
|
||||||
|
* remote address segment and one scatter entry.
|
||||||
|
*/
|
||||||
|
size = max_t(int, size,
|
||||||
|
sizeof (struct mthca_atomic_seg) +
|
||||||
|
sizeof (struct mthca_raddr_seg) +
|
||||||
|
sizeof (struct mthca_data_seg));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* bind seg is as big as atomic + raddr segs */
|
break;
|
||||||
size += sizeof (struct mthca_bind_seg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make sure that we have enough space for a bind request */
|
||||||
|
size = max_t(int, size, sizeof (struct mthca_bind_seg));
|
||||||
|
|
||||||
|
size += sizeof (struct mthca_next_seg);
|
||||||
|
|
||||||
|
if (size > dev->limits.max_desc_sz)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
for (qp->sq.wqe_shift = 6; 1 << qp->sq.wqe_shift < size;
|
for (qp->sq.wqe_shift = 6; 1 << qp->sq.wqe_shift < size;
|
||||||
qp->sq.wqe_shift++)
|
qp->sq.wqe_shift++)
|
||||||
; /* nothing */
|
; /* nothing */
|
||||||
|
@ -1066,6 +1134,8 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mthca_adjust_qp_caps(dev, pd, qp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is a userspace QP, we're done now. The doorbells
|
* If this is a userspace QP, we're done now. The doorbells
|
||||||
* will be allocated and buffers will be initialized in
|
* will be allocated and buffers will be initialized in
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
* Increment this value if any changes that break userspace ABI
|
* Increment this value if any changes that break userspace ABI
|
||||||
* compatibility are made.
|
* compatibility are made.
|
||||||
*/
|
*/
|
||||||
#define IB_USER_VERBS_ABI_VERSION 3
|
#define IB_USER_VERBS_ABI_VERSION 4
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
IB_USER_VERBS_CMD_GET_CONTEXT,
|
IB_USER_VERBS_CMD_GET_CONTEXT,
|
||||||
|
@ -333,6 +333,11 @@ struct ib_uverbs_create_qp {
|
||||||
struct ib_uverbs_create_qp_resp {
|
struct ib_uverbs_create_qp_resp {
|
||||||
__u32 qp_handle;
|
__u32 qp_handle;
|
||||||
__u32 qpn;
|
__u32 qpn;
|
||||||
|
__u32 max_send_wr;
|
||||||
|
__u32 max_recv_wr;
|
||||||
|
__u32 max_send_sge;
|
||||||
|
__u32 max_recv_sge;
|
||||||
|
__u32 max_inline_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -552,9 +557,7 @@ struct ib_uverbs_modify_srq {
|
||||||
__u32 srq_handle;
|
__u32 srq_handle;
|
||||||
__u32 attr_mask;
|
__u32 attr_mask;
|
||||||
__u32 max_wr;
|
__u32 max_wr;
|
||||||
__u32 max_sge;
|
|
||||||
__u32 srq_limit;
|
__u32 srq_limit;
|
||||||
__u32 reserved;
|
|
||||||
__u64 driver_data[0];
|
__u64 driver_data[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user