From patchwork Thu Feb 9 21:53:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 9565551 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 94A6A60216 for ; Thu, 9 Feb 2017 21:54:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86F7528552 for ; Thu, 9 Feb 2017 21:54:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C08A2855A; Thu, 9 Feb 2017 21:54:14 +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 49FF828552 for ; Thu, 9 Feb 2017 21:54:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753971AbdBIVyL (ORCPT ); Thu, 9 Feb 2017 16:54:11 -0500 Received: from quartz.orcorp.ca ([184.70.90.242]:34340 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753938AbdBIVyG (ORCPT ); Thu, 9 Feb 2017 16:54:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=obsidianresearch.com; s=rsa1; h=References:In-Reply-To:Message-Id:Date:Subject:To:From; bh=Io7iIsJ0on90MAQQvBdkuQprQTWzks5xVIDgXVacBKc=; b=SY9OcorDH4l8nQr/Lv2ORNCa8zuJ+ANqE1MkJKBn81PXQsJYf+RXu2rIg+sgIMTBY4hSjDxxQbNDx+buySiuQ4UBRLP41DNu9n7xKK61QdTHIcdO/jUmlzXEgNFeYMiEV6DY3qVpurtniQwq7T8d8/x0SWGDeaIFvFwcCZF5QEY=; Received: from [10.0.0.156] (helo=jggl.edm.orcorp.ca) by quartz.orcorp.ca with esmtps (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1cbwel-0004DE-2v for linux-rdma@vger.kernel.org; Thu, 09 Feb 2017 14:53:35 -0700 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Subject: [PATCH rdma-core 04/10] Do not use kernel byteswap macros Date: Thu, 9 Feb 2017 14:53:26 -0700 Message-Id: <1486677212-3188-5-git-send-email-jgunthorpe@obsidianresearch.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486677212-3188-1-git-send-email-jgunthorpe@obsidianresearch.com> References: <1486677212-3188-1-git-send-email-jgunthorpe@obsidianresearch.com> X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.156 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 These days the version in glibc's endian.h is just as good, since gcc 4.3 (we support no earlier compiler) this just boils down to __builtin_bswap which is a constant expression if the input is constant. Done via $ git ls-files | xargs sed -i -e 's/__constant_cpu_to_be64/htobe64/g' $ git ls-files | xargs sed -i -e 's/__cpu_to_be64/htobe64/g' $ git ls-files | xargs sed -i -e 's/__be64_to_cpu/be64toh/g' Signed-off-by: Jason Gunthorpe Reviewed-by: Steve Wise --- iwpmd/iwarp_pm_common.c | 5 +++-- libibcm/cm.h | 6 +++--- libibcm/examples/cmpost.c | 7 +++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/iwpmd/iwarp_pm_common.c b/iwpmd/iwarp_pm_common.c index 941e0406ade787..569d53531652aa 100644 --- a/iwpmd/iwarp_pm_common.c +++ b/iwpmd/iwarp_pm_common.c @@ -32,6 +32,7 @@ */ #include "iwarp_pm.h" +#include /* iwpm config params */ static const char * iwpm_param_names[IWPM_PARAM_NUM] = @@ -380,7 +381,7 @@ int parse_iwpm_msg(iwpm_wire_msg *pm_msg, iwpm_msg_parms *msg_parms) int ret_value = 0; msg_parms->pmtime = pm_msg->pmtime; - msg_parms->assochandle = __be64_to_cpu(pm_msg->assochandle); + msg_parms->assochandle = be64toh(pm_msg->assochandle); msg_parms->ip_ver = (pm_msg->magic & IWARP_PM_IPVER_MASK) >> IWARP_PM_IPVER_SHIFT; switch (msg_parms->ip_ver) { case 4: @@ -420,7 +421,7 @@ static void form_iwpm_msg(iwpm_wire_msg *pm_msg, iwpm_msg_parms *msg_parms) { memset(pm_msg, 0, sizeof(struct iwpm_wire_msg)); pm_msg->pmtime = msg_parms->pmtime; - pm_msg->assochandle = __cpu_to_be64(msg_parms->assochandle); + pm_msg->assochandle = htobe64(msg_parms->assochandle); /* record IP version, port mapper version, message type */ pm_msg->magic = (msg_parms->ip_ver << IWARP_PM_IPVER_SHIFT) & IWARP_PM_IPVER_MASK; pm_msg->magic |= (msg_parms->ver << IWARP_PM_VER_SHIFT) & IWARP_PM_VER_MASK; diff --git a/libibcm/cm.h b/libibcm/cm.h index e5e2b5e78c5032..6305e8236a3903 100644 --- a/libibcm/cm.h +++ b/libibcm/cm.h @@ -38,7 +38,7 @@ #include #include -#include +#include #ifdef __cplusplus extern "C" { @@ -325,8 +325,8 @@ struct ib_cm_attr_param { int ib_cm_attr_id(struct ib_cm_id *cm_id, struct ib_cm_attr_param *param); -#define IB_CM_ASSIGN_SERVICE_ID_MASK __constant_cpu_to_be64(0xFF00000000000000ULL) -#define IB_CM_ASSIGN_SERVICE_ID __constant_cpu_to_be64(0x0200000000000000ULL) +#define IB_CM_ASSIGN_SERVICE_ID_MASK htobe64(0xFF00000000000000ULL) +#define IB_CM_ASSIGN_SERVICE_ID htobe64(0x0200000000000000ULL) /** * ib_cm_listen - Initiates listening on the specified service ID for diff --git a/libibcm/examples/cmpost.c b/libibcm/examples/cmpost.c index f7833f5223185b..d27bdc9c1bf9f3 100644 --- a/libibcm/examples/cmpost.c +++ b/libibcm/examples/cmpost.c @@ -37,9 +37,8 @@ #include #include #include -#include +#include -#include #include #include @@ -585,7 +584,7 @@ static void run_server(void) printf("listen request failed\n"); return; } - ret = ib_cm_listen(listen_id, __cpu_to_be64(0x1000), 0); + ret = ib_cm_listen(listen_id, htobe64(0x1000), 0); if (ret) { printf("failure trying to listen: %d\n", ret); goto out; @@ -702,7 +701,7 @@ static void run_client(char *dst) memset(&req, 0, sizeof req); req.primary_path = &test.path_rec; - req.service_id = __cpu_to_be64(0x1000); + req.service_id = htobe64(0x1000); /* * When choosing the responder resources for a ULP, it is usually