From 7ffa09b9c5b449505dcbd5f6a073cc062f463167 Mon Sep 17 00:00:00 2001 From: Noa Osherovich Date: Wed, 31 Jul 2019 17:02:18 +0300 Subject: [PATCH 1/3] verbs: Fix UD pingpong default message size to match default MTU The default MTU size for Ethernet devices is 1500B. ibv_ud_pinpong defined its default message size to be 2048B. This means that if a user runs the default UD pingpong without prior MTU modification, the operation will fail with the following message: "Requested size larger than port MTU (1024)" Change the default message size to 1024B. Signed-off-by: Noa Osherovich --- libibverbs/examples/ud_pingpong.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libibverbs/examples/ud_pingpong.c b/libibverbs/examples/ud_pingpong.c index 0e1a481b9..4b0e8aff1 100644 --- a/libibverbs/examples/ud_pingpong.c +++ b/libibverbs/examples/ud_pingpong.c @@ -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; From 7f451bbdaacd8b91bb21c01405e0f3911672ac99 Mon Sep 17 00:00:00 2001 From: Noa Osherovich Date: Wed, 24 Jul 2019 14:05:40 +0300 Subject: [PATCH 2/3] pyverbs: Fix PD assignment in QPInitAttrEx PD was not properly assigned in the underlaying C object when PD was provided during QPInitAttrEx creation. Make sure that the C pointer is properly set in this case as well. Fixes: 9488abb14ab0c ('pyverbs: Add QP related classes') Signed-off-by: Noa Osherovich --- pyverbs/qp.pxd | 2 +- pyverbs/qp.pyx | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyverbs/qp.pxd b/pyverbs/qp.pxd index 29b9ec4a0..b3aa854da 100644 --- a/pyverbs/qp.pxd +++ b/pyverbs/qp.pxd @@ -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 diff --git a/pyverbs/qp.pyx b/pyverbs/qp.pyx index ad89c94c0..576c01357 100644 --- a/pyverbs/qp.pyx +++ b/pyverbs/qp.pyx @@ -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 = pd.pd self.attr.create_flags = create_flags self.attr.max_tso_header = max_tso_header self.attr.source_qpn = source_qpn @@ -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 = val.pd - self.pd = val + self._pd = val @property def create_flags(self): From 0b22d6fc6f0d40bb86097d5843b67a1e46084d46 Mon Sep 17 00:00:00 2001 From: Noa Osherovich Date: Thu, 26 Sep 2019 08:18:54 +0300 Subject: [PATCH 3/3] mlx4: Update errno where necessary Some bad flows paths didn't update errno, add these updates for CQ creation, QP creation and AH creation. Signed-off-by: Noa Osherovich --- providers/mlx4/verbs.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/providers/mlx4/verbs.c b/providers/mlx4/verbs.c index d814a2bc9..9f39ecd03 100644 --- a/providers/mlx4/verbs.c +++ b/providers/mlx4/verbs.c @@ -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 @@ -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) @@ -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) @@ -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) @@ -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)