summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/nxge/nxge_flow.h
blob: 637f1aad8d2be59db29d6604ed4402bbe7c1c535 (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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SYS_NXGE_NXGE_FLOW_H
#define	_SYS_NXGE_NXGE_FLOW_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <netinet/in.h>
#define	S6_addr32	_S6_un._S6_u32

typedef struct tcpip4_spec_s {
	in_addr_t  ip4src;
	in_addr_t  ip4dst;
	in_port_t  psrc;
	in_port_t  pdst;
	uint8_t	   tos;
} tcpip4_spec_t;

typedef struct tcpip6_spec_s {
	struct in6_addr ip6src;
	struct in6_addr ip6dst;
	in_port_t  psrc;
	in_port_t  pdst;
	uint8_t	   tos;
} tcpip6_spec_t;

typedef struct udpip4_spec_s {
	in_addr_t  ip4src;
	in_addr_t  ip4dst;
	in_port_t  psrc;
	in_port_t  pdst;
	uint8_t	   tos;
} udpip4_spec_t;

typedef struct udpip6_spec_s {
	struct in6_addr ip6src;
	struct in6_addr ip6dst;
	in_port_t  psrc;
	in_port_t  pdst;
	uint8_t	   tos;
} udpip6_spec_t;

typedef struct ahip4_spec_s {
	in_addr_t  ip4src;
	in_addr_t  ip4dst;
	uint32_t   spi;
	uint8_t	   tos;
} ahip4_spec_t;

typedef struct ahip6_spec_s {
	struct in6_addr ip6src;
	struct in6_addr ip6dst;
	uint32_t   spi;
	uint8_t	   tos;
} ahip6_spec_t;

typedef ahip4_spec_t espip4_spec_t;
typedef ahip6_spec_t espip6_spec_t;

typedef struct rawip4_spec_s {
	struct in6_addr ip4src;
	struct in6_addr ip4dst;
	uint8_t    hdata[64];
} rawip4_spec_t;

typedef struct rawip6_spec_s {
	struct in6_addr ip6src;
	struct in6_addr ip6dst;
	uint8_t    hdata[64];
} rawip6_spec_t;


typedef struct ether_spec_s {
	uint16_t   ether_type;
	uint8_t    frame_size;
	uint8_t    eframe[16];
} ether_spec_t;


#define	FSPEC_IP4	1
#define	FSPEC_IP6	2

typedef struct ip_user_spec_s {
	uint32_t	ip4src;
	uint32_t	ip4dst;
	uint32_t	l4_4_bytes;
	uint8_t    	tos;
	uint8_t    	ip_ver;
	uint8_t    	proto;
} ip_user_spec_t;

typedef struct ip6_frag_spec_s {
	struct in6_addr ip6src;
	struct in6_addr ip6dst;
	uint32_t	l4_4_bytes;
	uint8_t    	tos;
	uint8_t    	proto;	/* should be 44 */
} ip6_frag_spec_t;


typedef ether_spec_t arpip_spec_t;
typedef ether_spec_t ether_user_spec_t;

struct flow_spec_s {
	uint32_t  flow_type;
	union {
		tcpip4_spec_t tcpip4spec;
		tcpip6_spec_t tcpip6spec;
		udpip4_spec_t udpip4spec;
		udpip6_spec_t udpip6spec;
		arpip_spec_t  arpipspec;
		ahip4_spec_t  ahip4spec;
		ahip6_spec_t  ahip6spec;
		espip4_spec_t espip4spec;
		espip6_spec_t espip6spec;
		rawip4_spec_t rawip4spec;
		rawip6_spec_t rawip6spec;
		ether_spec_t  etherspec;
		ip_user_spec_t  ip_usr_spec;
		ip6_frag_spec_t  ip6_frag_spec;
		uint8_t		hdata[64];
	} uh, um; /* entry, mask */
} __attribute__((packed));

typedef struct flow_spec_s flow_spec_t;

#define	FSPEC_TCPIP4	0x1	/* TCP/IPv4 Flow */
#define	FSPEC_TCPIP6	0x2	/* TCP/IPv6 */
#define	FSPEC_UDPIP4	0x3	/* UDP/IPv4 */
#define	FSPEC_UDPIP6	0x4	/* UDP/IPv6 */
#define	FSPEC_ARPIP	0x5	/* ARP/IPv4 */
#define	FSPEC_AHIP4	0x6	/* AH/IP4   */
#define	FSPEC_AHIP6	0x7	/* AH/IP6   */
#define	FSPEC_ESPIP4	0x8	/* ESP/IP4  */
#define	FSPEC_ESPIP6	0x9	/* ESP/IP6  */
#define	FSPEC_SCTPIP4	0xA	/* SCTP/IP4  */
#define	FSPEC_SCTPIP6	0xB	/* SCTP/IP6  */
#define	FSPEC_IP6FRAG	0xC	/* IPv6 Fragments */
#define	FSPEC_RAW4	0xD	/* RAW/IP4  */
#define	FSPEC_RAW6	0xE	/* RAW/IP6  */
#define	FSPEC_ETHER	0xF	/* ETHER Programmable  */
#define	FSPEC_IP_USR	0x10	/* IP Programmable  */
#define	FSPEC_HDATA	0x11	/* Pkt Headers eth-da,sa,etype,ip,tcp(Bitmap) */

#define	TCAM_IPV6_ADDR(m32, ip6addr) {		\
		m32[0] = ip6addr.S6_addr32[0]; \
		m32[1] = ip6addr.S6_addr32[1]; \
		m32[2] = ip6addr.S6_addr32[2]; \
		m32[3] = ip6addr.S6_addr32[3]; \
	}

#define	FSPEC_IPV6_ADDR(ip6addr, m32) {		\
	ip6addr.S6_addr32[0] = m32[0];		\
	ip6addr.S6_addr32[1] = m32[1];		\
	ip6addr.S6_addr32[2] = m32[2];		\
	ip6addr.S6_addr32[3] = m32[3];		\
}

#define	TCAM_IPV4_ADDR(m32, ip4addr) (m32 = ip4addr)
#define	FSPEC_IPV4_ADDR(ip4addr, m32) (ip4addr = m32)

#define	TCAM_IP_PORTS(port32, dp, sp)	  (port32 = dp | (sp << 16))
#define	FSPEC_IP_PORTS(dp, sp, port32) {	\
	dp = port32 & 0xff;			\
	sp = port32 >> 16;			\
}

#define	TCAM_IP_CLASS(key, mask, class)	  {		\
		key = class; \
		mask = 0x1f; \
	}

#define	TCAM_IP_PROTO(key, mask, proto) {		\
		key = proto; \
		mask = 0xff; \
	}

struct flow_resource_s {
	uint64_t channel_cookie;
	uint64_t flow_cookie;
	uint64_t location;
	flow_spec_t flow_spec;
} __attribute__((packed));

typedef struct flow_resource_s flow_resource_t;

/* ioctl data structure and cmd types for configuring rx classification */

#define	NXGE_RX_CLASS_GCHAN	0x01
#define	NXGE_RX_CLASS_GRULE_CNT	0x02
#define	NXGE_RX_CLASS_GRULE	0x03
#define	NXGE_RX_CLASS_GRULE_ALL	0x04
#define	NXGE_RX_CLASS_RULE_DEL	0x05
#define	NXGE_RX_CLASS_RULE_INS	0x06

#define	NXGE_PKT_DISCARD	0xffffffffffffffffULL

struct rx_class_cfg_s {
	uint32_t cmd;
	uint32_t data; /* the rule DB size or the # rx rings */
	uint64_t rule_cnt;
	uint32_t rule_locs[256];
	flow_resource_t fs;
} __attribute__((packed));

typedef struct rx_class_cfg_s rx_class_cfg_t;

/*
 * ioctl data structure and cmd types for configuring rx hash
 * for IP tunneled traffic and symmetric mode.
 */

#define	NXGE_IPTUN_CFG_ADD_CLS	0x07
#define	NXGE_IPTUN_CFG_SET_HASH	0x08
#define	NXGE_IPTUN_CFG_DEL_CLS	0x09
#define	NXGE_IPTUN_CFG_GET_CLS	0x0a
#define	NXGE_CLS_CFG_SET_SYM	0x0b
#define	NXGE_CLS_CFG_GET_SYM	0x0c

#define	IPTUN_PKT_IPV4		1
#define	IPTUN_PKT_IPV6		2
#define	IPTUN_PKT_GRE		3
#define	IPTUN_PKT_GTP		4
#define	OTHER_USR_PKT		5

#define	SEL_L4B_0_3		0x0001
#define	SEL_L4B_4_7		0x0002
#define	SEL_L4B_8_11		0x0004
#define	SEL_L4B_12_15		0x0008
#define	SEL_L4B_16_19		0x0010
#define	SEL_L4B_20_23		0x0020
#define	SEL_L4B_24_27		0x0040
#define	SEL_L4B_28_31		0x0080
#define	SEL_L4B_32_35		0x0100
#define	SEL_L4B_36_39		0x0200

#define	HASH_IFPORT		0x0001
#define	HASH_L2DA		0x0002
#define	HASH_VLAN		0x0004
#define	HASH_IPSA		0x0008
#define	HASH_IPDA		0x0010
#define	HASH_L3PROTO		0x0020

#define	CLS_TCPV4		0x08
#define	CLS_UDPV4		0x09
#define	CLS_AHESPV4		0x0A
#define	CLS_SCTPV4		0x0B
#define	CLS_TCPV6		0x0C
#define	CLS_UDPV6		0x0D
#define	CLS_AHESPV6		0x0E
#define	CLS_SCTPV6		0x0F
#define	CLS_IPV6FRAG		0x1F

struct _iptun_cfg {
	uint8_t		in_pkt_type;
	uint8_t		l4b0_val;
	uint8_t		l4b0_mask;
	uint8_t		l4b23_sel;
	uint16_t	l4b23_val;
	uint16_t	l4xor_sel;
	uint8_t		hash_flags;
} __attribute__((packed));

typedef struct _iptun_cfg iptun_cfg_t;

struct _cfg_cmd {
	uint16_t cmd;
	uint8_t sym;
	uint8_t	class_id;
	iptun_cfg_t	iptun_cfg;
} __attribute__((packed));

typedef struct _cfg_cmd cfg_cmd_t;

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_NXGE_NXGE_FLOW_H */