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