1139823Simp/*-
2116808Sharti * Copyright (c) 2001-2003
3116808Sharti *	Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4116808Sharti * 	All rights reserved.
5116808Sharti *
6116808Sharti * Redistribution and use in source and binary forms, with or without
7116808Sharti * modification, are permitted provided that the following conditions
8116808Sharti * are met:
9116808Sharti * 1. Redistributions of source code must retain the above copyright
10116808Sharti *    notice, this list of conditions and the following disclaimer.
11116808Sharti * 2. Redistributions in binary form must reproduce the above copyright
12116808Sharti *    notice, this list of conditions and the following disclaimer in the
13116808Sharti *    documentation and/or other materials provided with the distribution.
14116808Sharti *
15116808Sharti * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16116808Sharti * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17116808Sharti * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18116808Sharti * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19116808Sharti * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20116808Sharti * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21116808Sharti * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22116808Sharti * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23116808Sharti * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24116808Sharti * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25116808Sharti * SUCH DAMAGE.
26116808Sharti *
27116808Sharti * Author: Harti Brandt <harti@freebsd.org>
28139823Simp */
29139823Simp
30139823Simp/*
31116808Sharti * Netgraph module to connect NATM interfaces to netgraph.
32116808Sharti *
33116808Sharti * $FreeBSD$
34116808Sharti */
35122614Sharti#ifndef _NETGRAPH_ATM_NG_ATM_H_
36122614Sharti#define _NETGRAPH_ATM_NG_ATM_H_
37116808Sharti
38116808Sharti#define NG_ATM_NODE_TYPE "atm"
39116808Sharti#define NGM_ATM_COOKIE	960802260
40116808Sharti
41116808Sharti/* Netgraph control messages */
42116808Shartienum {
43116808Sharti	NGM_ATM_GET_IFNAME = 1,		/* get the interface name */
44116808Sharti	NGM_ATM_GET_CONFIG,		/* get configuration */
45116808Sharti	NGM_ATM_GET_VCCS,		/* get a list of all active vccs */
46116808Sharti	NGM_ATM_CPCS_INIT,		/* start the channel */
47116808Sharti	NGM_ATM_CPCS_TERM,		/* stop the channel */
48116808Sharti	NGM_ATM_GET_VCC,		/* get VCC config */
49116808Sharti	NGM_ATM_GET_VCCID,		/* get VCC by VCI/VPI */
50116808Sharti	NGM_ATM_GET_STATS,		/* get global statistics */
51116808Sharti
52116808Sharti	/* messages from the node */
53118175Sharti	NGM_ATM_CARRIER_CHANGE = 1000,	/* UNUSED: carrier changed */
54116808Sharti	NGM_ATM_VCC_CHANGE,		/* permanent VCC changed */
55118175Sharti	NGM_ATM_ACR_CHANGE,		/* ABR ACR has changed */
56118175Sharti	NGM_ATM_IF_CHANGE,		/* interface state change */
57116808Sharti};
58116808Sharti
59116808Sharti/*
60116808Sharti * Hardware interface configuration
61116808Sharti */
62116808Shartistruct ngm_atm_config {
63116808Sharti	uint32_t	pcr;		/* peak cell rate */
64116808Sharti	uint32_t	vpi_bits;	/* number of active VPI bits */
65116808Sharti	uint32_t	vci_bits;	/* number of active VCI bits */
66116808Sharti	uint32_t	max_vpcs;	/* maximum number of VPCs */
67116808Sharti	uint32_t	max_vccs;	/* maximum number of VCCs */
68116808Sharti};
69116808Sharti#define NGM_ATM_CONFIG_INFO 					\
70116808Sharti	{							\
71116808Sharti	  { "pcr",	&ng_parse_uint32_type },		\
72116808Sharti	  { "vpi_bits",	&ng_parse_uint32_type },		\
73116808Sharti	  { "vci_bits",	&ng_parse_uint32_type },		\
74116808Sharti	  { "max_vpcs",	&ng_parse_uint32_type },		\
75116808Sharti	  { "max_vccs",	&ng_parse_uint32_type },		\
76116808Sharti	  { NULL }						\
77116808Sharti	}
78116808Sharti
79116808Sharti/*
80116808Sharti * Information about an open VCC
81116808Sharti * See net/if_atm.h. Keep in sync.
82116808Sharti */
83116808Sharti#define NGM_ATM_TPARAM_INFO 					\
84116808Sharti	{							\
85116808Sharti	  { "pcr",	&ng_parse_uint32_type },		\
86116808Sharti	  { "scr",	&ng_parse_uint32_type },		\
87116808Sharti	  { "mbs",	&ng_parse_uint32_type },		\
88116808Sharti	  { "mcr",	&ng_parse_uint32_type },		\
89116808Sharti	  { "icr",	&ng_parse_uint32_type },		\
90116808Sharti	  { "tbe",	&ng_parse_uint32_type },		\
91116808Sharti	  { "nrm",	&ng_parse_uint8_type },			\
92116808Sharti	  { "trm",	&ng_parse_uint8_type },			\
93116808Sharti	  { "adtf",	&ng_parse_uint16_type },		\
94116808Sharti	  { "rif",	&ng_parse_uint8_type },			\
95116808Sharti	  { "rdf",	&ng_parse_uint8_type },			\
96116808Sharti	  { "cdf",	&ng_parse_uint8_type },			\
97116808Sharti	  { NULL }						\
98116808Sharti	}
99116808Sharti
100116808Sharti#define NGM_ATM_VCC_INFO 					\
101116808Sharti	{							\
102116808Sharti	  { "flags",	&ng_parse_hint16_type },		\
103116808Sharti	  { "vpi",	&ng_parse_uint16_type },		\
104116808Sharti	  { "vci",	&ng_parse_uint16_type },		\
105116808Sharti	  { "rmtu",	&ng_parse_uint16_type },		\
106116808Sharti	  { "tmtu",	&ng_parse_uint16_type },		\
107116808Sharti	  { "aal",	&ng_parse_uint8_type },			\
108116808Sharti	  { "traffic",	&ng_parse_uint8_type },			\
109116808Sharti	  { "tparam",	&ng_atm_tparam_type },			\
110116808Sharti	  { NULL }						\
111116808Sharti	}
112116808Sharti
113116808Sharti#define NGM_ATM_VCCARRAY_INFO					\
114116808Sharti	{							\
115116808Sharti	  &ng_atm_vcc_type,					\
116116808Sharti	  ng_atm_vccarray_getlen,				\
117116808Sharti	  NULL							\
118116808Sharti	}
119116808Sharti
120116808Sharti#define NGM_ATM_VCCTABLE_INFO 					\
121116808Sharti	{							\
122116808Sharti	  { "count",	&ng_parse_uint32_type },		\
123116808Sharti	  { "vccs",	&ng_atm_vccarray_type },		\
124116808Sharti	  { NULL }						\
125116808Sharti	}
126116808Sharti
127116808Sharti/*
128116808Sharti * Structure to open a VCC.
129116808Sharti */
130116808Shartistruct ngm_atm_cpcs_init {
131125035Sharti	char		name[NG_HOOKSIZ];
132116808Sharti	uint32_t	flags;		/* flags. (if_atm.h) */
133116808Sharti	uint16_t	vci;		/* VCI to open */
134116808Sharti	uint16_t	vpi;		/* VPI to open */
135116808Sharti	uint16_t	rmtu;		/* Receive maximum CPCS size */
136116808Sharti	uint16_t	tmtu;		/* Transmit maximum CPCS size */
137116808Sharti	uint8_t		aal;		/* AAL type (if_atm.h) */
138116808Sharti	uint8_t		traffic;	/* traffic type (if_atm.h) */
139116808Sharti	uint32_t	pcr;		/* Peak cell rate */
140116808Sharti	uint32_t	scr;		/* VBR: Sustainable cell rate */
141116808Sharti	uint32_t	mbs;		/* VBR: Maximum burst rate */
142116808Sharti	uint32_t	mcr;		/* UBR+: Minimum cell rate */
143116808Sharti	uint32_t	icr;		/* ABR: Initial cell rate */
144116808Sharti	uint32_t	tbe;		/* ABR: Transmit buffer exposure */
145116808Sharti	uint8_t		nrm;		/* ABR: Nrm */
146116808Sharti	uint8_t		trm;		/* ABR: Trm */
147116808Sharti	uint16_t	adtf;		/* ABR: ADTF */
148116808Sharti	uint8_t		rif;		/* ABR: RIF */
149116808Sharti	uint8_t		rdf;		/* ABR: RDF */
150116808Sharti	uint8_t		cdf;		/* ABR: CDF */
151116808Sharti};
152116808Sharti
153116808Sharti#define NGM_ATM_CPCS_INIT_INFO 					\
154116808Sharti	{							\
155116808Sharti	  { "name",	&ng_parse_hookbuf_type },		\
156116808Sharti	  { "flags",	&ng_parse_hint32_type },		\
157116808Sharti	  { "vci",	&ng_parse_uint16_type },		\
158116808Sharti	  { "vpi",	&ng_parse_uint16_type },		\
159116808Sharti	  { "rmtu",	&ng_parse_uint16_type },		\
160116808Sharti	  { "tmtu",	&ng_parse_uint16_type },		\
161116808Sharti	  { "aal",	&ng_parse_uint8_type },			\
162116808Sharti	  { "traffic",	&ng_parse_uint8_type },			\
163116808Sharti	  { "pcr",	&ng_parse_uint32_type },		\
164116808Sharti	  { "scr",	&ng_parse_uint32_type },		\
165116808Sharti	  { "mbs",	&ng_parse_uint32_type },		\
166116808Sharti	  { "mcr",	&ng_parse_uint32_type },		\
167116808Sharti	  { "icr",	&ng_parse_uint32_type },		\
168116808Sharti	  { "tbe",	&ng_parse_uint32_type },		\
169116808Sharti	  { "nrm",	&ng_parse_uint8_type },			\
170116808Sharti	  { "trm",	&ng_parse_uint8_type },			\
171116808Sharti	  { "adtf",	&ng_parse_uint16_type },		\
172116808Sharti	  { "rif",	&ng_parse_uint8_type },			\
173116808Sharti	  { "rdf",	&ng_parse_uint8_type },			\
174116808Sharti	  { "cdf",	&ng_parse_uint8_type },			\
175116808Sharti	  { NULL }						\
176116808Sharti	}
177116808Sharti
178116808Sharti/*
179116808Sharti * Structure to close a VCI without disconnecting the hook
180116808Sharti */
181116808Shartistruct ngm_atm_cpcs_term {
182125035Sharti	char		name[NG_HOOKSIZ];
183116808Sharti};
184116808Sharti#define NGM_ATM_CPCS_TERM_INFO 					\
185116808Sharti	{							\
186116808Sharti	  { "name",	&ng_parse_hookbuf_type },		\
187116808Sharti	  { NULL }						\
188116808Sharti	}
189116808Sharti
190116808Shartistruct ngm_atm_stats {
191116808Sharti	uint64_t	in_packets;
192116808Sharti	uint64_t	in_errors;
193116808Sharti	uint64_t	out_packets;
194116808Sharti	uint64_t	out_errors;
195116808Sharti};
196116808Sharti#define NGM_ATM_STATS_INFO					\
197116808Sharti	{							\
198116808Sharti	  { "in_packets",	&ng_parse_uint64_type },	\
199116808Sharti	  { "in_errors",	&ng_parse_uint64_type },	\
200116808Sharti	  { "out_packets",	&ng_parse_uint64_type },	\
201116808Sharti	  { "out_errors",	&ng_parse_uint64_type },	\
202116808Sharti	  { NULL }						\
203116808Sharti	}
204116808Sharti
205118175Shartistruct ngm_atm_if_change {
206116808Sharti	uint32_t	node;
207118175Sharti	uint8_t		carrier;
208118175Sharti	uint8_t		running;
209116808Sharti};
210118175Sharti#define NGM_ATM_IF_CHANGE_INFO 					\
211116808Sharti	{							\
212116808Sharti	  { "node",	&ng_parse_hint32_type },		\
213118175Sharti	  { "carrier",	&ng_parse_uint8_type },			\
214118175Sharti	  { "running",	&ng_parse_uint8_type },			\
215116808Sharti	  { NULL }						\
216116808Sharti	}
217116808Sharti
218116808Shartistruct ngm_atm_vcc_change {
219116808Sharti	uint32_t	node;
220116808Sharti	uint16_t	vci;
221116808Sharti	uint8_t		vpi;
222116808Sharti	uint8_t		state;
223116808Sharti};
224116808Sharti#define NGM_ATM_VCC_CHANGE_INFO 				\
225116808Sharti	{							\
226116808Sharti	  { "node",	&ng_parse_hint32_type },		\
227116808Sharti	  { "vci",	&ng_parse_uint16_type },		\
228116808Sharti	  { "vpi",	&ng_parse_uint8_type },			\
229116808Sharti	  { "state",	&ng_parse_uint8_type },			\
230116808Sharti	  { NULL }						\
231116808Sharti	}
232116808Sharti
233118175Shartistruct ngm_atm_acr_change {
234118175Sharti	uint32_t	node;
235118175Sharti	uint16_t	vci;
236118175Sharti	uint8_t		vpi;
237118175Sharti	uint32_t	acr;
238118175Sharti};
239118175Sharti#define NGM_ATM_ACR_CHANGE_INFO					\
240118175Sharti	{							\
241118175Sharti	  { "node",	&ng_parse_hint32_type },		\
242118175Sharti	  { "vci",	&ng_parse_uint16_type },		\
243118175Sharti	  { "vpi",	&ng_parse_uint8_type },			\
244118175Sharti	  { "acr",	&ng_parse_uint32_type },		\
245118175Sharti	  { NULL }						\
246118175Sharti	}
247118175Sharti
248116808Sharti#endif /* _NETGRAPH_ATM_NG_ATM_H */
249