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