2007-04-17 00:35:11 +00:00
|
|
|
/* $OpenBSD: if_trunk.h,v 1.11 2007/01/31 06:20:19 reyk Exp $ */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NET_LAGG_H
|
|
|
|
#define _NET_LAGG_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Global definitions
|
|
|
|
*/
|
|
|
|
|
2007-06-12 07:29:11 +00:00
|
|
|
#define LAGG_MAX_PORTS 32 /* logically */
|
|
|
|
#define LAGG_MAX_NAMESIZE 32 /* name of a protocol */
|
|
|
|
#define LAGG_MAX_STACKING 4 /* maximum number of stacked laggs */
|
2007-04-17 00:35:11 +00:00
|
|
|
|
2012-03-06 22:58:13 +00:00
|
|
|
/* Lagg flags */
|
|
|
|
#define LAGG_F_HASHL2 0x00000001 /* hash layer 2 */
|
|
|
|
#define LAGG_F_HASHL3 0x00000002 /* hash layer 3 */
|
|
|
|
#define LAGG_F_HASHL4 0x00000004 /* hash layer 4 */
|
|
|
|
#define LAGG_F_HASHMASK 0x00000007
|
|
|
|
|
2007-04-17 00:35:11 +00:00
|
|
|
/* Port flags */
|
2007-06-12 07:29:11 +00:00
|
|
|
#define LAGG_PORT_SLAVE 0x00000000 /* normal enslaved port */
|
|
|
|
#define LAGG_PORT_MASTER 0x00000001 /* primary port */
|
|
|
|
#define LAGG_PORT_STACK 0x00000002 /* stacked lagg port */
|
|
|
|
#define LAGG_PORT_ACTIVE 0x00000004 /* port is active */
|
|
|
|
#define LAGG_PORT_COLLECTING 0x00000008 /* port is receiving frames */
|
|
|
|
#define LAGG_PORT_DISTRIBUTING 0x00000010 /* port is sending frames */
|
|
|
|
#define LAGG_PORT_BITS "\20\01MASTER\02STACK\03ACTIVE\04COLLECTING" \
|
2018-05-22 15:35:38 +00:00
|
|
|
"\05DISTRIBUTING"
|
2007-04-17 00:35:11 +00:00
|
|
|
|
|
|
|
/* Supported lagg PROTOs */
|
2014-09-26 08:12:12 +00:00
|
|
|
typedef enum {
|
|
|
|
LAGG_PROTO_NONE = 0, /* no lagg protocol defined */
|
|
|
|
LAGG_PROTO_ROUNDROBIN, /* simple round robin */
|
|
|
|
LAGG_PROTO_FAILOVER, /* active failover */
|
|
|
|
LAGG_PROTO_LOADBALANCE, /* loadbalance */
|
|
|
|
LAGG_PROTO_LACP, /* 802.3ad lacp */
|
|
|
|
LAGG_PROTO_BROADCAST, /* broadcast */
|
|
|
|
LAGG_PROTO_MAX,
|
|
|
|
} lagg_proto;
|
2007-04-17 00:35:11 +00:00
|
|
|
|
|
|
|
struct lagg_protos {
|
2007-06-12 07:29:11 +00:00
|
|
|
const char *lpr_name;
|
2014-09-26 08:12:12 +00:00
|
|
|
lagg_proto lpr_proto;
|
2007-04-17 00:35:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define LAGG_PROTO_DEFAULT LAGG_PROTO_FAILOVER
|
|
|
|
#define LAGG_PROTOS { \
|
2020-01-09 14:58:41 +00:00
|
|
|
{ "failover", LAGG_PROTO_FAILOVER }, \
|
2007-04-17 00:35:11 +00:00
|
|
|
{ "lacp", LAGG_PROTO_LACP }, \
|
|
|
|
{ "loadbalance", LAGG_PROTO_LOADBALANCE }, \
|
2020-01-09 14:58:41 +00:00
|
|
|
{ "roundrobin", LAGG_PROTO_ROUNDROBIN }, \
|
|
|
|
{ "broadcast", LAGG_PROTO_BROADCAST }, \
|
2007-04-17 00:35:11 +00:00
|
|
|
{ "none", LAGG_PROTO_NONE }, \
|
|
|
|
{ "default", LAGG_PROTO_DEFAULT } \
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* lagg ioctls.
|
|
|
|
*/
|
|
|
|
|
2007-07-05 09:18:57 +00:00
|
|
|
/*
|
|
|
|
* LACP current operational parameters structure.
|
|
|
|
*/
|
|
|
|
struct lacp_opreq {
|
|
|
|
uint16_t actor_prio;
|
|
|
|
uint8_t actor_mac[ETHER_ADDR_LEN];
|
|
|
|
uint16_t actor_key;
|
|
|
|
uint16_t actor_portprio;
|
|
|
|
uint16_t actor_portno;
|
|
|
|
uint8_t actor_state;
|
|
|
|
uint16_t partner_prio;
|
|
|
|
uint8_t partner_mac[ETHER_ADDR_LEN];
|
|
|
|
uint16_t partner_key;
|
|
|
|
uint16_t partner_portprio;
|
|
|
|
uint16_t partner_portno;
|
|
|
|
uint8_t partner_state;
|
|
|
|
};
|
|
|
|
|
2007-04-17 00:35:11 +00:00
|
|
|
/* lagg port settings */
|
|
|
|
struct lagg_reqport {
|
|
|
|
char rp_ifname[IFNAMSIZ]; /* name of the lagg */
|
|
|
|
char rp_portname[IFNAMSIZ]; /* name of the port */
|
|
|
|
u_int32_t rp_prio; /* port priority */
|
|
|
|
u_int32_t rp_flags; /* port flags */
|
2007-07-05 09:18:57 +00:00
|
|
|
union {
|
|
|
|
struct lacp_opreq rpsc_lacp;
|
|
|
|
} rp_psc;
|
|
|
|
#define rp_lacpreq rp_psc.rpsc_lacp
|
2007-04-17 00:35:11 +00:00
|
|
|
};
|
|
|
|
|
2007-06-12 07:29:11 +00:00
|
|
|
#define SIOCGLAGGPORT _IOWR('i', 140, struct lagg_reqport)
|
|
|
|
#define SIOCSLAGGPORT _IOW('i', 141, struct lagg_reqport)
|
|
|
|
#define SIOCSLAGGDELPORT _IOW('i', 142, struct lagg_reqport)
|
2007-04-17 00:35:11 +00:00
|
|
|
|
|
|
|
/* lagg, ports and options */
|
|
|
|
struct lagg_reqall {
|
|
|
|
char ra_ifname[IFNAMSIZ]; /* name of the lagg */
|
|
|
|
u_int ra_proto; /* lagg protocol */
|
|
|
|
|
|
|
|
size_t ra_size; /* size of buffer */
|
|
|
|
struct lagg_reqport *ra_port; /* allocated buffer */
|
|
|
|
int ra_ports; /* total port count */
|
2007-07-05 09:18:57 +00:00
|
|
|
union {
|
|
|
|
struct lacp_opreq rpsc_lacp;
|
|
|
|
} ra_psc;
|
|
|
|
#define ra_lacpreq ra_psc.rpsc_lacp
|
2007-04-17 00:35:11 +00:00
|
|
|
};
|
|
|
|
|
2007-06-12 07:29:11 +00:00
|
|
|
#define SIOCGLAGG _IOWR('i', 143, struct lagg_reqall)
|
|
|
|
#define SIOCSLAGG _IOW('i', 144, struct lagg_reqall)
|
2007-04-17 00:35:11 +00:00
|
|
|
|
2012-03-06 22:58:13 +00:00
|
|
|
struct lagg_reqflags {
|
|
|
|
char rf_ifname[IFNAMSIZ]; /* name of the lagg */
|
|
|
|
uint32_t rf_flags; /* lagg protocol */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SIOCGLAGGFLAGS _IOWR('i', 145, struct lagg_reqflags)
|
|
|
|
#define SIOCSLAGGHASH _IOW('i', 146, struct lagg_reqflags)
|
|
|
|
|
2014-10-02 20:01:13 +00:00
|
|
|
struct lagg_reqopts {
|
|
|
|
char ro_ifname[IFNAMSIZ]; /* name of the lagg */
|
|
|
|
|
|
|
|
int ro_opts; /* Option bitmap */
|
|
|
|
#define LAGG_OPT_NONE 0x00
|
2014-12-01 11:45:24 +00:00
|
|
|
#define LAGG_OPT_USE_FLOWID 0x01 /* enable use of flowid */
|
2014-10-02 20:01:13 +00:00
|
|
|
/* Pseudo flags which are used in ro_opts but not stored into sc_opts. */
|
2014-12-01 11:45:24 +00:00
|
|
|
#define LAGG_OPT_FLOWIDSHIFT 0x02 /* set flowid shift */
|
2019-05-03 14:43:21 +00:00
|
|
|
#define LAGG_OPT_USE_NUMA 0x04 /* enable use of numa */
|
2014-10-02 20:01:13 +00:00
|
|
|
#define LAGG_OPT_FLOWIDSHIFT_MASK 0x1f /* flowid is uint32_t */
|
|
|
|
#define LAGG_OPT_LACP_STRICT 0x10 /* LACP strict mode */
|
|
|
|
#define LAGG_OPT_LACP_TXTEST 0x20 /* LACP debug: txtest */
|
|
|
|
#define LAGG_OPT_LACP_RXTEST 0x40 /* LACP debug: rxtest */
|
2020-06-11 22:46:08 +00:00
|
|
|
#define LAGG_OPT_LACP_FAST_TIMO 0x80 /* LACP fast timeout */
|
2020-01-09 14:58:41 +00:00
|
|
|
#define LAGG_OPT_RR_LIMIT 0x100 /* RR stride */
|
2014-10-02 20:01:13 +00:00
|
|
|
u_int ro_count; /* number of ports */
|
|
|
|
u_int ro_active; /* active port count */
|
|
|
|
u_int ro_flapping; /* number of flapping */
|
|
|
|
int ro_flowid_shift; /* shift the flowid */
|
2019-12-22 21:56:47 +00:00
|
|
|
uint32_t ro_bkt; /* stride for RR */
|
2014-10-02 20:01:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define SIOCGLAGGOPTS _IOWR('i', 152, struct lagg_reqopts)
|
|
|
|
#define SIOCSLAGGOPTS _IOW('i', 153, struct lagg_reqopts)
|
|
|
|
|
2019-05-03 14:43:21 +00:00
|
|
|
#define LAGG_OPT_BITS "\020\001USE_FLOWID\003USE_NUMA" \
|
|
|
|
"\005LACP_STRICT\006LACP_TXTEST" \
|
2020-06-11 22:46:08 +00:00
|
|
|
"\007LACP_RXTEST\010LACP_FAST_TIMO"
|
2014-10-05 02:34:21 +00:00
|
|
|
|
2007-04-17 00:35:11 +00:00
|
|
|
#ifdef _KERNEL
|
2013-04-15 13:00:42 +00:00
|
|
|
|
2007-04-17 00:35:11 +00:00
|
|
|
/*
|
|
|
|
* Internal kernel part
|
|
|
|
*/
|
|
|
|
|
2007-06-12 07:29:11 +00:00
|
|
|
#define LAGG_PORTACTIVE(_tp) ( \
|
2014-09-26 13:02:29 +00:00
|
|
|
((_tp)->lp_ifp->if_link_state == LINK_STATE_UP) && \
|
2007-06-12 07:29:11 +00:00
|
|
|
((_tp)->lp_ifp->if_flags & IFF_UP) \
|
2007-04-17 00:35:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
struct lagg_ifreq {
|
|
|
|
union {
|
|
|
|
struct ifreq ifreq;
|
|
|
|
struct {
|
|
|
|
char ifr_name[IFNAMSIZ];
|
|
|
|
struct sockaddr_storage ifr_ss;
|
|
|
|
} ifreq_storage;
|
|
|
|
} ifreq;
|
|
|
|
};
|
|
|
|
|
2007-06-12 07:29:11 +00:00
|
|
|
#define sc_ifflags sc_ifp->if_flags /* flags */
|
|
|
|
#define sc_ifname sc_ifp->if_xname /* name */
|
2007-04-17 00:35:11 +00:00
|
|
|
|
|
|
|
/* Private data used by the loadbalancing protocol */
|
|
|
|
struct lagg_lb {
|
|
|
|
u_int32_t lb_key;
|
|
|
|
struct lagg_port *lb_ports[LAGG_MAX_PORTS];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lagg_mc {
|
2014-08-04 00:58:12 +00:00
|
|
|
struct sockaddr_dl mc_addr;
|
2007-05-07 00:18:56 +00:00
|
|
|
struct ifmultiaddr *mc_ifma;
|
|
|
|
SLIST_ENTRY(lagg_mc) mc_entries;
|
2007-04-17 00:35:11 +00:00
|
|
|
};
|
|
|
|
|
2014-09-27 13:57:48 +00:00
|
|
|
struct lagg_counters {
|
2014-09-28 08:57:07 +00:00
|
|
|
uint64_t val[IFCOUNTERS];
|
2014-09-27 13:57:48 +00:00
|
|
|
};
|
|
|
|
|
2007-04-17 00:35:11 +00:00
|
|
|
struct lagg_softc {
|
|
|
|
struct ifnet *sc_ifp; /* virtual interface */
|
2013-08-29 19:35:14 +00:00
|
|
|
struct rmlock sc_mtx;
|
2017-05-02 19:09:11 +00:00
|
|
|
struct sx sc_sx;
|
2007-04-17 00:35:11 +00:00
|
|
|
int sc_proto; /* lagg protocol */
|
|
|
|
u_int sc_count; /* number of ports */
|
2013-07-13 04:25:03 +00:00
|
|
|
u_int sc_active; /* active port count */
|
|
|
|
u_int sc_flapping; /* number of flapping
|
|
|
|
* events */
|
2007-04-17 00:35:11 +00:00
|
|
|
struct lagg_port *sc_primary; /* primary port */
|
|
|
|
struct ifmedia sc_media; /* media config */
|
2014-09-26 12:35:58 +00:00
|
|
|
void *sc_psc; /* protocol data */
|
2007-10-12 03:03:16 +00:00
|
|
|
uint32_t sc_seq; /* sequence counter */
|
2019-12-22 21:56:47 +00:00
|
|
|
uint32_t sc_stride; /* stride for RR */
|
2012-03-06 22:58:13 +00:00
|
|
|
uint32_t sc_flags;
|
2017-05-02 19:09:11 +00:00
|
|
|
int sc_destroying; /* destroying lagg */
|
2007-04-17 00:35:11 +00:00
|
|
|
|
2018-05-24 23:21:23 +00:00
|
|
|
CK_SLIST_HEAD(__tplhd, lagg_port) sc_ports; /* list of interfaces */
|
2007-04-17 00:35:11 +00:00
|
|
|
SLIST_ENTRY(lagg_softc) sc_entries;
|
|
|
|
|
2010-02-06 13:49:35 +00:00
|
|
|
eventhandler_tag vlan_attach;
|
|
|
|
eventhandler_tag vlan_detach;
|
2013-04-15 13:00:42 +00:00
|
|
|
struct callout sc_callout;
|
2014-10-01 21:37:32 +00:00
|
|
|
u_int sc_opts;
|
2013-12-30 01:32:17 +00:00
|
|
|
int flowid_shift; /* shift the flowid */
|
2014-09-27 13:57:48 +00:00
|
|
|
struct lagg_counters detached_counters; /* detached ports sum */
|
2007-04-17 00:35:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct lagg_port {
|
|
|
|
struct ifnet *lp_ifp; /* physical interface */
|
2007-06-12 07:29:11 +00:00
|
|
|
struct lagg_softc *lp_softc; /* parent lagg */
|
2007-04-17 00:35:11 +00:00
|
|
|
uint8_t lp_lladdr[ETHER_ADDR_LEN];
|
|
|
|
|
|
|
|
u_char lp_iftype; /* interface type */
|
|
|
|
uint32_t lp_prio; /* port priority */
|
|
|
|
uint32_t lp_flags; /* port flags */
|
|
|
|
int lp_ifflags; /* saved ifp flags */
|
2017-05-02 19:09:11 +00:00
|
|
|
int lp_ifcapenable; /* saved ifp capenable */
|
2007-04-17 00:35:11 +00:00
|
|
|
void *lh_cookie; /* if state hook */
|
2014-09-26 12:35:58 +00:00
|
|
|
void *lp_psc; /* protocol data */
|
2007-05-07 00:28:55 +00:00
|
|
|
int lp_detaching; /* ifnet is detaching */
|
2007-05-07 00:18:56 +00:00
|
|
|
SLIST_HEAD(__mclhd, lagg_mc) lp_mc_head; /* multicast addresses */
|
|
|
|
|
2007-04-17 00:35:11 +00:00
|
|
|
/* Redirected callbacks */
|
|
|
|
int (*lp_ioctl)(struct ifnet *, u_long, caddr_t);
|
2013-04-26 12:50:32 +00:00
|
|
|
int (*lp_output)(struct ifnet *, struct mbuf *,
|
|
|
|
const struct sockaddr *, struct route *);
|
2014-09-27 13:57:48 +00:00
|
|
|
struct lagg_counters port_counters; /* ifp counters copy */
|
2007-04-17 00:35:11 +00:00
|
|
|
|
2018-05-24 23:21:23 +00:00
|
|
|
CK_SLIST_ENTRY(lagg_port) lp_entries;
|
2018-05-14 20:06:49 +00:00
|
|
|
struct epoch_context lp_epoch_ctx;
|
2007-04-17 00:35:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct mbuf *(*lagg_input_p)(struct ifnet *, struct mbuf *);
|
2015-12-17 14:41:30 +00:00
|
|
|
extern void (*lagg_linkstate_p)(struct ifnet *, int );
|
2007-04-17 00:35:11 +00:00
|
|
|
|
|
|
|
int lagg_enqueue(struct ifnet *, struct mbuf *);
|
|
|
|
|
2013-07-13 04:25:03 +00:00
|
|
|
SYSCTL_DECL(_net_link_lagg);
|
|
|
|
|
2007-04-17 00:35:11 +00:00
|
|
|
#endif /* _KERNEL */
|
|
|
|
|
|
|
|
#endif /* _NET_LAGG_H */
|