From patchwork Thu Aug 10 18:04:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hiatt, Don" X-Patchwork-Id: 9894475 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 625F460352 for ; Thu, 10 Aug 2017 18:04:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5979A289C4 for ; Thu, 10 Aug 2017 18:04:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E97128B5F; Thu, 10 Aug 2017 18:04:36 +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.9 required=2.0 tests=BAYES_00,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 0806C289C4 for ; Thu, 10 Aug 2017 18:04:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753141AbdHJSEd (ORCPT ); Thu, 10 Aug 2017 14:04:33 -0400 Received: from mga06.intel.com ([134.134.136.31]:22465 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753031AbdHJSEb (ORCPT ); Thu, 10 Aug 2017 14:04:31 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP; 10 Aug 2017 11:04:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,354,1498546800"; d="scan'208";a="888643332" Received: from phwtpriv07.ph.intel.com ([10.228.208.82]) by FMSMGA003.fm.intel.com with ESMTP; 10 Aug 2017 11:04:30 -0700 From: Don Hiatt To: linux-rdma Subject: [PATCH rdma-next v4 5/8] IB/core: Add functions to convert 32 bit lids to 16 bits Date: Thu, 10 Aug 2017 14:04:25 -0400 Message-Id: <1502388268-20687-6-git-send-email-don.hiatt@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1502388268-20687-1-git-send-email-don.hiatt@intel.com> References: <1502388268-20687-1-git-send-email-don.hiatt@intel.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 Add two helper functions (ib_lid_cpu16(), ib_lid_be16()) to convert 32 bit lids to 16 bits. Signed-off-by: Don Hiatt Reviewed-by: Dennis Dalessandro --- include/rdma/ib_verbs.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index a7d6990..3875ea5d 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -3710,4 +3710,16 @@ static inline enum rdma_ah_attr_type rdma_ah_find_type(struct ib_device *dev, else return RDMA_AH_ATTR_TYPE_IB; } + +/* Return lid in 16bit CPU encoding */ +static inline u16 ib_lid_cpu16(u32 lid) +{ + return (u16)lid; +} + +/* Return lid in 16bit BE encoding */ +static inline u16 ib_lid_be16(u32 lid) +{ + return cpu_to_be16((u16)lid); +} #endif /* IB_VERBS_H */