ng_atm.h revision 118175
1275970Scy/*
2275970Scy * Copyright (c) 2001-2003
3275970Scy *	Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4275970Scy * 	All rights reserved.
5275970Scy *
6275970Scy * Redistribution and use in source and binary forms, with or without
7275970Scy * modification, are permitted provided that the following conditions
8275970Scy * are met:
9275970Scy * 1. Redistributions of source code must retain the above copyright
10275970Scy *    notice, this list of conditions and the following disclaimer.
11275970Scy * 2. Redistributions in binary form must reproduce the above copyright
12275970Scy *    notice, this list of conditions and the following disclaimer in the
13275970Scy *    documentation and/or other materials provided with the distribution.
14275970Scy *
15275970Scy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16275970Scy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17275970Scy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18275970Scy * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19275970Scy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20275970Scy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21275970Scy * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22275970Scy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23275970Scy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24275970Scy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25275970Scy * SUCH DAMAGE.
26275970Scy *
27275970Scy * Author: Harti Brandt <harti@freebsd.org>
28275970Scy *
29275970Scy * Netgraph module to connect NATM interfaces to netgraph.
30275970Scy *
31275970Scy * $FreeBSD: head/sys/netgraph/atm/ng_atm.h 118175 2003-07-29 16:27:23Z harti $
32275970Scy */
33275970Scy#ifndef _NETGRAPH_ATM_NG_ATM_H
34275970Scy#define _NETGRAPH_ATM_NG_ATM_H
35275970Scy
36275970Scy#define NG_ATM_NODE_TYPE "atm"
37275970Scy#define NGM_ATM_COOKIE	960802260
38275970Scy
39275970Scy/* Netgraph control messages */
40275970Scyenum {
41275970Scy	NGM_ATM_GET_IFNAME = 1,		/* get the interface name */
42275970Scy	NGM_ATM_GET_CONFIG,		/* get configuration */
43275970Scy	NGM_ATM_GET_VCCS,		/* get a list of all active vccs */
44275970Scy	NGM_ATM_CPCS_INIT,		/* start the channel */
45275970Scy	NGM_ATM_CPCS_TERM,		/* stop the channel */
46275970Scy	NGM_ATM_GET_VCC,		/* get VCC config */
47275970Scy	NGM_ATM_GET_VCCID,		/* get VCC by VCI/VPI */
48275970Scy	NGM_ATM_GET_STATS,		/* get global statistics */
49275970Scy
50275970Scy	/* messages from the node */
51275970Scy	NGM_ATM_CARRIER_CHANGE = 1000,	/* UNUSED: carrier changed */
52275970Scy	NGM_ATM_VCC_CHANGE,		/* permanent VCC changed */
53275970Scy	NGM_ATM_ACR_CHANGE,		/* ABR ACR has changed */
54275970Scy	NGM_ATM_IF_CHANGE,		/* interface state change */
55275970Scy};
56275970Scy
57275970Scy/*
58275970Scy * Hardware interface configuration
59275970Scy */
60275970Scystruct ngm_atm_config {
61275970Scy	uint32_t	pcr;		/* peak cell rate */
62275970Scy	uint32_t	vpi_bits;	/* number of active VPI bits */
63275970Scy	uint32_t	vci_bits;	/* number of active VCI bits */
64275970Scy	uint32_t	max_vpcs;	/* maximum number of VPCs */
65275970Scy	uint32_t	max_vccs;	/* maximum number of VCCs */
66275970Scy};
67275970Scy#define NGM_ATM_CONFIG_INFO 					\
68275970Scy	{							\
69275970Scy	  { "pcr",	&ng_parse_uint32_type },		\
70275970Scy	  { "vpi_bits",	&ng_parse_uint32_type },		\
71275970Scy	  { "vci_bits",	&ng_parse_uint32_type },		\
72275970Scy	  { "max_vpcs",	&ng_parse_uint32_type },		\
73275970Scy	  { "max_vccs",	&ng_parse_uint32_type },		\
74275970Scy	  { NULL }						\
75275970Scy	}
76275970Scy
77275970Scy/*
78275970Scy * Information about an open VCC
79275970Scy * See net/if_atm.h. Keep in sync.
80275970Scy */
81275970Scy#define NGM_ATM_TPARAM_INFO 					\
82275970Scy	{							\
83275970Scy	  { "pcr",	&ng_parse_uint32_type },		\
84275970Scy	  { "scr",	&ng_parse_uint32_type },		\
85275970Scy	  { "mbs",	&ng_parse_uint32_type },		\
86275970Scy	  { "mcr",	&ng_parse_uint32_type },		\
87275970Scy	  { "icr",	&ng_parse_uint32_type },		\
88275970Scy	  { "tbe",	&ng_parse_uint32_type },		\
89275970Scy	  { "nrm",	&ng_parse_uint8_type },			\
90275970Scy	  { "trm",	&ng_parse_uint8_type },			\
91275970Scy	  { "adtf",	&ng_parse_uint16_type },		\
92275970Scy	  { "rif",	&ng_parse_uint8_type },			\
93275970Scy	  { "rdf",	&ng_parse_uint8_type },			\
94275970Scy	  { "cdf",	&ng_parse_uint8_type },			\
95275970Scy	  { NULL }						\
96275970Scy	}
97275970Scy
98275970Scy#define NGM_ATM_VCC_INFO 					\
99275970Scy	{							\
100275970Scy	  { "flags",	&ng_parse_hint16_type },		\
101275970Scy	  { "vpi",	&ng_parse_uint16_type },		\
102275970Scy	  { "vci",	&ng_parse_uint16_type },		\
103275970Scy	  { "rmtu",	&ng_parse_uint16_type },		\
104275970Scy	  { "tmtu",	&ng_parse_uint16_type },		\
105275970Scy	  { "aal",	&ng_parse_uint8_type },			\
106275970Scy	  { "traffic",	&ng_parse_uint8_type },			\
107275970Scy	  { "tparam",	&ng_atm_tparam_type },			\
108275970Scy	  { NULL }						\
109275970Scy	}
110275970Scy
111275970Scy#define NGM_ATM_VCCARRAY_INFO					\
112275970Scy	{							\
113275970Scy	  &ng_atm_vcc_type,					\
114275970Scy	  ng_atm_vccarray_getlen,				\
115275970Scy	  NULL							\
116275970Scy	}
117275970Scy
118275970Scy#define NGM_ATM_VCCTABLE_INFO 					\
119275970Scy	{							\
120275970Scy	  { "count",	&ng_parse_uint32_type },		\
121275970Scy	  { "vccs",	&ng_atm_vccarray_type },		\
122275970Scy	  { NULL }						\
123275970Scy	}
124275970Scy
125275970Scy/*
126275970Scy * Structure to open a VCC.
127275970Scy */
128275970Scystruct ngm_atm_cpcs_init {
129275970Scy	char		name[NG_HOOKLEN + 1];
130275970Scy	uint32_t	flags;		/* flags. (if_atm.h) */
131275970Scy	uint16_t	vci;		/* VCI to open */
132275970Scy	uint16_t	vpi;		/* VPI to open */
133275970Scy	uint16_t	rmtu;		/* Receive maximum CPCS size */
134275970Scy	uint16_t	tmtu;		/* Transmit maximum CPCS size */
135275970Scy	uint8_t		aal;		/* AAL type (if_atm.h) */
136275970Scy	uint8_t		traffic;	/* traffic type (if_atm.h) */
137275970Scy	uint32_t	pcr;		/* Peak cell rate */
138275970Scy	uint32_t	scr;		/* VBR: Sustainable cell rate */
139275970Scy	uint32_t	mbs;		/* VBR: Maximum burst rate */
140275970Scy	uint32_t	mcr;		/* UBR+: Minimum cell rate */
141275970Scy	uint32_t	icr;		/* ABR: Initial cell rate */
142275970Scy	uint32_t	tbe;		/* ABR: Transmit buffer exposure */
143275970Scy	uint8_t		nrm;		/* ABR: Nrm */
144275970Scy	uint8_t		trm;		/* ABR: Trm */
145275970Scy	uint16_t	adtf;		/* ABR: ADTF */
146275970Scy	uint8_t		rif;		/* ABR: RIF */
147275970Scy	uint8_t		rdf;		/* ABR: RDF */
148	uint8_t		cdf;		/* ABR: CDF */
149};
150
151#define NGM_ATM_CPCS_INIT_INFO 					\
152	{							\
153	  { "name",	&ng_parse_hookbuf_type },		\
154	  { "flags",	&ng_parse_hint32_type },		\
155	  { "vci",	&ng_parse_uint16_type },		\
156	  { "vpi",	&ng_parse_uint16_type },		\
157	  { "rmtu",	&ng_parse_uint16_type },		\
158	  { "tmtu",	&ng_parse_uint16_type },		\
159	  { "aal",	&ng_parse_uint8_type },			\
160	  { "traffic",	&ng_parse_uint8_type },			\
161	  { "pcr",	&ng_parse_uint32_type },		\
162	  { "scr",	&ng_parse_uint32_type },		\
163	  { "mbs",	&ng_parse_uint32_type },		\
164	  { "mcr",	&ng_parse_uint32_type },		\
165	  { "icr",	&ng_parse_uint32_type },		\
166	  { "tbe",	&ng_parse_uint32_type },		\
167	  { "nrm",	&ng_parse_uint8_type },			\
168	  { "trm",	&ng_parse_uint8_type },			\
169	  { "adtf",	&ng_parse_uint16_type },		\
170	  { "rif",	&ng_parse_uint8_type },			\
171	  { "rdf",	&ng_parse_uint8_type },			\
172	  { "cdf",	&ng_parse_uint8_type },			\
173	  { NULL }						\
174	}
175
176/*
177 * Structure to close a VCI without disconnecting the hook
178 */
179struct ngm_atm_cpcs_term {
180	char		name[NG_HOOKLEN + 1];
181};
182#define NGM_ATM_CPCS_TERM_INFO 					\
183	{							\
184	  { "name",	&ng_parse_hookbuf_type },		\
185	  { NULL }						\
186	}
187
188struct ngm_atm_stats {
189	uint64_t	in_packets;
190	uint64_t	in_errors;
191	uint64_t	out_packets;
192	uint64_t	out_errors;
193};
194#define NGM_ATM_STATS_INFO					\
195	{							\
196	  { "in_packets",	&ng_parse_uint64_type },	\
197	  { "in_errors",	&ng_parse_uint64_type },	\
198	  { "out_packets",	&ng_parse_uint64_type },	\
199	  { "out_errors",	&ng_parse_uint64_type },	\
200	  { NULL }						\
201	}
202
203struct ngm_atm_if_change {
204	uint32_t	node;
205	uint8_t		carrier;
206	uint8_t		running;
207};
208#define NGM_ATM_IF_CHANGE_INFO 					\
209	{							\
210	  { "node",	&ng_parse_hint32_type },		\
211	  { "carrier",	&ng_parse_uint8_type },			\
212	  { "running",	&ng_parse_uint8_type },			\
213	  { NULL }						\
214	}
215
216struct ngm_atm_vcc_change {
217	uint32_t	node;
218	uint16_t	vci;
219	uint8_t		vpi;
220	uint8_t		state;
221};
222#define NGM_ATM_VCC_CHANGE_INFO 				\
223	{							\
224	  { "node",	&ng_parse_hint32_type },		\
225	  { "vci",	&ng_parse_uint16_type },		\
226	  { "vpi",	&ng_parse_uint8_type },			\
227	  { "state",	&ng_parse_uint8_type },			\
228	  { NULL }						\
229	}
230
231struct ngm_atm_acr_change {
232	uint32_t	node;
233	uint16_t	vci;
234	uint8_t		vpi;
235	uint32_t	acr;
236};
237#define NGM_ATM_ACR_CHANGE_INFO					\
238	{							\
239	  { "node",	&ng_parse_hint32_type },		\
240	  { "vci",	&ng_parse_uint16_type },		\
241	  { "vpi",	&ng_parse_uint8_type },			\
242	  { "acr",	&ng_parse_uint32_type },		\
243	  { NULL }						\
244	}
245
246#endif /* _NETGRAPH_ATM_NG_ATM_H */
247