Deleted Added
full compact
if_lagg.h (169569) if_lagg.h (170599)
1/* $OpenBSD: if_trunk.h,v 1.11 2007/01/31 06:20:19 reyk Exp $ */
2
3/*
4 * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
1/* $OpenBSD: if_trunk.h,v 1.11 2007/01/31 06:20:19 reyk Exp $ */
2
3/*
4 * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
18 * $FreeBSD: head/sys/net/if_lagg.h 169569 2007-05-15 07:41:46Z thompsa $
18 * $FreeBSD: head/sys/net/if_lagg.h 170599 2007-06-12 07:29:11Z thompsa $
19 */
20
21#ifndef _NET_LAGG_H
22#define _NET_LAGG_H
23
24/*
25 * Global definitions
26 */
27
19 */
20
21#ifndef _NET_LAGG_H
22#define _NET_LAGG_H
23
24/*
25 * Global definitions
26 */
27
28#define LAGG_MAX_PORTS 32 /* logically */
29#define LAGG_MAX_NAMESIZE 32 /* name of a protocol */
30#define LAGG_MAX_STACKING 4 /* maximum number of stacked laggs */
28#define LAGG_MAX_PORTS 32 /* logically */
29#define LAGG_MAX_NAMESIZE 32 /* name of a protocol */
30#define LAGG_MAX_STACKING 4 /* maximum number of stacked laggs */
31
32/* Port flags */
31
32/* Port flags */
33#define LAGG_PORT_SLAVE 0x00000000 /* normal enslaved port */
34#define LAGG_PORT_MASTER 0x00000001 /* primary port */
35#define LAGG_PORT_STACK 0x00000002 /* stacked lagg port */
36#define LAGG_PORT_ACTIVE 0x00000004 /* port is active */
37#define LAGG_PORT_COLLECTING 0x00000008 /* port is receiving frames */
38#define LAGG_PORT_DISTRIBUTING 0x00000010 /* port is sending frames */
39#define LAGG_PORT_DISABLED 0x00000020 /* port is disabled */
40#define LAGG_PORT_GLOBAL 0x80000000 /* IOCTL: global flag */
41#define LAGG_PORT_BITS "\20\01MASTER\02STACK\03ACTIVE\04COLLECTING" \
33#define LAGG_PORT_SLAVE 0x00000000 /* normal enslaved port */
34#define LAGG_PORT_MASTER 0x00000001 /* primary port */
35#define LAGG_PORT_STACK 0x00000002 /* stacked lagg port */
36#define LAGG_PORT_ACTIVE 0x00000004 /* port is active */
37#define LAGG_PORT_COLLECTING 0x00000008 /* port is receiving frames */
38#define LAGG_PORT_DISTRIBUTING 0x00000010 /* port is sending frames */
39#define LAGG_PORT_DISABLED 0x00000020 /* port is disabled */
40#define LAGG_PORT_BITS "\20\01MASTER\02STACK\03ACTIVE\04COLLECTING" \
42 "\05DISTRIBUTING\06DISABLED"
43
44/* Supported lagg PROTOs */
45#define LAGG_PROTO_NONE 0 /* no lagg protocol defined */
46#define LAGG_PROTO_ROUNDROBIN 1 /* simple round robin */
47#define LAGG_PROTO_FAILOVER 2 /* active failover */
48#define LAGG_PROTO_LOADBALANCE 3 /* loadbalance */
49#define LAGG_PROTO_LACP 4 /* 802.3ad lacp */
50#define LAGG_PROTO_ETHERCHANNEL 5 /* Cisco FEC */
51#define LAGG_PROTO_MAX 6
52
53struct lagg_protos {
41 "\05DISTRIBUTING\06DISABLED"
42
43/* Supported lagg PROTOs */
44#define LAGG_PROTO_NONE 0 /* no lagg protocol defined */
45#define LAGG_PROTO_ROUNDROBIN 1 /* simple round robin */
46#define LAGG_PROTO_FAILOVER 2 /* active failover */
47#define LAGG_PROTO_LOADBALANCE 3 /* loadbalance */
48#define LAGG_PROTO_LACP 4 /* 802.3ad lacp */
49#define LAGG_PROTO_ETHERCHANNEL 5 /* Cisco FEC */
50#define LAGG_PROTO_MAX 6
51
52struct lagg_protos {
54 const char *tpr_name;
55 int tpr_proto;
53 const char *lpr_name;
54 int lpr_proto;
56};
57
58#define LAGG_PROTO_DEFAULT LAGG_PROTO_FAILOVER
59#define LAGG_PROTOS { \
60 { "failover", LAGG_PROTO_FAILOVER }, \
61 { "fec", LAGG_PROTO_ETHERCHANNEL }, \
62 { "lacp", LAGG_PROTO_LACP }, \
63 { "loadbalance", LAGG_PROTO_LOADBALANCE }, \

--- 9 unchanged lines hidden (view full) ---

73/* lagg port settings */
74struct lagg_reqport {
75 char rp_ifname[IFNAMSIZ]; /* name of the lagg */
76 char rp_portname[IFNAMSIZ]; /* name of the port */
77 u_int32_t rp_prio; /* port priority */
78 u_int32_t rp_flags; /* port flags */
79};
80
55};
56
57#define LAGG_PROTO_DEFAULT LAGG_PROTO_FAILOVER
58#define LAGG_PROTOS { \
59 { "failover", LAGG_PROTO_FAILOVER }, \
60 { "fec", LAGG_PROTO_ETHERCHANNEL }, \
61 { "lacp", LAGG_PROTO_LACP }, \
62 { "loadbalance", LAGG_PROTO_LOADBALANCE }, \

--- 9 unchanged lines hidden (view full) ---

72/* lagg port settings */
73struct lagg_reqport {
74 char rp_ifname[IFNAMSIZ]; /* name of the lagg */
75 char rp_portname[IFNAMSIZ]; /* name of the port */
76 u_int32_t rp_prio; /* port priority */
77 u_int32_t rp_flags; /* port flags */
78};
79
81#define SIOCGLAGGPORT _IOWR('i', 140, struct lagg_reqport)
82#define SIOCSLAGGPORT _IOW('i', 141, struct lagg_reqport)
83#define SIOCSLAGGDELPORT _IOW('i', 142, struct lagg_reqport)
80#define SIOCGLAGGPORT _IOWR('i', 140, struct lagg_reqport)
81#define SIOCSLAGGPORT _IOW('i', 141, struct lagg_reqport)
82#define SIOCSLAGGDELPORT _IOW('i', 142, struct lagg_reqport)
84
85/* lagg, ports and options */
86struct lagg_reqall {
87 char ra_ifname[IFNAMSIZ]; /* name of the lagg */
88 u_int ra_proto; /* lagg protocol */
89
90 size_t ra_size; /* size of buffer */
91 struct lagg_reqport *ra_port; /* allocated buffer */
92 int ra_ports; /* total port count */
93};
94
83
84/* lagg, ports and options */
85struct lagg_reqall {
86 char ra_ifname[IFNAMSIZ]; /* name of the lagg */
87 u_int ra_proto; /* lagg protocol */
88
89 size_t ra_size; /* size of buffer */
90 struct lagg_reqport *ra_port; /* allocated buffer */
91 int ra_ports; /* total port count */
92};
93
95#define SIOCGLAGG _IOWR('i', 143, struct lagg_reqall)
96#define SIOCSLAGG _IOW('i', 144, struct lagg_reqall)
94#define SIOCGLAGG _IOWR('i', 143, struct lagg_reqall)
95#define SIOCSLAGG _IOW('i', 144, struct lagg_reqall)
97
98#ifdef _KERNEL
99/*
100 * Internal kernel part
101 */
102
96
97#ifdef _KERNEL
98/*
99 * Internal kernel part
100 */
101
103#define lp_ifname lp_ifp->if_xname /* interface name */
104#define lp_link_state lp_ifp->if_link_state /* link state */
105#define lp_capabilities lp_ifp->if_capabilities /* capabilities */
102#define lp_ifname lp_ifp->if_xname /* interface name */
103#define lp_link_state lp_ifp->if_link_state /* link state */
104#define lp_capabilities lp_ifp->if_capabilities /* capabilities */
106
105
107#define LAGG_PORTACTIVE(_tp) ( \
106#define LAGG_PORTACTIVE(_tp) ( \
108 ((_tp)->lp_link_state == LINK_STATE_UP) && \
107 ((_tp)->lp_link_state == LINK_STATE_UP) && \
109 ((_tp)->lp_ifp->if_flags & IFF_UP) \
108 ((_tp)->lp_ifp->if_flags & IFF_UP) \
110)
111
109)
110
112#define mc_enm mc_u.mcu_enm
113
114struct lagg_ifreq {
115 union {
116 struct ifreq ifreq;
117 struct {
118 char ifr_name[IFNAMSIZ];
119 struct sockaddr_storage ifr_ss;
120 } ifreq_storage;
121 } ifreq;
122};
123
111struct lagg_ifreq {
112 union {
113 struct ifreq ifreq;
114 struct {
115 char ifr_name[IFNAMSIZ];
116 struct sockaddr_storage ifr_ss;
117 } ifreq_storage;
118 } ifreq;
119};
120
124#define sc_ifflags sc_ifp->if_flags /* flags */
125#define sc_ifname sc_ifp->if_xname /* name */
126#define sc_capabilities sc_ifp->if_capabilities /* capabilities */
121#define sc_ifflags sc_ifp->if_flags /* flags */
122#define sc_ifname sc_ifp->if_xname /* name */
123#define sc_capabilities sc_ifp->if_capabilities /* capabilities */
127
124
128#define IFCAP_LAGG_MASK 0xffff0000 /* private capabilities */
129#define IFCAP_LAGG_FULLDUPLEX 0x00010000 /* full duplex with >1 ports */
125#define IFCAP_LAGG_MASK 0xffff0000 /* private capabilities */
126#define IFCAP_LAGG_FULLDUPLEX 0x00010000 /* full duplex with >1 ports */
130
131/* Private data used by the loadbalancing protocol */
127
128/* Private data used by the loadbalancing protocol */
132#define LAGG_LB_MAXKEYS 8
133struct lagg_lb {
134 u_int32_t lb_key;
135 struct lagg_port *lb_ports[LAGG_MAX_PORTS];
136};
137
138struct lagg_mc {
139 struct ifmultiaddr *mc_ifma;
140 SLIST_ENTRY(lagg_mc) mc_entries;

--- 32 unchanged lines hidden (view full) ---

173 void (*sc_linkstate)(struct lagg_port *);
174 void (*sc_init)(struct lagg_softc *);
175 void (*sc_stop)(struct lagg_softc *);
176 void (*sc_lladdr)(struct lagg_softc *);
177};
178
179struct lagg_port {
180 struct ifnet *lp_ifp; /* physical interface */
129struct lagg_lb {
130 u_int32_t lb_key;
131 struct lagg_port *lb_ports[LAGG_MAX_PORTS];
132};
133
134struct lagg_mc {
135 struct ifmultiaddr *mc_ifma;
136 SLIST_ENTRY(lagg_mc) mc_entries;

--- 32 unchanged lines hidden (view full) ---

169 void (*sc_linkstate)(struct lagg_port *);
170 void (*sc_init)(struct lagg_softc *);
171 void (*sc_stop)(struct lagg_softc *);
172 void (*sc_lladdr)(struct lagg_softc *);
173};
174
175struct lagg_port {
176 struct ifnet *lp_ifp; /* physical interface */
181 struct lagg_softc *lp_lagg; /* parent lagg */
177 struct lagg_softc *lp_softc; /* parent lagg */
182 uint8_t lp_lladdr[ETHER_ADDR_LEN];
183
184 u_char lp_iftype; /* interface type */
185 uint32_t lp_prio; /* port priority */
186 uint32_t lp_flags; /* port flags */
187 int lp_ifflags; /* saved ifp flags */
188 void *lh_cookie; /* if state hook */
189 caddr_t lp_psc; /* protocol data */

--- 4 unchanged lines hidden (view full) ---

194 /* Redirected callbacks */
195 int (*lp_ioctl)(struct ifnet *, u_long, caddr_t);
196 int (*lp_output)(struct ifnet *, struct mbuf *, struct sockaddr *,
197 struct rtentry *);
198
199 SLIST_ENTRY(lagg_port) lp_entries;
200};
201
178 uint8_t lp_lladdr[ETHER_ADDR_LEN];
179
180 u_char lp_iftype; /* interface type */
181 uint32_t lp_prio; /* port priority */
182 uint32_t lp_flags; /* port flags */
183 int lp_ifflags; /* saved ifp flags */
184 void *lh_cookie; /* if state hook */
185 caddr_t lp_psc; /* protocol data */

--- 4 unchanged lines hidden (view full) ---

190 /* Redirected callbacks */
191 int (*lp_ioctl)(struct ifnet *, u_long, caddr_t);
192 int (*lp_output)(struct ifnet *, struct mbuf *, struct sockaddr *,
193 struct rtentry *);
194
195 SLIST_ENTRY(lagg_port) lp_entries;
196};
197
202#define LAGG_LOCK_INIT(_sc) rw_init(&(_sc)->sc_mtx, "if_lagg rwlock")
203#define LAGG_LOCK_DESTROY(_sc) rw_destroy(&(_sc)->sc_mtx)
204#define LAGG_RLOCK(_sc) rw_rlock(&(_sc)->sc_mtx)
205#define LAGG_WLOCK(_sc) rw_wlock(&(_sc)->sc_mtx)
206#define LAGG_RUNLOCK(_sc) rw_runlock(&(_sc)->sc_mtx)
207#define LAGG_WUNLOCK(_sc) rw_wunlock(&(_sc)->sc_mtx)
208#define LAGG_RLOCK_ASSERT(_sc) rw_assert(&(_sc)->sc_mtx, RA_RLOCKED)
209#define LAGG_WLOCK_ASSERT(_sc) rw_assert(&(_sc)->sc_mtx, RA_WLOCKED)
198#define LAGG_LOCK_INIT(_sc) rw_init(&(_sc)->sc_mtx, "if_lagg rwlock")
199#define LAGG_LOCK_DESTROY(_sc) rw_destroy(&(_sc)->sc_mtx)
200#define LAGG_RLOCK(_sc) rw_rlock(&(_sc)->sc_mtx)
201#define LAGG_WLOCK(_sc) rw_wlock(&(_sc)->sc_mtx)
202#define LAGG_RUNLOCK(_sc) rw_runlock(&(_sc)->sc_mtx)
203#define LAGG_WUNLOCK(_sc) rw_wunlock(&(_sc)->sc_mtx)
204#define LAGG_RLOCK_ASSERT(_sc) rw_assert(&(_sc)->sc_mtx, RA_RLOCKED)
205#define LAGG_WLOCK_ASSERT(_sc) rw_assert(&(_sc)->sc_mtx, RA_WLOCKED)
210
211extern struct mbuf *(*lagg_input_p)(struct ifnet *, struct mbuf *);
212extern void (*lagg_linkstate_p)(struct ifnet *, int );
213
214int lagg_enqueue(struct ifnet *, struct mbuf *);
215uint32_t lagg_hashmbuf(struct mbuf *, uint32_t);
216
217#endif /* _KERNEL */
218
219#endif /* _NET_LAGG_H */
206
207extern struct mbuf *(*lagg_input_p)(struct ifnet *, struct mbuf *);
208extern void (*lagg_linkstate_p)(struct ifnet *, int );
209
210int lagg_enqueue(struct ifnet *, struct mbuf *);
211uint32_t lagg_hashmbuf(struct mbuf *, uint32_t);
212
213#endif /* _KERNEL */
214
215#endif /* _NET_LAGG_H */