xref: /titanic_50/usr/src/uts/common/sys/vlan.h (revision da14cebe459d3275048785f25bd869cb09b5307f)
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
5605445d5Sdg199075  * Common Development and Distribution License (the "License").
6605445d5Sdg199075  * 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*da14cebeSEric Cheng  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate  * vlan.h header for common (non-media specific) VLAN declarations.
287c478bd9Sstevel@tonic-gate  */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifndef	_SYS_VLAN_H
317c478bd9Sstevel@tonic-gate #define	_SYS_VLAN_H
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #define	VLAN_TAGSZ	4
387c478bd9Sstevel@tonic-gate 
39*da14cebeSEric Cheng #define	VLAN_TPID	0x8100u
40*da14cebeSEric Cheng 
417c478bd9Sstevel@tonic-gate #define	VLAN_ID_MASK	0x0fffu
427c478bd9Sstevel@tonic-gate #define	VLAN_ID_SIZE	12
437c478bd9Sstevel@tonic-gate #define	VLAN_ID_SHIFT	0
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate #define	VLAN_CFI_MASK	0x0001u
467c478bd9Sstevel@tonic-gate #define	VLAN_CFI_SIZE	1
477c478bd9Sstevel@tonic-gate #define	VLAN_CFI_SHIFT	(VLAN_ID_SHIFT + VLAN_ID_SIZE)
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #define	VLAN_PRI_MASK	0x0007u
507c478bd9Sstevel@tonic-gate #define	VLAN_PRI_SIZE	3
517c478bd9Sstevel@tonic-gate #define	VLAN_PRI_SHIFT	(VLAN_CFI_SHIFT + VLAN_CFI_SIZE)
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate #define	VLAN_ID_NONE	0
547c478bd9Sstevel@tonic-gate #define	VLAN_ID_MIN	1
557c478bd9Sstevel@tonic-gate #define	VLAN_ID_MAX	4094
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate #define	VLAN_TCI(pri, cfi, vid) \
587c478bd9Sstevel@tonic-gate 	(((pri) << VLAN_PRI_SHIFT) | \
597c478bd9Sstevel@tonic-gate 	((cfi) << VLAN_CFI_SHIFT) | \
607c478bd9Sstevel@tonic-gate 	((vid) << VLAN_ID_SHIFT))
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate  * Deconstruct a VTAG ...
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate #define	VLAN_PRI(tci)	(((tci) >> VLAN_PRI_SHIFT) & VLAN_PRI_MASK)
667c478bd9Sstevel@tonic-gate #define	VLAN_CFI(tci)	(((tci) >> VLAN_CFI_SHIFT) & VLAN_CFI_MASK)
677c478bd9Sstevel@tonic-gate #define	VLAN_ID(tci)	(((tci) >> VLAN_ID_SHIFT) & VLAN_ID_MASK)
687c478bd9Sstevel@tonic-gate 
69605445d5Sdg199075 #define	VLAN_BAND_MAP	32
70605445d5Sdg199075 
71605445d5Sdg199075 #define	VLAN_MBLKPRI(mp)				\
72605445d5Sdg199075 	((((mp)->b_band) / VLAN_BAND_MAP) > 7 ? 0 :	\
73605445d5Sdg199075 	(((mp)->b_band) / VLAN_BAND_MAP))
74605445d5Sdg199075 
757c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
767c478bd9Sstevel@tonic-gate }
777c478bd9Sstevel@tonic-gate #endif
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate #endif	/* _SYS_VLAN_H */
80