1 /* $NetBSD: ieee8023ad_lacp_impl.h,v 1.4 2006/10/29 22:14:14 yamt Exp $ */
4 * Copyright (c)2005 YAMAMOTO Takashi,
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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
29 #ifndef _NET_AGR_IEEE8023AD_LACP_IMPL_H_
30 #define _NET_AGR_IEEE8023AD_LACP_IMPL_H_
35 * implementation details.
38 #include <sys/queue.h>
40 #define LACP_TIMER_CURRENT_WHILE 0
41 #define LACP_TIMER_PERIODIC 1
42 #define LACP_TIMER_WAIT_WHILE 2
45 #define LACP_TIMER_ARM(port, timer, val) \
46 (port)->lp_timer[(timer)] = (val)
47 #define LACP_TIMER_DISARM(port, timer) \
48 (port)->lp_timer[(timer)] = 0
49 #define LACP_TIMER_ISARMED(port, timer) \
50 ((port)->lp_timer[(timer)] > 0)
52 struct lacp_aggregator
{
53 TAILQ_ENTRY(lacp_aggregator
) la_q
;
54 int la_refcnt
; /* number of ports which selected us */
55 int la_nports
; /* number of distributing ports */
56 TAILQ_HEAD(, lacp_port
) la_ports
; /* distributing ports */
57 struct lacp_peerinfo la_partner
;
58 struct lacp_peerinfo la_actor
;
59 int la_pending
; /* number of ports which is waiting wait_while */
63 struct lacp_aggregator
*lsc_active_aggregator
;
64 TAILQ_HEAD(, lacp_aggregator
) lsc_aggregators
;
65 bool lsc_suppress_distributing
;
66 struct callout lsc_transit_callout
;
69 #define LACP_TRANSIT_DELAY 1000 /* in msec */
73 LACP_STANDBY
, /* not used in this implementation */
82 LACP_MUX_DISTRIBUTING
,
86 TAILQ_ENTRY(lacp_port
) lp_dist_q
;
87 struct agr_port
*lp_agrport
;
88 struct lacp_peerinfo lp_partner
;
89 struct lacp_peerinfo lp_actor
;
90 #define lp_state lp_actor.lip_state
91 #define lp_key lp_actor.lip_key
92 int lp_last_lacpdu_sent
;
93 enum lacp_mux_state lp_mux_state
;
94 enum lacp_selected lp_selected
;
96 u_int lp_media
; /* XXX redundant */
97 int lp_timer
[LACP_NTIMER
];
99 struct lacp_aggregator
*lp_aggregator
;
102 #define LACPPORT_NTT 1 /* need to transmit */
104 #define LACP_SOFTC(sc) \
105 (&IEEE8023AD_SOFTC(sc)->isc_lacpsc)
106 #define LACP_PORT(port) \
107 (&IEEE8023AD_PORT(port)->iport_lacpport)
109 void lacp_run_timers(struct lacp_port
*);
110 void lacp_portinit(struct agr_port
*);
111 void lacp_portfini(struct agr_port
*);
112 int lacp_compare_peerinfo(const struct lacp_peerinfo
*,
113 const struct lacp_peerinfo
*);
114 int lacp_compare_systemid(const struct lacp_systemid
*,
115 const struct lacp_systemid
*);
116 int lacp_compare_portid(const struct lacp_portid
*,
117 const struct lacp_portid
*);
119 void lacp_select(struct lacp_port
*);
120 void lacp_unselect(struct lacp_port
*);
122 void lacp_disable_collecting(struct lacp_port
*);
123 void lacp_enable_collecting(struct lacp_port
*);
124 void lacp_disable_distributing(struct lacp_port
*);
125 void lacp_enable_distributing(struct lacp_port
*);
127 int lacp_xmit_lacpdu(struct lacp_port
*);
129 #endif /* !_NET_AGR_IEEE8023AD_LACP_IMPL_H_ */