From patchwork Tue Mar 13 22:07:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10281035 X-Patchwork-Delegate: sean.hefty@intel.com 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 3361F602BD for ; Tue, 13 Mar 2018 22:07:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C6F62580E for ; Tue, 13 Mar 2018 22:07:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 110B72807B; Tue, 13 Mar 2018 22:07:54 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 6FE712848B for ; Tue, 13 Mar 2018 22:07:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752402AbeCMWHv (ORCPT ); Tue, 13 Mar 2018 18:07:51 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:38133 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752054AbeCMWHs (ORCPT ); Tue, 13 Mar 2018 18:07:48 -0400 Received: by mail-pf0-f193.google.com with SMTP id d26so500480pfn.5 for ; Tue, 13 Mar 2018 15:07:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OR9A0ExUY4a1FrrB+twawMg2WoNcxo8d/jsv3+m40Js=; b=M4B6sElihJK6oER1K8a9fO0du/TgLMVphFt63dMR9eBb4EPXBEArIA3mRRlSG/RJlN +CNXsjwUKhcXqWkK/d/m2NDogD0mdwpa1g/G9PxIQKoNdY96ils2W1aYn/W0NMO1e9gD GGEL0OrUFHItHZqxZOCISBvWJCFqlr4ijt+W0l1s/XRt9KzBr+wXkt7V48vOiFrfpLPE 2Q4AbdYF32ruYehH+iQL9XBhi3G8ymcKANa16/BCIrEQWd1YZrNiRBWayfIUsaG0cliz 0+59Ex5zSjrjLFeZvY5ymfwB56F394M940s7ISYxkoQvsLDkIEaGQDcUTeYzgFmWCflq zgHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OR9A0ExUY4a1FrrB+twawMg2WoNcxo8d/jsv3+m40Js=; b=h/QkcVyOTxGEHu7l5SHf/cXqWFMyUti7SjcQ88LdGYSTcdTflmi0YB5MhWtSFm85c+ ExGmUOo2IoRsSrQJqftpDy+rnIIgCXhzsOKzF5zCJn77e/jIbGFRkiueUECnp4SUe/5+ Uq7nppEbxympgUf65twdvyi7d0V94wK8omtiPgQBdp7+7xAfzQvceThubAih5YCnJZd5 rU2rGg1QmWyZg+pu1rUKzir3LcxknOrAVilUHbAQFRgqrtB13ueYTPcN9ZrzakgII+di GsjkTSdE2IxZ3uNHKFjqSGBBeTrOMIaBHt8oejoxj6FSnFHL6243Lrvu5gWL/HxTe/6y RPZQ== X-Gm-Message-State: AElRT7E6huuD2tQ05jt9oYnNHugUEgZq9xIZ6i9U0/xlIDjfZNiqi0C3 C6i86CKd0CCp0ADVNqbXVgxUvjNKBZs= X-Google-Smtp-Source: AG47ELvjjHXuIW5OJq6w53ri/UjVN9Pk2GkCZkXw7LpO5ajFtf08YCsW/om9Q+E2RqXUraEZx6ak9Q== X-Received: by 10.99.120.197 with SMTP id t188mr1742388pgc.358.1520978867587; Tue, 13 Mar 2018 15:07:47 -0700 (PDT) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id n7sm1645440pgd.87.2018.03.13.15.07.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 15:07:44 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1evs57-0001BM-A4; Tue, 13 Mar 2018 16:07:41 -0600 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Cc: Jason Gunthorpe Subject: [PATCH rdma-core 8/8] verbs: Use kabi for create_qp Date: Tue, 13 Mar 2018 16:07:37 -0600 Message-Id: <20180313220737.4336-9-jgg@ziepe.ca> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180313220737.4336-1-jgg@ziepe.ca> References: <20180313220737.4336-1-jgg@ziepe.ca> 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 From: Jason Gunthorpe Instead of creating a dummy structure in kern-abi.h, just use the normal command structure provided by the kernel with some simple container_of help. Signed-off-by: Jason Gunthorpe --- libibverbs/cmd.c | 13 ++++++------ libibverbs/kern-abi.h | 54 ++++++++++++++++++-------------------------------- providers/mlx4/verbs.c | 5 +---- providers/mlx5/verbs.c | 5 +---- 4 files changed, 28 insertions(+), 49 deletions(-) diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index e30603dd5d4194..36d62eb09ad107 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -781,7 +781,7 @@ int ibv_cmd_destroy_srq(struct ibv_srq *srq) static int create_qp_ex_common(struct verbs_qp *qp, struct ibv_qp_init_attr_ex *qp_attr, struct verbs_xrcd *vxrcd, - struct ibv_create_qp_common *cmd) + struct ib_uverbs_create_qp *cmd) { cmd->user_handle = (uintptr_t)qp; @@ -896,7 +896,8 @@ int ibv_cmd_create_qp_ex2(struct ibv_context *context, IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size, CREATE_QP, resp, resp_core_size, resp_size); - err = create_qp_ex_common(qp, qp_attr, vxrcd, &cmd->base); + err = create_qp_ex_common(qp, qp_attr, vxrcd, + ibv_create_cq_ex_to_reg(cmd)); if (err) return err; @@ -913,10 +914,10 @@ int ibv_cmd_create_qp_ex2(struct ibv_context *context, } if (qp_attr->comp_mask & IBV_QP_INIT_ATTR_IND_TABLE) { - if (cmd_core_size < offsetof(struct ibv_create_qp_ex, ind_tbl_handle) + - sizeof(cmd->ind_tbl_handle)) + if (cmd_core_size < offsetof(struct ibv_create_qp_ex, rwq_ind_tbl_handle) + + sizeof(cmd->rwq_ind_tbl_handle)) return EINVAL; - cmd->ind_tbl_handle = qp_attr->rwq_ind_tbl->ind_tbl_handle; + cmd->rwq_ind_tbl_handle = qp_attr->rwq_ind_tbl->ind_tbl_handle; cmd->comp_mask = IB_UVERBS_CREATE_QP_MASK_IND_TABLE; } @@ -947,7 +948,7 @@ int ibv_cmd_create_qp_ex(struct ibv_context *context, return ENOSYS; err = create_qp_ex_common(qp, attr_ex, vxrcd, - (struct ibv_create_qp_common *)&cmd->user_handle); + &cmd->core_payload); if (err) return err; diff --git a/libibverbs/kern-abi.h b/libibverbs/kern-abi.h index 26bdf19d616b5a..157f64f649af09 100644 --- a/libibverbs/kern-abi.h +++ b/libibverbs/kern-abi.h @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -170,6 +171,7 @@ DECLARE_CMDX(IB_USER_VERBS_CMD_CLOSE_XRCD, ibv_close_xrcd, ib_uverbs_close_xrcd, DECLARE_CMD(IB_USER_VERBS_CMD_CREATE_AH, ibv_create_ah, ib_uverbs_create_ah); DECLARE_CMD(IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL, ibv_create_comp_channel, ib_uverbs_create_comp_channel); DECLARE_CMD(IB_USER_VERBS_CMD_CREATE_CQ, ibv_create_cq, ib_uverbs_create_cq); +DECLARE_CMD(IB_USER_VERBS_CMD_CREATE_QP, ibv_create_qp, ib_uverbs_create_qp); DECLARE_CMD(IB_USER_VERBS_CMD_CREATE_SRQ, ibv_create_srq, ib_uverbs_create_srq); DECLARE_CMDX(IB_USER_VERBS_CMD_CREATE_XSRQ, ibv_create_xsrq, ib_uverbs_create_xsrq, ib_uverbs_create_srq_resp); DECLARE_CMDX(IB_USER_VERBS_CMD_DEALLOC_MW, ibv_dealloc_mw, ib_uverbs_dealloc_mw, empty); @@ -200,6 +202,7 @@ DECLARE_CMD(IB_USER_VERBS_CMD_RESIZE_CQ, ibv_resize_cq, ib_uverbs_resize_cq); DECLARE_CMD_EX(IB_USER_VERBS_EX_CMD_CREATE_CQ, ibv_create_cq_ex, ib_uverbs_ex_create_cq); DECLARE_CMD_EX(IB_USER_VERBS_EX_CMD_CREATE_FLOW, ibv_create_flow, ib_uverbs_create_flow); +DECLARE_CMD_EX(IB_USER_VERBS_EX_CMD_CREATE_QP, ibv_create_qp_ex, ib_uverbs_ex_create_qp); DECLARE_CMD_EX(IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL, ibv_create_rwq_ind_table, ib_uverbs_ex_create_rwq_ind_table); DECLARE_CMD_EX(IB_USER_VERBS_EX_CMD_CREATE_WQ, ibv_create_wq, ib_uverbs_ex_create_wq); DECLARE_CMD_EXX(IB_USER_VERBS_EX_CMD_DESTROY_FLOW, ibv_destroy_flow, ib_uverbs_destroy_flow, empty); @@ -210,6 +213,22 @@ DECLARE_CMD_EX(IB_USER_VERBS_EX_CMD_MODIFY_QP, ibv_modify_qp_ex, ib_uverbs_ex_mo DECLARE_CMD_EXX(IB_USER_VERBS_EX_CMD_MODIFY_WQ, ibv_modify_wq, ib_uverbs_ex_modify_wq, empty); DECLARE_CMD_EX(IB_USER_VERBS_EX_CMD_QUERY_DEVICE, ibv_query_device_ex, ib_uverbs_ex_query_device); +/* + * Both ib_uverbs_create_qp and ib_uverbs_ex_create_qp start with the same + * structure, this function converts the ex version into the normal version + */ +static inline struct ib_uverbs_create_qp * +ibv_create_cq_ex_to_reg(struct ibv_create_qp_ex *cmd_ex) +{ + /* + * user_handle is the start in both places, note that the ex + * does not have response located in the same place, so response + * cannot be touched. + */ + return container_of(&cmd_ex->user_handle, struct ib_uverbs_create_qp, + user_handle); +} + /* * This file contains copied data from the kernel's include/uapi/rdma/ib_user_verbs.h, * now included above. @@ -218,41 +237,6 @@ DECLARE_CMD_EX(IB_USER_VERBS_EX_CMD_QUERY_DEVICE, ibv_query_device_ex, ib_uverbs * copying from that header into this file. */ -#define IBV_CREATE_QP_COMMON \ - __u64 user_handle; \ - __u32 pd_handle; \ - __u32 send_cq_handle; \ - __u32 recv_cq_handle; \ - __u32 srq_handle; \ - __u32 max_send_wr; \ - __u32 max_recv_wr; \ - __u32 max_send_sge; \ - __u32 max_recv_sge; \ - __u32 max_inline_data; \ - __u8 sq_sig_all; \ - __u8 qp_type; \ - __u8 is_srq; \ - __u8 reserved - -struct ibv_create_qp { - struct ib_uverbs_cmd_hdr hdr; - __u64 response; - IBV_CREATE_QP_COMMON; -}; - -struct ibv_create_qp_common { - IBV_CREATE_QP_COMMON; -}; - -struct ibv_create_qp_ex { - struct ex_hdr hdr; - struct ibv_create_qp_common base; - __u32 comp_mask; - __u32 create_flags; - __u32 ind_tbl_handle; - __u32 source_qpn; -}; - struct ibv_kern_ipv4_filter { __u32 src_ip; __u32 dst_ip; diff --git a/providers/mlx4/verbs.c b/providers/mlx4/verbs.c index 3daa025cff78c2..9d8d3403bb6394 100644 --- a/providers/mlx4/verbs.c +++ b/providers/mlx4/verbs.c @@ -831,10 +831,7 @@ static int mlx4_cmd_create_qp_ex(struct ibv_context *context, int ret; memset(&cmd_ex, 0, sizeof(cmd_ex)); - memcpy(&cmd_ex.ibv_cmd.base, &cmd->ibv_cmd.user_handle, - offsetof(typeof(cmd->ibv_cmd), is_srq) + - sizeof(cmd->ibv_cmd.is_srq) - - offsetof(typeof(cmd->ibv_cmd), user_handle)); + *ibv_create_cq_ex_to_reg(&cmd_ex.ibv_cmd) = cmd->ibv_cmd.core_payload; memcpy(&cmd_ex.drv_ex, &cmd->buf_addr, offsetof(typeof(*cmd), sq_no_prefetch) + diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index cab65478bbe597..082149e4fb35f3 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -1466,10 +1466,7 @@ static int mlx5_cmd_create_qp_ex(struct ibv_context *context, int ret; memset(&cmd_ex, 0, sizeof(cmd_ex)); - memcpy(&cmd_ex.ibv_cmd.base, &cmd->ibv_cmd.user_handle, - offsetof(typeof(cmd->ibv_cmd), is_srq) + - sizeof(cmd->ibv_cmd.is_srq) - - offsetof(typeof(cmd->ibv_cmd), user_handle)); + *ibv_create_cq_ex_to_reg(&cmd_ex.ibv_cmd) = cmd->ibv_cmd.core_payload; memcpy(&cmd_ex.drv_ex, &cmd->buf_addr, offsetof(typeof(*cmd), sq_buf_addr) +