summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/atm/ng_atmpif.h
blob: b45df7578a0b006fe9d0839814acd313b068b84b (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
 * 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$
 */

#ifndef _NETGRAPH_ATM_NG_ATMPIF_H_
#define _NETGRAPH_ATM_NG_ATMPIF_H_

/* Node type name and magic cookie */
#define NG_ATMPIF_NODE_TYPE		"atmpif"
#define NGM_ATMPIF_COOKIE		967239456

/*
 * Physical device name - used to configure HARP devices
 */
#ifndef VATMPIF_DEV_NAME
#define VATMPIF_DEV_NAME	"hva"	/* HARP Virtual ATM */
#endif

#define VATMPIF_MAX_VCI		65535
#define VATMPIF_MAX_VPI		255

/* Hook name */
#define NG_ATMPIF_HOOK_LINK	"link"	 /* virtual link hook */

/*
 * Node configuration structure
 */
struct ng_vatmpif_config {
	uint8_t		debug;		/* debug bit field (see below) */
	uint32_t	pcr;		/* peak cell rate */
	Mac_addr	macaddr;	/* Mac Address */
};
/* Keep this in sync with the above structure definition */
#define NG_ATMPIF_CONFIG_TYPE_INFO { 				\
	{ "debug",		&ng_parse_uint8_type	},	\
	{ "pcr",		&ng_parse_uint32_type	},	\
	{ "macaddr",		&ng_mac_addr_type	},	\
	{ NULL }						\
}

/*
 * Debug bit-fields
 */
#define VATMPIF_DEBUG_NONE	0x00
#define VATMPIF_DEBUG_PACKET	0x01 /* enable ng_atmpif debugging	 */

#define IS_VATMPIF_DEBUG_PACKET(a)  ( (a)	\
				&&  ((a)->conf.debug & VATMPIF_DEBUG_PACKET)  )

/*
 * Statistics
 */
struct hva_stats_ng {
	uint32_t	ng_errseq;	/* Duplicate or out of order */
	uint32_t	ng_lostpdu;	/* PDU lost detected */
	uint32_t	ng_badpdu;	/* Unknown PDU type */
	uint32_t	ng_rx_novcc;	/* Draining PDU on closed VCC */
	uint32_t	ng_rx_iqfull;	/* PDU drops, no room in atm_intrq */
	uint32_t	ng_tx_rawcell;	/* PDU raw cells transmitted */
	uint32_t	ng_rx_rawcell;	/* PDU raw cells received */
	uint64_t	ng_tx_pdu;	/* PDU transmitted */
	uint64_t	ng_rx_pdu;	/* PDU received */
};
typedef struct hva_stats_ng	Hva_Stats_ng;
/* Keep this in sync with the above structure definition */
#define HVA_STATS_NG_TYPE_INFO 		 			\
	{ "errSeqOrder",	&ng_parse_uint32_type	},	\
	{ "errLostPDU",		&ng_parse_uint32_type	},	\
	{ "recvBadPDU",		&ng_parse_uint32_type	},	\
	{ "ErrATMVC",		&ng_parse_uint32_type	},	\
	{ "ErrQfull",		&ng_parse_uint32_type	},	\
	{ "xmitRawCell",	&ng_parse_uint32_type	},	\
	{ "recvRawCell",	&ng_parse_uint32_type	},	\
	{ "xmitPDU",		&ng_parse_uint64_type	},	\
	{ "recvPDU",		&ng_parse_uint64_type	},
	

struct hva_stats_atm {
	uint64_t	atm_xmit;	/* Cells transmitted */
	uint64_t	atm_rcvd;	/* Cells received */
};
typedef struct hva_stats_atm	Hva_Stats_atm;
/* Keep this in sync with the above structure definition */
#define HVA_STATS_ATM_NG_TYPE_INFO	 			\
	{ "xmitATMCells",	&ng_parse_uint64_type	},	\
	{ "recvATMCells",	&ng_parse_uint64_type	},

struct hva_stats_aal5 {
	uint64_t	aal5_xmit;	/* Cells transmitted */
	uint64_t	aal5_rcvd;	/* Cells received */
	uint32_t	aal5_crc_len;	/* Cells with CRC/length errors */
	uint32_t	aal5_drops;	/* Cell drops */
	uint64_t	aal5_pdu_xmit;	/* CS PDUs transmitted */
	uint64_t	aal5_pdu_rcvd;	/* CS PDUs received */
	uint32_t	aal5_pdu_crc;	/* CS PDUs with CRC errors */
	uint32_t	aal5_pdu_errs;	/* CS layer protocol errors */
	uint32_t	aal5_pdu_drops;	/* CS PDUs dropped */
};
typedef struct hva_stats_aal5	Hva_Stats_aal5;
/* Keep this in sync with the above structure definition */
#define HVA_STATS_AAL5_NG_TYPE_INFO	 			\
	{ "xmitAAL5Cells",		&ng_parse_uint64_type	},	\
	{ "recvAAL5Cells",		&ng_parse_uint64_type	},	\
	{ "AAL5ErrCRCCells",		&ng_parse_uint32_type	},	\
	{ "AAL5DropsCells",		&ng_parse_uint32_type	},	\
	{ "xmitAAL5PDU",		&ng_parse_uint64_type	},	\
	{ "recvAAL5PDU",		&ng_parse_uint64_type	},	\
	{ "AAL5CRCPDU",			&ng_parse_uint32_type	},	\
	{ "AAL5ErrPDU",			&ng_parse_uint32_type	},	\
	{ "AAL5DropsPDU",		&ng_parse_uint32_type	},

struct vatmpif_stats {
	Hva_Stats_ng	hva_st_ng;	/* Netgraph layer stats */
	Hva_Stats_atm	hva_st_atm;	/* ATM layer stats */
	Hva_Stats_aal5	hva_st_aal5;	/* AAL5 layer stats */
};
typedef struct vatmpif_stats	Vatmpif_stats;
/* Keep this in sync with the above structure definition */
#define NG_ATMPIF_STATS_TYPE_INFO {	\
	HVA_STATS_NG_TYPE_INFO	 	\
	HVA_STATS_ATM_NG_TYPE_INFO	\
	HVA_STATS_AAL5_NG_TYPE_INFO	\
	{ NULL }			\
}

/* Structure returned by NGM_ATMPIF_GET_LINK_STATUS */
struct ng_atmpif_link_status {
	uint32_t	InSeq;		/* last received sequence number + 1 */
	uint32_t	OutSeq;		/* last sent sequence number */
	uint32_t	cur_pcr;	/* slot's reserved PCR */
};
/* Keep this in sync with the above structure definition */
#define NG_ATMPIF_LINK_STATUS_TYPE_INFO  {		\
	{ "InSeq",	&ng_parse_uint32_type },	\
	{ "OutSeq",	&ng_parse_uint32_type },	\
	{ "cur_pcr",	&ng_parse_uint32_type },	\
	{ NULL }					\
}

/* Netgraph control messages */
enum {
	NGM_ATMPIF_SET_CONFIG = 1,	/* set node configuration */
	NGM_ATMPIF_GET_CONFIG,		/* get node configuration */
	NGM_ATMPIF_GET_LINK_STATUS,	/* get link status */
	NGM_ATMPIF_GET_STATS,		/* get link stats */
	NGM_ATMPIF_CLR_STATS,		/* clear link stats */
	NGM_ATMPIF_GETCLR_STATS,	/* atomically get & clear link stats */
};

#endif /* _NETGRAPH_NG_ATMPIF_H_ */
OpenPOWER on IntegriCloud