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/6.3/sys/net/if_lagg.h 173886 2007-11-24 19:45:58Z cvs2svn $
   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 /* 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_BITS          "\2\01MASTER\02STACK\03ACTIVE\04COLLECTING" \
   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 
   52 struct lagg_protos {
   53         const char              *lpr_name;
   54         int                     lpr_proto;
   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 },               \
   63         { "roundrobin",         LAGG_PROTO_ROUNDROBIN },                \
   64         { "none",               LAGG_PROTO_NONE },                      \
   65         { "default",            LAGG_PROTO_DEFAULT }                    \
   66 }
   67 
   68 /*
   69  * lagg ioctls.
   70  */
   71 
   72 /*
   73  * LACP current operational parameters structure.
   74  */
   75 struct lacp_opreq {
   76         uint16_t                actor_prio;
   77         uint8_t                 actor_mac[ETHER_ADDR_LEN];
   78         uint16_t                actor_key;
   79         uint16_t                actor_portprio;
   80         uint16_t                actor_portno;
   81         uint8_t                 actor_state;
   82         uint16_t                partner_prio;
   83         uint8_t                 partner_mac[ETHER_ADDR_LEN];
   84         uint16_t                partner_key;
   85         uint16_t                partner_portprio;
   86         uint16_t                partner_portno;
   87         uint8_t                 partner_state;
   88 };
   89 
   90 /* lagg port settings */
   91 struct lagg_reqport {
   92         char                    rp_ifname[IFNAMSIZ];    /* name of the lagg */
   93         char                    rp_portname[IFNAMSIZ];  /* name of the port */
   94         u_int32_t               rp_prio;                /* port priority */
   95         u_int32_t               rp_flags;               /* port flags */
   96         union {
   97                 struct lacp_opreq rpsc_lacp;
   98         } rp_psc;
   99 #define rp_lacpreq      rp_psc.rpsc_lacp
  100 };
  101 
  102 #define SIOCGLAGGPORT           _IOWR('i', 140, struct lagg_reqport)
  103 #define SIOCSLAGGPORT            _IOW('i', 141, struct lagg_reqport)
  104 #define SIOCSLAGGDELPORT         _IOW('i', 142, struct lagg_reqport)
  105 
  106 /* lagg, ports and options */
  107 struct lagg_reqall {
  108         char                    ra_ifname[IFNAMSIZ];    /* name of the lagg */
  109         u_int                   ra_proto;               /* lagg protocol */
  110 
  111         size_t                  ra_size;                /* size of buffer */
  112         struct lagg_reqport     *ra_port;               /* allocated buffer */
  113         int                     ra_ports;               /* total port count */
  114         union {
  115                 struct lacp_opreq rpsc_lacp;
  116         } ra_psc;
  117 #define ra_lacpreq      ra_psc.rpsc_lacp
  118 };
  119 
  120 #define SIOCGLAGG               _IOWR('i', 143, struct lagg_reqall)
  121 #define SIOCSLAGG                _IOW('i', 144, struct lagg_reqall)
  122 
  123 #ifdef _KERNEL
  124 /*
  125  * Internal kernel part
  126  */
  127 
  128 #define lp_ifname               lp_ifp->if_xname        /* interface name */
  129 #define lp_link_state           lp_ifp->if_link_state   /* link state */
  130 
  131 #define LAGG_PORTACTIVE(_tp)    (                                       \
  132         ((_tp)->lp_link_state == LINK_STATE_UP) &&                      \
  133         ((_tp)->lp_ifp->if_flags & IFF_UP)                              \
  134 )
  135 
  136 struct lagg_ifreq {
  137         union {
  138                 struct ifreq ifreq;
  139                 struct {
  140                         char ifr_name[IFNAMSIZ];
  141                         struct sockaddr_storage ifr_ss;
  142                 } ifreq_storage;
  143         } ifreq;
  144 };
  145 
  146 #define sc_ifflags              sc_ifp->if_flags                /* flags */
  147 #define sc_ifname               sc_ifp->if_xname                /* name */
  148 #define sc_capabilities         sc_ifp->if_capabilities /* capabilities */
  149 
  150 #define IFCAP_LAGG_MASK         0xffff0000      /* private capabilities */
  151 #define IFCAP_LAGG_FULLDUPLEX   0x00010000      /* full duplex with >1 ports */
  152 
  153 /* Private data used by the loadbalancing protocol */
  154 struct lagg_lb {
  155         u_int32_t               lb_key;
  156         struct lagg_port        *lb_ports[LAGG_MAX_PORTS];
  157 };
  158 
  159 struct lagg_mc {
  160         union {
  161                 struct ether_multi      *mcu_enm;
  162         } mc_u;
  163         struct sockaddr_storage         mc_addr;
  164 
  165         SLIST_ENTRY(lagg_mc)            mc_entries;
  166 };
  167 
  168 /* List of interfaces to have the MAC address modified */
  169 struct lagg_llq {
  170         struct ifnet            *llq_ifp;
  171         uint8_t                 llq_lladdr[ETHER_ADDR_LEN];
  172         SLIST_ENTRY(lagg_llq)   llq_entries;
  173 };
  174 
  175 struct lagg_softc {
  176         struct ifnet                    *sc_ifp;        /* virtual interface */
  177         struct rwlock                   sc_mtx;
  178         int                             sc_proto;       /* lagg protocol */
  179         u_int                           sc_count;       /* number of ports */
  180         struct lagg_port                *sc_primary;    /* primary port */
  181         struct ifmedia                  sc_media;       /* media config */
  182         caddr_t                         sc_psc;         /* protocol data */
  183         uint32_t                        sc_seq;         /* sequence counter */
  184 
  185         SLIST_HEAD(__tplhd, lagg_port)  sc_ports;       /* list of interfaces */
  186         SLIST_ENTRY(lagg_softc) sc_entries;
  187 
  188         SLIST_HEAD(__mclhd, lagg_mc)    sc_mc_head;     /* multicast addresses */
  189         struct task                     sc_lladdr_task;
  190         SLIST_HEAD(__llqhd, lagg_llq)   sc_llq_head;    /* interfaces to program
  191                                                            the lladdr on */
  192 
  193         /* lagg protocol callbacks */
  194         int     (*sc_detach)(struct lagg_softc *);
  195         int     (*sc_start)(struct lagg_softc *, struct mbuf *);
  196         struct mbuf *(*sc_input)(struct lagg_softc *, struct lagg_port *,
  197                     struct mbuf *);
  198         int     (*sc_port_create)(struct lagg_port *);
  199         void    (*sc_port_destroy)(struct lagg_port *);
  200         void    (*sc_linkstate)(struct lagg_port *);
  201         void    (*sc_init)(struct lagg_softc *);
  202         void    (*sc_stop)(struct lagg_softc *);
  203         void    (*sc_lladdr)(struct lagg_softc *);
  204         void    (*sc_req)(struct lagg_softc *, caddr_t);
  205         void    (*sc_portreq)(struct lagg_port *, caddr_t);
  206 };
  207 
  208 struct lagg_port {
  209         struct ifnet                    *lp_ifp;        /* physical interface */
  210         struct lagg_softc               *lp_softc;      /* parent lagg */
  211         uint8_t                         lp_lladdr[ETHER_ADDR_LEN];
  212 
  213         u_char                          lp_iftype;      /* interface type */
  214         uint32_t                        lp_prio;        /* port priority */
  215         uint32_t                        lp_flags;       /* port flags */
  216         int                             lp_ifflags;     /* saved ifp flags */
  217         void                            *lh_cookie;     /* if state hook */
  218         caddr_t                         lp_psc;         /* protocol data */
  219         int                             lp_detaching;   /* ifnet is detaching */
  220 
  221         /* Redirected callbacks */
  222         int     (*lp_ioctl)(struct ifnet *, u_long, caddr_t);
  223         int     (*lp_output)(struct ifnet *, struct mbuf *, struct sockaddr *,
  224                      struct rtentry *);
  225 
  226         SLIST_ENTRY(lagg_port)          lp_entries;
  227 };
  228 
  229 #define LAGG_LOCK_INIT(_sc)     rw_init(&(_sc)->sc_mtx, "if_lagg rwlock")
  230 #define LAGG_LOCK_DESTROY(_sc)  rw_destroy(&(_sc)->sc_mtx)
  231 #define LAGG_RLOCK(_sc)         rw_rlock(&(_sc)->sc_mtx)
  232 #define LAGG_WLOCK(_sc)         rw_wlock(&(_sc)->sc_mtx)
  233 #define LAGG_RUNLOCK(_sc)       rw_runlock(&(_sc)->sc_mtx)
  234 #define LAGG_WUNLOCK(_sc)       rw_wunlock(&(_sc)->sc_mtx)
  235 #define LAGG_RLOCK_ASSERT(_sc)  rw_assert(&(_sc)->sc_mtx, RA_RLOCKED)
  236 #define LAGG_WLOCK_ASSERT(_sc)  rw_assert(&(_sc)->sc_mtx, RA_WLOCKED)
  237 
  238 extern struct mbuf *(*lagg_input_p)(struct ifnet *, struct mbuf *);
  239 extern void     (*lagg_linkstate_p)(struct ifnet *, int );
  240 
  241 int             lagg_enqueue(struct ifnet *, struct mbuf *);
  242 uint32_t        lagg_hashmbuf(struct mbuf *, uint32_t);
  243 
  244 #endif /* _KERNEL */
  245 
  246 #endif /* _NET_LAGG_H */

Cache object: c505fa5c99979b919db77f0c6c74d0fb


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