* [PATCH libmlx5] Add support for legacy context size
@ 2016-03-27 11:30 Majd Dibbiny
[not found] ` <1459078225-16205-1-git-send-email-majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Majd Dibbiny @ 2016-03-27 11:30 UTC (permalink / raw)
To: yishaih-VPRAkNaXOzVWk0Htik3J/w
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, matanb-VPRAkNaXOzVWk0Htik3J/w,
Majd Dibbiny
The ibv_cmd_get_context fails in older kernels when passing
a request length that the kernel doesn't know.
To avoid breaking compatibility of new libmlx5 and older kernels,
when ibv_cmd_get_context fails with the full request length,
we try once again with the legacy length.
Signed-off-by: Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Reviewed-by: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
src/mlx5.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/src/mlx5.c b/src/mlx5.c
index d19c376..7bd01bd 100644
--- a/src/mlx5.c
+++ b/src/mlx5.c
@@ -533,6 +533,28 @@ static int single_threaded_app(void)
return 0;
}
+static int mlx5_cmd_get_context(struct mlx5_context *context,
+ struct mlx5_alloc_ucontext *req,
+ size_t req_len,
+ struct mlx5_alloc_ucontext_resp *resp,
+ size_t resp_len)
+{
+ if (!ibv_cmd_get_context(&context->ibv_ctx, &req->ibv_req,
+ req_len, &resp->ibv_resp, resp_len))
+ return 0;
+
+ /* The ibv_cmd_get_context fails in older kernels when passing
+ * a request length that the kernel doesn't know.
+ * To avoid breaking compatibility of new libmlx5 and older
+ * kernels, when ibv_cmd_get_context fails with the full
+ * request length, we try once again with the legacy length.
+ */
+ return ibv_cmd_get_context(&context->ibv_ctx, &req->ibv_req,
+ offsetof(struct mlx5_alloc_ucontext,
+ cqe_version),
+ &resp->ibv_resp, resp_len);
+}
+
static int mlx5_init_context(struct verbs_device *vdev,
struct ibv_context *ctx, int cmd_fd)
{
@@ -598,8 +620,9 @@ static int mlx5_init_context(struct verbs_device *vdev,
req.total_num_uuars = tot_uuars;
req.num_low_latency_uuars = low_lat_uuars;
req.cqe_version = MLX5_CQE_VERSION_V1;
- if (ibv_cmd_get_context(&context->ibv_ctx, &req.ibv_req, sizeof req,
- &resp.ibv_resp, sizeof resp))
+
+ if (mlx5_cmd_get_context(context, &req, sizeof(req), &resp,
+ sizeof(resp)))
goto err_free_bf;
context->max_num_qps = resp.qp_tab_size;
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH libmlx5] Add support for legacy context size
[not found] ` <1459078225-16205-1-git-send-email-majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
@ 2016-03-29 7:07 ` Yishai Hadas
0 siblings, 0 replies; 2+ messages in thread
From: Yishai Hadas @ 2016-03-29 7:07 UTC (permalink / raw)
To: Majd Dibbiny
Cc: yishaih-VPRAkNaXOzVWk0Htik3J/w, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
matanb-VPRAkNaXOzVWk0Htik3J/w
On 3/27/2016 2:30 PM, Majd Dibbiny wrote:
> The ibv_cmd_get_context fails in older kernels when passing
> a request length that the kernel doesn't know.
> To avoid breaking compatibility of new libmlx5 and older kernels,
> when ibv_cmd_get_context fails with the full request length,
> we try once again with the legacy length.
>
> Signed-off-by: Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> Reviewed-by: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> ---
> src/mlx5.c | 27 +++++++++++++++++++++++++--
> 1 file changed, 25 insertions(+), 2 deletions(-)
>
Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-29 7:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-27 11:30 [PATCH libmlx5] Add support for legacy context size Majd Dibbiny
[not found] ` <1459078225-16205-1-git-send-email-majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2016-03-29 7:07 ` Yishai Hadas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).