From patchwork Tue Nov 21 01:41:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 10067587 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 05ADF603FA for ; Tue, 21 Nov 2017 01:41:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA736292F4 for ; Tue, 21 Nov 2017 01:41:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF6A62931B; Tue, 21 Nov 2017 01:41:31 +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 609B829303 for ; Tue, 21 Nov 2017 01:41:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751803AbdKUBla (ORCPT ); Mon, 20 Nov 2017 20:41:30 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:42999 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751253AbdKUBla (ORCPT ); Mon, 20 Nov 2017 20:41:30 -0500 Received: by mail-wr0-f194.google.com with SMTP id o14so9826922wrf.9 for ; Mon, 20 Nov 2017 17:41:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev-mellanox-co-il.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=T7Mwu0iobzJHycGraBypuRu0ZFiiC6YRW4+0VsLpEcw=; b=By5LOxJkfA1bn8qMUHbNdfQv6Fk4EaL1tgDMsC5Yhs9IsCHn0f5u6MJQz097xGeRVF YgirCPt5HxbfFYwsFgdNrymWFJnWCDwMPrVIisb5dXoWzN0/XaCb1JY2qCTeVkRBj+wP yfDe8XCYbFO6LT1lMPhpGZKNvcrpovt0ppJoSabVA+zlmeEW4jtVcjjSh47XXpa3m2I7 T7h5MGA4TNoypOLWgtPnqNCA0Y5RDx98pcgnkqNaZjFLWi2AuTD4GYvVES/dGFqZyXEG CGWgf8fc3292Lg3eS4CVrNJfRR2xYQ66A6PVFQxYik0FaaRZRoE0fz3L+OhptQtKmLnK fvfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=T7Mwu0iobzJHycGraBypuRu0ZFiiC6YRW4+0VsLpEcw=; b=FUqLaYF5YeaToyjyqdL2vcNjU+KzY5t9wJihzJDbdWiC6AG1h9kwTjsxFoN69Uou3V O2UPPAhLSyW0xTfYJ57SdEiZXYKrgoexGS2KYfNsg1OdQR23u7O6Sb2EnBL4SbiT2A2R PgkiIBlBnv4DCGEw2zMcar8dta/i/Fv8wZFdrtX0WRpe2WDOUIDw6nzCUS3BdbuArSSM wLtCiAGBY6Npm9GsB0lNAIkeZ2wHAzZcYzANIkA3W0JgnPTxHx1E8lNMmJ3Hyi588W+u autsq9mEMORPo7K29PBO8E374WGhCV1fP0SzCjTWgy5Ptj2I2/Fc5ic4qTFwo+2wPS+s 0h5A== X-Gm-Message-State: AJaThX7Q+YBQt7MDGSLjRfyStlEQnMoAOdkrrP8h9AlXuwQ/GnZAw7Iz mcJa30+012QIE49bN2w7K2ahIfC4 X-Google-Smtp-Source: AGs4zMYrYPogdg6bL0i7G5bGAZEwhYZJA12h+9eLyy5AJK0wr5uIJ4MzX/cA5P4uZM9NTb2KSFrCug== X-Received: by 10.223.167.3 with SMTP id c3mr2921898wrd.127.1511228488596; Mon, 20 Nov 2017 17:41:28 -0800 (PST) Received: from [192.168.1.183] (c-73-182-207-166.hsd1.ma.comcast.net. [73.182.207.166]) by smtp.googlemail.com with ESMTPSA id y84sm17169wmg.39.2017.11.20.17.41.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2017 17:41:28 -0800 (PST) To: "linux-rdma@vger.kernel.org" From: Hal Rosenstock Subject: [PATCH rdma-core 3/3] libibumad: Move common enums, defines, and helpers to umad_sa.h Message-ID: Date: Mon, 20 Nov 2017 20:41:25 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-US 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 A number of enums, defines and helpers for SA MCMemberRecord are identical for SA PathRecord and MultiPathRecord so move them from umad_sa_mcm.h to umad_sa.h Signed-off-by: Hal Rosenstock --- libibumad/tests/umad_sa_mcm_rereg_test.c | 12 ++++++------ libibumad/umad_sa.h | 26 ++++++++++++++++++++++++++ libibumad/umad_sa_mcm.h | 32 -------------------------------- 3 files changed, 32 insertions(+), 38 deletions(-) diff --git a/libibumad/tests/umad_sa_mcm_rereg_test.c b/libibumad/tests/umad_sa_mcm_rereg_test.c index 199d436..77209d4 100644 --- a/libibumad/tests/umad_sa_mcm_rereg_test.c +++ b/libibumad/tests/umad_sa_mcm_rereg_test.c @@ -120,16 +120,16 @@ static void build_mcm_rec(struct umad_sa_packet *sa, uint8_t method, sa->comp_mask |= htobe64(UMAD_SA_MCM_COMP_MASK_RATE_SEL | UMAD_SA_MCM_COMP_MASK_RATE); - mcm->rate = (UMAD_SA_MCM_SELECTOR_EXACTLY << - UMAD_SA_MCM_SELECTOR_SHIFT) | - (rate & UMAD_SA_MCM_RATE_MTU_PKT_LIFE_MASK); + mcm->rate = (UMAD_SA_SELECTOR_EXACTLY << + UMAD_SA_SELECTOR_SHIFT) | + (rate & UMAD_SA_RATE_MTU_PKT_LIFE_MASK); } if (mtu != 0xff) { sa->comp_mask |= htobe64(UMAD_SA_MCM_COMP_MASK_MTU_SEL | UMAD_SA_MCM_COMP_MASK_MTU); - mcm->mtu = (UMAD_SA_MCM_SELECTOR_EXACTLY << - UMAD_SA_MCM_SELECTOR_SHIFT) | - (mtu & UMAD_SA_MCM_RATE_MTU_PKT_LIFE_MASK); + mcm->mtu = (UMAD_SA_SELECTOR_EXACTLY << + UMAD_SA_SELECTOR_SHIFT) | + (mtu & UMAD_SA_RATE_MTU_PKT_LIFE_MASK); } if (sl != 0xff) { sa->comp_mask |= htobe64(UMAD_SA_MCM_COMP_MASK_SL); diff --git a/libibumad/umad_sa.h b/libibumad/umad_sa.h index 3f0f877..2598741 100644 --- a/libibumad/umad_sa.h +++ b/libibumad/umad_sa.h @@ -132,6 +132,20 @@ enum { }; /* + * Shared by SA MCMemberRecord, PathRecord, and MultiPathRecord + */ +enum { + UMAD_SA_SELECTOR_GREATER_THAN = 0, + UMAD_SA_SELECTOR_LESS_THAN = 1, + UMAD_SA_SELECTOR_EXACTLY = 2, + UMAD_SA_SELECTOR_LARGEST_AVAIL = 3, /* rate & MTU */ + UMAD_SA_SELECTOR_SMALLEST_AVAIL = 3 /* packet lifetime */ +}; + +#define UMAD_SA_SELECTOR_SHIFT 6 +#define UMAD_SA_RATE_MTU_PKT_LIFE_MASK 0x3f + +/* * sm_key is not aligned on an 8-byte boundary, so is defined as a byte array */ struct umad_sa_packet { @@ -144,5 +158,17 @@ struct umad_sa_packet { uint8_t data[UMAD_LEN_SA_DATA]; /* network-byte order */ }; +static inline uint8_t +umad_sa_get_rate_mtu_or_life(uint8_t rate_mtu_or_life) +{ + return (rate_mtu_or_life & 0x3f); +} + +static inline uint8_t +umad_sa_set_rate_mtu_or_life(uint8_t selector, uint8_t rate_mtu_or_life) +{ + return (((selector & 0x3) << 6) | (rate_mtu_or_life & 0x3f)); +} + END_C_DECLS #endif /* _UMAD_SA_H */ diff --git a/libibumad/umad_sa_mcm.h b/libibumad/umad_sa_mcm.h index 4aaaf02..b784b4d 100644 --- a/libibumad/umad_sa_mcm.h +++ b/libibumad/umad_sa_mcm.h @@ -62,22 +62,6 @@ enum { UMAD_SA_MCM_COMP_MASK_PROXY_JOIN = (1ULL << 17) }; -/* - * Should this enum be moved to umad_sa.h and MCM_ removed - * as these are shared by PathRecord and MultiPathRecord ? - */ -enum { - UMAD_SA_MCM_SELECTOR_GREATER_THAN = 0, - UMAD_SA_MCM_SELECTOR_LESS_THAN = 1, - UMAD_SA_MCM_SELECTOR_EXACTLY = 2, - UMAD_SA_MCM_SELECTOR_LARGEST_AVAIL = 3, /* rate & MTU */ - UMAD_SA_MCM_SELECTOR_SMALLEST_AVAIL = 3 /* packet lifetime */ -}; - -/* Similarly for the following 2 defines */ -#define UMAD_SA_MCM_SELECTOR_SHIFT 6 -#define UMAD_SA_MCM_RATE_MTU_PKT_LIFE_MASK 0x3f - enum { UMAD_SA_MCM_JOIN_STATE_FULL_MEMBER = (1 << 0), UMAD_SA_MCM_JOIN_STATE_NON_MEMBER = (1 << 1), @@ -171,22 +155,6 @@ umad_sa_mcm_get_proxy_join(struct umad_sa_mcmember_record *p_mc_rec) return ((p_mc_rec->proxy_join & 0x80) == 0x80); } -/* - * Similarly, should the next 2 helpers be moved to umad_sa.h - * without mcm_ in the function name ? - */ -static inline uint8_t -umad_sa_mcm_get_rate_mtu_or_life(uint8_t rate_mtu_or_life) -{ - return (rate_mtu_or_life & 0x3f); -} - -static inline uint8_t -umad_sa_mcm_set_rate_mtu_or_life(uint8_t selector, uint8_t rate_mtu_or_life) -{ - return (((selector & 0x3) << 6) | (rate_mtu_or_life & 0x3f)); -} - #ifdef __cplusplus } #endif