xref: /titanic_51/usr/src/uts/common/sys/aggr.h (revision d62bc4badc1c1f1549c961cfb8b420e650e1272b)
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
5ba2e4443Sseb  * Common Development and Distribution License (the "License").
6ba2e4443Sseb  * 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*d62bc4baSyz147064  * 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 #ifndef	_SYS_AGGR_H
277c478bd9Sstevel@tonic-gate #define	_SYS_AGGR_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/types.h>
327c478bd9Sstevel@tonic-gate #include <sys/ethernet.h>
33*d62bc4baSyz147064 #include <sys/mac.h>
34*d62bc4baSyz147064 #include <sys/dls.h>
357c478bd9Sstevel@tonic-gate #include <sys/param.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
387c478bd9Sstevel@tonic-gate extern "C" {
397c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /* control interface name */
427c478bd9Sstevel@tonic-gate #define	AGGR_DEVNAME_CTL	"ctl"
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
457c478bd9Sstevel@tonic-gate  * Transmit load balancing policies.
467c478bd9Sstevel@tonic-gate  */
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #define	AGGR_POLICY_L2		0x01
497c478bd9Sstevel@tonic-gate #define	AGGR_POLICY_L3		0x02
507c478bd9Sstevel@tonic-gate #define	AGGR_POLICY_L4		0x04
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * LACP mode and timer.
547c478bd9Sstevel@tonic-gate  */
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate typedef enum {
577c478bd9Sstevel@tonic-gate 	AGGR_LACP_OFF		= 0,
587c478bd9Sstevel@tonic-gate 	AGGR_LACP_ACTIVE	= 1,
597c478bd9Sstevel@tonic-gate 	AGGR_LACP_PASSIVE	= 2
607c478bd9Sstevel@tonic-gate } aggr_lacp_mode_t;
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate typedef enum {
637c478bd9Sstevel@tonic-gate 	AGGR_LACP_TIMER_LONG	= 0,
647c478bd9Sstevel@tonic-gate 	AGGR_LACP_TIMER_SHORT	= 1
657c478bd9Sstevel@tonic-gate } aggr_lacp_timer_t;
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /*
687c478bd9Sstevel@tonic-gate  * MAC port state.
697c478bd9Sstevel@tonic-gate  */
707c478bd9Sstevel@tonic-gate typedef enum {
717c478bd9Sstevel@tonic-gate 	AGGR_PORT_STATE_STANDBY = 1,
727c478bd9Sstevel@tonic-gate 	AGGR_PORT_STATE_ATTACHED = 2
737c478bd9Sstevel@tonic-gate } aggr_port_state_t;
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate /* Maximum number of ports per aggregation. */
767c478bd9Sstevel@tonic-gate #define	AGGR_MAX_PORTS	256
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate /*
79*d62bc4baSyz147064  * The largest configurable aggregation key.  Because by default the key is
80*d62bc4baSyz147064  * used as the DLPI device PPA and default VLAN PPA's are calculated as
81*d62bc4baSyz147064  * ((1000 * vid) + PPA), the largest key can't be > 999.
82*d62bc4baSyz147064  */
83*d62bc4baSyz147064 #define	AGGR_MAX_KEY	999
84*d62bc4baSyz147064 
85*d62bc4baSyz147064 /*
867c478bd9Sstevel@tonic-gate  * LACP port state.
877c478bd9Sstevel@tonic-gate  */
887c478bd9Sstevel@tonic-gate typedef union {
897c478bd9Sstevel@tonic-gate 	struct {
907c478bd9Sstevel@tonic-gate #if defined(_BIT_FIELDS_HTOL)
917c478bd9Sstevel@tonic-gate 		uint8_t expired:	1;
927c478bd9Sstevel@tonic-gate 		uint8_t defaulted:	1;
937c478bd9Sstevel@tonic-gate 		uint8_t distributing:	1;
947c478bd9Sstevel@tonic-gate 		uint8_t collecting:	1;
957c478bd9Sstevel@tonic-gate 		uint8_t sync:	1;
967c478bd9Sstevel@tonic-gate 		uint8_t aggregation:	1;
977c478bd9Sstevel@tonic-gate 		uint8_t timeout:	1;
987c478bd9Sstevel@tonic-gate 		uint8_t	activity:	1;
997c478bd9Sstevel@tonic-gate #elif defined(_BIT_FIELDS_LTOH)
1007c478bd9Sstevel@tonic-gate 		uint8_t	activity:	1;
1017c478bd9Sstevel@tonic-gate 		uint8_t timeout:	1;
1027c478bd9Sstevel@tonic-gate 		uint8_t aggregation:	1;
1037c478bd9Sstevel@tonic-gate 		uint8_t sync:	1;
1047c478bd9Sstevel@tonic-gate 		uint8_t collecting:	1;
1057c478bd9Sstevel@tonic-gate 		uint8_t distributing:	1;
1067c478bd9Sstevel@tonic-gate 		uint8_t defaulted:	1;
1077c478bd9Sstevel@tonic-gate 		uint8_t expired:	1;
1087c478bd9Sstevel@tonic-gate #else
1097c478bd9Sstevel@tonic-gate #error "unknown bit fields ordering"
1107c478bd9Sstevel@tonic-gate #endif
1117c478bd9Sstevel@tonic-gate 	} bit;
1127c478bd9Sstevel@tonic-gate 	uint8_t state;
1137c478bd9Sstevel@tonic-gate } aggr_lacp_state_t;
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate #define	LAIOC(x)		(('l' << 24) | ('a' << 16) | ('m' << 8) | (x))
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate /* one of the ports of a link aggregation group */
1187c478bd9Sstevel@tonic-gate typedef struct laioc_port {
119*d62bc4baSyz147064 	datalink_id_t	lp_linkid;
1207c478bd9Sstevel@tonic-gate } laioc_port_t;
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate #define	LAIOC_CREATE		LAIOC(1)
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate typedef struct laioc_create {
125*d62bc4baSyz147064 	datalink_id_t	lc_linkid;
1267c478bd9Sstevel@tonic-gate 	uint32_t	lc_key;
1277c478bd9Sstevel@tonic-gate 	uint32_t	lc_nports;
1287c478bd9Sstevel@tonic-gate 	uint32_t	lc_policy;
1297c478bd9Sstevel@tonic-gate 	uchar_t		lc_mac[ETHERADDRL];
1307c478bd9Sstevel@tonic-gate 	aggr_lacp_mode_t lc_lacp_mode;
1317c478bd9Sstevel@tonic-gate 	aggr_lacp_timer_t lc_lacp_timer;
132*d62bc4baSyz147064 	uint32_t	lc_mac_fixed : 1,
133*d62bc4baSyz147064 			lc_force : 1,
134*d62bc4baSyz147064 			lc_pad_bits : 30;
1357c478bd9Sstevel@tonic-gate } laioc_create_t;
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate typedef struct laioc_create32 {
140*d62bc4baSyz147064 	datalink_id_t	lc_linkid;
1417c478bd9Sstevel@tonic-gate 	uint32_t	lc_key;
1427c478bd9Sstevel@tonic-gate 	uint32_t	lc_nports;
1437c478bd9Sstevel@tonic-gate 	uint32_t	lc_policy;
1447c478bd9Sstevel@tonic-gate 	uchar_t		lc_mac[ETHERADDRL];
1457c478bd9Sstevel@tonic-gate 	aggr_lacp_mode_t lc_lacp_mode;
1467c478bd9Sstevel@tonic-gate 	aggr_lacp_timer_t lc_lacp_timer;
147*d62bc4baSyz147064 	uint32_t	lc_mac_fixed : 1,
148*d62bc4baSyz147064 			lc_force : 1,
149*d62bc4baSyz147064 			lc_pad_bits : 30;
1507c478bd9Sstevel@tonic-gate } laioc_create32_t;
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate #define	LAIOC_DELETE		LAIOC(2)
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate typedef struct laioc_delete {
157*d62bc4baSyz147064 	datalink_id_t	ld_linkid;
1587c478bd9Sstevel@tonic-gate } laioc_delete_t;
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate typedef struct laioc_delete32 {
163*d62bc4baSyz147064 	datalink_id_t	ld_linkid;
1647c478bd9Sstevel@tonic-gate } laioc_delete32_t;
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate #define	LAIOC_INFO		LAIOC(3)
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate typedef enum aggr_link_duplex {
1717c478bd9Sstevel@tonic-gate 	AGGR_LINK_DUPLEX_FULL = 1,
1727c478bd9Sstevel@tonic-gate 	AGGR_LINK_DUPLEX_HALF = 2,
1737c478bd9Sstevel@tonic-gate 	AGGR_LINK_DUPLEX_UNKNOWN = 3
1747c478bd9Sstevel@tonic-gate } aggr_link_duplex_t;
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate typedef enum aggr_link_state {
1777c478bd9Sstevel@tonic-gate 	AGGR_LINK_STATE_UP = 1,
1787c478bd9Sstevel@tonic-gate 	AGGR_LINK_STATE_DOWN = 2,
1797c478bd9Sstevel@tonic-gate 	AGGR_LINK_STATE_UNKNOWN = 3
1807c478bd9Sstevel@tonic-gate } aggr_link_state_t;
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate typedef struct laioc_info_port {
183*d62bc4baSyz147064 	datalink_id_t	lp_linkid;
1847c478bd9Sstevel@tonic-gate 	uchar_t		lp_mac[ETHERADDRL];
1857c478bd9Sstevel@tonic-gate 	aggr_port_state_t lp_state;
1867c478bd9Sstevel@tonic-gate 	aggr_lacp_state_t lp_lacp_state;
1877c478bd9Sstevel@tonic-gate } laioc_info_port_t;
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate typedef struct laioc_info_group {
190*d62bc4baSyz147064 	datalink_id_t	lg_linkid;
1917c478bd9Sstevel@tonic-gate 	uint32_t	lg_key;
1927c478bd9Sstevel@tonic-gate 	uchar_t		lg_mac[ETHERADDRL];
1937c478bd9Sstevel@tonic-gate 	boolean_t	lg_mac_fixed;
194*d62bc4baSyz147064 	boolean_t	lg_force;
1957c478bd9Sstevel@tonic-gate 	uint32_t	lg_policy;
1967c478bd9Sstevel@tonic-gate 	uint32_t	lg_nports;
1977c478bd9Sstevel@tonic-gate 	aggr_lacp_mode_t lg_lacp_mode;
1987c478bd9Sstevel@tonic-gate 	aggr_lacp_timer_t lg_lacp_timer;
1997c478bd9Sstevel@tonic-gate } laioc_info_group_t;
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate typedef struct laioc_info {
202*d62bc4baSyz147064 	/* Must not be DLADM_INVALID_LINKID */
203*d62bc4baSyz147064 	datalink_id_t	li_group_linkid;
2047c478bd9Sstevel@tonic-gate } laioc_info_t;
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate #define	LAIOC_ADD		LAIOC(4)
2077c478bd9Sstevel@tonic-gate #define	LAIOC_REMOVE		LAIOC(5)
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate typedef struct laioc_add_rem {
210*d62bc4baSyz147064 	datalink_id_t	la_linkid;
2117c478bd9Sstevel@tonic-gate 	uint32_t	la_nports;
212*d62bc4baSyz147064 	uint32_t	la_force;
213210db224Sericheng } laioc_add_rem_t;
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate typedef struct laioc_add_rem32 {
218*d62bc4baSyz147064 	datalink_id_t	la_linkid;
2197c478bd9Sstevel@tonic-gate 	uint32_t	la_nports;
220*d62bc4baSyz147064 	uint32_t	la_force;
2217c478bd9Sstevel@tonic-gate } laioc_add_rem32_t;
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate #define	LAIOC_MODIFY			LAIOC(6)
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate #define	LAIOC_MODIFY_POLICY		0x01
2287c478bd9Sstevel@tonic-gate #define	LAIOC_MODIFY_MAC		0x02
2297c478bd9Sstevel@tonic-gate #define	LAIOC_MODIFY_LACP_MODE		0x04
2307c478bd9Sstevel@tonic-gate #define	LAIOC_MODIFY_LACP_TIMER		0x08
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate typedef struct laioc_modify {
233*d62bc4baSyz147064 	datalink_id_t	lu_linkid;
2347c478bd9Sstevel@tonic-gate 	uint8_t		lu_modify_mask;
2357c478bd9Sstevel@tonic-gate 	uint32_t	lu_policy;
2367c478bd9Sstevel@tonic-gate 	uchar_t		lu_mac[ETHERADDRL];
2377c478bd9Sstevel@tonic-gate 	boolean_t	lu_mac_fixed;
2387c478bd9Sstevel@tonic-gate 	aggr_lacp_mode_t lu_lacp_mode;
2397c478bd9Sstevel@tonic-gate 	aggr_lacp_timer_t lu_lacp_timer;
2407c478bd9Sstevel@tonic-gate } laioc_modify_t;
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate typedef struct laioc_modify32 {
245*d62bc4baSyz147064 	datalink_id_t	lu_linkid;
2467c478bd9Sstevel@tonic-gate 	uint8_t		lu_modify_mask;
2477c478bd9Sstevel@tonic-gate 	uint32_t	lu_policy;
2487c478bd9Sstevel@tonic-gate 	uchar_t		lu_mac[ETHERADDRL];
2497c478bd9Sstevel@tonic-gate 	boolean_t	lu_mac_fixed;
2507c478bd9Sstevel@tonic-gate 	aggr_lacp_mode_t lu_lacp_mode;
2517c478bd9Sstevel@tonic-gate 	aggr_lacp_timer_t lu_lacp_timer;
2527c478bd9Sstevel@tonic-gate } laioc_modify32_t;
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2577c478bd9Sstevel@tonic-gate }
2587c478bd9Sstevel@tonic-gate #endif
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate #endif	/* _SYS_AGGR_H */
261