Skip to content

Commit

Permalink
Merge pull request #586 from noaos/pr-fixes
Browse files Browse the repository at this point in the history
General fixes
  • Loading branch information
rleon committed Oct 2, 2019
2 parents 7edd225 + 0b22d6f commit 4159490
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion libibverbs/examples/ud_pingpong.c
Expand Up @@ -563,7 +563,7 @@ int main(int argc, char *argv[])
char *servername = NULL;
unsigned int port = 18515;
int ib_port = 1;
unsigned int size = 2048;
unsigned int size = 1024;
unsigned int rx_depth = 500;
unsigned int iters = 1000;
int use_event = 0;
Expand Down
36 changes: 27 additions & 9 deletions providers/mlx4/verbs.c
Expand Up @@ -473,8 +473,10 @@ static struct ibv_cq_ex *create_cq(struct ibv_context *context,
return NULL;
}

if (cq_attr->wc_flags & ~CREATE_CQ_SUPPORTED_WC_FLAGS)
if (cq_attr->wc_flags & ~CREATE_CQ_SUPPORTED_WC_FLAGS) {
errno = ENOTSUP;
return NULL;
}

/* mlx4 devices don't support slid and sl in cqe when completion
* timestamp is enabled in the CQ
Expand Down Expand Up @@ -656,8 +658,10 @@ struct ibv_srq *mlx4_create_srq(struct ibv_pd *pd,
int ret;

/* Sanity check SRQ size before proceeding */
if (attr->attr.max_wr > 1 << 16 || attr->attr.max_sge > 64)
if (attr->attr.max_wr > 1 << 16 || attr->attr.max_sge > 64) {
errno = EINVAL;
return NULL;
}

srq = malloc(sizeof *srq);
if (!srq)
Expand Down Expand Up @@ -789,11 +793,15 @@ static struct ibv_qp *_mlx4_create_qp_ex_rss(struct ibv_context *context,
int ret;

if (!(attr->comp_mask & IBV_QP_INIT_ATTR_RX_HASH) ||
!(attr->comp_mask & IBV_QP_INIT_ATTR_IND_TABLE))
!(attr->comp_mask & IBV_QP_INIT_ATTR_IND_TABLE)) {
errno = EINVAL;
return NULL;
}

if (attr->qp_type != IBV_QPT_RAW_PACKET)
if (attr->qp_type != IBV_QPT_RAW_PACKET) {
errno = EINVAL;
return NULL;
}

qp = calloc(1, sizeof(*qp));
if (!qp)
Expand Down Expand Up @@ -868,20 +876,28 @@ static struct ibv_qp *create_qp_ex(struct ibv_context *context,
if (attr->cap.max_send_wr > ctx->max_qp_wr ||
attr->cap.max_recv_wr > ctx->max_qp_wr ||
attr->cap.max_send_sge > ctx->max_sge ||
attr->cap.max_recv_sge > ctx->max_sge)
attr->cap.max_recv_sge > ctx->max_sge) {
errno = EINVAL;
return NULL;
}
} else {
if (attr->cap.max_send_wr > 65536 ||
attr->cap.max_recv_wr > 65536 ||
attr->cap.max_send_sge > 64 ||
attr->cap.max_recv_sge > 64)
attr->cap.max_recv_sge > 64) {
errno = EINVAL;
return NULL;
}
}
if (attr->cap.max_inline_data > 1024)
if (attr->cap.max_inline_data > 1024) {
errno = EINVAL;
return NULL;
}

if (attr->comp_mask & ~MLX4_CREATE_QP_SUP_COMP_MASK)
if (attr->comp_mask & ~MLX4_CREATE_QP_SUP_COMP_MASK) {
errno = ENOTSUP;
return NULL;
}

qp = calloc(1, sizeof *qp);
if (!qp)
Expand Down Expand Up @@ -1322,8 +1338,10 @@ struct ibv_ah *mlx4_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
return NULL;

if (port_attr.flags & IBV_QPF_GRH_REQUIRED &&
!attr->is_global)
!attr->is_global) {
errno = EINVAL;
return NULL;
}

ah = malloc(sizeof *ah);
if (!ah)
Expand Down
2 changes: 1 addition & 1 deletion pyverbs/qp.pxd
Expand Up @@ -18,7 +18,7 @@ cdef class QPInitAttrEx(PyverbsObject):
cdef v.ibv_qp_init_attr_ex attr
cdef object scq
cdef object rcq
cdef object pd
cdef object _pd

cdef class QPAttr(PyverbsObject):
cdef v.ibv_qp_attr attr
Expand Down
7 changes: 4 additions & 3 deletions pyverbs/qp.pyx
Expand Up @@ -250,7 +250,8 @@ cdef class QPInitAttrEx(PyverbsObject):
raise PyverbsUserError('XRCD and RSS are not yet supported in pyverbs')
self.attr.comp_mask = comp_mask
if pd is not None:
self.pd = pd
self._pd = pd
self.attr.pd = <v.ibv_pd*>pd.pd
self.attr.create_flags = create_flags
self.attr.max_tso_header = max_tso_header
self.attr.source_qpn = source_qpn
Expand Down Expand Up @@ -311,11 +312,11 @@ cdef class QPInitAttrEx(PyverbsObject):

@property
def pd(self):
return self.pd
return self._pd
@pd.setter
def pd(self, PD val):
self.attr.pd = <v.ibv_pd*>val.pd
self.pd = val
self._pd = val

@property
def create_flags(self):
Expand Down

0 comments on commit 4159490

Please sign in to comment.