From patchwork Wed Nov 21 15:51:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 10692735 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 6276717FE for ; Wed, 21 Nov 2018 15:51:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 511F52BFEF for ; Wed, 21 Nov 2018 15:51:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45AF72BFFC; Wed, 21 Nov 2018 15:51:47 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 D379A2BFEF for ; Wed, 21 Nov 2018 15:51:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731452AbeKVC0o (ORCPT ); Wed, 21 Nov 2018 21:26:44 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:41740 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731296AbeKVC0o (ORCPT ); Wed, 21 Nov 2018 21:26:44 -0500 Received: by mail-qt1-f195.google.com with SMTP id d18so4296055qto.8 for ; Wed, 21 Nov 2018 07:51:45 -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=/oebZg1EEpPHeAdWLAruQuhvzhB7QZk1BU6FSg0D9bM=; b=1RKObqORQt9Esv3HdOQ2xWuXQtbNl6l28CXYXEYVx4SZT+WbeMRgjyTRfsAIT4JPW/ y3LEheFkguIwJMW9ZIau/U3FHftjjo0LMMEt5rrUe2pOjpof0YbRxGb5qX+GnQodlPTB sTsZ3Lbz92aqcXC4gXdSFcAkRxAR7yCkCgXrbRlIaG+jZGd32V/4X4Qi1sRRyu9zKlAM pCze57RzsrPmyzWHPVuZ3vaOrzKAr/CHN5Xc9w9eKRsWKxj9YoPHsvkW2gsqZbpCNcgI EVanqtw/jBQoOFs0PfOvCio+aL/JIMmi8kBGNSlfB0F8qJV01kB9bDgAT5A/3cc7VtlH FqWg== 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=/oebZg1EEpPHeAdWLAruQuhvzhB7QZk1BU6FSg0D9bM=; b=T2m86T7SJXWYgq4tIVaOkRAy8FdN7pzLRPL0lf+5/JT1KrptDpdoZ2ysbqxeOK+jYb 6R4ezsNr69Xdb0x5QzsQ5JMvsuRarXNJPBLJhTq1W4b6EMYxf59nyC5EpSOw+553IMjY uuDivzPtD5nDl8zyU/6rZ0ok/zDbQZfa13jt/AU4xPHqy+x0gdO8WU9wtDLdnkoRWqHI tffA13yxEQ4TvD9T61wdZlj/GGfM/6qZgMjvori6ZATDZuu4AoYZhACskYO+/hfckPfX 6OLDmuNbFPn5PkWMKUxmP/n4zydTPlBQ3JrxWD5/nHxlH6kvfYs34VLKbnSLBBGkcAwK q5iw== X-Gm-Message-State: AGRZ1gKR6UC2Hbu/u2u8wRmVb6H9jQyXwmjA+UfblJunFZaJGVmUVrBR iIowH8Q6RGBcywPe35lIVwmzgpOy8JA= X-Google-Smtp-Source: AJdET5exKIcjkhlFOj2FoT0dBnAK4+QJ1UBe+GjPwnWA6zghu/mP6AfZ/0HXKRs7VomGBkEPhcV/OA== X-Received: by 2002:ac8:1b4d:: with SMTP id p13mr6354315qtk.56.1542815504404; Wed, 21 Nov 2018 07:51:44 -0800 (PST) Received: from [192.168.1.119] (c-73-142-227-196.hsd1.ma.comcast.net. [73.142.227.196]) by smtp.googlemail.com with ESMTPSA id o25sm11003359qtj.10.2018.11.21.07.51.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 07:51:43 -0800 (PST) To: "linux-rdma@vger.kernel.org" From: Hal Rosenstock Subject: [PATCH rdma-core] libibumad/umad_sa.h: Change to umad_sa_set_rate_mtu_or_life Message-ID: <07ec40ba-583e-f738-3251-e06aaf6020be@dev.mellanox.co.il> Date: Wed, 21 Nov 2018 10:51:41 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 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 commit 0ff0e21b89e24d29f7d1eec9b83f9eebc75ca316 Author: Hkon Bugge Date: Tue Nov 20 13:42:11 2018 +0100 ibacm: Use helper functions and existing defines to avoid literal use Use existing helper functions to avoid the use of literal constants. Took the liberty to also use those defines in some helper functions where appropriate. Added an enum for the Multicast Address Scope values. Signed-off-by: Hkon Bugge changed umad_sa_set_rate_mtu_or_life as follows: 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)); + return (((selector & UMAD_SA_RATE_MTU_PKT_LIFE_MASK) << UMAD_SA_SELECTOR _SHIFT) | + (rate_mtu_or_life & UMAD_SA_RATE_MTU_PKT_LIFE_MASK)); } so 0x3 was changed to 0x3f (UMAD_SA_RATE_MTU_PKT_LIFE_MASK). While this should work due to using left shift by 6 on 8 bit variable, a more literal translation is better IMO. Signed-off-by: Hal Rosenstock --- libibumad/umad_sa.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libibumad/umad_sa.h b/libibumad/umad_sa.h index 4ade055..b07774b 100644 --- a/libibumad/umad_sa.h +++ b/libibumad/umad_sa.h @@ -138,6 +138,7 @@ enum { #define UMAD_SA_SELECTOR_SHIFT 6 #define UMAD_SA_RATE_MTU_PKT_LIFE_MASK 0x3f +#define UMAD_SA_SELECTOR_MASK 0x3 /* * sm_key is not aligned on an 8-byte boundary, so is defined as a byte array @@ -161,7 +162,7 @@ umad_sa_get_rate_mtu_or_life(uint8_t rate_mtu_or_life) static inline uint8_t umad_sa_set_rate_mtu_or_life(uint8_t selector, uint8_t rate_mtu_or_life) { - return (((selector & UMAD_SA_RATE_MTU_PKT_LIFE_MASK) << UMAD_SA_SELECTOR_SHIFT) | + return (((selector & UMAD_SA_SELECTOR_MASK) << UMAD_SA_SELECTOR_SHIFT) | (rate_mtu_or_life & UMAD_SA_RATE_MTU_PKT_LIFE_MASK)); }