17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
5ba2e444seb * Common Development and Distribution License (the "License").
6ba2e444seb * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
217c478bdstevel@tonic-gate/*
22d62bc4byz * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bdstevel@tonic-gate * Use is subject to license terms.
247c478bdstevel@tonic-gate */
257c478bdstevel@tonic-gate
267c478bdstevel@tonic-gate#ifndef	_SYS_AGGR_H
277c478bdstevel@tonic-gate#define	_SYS_AGGR_H
287c478bdstevel@tonic-gate
297c478bdstevel@tonic-gate#include <sys/types.h>
307c478bdstevel@tonic-gate#include <sys/ethernet.h>
317c478bdstevel@tonic-gate#include <sys/param.h>
32da14cebEric Cheng#include <sys/mac.h>
33eae72b5Sebastien Roy#include <sys/dld_ioc.h>
347c478bdstevel@tonic-gate
357c478bdstevel@tonic-gate#ifdef	__cplusplus
367c478bdstevel@tonic-gateextern "C" {
377c478bdstevel@tonic-gate#endif
387c478bdstevel@tonic-gate
39eae72b5Sebastien Roy/*
40da14cebEric Cheng * Note that the data structures defined here define an ioctl interface
41eae72b5Sebastien Roy * that is shared betwen user and kernel space.  The aggr driver thus
42eae72b5Sebastien Roy * assumes that the structures have identical layout and size when
43eae72b5Sebastien Roy * compiled in either IPL32 or LP64.
44eae72b5Sebastien Roy */
457c478bdstevel@tonic-gate
467c478bdstevel@tonic-gate/*
477c478bdstevel@tonic-gate * Transmit load balancing policies.
487c478bdstevel@tonic-gate */
497c478bdstevel@tonic-gate
507c478bdstevel@tonic-gate#define	AGGR_POLICY_L2		0x01
517c478bdstevel@tonic-gate#define	AGGR_POLICY_L3		0x02
527c478bdstevel@tonic-gate#define	AGGR_POLICY_L4		0x04
537c478bdstevel@tonic-gate
547c478bdstevel@tonic-gate/*
557c478bdstevel@tonic-gate * LACP mode and timer.
567c478bdstevel@tonic-gate */
577c478bdstevel@tonic-gate
587c478bdstevel@tonic-gatetypedef enum {
597c478bdstevel@tonic-gate	AGGR_LACP_OFF		= 0,
607c478bdstevel@tonic-gate	AGGR_LACP_ACTIVE	= 1,
617c478bdstevel@tonic-gate	AGGR_LACP_PASSIVE	= 2
627c478bdstevel@tonic-gate} aggr_lacp_mode_t;
637c478bdstevel@tonic-gate
647c478bdstevel@tonic-gatetypedef enum {
657c478bdstevel@tonic-gate	AGGR_LACP_TIMER_LONG	= 0,
667c478bdstevel@tonic-gate	AGGR_LACP_TIMER_SHORT	= 1
677c478bdstevel@tonic-gate} aggr_lacp_timer_t;
687c478bdstevel@tonic-gate
697c478bdstevel@tonic-gate/*
707c478bdstevel@tonic-gate * MAC port state.
717c478bdstevel@tonic-gate */
727c478bdstevel@tonic-gatetypedef enum {
737c478bdstevel@tonic-gate	AGGR_PORT_STATE_STANDBY = 1,
747c478bdstevel@tonic-gate	AGGR_PORT_STATE_ATTACHED = 2
757c478bdstevel@tonic-gate} aggr_port_state_t;
767c478bdstevel@tonic-gate
777c478bdstevel@tonic-gate/* Maximum number of ports per aggregation. */
787c478bdstevel@tonic-gate#define	AGGR_MAX_PORTS	256
797c478bdstevel@tonic-gate
807c478bdstevel@tonic-gate/*
81d62bc4byz * The largest configurable aggregation key.  Because by default the key is
82d62bc4byz * used as the DLPI device PPA and default VLAN PPA's are calculated as
83d62bc4byz * ((1000 * vid) + PPA), the largest key can't be > 999.
84d62bc4byz */
85d62bc4byz#define	AGGR_MAX_KEY	999
86d62bc4byz
87d62bc4byz/*
887c478bdstevel@tonic-gate * LACP port state.
897c478bdstevel@tonic-gate */
907c478bdstevel@tonic-gatetypedef union {
917c478bdstevel@tonic-gate	struct {
927c478bdstevel@tonic-gate#if defined(_BIT_FIELDS_HTOL)
937c478bdstevel@tonic-gate		uint8_t expired:	1;
947c478bdstevel@tonic-gate		uint8_t defaulted:	1;
957c478bdstevel@tonic-gate		uint8_t distributing:	1;
967c478bdstevel@tonic-gate		uint8_t collecting:	1;
977c478bdstevel@tonic-gate		uint8_t sync:	1;
987c478bdstevel@tonic-gate		uint8_t aggregation:	1;
997c478bdstevel@tonic-gate		uint8_t timeout:	1;
1007c478bdstevel@tonic-gate		uint8_t	activity:	1;
1017c478bdstevel@tonic-gate#elif defined(_BIT_FIELDS_LTOH)
1027c478bdstevel@tonic-gate		uint8_t	activity:	1;
1037c478bdstevel@tonic-gate		uint8_t timeout:	1;
1047c478bdstevel@tonic-gate		uint8_t aggregation:	1;
1057c478bdstevel@tonic-gate		uint8_t sync:	1;
1067c478bdstevel@tonic-gate		uint8_t collecting:	1;
1077c478bdstevel@tonic-gate		uint8_t distributing:	1;
1087c478bdstevel@tonic-gate		uint8_t defaulted:	1;
1097c478bdstevel@tonic-gate		uint8_t expired:	1;
1107c478bdstevel@tonic-gate#else
1117c478bdstevel@tonic-gate#error "unknown bit fields ordering"
1127c478bdstevel@tonic-gate#endif
1137c478bdstevel@tonic-gate	} bit;
1147c478bdstevel@tonic-gate	uint8_t state;
1157c478bdstevel@tonic-gate} aggr_lacp_state_t;
1167c478bdstevel@tonic-gate
1177c478bdstevel@tonic-gate/* one of the ports of a link aggregation group */
1187c478bdstevel@tonic-gatetypedef struct laioc_port {
119d62bc4byz	datalink_id_t	lp_linkid;
1207c478bdstevel@tonic-gate} laioc_port_t;
1217c478bdstevel@tonic-gate
122eae72b5Sebastien Roy#define	LAIOC_CREATE		AGGRIOC(1)
1237c478bdstevel@tonic-gate
1247c478bdstevel@tonic-gatetypedef struct laioc_create {
125d62bc4byz	datalink_id_t	lc_linkid;
1267c478bdstevel@tonic-gate	uint32_t	lc_key;
1277c478bdstevel@tonic-gate	uint32_t	lc_nports;
1287c478bdstevel@tonic-gate	uint32_t	lc_policy;
1297c478bdstevel@tonic-gate	uchar_t		lc_mac[ETHERADDRL];
1307c478bdstevel@tonic-gate	aggr_lacp_mode_t lc_lacp_mode;
1317c478bdstevel@tonic-gate	aggr_lacp_timer_t lc_lacp_timer;
132d62bc4byz	uint32_t	lc_mac_fixed : 1,
133d62bc4byz			lc_force : 1,
134d62bc4byz			lc_pad_bits : 30;
1357c478bdstevel@tonic-gate} laioc_create_t;
1367c478bdstevel@tonic-gate
137eae72b5Sebastien Roy#define	LAIOC_DELETE		AGGRIOC(2)
1387c478bdstevel@tonic-gate
1397c478bdstevel@tonic-gatetypedef struct laioc_delete {
140d62bc4byz	datalink_id_t	ld_linkid;
1417c478bdstevel@tonic-gate} laioc_delete_t;
1427c478bdstevel@tonic-gate
143eae72b5Sebastien Roy#define	LAIOC_INFO		AGGRIOC(3)
1447c478bdstevel@tonic-gate
1457c478bdstevel@tonic-gatetypedef enum aggr_link_duplex {
1467c478bdstevel@tonic-gate	AGGR_LINK_DUPLEX_FULL = 1,
1477c478bdstevel@tonic-gate	AGGR_LINK_DUPLEX_HALF = 2,
1487c478bdstevel@tonic-gate	AGGR_LINK_DUPLEX_UNKNOWN = 3
1497c478bdstevel@tonic-gate} aggr_link_duplex_t;
1507c478bdstevel@tonic-gate
1517c478bdstevel@tonic-gatetypedef enum aggr_link_state {
1527c478bdstevel@tonic-gate	AGGR_LINK_STATE_UP = 1,
1537c478bdstevel@tonic-gate	AGGR_LINK_STATE_DOWN = 2,
1547c478bdstevel@tonic-gate	AGGR_LINK_STATE_UNKNOWN = 3
1557c478bdstevel@tonic-gate} aggr_link_state_t;
1567c478bdstevel@tonic-gate
1577c478bdstevel@tonic-gatetypedef struct laioc_info_port {
158d62bc4byz	datalink_id_t	lp_linkid;
1597c478bdstevel@tonic-gate	uchar_t		lp_mac[ETHERADDRL];
1607c478bdstevel@tonic-gate	aggr_port_state_t lp_state;
1617c478bdstevel@tonic-gate	aggr_lacp_state_t lp_lacp_state;
1627c478bdstevel@tonic-gate} laioc_info_port_t;
1637c478bdstevel@tonic-gate
1647c478bdstevel@tonic-gatetypedef struct laioc_info_group {
165d62bc4byz	datalink_id_t	lg_linkid;
1667c478bdstevel@tonic-gate	uint32_t	lg_key;
1677c478bdstevel@tonic-gate	uchar_t		lg_mac[ETHERADDRL];
1687c478bdstevel@tonic-gate	boolean_t	lg_mac_fixed;
169d62bc4byz	boolean_t	lg_force;
1707c478bdstevel@tonic-gate	uint32_t	lg_policy;
1717c478bdstevel@tonic-gate	uint32_t	lg_nports;
1727c478bdstevel@tonic-gate	aggr_lacp_mode_t lg_lacp_mode;
1737c478bdstevel@tonic-gate	aggr_lacp_timer_t lg_lacp_timer;
1747c478bdstevel@tonic-gate} laioc_info_group_t;
1757c478bdstevel@tonic-gate
1767c478bdstevel@tonic-gatetypedef struct laioc_info {
177d62bc4byz	/* Must not be DLADM_INVALID_LINKID */
178d62bc4byz	datalink_id_t	li_group_linkid;
179eae72b5Sebastien Roy	uint32_t	li_bufsize;
1807c478bdstevel@tonic-gate} laioc_info_t;
1817c478bdstevel@tonic-gate
182eae72b5Sebastien Roy#define	LAIOC_ADD		AGGRIOC(4)
183eae72b5Sebastien Roy#define	LAIOC_REMOVE		AGGRIOC(5)
1847c478bdstevel@tonic-gate
1857c478bdstevel@tonic-gatetypedef struct laioc_add_rem {
186d62bc4byz	datalink_id_t	la_linkid;
1877c478bdstevel@tonic-gate	uint32_t	la_nports;
188d62bc4byz	uint32_t	la_force;
189210db22ericheng} laioc_add_rem_t;
1907c478bdstevel@tonic-gate
191eae72b5Sebastien Roy#define	LAIOC_MODIFY			AGGRIOC(6)
1927c478bdstevel@tonic-gate
1937c478bdstevel@tonic-gate#define	LAIOC_MODIFY_POLICY		0x01
1947c478bdstevel@tonic-gate#define	LAIOC_MODIFY_MAC		0x02
1957c478bdstevel@tonic-gate#define	LAIOC_MODIFY_LACP_MODE		0x04
1967c478bdstevel@tonic-gate#define	LAIOC_MODIFY_LACP_TIMER		0x08
1977c478bdstevel@tonic-gate
1987c478bdstevel@tonic-gatetypedef struct laioc_modify {
199d62bc4byz	datalink_id_t	lu_linkid;
2007c478bdstevel@tonic-gate	uint8_t		lu_modify_mask;
2017c478bdstevel@tonic-gate	uint32_t	lu_policy;
2027c478bdstevel@tonic-gate	uchar_t		lu_mac[ETHERADDRL];
2037c478bdstevel@tonic-gate	boolean_t	lu_mac_fixed;
2047c478bdstevel@tonic-gate	aggr_lacp_mode_t lu_lacp_mode;
2057c478bdstevel@tonic-gate	aggr_lacp_timer_t lu_lacp_timer;
2067c478bdstevel@tonic-gate} laioc_modify_t;
2077c478bdstevel@tonic-gate
2087c478bdstevel@tonic-gate#ifdef	__cplusplus
2097c478bdstevel@tonic-gate}
2107c478bdstevel@tonic-gate#endif
2117c478bdstevel@tonic-gate
2127c478bdstevel@tonic-gate#endif	/* _SYS_AGGR_H */
213