From patchwork Thu Jan 11 22:13:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10158817 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 6FF7B60170 for ; Thu, 11 Jan 2018 22:30:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AF53289C9 for ; Thu, 11 Jan 2018 22:30:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 591BB289CE; Thu, 11 Jan 2018 22:30:39 +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 1FD84289C9 for ; Thu, 11 Jan 2018 22:30:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933357AbeAKWaY (ORCPT ); Thu, 11 Jan 2018 17:30:24 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37125 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933287AbeAKWaX (ORCPT ); Thu, 11 Jan 2018 17:30:23 -0500 Received: by mail-wm0-f67.google.com with SMTP id f140so8276548wmd.2 for ; Thu, 11 Jan 2018 14:30:23 -0800 (PST) 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=a23kQNo5lhf1D1DWa3BbQuQqR37zE+R4FHm7voKJCPI=; b=PLAMGdPmoCAeS8aFVnNTcW9hhTq4ohx9XT4jZYjWvj9CtGa7+sIGAK2NBtUBY6Ok+9 z4hLzGAXGtSm/Gyn9aNU+f2pod0z7XCRcHSYxEwXIQPbjbGWkUt8IBE0bq+7FTL100xG YKZo4mAkJuaGglUqQSkSFBhjFVkVM3P7P89D7GMsSkeY3N7KeQBzZqppjqjWGZnJdVup +L0sdFrC7nC0Zf5dgkLXgQUaLPoYzZYO7D0DKyzlWHMVwLaANKqqiDSRRyBhe+aZ9mM2 vst7ZfgXLNT0j6edk6GF0xXQy1G/dtShusMIS4BVW2POQUN1FiIqOfH+WOEVJN579otz 1e1g== 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=a23kQNo5lhf1D1DWa3BbQuQqR37zE+R4FHm7voKJCPI=; b=AV6dolH/+3CJtPrbA287ZU49pELFtEq4XB7gyDipyE6Qnsn/zt+G2TX0wwj5fcSViU Af525CbBdaxJzVYY90GwrBASBZcKZGpVqJAc3VmtSNmgL5wAbZeUZnBeLme/wqOwGk+z am/yrVOGK1S6ioZj+hneVlIVYae+Ms9YBNj1oo3dUGXkUyXdMjAPBn5/b8x2YZLSDtTD sYQLAX2UzWQFKzQyFrdU55OEdgiKmtBLyAjx9jh7VEcYzRMOOyQqUTIBsP+VAxIyYrKn UUFYbU19jcK4lqwRDLU4s8t8gMT/On1Xf961HJNJE1NZ3/JSXk0bcdMwJzqZzyaxUtSF NxrQ== X-Gm-Message-State: AKwxytf18g1FjPAGGRq2cABYCqEzzQqBYlFw8wBeNvjtj+U8NJW9WXB5 iIHeZhvYZA2IHYQt69JZ65RZHZSYWvI= X-Google-Smtp-Source: ACJfBov0pdDf7LOvt1M+i1RhkKG+3DVoOcAZXlZcgwmf6SU2EiCA/6yNN7Q8DdJv4q32ewhAbI7BKw== X-Received: by 10.28.230.199 with SMTP id e68mr2322867wmi.134.1515709822108; Thu, 11 Jan 2018 14:30:22 -0800 (PST) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [70.74.179.152]) by smtp.gmail.com with ESMTPSA id l72sm3737516wmi.4.2018.01.11.14.30.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jan 2018 14:30:21 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1eZl6Z-0000Kf-9l; Thu, 11 Jan 2018 15:13:47 -0700 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Cc: Jason Gunthorpe Subject: [PATCH rdma-core 17/17] verbs: Tidy up the remaining structs in kern-abi.h Date: Thu, 11 Jan 2018 15:13:40 -0700 Message-Id: <20180111221340.965-18-jgg@ziepe.ca> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180111221340.965-1-jgg@ziepe.ca> References: <20180111221340.965-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 These are almost now all the manual wrapper structs around the kernel ABI struct. - Include the header using struct ib_uverbs_cmd_hdr and revise the macros to use it - Delete driver_data[0] VLA. The driver data following the command data is implied for all commands. Signed-off-by: Jason Gunthorpe --- libibverbs/cmd.c | 2 +- libibverbs/ibverbs.h | 12 ++-- libibverbs/kern-abi.h | 164 +++++++++++--------------------------------------- providers/rxe/rxe.c | 6 +- 4 files changed, 46 insertions(+), 138 deletions(-) diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index 0e1589e1c8963e..b89b1bdd366bc6 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -793,7 +793,7 @@ static int ibv_cmd_modify_srq_v3(struct ibv_srq *srq, cmd_size = sizeof *cmd + new_cmd_size - sizeof *new_cmd; cmd = alloca(cmd_size); - memcpy(cmd->driver_data, new_cmd->driver_data, new_cmd_size - sizeof *new_cmd); + memcpy(cmd + 1, new_cmd + 1, new_cmd_size - sizeof *new_cmd); IBV_INIT_CMD(cmd, cmd_size, MODIFY_SRQ); diff --git a/libibverbs/ibverbs.h b/libibverbs/ibverbs.h index ceb6c5bfd4e3f9..7238d79168733f 100644 --- a/libibverbs/ibverbs.h +++ b/libibverbs/ibverbs.h @@ -64,16 +64,16 @@ struct verbs_ex_private { #define IBV_INIT_CMD(cmd, size, opcode) \ do { \ - (cmd)->command = IB_USER_VERBS_CMD_##opcode; \ - (cmd)->in_words = (size) / 4; \ - (cmd)->out_words = 0; \ + (cmd)->hdr.command = IB_USER_VERBS_CMD_##opcode; \ + (cmd)->hdr.in_words = (size) / 4; \ + (cmd)->hdr.out_words = 0; \ } while (0) #define IBV_INIT_CMD_RESP(cmd, size, opcode, out, outsize) \ do { \ - (cmd)->command = IB_USER_VERBS_CMD_##opcode; \ - (cmd)->in_words = (size) / 4; \ - (cmd)->out_words = (outsize) / 4; \ + (cmd)->hdr.command = IB_USER_VERBS_CMD_##opcode; \ + (cmd)->hdr.in_words = (size) / 4; \ + (cmd)->hdr.out_words = (outsize) / 4; \ (cmd)->response = (uintptr_t) (out); \ } while (0) diff --git a/libibverbs/kern-abi.h b/libibverbs/kern-abi.h index ca7ba14dfdb580..8e264b00db46b5 100644 --- a/libibverbs/kern-abi.h +++ b/libibverbs/kern-abi.h @@ -78,19 +78,13 @@ struct ex_hdr { */ struct ibv_get_context { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; - __u64 driver_data[0]; }; struct ibv_query_device { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; - __u64 driver_data[0]; }; struct ibv_query_device_ex { @@ -100,64 +94,46 @@ struct ibv_query_device_ex { }; struct ibv_query_port { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u8 port_num; __u8 reserved[7]; - __u64 driver_data[0]; }; struct ibv_alloc_pd { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; - __u64 driver_data[0]; }; struct ibv_dealloc_pd { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u32 pd_handle; }; struct ibv_open_xrcd { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u32 fd; __u32 oflags; - __u64 driver_data[0]; }; struct ibv_close_xrcd { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u32 xrcd_handle; }; struct ibv_reg_mr { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u64 start; __u64 length; __u64 hca_va; __u32 pd_handle; __u32 access_flags; - __u64 driver_data[0]; }; struct ibv_rereg_mr { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u32 mr_handle; __u32 flags; @@ -166,20 +142,15 @@ struct ibv_rereg_mr { __u64 hca_va; __u32 pd_handle; __u32 access_flags; - __u64 driver_data[0]; }; struct ibv_dereg_mr { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u32 mr_handle; }; struct ibv_alloc_mw { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u32 pd_handle; __u8 mw_type; @@ -187,31 +158,24 @@ struct ibv_alloc_mw { }; struct ibv_dealloc_mw { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u32 mw_handle; __u32 reserved; }; struct ibv_create_comp_channel { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; }; struct ibv_create_cq { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u64 user_handle; __u32 cqe; __u32 comp_vector; __s32 comp_channel; __u32 reserved; - __u64 driver_data[0]; }; enum ibv_create_cq_ex_kernel_flags { @@ -230,36 +194,27 @@ struct ibv_create_cq_ex { }; struct ibv_poll_cq { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u32 cq_handle; __u32 ne; }; struct ibv_req_notify_cq { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u32 cq_handle; __u32 solicited; }; struct ibv_resize_cq { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u32 cq_handle; __u32 cqe; - __u64 driver_data[0]; }; struct ibv_destroy_cq { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u32 cq_handle; __u32 reserved; @@ -282,12 +237,9 @@ struct ibv_destroy_cq { __u8 reserved struct ibv_create_qp { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; IBV_CREATE_QP_COMMON; - __u64 driver_data[0]; }; struct ibv_create_qp_common { @@ -295,16 +247,13 @@ struct ibv_create_qp_common { }; struct ibv_open_qp { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u64 user_handle; __u32 pd_handle; __u32 qpn; __u8 qp_type; __u8 reserved[7]; - __u64 driver_data[0]; }; struct ibv_create_qp_ex { @@ -317,21 +266,15 @@ struct ibv_create_qp_ex { }; struct ibv_query_qp { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u32 qp_handle; __u32 attr_mask; - __u64 driver_data[0]; }; struct ibv_modify_qp { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; struct ib_uverbs_modify_qp base; - __u64 driver_data[0]; }; struct ibv_modify_qp_ex { @@ -342,9 +285,7 @@ struct ibv_modify_qp_ex { }; struct ibv_destroy_qp { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u32 qp_handle; __u32 reserved; @@ -378,9 +319,7 @@ struct ibv_kern_spec { }; struct ibv_post_send { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u32 qp_handle; __u32 wr_count; @@ -390,9 +329,7 @@ struct ibv_post_send { }; struct ibv_post_recv { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u32 qp_handle; __u32 wr_count; @@ -402,9 +339,7 @@ struct ibv_post_recv { }; struct ibv_post_srq_recv { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u32 srq_handle; __u32 wr_count; @@ -414,9 +349,7 @@ struct ibv_post_srq_recv { }; struct ibv_create_ah { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u64 user_handle; __u32 pd_handle; @@ -425,21 +358,16 @@ struct ibv_create_ah { }; struct ibv_destroy_ah { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u32 ah_handle; }; struct ibv_attach_mcast { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u8 gid[16]; __u32 qp_handle; __u16 mlid; __u16 reserved; - __u64 driver_data[0]; }; struct ibv_create_flow { @@ -456,33 +384,25 @@ struct ibv_destroy_flow { }; struct ibv_detach_mcast { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u8 gid[16]; __u32 qp_handle; __u16 mlid; __u16 reserved; - __u64 driver_data[0]; }; struct ibv_create_srq { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u64 user_handle; __u32 pd_handle; __u32 max_wr; __u32 max_sge; __u32 srq_limit; - __u64 driver_data[0]; }; struct ibv_create_xsrq { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u64 user_handle; __u32 srq_type; @@ -493,50 +413,38 @@ struct ibv_create_xsrq { __u32 max_num_tags; __u32 xrcd_handle; __u32 cq_handle; - __u64 driver_data[0]; }; struct ibv_modify_srq { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u32 srq_handle; __u32 attr_mask; __u32 max_wr; __u32 srq_limit; - __u64 driver_data[0]; }; struct ibv_query_srq { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u32 srq_handle; __u32 reserved; - __u64 driver_data[0]; }; struct ibv_destroy_srq { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u64 response; __u32 srq_handle; __u32 reserved; }; struct ibv_modify_srq_v3 { - __u32 command; - __u16 in_words; - __u16 out_words; + struct ib_uverbs_cmd_hdr hdr; __u32 srq_handle; __u32 attr_mask; __u32 max_wr; __u32 max_sge; __u32 srq_limit; __u32 reserved; - __u64 driver_data[0]; }; struct ibv_create_qp_resp_v3 { diff --git a/providers/rxe/rxe.c b/providers/rxe/rxe.c index c6ec95c2bcf80d..5978df3abfa7b5 100644 --- a/providers/rxe/rxe.c +++ b/providers/rxe/rxe.c @@ -672,9 +672,9 @@ static int post_send_db(struct ibv_qp *ibqp) struct ibv_post_send cmd; struct ib_uverbs_post_send_resp resp; - cmd.command = IB_USER_VERBS_CMD_POST_SEND; - cmd.in_words = sizeof(cmd)/4; - cmd.out_words = sizeof(resp)/4; + cmd.hdr.command = IB_USER_VERBS_CMD_POST_SEND; + cmd.hdr.in_words = sizeof(cmd) / 4; + cmd.hdr.out_words = sizeof(resp) / 4; cmd.response = (uintptr_t)&resp; cmd.qp_handle = ibqp->handle; cmd.wr_count = 0;