From patchwork Sat Sep 17 03:59:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Knut Omang X-Patchwork-Id: 9336949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 353396089F for ; Sat, 17 Sep 2016 03:59:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 273AC29FE7 for ; Sat, 17 Sep 2016 03:59:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C23E29FEF; Sat, 17 Sep 2016 03:59:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E526129FE9 for ; Sat, 17 Sep 2016 03:59:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932785AbcIQD7a (ORCPT ); Fri, 16 Sep 2016 23:59:30 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:32804 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933696AbcIQD72 (ORCPT ); Fri, 16 Sep 2016 23:59:28 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8H3xPKH005156 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 17 Sep 2016 03:59:25 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u8H3xPl8017766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 17 Sep 2016 03:59:25 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u8H3xN6u022996; Sat, 17 Sep 2016 03:59:25 GMT Received: from abi.no.oracle.com (/10.172.144.123) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 16 Sep 2016 20:59:23 -0700 From: Knut Omang To: Doug Ledford Cc: linux-rdma@vger.kernel.org, Mukesh Kacker , Knut Omang Subject: [PATCH libibverbs v2 1/3] Add new call ibv_cmd_create_ah_ex which supports extra parameters Date: Sat, 17 Sep 2016 05:59:11 +0200 Message-Id: <5cc0157c0f05701d8cb1334e6ee11e1e7be6fa24.1474063039.git-series.knut.omang@oracle.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: References: X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The original call ibv_cmd_create_ah does not allow vendor specific request or response parameters to be defined and passed through to kernel space. To keep backward compatibility, introduce a new extended call which accepts cmd and resp parameters similar to other parts of the API. Reimplement the old call to just use the new extended call. The new call is versioned in the shared library as IBVERBS_1.3 to leave room for a 1.2 that should have been added for other changes. Signed-off-by: Knut Omang Reviewed-by: Mukesh Kacker --- include/infiniband/driver.h | 4 +++- src/cmd.c | 50 +++++++++++++++++++++----------------- src/libibverbs.map | 4 +++- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/include/infiniband/driver.h b/include/infiniband/driver.h index 65fa44f..c46c55f 100644 --- a/include/infiniband/driver.h +++ b/include/infiniband/driver.h @@ -229,6 +229,10 @@ int ibv_cmd_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr, struct ibv_recv_wr **bad_wr); int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah, struct ibv_ah_attr *attr); +int ibv_cmd_create_ah_ex(struct ibv_pd *pd, struct ibv_ah *ah, + struct ibv_ah_attr *attr, + struct ibv_create_ah *cmd, size_t cmd_size, + struct ibv_create_ah_resp *resp, size_t resp_size); int ibv_cmd_destroy_ah(struct ibv_ah *ah); int ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); diff --git a/src/cmd.c b/src/cmd.c index cb9e34c..12d8640 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1463,38 +1463,44 @@ int ibv_cmd_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr, return ret; } -int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah, - struct ibv_ah_attr *attr) +int ibv_cmd_create_ah_ex(struct ibv_pd *pd, struct ibv_ah *ah, struct ibv_ah_attr *attr, + struct ibv_create_ah *cmd, size_t cmd_size, + struct ibv_create_ah_resp *resp, size_t resp_size) { - struct ibv_create_ah cmd; - struct ibv_create_ah_resp resp; - - IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_AH, &resp, sizeof resp); - cmd.user_handle = (uintptr_t) ah; - cmd.pd_handle = pd->handle; - cmd.attr.dlid = attr->dlid; - cmd.attr.sl = attr->sl; - cmd.attr.src_path_bits = attr->src_path_bits; - cmd.attr.static_rate = attr->static_rate; - cmd.attr.is_global = attr->is_global; - cmd.attr.port_num = attr->port_num; - cmd.attr.grh.flow_label = attr->grh.flow_label; - cmd.attr.grh.sgid_index = attr->grh.sgid_index; - cmd.attr.grh.hop_limit = attr->grh.hop_limit; - cmd.attr.grh.traffic_class = attr->grh.traffic_class; - memcpy(cmd.attr.grh.dgid, attr->grh.dgid.raw, 16); + IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_AH, resp, resp_size); + cmd->user_handle = (uintptr_t) ah; + cmd->pd_handle = pd->handle; + cmd->attr.dlid = attr->dlid; + cmd->attr.sl = attr->sl; + cmd->attr.src_path_bits = attr->src_path_bits; + cmd->attr.static_rate = attr->static_rate; + cmd->attr.is_global = attr->is_global; + cmd->attr.port_num = attr->port_num; + cmd->attr.grh.flow_label = attr->grh.flow_label; + cmd->attr.grh.sgid_index = attr->grh.sgid_index; + cmd->attr.grh.hop_limit = attr->grh.hop_limit; + cmd->attr.grh.traffic_class = attr->grh.traffic_class; + memcpy(cmd->attr.grh.dgid, attr->grh.dgid.raw, 16); - if (write(pd->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) + if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size) return errno; - (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); + (void) VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp); - ah->handle = resp.handle; + ah->handle = resp->handle; ah->context = pd->context; return 0; } +int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah, + struct ibv_ah_attr *attr) +{ + struct ibv_create_ah cmd; + struct ibv_create_ah_resp resp; + return ibv_cmd_create_ah_ex(pd, ah, attr, &cmd, sizeof(cmd), &resp, sizeof(resp)); +} + int ibv_cmd_destroy_ah(struct ibv_ah *ah) { struct ibv_destroy_ah cmd; diff --git a/src/libibverbs.map b/src/libibverbs.map index 5134bd9..e327a84 100644 --- a/src/libibverbs.map +++ b/src/libibverbs.map @@ -118,5 +118,9 @@ IBVERBS_1.1 { ibv_cmd_create_qp_ex2; ibv_cmd_open_qp; ibv_cmd_rereg_mr; +}; +IBVERBS_1.3 { + global: + ibv_cmd_create_ah_ex; } IBVERBS_1.0;