xref: /onnv-gate/usr/src/uts/common/io/hxge/hxge_flow.h (revision 6349:b4971e04f83d)
1*6349Sqs148142 /*
2*6349Sqs148142  * CDDL HEADER START
3*6349Sqs148142  *
4*6349Sqs148142  * The contents of this file are subject to the terms of the
5*6349Sqs148142  * Common Development and Distribution License (the "License").
6*6349Sqs148142  * You may not use this file except in compliance with the License.
7*6349Sqs148142  *
8*6349Sqs148142  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*6349Sqs148142  * or http://www.opensolaris.org/os/licensing.
10*6349Sqs148142  * See the License for the specific language governing permissions
11*6349Sqs148142  * and limitations under the License.
12*6349Sqs148142  *
13*6349Sqs148142  * When distributing Covered Code, include this CDDL HEADER in each
14*6349Sqs148142  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*6349Sqs148142  * If applicable, add the following below this CDDL HEADER, with the
16*6349Sqs148142  * fields enclosed by brackets "[]" replaced with your own identifying
17*6349Sqs148142  * information: Portions Copyright [yyyy] [name of copyright owner]
18*6349Sqs148142  *
19*6349Sqs148142  * CDDL HEADER END
20*6349Sqs148142  */
21*6349Sqs148142 /*
22*6349Sqs148142  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*6349Sqs148142  * Use is subject to license terms.
24*6349Sqs148142  */
25*6349Sqs148142 
26*6349Sqs148142 #ifndef	_SYS_HXGE_HXGE_FLOW_H
27*6349Sqs148142 #define	_SYS_HXGE_HXGE_FLOW_H
28*6349Sqs148142 
29*6349Sqs148142 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*6349Sqs148142 
31*6349Sqs148142 #ifdef	__cplusplus
32*6349Sqs148142 extern "C" {
33*6349Sqs148142 #endif
34*6349Sqs148142 
35*6349Sqs148142 #include <netinet/in.h>
36*6349Sqs148142 #define	 S6_addr32		_S6_un._S6_u32
37*6349Sqs148142 
38*6349Sqs148142 typedef struct tcpip4_spec_s {
39*6349Sqs148142 	in_addr_t  ip4src;
40*6349Sqs148142 	in_addr_t  ip4dst;
41*6349Sqs148142 	in_port_t  psrc;
42*6349Sqs148142 	in_port_t  pdst;
43*6349Sqs148142 } tcpip4_spec_t;
44*6349Sqs148142 
45*6349Sqs148142 typedef struct tcpip6_spec_s {
46*6349Sqs148142 	struct in6_addr ip6src;
47*6349Sqs148142 	struct in6_addr ip6dst;
48*6349Sqs148142 	in_port_t  psrc;
49*6349Sqs148142 	in_port_t  pdst;
50*6349Sqs148142 } tcpip6_spec_t;
51*6349Sqs148142 
52*6349Sqs148142 typedef struct udpip4_spec_s {
53*6349Sqs148142 	in_addr_t  ip4src;
54*6349Sqs148142 	in_addr_t  ip4dst;
55*6349Sqs148142 	in_port_t  psrc;
56*6349Sqs148142 	in_port_t  pdst;
57*6349Sqs148142 } udpip4_spec_t;
58*6349Sqs148142 
59*6349Sqs148142 typedef struct udpip6_spec_s {
60*6349Sqs148142 	struct in6_addr ip6src;
61*6349Sqs148142 	struct in6_addr ip6dst;
62*6349Sqs148142 	in_port_t  psrc;
63*6349Sqs148142 	in_port_t  pdst;
64*6349Sqs148142 } udpip6_spec_t;
65*6349Sqs148142 
66*6349Sqs148142 typedef struct ahip4_spec_s {
67*6349Sqs148142 	in_addr_t  ip4src;
68*6349Sqs148142 	in_addr_t  ip4dst;
69*6349Sqs148142 	uint32_t   spi;
70*6349Sqs148142 } ahip4_spec_t;
71*6349Sqs148142 
72*6349Sqs148142 typedef struct ahip6_spec_s {
73*6349Sqs148142 	struct in6_addr ip6src;
74*6349Sqs148142 	struct in6_addr ip6dst;
75*6349Sqs148142 	uint32_t   spi;
76*6349Sqs148142 } ahip6_spec_t;
77*6349Sqs148142 
78*6349Sqs148142 typedef ahip4_spec_t espip4_spec_t;
79*6349Sqs148142 typedef ahip6_spec_t espip6_spec_t;
80*6349Sqs148142 
81*6349Sqs148142 typedef struct rawip4_spec_s {
82*6349Sqs148142 	struct in6_addr ip4src;
83*6349Sqs148142 	struct in6_addr ip4dst;
84*6349Sqs148142 	uint8_t    hdata[64];
85*6349Sqs148142 } rawip4_spec_t;
86*6349Sqs148142 
87*6349Sqs148142 typedef struct rawip6_spec_s {
88*6349Sqs148142 	struct in6_addr ip6src;
89*6349Sqs148142 	struct in6_addr ip6dst;
90*6349Sqs148142 	uint8_t    hdata[64];
91*6349Sqs148142 } rawip6_spec_t;
92*6349Sqs148142 
93*6349Sqs148142 
94*6349Sqs148142 typedef struct ether_spec_s {
95*6349Sqs148142 	uint16_t   ether_type;
96*6349Sqs148142 	uint8_t    frame_size;
97*6349Sqs148142 	uint8_t    eframe[16];
98*6349Sqs148142 } ether_spec_t;
99*6349Sqs148142 
100*6349Sqs148142 
101*6349Sqs148142 typedef struct ip_user_spec_s {
102*6349Sqs148142 	uint8_t    id;
103*6349Sqs148142 	uint8_t    ip_ver;
104*6349Sqs148142 	uint8_t    proto;
105*6349Sqs148142 	uint8_t    tos_mask;
106*6349Sqs148142 	uint8_t    tos;
107*6349Sqs148142 } ip_user_spec_t;
108*6349Sqs148142 
109*6349Sqs148142 typedef ether_spec_t arpip_spec_t;
110*6349Sqs148142 typedef ether_spec_t ether_user_spec_t;
111*6349Sqs148142 
112*6349Sqs148142 typedef struct flow_spec_s {
113*6349Sqs148142 	uint32_t  flow_type;
114*6349Sqs148142 	union {
115*6349Sqs148142 		tcpip4_spec_t tcpip4spec;
116*6349Sqs148142 		tcpip6_spec_t tcpip6spec;
117*6349Sqs148142 		udpip4_spec_t udpip4spec;
118*6349Sqs148142 		udpip6_spec_t udpip6spec;
119*6349Sqs148142 		arpip_spec_t  arpipspec;
120*6349Sqs148142 		ahip4_spec_t  ahip4spec;
121*6349Sqs148142 		ahip6_spec_t  ahip6spec;
122*6349Sqs148142 		espip4_spec_t espip4spec;
123*6349Sqs148142 		espip6_spec_t espip6spec;
124*6349Sqs148142 		rawip4_spec_t rawip4spec;
125*6349Sqs148142 		rawip6_spec_t rawip6spec;
126*6349Sqs148142 		ether_spec_t  etherspec;
127*6349Sqs148142 		ip_user_spec_t  ip_usr_spec;
128*6349Sqs148142 		uint8_t		hdata[64];
129*6349Sqs148142 	} uh, um; /* entry, mask */
130*6349Sqs148142 } flow_spec_t;
131*6349Sqs148142 
132*6349Sqs148142 #define	FSPEC_TCPIP4	0x1	/* TCP/IPv4 Flow */
133*6349Sqs148142 #define	FSPEC_TCPIP6	0x2	/* TCP/IPv6 */
134*6349Sqs148142 #define	FSPEC_UDPIP4	0x3	/* UDP/IPv4 */
135*6349Sqs148142 #define	FSPEC_UDPIP6	0x4	/* UDP/IPv6 */
136*6349Sqs148142 #define	FSPEC_ARPIP	0x5	/* ARP/IPv4 */
137*6349Sqs148142 #define	FSPEC_AHIP4	0x6	/* AH/IP4   */
138*6349Sqs148142 #define	FSPEC_AHIP6	0x7	/* AH/IP6   */
139*6349Sqs148142 #define	FSPEC_ESPIP4	0x8	/* ESP/IP4  */
140*6349Sqs148142 #define	FSPEC_ESPIP6	0x9	/* ESP/IP6  */
141*6349Sqs148142 #define	FSPEC_SCTPIP4	0xA	/* ESP/IP4  */
142*6349Sqs148142 #define	FSPEC_SCTPIP6	0xB	/* ESP/IP6  */
143*6349Sqs148142 #define	FSPEC_RAW4	0xC	/* RAW/IP4  */
144*6349Sqs148142 #define	FSPEC_RAW6	0xD	/* RAW/IP6  */
145*6349Sqs148142 #define	FSPEC_ETHER	0xE	/* ETHER Programmable  */
146*6349Sqs148142 #define	FSPEC_IP_USR	0xF	/* IP Programmable  */
147*6349Sqs148142 #define	FSPEC_HDATA	0x10	/* Pkt Headers eth-da,sa,etype,ip,tcp(Bitmap) */
148*6349Sqs148142 
149*6349Sqs148142 
150*6349Sqs148142 #define	TCAM_IPV6_ADDR(m32, ip6addr) {		\
151*6349Sqs148142 		m32[0] = ip6addr.S6_addr32[0]; \
152*6349Sqs148142 		m32[1] = ip6addr.S6_addr32[1]; \
153*6349Sqs148142 		m32[2] = ip6addr.S6_addr32[2]; \
154*6349Sqs148142 		m32[3] = ip6addr.S6_addr32[3]; \
155*6349Sqs148142 	}
156*6349Sqs148142 
157*6349Sqs148142 
158*6349Sqs148142 #define	TCAM_IPV4_ADDR(m32, ip4addr) (m32 = ip4addr)
159*6349Sqs148142 #define	TCAM_IP_PORTS(port32, dp, sp)	  (port32 = dp | (sp << 16))
160*6349Sqs148142 #define	TCAM_IP_CLASS(key, mask, class)	  {		\
161*6349Sqs148142 		key = class; \
162*6349Sqs148142 		mask = 0x1f; \
163*6349Sqs148142 	}
164*6349Sqs148142 
165*6349Sqs148142 #define	TCAM_IP_PROTO(key, mask, proto) {		\
166*6349Sqs148142 		key = proto; \
167*6349Sqs148142 		mask = 0xff; \
168*6349Sqs148142 	}
169*6349Sqs148142 
170*6349Sqs148142 
171*6349Sqs148142 typedef struct flow_resource_s {
172*6349Sqs148142 	uint64_t	channel_cookie;
173*6349Sqs148142 	uint64_t	flow_cookie;
174*6349Sqs148142 	uint8_t		tcam_location;
175*6349Sqs148142 	flow_spec_t	flow_spec;
176*6349Sqs148142 } flow_resource_t;
177*6349Sqs148142 
178*6349Sqs148142 #ifdef	__cplusplus
179*6349Sqs148142 }
180*6349Sqs148142 #endif
181*6349Sqs148142 
182*6349Sqs148142 #endif	/* _SYS_HXGE_HXGE_FLOW_H */
183