~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/rdma/opa_addr.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2 /*
  3  * Copyright(c) 2017 Intel Corporation.
  4  */
  5 
  6 #ifndef OPA_ADDR_H
  7 #define OPA_ADDR_H
  8 
  9 #include <rdma/opa_smi.h>
 10 
 11 #define OPA_SPECIAL_OUI         (0x00066AULL)
 12 #define OPA_MAKE_ID(x)          (cpu_to_be64(OPA_SPECIAL_OUI << 40 | (x)))
 13 #define OPA_TO_IB_UCAST_LID(x) (((x) >= be16_to_cpu(IB_MULTICAST_LID_BASE)) \
 14                                 ? 0 : x)
 15 #define OPA_GID_INDEX           0x1
 16 /**
 17  * 0xF8 - 4 bits of multicast range and 1 bit for collective range
 18  * Example: For 24 bit LID space,
 19  * Multicast range: 0xF00000 to 0xF7FFFF
 20  * Collective range: 0xF80000 to 0xFFFFFE
 21  */
 22 #define OPA_MCAST_NR 0x4 /* Number of top bits set */
 23 #define OPA_COLLECTIVE_NR 0x1 /* Number of bits after MCAST_NR */
 24 
 25 /**
 26  * ib_is_opa_gid: Returns true if the top 24 bits of the gid
 27  * contains the OPA_STL_OUI identifier. This identifies that
 28  * the provided gid is a special purpose GID meant to carry
 29  * extended LID information.
 30  *
 31  * @gid: The Global identifier
 32  */
 33 static inline bool ib_is_opa_gid(const union ib_gid *gid)
 34 {
 35         return ((be64_to_cpu(gid->global.interface_id) >> 40) ==
 36                 OPA_SPECIAL_OUI);
 37 }
 38 
 39 /**
 40  * opa_get_lid_from_gid: Returns the last 32 bits of the gid.
 41  * OPA devices use one of the gids in the gid table to also
 42  * store the lid.
 43  *
 44  * @gid: The Global identifier
 45  */
 46 static inline u32 opa_get_lid_from_gid(const union ib_gid *gid)
 47 {
 48         return be64_to_cpu(gid->global.interface_id) & 0xFFFFFFFF;
 49 }
 50 
 51 /**
 52  * opa_is_extended_lid: Returns true if dlid or slid are
 53  * extended.
 54  *
 55  * @dlid: The DLID
 56  * @slid: The SLID
 57  */
 58 static inline bool opa_is_extended_lid(__be32 dlid, __be32 slid)
 59 {
 60         if ((be32_to_cpu(dlid) >=
 61              be16_to_cpu(IB_MULTICAST_LID_BASE)) ||
 62             (be32_to_cpu(slid) >=
 63              be16_to_cpu(IB_MULTICAST_LID_BASE)))
 64                 return true;
 65 
 66         return false;
 67 }
 68 
 69 /* Get multicast lid base */
 70 static inline u32 opa_get_mcast_base(u32 nr_top_bits)
 71 {
 72         return (be32_to_cpu(OPA_LID_PERMISSIVE) << (32 - nr_top_bits));
 73 }
 74 
 75 /* Check for a valid unicast LID for non-SM traffic types */
 76 static inline bool rdma_is_valid_unicast_lid(struct rdma_ah_attr *attr)
 77 {
 78         if (attr->type == RDMA_AH_ATTR_TYPE_IB) {
 79                 if (!rdma_ah_get_dlid(attr) ||
 80                     rdma_ah_get_dlid(attr) >=
 81                     be16_to_cpu(IB_MULTICAST_LID_BASE))
 82                         return false;
 83         } else if (attr->type == RDMA_AH_ATTR_TYPE_OPA) {
 84                 if (!rdma_ah_get_dlid(attr) ||
 85                     rdma_ah_get_dlid(attr) >=
 86                     opa_get_mcast_base(OPA_MCAST_NR))
 87                         return false;
 88         }
 89         return true;
 90 }
 91 #endif /* OPA_ADDR_H */
 92 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php