xref: /titanic_51/usr/src/uts/common/sys/nxge/nxge_flow.h (revision 81d9f076db88c1f40c85831ce1ebb444a209c5a8)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_NXGE_NXGE_FLOW_H
27 #define	_SYS_NXGE_NXGE_FLOW_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <netinet/in.h>
34 #define	S6_addr32	_S6_un._S6_u32
35 
36 typedef struct tcpip4_spec_s {
37 	in_addr_t  ip4src;
38 	in_addr_t  ip4dst;
39 	in_port_t  psrc;
40 	in_port_t  pdst;
41 	uint8_t	   tos;
42 } tcpip4_spec_t;
43 
44 typedef struct tcpip6_spec_s {
45 	struct in6_addr ip6src;
46 	struct in6_addr ip6dst;
47 	in_port_t  psrc;
48 	in_port_t  pdst;
49 	uint8_t	   tos;
50 } tcpip6_spec_t;
51 
52 typedef struct udpip4_spec_s {
53 	in_addr_t  ip4src;
54 	in_addr_t  ip4dst;
55 	in_port_t  psrc;
56 	in_port_t  pdst;
57 	uint8_t	   tos;
58 } udpip4_spec_t;
59 
60 typedef struct udpip6_spec_s {
61 	struct in6_addr ip6src;
62 	struct in6_addr ip6dst;
63 	in_port_t  psrc;
64 	in_port_t  pdst;
65 	uint8_t	   tos;
66 } udpip6_spec_t;
67 
68 typedef struct ahip4_spec_s {
69 	in_addr_t  ip4src;
70 	in_addr_t  ip4dst;
71 	uint32_t   spi;
72 	uint8_t	   tos;
73 } ahip4_spec_t;
74 
75 typedef struct ahip6_spec_s {
76 	struct in6_addr ip6src;
77 	struct in6_addr ip6dst;
78 	uint32_t   spi;
79 	uint8_t	   tos;
80 } ahip6_spec_t;
81 
82 typedef ahip4_spec_t espip4_spec_t;
83 typedef ahip6_spec_t espip6_spec_t;
84 
85 typedef struct rawip4_spec_s {
86 	struct in6_addr ip4src;
87 	struct in6_addr ip4dst;
88 	uint8_t    hdata[64];
89 } rawip4_spec_t;
90 
91 typedef struct rawip6_spec_s {
92 	struct in6_addr ip6src;
93 	struct in6_addr ip6dst;
94 	uint8_t    hdata[64];
95 } rawip6_spec_t;
96 
97 
98 typedef struct ether_spec_s {
99 	uint16_t   ether_type;
100 	uint8_t    frame_size;
101 	uint8_t    eframe[16];
102 } ether_spec_t;
103 
104 
105 #define	FSPEC_IP4	1
106 #define	FSPEC_IP6	2
107 
108 typedef struct ip_user_spec_s {
109 	uint32_t	ip4src;
110 	uint32_t	ip4dst;
111 	uint32_t	l4_4_bytes;
112 	uint8_t    	tos;
113 	uint8_t    	ip_ver;
114 	uint8_t    	proto;
115 } ip_user_spec_t;
116 
117 typedef struct ip6_frag_spec_s {
118 	struct in6_addr ip6src;
119 	struct in6_addr ip6dst;
120 	uint32_t	l4_4_bytes;
121 	uint8_t    	tos;
122 	uint8_t    	proto;	/* should be 44 */
123 } ip6_frag_spec_t;
124 
125 
126 typedef ether_spec_t arpip_spec_t;
127 typedef ether_spec_t ether_user_spec_t;
128 
129 struct flow_spec_s {
130 	uint32_t  flow_type;
131 	union {
132 		tcpip4_spec_t tcpip4spec;
133 		tcpip6_spec_t tcpip6spec;
134 		udpip4_spec_t udpip4spec;
135 		udpip6_spec_t udpip6spec;
136 		arpip_spec_t  arpipspec;
137 		ahip4_spec_t  ahip4spec;
138 		ahip6_spec_t  ahip6spec;
139 		espip4_spec_t espip4spec;
140 		espip6_spec_t espip6spec;
141 		rawip4_spec_t rawip4spec;
142 		rawip6_spec_t rawip6spec;
143 		ether_spec_t  etherspec;
144 		ip_user_spec_t  ip_usr_spec;
145 		ip6_frag_spec_t  ip6_frag_spec;
146 		uint8_t		hdata[64];
147 	} uh, um; /* entry, mask */
148 } __attribute__((packed));
149 
150 typedef struct flow_spec_s flow_spec_t;
151 
152 #define	FSPEC_TCPIP4	0x1	/* TCP/IPv4 Flow */
153 #define	FSPEC_TCPIP6	0x2	/* TCP/IPv6 */
154 #define	FSPEC_UDPIP4	0x3	/* UDP/IPv4 */
155 #define	FSPEC_UDPIP6	0x4	/* UDP/IPv6 */
156 #define	FSPEC_ARPIP	0x5	/* ARP/IPv4 */
157 #define	FSPEC_AHIP4	0x6	/* AH/IP4   */
158 #define	FSPEC_AHIP6	0x7	/* AH/IP6   */
159 #define	FSPEC_ESPIP4	0x8	/* ESP/IP4  */
160 #define	FSPEC_ESPIP6	0x9	/* ESP/IP6  */
161 #define	FSPEC_SCTPIP4	0xA	/* SCTP/IP4  */
162 #define	FSPEC_SCTPIP6	0xB	/* SCTP/IP6  */
163 #define	FSPEC_IP6FRAG	0xC	/* IPv6 Fragments */
164 #define	FSPEC_RAW4	0xD	/* RAW/IP4  */
165 #define	FSPEC_RAW6	0xE	/* RAW/IP6  */
166 #define	FSPEC_ETHER	0xF	/* ETHER Programmable  */
167 #define	FSPEC_IP_USR	0x10	/* IP Programmable  */
168 #define	FSPEC_HDATA	0x11	/* Pkt Headers eth-da,sa,etype,ip,tcp(Bitmap) */
169 
170 #define	TCAM_IPV6_ADDR(m32, ip6addr) {		\
171 		m32[0] = ip6addr.S6_addr32[0]; \
172 		m32[1] = ip6addr.S6_addr32[1]; \
173 		m32[2] = ip6addr.S6_addr32[2]; \
174 		m32[3] = ip6addr.S6_addr32[3]; \
175 	}
176 
177 #define	FSPEC_IPV6_ADDR(ip6addr, m32) {		\
178 	ip6addr.S6_addr32[0] = m32[0];		\
179 	ip6addr.S6_addr32[1] = m32[1];		\
180 	ip6addr.S6_addr32[2] = m32[2];		\
181 	ip6addr.S6_addr32[3] = m32[3];		\
182 }
183 
184 #define	TCAM_IPV4_ADDR(m32, ip4addr) (m32 = ip4addr)
185 #define	FSPEC_IPV4_ADDR(ip4addr, m32) (ip4addr = m32)
186 
187 #define	TCAM_IP_PORTS(port32, dp, sp)	  (port32 = dp | (sp << 16))
188 #define	FSPEC_IP_PORTS(dp, sp, port32) {	\
189 	dp = port32 & 0xff;			\
190 	sp = port32 >> 16;			\
191 }
192 
193 #define	TCAM_IP_CLASS(key, mask, class)	  {		\
194 		key = class; \
195 		mask = 0x1f; \
196 	}
197 
198 #define	TCAM_IP_PROTO(key, mask, proto) {		\
199 		key = proto; \
200 		mask = 0xff; \
201 	}
202 
203 struct flow_resource_s {
204 	uint64_t channel_cookie;
205 	uint64_t flow_cookie;
206 	uint64_t location;
207 	flow_spec_t flow_spec;
208 } __attribute__((packed));
209 
210 typedef struct flow_resource_s flow_resource_t;
211 
212 /* ioctl data structure and cmd types for configuring rx classification */
213 
214 #define	NXGE_RX_CLASS_GCHAN	0x01
215 #define	NXGE_RX_CLASS_GRULE_CNT	0x02
216 #define	NXGE_RX_CLASS_GRULE	0x03
217 #define	NXGE_RX_CLASS_GRULE_ALL	0x04
218 #define	NXGE_RX_CLASS_RULE_DEL	0x05
219 #define	NXGE_RX_CLASS_RULE_INS	0x06
220 
221 #define	NXGE_PKT_DISCARD	0xffffffffffffffffULL
222 
223 struct rx_class_cfg_s {
224 	uint32_t cmd;
225 	uint32_t data; /* the rule DB size or the # rx rings */
226 	uint64_t rule_cnt;
227 	uint32_t rule_locs[256];
228 	flow_resource_t fs;
229 } __attribute__((packed));
230 
231 typedef struct rx_class_cfg_s rx_class_cfg_t;
232 
233 /*
234  * ioctl data structure and cmd types for configuring rx hash
235  * for IP tunneled traffic and symmetric mode.
236  */
237 
238 #define	NXGE_IPTUN_CFG_ADD_CLS	0x07
239 #define	NXGE_IPTUN_CFG_SET_HASH	0x08
240 #define	NXGE_IPTUN_CFG_DEL_CLS	0x09
241 #define	NXGE_IPTUN_CFG_GET_CLS	0x0a
242 #define	NXGE_CLS_CFG_SET_SYM	0x0b
243 #define	NXGE_CLS_CFG_GET_SYM	0x0c
244 
245 #define	IPTUN_PKT_IPV4		1
246 #define	IPTUN_PKT_IPV6		2
247 #define	IPTUN_PKT_GRE		3
248 #define	IPTUN_PKT_GTP		4
249 #define	OTHER_USR_PKT		5
250 
251 #define	SEL_L4B_0_3		0x0001
252 #define	SEL_L4B_4_7		0x0002
253 #define	SEL_L4B_8_11		0x0004
254 #define	SEL_L4B_12_15		0x0008
255 #define	SEL_L4B_16_19		0x0010
256 #define	SEL_L4B_20_23		0x0020
257 #define	SEL_L4B_24_27		0x0040
258 #define	SEL_L4B_28_31		0x0080
259 #define	SEL_L4B_32_35		0x0100
260 #define	SEL_L4B_36_39		0x0200
261 
262 #define	HASH_IFPORT		0x0001
263 #define	HASH_L2DA		0x0002
264 #define	HASH_VLAN		0x0004
265 #define	HASH_IPSA		0x0008
266 #define	HASH_IPDA		0x0010
267 #define	HASH_L3PROTO		0x0020
268 
269 #define	CLS_TCPV4		0x08
270 #define	CLS_UDPV4		0x09
271 #define	CLS_AHESPV4		0x0A
272 #define	CLS_SCTPV4		0x0B
273 #define	CLS_TCPV6		0x0C
274 #define	CLS_UDPV6		0x0D
275 #define	CLS_AHESPV6		0x0E
276 #define	CLS_SCTPV6		0x0F
277 #define	CLS_IPV6FRAG		0x1F
278 
279 struct _iptun_cfg {
280 	uint8_t		in_pkt_type;
281 	uint8_t		l4b0_val;
282 	uint8_t		l4b0_mask;
283 	uint8_t		l4b23_sel;
284 	uint16_t	l4b23_val;
285 	uint16_t	l4xor_sel;
286 	uint8_t		hash_flags;
287 } __attribute__((packed));
288 
289 typedef struct _iptun_cfg iptun_cfg_t;
290 
291 struct _cfg_cmd {
292 	uint16_t cmd;
293 	uint8_t sym;
294 	uint8_t	class_id;
295 	iptun_cfg_t	iptun_cfg;
296 } __attribute__((packed));
297 
298 typedef struct _cfg_cmd cfg_cmd_t;
299 
300 #ifdef	__cplusplus
301 }
302 #endif
303 
304 #endif	/* _SYS_NXGE_NXGE_FLOW_H */
305