From patchwork Fri Jul 6 17:17:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10512169 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 3B86A603D7 for ; Fri, 6 Jul 2018 17:17:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D8972872E for ; Fri, 6 Jul 2018 17:17:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11D7428739; Fri, 6 Jul 2018 17:17:41 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 A010E28734 for ; Fri, 6 Jul 2018 17:17:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932992AbeGFRRi (ORCPT ); Fri, 6 Jul 2018 13:17:38 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:63065 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932834AbeGFRRi (ORCPT ); Fri, 6 Jul 2018 13:17:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1530897459; x=1562433459; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=qNiFT11LjcD56hamDqYuokcXB/iK2AVS6Qand5U0JfI=; b=AnMYFAfcgstE3er2yK4ixyPqz4OHfP+V3IzR6FBdICJQ2xFIIhnIoNq6 5Hq4PSGW5pS5RDwFy5tCvNRlK1trWROcZ25PQunJ2wu/wRfo8Hv4f5emj B29zLLWns8CjTTAKtRFiEAObsda4xYSiiB8GVE+5Dd5EkK7ju7mmlrCWX HzCPSkwm/RAG1iHA5NLgxAxw1aRMhWA9drHg2yVH2j4ubOabWxP/cfPNK oGER1bstF6QhK3dQypR5X3idLfFLSecKtnwn1XVIEcpCi29gc+JZT47Xq t1u3L0efanee7Kxuwv199+jT7FR4Dpsp8pVCT26aLuP54sA1V8adtbpSb g==; X-IronPort-AV: E=Sophos;i="5.51,317,1526313600"; d="scan'208";a="84076245" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 07 Jul 2018 01:17:38 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 06 Jul 2018 10:06:49 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com ([10.111.67.248]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Jul 2018 10:17:38 -0700 From: Bart Van Assche To: Jason Gunthorpe Cc: Doug Ledford , linux-rdma@vger.kernel.org, Bart Van Assche , Leon Romanovsky , Parav Pandit Subject: [PATCH 01/13] RDMA/verbs: Convert struct ib_send_wr conversion functions into macros Date: Fri, 6 Jul 2018 10:17:24 -0700 Message-Id: <20180706171736.14543-2-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180706171736.14543-1-bart.vanassche@wdc.com> References: <20180706171736.14543-1-bart.vanassche@wdc.com> 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 Since the C programming language does not allow to define a single function of which the constness of the return type depends on the constness of an argument type, convert the struct ib_send_wr conversion functions into macros. That will allow these conversion functions to be used both in a context where the send work request is modified and where it is not modified. The iSER initiator driver is the only driver that uses one of these functions to obtain a modifiable pointer to a work request, namely as follows: wr = reg_wr(iser_tx_next_wr(tx_desc)); Signed-off-by: Bart Van Assche Cc: Leon Romanovsky Cc: Parav Pandit --- include/rdma/ib_verbs.h | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index e1130c6c1377..f0b70f3f2a65 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1373,10 +1373,7 @@ struct ib_rdma_wr { u32 rkey; }; -static inline struct ib_rdma_wr *rdma_wr(struct ib_send_wr *wr) -{ - return container_of(wr, struct ib_rdma_wr, wr); -} +#define rdma_wr(send_wr) container_of(send_wr, struct ib_rdma_wr, wr) struct ib_atomic_wr { struct ib_send_wr wr; @@ -1388,10 +1385,7 @@ struct ib_atomic_wr { u32 rkey; }; -static inline struct ib_atomic_wr *atomic_wr(struct ib_send_wr *wr) -{ - return container_of(wr, struct ib_atomic_wr, wr); -} +#define atomic_wr(send_wr) container_of(send_wr, struct ib_atomic_wr, wr) struct ib_ud_wr { struct ib_send_wr wr; @@ -1405,10 +1399,7 @@ struct ib_ud_wr { u8 port_num; /* valid for DR SMPs on switch only */ }; -static inline struct ib_ud_wr *ud_wr(struct ib_send_wr *wr) -{ - return container_of(wr, struct ib_ud_wr, wr); -} +#define ud_wr(send_wr) container_of(send_wr, struct ib_ud_wr, wr) struct ib_reg_wr { struct ib_send_wr wr; @@ -1417,10 +1408,7 @@ struct ib_reg_wr { int access; }; -static inline struct ib_reg_wr *reg_wr(struct ib_send_wr *wr) -{ - return container_of(wr, struct ib_reg_wr, wr); -} +#define reg_wr(send_wr) container_of(send_wr, struct ib_reg_wr, wr) struct ib_sig_handover_wr { struct ib_send_wr wr; @@ -1430,10 +1418,8 @@ struct ib_sig_handover_wr { struct ib_sge *prot; }; -static inline struct ib_sig_handover_wr *sig_handover_wr(struct ib_send_wr *wr) -{ - return container_of(wr, struct ib_sig_handover_wr, wr); -} +#define sig_handover_wr(send_wr) \ + container_of(send_wr, struct ib_sig_handover_wr, wr) struct ib_recv_wr { struct ib_recv_wr *next;