1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _LIBDLAGGR_H
27 #define	_LIBDLAGGR_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * This file includes structures, macros and routines used by aggregation link
33  * administration.
34  */
35 
36 #include <sys/types.h>
37 #include <sys/aggr.h>
38 #include <libdladm.h>
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 /*
45  * Modification flags sent with the LAIOC_MODIFY ioctl
46  */
47 #define	DLADM_AGGR_MODIFY_POLICY	0x01
48 #define	DLADM_AGGR_MODIFY_MAC		0x02
49 #define	DLADM_AGGR_MODIFY_LACP_MODE	0x04
50 #define	DLADM_AGGR_MODIFY_LACP_TIMER	0x08
51 
52 typedef struct dladm_aggr_port_attr_db {
53 	datalink_id_t	lp_linkid;
54 } dladm_aggr_port_attr_db_t;
55 
56 typedef struct dladm_aggr_port_attr {
57 	datalink_id_t	lp_linkid;
58 	uchar_t		lp_mac[ETHERADDRL];
59 	aggr_port_state_t lp_state;
60 	aggr_lacp_state_t lp_lacp_state;
61 } dladm_aggr_port_attr_t;
62 
63 typedef struct dladm_aggr_grp_attr {
64 	datalink_id_t	lg_linkid;
65 	uint32_t	lg_key;
66 	uint32_t	lg_nports;
67 	dladm_aggr_port_attr_t *lg_ports;
68 	uint32_t	lg_policy;
69 	uchar_t		lg_mac[ETHERADDRL];
70 	boolean_t	lg_mac_fixed;
71 	boolean_t	lg_force;
72 	aggr_lacp_mode_t lg_lacp_mode;
73 	aggr_lacp_timer_t lg_lacp_timer;
74 } dladm_aggr_grp_attr_t;
75 
76 extern dladm_status_t	dladm_aggr_create(const char *, uint16_t, uint32_t,
77 			    dladm_aggr_port_attr_db_t *, uint32_t, boolean_t,
78 			    const uchar_t *, aggr_lacp_mode_t,
79 			    aggr_lacp_timer_t, uint32_t);
80 extern dladm_status_t	dladm_aggr_delete(datalink_id_t, uint32_t);
81 extern dladm_status_t	dladm_aggr_add(datalink_id_t, uint32_t,
82 			    dladm_aggr_port_attr_db_t *, uint32_t);
83 extern dladm_status_t	dladm_aggr_remove(datalink_id_t, uint32_t,
84 			    dladm_aggr_port_attr_db_t *, uint32_t);
85 extern dladm_status_t	dladm_aggr_modify(datalink_id_t, uint32_t, uint32_t,
86 			    boolean_t, const uchar_t *, aggr_lacp_mode_t,
87 			    aggr_lacp_timer_t, uint32_t);
88 extern dladm_status_t	dladm_aggr_up(datalink_id_t);
89 extern dladm_status_t	dladm_aggr_info(datalink_id_t, dladm_aggr_grp_attr_t *,
90 			    uint32_t);
91 
92 extern boolean_t	dladm_aggr_str2policy(const char *, uint32_t *);
93 extern char		*dladm_aggr_policy2str(uint32_t, char *);
94 extern boolean_t	dladm_aggr_str2macaddr(const char *, boolean_t *,
95 			    uchar_t *);
96 extern const char	*dladm_aggr_macaddr2str(const unsigned char *, char *);
97 extern boolean_t	dladm_aggr_str2lacpmode(const char *,
98 			    aggr_lacp_mode_t *);
99 extern const char	*dladm_aggr_lacpmode2str(aggr_lacp_mode_t, char *);
100 extern boolean_t	dladm_aggr_str2lacptimer(const char *,
101 			    aggr_lacp_timer_t *);
102 extern const char	*dladm_aggr_lacptimer2str(aggr_lacp_timer_t, char *);
103 extern const char	*dladm_aggr_portstate2str(aggr_port_state_t, char *);
104 extern dladm_status_t	dladm_key2linkid(uint16_t, datalink_id_t *,
105 			    uint32_t);
106 
107 #ifdef	__cplusplus
108 }
109 #endif
110 
111 #endif	/* _LIBDLAGGR_H */
112