From patchwork Wed Mar 14 20:39:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10283547 X-Patchwork-Delegate: jgg@ziepe.ca 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 93C1260621 for ; Wed, 14 Mar 2018 20:39:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 808A82848B for ; Wed, 14 Mar 2018 20:39:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74A5228515; Wed, 14 Mar 2018 20:39:57 +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 0947C2848B for ; Wed, 14 Mar 2018 20:39:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751835AbeCNUjy (ORCPT ); Wed, 14 Mar 2018 16:39:54 -0400 Received: from mail-he1eur01on0058.outbound.protection.outlook.com ([104.47.0.58]:12560 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751806AbeCNUjx (ORCPT ); Wed, 14 Mar 2018 16:39:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ZZ5iwo9pbnYYBIbgpJVCQG71dczIORzX477rFrBYsqk=; b=tqXC07eD2mb+SWlcLHnxdBmqP5X7HpR713lWYTugUxDmj+FP1i+vXDv9L0rXLQ/edXDAJ+RpO3PfjBBsE1BlmmgNKpYq7mafVFOlZfqbGDnSexd41fGtvk4LDR2twChjAeFhJqfKN7Rvx1t+K7pk5KUcIX6jQw1y2V7+W1sYoCk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jgg@mellanox.com; Received: from mlx.ziepe.ca (174.3.196.123) by HE1PR0501MB2859.eurprd05.prod.outlook.com (2603:10a6:3:c2::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Wed, 14 Mar 2018 20:39:49 +0000 Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1ewDBW-0001ir-NJ; Wed, 14 Mar 2018 14:39:42 -0600 Date: Wed, 14 Mar 2018 14:39:42 -0600 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org, Yixian Liu Cc: Lijun Ou , Wei Hu Subject: [PATCH] RDMA/hns: Use structs to describe the uABI instead of opencoding Message-ID: <20180314203942.GA6563@ziepe.ca> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [174.3.196.123] X-ClientProxiedBy: HE1PR07CA0003.eurprd07.prod.outlook.com (2603:10a6:7:67::13) To HE1PR0501MB2859.eurprd05.prod.outlook.com (2603:10a6:3:c2::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: de487025-35a9-45e8-ff9e-08d589ebbb8e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:HE1PR0501MB2859; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2859; 3:flcxiyTkjjhe6Vn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e5mfqtAa/FeTm0j7W7U8p3KzeWBiWoYkCCLV9XUsvMwloyn98w3wVHwFt5uc0/Xf+ti6cAIO0hPymjRc0M9he65q+TQ02r2gplX8bBVl4MNHhyhoJym5316zDZEIauo5eF1MdqWZ3nFy/zXPx03PjcNsZTnQugmHhyMXDyzQorPazlS+VgZCAH7DYCq+OotAEZhS//UVIGIGfakyt0bdKhS4xB1dLgPzJ4vQdcquh/uPBLOJVwLjmOSNPp5h5Kx9+Rp/ZpsZI+TTESJAvBv34b5aH+jrTYTlYzrFZzaFq+/17JqHLsQkbGvUpLm74glhhFQJjgilhXAQhO+WkV/P/2XIHFvmkHfZ/8; 4:0i2MQ6fOqm955DYQKE2+VJEAz2Zt62983jXWxNwFzA3zOugAR44aFMU+aMrRMFGRREfLcnC+7qd6KTSoUP3okIWbsG0jyHW6D5QklQc9W8YDwOCHhoa1GPEVGCQW53DFfqaoG62Sd7W12tLIgmCUqS0XhKe8Vkegi+RmklR6wMvm5ZH0BIGewaln9FAMKRlYJ8rqwlCPtz/bMoyCCpSUpL5OE5n1o1nVzstAVaJJuKfiQF1X3/1BAzPPkVm4ego2o+Ex/jzZNxYV+VTstPBKCA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231221)(944501244)(52105095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:HE1PR0501MB2859; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0501MB2859; X-Forefront-PRVS: 0611A21987 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39850400004)(346002)(376002)(396003)(39380400002)(189003)(199004)(106356001)(81156014)(478600001)(33896004)(81166006)(53936002)(26005)(16586007)(52116002)(386003)(8936002)(8676002)(105586002)(23726003)(122856001)(2906002)(4326008)(33656002)(86362001)(47776003)(59450400001)(68736007)(6916009)(6116002)(186003)(46656002)(3846002)(9746002)(66066001)(7736002)(69596002)(36756003)(9786002)(1076002)(316002)(57986006)(83796002)(5660300001)(1857600001)(50466002)(54906003)(305945005)(9686003)(58126008)(97736004)(18370500001)(24400500001)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0501MB2859; H:mlx.ziepe.ca; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0501MB2859; 23:bp1MKtqDQtloIKU7rD4ySC7V+zxWmEIyNghGGHP?= =?us-ascii?Q?5AtRETs/lDQk6BIlg6GzvLirWcUAwRB2Aji6/TdVTg37RV91ywxHnHRTEr50?= =?us-ascii?Q?nX89xcUjOhTLJ4xXz5mufIDhl1yMQ7adQprfHoG+iv3GcDO96MK1Z+INv6ht?= =?us-ascii?Q?/vyCNWQ98DRKr5JMxpiayD0ltvFZO4ns6wa1nPDOdhCABDf79mJF3UFr45Bf?= =?us-ascii?Q?615QNS3dzhe35nwacBOI/so+rbOpNb/t7U3Xkdc2DKZP+RblzkH2InCAbCip?= =?us-ascii?Q?93PS6k7+iEG6d+j7l4pd3e0tZLzdyWRmIpF5Sef9TiYS0DyzQ5nfOmvB/U+m?= =?us-ascii?Q?axhukt63DnjywvN3UAJtyrV1VOriXY0h7TPMeZeZI04kL51Tyrj+Sj8ob1V9?= =?us-ascii?Q?ZKDTd9m1f7hvPwZ3wW/GiIm7+AndGI8j1MXCu7ITylE+cwIN1NyqOBoE7jl7?= =?us-ascii?Q?BRhYSVz1+2t+jXiPGI/xdTN4wRgy/jJ9XYYaaPrWuFAitYXNkJhdARrA57Ct?= =?us-ascii?Q?HKlnqEm5avXaoiZrcY18RXdQPETPS8nrlzOyehk8RFq1zHjFb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exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2018 20:39:49.7949 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de487025-35a9-45e8-ff9e-08d589ebbb8e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2859 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 Open coding a loose value size is not acceptable for describing the uABI in RDMA. Provide the missing struct. Signed-off-by: Jason Gunthorpe --- drivers/infiniband/hw/hns/hns_roce_pd.c | 5 ++++- include/uapi/rdma/hns-abi.h | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) hns team: This patch goes along with the remarks in my prior email, structs should always be used with hns_roce_ib_alloc_pd_resp. Please ensure whatever you come up with follows that principle. Thanks, Jason diff --git a/drivers/infiniband/hw/hns/hns_roce_pd.c b/drivers/infiniband/hw/hns/hns_roce_pd.c index bdab2188c04a9a..4b41e041799cae 100644 --- a/drivers/infiniband/hw/hns/hns_roce_pd.c +++ b/drivers/infiniband/hw/hns/hns_roce_pd.c @@ -32,6 +32,7 @@ #include #include +#include #include "hns_roce_device.h" static int hns_roce_pd_alloc(struct hns_roce_dev *hr_dev, unsigned long *pdn) @@ -77,7 +78,9 @@ struct ib_pd *hns_roce_alloc_pd(struct ib_device *ib_dev, } if (context) { - if (ib_copy_to_udata(udata, &pd->pdn, sizeof(u64))) { + struct hns_roce_ib_alloc_pd_resp uresp = {.pdn = pd->pdn}; + + if (ib_copy_to_udata(udata, &uresp, sizeof(uresp))) { hns_roce_pd_free(to_hr_dev(ib_dev), pd->pdn); dev_err(dev, "[alloc_pd]ib_copy_to_udata failed!\n"); kfree(pd); diff --git a/include/uapi/rdma/hns-abi.h b/include/uapi/rdma/hns-abi.h index 4df5b79c9e11a3..a464d7945ebb48 100644 --- a/include/uapi/rdma/hns-abi.h +++ b/include/uapi/rdma/hns-abi.h @@ -64,4 +64,9 @@ struct hns_roce_ib_alloc_ucontext_resp { __u32 qp_tab_size; __u32 reserved; }; + +struct hns_roce_ib_alloc_pd_resp { + __u32 pdn; +}; + #endif /* HNS_ABI_USER_H */