Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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