summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/atm/atmpif/ng_atmpif_var.h
blob: f295461678dc85d1f402ff5c686991a3eba376a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
 * Copyright (c) 2003 Harti Brandt.
 * Copyright (c) 2003 Vincent Jardin.
 * 	All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * 
 * $FreeBSD$
 */

/*
 * Supported AALs
 */
enum vatmpif_aal {
	VATMPIF_AAL_0 = 0,	/* Cell Service */
	VATMPIF_AAL_4 = 4,	/* AAL 3/4 */
	VATMPIF_AAL_5 = 5,	/* AAL 5 */
};
typedef enum vatmpif_aal Vatmpif_aal;

/*
 * Supported traffic type
 */
enum vatmpif_traffic_type {
	VATMPIF_TRAF_CBR = 0x01,	/* Constant bit rate */
	VATMPIF_TRAF_VBR = 0x02,	/* Variable bit rate */
	VATMPIF_TRAF_ABR = 0x03,	/* Available Bit Rate */
	VATMPIF_TRAF_UBR = 0x04,	/* Unspecified bit rate */
};
typedef enum vatmpif_traffic_type Vatmpif_traffic_type;

typedef struct t_atm_traffic Vatmpif_traffic;

/*
 * Host protocol control blocks
 * 
 */
/*
 * Device VCC Entry
 * 
 * Contains the common (vv_cmn) and specific information for each VCC
 * which is opened through a ATM PIF node.
 * It is a virtual VCC. From the Netgraph poit of view it is a
 * per-node's hook private data.
 *
 * It is a polymorph object with the instances of Cmn_vcc.
 */
struct vatmpif_vcc {
	Cmn_vcc			vv_cmn;		/* Common VCC stuff */
	Vatmpif_aal		vv_aal;		/* AAL */
	Vatmpif_traffic		vv_traffic;	/* forward and backward ATM traffic */
	Vatmpif_traffic_type	vv_traffic_type;/* CBR, VBR, UBR, ... */
};
typedef struct vatmpif_vcc	Vatmpif_vcc;

#define vv_next		vv_cmn.cv_next
#define vv_toku		vv_cmn.cv_toku
#define vv_upper	vv_cmn.cv_upper
#define vv_connvc	vv_cmn.cv_connvc
#define vv_state	vv_cmn.cv_state

/*
 * The hook structure describes a virtual link
 */
struct ng_vatmpif_hook {
	hook_p		hook;		/* netgraph hook */
	Vatmpif_stats	stats;		/* link stats */
	uint32_t	InSeq;		/* last received sequence number + 1 */
	uint32_t	OutSeq;		/* last sent sequence number */
	uint32_t	cur_pcr;	/* slot's reserved PCR */
};

/*
 * Device Virtual Unit Structure
 * 
 * Contains all the information for a single device (adapter).
 * It is a virtual device. From the Netgraph point of view it is
 * a per-node private data.
 *
 * It is a polymorph object with the instances of Cmn_unit.
 */
struct vatmpif_unit {
	Cmn_unit			vu_cmn;	/* Common unit stuff */
	node_p				node;	/* netgraph node */
	struct ng_vatmpif_hook*		link;	/* virtual link hoook */
	struct ng_vatmpif_config	conf;	/* node configuration */
};
typedef struct vatmpif_unit		Vatmpif_unit;

#define ng_vatmpif_private vatmpif_unit
typedef struct ng_vatmpif_private *priv_p;

#define vu_pif			vu_cmn.cu_pif
#define vu_unit			vu_cmn.cu_unit
#define vu_flags		vu_cmn.cu_flags
#define vu_mtu			vu_cmn.cu_mtu
#define vu_open_vcc		vu_cmn.cu_open_vcc
#define vu_vcc			vu_cmn.cu_vcc
#define vu_vcc_zone		vu_cmn.cu_vcc_zone
#define vu_nif_zone		vu_cmn.cu_nif_zone
#define vu_ioctl		vu_cmn.cu_ioctl
#define vu_instvcc		vu_cmn.cu_instvcc
#define vu_openvcc		vu_cmn.cu_openvcc
#define vu_closevcc		vu_cmn.cu_closevcc
#define vu_output		vu_cmn.cu_output
#define vu_config		vu_cmn.cu_config
#define vu_softc		vu_cmn.cu_softc

#define vu_stats		link->stats
#define vu_cur_pcr		link->cur_pcr

/*
 * Netgraph to HARP API
 */
int vatmpif_harp_attach(node_p node);
int vatmpif_harp_detach(node_p node);

int vatmpif_harp_recv_drain(Vatmpif_unit *vup, KBuffer *m,
  uint8_t vpi, uint16_t vci, uint8_t pt, uint8_t clp, Vatmpif_aal aal);

/*
 * HARP to Netgraph API
 */
int ng_atmpif_transmit(const priv_p priv, struct mbuf *m,
    uint8_t vpi, uint16_t vci, uint8_t pt, uint8_t clp, Vatmpif_aal aal);

extern uma_zone_t vatmpif_nif_zone;
extern uma_zone_t vatmpif_vcc_zone;
OpenPOWER on IntegriCloud