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