xref: /illumos-gate/usr/src/uts/common/io/hxge/hxge_flow.h (revision c65ebfc7045424bd04a6c7719a27b0ad3399ad54)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_HXGE_HXGE_FLOW_H
27 #define	_SYS_HXGE_HXGE_FLOW_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <netinet/in.h>
36 #define	 S6_addr32		_S6_un._S6_u32
37 
38 typedef struct tcpip4_spec_s {
39 	in_addr_t  ip4src;
40 	in_addr_t  ip4dst;
41 	in_port_t  psrc;
42 	in_port_t  pdst;
43 } tcpip4_spec_t;
44 
45 typedef struct tcpip6_spec_s {
46 	struct in6_addr ip6src;
47 	struct in6_addr ip6dst;
48 	in_port_t  psrc;
49 	in_port_t  pdst;
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 } udpip4_spec_t;
58 
59 typedef struct udpip6_spec_s {
60 	struct in6_addr ip6src;
61 	struct in6_addr ip6dst;
62 	in_port_t  psrc;
63 	in_port_t  pdst;
64 } udpip6_spec_t;
65 
66 typedef struct ahip4_spec_s {
67 	in_addr_t  ip4src;
68 	in_addr_t  ip4dst;
69 	uint32_t   spi;
70 } ahip4_spec_t;
71 
72 typedef struct ahip6_spec_s {
73 	struct in6_addr ip6src;
74 	struct in6_addr ip6dst;
75 	uint32_t   spi;
76 } ahip6_spec_t;
77 
78 typedef ahip4_spec_t espip4_spec_t;
79 typedef ahip6_spec_t espip6_spec_t;
80 
81 typedef struct rawip4_spec_s {
82 	struct in6_addr ip4src;
83 	struct in6_addr ip4dst;
84 	uint8_t    hdata[64];
85 } rawip4_spec_t;
86 
87 typedef struct rawip6_spec_s {
88 	struct in6_addr ip6src;
89 	struct in6_addr ip6dst;
90 	uint8_t    hdata[64];
91 } rawip6_spec_t;
92 
93 
94 typedef struct ether_spec_s {
95 	uint16_t   ether_type;
96 	uint8_t    frame_size;
97 	uint8_t    eframe[16];
98 } ether_spec_t;
99 
100 
101 typedef struct ip_user_spec_s {
102 	uint8_t    id;
103 	uint8_t    ip_ver;
104 	uint8_t    proto;
105 	uint8_t    tos_mask;
106 	uint8_t    tos;
107 } ip_user_spec_t;
108 
109 typedef ether_spec_t arpip_spec_t;
110 typedef ether_spec_t ether_user_spec_t;
111 
112 typedef struct flow_spec_s {
113 	uint32_t  flow_type;
114 	union {
115 		tcpip4_spec_t tcpip4spec;
116 		tcpip6_spec_t tcpip6spec;
117 		udpip4_spec_t udpip4spec;
118 		udpip6_spec_t udpip6spec;
119 		arpip_spec_t  arpipspec;
120 		ahip4_spec_t  ahip4spec;
121 		ahip6_spec_t  ahip6spec;
122 		espip4_spec_t espip4spec;
123 		espip6_spec_t espip6spec;
124 		rawip4_spec_t rawip4spec;
125 		rawip6_spec_t rawip6spec;
126 		ether_spec_t  etherspec;
127 		ip_user_spec_t  ip_usr_spec;
128 		uint8_t		hdata[64];
129 	} uh, um; /* entry, mask */
130 } flow_spec_t;
131 
132 #define	FSPEC_TCPIP4	0x1	/* TCP/IPv4 Flow */
133 #define	FSPEC_TCPIP6	0x2	/* TCP/IPv6 */
134 #define	FSPEC_UDPIP4	0x3	/* UDP/IPv4 */
135 #define	FSPEC_UDPIP6	0x4	/* UDP/IPv6 */
136 #define	FSPEC_ARPIP	0x5	/* ARP/IPv4 */
137 #define	FSPEC_AHIP4	0x6	/* AH/IP4   */
138 #define	FSPEC_AHIP6	0x7	/* AH/IP6   */
139 #define	FSPEC_ESPIP4	0x8	/* ESP/IP4  */
140 #define	FSPEC_ESPIP6	0x9	/* ESP/IP6  */
141 #define	FSPEC_SCTPIP4	0xA	/* ESP/IP4  */
142 #define	FSPEC_SCTPIP6	0xB	/* ESP/IP6  */
143 #define	FSPEC_RAW4	0xC	/* RAW/IP4  */
144 #define	FSPEC_RAW6	0xD	/* RAW/IP6  */
145 #define	FSPEC_ETHER	0xE	/* ETHER Programmable  */
146 #define	FSPEC_IP_USR	0xF	/* IP Programmable  */
147 #define	FSPEC_HDATA	0x10	/* Pkt Headers eth-da,sa,etype,ip,tcp(Bitmap) */
148 
149 
150 #define	TCAM_IPV6_ADDR(m32, ip6addr) {		\
151 		m32[0] = ip6addr.S6_addr32[0]; \
152 		m32[1] = ip6addr.S6_addr32[1]; \
153 		m32[2] = ip6addr.S6_addr32[2]; \
154 		m32[3] = ip6addr.S6_addr32[3]; \
155 	}
156 
157 
158 #define	TCAM_IPV4_ADDR(m32, ip4addr) (m32 = ip4addr)
159 #define	TCAM_IP_PORTS(port32, dp, sp)	  (port32 = dp | (sp << 16))
160 #define	TCAM_IP_CLASS(key, mask, class)	  {		\
161 		key = class; \
162 		mask = 0x1f; \
163 	}
164 
165 #define	TCAM_IP_PROTO(key, mask, proto) {		\
166 		key = proto; \
167 		mask = 0xff; \
168 	}
169 
170 
171 typedef struct flow_resource_s {
172 	uint64_t	channel_cookie;
173 	uint64_t	flow_cookie;
174 	uint8_t		tcam_location;
175 	flow_spec_t	flow_spec;
176 } flow_resource_t;
177 
178 #ifdef	__cplusplus
179 }
180 #endif
181 
182 #endif	/* _SYS_HXGE_HXGE_FLOW_H */
183