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