xref: /illumos-gate/usr/src/uts/common/sys/ib/ib_types.h (revision 2d6eb4a5)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*015f8fffShiremath  * Common Development and Distribution License (the "License").
6*015f8fffShiremath  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*015f8fffShiremath  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _SYS_IB_IB_TYPES_H
277c478bd9Sstevel@tonic-gate #define	_SYS_IB_IB_TYPES_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * ib_types.h
317c478bd9Sstevel@tonic-gate  *
327c478bd9Sstevel@tonic-gate  * Data definitions for all IBTA primitive data types.
337c478bd9Sstevel@tonic-gate  */
347c478bd9Sstevel@tonic-gate #include <sys/types.h>
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #ifdef __cplusplus
377c478bd9Sstevel@tonic-gate extern "C" {
387c478bd9Sstevel@tonic-gate #endif
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
427c478bd9Sstevel@tonic-gate  * Addressing types
437c478bd9Sstevel@tonic-gate  *	See Chapter 4 of the IBTA Volume 1 IB specification for more details.
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate #define	IB_EUI64_COMPANYID_MASK		0x0000000000FFFFFF
467c478bd9Sstevel@tonic-gate #define	IB_EUI64_COMPANYID_SHIFT	40
477c478bd9Sstevel@tonic-gate #define	IB_EUI64_IDENTIFIER_MASK	0x000000FFFFFFFFFF
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /* LID Ranges */
507c478bd9Sstevel@tonic-gate #define	IB_LID_UC_FIRST			0x0001
517c478bd9Sstevel@tonic-gate #define	IB_LID_UC_LAST			0xBFFF
527c478bd9Sstevel@tonic-gate #define	IB_LID_MC_FIRST			0xC000
537c478bd9Sstevel@tonic-gate #define	IB_LID_MC_LAST			0xFFFE
547c478bd9Sstevel@tonic-gate #define	IB_LID_PERMISSIVE		0xFFFF
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /* Unicast GID & Multicast GID */
577c478bd9Sstevel@tonic-gate typedef	uint64_t	ib_guid_t;	/* EUI-64 GUID */
587c478bd9Sstevel@tonic-gate typedef	uint64_t	ib_sn_prefix_t;	/* Subnet Prefix */
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate typedef struct ib_ucast_gid_s {
617c478bd9Sstevel@tonic-gate 	ib_sn_prefix_t	ugid_prefix;	/* GID prefix */
627c478bd9Sstevel@tonic-gate 	ib_guid_t	ugid_guid;	/* Port GUID */
637c478bd9Sstevel@tonic-gate } ib_ucast_gid_t;
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate typedef struct ib_mcast_gid_s {
667c478bd9Sstevel@tonic-gate 	uint32_t	mcast_gid_prefix; /* flags, scope, and signature */
677c478bd9Sstevel@tonic-gate 	uint8_t		mcast_gid_bytes[12];
687c478bd9Sstevel@tonic-gate } ib_mcast_gid_t;
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate typedef struct ib_gid_s {
717c478bd9Sstevel@tonic-gate 	union {
727c478bd9Sstevel@tonic-gate 		ib_ucast_gid_t	ucast_gid;	/* unicast gid */
737c478bd9Sstevel@tonic-gate 		ib_mcast_gid_t	mcast_gid;	/* multicast gid */
747c478bd9Sstevel@tonic-gate 	} gid;
757c478bd9Sstevel@tonic-gate } ib_gid_t;
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate #define	gid_prefix	gid.ucast_gid.ugid_prefix
787c478bd9Sstevel@tonic-gate #define	gid_guid	gid.ucast_gid.ugid_guid
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate #define	mgid_prefix	gid.mcast_gid.mcast_gid_prefix
817c478bd9Sstevel@tonic-gate #define	mgid_bytes	gid.mcast_gid.mcast_gid_bytes
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate #define	IB_GID_DEFAULT_PREFIX		0xFE80000000000000
847c478bd9Sstevel@tonic-gate #define	IB_GID_SUBNET_LOCAL_PREFIX	IB_GID_DEFAULT_PREFIX
857c478bd9Sstevel@tonic-gate #define	IB_GID_SITE_LOCAL_PREFIX	0xFEC0000000000000
867c478bd9Sstevel@tonic-gate #define	IB_GID_SITE_LOCAL_SUBNET_MASK	0x000000000000FFFF
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate /* Multicast GID. */
897c478bd9Sstevel@tonic-gate #define	IB_MCGID_PREFIX			0xFF000000
907c478bd9Sstevel@tonic-gate #define	IB_MCGID_TRANSIENT_FLAG		0x00100000
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate /* Multicast Address Scope. */
937c478bd9Sstevel@tonic-gate #define	IB_MC_SCOPE_SUBNET_LOCAL	0x02
947c478bd9Sstevel@tonic-gate #define	IB_MC_SCOPE_SITE_LOCAL		0x05
957c478bd9Sstevel@tonic-gate #define	IB_MC_SCOPE_ORG_LOCAL		0x08
967c478bd9Sstevel@tonic-gate #define	IB_MC_SCOPE_GLOBAL		0x0E
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate /* Multicast Join State. */
997c478bd9Sstevel@tonic-gate #define	IB_MC_JSTATE_FULL		0x01	/* Full Member */
1007c478bd9Sstevel@tonic-gate #define	IB_MC_JSTATE_NON		0x02	/* Non Member */
1017c478bd9Sstevel@tonic-gate #define	IB_MC_JSTATE_SEND_ONLY_NON	0x04	/* Send Only Non Member */
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate #define	IB_MC_QPN			0xFFFFFF	/* Multicast QPN */
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate /*
1067c478bd9Sstevel@tonic-gate  * IP-on-IB Multicast GIDs
1077c478bd9Sstevel@tonic-gate  *
1087c478bd9Sstevel@tonic-gate  * IPV4 gid_prefix:
1097c478bd9Sstevel@tonic-gate  *   IB_MCGID_IPV4_PREFIX
1107c478bd9Sstevel@tonic-gate  *   IB_MCGID_SCOPE_MASK
1117c478bd9Sstevel@tonic-gate  *   IB_MCGID_IP_PKEY_MASK
1127c478bd9Sstevel@tonic-gate  * IPV4 gid_guid:
1137c478bd9Sstevel@tonic-gate  *   IB_MCGID_IPV4_LOW_GROUP_MASK
1147c478bd9Sstevel@tonic-gate  *
1157c478bd9Sstevel@tonic-gate  * IPV6 gid_prefix:
1167c478bd9Sstevel@tonic-gate  *   IB_MCGID_IPV6_PREFIX
1177c478bd9Sstevel@tonic-gate  *   IB_MCGID_SCOPE_MASK
1187c478bd9Sstevel@tonic-gate  *   IB_MCGID_IP_PKEY_MASK
1197c478bd9Sstevel@tonic-gate  *   IB_MCGID_IPV6_HI_GROUP_MASK
1207c478bd9Sstevel@tonic-gate  * IPV6 gid_guid:
1217c478bd9Sstevel@tonic-gate  *   entire gid_guid holds low part of group ID
1227c478bd9Sstevel@tonic-gate  */
1237c478bd9Sstevel@tonic-gate #define	IB_MCGID_IPV4_PREFIX		0xFF10401B
1247c478bd9Sstevel@tonic-gate #define	IB_MCGID_IPV6_PREFIX		0xFF10601B
1257c478bd9Sstevel@tonic-gate #define	IB_MCGID_SA_PREFIX		0xFF10A01B
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate typedef	uint16_t	ib_lid_t;	/* Port Local ID (LID) */
1287c478bd9Sstevel@tonic-gate typedef	uint8_t		ib_path_bits_t;	/* From 0 to 7 low order bits of LID */
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate /*
1317c478bd9Sstevel@tonic-gate  * PKeys and QKeys
1327c478bd9Sstevel@tonic-gate  */
1337c478bd9Sstevel@tonic-gate #define	IB_PKEY_DEFAULT_FULL		0xFFFF
1347c478bd9Sstevel@tonic-gate #define	IB_PKEY_DEFAULT_LIMITED		0x7FFF
1357c478bd9Sstevel@tonic-gate #define	IB_PKEY_INVALID_FULL		0x8000
1367c478bd9Sstevel@tonic-gate #define	IB_PKEY_INVALID_LIMITED		0x0000
1377c478bd9Sstevel@tonic-gate #define	IB_GSI_QKEY			0x80010000
1387c478bd9Sstevel@tonic-gate #define	IB_PRIVILEGED_QKEY_BIT		0x80000000
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate typedef	uint16_t	ib_pkey_t;	/* P_Key */
1417c478bd9Sstevel@tonic-gate typedef	uint32_t	ib_qkey_t;	/* Q_Key */
1427c478bd9Sstevel@tonic-gate typedef	uint16_t	ib_pkey_cntr_t;
1437c478bd9Sstevel@tonic-gate typedef	uint16_t	ib_qkey_cntr_t;
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate /*
1467c478bd9Sstevel@tonic-gate  * General IBT types
1477c478bd9Sstevel@tonic-gate  */
1487c478bd9Sstevel@tonic-gate typedef uint64_t	ib_smkey_t;	/* subnet manager key */
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate typedef	uint16_t	ib_ethertype_t;	/* Ethertype */
1517c478bd9Sstevel@tonic-gate typedef	uint32_t	ib_qpn_t;	/* 24 bit QP number */
1527c478bd9Sstevel@tonic-gate typedef	uint32_t	ib_eecn_t;	/* 24 bit EEC number */
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate #define	IB_QPN_MASK	0xFFFFFF
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate typedef	uint32_t	ib_msglen_t;	/* message length */
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate typedef	uint64_t	ib_vaddr_t;	/* registered memory Virtual Address */
1597c478bd9Sstevel@tonic-gate typedef	uint64_t	ib_memlen_t;	/* registered memory length */
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate typedef	uint64_t	ib_svc_id_t;	/* CM Service ID */
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate #define	IB_SVC_NAME_LEN	64		/* Maximum length of Service Name, */
1647c478bd9Sstevel@tonic-gate 					/* which includes a terminating NULL */
1657c478bd9Sstevel@tonic-gate #define	IB_SVC_DATA_LEN	64		/* Length of Service Data */
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate /* MTU Size */
1687c478bd9Sstevel@tonic-gate typedef enum {
1697c478bd9Sstevel@tonic-gate 	IB_MTU_NOT_SPECIFIED	= 0,
1707c478bd9Sstevel@tonic-gate 	IB_MTU_256		= 1,	/* 256 bytes */
1717c478bd9Sstevel@tonic-gate 	IB_MTU_512		= 2,	/* 512 bytes */
1727c478bd9Sstevel@tonic-gate 	IB_MTU_1K		= 3,	/* 1k bytes */
1737c478bd9Sstevel@tonic-gate 	IB_MTU_2K		= 4,	/* 2k bytes */
1747c478bd9Sstevel@tonic-gate 	IB_MTU_4K		= 5	/* 4k bytes */
1757c478bd9Sstevel@tonic-gate } ib_mtu_t;
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate typedef	uint8_t			ib_time_t;	/* 6 bits of timeout exponent */
1787c478bd9Sstevel@tonic-gate #define	IB_TIME_EXP_MASK	0x3F		/* time = 4.096us * 2 ^ exp */
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate /*
1817c478bd9Sstevel@tonic-gate  * Infiniband Identifiers, based on Administration Group Number (AGN) codes
1827c478bd9Sstevel@tonic-gate  * there are different types of Service IDs which identifies the group.
1837c478bd9Sstevel@tonic-gate  * The first byte of the Service ID comprises of AGN field and following
1847c478bd9Sstevel@tonic-gate  * specifies the values for AGN field.
1857c478bd9Sstevel@tonic-gate  *
1867c478bd9Sstevel@tonic-gate  *	0x0		- IBTA assigned Ids (WellKnown)
1877c478bd9Sstevel@tonic-gate  *	0x1		- IETF (any category)
1887c478bd9Sstevel@tonic-gate  *	0x2		- Locally assigned Ids with limited cacheability
1897c478bd9Sstevel@tonic-gate  *	0x10 to 0x1f	- External Organizations assigned Ids (Well Known)
1907c478bd9Sstevel@tonic-gate  *	others		- Reserved
1917c478bd9Sstevel@tonic-gate  */
1927c478bd9Sstevel@tonic-gate #define	IB_SID_MASK		0x00FFFFFFFFFFFFFF
1937c478bd9Sstevel@tonic-gate #define	IB_SID_AGN_MASK		0xFF00000000000000
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate #define	IB_SID_AGN_IBTA		0x0000000000000000
1967c478bd9Sstevel@tonic-gate #define	IB_SID_AGN_IETF		0x0100000000000000
1977c478bd9Sstevel@tonic-gate #define	IB_SID_AGN_LOCAL	0x0200000000000000
1987c478bd9Sstevel@tonic-gate 
199*015f8fffShiremath #define	IB_SID_IPADDR_PREFIX		0x0000000001000000	/* Byte 4 */
200*015f8fffShiremath #define	IB_SID_IPADDR_PREFIX_MASK	0xFFFFFFFFFE000000
201*015f8fffShiremath #define	IB_SID_IPADDR_IPNUM_MASK	0x0000000000FF0000	/* Byte 5 */
202*015f8fffShiremath #define	IB_SID_IPADDR_PORTNUM_MASK	0x000000000000FFFF	/* Byte 6 & 7 */
203*015f8fffShiremath 
2047c478bd9Sstevel@tonic-gate #ifdef __cplusplus
2057c478bd9Sstevel@tonic-gate }
2067c478bd9Sstevel@tonic-gate #endif
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate #endif /* _SYS_IB_IB_TYPES_H */
209