From patchwork Tue Apr 9 13:11:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10891251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A94E01805 for ; Tue, 9 Apr 2019 13:11:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 939D4288F7 for ; Tue, 9 Apr 2019 13:11:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8472328923; Tue, 9 Apr 2019 13:11:46 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 CC731288E8 for ; Tue, 9 Apr 2019 13:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726993AbfDINLo (ORCPT ); Tue, 9 Apr 2019 09:11:44 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:45199 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726112AbfDINLo (ORCPT ); Tue, 9 Apr 2019 09:11:44 -0400 Received: by mail-qt1-f196.google.com with SMTP id v20so19549475qtv.12 for ; Tue, 09 Apr 2019 06:11:43 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=7Yhq0U4aP2OVKCqs/39H77dJua9mGhqfbh9sFI4QdSE=; b=hkx7FuicC1ubYRvUHWgzEQauj85LeZ/ji9GftoFsFff3OnxuhnM6FzXH7Ok0WXRY/a 2Pu35Jf/gJ/UCBzlZjkGuGtw6YMgvpCyDUl57UggAQFll36sqBAbWj2EILR5B5WpuTtL ihtjKI1hKm8ou5ezbu9hsguEO/7PMuQiO8JfxrItoCa50hLLOBlf3N1EpfC+GYXbDEEf loTk/DFoSvHKgnN33AMVyrakITgrShLj8gqtqb//b3tdE5054wScUhKjFnxSE2cd2w7S jcmtijw0j54zBSD30b0o4IehkiAPLh+PfXmHIQOXMIXCfLSEitmkX3dMA6TzmK1rkvdq 2Ahw== 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:mime-version:content-transfer-encoding; bh=7Yhq0U4aP2OVKCqs/39H77dJua9mGhqfbh9sFI4QdSE=; b=irA9/jOQ4ZezKAhwrRJMzHHBXQ2rYxJUggmP3DKA7hKKW7+PCug8FSgX1I6d8IpEOQ CUEhItgU+wUK1TrAITtql9URq2FejlJ7R8VfP+YQ94v9ESsC4vBECAhbriB0lxQYglCw 7Nrj9898hzBpl8gs+0/aXMPZch6a+iJw7exhz/uLxXtFm+T5izFwS+z/I3kNNrWAP3l8 oI2H3Al4gX3ulUlwIrr+Ffat07GR8rXpwZtxgrdIK3L6LjO1GIqpUGvbcwNHuC9vP4Ev qMNRy9Q51xV7x8CLgCPKzWP2It0N8k7xFUL2R0hRWSKq/sRhS8/DcfPoMWXhmMA+9oBG BPog== X-Gm-Message-State: APjAAAU1HZZ8yvDl7IjMkpXNMHqddUcAfglJCUxCsRFGX7DG5RWUYtaQ nSW7flHw1MbsMk8SCFPNnQhweGAXuYQ= X-Google-Smtp-Source: APXvYqxEZ+v/ZZ/RjiD3mNQcsBKGixwqXk6sO68pTEBI0RrhSprGZaylBHO2DS7cbQvzC2BsYcKVMg== X-Received: by 2002:ac8:3957:: with SMTP id t23mr30117104qtb.331.1554815503046; Tue, 09 Apr 2019 06:11:43 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-49-251.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.49.251]) by smtp.gmail.com with ESMTPSA id a188sm11331316qkf.34.2019.04.09.06.11.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2019 06:11:37 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hDqXH-0004E0-Hx; Tue, 09 Apr 2019 10:11:35 -0300 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Cc: Jason Gunthorpe Subject: [PATCH ibdiags 02/16] ibdiags: Replace cl_hton with htobe Date: Tue, 9 Apr 2019 10:11:19 -0300 Message-Id: <20190409131133.16140-3-jgg@ziepe.ca> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190409131133.16140-1-jgg@ziepe.ca> References: <20190409131133.16140-1-jgg@ziepe.ca> MIME-Version: 1.0 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 This is done with a sed script. The glibc version automatically optimally handles constant values, so no need for the special constant version. Signed-off-by: Jason Gunthorpe --- include/ibdiag_sa.h | 7 +++++-- src/ibsendtrap.c | 44 ++++++++++++++++++++++---------------------- src/saquery.c | 8 ++++---- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/include/ibdiag_sa.h b/include/ibdiag_sa.h index 368a8294dc82a7..886e963cf7ef36 100644 --- a/include/ibdiag_sa.h +++ b/include/ibdiag_sa.h @@ -70,10 +70,13 @@ void *sa_get_query_rec(void *mad, unsigned i); void sa_report_err(int status); /* Macros for setting query values and ComponentMasks */ -#define cl_hton8(x) (x) +static inline uint8_t htobe8(uint8_t val) +{ + return val; +} #define CHECK_AND_SET_VAL(val, size, comp_with, target, name, mask) \ if ((int##size##_t) val != (int##size##_t) comp_with) { \ - target = cl_hton##size((uint##size##_t) val); \ + target = htobe##size((uint##size##_t) val); \ comp_mask |= IB_##name##_COMPMASK_##mask; \ } diff --git a/src/ibsendtrap.c b/src/ibsendtrap.c index 4459b1658417bd..b6751a957c9183 100644 --- a/src/ibsendtrap.c +++ b/src/ibsendtrap.c @@ -77,20 +77,20 @@ static uint32_t get_cap_mask(ib_portid_t * port) static void build_trap145(ib_mad_notice_attr_t * n, ib_portid_t * port) { n->generic_type = 0x80 | IB_NOTICE_TYPE_INFO; - n->g_or_v.generic.prod_type_lsb = cl_hton16(get_node_type(port)); - n->g_or_v.generic.trap_num = cl_hton16(145); - n->issuer_lid = cl_hton16((uint16_t) port->lid); - n->data_details.ntc_145.new_sys_guid = cl_hton64(0x1234567812345678); + n->g_or_v.generic.prod_type_lsb = htobe16(get_node_type(port)); + n->g_or_v.generic.trap_num = htobe16(145); + n->issuer_lid = htobe16((uint16_t) port->lid); + n->data_details.ntc_145.new_sys_guid = htobe64(0x1234567812345678); } static void build_trap144_local(ib_mad_notice_attr_t * n, ib_portid_t * port) { n->generic_type = 0x80 | IB_NOTICE_TYPE_INFO; - n->g_or_v.generic.prod_type_lsb = cl_hton16(get_node_type(port)); - n->g_or_v.generic.trap_num = cl_hton16(144); - n->issuer_lid = cl_hton16((uint16_t) port->lid); + n->g_or_v.generic.prod_type_lsb = htobe16(get_node_type(port)); + n->g_or_v.generic.trap_num = htobe16(144); + n->issuer_lid = htobe16((uint16_t) port->lid); n->data_details.ntc_144.lid = n->issuer_lid; - n->data_details.ntc_144.new_cap_mask = cl_hton32(get_cap_mask(port)); + n->data_details.ntc_144.new_cap_mask = htobe32(get_cap_mask(port)); n->data_details.ntc_144.local_changes = TRAP_144_MASK_OTHER_LOCAL_CHANGES; } @@ -113,9 +113,9 @@ static void build_trap144_linkspeed(ib_mad_notice_attr_t * n, static void build_trap129(ib_mad_notice_attr_t * n, ib_portid_t * port) { n->generic_type = 0x80 | IB_NOTICE_TYPE_URGENT; - n->g_or_v.generic.prod_type_lsb = cl_hton16(get_node_type(port)); - n->g_or_v.generic.trap_num = cl_hton16(129); - n->issuer_lid = cl_hton16((uint16_t) port->lid); + n->g_or_v.generic.prod_type_lsb = htobe16(get_node_type(port)); + n->g_or_v.generic.trap_num = htobe16(129); + n->issuer_lid = htobe16((uint16_t) port->lid); n->data_details.ntc_129_131.lid = n->issuer_lid; n->data_details.ntc_129_131.pad = 0; n->data_details.ntc_129_131.port_num = (uint8_t) error_port; @@ -124,9 +124,9 @@ static void build_trap129(ib_mad_notice_attr_t * n, ib_portid_t * port) static void build_trap256_local(ib_mad_notice_attr_t * n, ib_portid_t * port) { n->generic_type = 0x80 | IB_NOTICE_TYPE_SECURITY; - n->g_or_v.generic.prod_type_lsb = cl_hton16(get_node_type(port)); - n->g_or_v.generic.trap_num = cl_hton16(256); - n->issuer_lid = cl_hton16((uint16_t) port->lid); + n->g_or_v.generic.prod_type_lsb = htobe16(get_node_type(port)); + n->g_or_v.generic.trap_num = htobe16(256); + n->issuer_lid = htobe16((uint16_t) port->lid); n->data_details.ntc_256.lid = n->issuer_lid; n->data_details.ntc_256.dr_slid = 0xffff; n->data_details.ntc_256.method = 1; @@ -155,14 +155,14 @@ static void build_trap257_258(ib_mad_notice_attr_t * n, ib_portid_t * port, uint16_t trap_num) { n->generic_type = 0x80 | IB_NOTICE_TYPE_SECURITY; - n->g_or_v.generic.prod_type_lsb = cl_hton16(get_node_type(port)); - n->g_or_v.generic.trap_num = cl_hton16(trap_num); - n->issuer_lid = cl_hton16((uint16_t) port->lid); - n->data_details.ntc_257_258.lid1 = cl_hton16(1); - n->data_details.ntc_257_258.lid2 = cl_hton16(2); - n->data_details.ntc_257_258.key = cl_hton32(0x12345678); - n->data_details.ntc_257_258.qp1 = cl_hton32(0x010101); - n->data_details.ntc_257_258.qp2 = cl_hton32(0x020202); + n->g_or_v.generic.prod_type_lsb = htobe16(get_node_type(port)); + n->g_or_v.generic.trap_num = htobe16(trap_num); + n->issuer_lid = htobe16((uint16_t) port->lid); + n->data_details.ntc_257_258.lid1 = htobe16(1); + n->data_details.ntc_257_258.lid2 = htobe16(2); + n->data_details.ntc_257_258.key = htobe32(0x12345678); + n->data_details.ntc_257_258.qp1 = htobe32(0x010101); + n->data_details.ntc_257_258.qp2 = htobe32(0x020202); n->data_details.ntc_257_258.gid1.unicast.prefix = be64toh(0xf8c0000000000001); n->data_details.ntc_257_258.gid1.unicast.interface_id = be64toh(0x1111222233334444); n->data_details.ntc_257_258.gid2.unicast.prefix = be64toh(0xf8c0000000000001); diff --git a/src/saquery.c b/src/saquery.c index 9ecd5f5332b263..40492a619c73f4 100644 --- a/src/saquery.c +++ b/src/saquery.c @@ -1058,7 +1058,7 @@ static int query_path_records(const struct query_cmd *q, struct sa_handle * h, CHECK_AND_SET_VAL(p->dlid, 16, 0, pr.dlid, PR, DLID); CHECK_AND_SET_VAL(p->hop_limit, 32, -1, pr.hop_flow_raw, PR, HOPLIMIT); CHECK_AND_SET_VAL(p->flow_label, 8, 0, flow, PR, FLOWLABEL); - pr.hop_flow_raw |= cl_hton32(flow << 8); + pr.hop_flow_raw |= htobe32(flow << 8); CHECK_AND_SET_VAL(p->tclass, 8, 0, pr.tclass, PR, TCLASS); CHECK_AND_SET_VAL(p->reversible, 8, -1, reversible, PR, REVERSIBLE); CHECK_AND_SET_VAL(p->numb_path, 8, -1, pr.num_path, PR, NUMBPATH); @@ -1066,7 +1066,7 @@ static int query_path_records(const struct query_cmd *q, struct sa_handle * h, CHECK_AND_SET_VAL(p->pkey, 16, 0, pr.pkey, PR, PKEY); CHECK_AND_SET_VAL(p->sl, 16, -1, pr.qos_class_sl, PR, SL); CHECK_AND_SET_VAL((p->qos_class << 4), 16, -1, qos_class, PR, QOS_CLASS); - pr.qos_class_sl = (pr.qos_class_sl & CL_HTON16(IB_PATH_REC_SL_MASK)) | + pr.qos_class_sl = (pr.qos_class_sl & htobe16(IB_PATH_REC_SL_MASK)) | qos_class; CHECK_AND_SET_VAL_AND_SEL(p->mtu, pr.mtu, PR, MTU, SELEC); CHECK_AND_SET_VAL_AND_SEL(p->rate, pr.rate, PR, RATE, SELEC); @@ -1418,9 +1418,9 @@ static int query_mft_records(const struct query_cmd *q, struct sa_handle * h, memset(&mftr, 0, sizeof(mftr)); CHECK_AND_SET_VAL(lid, 16, 0, mftr.lid, MFTR, LID); CHECK_AND_SET_VAL(block, 16, -1, mftr.position_block_num, MFTR, BLOCK); - mftr.position_block_num &= cl_hton16(IB_MCAST_BLOCK_ID_MASK_HO); + mftr.position_block_num &= htobe16(IB_MCAST_BLOCK_ID_MASK_HO); CHECK_AND_SET_VAL(position, 8, -1, pos, MFTR, POSITION); - mftr.position_block_num |= cl_hton16(pos << 12); + mftr.position_block_num |= htobe16(pos << 12); return get_and_dump_any_records(h, IB_SA_ATTR_MFTRECORD, 0, comp_mask, &mftr, sizeof(mftr), dump_one_mft_record, p);