The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/net/if_lagg.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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: releng/10.2/sys/net/if_lagg.h 281955 2015-04-24 23:26:44Z hiren $
   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 */
   31 
   32 /* Lagg flags */
   33 #define LAGG_F_HASHL2           0x00000001      /* hash layer 2 */
   34 #define LAGG_F_HASHL3           0x00000002      /* hash layer 3 */
   35 #define LAGG_F_HASHL4           0x00000004      /* hash layer 4 */
   36 #define LAGG_F_HASHMASK         0x00000007
   37 
   38 /* Port flags */
   39 #define LAGG_PORT_SLAVE         0x00000000      /* normal enslaved port */
   40 #define LAGG_PORT_MASTER        0x00000001      /* primary port */
   41 #define LAGG_PORT_STACK         0x00000002      /* stacked lagg port */
   42 #define LAGG_PORT_ACTIVE        0x00000004      /* port is active */
   43 #define LAGG_PORT_COLLECTING    0x00000008      /* port is receiving frames */
   44 #define LAGG_PORT_DISTRIBUTING  0x00000010      /* port is sending frames */
   45 #define LAGG_PORT_DISABLED      0x00000020      /* port is disabled */
   46 #define LAGG_PORT_BITS          "\2\01MASTER\02STACK\03ACTIVE\04COLLECTING" \
   47                                   "\05DISTRIBUTING\06DISABLED"
   48 
   49 /* Supported lagg PROTOs */
   50 #define LAGG_PROTO_NONE         0       /* no lagg protocol defined */
   51 #define LAGG_PROTO_ROUNDROBIN   1       /* simple round robin */
   52 #define LAGG_PROTO_FAILOVER     2       /* active failover */
   53 #define LAGG_PROTO_LOADBALANCE  3       /* loadbalance */
   54 #define LAGG_PROTO_LACP         4       /* 802.3ad lacp */
   55 #define LAGG_PROTO_ETHERCHANNEL 5       /* Cisco FEC */
   56 #define LAGG_PROTO_MAX          6
   57 
   58 struct lagg_protos {
   59         const char              *lpr_name;
   60         int                     lpr_proto;
   61 };
   62 
   63 #define LAGG_PROTO_DEFAULT      LAGG_PROTO_FAILOVER
   64 #define LAGG_PROTOS     {                                               \
   65         { "failover",           LAGG_PROTO_FAILOVER },                  \
   66         { "fec",                LAGG_PROTO_ETHERCHANNEL },              \
   67         { "lacp",               LAGG_PROTO_LACP },                      \
   68         { "loadbalance",        LAGG_PROTO_LOADBALANCE },               \
   69         { "roundrobin",         LAGG_PROTO_ROUNDROBIN },                \
   70         { "none",               LAGG_PROTO_NONE },                      \
   71         { "default",            LAGG_PROTO_DEFAULT }                    \
   72 }
   73 
   74 /*
   75  * lagg ioctls.
   76  */
   77 
   78 /*
   79  * LACP current operational parameters structure.
   80  */
   81 struct lacp_opreq {
   82         uint16_t                actor_prio;
   83         uint8_t                 actor_mac[ETHER_ADDR_LEN];
   84         uint16_t                actor_key;
   85         uint16_t                actor_portprio;
   86         uint16_t                actor_portno;
   87         uint8_t                 actor_state;
   88         uint16_t                partner_prio;
   89         uint8_t                 partner_mac[ETHER_ADDR_LEN];
   90         uint16_t                partner_key;
   91         uint16_t                partner_portprio;
   92         uint16_t                partner_portno;
   93         uint8_t                 partner_state;
   94 };
   95 
   96 /* lagg port settings */
   97 struct lagg_reqport {
   98         char                    rp_ifname[IFNAMSIZ];    /* name of the lagg */
   99         char                    rp_portname[IFNAMSIZ];  /* name of the port */
  100         u_int32_t               rp_prio;                /* port priority */
  101         u_int32_t               rp_flags;               /* port flags */
  102         union {
  103                 struct lacp_opreq rpsc_lacp;
  104         } rp_psc;
  105 #define rp_lacpreq      rp_psc.rpsc_lacp
  106 };
  107 
  108 #define SIOCGLAGGPORT           _IOWR('i', 140, struct lagg_reqport)
  109 #define SIOCSLAGGPORT            _IOW('i', 141, struct lagg_reqport)
  110 #define SIOCSLAGGDELPORT         _IOW('i', 142, struct lagg_reqport)
  111 
  112 /* lagg, ports and options */
  113 struct lagg_reqall {
  114         char                    ra_ifname[IFNAMSIZ];    /* name of the lagg */
  115         u_int                   ra_proto;               /* lagg protocol */
  116 
  117         size_t                  ra_size;                /* size of buffer */
  118         struct lagg_reqport     *ra_port;               /* allocated buffer */
  119         int                     ra_ports;               /* total port count */
  120         union {
  121                 struct lacp_opreq rpsc_lacp;
  122         } ra_psc;
  123 #define ra_lacpreq      ra_psc.rpsc_lacp
  124 };
  125 
  126 #define SIOCGLAGG               _IOWR('i', 143, struct lagg_reqall)
  127 #define SIOCSLAGG                _IOW('i', 144, struct lagg_reqall)
  128 
  129 struct lagg_reqflags {
  130         char                    rf_ifname[IFNAMSIZ];    /* name of the lagg */
  131         uint32_t                rf_flags;               /* lagg protocol */
  132 };
  133 
  134 #define SIOCGLAGGFLAGS          _IOWR('i', 145, struct lagg_reqflags)
  135 #define SIOCSLAGGHASH            _IOW('i', 146, struct lagg_reqflags)
  136 
  137 #ifdef _KERNEL
  138 
  139 #include <sys/counter.h>
  140 
  141 /*
  142  * Internal kernel part
  143  */
  144 
  145 #define lp_ifname               lp_ifp->if_xname        /* interface name */
  146 #define lp_link_state           lp_ifp->if_link_state   /* link state */
  147 
  148 #define LAGG_PORTACTIVE(_tp)    (                                       \
  149         ((_tp)->lp_link_state == LINK_STATE_UP) &&                      \
  150         ((_tp)->lp_ifp->if_flags & IFF_UP)                              \
  151 )
  152 
  153 struct lagg_ifreq {
  154         union {
  155                 struct ifreq ifreq;
  156                 struct {
  157                         char ifr_name[IFNAMSIZ];
  158                         struct sockaddr_storage ifr_ss;
  159                 } ifreq_storage;
  160         } ifreq;
  161 };
  162 
  163 #define sc_ifflags              sc_ifp->if_flags                /* flags */
  164 #define sc_ifname               sc_ifp->if_xname                /* name */
  165 #define sc_capabilities         sc_ifp->if_capabilities /* capabilities */
  166 
  167 #define IFCAP_LAGG_MASK         0xffff0000      /* private capabilities */
  168 #define IFCAP_LAGG_FULLDUPLEX   0x00010000      /* full duplex with >1 ports */
  169 
  170 /* Private data used by the loadbalancing protocol */
  171 struct lagg_lb {
  172         u_int32_t               lb_key;
  173         struct lagg_port        *lb_ports[LAGG_MAX_PORTS];
  174 };
  175 
  176 struct lagg_mc {
  177         struct sockaddr_dl      mc_addr;
  178         struct ifmultiaddr      *mc_ifma;
  179         SLIST_ENTRY(lagg_mc)    mc_entries;
  180 };
  181 
  182 /* List of interfaces to have the MAC address modified */
  183 struct lagg_llq {
  184         struct ifnet            *llq_ifp;
  185         uint8_t                 llq_lladdr[ETHER_ADDR_LEN];
  186         SLIST_ENTRY(lagg_llq)   llq_entries;
  187 };
  188 
  189 struct lagg_softc {
  190         struct ifnet                    *sc_ifp;        /* virtual interface */
  191         struct rmlock                   sc_mtx;
  192         struct mtx                      sc_call_mtx;
  193         int                             sc_proto;       /* lagg protocol */
  194         u_int                           sc_count;       /* number of ports */
  195         u_int                           sc_active;      /* active port count */
  196         u_int                           sc_flapping;    /* number of flapping
  197                                                          * events */
  198         struct lagg_port                *sc_primary;    /* primary port */
  199         struct ifmedia                  sc_media;       /* media config */
  200         caddr_t                         sc_psc;         /* protocol data */
  201         uint32_t                        sc_seq;         /* sequence counter */
  202         uint32_t                        sc_flags;
  203 
  204         counter_u64_t                   sc_ipackets;
  205         counter_u64_t                   sc_opackets;
  206         counter_u64_t                   sc_ibytes;
  207         counter_u64_t                   sc_obytes;
  208 
  209         SLIST_HEAD(__tplhd, lagg_port)  sc_ports;       /* list of interfaces */
  210         SLIST_ENTRY(lagg_softc) sc_entries;
  211 
  212         struct task                     sc_lladdr_task;
  213         SLIST_HEAD(__llqhd, lagg_llq)   sc_llq_head;    /* interfaces to program
  214                                                            the lladdr on */
  215 
  216         /* lagg protocol callbacks */
  217         int     (*sc_detach)(struct lagg_softc *);
  218         int     (*sc_start)(struct lagg_softc *, struct mbuf *);
  219         struct mbuf *(*sc_input)(struct lagg_softc *, struct lagg_port *,
  220                     struct mbuf *);
  221         int     (*sc_port_create)(struct lagg_port *);
  222         void    (*sc_port_destroy)(struct lagg_port *);
  223         void    (*sc_linkstate)(struct lagg_port *);
  224         void    (*sc_init)(struct lagg_softc *);
  225         void    (*sc_stop)(struct lagg_softc *);
  226         void    (*sc_lladdr)(struct lagg_softc *);
  227         void    (*sc_req)(struct lagg_softc *, caddr_t);
  228         void    (*sc_portreq)(struct lagg_port *, caddr_t);
  229         eventhandler_tag vlan_attach;
  230         eventhandler_tag vlan_detach;
  231         struct callout                  sc_callout;
  232         struct sysctl_ctx_list          ctx;            /* sysctl variables */
  233         struct sysctl_oid               *sc_oid;        /* sysctl tree oid */
  234         int                             use_flowid;     /* enable use of flowid */
  235         int                             flowid_shift;   /* set flowid shift*/
  236 };
  237 
  238 struct lagg_port {
  239         struct ifnet                    *lp_ifp;        /* physical interface */
  240         struct lagg_softc               *lp_softc;      /* parent lagg */
  241         uint8_t                         lp_lladdr[ETHER_ADDR_LEN];
  242 
  243         u_char                          lp_iftype;      /* interface type */
  244         uint32_t                        lp_prio;        /* port priority */
  245         uint32_t                        lp_flags;       /* port flags */
  246         int                             lp_ifflags;     /* saved ifp flags */
  247         void                            *lh_cookie;     /* if state hook */
  248         caddr_t                         lp_psc;         /* protocol data */
  249         int                             lp_detaching;   /* ifnet is detaching */
  250 
  251         SLIST_HEAD(__mclhd, lagg_mc)    lp_mc_head;     /* multicast addresses */
  252 
  253         /* Redirected callbacks */
  254         int     (*lp_ioctl)(struct ifnet *, u_long, caddr_t);
  255         int     (*lp_output)(struct ifnet *, struct mbuf *,
  256                      const struct sockaddr *, struct route *);
  257 
  258         SLIST_ENTRY(lagg_port)          lp_entries;
  259 };
  260 
  261 #define LAGG_LOCK_INIT(_sc)     rm_init(&(_sc)->sc_mtx, "if_lagg rmlock")
  262 #define LAGG_LOCK_DESTROY(_sc)  rm_destroy(&(_sc)->sc_mtx)
  263 #define LAGG_RLOCK(_sc, _p)     rm_rlock(&(_sc)->sc_mtx, (_p))
  264 #define LAGG_WLOCK(_sc)         rm_wlock(&(_sc)->sc_mtx)
  265 #define LAGG_RUNLOCK(_sc, _p)   rm_runlock(&(_sc)->sc_mtx, (_p))
  266 #define LAGG_WUNLOCK(_sc)       rm_wunlock(&(_sc)->sc_mtx)
  267 #define LAGG_RLOCK_ASSERT(_sc)  rm_assert(&(_sc)->sc_mtx, RA_RLOCKED)
  268 #define LAGG_WLOCK_ASSERT(_sc)  rm_assert(&(_sc)->sc_mtx, RA_WLOCKED)
  269 
  270 #define LAGG_CALLOUT_LOCK_INIT(_sc)                                     \
  271             mtx_init(&(_sc)->sc_call_mtx, "if_lagg callout mutex", NULL,\
  272             MTX_DEF)
  273 #define LAGG_CALLOUT_LOCK_DESTROY(_sc)  mtx_destroy(&(_sc)->sc_call_mtx)
  274 
  275 extern struct mbuf *(*lagg_input_p)(struct ifnet *, struct mbuf *);
  276 extern void     (*lagg_linkstate_p)(struct ifnet *, int );
  277 
  278 int             lagg_enqueue(struct ifnet *, struct mbuf *);
  279 uint32_t        lagg_hashmbuf(struct lagg_softc *, struct mbuf *, uint32_t);
  280 
  281 SYSCTL_DECL(_net_link_lagg);
  282 
  283 #endif /* _KERNEL */
  284 
  285 #endif /* _NET_LAGG_H */

Cache object: 2ee689466b66ac63c5e1e6e498bdd089


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.