1 /*	$NetBSD: ieee8023ad_lacp.h,v 1.3 2008/12/16 22:35:38 christos Exp $	*/
2 
3 /*-
4  * Copyright (c)2005 YAMAMOTO Takashi,
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #ifndef _NET_AGR_IEEE8023AD_LACP_H_
30 #define	_NET_AGR_IEEE8023AD_LACP_H_
31 
32 /*
33  * IEEE802.3ad LACP
34  *
35  * protocol definitions.
36  */
37 
38 struct lacp_systemid {
39 	uint16_t lsi_prio;
40 	uint8_t lsi_mac[6];
41 } __packed;
42 
43 struct lacp_portid {
44 	uint16_t lpi_prio;
45 	uint16_t lpi_portno;
46 } __packed;
47 
48 struct lacp_peerinfo {
49 	struct lacp_systemid lip_systemid;
50 	uint16_t lip_key;
51 	struct lacp_portid lip_portid;
52 	uint8_t lip_state;
53 	uint8_t lip_resv[3];
54 } __packed;
55 
56 #define	LACP_STATE_ACTIVITY	(1<<0)
57 #define	LACP_STATE_TIMEOUT	(1<<1)
58 #define	LACP_STATE_AGGREGATION	(1<<2)
59 #define	LACP_STATE_SYNC		(1<<3)
60 #define	LACP_STATE_COLLECTING	(1<<4)
61 #define	LACP_STATE_DISTRIBUTING	(1<<5)
62 #define	LACP_STATE_DEFAULTED	(1<<6)
63 #define	LACP_STATE_EXPIRED	(1<<7)
64 
65 /* for snprintb(3) */
66 #define	LACP_STATE_BITS		\
67 	"\177\020"		\
68 	"b\0ACTIVITY\0"		\
69 	"b\1TIMEOUT\0"		\
70 	"b\2AGGREGATION\0"	\
71 	"b\3SYNC\0"		\
72 	"b\4COLLECTING\0"	\
73 	"b\5DISTRIBUTING\0"	\
74 	"b\6DEFAULTED\0"		\
75 	"b\7EXPIRED\0"
76 
77 struct lacp_collectorinfo {
78 	uint16_t lci_maxdelay;
79 	uint8_t lci_resv[12];
80 } __packed;
81 
82 struct lacpdu {
83 	struct ether_header ldu_eh;
84 	struct slowprothdr ldu_sph;
85 
86 	struct tlvhdr ldu_tlv_actor;
87 	struct lacp_peerinfo ldu_actor;
88 	struct tlvhdr ldu_tlv_partner;
89 	struct lacp_peerinfo ldu_partner;
90 	struct tlvhdr ldu_tlv_collector;
91 	struct lacp_collectorinfo ldu_collector;
92 	struct tlvhdr ldu_tlv_term;
93 	uint8_t ldu_resv[50];
94 } __packed;
95 
96 #define	LACP_TYPE_ACTORINFO	1
97 #define	LACP_TYPE_PARTNERINFO	2
98 #define	LACP_TYPE_COLLECTORINFO	3
99 
100 /* timeout values (in sec) */
101 #define	LACP_FAST_PERIODIC_TIME		(1)
102 #define	LACP_SLOW_PERIODIC_TIME		(30)
103 #define	LACP_SHORT_TIMEOUT_TIME		(3 * LACP_FAST_PERIODIC_TIME)
104 #define	LACP_LONG_TIMEOUT_TIME		(3 * LACP_SLOW_PERIODIC_TIME)
105 #define	LACP_CHURN_DETECTION_TIME	(60)
106 #define	LACP_AGGREGATE_WAIT_TIME	(2)
107 
108 #endif /* !_NET_AGR_IEEE8023AD_LACP_H_ */
109