xref: /illumos-gate/usr/src/uts/common/net/trill.h (revision 4eaa4710)
1*4eaa4710SRishi Srivatsavai /*
2*4eaa4710SRishi Srivatsavai  * CDDL HEADER START
3*4eaa4710SRishi Srivatsavai  *
4*4eaa4710SRishi Srivatsavai  * The contents of this file are subject to the terms of the
5*4eaa4710SRishi Srivatsavai  * Common Development and Distribution License (the "License").
6*4eaa4710SRishi Srivatsavai  * You may not use this file except in compliance with the License.
7*4eaa4710SRishi Srivatsavai  *
8*4eaa4710SRishi Srivatsavai  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*4eaa4710SRishi Srivatsavai  * or http://www.opensolaris.org/os/licensing.
10*4eaa4710SRishi Srivatsavai  * See the License for the specific language governing permissions
11*4eaa4710SRishi Srivatsavai  * and limitations under the License.
12*4eaa4710SRishi Srivatsavai  *
13*4eaa4710SRishi Srivatsavai  * When distributing Covered Code, include this CDDL HEADER in each
14*4eaa4710SRishi Srivatsavai  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*4eaa4710SRishi Srivatsavai  * If applicable, add the following below this CDDL HEADER, with the
16*4eaa4710SRishi Srivatsavai  * fields enclosed by brackets "[]" replaced with your own identifying
17*4eaa4710SRishi Srivatsavai  * information: Portions Copyright [yyyy] [name of copyright owner]
18*4eaa4710SRishi Srivatsavai  *
19*4eaa4710SRishi Srivatsavai  * CDDL HEADER END
20*4eaa4710SRishi Srivatsavai  */
21*4eaa4710SRishi Srivatsavai 
22*4eaa4710SRishi Srivatsavai /*
23*4eaa4710SRishi Srivatsavai  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*4eaa4710SRishi Srivatsavai  * Use is subject to license terms.
25*4eaa4710SRishi Srivatsavai  */
26*4eaa4710SRishi Srivatsavai 
27*4eaa4710SRishi Srivatsavai #ifndef _NET_TRILL_H
28*4eaa4710SRishi Srivatsavai #define	_NET_TRILL_H
29*4eaa4710SRishi Srivatsavai 
30*4eaa4710SRishi Srivatsavai #include <sys/types.h>
31*4eaa4710SRishi Srivatsavai #include <sys/param.h>
32*4eaa4710SRishi Srivatsavai #include <sys/ethernet.h>
33*4eaa4710SRishi Srivatsavai 
34*4eaa4710SRishi Srivatsavai #ifdef __cplusplus
35*4eaa4710SRishi Srivatsavai extern "C" {
36*4eaa4710SRishi Srivatsavai #endif
37*4eaa4710SRishi Srivatsavai 
38*4eaa4710SRishi Srivatsavai /* Various well-known Ethernet addresses used by TRILL */
39*4eaa4710SRishi Srivatsavai #define	ALL_RBRIDGES		{ 0x01, 0x80, 0xC2, 0x00, 0x02, 0x00 }
40*4eaa4710SRishi Srivatsavai #define	ALL_ISIS_RBRIDGES	{ 0x01, 0x80, 0xC2, 0x00, 0x02, 0x01 }
41*4eaa4710SRishi Srivatsavai #define	ALL_ESADI_RBRIDGES	{ 0x01, 0x80, 0xC2, 0x00, 0x02, 0x02 }
42*4eaa4710SRishi Srivatsavai 
43*4eaa4710SRishi Srivatsavai #define	TRILL_PROTOCOL_VERS 0	/* th_version */
44*4eaa4710SRishi Srivatsavai #define	TRILL_DEFAULT_HOPS 21	/* th_hopcount */
45*4eaa4710SRishi Srivatsavai 
46*4eaa4710SRishi Srivatsavai /* Nickname range */
47*4eaa4710SRishi Srivatsavai #define	RBRIDGE_NICKNAME_MIN		0x0000
48*4eaa4710SRishi Srivatsavai #define	RBRIDGE_NICKNAME_MAX		0xFFFF
49*4eaa4710SRishi Srivatsavai 
50*4eaa4710SRishi Srivatsavai /* Define well-known nicknames */
51*4eaa4710SRishi Srivatsavai #define	RBRIDGE_NICKNAME_NONE		RBRIDGE_NICKNAME_MIN
52*4eaa4710SRishi Srivatsavai #define	RBRIDGE_NICKNAME_MINRES		0xFFC0
53*4eaa4710SRishi Srivatsavai #define	RBRIDGE_NICKNAME_MAXRES		(RBRIDGE_NICKNAME_MAX - 1)
55*4eaa4710SRishi Srivatsavai 
56*4eaa4710SRishi Srivatsavai #define	MIN_RBRIDGE_RANDOM_NICKNAME	(RBRIDGE_NICKNAME_NONE + 1)
58*4eaa4710SRishi Srivatsavai 
59*4eaa4710SRishi Srivatsavai /* AF_TRILL IOCTL codes */
60*4eaa4710SRishi Srivatsavai #define	TRILL_BASE	(0x54524c00)	/* base (TRL in hex) */
61*4eaa4710SRishi Srivatsavai #define	TRILL_SETNICK	(TRILL_BASE + 0)    /* trill_node_t */
62*4eaa4710SRishi Srivatsavai #define	TRILL_GETNICK	(TRILL_BASE + 1)    /* uint16_t */
63*4eaa4710SRishi Srivatsavai #define	TRILL_ADDNICK	(TRILL_BASE + 2)    /* trill_node_t */
64*4eaa4710SRishi Srivatsavai #define	TRILL_DELNICK	(TRILL_BASE + 3)    /* uint16_t */
65*4eaa4710SRishi Srivatsavai #define	TRILL_DELALL	(TRILL_BASE + 4)    /* void */
66*4eaa4710SRishi Srivatsavai #define	TRILL_HWADDR	(TRILL_BASE + 5)    /* uint8_t[ETHERADDRL] */
67*4eaa4710SRishi Srivatsavai #define	TRILL_TREEROOT	(TRILL_BASE + 6)    /* uint16_t */
68*4eaa4710SRishi Srivatsavai #define	TRILL_NEWBRIDGE	(TRILL_BASE + 7)    /* char[MAXLINKNAMELEN] */
69*4eaa4710SRishi Srivatsavai #define	TRILL_VLANFWDER	(TRILL_BASE + 8)    /* uint8_t[TRILL_VLANS_ARRSIZE] */
70*4eaa4710SRishi Srivatsavai #define	TRILL_DESIGVLAN (TRILL_BASE + 9)    /* uint16_t */
71*4eaa4710SRishi Srivatsavai #define	TRILL_LISTNICK	(TRILL_BASE + 10)   /* trill_listnick_t */
72*4eaa4710SRishi Srivatsavai #define	TRILL_GETBRIDGE	(TRILL_BASE + 11)   /* char[MAXLINKNAMELEN] */
73*4eaa4710SRishi Srivatsavai #define	TRILL_PORTFLUSH	(TRILL_BASE + 12)   /* uint16_t */
74*4eaa4710SRishi Srivatsavai #define	TRILL_NICKFLUSH	(TRILL_BASE + 13)   /* uint16_t */
75*4eaa4710SRishi Srivatsavai #define	TRILL_GETMTU	(TRILL_BASE + 14)   /* uint_t * */
76*4eaa4710SRishi Srivatsavai 
77*4eaa4710SRishi Srivatsavai typedef struct trill_header {
78*4eaa4710SRishi Srivatsavai #ifdef	_BIT_FIELDS_HTOL
79*4eaa4710SRishi Srivatsavai 	uint8_t th_version : 2;
80*4eaa4710SRishi Srivatsavai 	uint8_t th_reserved : 2;
81*4eaa4710SRishi Srivatsavai 	uint8_t th_multidest : 1;
82*4eaa4710SRishi Srivatsavai 	uint8_t th_optslen_hi : 3;
83*4eaa4710SRishi Srivatsavai #else
84*4eaa4710SRishi Srivatsavai 	uint8_t th_optslen_hi : 3;
85*4eaa4710SRishi Srivatsavai 	uint8_t th_multidest : 1;
86*4eaa4710SRishi Srivatsavai 	uint8_t th_reserved : 2;
87*4eaa4710SRishi Srivatsavai 	uint8_t th_version : 2;
88*4eaa4710SRishi Srivatsavai #endif
89*4eaa4710SRishi Srivatsavai 
90*4eaa4710SRishi Srivatsavai #ifdef	_BIT_FIELDS_HTOL
91*4eaa4710SRishi Srivatsavai 	uint8_t th_optslen_lo : 2;
92*4eaa4710SRishi Srivatsavai 	uint8_t th_hopcount : 6;
93*4eaa4710SRishi Srivatsavai #else
94*4eaa4710SRishi Srivatsavai 	uint8_t th_hopcount : 6;
95*4eaa4710SRishi Srivatsavai 	uint8_t th_optslen_lo : 2;
96*4eaa4710SRishi Srivatsavai #endif
97*4eaa4710SRishi Srivatsavai 	uint16_t th_egressnick;
98*4eaa4710SRishi Srivatsavai 	uint16_t th_ingressnick;
99*4eaa4710SRishi Srivatsavai } trill_header_t;
100*4eaa4710SRishi Srivatsavai 
101*4eaa4710SRishi Srivatsavai #define	TRILL_HDR_ALIGN		(sizeof (uint16_t))
102*4eaa4710SRishi Srivatsavai 
103*4eaa4710SRishi Srivatsavai #define	SET_TRILL_OPTS_LEN(hdr_p, val) \
104*4eaa4710SRishi Srivatsavai 	do { \
105*4eaa4710SRishi Srivatsavai 		(hdr_p)->th_optslen_lo = (val)&0x03;	\
106*4eaa4710SRishi Srivatsavai 		(hdr_p)->th_optslen_hi = (val)>>2;	\
107*4eaa4710SRishi Srivatsavai 		_NOTE(CONSTANTCONDITION)		\
108*4eaa4710SRishi Srivatsavai 	} while (0)
109*4eaa4710SRishi Srivatsavai 
110*4eaa4710SRishi Srivatsavai #define	GET_TRILL_OPTS_LEN(hdr_p) \
111*4eaa4710SRishi Srivatsavai 	((hdr_p)->th_optslen_lo|((hdr_p)->th_optslen_hi<<2))
112*4eaa4710SRishi Srivatsavai 
113*4eaa4710SRishi Srivatsavai /* RBridge nick and tree information (*variable* size) */
114*4eaa4710SRishi Srivatsavai typedef struct trill_nickinfo_s {
115*4eaa4710SRishi Srivatsavai 	/* Nickname of the RBridge */
116*4eaa4710SRishi Srivatsavai 	uint16_t	tni_nick;
117*4eaa4710SRishi Srivatsavai 	/* Next-hop SNPA address to reach this RBridge */
118*4eaa4710SRishi Srivatsavai 	ether_addr_t	tni_adjsnpa;
119*4eaa4710SRishi Srivatsavai 	/* Link on our system to use to reach next-hop */
120*4eaa4710SRishi Srivatsavai 	datalink_id_t	tni_linkid;
121*4eaa4710SRishi Srivatsavai 	/* Num of *our* adjacencies on a tree rooted at this RBridge */
122*4eaa4710SRishi Srivatsavai 	uint16_t	tni_adjcount;
123*4eaa4710SRishi Srivatsavai 	/* Num of distribution tree root nicks chosen by this RBridge */
124*4eaa4710SRishi Srivatsavai 	uint16_t	tni_dtrootcount;
125*4eaa4710SRishi Srivatsavai 	/*
126*4eaa4710SRishi Srivatsavai 	 * Variable size bytes to store adjacency nicks, distribution
127*4eaa4710SRishi Srivatsavai 	 * tree roots and VLAN filter lists. Adjacency nicks and
128*4eaa4710SRishi Srivatsavai 	 * distribution tree roots are 16-bit fields.
129*4eaa4710SRishi Srivatsavai 	 *
130*4eaa4710SRishi Srivatsavai 	 * Number of VLAN filter lists is equal to tni_adjcount as
131*4eaa4710SRishi Srivatsavai 	 * the VLAN filter list is one per adjacency in each DT.
132*4eaa4710SRishi Srivatsavai 	 * VLAN filter list is a 512 byte bitmap with the set of VLANs
133*4eaa4710SRishi Srivatsavai 	 * that are reachable downstream via the adjacency.
134*4eaa4710SRishi Srivatsavai 	 */
135*4eaa4710SRishi Srivatsavai } trill_nickinfo_t;
136*4eaa4710SRishi Srivatsavai 
137*4eaa4710SRishi Srivatsavai typedef struct trill_listnick_s {
138*4eaa4710SRishi Srivatsavai 	uint16_t	tln_nick;
139*4eaa4710SRishi Srivatsavai 	ether_addr_t	tln_nexthop;
140*4eaa4710SRishi Srivatsavai 	datalink_id_t	tln_linkid;
141*4eaa4710SRishi Srivatsavai 	boolean_t	tln_ours;
142*4eaa4710SRishi Srivatsavai } trill_listnick_t;
143*4eaa4710SRishi Srivatsavai 
144*4eaa4710SRishi Srivatsavai /* Access the adjacency nick list at the end of trill_nickinfo_t */
145*4eaa4710SRishi Srivatsavai #define	TNI_ADJNICKSPTR(v) ((uint16_t *)((trill_nickinfo_t *)(v)+1))
146*4eaa4710SRishi Srivatsavai #define	TNI_ADJNICK(v, n) (TNI_ADJNICKSPTR(v)[(n)])
147*4eaa4710SRishi Srivatsavai 
148*4eaa4710SRishi Srivatsavai /* Access the DT root nick list in trill_nickinfo_t after adjacency nicks */
149*4eaa4710SRishi Srivatsavai #define	TNI_DTROOTNICKSPTR(v) (TNI_ADJNICKSPTR(v)+(v)->tni_adjcount)
150*4eaa4710SRishi Srivatsavai #define	TNI_DTROOTNICK(v, n) (TNI_DTROOTNICKSPTR(v)[(n)])
151*4eaa4710SRishi Srivatsavai 
152*4eaa4710SRishi Srivatsavai /* Access the VLAN filter list in trill_nickinfo_t after DT Roots */
153*4eaa4710SRishi Srivatsavai #define	TNI_VLANFILTERSPTR(v) (TNI_DTROOTNICKSPTR(v)+(v)->tni_dtrootcount)
154*4eaa4710SRishi Srivatsavai #define	TNI_VLANFILTERMAP(v, n) \
155*4eaa4710SRishi Srivatsavai 	(((uint8_t *)(TNI_VLANFILTERSPTR(v)))+((n)*((1<<12)/NBBY)))
156*4eaa4710SRishi Srivatsavai 
157*4eaa4710SRishi Srivatsavai #define	TNI_TOTALSIZE(v) (sizeof (trill_nickinfo_t) + \
158*4eaa4710SRishi Srivatsavai 	(sizeof (uint16_t) * (v)->tni_adjcount) + \
159*4eaa4710SRishi Srivatsavai 	(sizeof (uint16_t) * (v)->tni_dtrootcount) + \
160*4eaa4710SRishi Srivatsavai 	(((1<<12)/NBBY) * (v)->tni_adjcount))
161*4eaa4710SRishi Srivatsavai 
162*4eaa4710SRishi Srivatsavai /*
163*4eaa4710SRishi Srivatsavai  * This is a special value used in the sockaddr_dl "selector" field to denote
164*4eaa4710SRishi Srivatsavai  * that the packet represents a Bridging PDU.  The core STP instance is not
165*4eaa4710SRishi Srivatsavai  * defined on a VLAN, so this overload is safe.  All other selector values are
166*4eaa4710SRishi Srivatsavai  * used for TRILL IS-IS PDUs to indicate VLAN ID.
167*4eaa4710SRishi Srivatsavai  */
168*4eaa4710SRishi Srivatsavai #define	TRILL_TCI_BPDU	0xFFFF
169*4eaa4710SRishi Srivatsavai 
170*4eaa4710SRishi Srivatsavai #ifdef __cplusplus
171*4eaa4710SRishi Srivatsavai }
172*4eaa4710SRishi Srivatsavai #endif
173*4eaa4710SRishi Srivatsavai 
174*4eaa4710SRishi Srivatsavai #endif /* _NET_TRILL_H */