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