From patchwork Sun Mar 11 16:35:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Barak X-Patchwork-Id: 10274851 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 DB46C602BD for ; Sun, 11 Mar 2018 16:35:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA33D28D58 for ; Sun, 11 Mar 2018 16:35:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA03528D65; Sun, 11 Mar 2018 16:35:25 +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 AD98028D58 for ; Sun, 11 Mar 2018 16:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932168AbeCKQfX (ORCPT ); Sun, 11 Mar 2018 12:35:23 -0400 Received: from mail-ua0-f195.google.com ([209.85.217.195]:36299 "EHLO mail-ua0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932166AbeCKQfW (ORCPT ); Sun, 11 Mar 2018 12:35:22 -0400 Received: by mail-ua0-f195.google.com with SMTP id j15so5299211uan.3 for ; Sun, 11 Mar 2018 09:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev-mellanox-co-il.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=vZD00yc48qcIUZ41gZBBk/uR5TSwaGYOATPjk98pUjA=; b=qRQ+2rdPEl1TRGzQXMbB3+hOzpkXD26qqP6FHn3M/Y7trNJKhbwoGDkc+jQgmJcL9D 2piyXufJYdygfOhBWu1UWEmVRFcXb6vwV6LRpD7CMIzs+F+DgvYLheo7ZuSTh/O0p7jM c3Lpnp+Ga6RrTNljIbLraymHFkUqUrRRgR7IQhA0IGkXTDhGOVnMwRXSX1Mb3n8Mmn12 ZA7qzIplkkwg5a3vkLmJYnoQ47K3sM8RSu2i8Y0At9ihqF7tNP0bEhdnQUIQus1qMAXw 7xhx/CJ9iBg9OkC8UfiegmmQ+cRw+pFwW87ZvpXevuXCIWXToGQ6rqIqLRmCg0lTY6Nz zeZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=vZD00yc48qcIUZ41gZBBk/uR5TSwaGYOATPjk98pUjA=; b=pP+WQ9kClTUHLQAW3nlJEvs/icDSOswvYAH/J6qIRt5iT0XSRy97tkRGglH3MQhBjI whUzMKDso/fb9B0N23pemQEwYjQYDKwummRDhJpaGXwn66Ww3Uec1XuoVX98j9ZMRzbK abxI+1gWcdTprS8CkoeAAK28HQTllXt4soXGI7OD/NC3GnTMQ5EhsatLqNGfrflQyw5J Rc/FvHJi8y/bH3PALDmSTUUP9PQfx0d1SZeS8tzA//IdxHQ4S/d1BEv1AqsoaihhUqA4 0emX2PZQieL++26gC1SkhWEnodCNt6PrIW1rT7zum2ajK/QpnoI9hUh5h7IBQRghUvCu 2zJw== X-Gm-Message-State: AElRT7G86U4CyfOtBcua3Y1UElxReF1AKRTOwkz2fa0o+MEP4J3fEbxr CK9Hqyts4es1I18+Xp6mdQZUgzSF+lRn9GA/amC5fA== X-Google-Smtp-Source: AG47ELuh3ai/jDTOFBU2TWQBld7OIhVsy1UUYiUVFtpf/8m8EAPz6rtv8K9AD5fc+Osx7KrBP280kqx6Sj1yD9Tg2Wg= X-Received: by 10.176.94.143 with SMTP id y15mr3580187uag.116.1520786121009; Sun, 11 Mar 2018 09:35:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.159.60.175 with HTTP; Sun, 11 Mar 2018 09:35:20 -0700 (PDT) In-Reply-To: <20180308214558.GG6785@ziepe.ca> References: <20180308171935.25570-1-leon@kernel.org> <20180308171935.25570-3-leon@kernel.org> <14063C7AD467DE4B82DEDB5C278E8663B2E0011B@FMSMSX108.amr.corp.intel.com> <20180308214558.GG6785@ziepe.ca> From: Matan Barak Date: Sun, 11 Mar 2018 18:35:20 +0200 Message-ID: Subject: Re: [PATCH rdma-next 02/12] IB/uverbs: Move to new headers and make naming consistent To: Jason Gunthorpe Cc: "Ruhl, Michael J" , Leon Romanovsky , Doug Ledford , Leon Romanovsky , RDMA mailing list , Aviad Yehezkel , Boris Pismenny , Matan Barak , Yishai Hadas 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 On Thu, Mar 8, 2018 at 11:45 PM, Jason Gunthorpe wrote: > On Thu, Mar 08, 2018 at 09:16:32PM +0000, Ruhl, Michael J wrote: >> > From: linux-rdma-owner@vger.kernel.org [mailto:linux-rdma- >> > owner@vger.kernel.org] On Behalf Of Leon Romanovsky >> > Sent: Thursday, March 8, 2018 12:19 PM >> > To: Doug Ledford ; Jason Gunthorpe >> > >> > Cc: Leon Romanovsky ; RDMA mailing list > > rdma@vger.kernel.org>; Aviad Yehezkel ; Boris >> > Pismenny ; Matan Barak ; >> > Yishai Hadas >> > Subject: [PATCH rdma-next 02/12] IB/uverbs: Move to new headers and >> > make naming consistent >> > >> > From: Matan Barak >> > >> > Use macros to make names consistent in ioctl() uAPI: >> > The ioctl() uAPI works with object-method hierarchy. The method part >> > also states which handler should be executed when this method is called >> > from user-space. Therefore, we need to tie method, method's id, method's >> > handler and the object owning this method together. >> > Previously, this was done through explicit developer chosen names. >> > This makes grepping the code harder. Changing the method's name, >> > method's handler and object's name to be automatically generated based >> > on the ids. >> > >> > The headers are split in a way so they be included and used by >> > user-space. One header strictly contains structures that are used >> > directly by user-space applications, where another header is used for >> > internal library (i.e. libibverbs) to form the ioctl() commands. >> > Other header simply contains the required general command structure. >> > >> > Reviewed-by: Yishai Hadas >> > Signed-off-by: Matan Barak >> > Signed-off-by: Leon Romanovsky >> > drivers/infiniband/core/uverbs_std_types.c | 139 ++++++++++++-------- >> > >> > diff --git a/drivers/infiniband/core/uverbs_std_types.c >> > b/drivers/infiniband/core/uverbs_std_types.c >> > index df1360e6774f..99f971b6cc67 100644 >> > +++ b/drivers/infiniband/core/uverbs_std_types.c >> > @@ -210,15 +210,24 @@ static int >> > uverbs_hot_unplug_completion_event_file(struct ib_uobject_file *uobj_ >> > return 0; >> > }; >> > >> > +#define UVERBS_METHOD(id) uverbs_method_##id >> > +#define UVERBS_HANDLER(id) uverbs_handler_##id >> > + >> > +#define DECLARE_COMMON_METHOD(id, ...) \ >> > + DECLARE_UVERBS_METHOD(UVERBS_METHOD(id), id, >> > UVERBS_HANDLER(id), ##__VA_ARGS__) >> > + >> > +#define DECLARE_COMMON_OBJECT(id, ...) \ >> > + DECLARE_UVERBS_OBJECT(UVERBS_OBJECT(id), id, >> > ##__VA_ARGS__) >> >> I applied this patch to my tree and noticed that the declarations for the >> METHODS and OBJECTS and HANDLERs had changed. >> >> I assumed that the above macros had been updated in the appropriate >> header files. When I tried to apply these "new" macros to my tree, I couldn't >> compile. >> >> So I cannot (easily) use the example of uverbs_std_verbs.c to set up my own >> stuff, and if I do, I have to copy the above macros to my files, or decipher these >> macros to figure out what I should use. > > Yeah, the normal DECLARE_UVERBS_METHOD/etc should just do this, we shouldn't > wrapper them in uvrebs_std_types.c > Ok, so this is the proposed change: + DECLARE_UVERBS_OBJECT(UVERBS_OBJECT(id), id, ##__VA_ARGS__) + +#endif In order to use this layer of macros, you'll have to define your module name (UVERBS_MODULE_NAME). The other names follow automatically. I first tried to use KBUILD_MODNAME, but since it's a stringifyed version of our module name, it doesn't work :( Later on I intend to try adding here some easy-to-use macros to declare a parsing tree with one argument (that extends one of the common methods). Are you ok with that? > Jason Matan > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html --- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/rdma/uverbs_named_ioctl.h b/include/rdma/uverbs_named_ioctl.h new file mode 100644 index 000000000000..f9dff179a740 --- /dev/null +++ b/include/rdma/uverbs_named_ioctl.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2018, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _UVERBS_NAMED_IOCTL_ +#define _UVERBS_NAMED_IOCTL_ + +#include + +#ifndef UVERBS_MODULE_NAME +#error "Please #define UVERBS_MODULE_NAME before including rdma/uverbs_named_ioctl.h" +#endif + +#define _UVERBS_PASTE(x, y) x ## y +#define _UVERBS_NAME(x, y) _UVERBS_PASTE(x, y) +#define UVERBS_METHOD(id) _UVERBS_NAME(UVERBS_MODULE_NAME, _method_##id) +#define UVERBS_HANDLER(id) _UVERBS_NAME(UVERBS_MODULE_NAME, _handler_##id) + +#define DECLARE_NAMED_METHOD(id, ...) \ + DECLARE_UVERBS_METHOD(UVERBS_METHOD(id), id, UVERBS_HANDLER(id), ##__VA_ARGS__) + +#define DECLARE_NAMED_METHOD_WITH_HANDLER(id, handler, ...) \ + DECLARE_UVERBS_METHOD(UVERBS_METHOD(id), id, handler, ##__VA_ARGS__) + +#define DECLARE_NAMED_METHOD_NO_HANDLER(id, handler, ...) \ + DECLARE_UVERBS_METHOD(UVERBS_METHOD(id), id, NULL, ##__VA_ARGS__) + + +#define DECLARE_NAMED_OBJECT(id, ...) \