From patchwork Tue Nov 21 01:41:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 10067583 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 E3E1B603FA for ; Tue, 21 Nov 2017 01:41:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4F62292F4 for ; Tue, 21 Nov 2017 01:41:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9410292E1; Tue, 21 Nov 2017 01:41: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 E60FE292E1 for ; Tue, 21 Nov 2017 01:41:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751347AbdKUBlN (ORCPT ); Mon, 20 Nov 2017 20:41:13 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:37247 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751253AbdKUBlM (ORCPT ); Mon, 20 Nov 2017 20:41:12 -0500 Received: by mail-wm0-f65.google.com with SMTP id v186so136601wma.2 for ; Mon, 20 Nov 2017 17:41:11 -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=05lhSl6lbMqklNV6iScCT7OPpVxPwWHPBYmDso4x/tE=; b=DbDtFSH6/LNxWGtWM2Y/5jI+p6jHSAq6P2MU5rP4SEup2cG9d7pXv5OOFA8KYCDmGQ +6Tl35ckjfNb3j+95oJgJgXTsLJAwGjh/lsY/0sWusi3tsgeXEQ19pbDsF4MsUFnIVXr KKz+lUHsM9D5Eq+bjcEITvUDyJ2meyOsHE3+agP2xXXAOJp/iMiRqyvmweX4rJdT4bkJ paQAY7mtOdliEgpqAPLNOk/1Y0doa6nvfivpOHT2JmJPDpagNr/Be/UOFnOK+ohtZhMy WzlwUgDvO16VkU9QsWpY5ILc6VW5NN8IrkmLQMxzzEa9lVfCi1SLjSQkJKtabo6JUqQy WP7g== 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=05lhSl6lbMqklNV6iScCT7OPpVxPwWHPBYmDso4x/tE=; b=i/Wt4Aqa786nGAjxEKnauw1dTrfdJUby9aRv8df/CQuLOkf2hZeqqyBi7o2Z0chyxv mGgElkTNCOskyC+luZyyzcC5y3/KSJrXG9Z+kPqO8gSs62/mZxkLqt8nJmZ58FNEGo7A hcUBNW5LiYu+NakoRaLtDpxSdIHuJ1eFvxYufxWq568AO3hwdDSbFueO29hzdKsf6zZv ti5m7nwzgb2HGIYi3vfAfFmvd7EbjBKuJ5HTdRTTN4tWv1jQJAIf/E4F1olIT/+/tkAn VeIXHlamQuXNpEV3ySsU8N3La9Vc0UgzyIhEUxc5pvu/ftE4JeWq4gDpfL1TDtnVdeTO K6zw== X-Gm-Message-State: AJaThX4bJ0pq6u91gsXq+3FjV6QXl0pEZ4LmhBJtlaiJVwsnlUdz+p6T 4K/8D0sHUKnXbA5NO80yVgFmmh0o X-Google-Smtp-Source: AGs4zMa1XuMyT5yLLx/k1e41eVB8ovQUovfhegheblYHHufFqr9xUHEMqyZaOoFRY9eJFSAkfTIUiA== X-Received: by 10.28.19.130 with SMTP id 124mr11122356wmt.108.1511228470387; Mon, 20 Nov 2017 17:41:10 -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 o20sm11506857wro.6.2017.11.20.17.41.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2017 17:41:09 -0800 (PST) To: "linux-rdma@vger.kernel.org" From: Hal Rosenstock Subject: [PATCH rdma-core 1/3] libibumad: Add umad_sa_mcm.h for umad SA MCMemberRecord support Message-ID: Date: Mon, 20 Nov 2017 20:41:07 -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 Signed-off-by: Hal Rosenstock --- libibumad/CMakeLists.txt | 1 + libibumad/umad_sa_mcm.h | 193 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 libibumad/umad_sa_mcm.h diff --git a/libibumad/CMakeLists.txt b/libibumad/CMakeLists.txt index ba2463b..b85c94a 100644 --- a/libibumad/CMakeLists.txt +++ b/libibumad/CMakeLists.txt @@ -2,6 +2,7 @@ publish_headers(infiniband umad.h umad_cm.h umad_sa.h + umad_sa_mcm.h umad_sm.h umad_str.h umad_types.h diff --git a/libibumad/umad_sa_mcm.h b/libibumad/umad_sa_mcm.h new file mode 100644 index 0000000..4aaaf02 --- /dev/null +++ b/libibumad/umad_sa_mcm.h @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2017 Mellanox Technologies LTD. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +#ifndef _UMAD_SA_MCM_H +#define _UMAD_SA_MCM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Component mask bits for MCMemberRecord */ +enum { + UMAD_SA_MCM_COMP_MASK_MGID = (1ULL << 0), + UMAD_SA_MCM_COMP_MASK_PORT_GID = (1ULL << 1), + UMAD_SA_MCM_COMP_MASK_QKEY = (1ULL << 2), + UMAD_SA_MCM_COMP_MASK_MLID = (1ULL << 3), + UMAD_SA_MCM_COMP_MASK_MTU_SEL = (1ULL << 4), + UMAD_SA_MCM_COMP_MASK_MTU = (1ULL << 5), + UMAD_SA_MCM_COMP_MASK_TCLASS = (1ULL << 6), + UMAD_SA_MCM_COMP_MASK_PKEY = (1ULL << 7), + UMAD_SA_MCM_COMP_MASK_RATE_SEL = (1ULL << 8), + UMAD_SA_MCM_COMP_MASK_RATE = (1ULL << 9), + UMAD_SA_MCM_COMP_MASK_LIFE_TIME_SEL = (1ULL << 10), + UMAD_SA_MCM_COMP_MASK_LIFE_TIME = (1ULL << 11), + UMAD_SA_MCM_COMP_MASK_SL = (1ULL << 12), + UMAD_SA_MCM_COMP_MASK_FLOW_LABEL = (1ULL << 13), + UMAD_SA_MCM_COMP_MASK_HOP_LIMIT = (1ULL << 14), + UMAD_SA_MCM_COMP_MASK_SCOPE = (1ULL << 15), + UMAD_SA_MCM_COMP_MASK_JOIN_STATE = (1ULL << 16), + 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), + UMAD_SA_MCM_JOIN_STATE_SEND_ONLY_NON_MEMBER = (1 << 2), + UMAD_SA_MCM_JOIN_STATE_SEND_ONLY_FULL_MEMBER = (1 << 3) +}; + +struct umad_sa_mcmember_record { + uint8_t mgid[16]; /* network-byte order */ + uint8_t portgid[16]; /* network-byte order */ + __be32 qkey; + __be16 mlid; + uint8_t mtu; /* 2 bit selector included */ + uint8_t tclass; + __be16 pkey; + uint8_t rate; /* 2 bit selector included */ + uint8_t pkt_life; /* 2 bit selector included */ + __be32 sl_flow_hop; /* SL: 4 bits, FlowLabel: 20 bits, */ + /* HopLimit: 8 bits */ + uint8_t scope_state; /* Scope: 4 bits, JoinState: 4 bits */ + uint8_t proxy_join; /* ProxyJoin: 1 bit (computed by SA) */ + uint8_t reserved[2]; + uint8_t pad[4]; /* SA records are multiple of 8 bytes */ +}; + +static inline void +umad_sa_mcm_get_sl_flow_hop(__be32 sl_flow_hop, uint8_t * const p_sl, + uint32_t * const p_flow_lbl, uint8_t * const p_hop) +{ + uint32_t tmp; + + tmp = ntohl(sl_flow_hop); + if (p_hop) + *p_hop = (uint8_t) tmp; + + tmp >>= 8; + if (p_flow_lbl) + *p_flow_lbl = (uint32_t) (tmp & 0xfffff); + + tmp >>= 20; + if (p_sl) + *p_sl = (uint8_t) tmp; +} + +static inline __be32 +umad_sa_mcm_set_sl_flow_hop(uint8_t sl, uint32_t flow_label, uint8_t hop_limit) +{ + uint32_t tmp; + + tmp = (sl << 28) | ((flow_label & 0xfffff) << 8) | hop_limit; + return htonl(tmp); +} + +static inline void +umad_sa_mcm_get_scope_state(const uint8_t scope_state, uint8_t * const p_scope, + uint8_t * const p_state) +{ + uint8_t tmp_scope_state; + + if (p_state) + *p_state = (uint8_t) (scope_state & 0x0f); + + tmp_scope_state = scope_state >> 4; + + if (p_scope) + *p_scope = (uint8_t) (tmp_scope_state & 0x0f); +} + +static inline uint8_t +umad_sa_mcm_set_scope_state(const uint8_t scope, const uint8_t state) +{ + uint8_t scope_state; + + scope_state = scope; + scope_state = scope_state << 4; + scope_state = scope_state | state; + return scope_state; +} + +static inline void +umad_sa_mcm_set_join_state(struct umad_sa_mcmember_record *p_mc_rec, + const uint8_t state) +{ + /* keep the scope as it is */ + p_mc_rec->scope_state = (p_mc_rec->scope_state & 0xf0) | (0x0f & state); +} + +static inline int +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 +#endif /* _UMAD_SA_MCM_H */