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.3/sys/net/if_lagg.h 287808 2015-09-15 05:19:10Z 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 typedef enum {
   51         LAGG_PROTO_NONE = 0,    /* no lagg protocol defined */
   52         LAGG_PROTO_ROUNDROBIN,  /* simple round robin */
   53         LAGG_PROTO_FAILOVER,    /* active failover */
   54         LAGG_PROTO_LOADBALANCE, /* loadbalance */
   55         LAGG_PROTO_LACP,        /* 802.3ad lacp */
   56         LAGG_PROTO_ETHERCHANNEL,/* Cisco FEC */
   57         LAGG_PROTO_MAX,
   58 } lagg_proto;
   59 
   60 struct lagg_protos {
   61         const char              *lpr_name;
   62         lagg_proto              lpr_proto;
   63 };
   64 
   65 #define LAGG_PROTO_DEFAULT      LAGG_PROTO_FAILOVER
   66 #define LAGG_PROTOS     {                                               \
   67         { "failover",           LAGG_PROTO_FAILOVER },                  \
   68         { "fec",                LAGG_PROTO_ETHERCHANNEL },              \
   69         { "lacp",               LAGG_PROTO_LACP },                      \
   70         { "loadbalance",        LAGG_PROTO_LOADBALANCE },               \
   71         { "roundrobin",         LAGG_PROTO_ROUNDROBIN },                \
   72         { "none",               LAGG_PROTO_NONE },                      \
   73         { "default",            LAGG_PROTO_DEFAULT }                    \
   74 }
   75 
   76 /*
   77  * lagg ioctls.
   78  */
   79 
   80 /*
   81  * LACP current operational parameters structure.
   82  */
   83 struct lacp_opreq {
   84         uint16_t                actor_prio;
   85         uint8_t                 actor_mac[ETHER_ADDR_LEN];
   86         uint16_t                actor_key;
   87         uint16_t                actor_portprio;
   88         uint16_t                actor_portno;
   89         uint8_t                 actor_state;
   90         uint16_t                partner_prio;
   91         uint8_t                 partner_mac[ETHER_ADDR_LEN];
   92         uint16_t                partner_key;
   93         uint16_t                partner_portprio;
   94         uint16_t                partner_portno;
   95         uint8_t                 partner_state;
   96 };
   97 
   98 /* lagg port settings */
   99 struct lagg_reqport {
  100         char                    rp_ifname[IFNAMSIZ];    /* name of the lagg */
  101         char                    rp_portname[IFNAMSIZ];  /* name of the port */
  102         u_int32_t               rp_prio;                /* port priority */
  103         u_int32_t               rp_flags;               /* port flags */
  104         union {
  105                 struct lacp_opreq rpsc_lacp;
  106         } rp_psc;
  107 #define rp_lacpreq      rp_psc.rpsc_lacp
  108 };
  109 
  110 #define SIOCGLAGGPORT           _IOWR('i', 140, struct lagg_reqport)
  111 #define SIOCSLAGGPORT            _IOW('i', 141, struct lagg_reqport)
  112 #define SIOCSLAGGDELPORT         _IOW('i', 142, struct lagg_reqport)
  113 
  114 /* lagg, ports and options */
  115 struct lagg_reqall {
  116         char                    ra_ifname[IFNAMSIZ];    /* name of the lagg */
  117         u_int                   ra_proto;               /* lagg protocol */
  118 
  119         size_t                  ra_size;                /* size of buffer */
  120         struct lagg_reqport     *ra_port;               /* allocated buffer */
  121         int                     ra_ports;               /* total port count */
  122         union {
  123                 struct lacp_opreq rpsc_lacp;
  124         } ra_psc;
  125 #define ra_lacpreq      ra_psc.rpsc_lacp
  126 };
  127 
  128 #define SIOCGLAGG               _IOWR('i', 143, struct lagg_reqall)
  129 #define SIOCSLAGG                _IOW('i', 144, struct lagg_reqall)
  130 
  131 struct lagg_reqflags {
  132         char                    rf_ifname[IFNAMSIZ];    /* name of the lagg */
  133         uint32_t                rf_flags;               /* lagg protocol */
  134 };
  135 
  136 #define SIOCGLAGGFLAGS          _IOWR('i', 145, struct lagg_reqflags)
  137 #define SIOCSLAGGHASH            _IOW('i', 146, struct lagg_reqflags)
  138 
  139 struct lagg_reqopts {
  140         char                    ro_ifname[IFNAMSIZ];    /* name of the lagg */
  141 
  142         int                     ro_opts;                /* Option bitmap */
  143 #define LAGG_OPT_NONE                   0x00
  144 #define LAGG_OPT_USE_FLOWID             0x01            /* use M_FLOWID */
  145 /* Pseudo flags which are used in ro_opts but not stored into sc_opts. */
  146 #define LAGG_OPT_FLOWIDSHIFT            0x02            /* Set flowid */
  147 #define LAGG_OPT_FLOWIDSHIFT_MASK       0x1f            /* flowid is uint32_t */
  148 #define LAGG_OPT_LACP_STRICT            0x10            /* LACP strict mode */
  149 #define LAGG_OPT_LACP_TXTEST            0x20            /* LACP debug: txtest */
  150 #define LAGG_OPT_LACP_RXTEST            0x40            /* LACP debug: rxtest */
  151 #define LAGG_OPT_LACP_TIMEOUT           0x80            /* LACP timeout */
  152         u_int                   ro_count;               /* number of ports */
  153         u_int                   ro_active;              /* active port count */
  154         u_int                   ro_flapping;            /* number of flapping */
  155         int                     ro_flowid_shift;        /* shift the flowid */
  156 };
  157 
  158 #define SIOCGLAGGOPTS           _IOWR('i', 152, struct lagg_reqopts)
  159 #define SIOCSLAGGOPTS            _IOW('i', 153, struct lagg_reqopts)
  160 
  161 #define LAGG_OPT_BITS           "\020\001USE_FLOWID\005LACP_STRICT" \
  162                                 "\006LACP_TXTEST\007LACP_RXTEST"
  163 
  164 #ifdef _KERNEL
  165 
  166 #include <sys/counter.h>
  167 
  168 /*
  169  * Internal kernel part
  170  */
  171 
  172 #define lp_ifname               lp_ifp->if_xname        /* interface name */
  173 #define lp_link_state           lp_ifp->if_link_state   /* link state */
  174 
  175 #define LAGG_PORTACTIVE(_tp)    (                                       \
  176         ((_tp)->lp_link_state == LINK_STATE_UP) &&                      \
  177         ((_tp)->lp_ifp->if_flags & IFF_UP)                              \
  178 )
  179 
  180 struct lagg_ifreq {
  181         union {
  182                 struct ifreq ifreq;
  183                 struct {
  184                         char ifr_name[IFNAMSIZ];
  185                         struct sockaddr_storage ifr_ss;
  186                 } ifreq_storage;
  187         } ifreq;
  188 };
  189 
  190 #define sc_ifflags              sc_ifp->if_flags                /* flags */
  191 #define sc_ifname               sc_ifp->if_xname                /* name */
  192 #define sc_capabilities         sc_ifp->if_capabilities /* capabilities */
  193 
  194 #define IFCAP_LAGG_MASK         0xffff0000      /* private capabilities */
  195 #define IFCAP_LAGG_FULLDUPLEX   0x00010000      /* full duplex with >1 ports */
  196 
  197 /* Private data used by the loadbalancing protocol */
  198 struct lagg_lb {
  199         u_int32_t               lb_key;
  200         struct lagg_port        *lb_ports[LAGG_MAX_PORTS];
  201 };
  202 
  203 struct lagg_mc {
  204         struct sockaddr_dl      mc_addr;
  205         struct ifmultiaddr      *mc_ifma;
  206         SLIST_ENTRY(lagg_mc)    mc_entries;
  207 };
  208 
  209 /* List of interfaces to have the MAC address modified */
  210 struct lagg_llq {
  211         struct ifnet            *llq_ifp;
  212         uint8_t                 llq_lladdr[ETHER_ADDR_LEN];
  213         uint8_t                 llq_primary;
  214         SLIST_ENTRY(lagg_llq)   llq_entries;
  215 };
  216 
  217 struct lagg_softc {
  218         struct ifnet                    *sc_ifp;        /* virtual interface */
  219         struct rmlock                   sc_mtx;
  220         struct mtx                      sc_call_mtx;
  221         int                             sc_proto;       /* lagg protocol */
  222         u_int                           sc_count;       /* number of ports */
  223         u_int                           sc_active;      /* active port count */
  224         u_int                           sc_flapping;    /* number of flapping
  225                                                          * events */
  226         struct lagg_port                *sc_primary;    /* primary port */
  227         struct ifmedia                  sc_media;       /* media config */
  228         caddr_t                         sc_psc;         /* protocol data */
  229         uint32_t                        sc_seq;         /* sequence counter */
  230         uint32_t                        sc_flags;
  231 
  232         counter_u64_t                   sc_ipackets;
  233         counter_u64_t                   sc_opackets;
  234         counter_u64_t                   sc_ibytes;
  235         counter_u64_t                   sc_obytes;
  236 
  237         SLIST_HEAD(__tplhd, lagg_port)  sc_ports;       /* list of interfaces */
  238         SLIST_ENTRY(lagg_softc) sc_entries;
  239 
  240         struct task                     sc_lladdr_task;
  241         SLIST_HEAD(__llqhd, lagg_llq)   sc_llq_head;    /* interfaces to program
  242                                                            the lladdr on */
  243 
  244         /* lagg protocol callbacks */
  245         int     (*sc_detach)(struct lagg_softc *);
  246         int     (*sc_start)(struct lagg_softc *, struct mbuf *);
  247         struct mbuf *(*sc_input)(struct lagg_softc *, struct lagg_port *,
  248                     struct mbuf *);
  249         int     (*sc_port_create)(struct lagg_port *);
  250         void    (*sc_port_destroy)(struct lagg_port *);
  251         void    (*sc_linkstate)(struct lagg_port *);
  252         void    (*sc_init)(struct lagg_softc *);
  253         void    (*sc_stop)(struct lagg_softc *);
  254         void    (*sc_lladdr)(struct lagg_softc *);
  255         void    (*sc_req)(struct lagg_softc *, caddr_t);
  256         void    (*sc_portreq)(struct lagg_port *, caddr_t);
  257         eventhandler_tag vlan_attach;
  258         eventhandler_tag vlan_detach;
  259         struct callout                  sc_callout;
  260         u_int                           sc_opts;
  261         int                             flowid_shift;   /* set flowid shift*/
  262 };
  263 
  264 struct lagg_port {
  265         struct ifnet                    *lp_ifp;        /* physical interface */
  266         struct lagg_softc               *lp_softc;      /* parent lagg */
  267         uint8_t                         lp_lladdr[ETHER_ADDR_LEN];
  268 
  269         u_char                          lp_iftype;      /* interface type */
  270         uint32_t                        lp_prio;        /* port priority */
  271         uint32_t                        lp_flags;       /* port flags */
  272         int                             lp_ifflags;     /* saved ifp flags */
  273         void                            *lh_cookie;     /* if state hook */
  274         caddr_t                         lp_psc;         /* protocol data */
  275         int                             lp_detaching;   /* ifnet is detaching */
  276 
  277         SLIST_HEAD(__mclhd, lagg_mc)    lp_mc_head;     /* multicast addresses */
  278 
  279         /* Redirected callbacks */
  280         int     (*lp_ioctl)(struct ifnet *, u_long, caddr_t);
  281         int     (*lp_output)(struct ifnet *, struct mbuf *,
  282                      const struct sockaddr *, struct route *);
  283 
  284         SLIST_ENTRY(lagg_port)          lp_entries;
  285 };
  286 
  287 #define LAGG_LOCK_INIT(_sc)     rm_init(&(_sc)->sc_mtx, "if_lagg rmlock")
  288 #define LAGG_LOCK_DESTROY(_sc)  rm_destroy(&(_sc)->sc_mtx)
  289 #define LAGG_RLOCK(_sc, _p)     rm_rlock(&(_sc)->sc_mtx, (_p))
  290 #define LAGG_WLOCK(_sc)         rm_wlock(&(_sc)->sc_mtx)
  291 #define LAGG_RUNLOCK(_sc, _p)   rm_runlock(&(_sc)->sc_mtx, (_p))
  292 #define LAGG_WUNLOCK(_sc)       rm_wunlock(&(_sc)->sc_mtx)
  293 #define LAGG_RLOCK_ASSERT(_sc)  rm_assert(&(_sc)->sc_mtx, RA_RLOCKED)
  294 #define LAGG_WLOCK_ASSERT(_sc)  rm_assert(&(_sc)->sc_mtx, RA_WLOCKED)
  295 
  296 #define LAGG_CALLOUT_LOCK_INIT(_sc)                                     \
  297             mtx_init(&(_sc)->sc_call_mtx, "if_lagg callout mutex", NULL,\
  298             MTX_DEF)
  299 #define LAGG_CALLOUT_LOCK_DESTROY(_sc)  mtx_destroy(&(_sc)->sc_call_mtx)
  300 
  301 extern struct mbuf *(*lagg_input_p)(struct ifnet *, struct mbuf *);
  302 extern void     (*lagg_linkstate_p)(struct ifnet *, int );
  303 
  304 int             lagg_enqueue(struct ifnet *, struct mbuf *);
  305 uint32_t        lagg_hashmbuf(struct lagg_softc *, struct mbuf *, uint32_t);
  306 
  307 SYSCTL_DECL(_net_link_lagg);
  308 
  309 #endif /* _KERNEL */
  310 
  311 #endif /* _NET_LAGG_H */

Cache object: b5c592f00a869296615762255f599a09


[ 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.