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