From patchwork Sun Sep 14 13:20:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Or Gerlitz X-Patchwork-Id: 4901371 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 846A3BEEA5 for ; Sun, 14 Sep 2014 13:20:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A5AB720200 for ; Sun, 14 Sep 2014 13:20:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BD9D5201FB for ; Sun, 14 Sep 2014 13:20:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752593AbaINNUO (ORCPT ); Sun, 14 Sep 2014 09:20:14 -0400 Received: from mailp.voltaire.com ([193.47.165.129]:40225 "EHLO mellanox.co.il" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752597AbaINNUN (ORCPT ); Sun, 14 Sep 2014 09:20:13 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from ogerlitz@mellanox.com) with SMTP; 14 Sep 2014 16:20:07 +0300 Received: from r-vnc04.mtr.labs.mlnx (r-vnc04.mtr.labs.mlnx [10.208.0.116]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id s8EDK4wI022586; Sun, 14 Sep 2014 16:20:06 +0300 From: Or Gerlitz To: Roland Dreier Cc: linux-rdma@vger.kernel.org, Matan Barak , cl@linux.com, Or Gerlitz Subject: [PATCH for-next 1/2] IB/uverbs: Add QP creation flags, allow blocking UD multicast loopback Date: Sun, 14 Sep 2014 16:20:01 +0300 Message-Id: <1410700802-27848-2-git-send-email-ogerlitz@mellanox.com> X-Mailer: git-send-email 1.7.8.2 In-Reply-To: <1410700802-27848-1-git-send-email-ogerlitz@mellanox.com> References: <1410700802-27848-1-git-send-email-ogerlitz@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, there's no way for user-space applications to specify the IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK QP creation flags defined by commit 47ee1b9 "IB/core: Add support for multicast loopback blocking". As a result, applications who send and recieve over the same QP to the same multicast group get all their packets bouncded back to them, which is terribly bad performance wise. To fix this long standing issue, add the ability to provide QP creation flags through uverbs. Signed-off-by: Matan Barak Signed-off-by: Or Gerlitz --- drivers/infiniband/core/uverbs_cmd.c | 35 ++++++++++++++++++++++++++++++++- include/uapi/rdma/ib_user_verbs.h | 2 +- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 0600c50..1ad489c 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -1579,6 +1579,31 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, return in_len; } +enum ib_uverbs_qp_create_flags { + IB_UVERBS_QP_CREATE_LSO = 0, + IB_UVERBS_QP_CREATE_BLOCK_MULTICAST_LOOPBACK = 1, + IB_UVERBS_SUPPORTED_FLAGS +}; + +static int ib_uverbs_create_qp_trans(u8 u_flags) +{ + int i; + int res; + static const enum ib_qp_create_flags ib_uverbs_qp_create_flags[IB_UVERBS_SUPPORTED_FLAGS] = { + [IB_UVERBS_QP_CREATE_LSO] = IB_QP_CREATE_IPOIB_UD_LSO, + [IB_UVERBS_QP_CREATE_BLOCK_MULTICAST_LOOPBACK] = IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK, + }; + + if (u_flags & ~((1 << IB_UVERBS_SUPPORTED_FLAGS) - 1)) + return -1; + + for (i = 0; i < IB_UVERBS_SUPPORTED_FLAGS; i++) + if (u_flags & (1 << i)) + res |= ib_uverbs_qp_create_flags[i]; + + return res; +} + ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, const char __user *buf, int in_len, int out_len) @@ -1595,7 +1620,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, struct ib_srq *srq = NULL; struct ib_qp *qp; struct ib_qp_init_attr attr; - int ret; + int flags, ret; if (out_len < sizeof resp) return -ENOSPC; @@ -1664,7 +1689,13 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, attr.xrcd = xrcd; attr.sq_sig_type = cmd.sq_sig_all ? IB_SIGNAL_ALL_WR : IB_SIGNAL_REQ_WR; attr.qp_type = cmd.qp_type; - attr.create_flags = 0; + + flags = ib_uverbs_create_qp_trans(cmd.create_flags); + if (flags < 0) { + ret = -EINVAL; + goto err_put; + } + attr.create_flags = flags; attr.cap.max_send_wr = cmd.max_send_wr; attr.cap.max_recv_wr = cmd.max_recv_wr; diff --git a/include/uapi/rdma/ib_user_verbs.h b/include/uapi/rdma/ib_user_verbs.h index 26daf55..fac6975 100644 --- a/include/uapi/rdma/ib_user_verbs.h +++ b/include/uapi/rdma/ib_user_verbs.h @@ -470,7 +470,7 @@ struct ib_uverbs_create_qp { __u8 sq_sig_all; __u8 qp_type; __u8 is_srq; - __u8 reserved; + __u8 create_flags; __u64 driver_data[0]; };