Home | History | Annotate | Line # | Download | only in agr
if_agrvar_impl.h revision 1.2.16.1
      1  1.2.16.1  gdamore /*	$NetBSD: if_agrvar_impl.h,v 1.2.16.1 2006/07/13 17:49:57 gdamore Exp $	*/
      2       1.1     yamt 
      3       1.1     yamt /*-
      4       1.1     yamt  * Copyright (c)2005 YAMAMOTO Takashi,
      5       1.1     yamt  * All rights reserved.
      6       1.1     yamt  *
      7       1.1     yamt  * Redistribution and use in source and binary forms, with or without
      8       1.1     yamt  * modification, are permitted provided that the following conditions
      9       1.1     yamt  * are met:
     10       1.1     yamt  * 1. Redistributions of source code must retain the above copyright
     11       1.1     yamt  *    notice, this list of conditions and the following disclaimer.
     12       1.1     yamt  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1     yamt  *    notice, this list of conditions and the following disclaimer in the
     14       1.1     yamt  *    documentation and/or other materials provided with the distribution.
     15       1.1     yamt  *
     16       1.1     yamt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17       1.1     yamt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18       1.1     yamt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19       1.1     yamt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     20       1.1     yamt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21       1.1     yamt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22       1.1     yamt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23       1.1     yamt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24       1.1     yamt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25       1.1     yamt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26       1.1     yamt  * SUCH DAMAGE.
     27       1.1     yamt  */
     28       1.1     yamt 
     29  1.2.16.1  gdamore #ifndef _NET_AGR_IF_AGRVAR_IMPL_H_
     30  1.2.16.1  gdamore #define	_NET_AGR_IF_AGRVAR_IMPL_H_
     31       1.1     yamt 
     32       1.1     yamt /*
     33       1.1     yamt  * implementaion details for agr(4) driver.  (contrast to if_agrvar.h)
     34       1.1     yamt  */
     35       1.1     yamt 
     36       1.1     yamt struct agr_port;
     37       1.1     yamt struct agr_softc;
     38       1.1     yamt 
     39       1.1     yamt struct agr_port {
     40       1.1     yamt 	struct ifnet *port_agrifp;
     41       1.1     yamt 	struct ifnet *port_ifp;
     42       1.1     yamt 	TAILQ_ENTRY(agr_port) port_q;
     43       1.1     yamt 	int (*port_ioctl)(struct ifnet *, u_long, caddr_t);
     44       1.1     yamt 	void *port_iftprivate;
     45       1.1     yamt 	int port_flags;
     46       1.1     yamt 	u_int port_media;
     47       1.1     yamt 	char port_origlladdr[0];
     48       1.1     yamt };
     49       1.1     yamt #define	AGRPORT_COLLECTING	0x00000001
     50       1.1     yamt #define	AGRPORT_DISTRIBUTING	0x00000002
     51       1.1     yamt #define	AGRPORT_PROMISC		0x00000004
     52       1.1     yamt #define	AGRPORT_LADDRCHANGED	0x00000008
     53       1.1     yamt #define	AGRPORT_ATTACHED	0x00000010
     54       1.1     yamt #define	AGRPORT_LARVAL		0x00000020
     55       1.1     yamt #define	AGRPORT_DETACHING	0x00000040
     56       1.1     yamt 
     57       1.1     yamt struct agr_iftype_ops {
     58       1.1     yamt 
     59       1.1     yamt 	void (*iftop_tick)(struct agr_softc *);
     60       1.1     yamt 	void (*iftop_porttick)(struct agr_softc *, struct agr_port *);
     61       1.1     yamt 	void (*iftop_portstate)(struct agr_port *);
     62       1.1     yamt 
     63       1.1     yamt 	/*
     64       1.1     yamt 	 * iftop_ctor:
     65       1.1     yamt 	 * - inherit setting (eg. L1 address) from the first port.
     66       1.1     yamt 	 * - initialize if_output, if_input, if_dlt, etc.
     67       1.1     yamt 	 *   (in the case of IFT_ETHER, ether_ifattach.
     68       1.1     yamt 	 */
     69       1.1     yamt 
     70       1.1     yamt 	int (*iftop_ctor)(struct agr_softc *, struct ifnet *);
     71       1.1     yamt 
     72       1.1     yamt 	void (*iftop_dtor)(struct agr_softc *);
     73       1.1     yamt 
     74       1.1     yamt 	/*
     75       1.1     yamt 	 * iftop_portinit:
     76       1.1     yamt 	 * propagate setting to a newly added port.
     77       1.1     yamt 	 */
     78       1.1     yamt 
     79       1.1     yamt 	int (*iftop_portinit)(struct agr_softc *, struct agr_port *);
     80       1.1     yamt 
     81       1.1     yamt 	/*
     82       1.1     yamt 	 * iftop_portfini:
     83       1.1     yamt 	 * restore setting of a port being removed.
     84       1.1     yamt 	 */
     85       1.1     yamt 	int (*iftop_portfini)(struct agr_softc *, struct agr_port *);
     86       1.1     yamt 
     87       1.1     yamt 	struct agr_port *(*iftop_select_tx_port)(struct agr_softc *,
     88       1.1     yamt 	    struct mbuf *);
     89       1.1     yamt 	uint32_t (*iftop_hashmbuf)(struct agr_softc *, struct mbuf *);
     90       1.1     yamt 
     91       1.1     yamt 	int (*iftop_configmulti_port)(struct agr_softc *, struct agr_port *,
     92       1.1     yamt 	    boolean_t);
     93       1.1     yamt 	int (*iftop_configmulti_ifreq)(struct agr_softc *, struct ifreq *,
     94       1.1     yamt 	    boolean_t);
     95       1.1     yamt };
     96       1.1     yamt 
     97       1.1     yamt struct agr_ifreq {
     98       1.1     yamt 	char ifr_name[IFNAMSIZ];
     99       1.1     yamt 	struct sockaddr_storage ifr_ss;
    100       1.1     yamt };
    101       1.1     yamt 
    102       1.1     yamt struct agr_softc {
    103       1.1     yamt 	struct lock sc_ioctl_lock;
    104       1.1     yamt 	struct simplelock sc_lock;
    105       1.1     yamt 	struct callout sc_callout;
    106       1.1     yamt 	int sc_nports;
    107       1.1     yamt 	TAILQ_HEAD(, agr_port) sc_ports;
    108       1.1     yamt 	const struct agr_iftype_ops *sc_iftop;
    109       1.1     yamt 	uint32_t sc_rr_counter;	/* distributor algorithm specific */
    110       1.1     yamt 	void *sc_iftprivate;
    111       1.1     yamt 	struct ifnet sc_if; /* should be the last. see agr_alloc_softc(). */
    112       1.1     yamt };
    113       1.1     yamt 
    114       1.1     yamt #define	AGR_SC_FROM_PORT(port) \
    115       1.1     yamt 	((struct agr_softc *)(port)->port_agrifp->if_softc)
    116       1.1     yamt 
    117       1.1     yamt #define	AGR_LOCK(sc)		agr_lock(sc)
    118       1.1     yamt #define	AGR_UNLOCK(sc, s)	agr_unlock((sc), (s))
    119       1.1     yamt #define	AGR_ASSERT_LOCKED(sc)	LOCK_ASSERT(simple_lock_held(&(sc)->sc_lock))
    120       1.1     yamt 
    121       1.1     yamt int agr_lock(struct agr_softc *);
    122       1.1     yamt void agr_unlock(struct agr_softc *, int);
    123       1.1     yamt 
    124       1.1     yamt void agr_ioctl_lock(struct agr_softc *);
    125       1.1     yamt void agr_ioctl_unlock(struct agr_softc *);
    126       1.1     yamt 
    127       1.1     yamt int agrport_ioctl(struct agr_port *, u_long, caddr_t);
    128       1.1     yamt 
    129       1.1     yamt struct agr_softc *agr_alloc_softc(void);
    130       1.1     yamt void agr_free_softc(struct agr_softc *);
    131       1.1     yamt 
    132       1.1     yamt int agr_xmit_frame(struct ifnet *, struct mbuf *); /* XXX */
    133       1.1     yamt 
    134       1.1     yamt #define	AGR_ROUNDROBIN(sc)	(((sc)->sc_if.if_flags & IFF_LINK0) != 0)
    135       1.1     yamt 
    136       1.1     yamt void agrtimer_init(struct agr_softc *);
    137       1.1     yamt void agrtimer_start(struct agr_softc *);
    138       1.1     yamt void agrtimer_stop(struct agr_softc *);
    139       1.1     yamt 
    140       1.1     yamt void agrport_monitor(struct agr_port *);
    141       1.1     yamt 
    142  1.2.16.1  gdamore #endif /* !_NET_AGR_IF_AGRVAR_IMPL_H_ */
    143