xref: /onnv-gate/usr/src/uts/common/sys/aggr.h (revision 7408:eff7960d93cd)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52311Sseb  * Common Development and Distribution License (the "License").
62311Sseb  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
225895Syz147064  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_AGGR_H
270Sstevel@tonic-gate #define	_SYS_AGGR_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #include <sys/types.h>
300Sstevel@tonic-gate #include <sys/ethernet.h>
315895Syz147064 #include <sys/mac.h>
325895Syz147064 #include <sys/dls.h>
330Sstevel@tonic-gate #include <sys/param.h>
34*7408SSebastien.Roy@Sun.COM #include <sys/dld_ioc.h>
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #ifdef	__cplusplus
370Sstevel@tonic-gate extern "C" {
380Sstevel@tonic-gate #endif
390Sstevel@tonic-gate 
40*7408SSebastien.Roy@Sun.COM /*
41*7408SSebastien.Roy@Sun.COM  * Note that the datastructures defined here define an ioctl interface
42*7408SSebastien.Roy@Sun.COM  * that is shared betwen user and kernel space.  The aggr driver thus
43*7408SSebastien.Roy@Sun.COM  * assumes that the structures have identical layout and size when
44*7408SSebastien.Roy@Sun.COM  * compiled in either IPL32 or LP64.
45*7408SSebastien.Roy@Sun.COM  */
460Sstevel@tonic-gate 
470Sstevel@tonic-gate /*
480Sstevel@tonic-gate  * Transmit load balancing policies.
490Sstevel@tonic-gate  */
500Sstevel@tonic-gate 
510Sstevel@tonic-gate #define	AGGR_POLICY_L2		0x01
520Sstevel@tonic-gate #define	AGGR_POLICY_L3		0x02
530Sstevel@tonic-gate #define	AGGR_POLICY_L4		0x04
540Sstevel@tonic-gate 
550Sstevel@tonic-gate /*
560Sstevel@tonic-gate  * LACP mode and timer.
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate 
590Sstevel@tonic-gate typedef enum {
600Sstevel@tonic-gate 	AGGR_LACP_OFF		= 0,
610Sstevel@tonic-gate 	AGGR_LACP_ACTIVE	= 1,
620Sstevel@tonic-gate 	AGGR_LACP_PASSIVE	= 2
630Sstevel@tonic-gate } aggr_lacp_mode_t;
640Sstevel@tonic-gate 
650Sstevel@tonic-gate typedef enum {
660Sstevel@tonic-gate 	AGGR_LACP_TIMER_LONG	= 0,
670Sstevel@tonic-gate 	AGGR_LACP_TIMER_SHORT	= 1
680Sstevel@tonic-gate } aggr_lacp_timer_t;
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /*
710Sstevel@tonic-gate  * MAC port state.
720Sstevel@tonic-gate  */
730Sstevel@tonic-gate typedef enum {
740Sstevel@tonic-gate 	AGGR_PORT_STATE_STANDBY = 1,
750Sstevel@tonic-gate 	AGGR_PORT_STATE_ATTACHED = 2
760Sstevel@tonic-gate } aggr_port_state_t;
770Sstevel@tonic-gate 
780Sstevel@tonic-gate /* Maximum number of ports per aggregation. */
790Sstevel@tonic-gate #define	AGGR_MAX_PORTS	256
800Sstevel@tonic-gate 
810Sstevel@tonic-gate /*
825895Syz147064  * The largest configurable aggregation key.  Because by default the key is
835895Syz147064  * used as the DLPI device PPA and default VLAN PPA's are calculated as
845895Syz147064  * ((1000 * vid) + PPA), the largest key can't be > 999.
855895Syz147064  */
865895Syz147064 #define	AGGR_MAX_KEY	999
875895Syz147064 
885895Syz147064 /*
890Sstevel@tonic-gate  * LACP port state.
900Sstevel@tonic-gate  */
910Sstevel@tonic-gate typedef union {
920Sstevel@tonic-gate 	struct {
930Sstevel@tonic-gate #if defined(_BIT_FIELDS_HTOL)
940Sstevel@tonic-gate 		uint8_t expired:	1;
950Sstevel@tonic-gate 		uint8_t defaulted:	1;
960Sstevel@tonic-gate 		uint8_t distributing:	1;
970Sstevel@tonic-gate 		uint8_t collecting:	1;
980Sstevel@tonic-gate 		uint8_t sync:	1;
990Sstevel@tonic-gate 		uint8_t aggregation:	1;
1000Sstevel@tonic-gate 		uint8_t timeout:	1;
1010Sstevel@tonic-gate 		uint8_t	activity:	1;
1020Sstevel@tonic-gate #elif defined(_BIT_FIELDS_LTOH)
1030Sstevel@tonic-gate 		uint8_t	activity:	1;
1040Sstevel@tonic-gate 		uint8_t timeout:	1;
1050Sstevel@tonic-gate 		uint8_t aggregation:	1;
1060Sstevel@tonic-gate 		uint8_t sync:	1;
1070Sstevel@tonic-gate 		uint8_t collecting:	1;
1080Sstevel@tonic-gate 		uint8_t distributing:	1;
1090Sstevel@tonic-gate 		uint8_t defaulted:	1;
1100Sstevel@tonic-gate 		uint8_t expired:	1;
1110Sstevel@tonic-gate #else
1120Sstevel@tonic-gate #error "unknown bit fields ordering"
1130Sstevel@tonic-gate #endif
1140Sstevel@tonic-gate 	} bit;
1150Sstevel@tonic-gate 	uint8_t state;
1160Sstevel@tonic-gate } aggr_lacp_state_t;
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate /* one of the ports of a link aggregation group */
1190Sstevel@tonic-gate typedef struct laioc_port {
1205895Syz147064 	datalink_id_t	lp_linkid;
1210Sstevel@tonic-gate } laioc_port_t;
1220Sstevel@tonic-gate 
123*7408SSebastien.Roy@Sun.COM #define	LAIOC_CREATE		AGGRIOC(1)
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate typedef struct laioc_create {
1265895Syz147064 	datalink_id_t	lc_linkid;
1270Sstevel@tonic-gate 	uint32_t	lc_key;
1280Sstevel@tonic-gate 	uint32_t	lc_nports;
1290Sstevel@tonic-gate 	uint32_t	lc_policy;
1300Sstevel@tonic-gate 	uchar_t		lc_mac[ETHERADDRL];
1310Sstevel@tonic-gate 	aggr_lacp_mode_t lc_lacp_mode;
1320Sstevel@tonic-gate 	aggr_lacp_timer_t lc_lacp_timer;
1335895Syz147064 	uint32_t	lc_mac_fixed : 1,
1345895Syz147064 			lc_force : 1,
1355895Syz147064 			lc_pad_bits : 30;
1360Sstevel@tonic-gate } laioc_create_t;
1370Sstevel@tonic-gate 
138*7408SSebastien.Roy@Sun.COM #define	LAIOC_DELETE		AGGRIOC(2)
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate typedef struct laioc_delete {
1415895Syz147064 	datalink_id_t	ld_linkid;
1420Sstevel@tonic-gate } laioc_delete_t;
1430Sstevel@tonic-gate 
144*7408SSebastien.Roy@Sun.COM #define	LAIOC_INFO		AGGRIOC(3)
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate typedef enum aggr_link_duplex {
1470Sstevel@tonic-gate 	AGGR_LINK_DUPLEX_FULL = 1,
1480Sstevel@tonic-gate 	AGGR_LINK_DUPLEX_HALF = 2,
1490Sstevel@tonic-gate 	AGGR_LINK_DUPLEX_UNKNOWN = 3
1500Sstevel@tonic-gate } aggr_link_duplex_t;
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate typedef enum aggr_link_state {
1530Sstevel@tonic-gate 	AGGR_LINK_STATE_UP = 1,
1540Sstevel@tonic-gate 	AGGR_LINK_STATE_DOWN = 2,
1550Sstevel@tonic-gate 	AGGR_LINK_STATE_UNKNOWN = 3
1560Sstevel@tonic-gate } aggr_link_state_t;
1570Sstevel@tonic-gate 
1580Sstevel@tonic-gate typedef struct laioc_info_port {
1595895Syz147064 	datalink_id_t	lp_linkid;
1600Sstevel@tonic-gate 	uchar_t		lp_mac[ETHERADDRL];
1610Sstevel@tonic-gate 	aggr_port_state_t lp_state;
1620Sstevel@tonic-gate 	aggr_lacp_state_t lp_lacp_state;
1630Sstevel@tonic-gate } laioc_info_port_t;
1640Sstevel@tonic-gate 
1650Sstevel@tonic-gate typedef struct laioc_info_group {
1665895Syz147064 	datalink_id_t	lg_linkid;
1670Sstevel@tonic-gate 	uint32_t	lg_key;
1680Sstevel@tonic-gate 	uchar_t		lg_mac[ETHERADDRL];
1690Sstevel@tonic-gate 	boolean_t	lg_mac_fixed;
1705895Syz147064 	boolean_t	lg_force;
1710Sstevel@tonic-gate 	uint32_t	lg_policy;
1720Sstevel@tonic-gate 	uint32_t	lg_nports;
1730Sstevel@tonic-gate 	aggr_lacp_mode_t lg_lacp_mode;
1740Sstevel@tonic-gate 	aggr_lacp_timer_t lg_lacp_timer;
1750Sstevel@tonic-gate } laioc_info_group_t;
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate typedef struct laioc_info {
1785895Syz147064 	/* Must not be DLADM_INVALID_LINKID */
1795895Syz147064 	datalink_id_t	li_group_linkid;
180*7408SSebastien.Roy@Sun.COM 	uint32_t	li_bufsize;
1810Sstevel@tonic-gate } laioc_info_t;
1820Sstevel@tonic-gate 
183*7408SSebastien.Roy@Sun.COM #define	LAIOC_ADD		AGGRIOC(4)
184*7408SSebastien.Roy@Sun.COM #define	LAIOC_REMOVE		AGGRIOC(5)
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate typedef struct laioc_add_rem {
1875895Syz147064 	datalink_id_t	la_linkid;
1880Sstevel@tonic-gate 	uint32_t	la_nports;
1895895Syz147064 	uint32_t	la_force;
190269Sericheng } laioc_add_rem_t;
1910Sstevel@tonic-gate 
192*7408SSebastien.Roy@Sun.COM #define	LAIOC_MODIFY			AGGRIOC(6)
1930Sstevel@tonic-gate 
1940Sstevel@tonic-gate #define	LAIOC_MODIFY_POLICY		0x01
1950Sstevel@tonic-gate #define	LAIOC_MODIFY_MAC		0x02
1960Sstevel@tonic-gate #define	LAIOC_MODIFY_LACP_MODE		0x04
1970Sstevel@tonic-gate #define	LAIOC_MODIFY_LACP_TIMER		0x08
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate typedef struct laioc_modify {
2005895Syz147064 	datalink_id_t	lu_linkid;
2010Sstevel@tonic-gate 	uint8_t		lu_modify_mask;
2020Sstevel@tonic-gate 	uint32_t	lu_policy;
2030Sstevel@tonic-gate 	uchar_t		lu_mac[ETHERADDRL];
2040Sstevel@tonic-gate 	boolean_t	lu_mac_fixed;
2050Sstevel@tonic-gate 	aggr_lacp_mode_t lu_lacp_mode;
2060Sstevel@tonic-gate 	aggr_lacp_timer_t lu_lacp_timer;
2070Sstevel@tonic-gate } laioc_modify_t;
2080Sstevel@tonic-gate 
2090Sstevel@tonic-gate #ifdef	__cplusplus
2100Sstevel@tonic-gate }
2110Sstevel@tonic-gate #endif
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate #endif	/* _SYS_AGGR_H */
214