xref: /titanic_51/usr/src/uts/common/sys/nxge/nxge_flow.h (revision 4df55fde49134f9735f84011f23a767c75e393c7)
16f45ec7bSml29623 /*
26f45ec7bSml29623  * CDDL HEADER START
36f45ec7bSml29623  *
46f45ec7bSml29623  * The contents of this file are subject to the terms of the
56f45ec7bSml29623  * Common Development and Distribution License (the "License").
66f45ec7bSml29623  * You may not use this file except in compliance with the License.
76f45ec7bSml29623  *
86f45ec7bSml29623  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96f45ec7bSml29623  * or http://www.opensolaris.org/os/licensing.
106f45ec7bSml29623  * See the License for the specific language governing permissions
116f45ec7bSml29623  * and limitations under the License.
126f45ec7bSml29623  *
136f45ec7bSml29623  * When distributing Covered Code, include this CDDL HEADER in each
146f45ec7bSml29623  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156f45ec7bSml29623  * If applicable, add the following below this CDDL HEADER, with the
166f45ec7bSml29623  * fields enclosed by brackets "[]" replaced with your own identifying
176f45ec7bSml29623  * information: Portions Copyright [yyyy] [name of copyright owner]
186f45ec7bSml29623  *
196f45ec7bSml29623  * CDDL HEADER END
206f45ec7bSml29623  */
216f45ec7bSml29623 /*
22*4df55fdeSJanie Lu  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
236f45ec7bSml29623  * Use is subject to license terms.
246f45ec7bSml29623  */
256f45ec7bSml29623 
266f45ec7bSml29623 #ifndef	_SYS_NXGE_NXGE_FLOW_H
276f45ec7bSml29623 #define	_SYS_NXGE_NXGE_FLOW_H
286f45ec7bSml29623 
296f45ec7bSml29623 #ifdef	__cplusplus
306f45ec7bSml29623 extern "C" {
316f45ec7bSml29623 #endif
326f45ec7bSml29623 
336f45ec7bSml29623 #include <netinet/in.h>
346f45ec7bSml29623 #define	S6_addr32	_S6_un._S6_u32
356f45ec7bSml29623 
366f45ec7bSml29623 typedef struct tcpip4_spec_s {
376f45ec7bSml29623 	in_addr_t  ip4src;
386f45ec7bSml29623 	in_addr_t  ip4dst;
396f45ec7bSml29623 	in_port_t  psrc;
406f45ec7bSml29623 	in_port_t  pdst;
41*4df55fdeSJanie Lu 	uint8_t	   tos;
426f45ec7bSml29623 } tcpip4_spec_t;
436f45ec7bSml29623 
446f45ec7bSml29623 typedef struct tcpip6_spec_s {
456f45ec7bSml29623 	struct in6_addr ip6src;
466f45ec7bSml29623 	struct in6_addr ip6dst;
476f45ec7bSml29623 	in_port_t  psrc;
486f45ec7bSml29623 	in_port_t  pdst;
49*4df55fdeSJanie Lu 	uint8_t	   tos;
506f45ec7bSml29623 } tcpip6_spec_t;
516f45ec7bSml29623 
526f45ec7bSml29623 typedef struct udpip4_spec_s {
536f45ec7bSml29623 	in_addr_t  ip4src;
546f45ec7bSml29623 	in_addr_t  ip4dst;
556f45ec7bSml29623 	in_port_t  psrc;
566f45ec7bSml29623 	in_port_t  pdst;
57*4df55fdeSJanie Lu 	uint8_t	   tos;
586f45ec7bSml29623 } udpip4_spec_t;
596f45ec7bSml29623 
606f45ec7bSml29623 typedef struct udpip6_spec_s {
616f45ec7bSml29623 	struct in6_addr ip6src;
626f45ec7bSml29623 	struct in6_addr ip6dst;
636f45ec7bSml29623 	in_port_t  psrc;
646f45ec7bSml29623 	in_port_t  pdst;
65*4df55fdeSJanie Lu 	uint8_t	   tos;
666f45ec7bSml29623 } udpip6_spec_t;
676f45ec7bSml29623 
686f45ec7bSml29623 typedef struct ahip4_spec_s {
696f45ec7bSml29623 	in_addr_t  ip4src;
706f45ec7bSml29623 	in_addr_t  ip4dst;
716f45ec7bSml29623 	uint32_t   spi;
72*4df55fdeSJanie Lu 	uint8_t	   tos;
736f45ec7bSml29623 } ahip4_spec_t;
746f45ec7bSml29623 
756f45ec7bSml29623 typedef struct ahip6_spec_s {
766f45ec7bSml29623 	struct in6_addr ip6src;
776f45ec7bSml29623 	struct in6_addr ip6dst;
786f45ec7bSml29623 	uint32_t   spi;
79*4df55fdeSJanie Lu 	uint8_t	   tos;
806f45ec7bSml29623 } ahip6_spec_t;
816f45ec7bSml29623 
826f45ec7bSml29623 typedef ahip4_spec_t espip4_spec_t;
836f45ec7bSml29623 typedef ahip6_spec_t espip6_spec_t;
846f45ec7bSml29623 
856f45ec7bSml29623 typedef struct rawip4_spec_s {
866f45ec7bSml29623 	struct in6_addr ip4src;
876f45ec7bSml29623 	struct in6_addr ip4dst;
886f45ec7bSml29623 	uint8_t    hdata[64];
896f45ec7bSml29623 } rawip4_spec_t;
906f45ec7bSml29623 
916f45ec7bSml29623 typedef struct rawip6_spec_s {
926f45ec7bSml29623 	struct in6_addr ip6src;
936f45ec7bSml29623 	struct in6_addr ip6dst;
946f45ec7bSml29623 	uint8_t    hdata[64];
956f45ec7bSml29623 } rawip6_spec_t;
966f45ec7bSml29623 
976f45ec7bSml29623 
986f45ec7bSml29623 typedef struct ether_spec_s {
996f45ec7bSml29623 	uint16_t   ether_type;
1006f45ec7bSml29623 	uint8_t    frame_size;
1016f45ec7bSml29623 	uint8_t    eframe[16];
1026f45ec7bSml29623 } ether_spec_t;
1036f45ec7bSml29623 
1046f45ec7bSml29623 
105*4df55fdeSJanie Lu #define	FSPEC_IP4	1
106*4df55fdeSJanie Lu #define	FSPEC_IP6	2
107*4df55fdeSJanie Lu 
1086f45ec7bSml29623 typedef struct ip_user_spec_s {
109*4df55fdeSJanie Lu 	uint32_t	ip4src;
110*4df55fdeSJanie Lu 	uint32_t	ip4dst;
111*4df55fdeSJanie Lu 	uint32_t	l4_4_bytes;
112*4df55fdeSJanie Lu 	uint8_t    	tos;
1136f45ec7bSml29623 	uint8_t    	ip_ver;
1146f45ec7bSml29623 	uint8_t    	proto;
1156f45ec7bSml29623 } ip_user_spec_t;
1166f45ec7bSml29623 
117*4df55fdeSJanie Lu typedef struct ip6_frag_spec_s {
118*4df55fdeSJanie Lu 	struct in6_addr ip6src;
119*4df55fdeSJanie Lu 	struct in6_addr ip6dst;
120*4df55fdeSJanie Lu 	uint32_t	l4_4_bytes;
121*4df55fdeSJanie Lu 	uint8_t    	tos;
122*4df55fdeSJanie Lu 	uint8_t    	proto;	/* should be 44 */
123*4df55fdeSJanie Lu } ip6_frag_spec_t;
124*4df55fdeSJanie Lu 
125*4df55fdeSJanie Lu 
1266f45ec7bSml29623 typedef ether_spec_t arpip_spec_t;
1276f45ec7bSml29623 typedef ether_spec_t ether_user_spec_t;
1286f45ec7bSml29623 
129*4df55fdeSJanie Lu struct flow_spec_s {
1306f45ec7bSml29623 	uint32_t  flow_type;
1316f45ec7bSml29623 	union {
1326f45ec7bSml29623 		tcpip4_spec_t tcpip4spec;
1336f45ec7bSml29623 		tcpip6_spec_t tcpip6spec;
1346f45ec7bSml29623 		udpip4_spec_t udpip4spec;
1356f45ec7bSml29623 		udpip6_spec_t udpip6spec;
1366f45ec7bSml29623 		arpip_spec_t  arpipspec;
1376f45ec7bSml29623 		ahip4_spec_t  ahip4spec;
1386f45ec7bSml29623 		ahip6_spec_t  ahip6spec;
1396f45ec7bSml29623 		espip4_spec_t espip4spec;
1406f45ec7bSml29623 		espip6_spec_t espip6spec;
1416f45ec7bSml29623 		rawip4_spec_t rawip4spec;
1426f45ec7bSml29623 		rawip6_spec_t rawip6spec;
1436f45ec7bSml29623 		ether_spec_t  etherspec;
1446f45ec7bSml29623 		ip_user_spec_t  ip_usr_spec;
145*4df55fdeSJanie Lu 		ip6_frag_spec_t  ip6_frag_spec;
1466f45ec7bSml29623 		uint8_t		hdata[64];
1476f45ec7bSml29623 	} uh, um; /* entry, mask */
148*4df55fdeSJanie Lu } __attribute__((packed));
149*4df55fdeSJanie Lu 
150*4df55fdeSJanie Lu typedef struct flow_spec_s flow_spec_t;
1516f45ec7bSml29623 
1526f45ec7bSml29623 #define	FSPEC_TCPIP4	0x1	/* TCP/IPv4 Flow */
1536f45ec7bSml29623 #define	FSPEC_TCPIP6	0x2	/* TCP/IPv6 */
1546f45ec7bSml29623 #define	FSPEC_UDPIP4	0x3	/* UDP/IPv4 */
1556f45ec7bSml29623 #define	FSPEC_UDPIP6	0x4	/* UDP/IPv6 */
1566f45ec7bSml29623 #define	FSPEC_ARPIP	0x5	/* ARP/IPv4 */
1576f45ec7bSml29623 #define	FSPEC_AHIP4	0x6	/* AH/IP4   */
1586f45ec7bSml29623 #define	FSPEC_AHIP6	0x7	/* AH/IP6   */
1596f45ec7bSml29623 #define	FSPEC_ESPIP4	0x8	/* ESP/IP4  */
1606f45ec7bSml29623 #define	FSPEC_ESPIP6	0x9	/* ESP/IP6  */
161*4df55fdeSJanie Lu #define	FSPEC_SCTPIP4	0xA	/* SCTP/IP4  */
162*4df55fdeSJanie Lu #define	FSPEC_SCTPIP6	0xB	/* SCTP/IP6  */
163*4df55fdeSJanie Lu #define	FSPEC_IP6FRAG	0xC	/* IPv6 Fragments */
164*4df55fdeSJanie Lu #define	FSPEC_RAW4	0xD	/* RAW/IP4  */
165*4df55fdeSJanie Lu #define	FSPEC_RAW6	0xE	/* RAW/IP6  */
166*4df55fdeSJanie Lu #define	FSPEC_ETHER	0xF	/* ETHER Programmable  */
167*4df55fdeSJanie Lu #define	FSPEC_IP_USR	0x10	/* IP Programmable  */
168*4df55fdeSJanie Lu #define	FSPEC_HDATA	0x11	/* Pkt Headers eth-da,sa,etype,ip,tcp(Bitmap) */
1696f45ec7bSml29623 
1706f45ec7bSml29623 #define	TCAM_IPV6_ADDR(m32, ip6addr) {		\
1716f45ec7bSml29623 		m32[0] = ip6addr.S6_addr32[0]; \
1726f45ec7bSml29623 		m32[1] = ip6addr.S6_addr32[1]; \
1736f45ec7bSml29623 		m32[2] = ip6addr.S6_addr32[2]; \
1746f45ec7bSml29623 		m32[3] = ip6addr.S6_addr32[3]; \
1756f45ec7bSml29623 	}
1766f45ec7bSml29623 
177*4df55fdeSJanie Lu #define	FSPEC_IPV6_ADDR(ip6addr, m32) {		\
178*4df55fdeSJanie Lu 	ip6addr.S6_addr32[0] = m32[0];		\
179*4df55fdeSJanie Lu 	ip6addr.S6_addr32[1] = m32[1];		\
180*4df55fdeSJanie Lu 	ip6addr.S6_addr32[2] = m32[2];		\
181*4df55fdeSJanie Lu 	ip6addr.S6_addr32[3] = m32[3];		\
182*4df55fdeSJanie Lu }
183*4df55fdeSJanie Lu 
1846f45ec7bSml29623 #define	TCAM_IPV4_ADDR(m32, ip4addr) (m32 = ip4addr)
185*4df55fdeSJanie Lu #define	FSPEC_IPV4_ADDR(ip4addr, m32) (ip4addr = m32)
186*4df55fdeSJanie Lu 
1876f45ec7bSml29623 #define	TCAM_IP_PORTS(port32, dp, sp)	  (port32 = dp | (sp << 16))
188*4df55fdeSJanie Lu #define	FSPEC_IP_PORTS(dp, sp, port32) {	\
189*4df55fdeSJanie Lu 	dp = port32 & 0xff;			\
190*4df55fdeSJanie Lu 	sp = port32 >> 16;			\
191*4df55fdeSJanie Lu }
192*4df55fdeSJanie Lu 
1936f45ec7bSml29623 #define	TCAM_IP_CLASS(key, mask, class)	  {		\
1946f45ec7bSml29623 		key = class; \
1956f45ec7bSml29623 		mask = 0x1f; \
1966f45ec7bSml29623 	}
1976f45ec7bSml29623 
1986f45ec7bSml29623 #define	TCAM_IP_PROTO(key, mask, proto) {		\
1996f45ec7bSml29623 		key = proto; \
2006f45ec7bSml29623 		mask = 0xff; \
2016f45ec7bSml29623 	}
2026f45ec7bSml29623 
203*4df55fdeSJanie Lu struct flow_resource_s {
2046f45ec7bSml29623 	uint64_t channel_cookie;
2056f45ec7bSml29623 	uint64_t flow_cookie;
206*4df55fdeSJanie Lu 	uint64_t location;
2076f45ec7bSml29623 	flow_spec_t flow_spec;
208*4df55fdeSJanie Lu } __attribute__((packed));
209*4df55fdeSJanie Lu 
210*4df55fdeSJanie Lu typedef struct flow_resource_s flow_resource_t;
211*4df55fdeSJanie Lu 
212*4df55fdeSJanie Lu /* ioctl data structure and cmd types for configuring rx classification */
213*4df55fdeSJanie Lu 
214*4df55fdeSJanie Lu #define	NXGE_RX_CLASS_GCHAN	0x01
215*4df55fdeSJanie Lu #define	NXGE_RX_CLASS_GRULE_CNT	0x02
216*4df55fdeSJanie Lu #define	NXGE_RX_CLASS_GRULE	0x03
217*4df55fdeSJanie Lu #define	NXGE_RX_CLASS_GRULE_ALL	0x04
218*4df55fdeSJanie Lu #define	NXGE_RX_CLASS_RULE_DEL	0x05
219*4df55fdeSJanie Lu #define	NXGE_RX_CLASS_RULE_INS	0x06
220*4df55fdeSJanie Lu 
221*4df55fdeSJanie Lu #define	NXGE_PKT_DISCARD	0xffffffffffffffffULL
222*4df55fdeSJanie Lu 
223*4df55fdeSJanie Lu struct rx_class_cfg_s {
224*4df55fdeSJanie Lu 	uint32_t cmd;
225*4df55fdeSJanie Lu 	uint32_t data; /* the rule DB size or the # rx rings */
226*4df55fdeSJanie Lu 	uint64_t rule_cnt;
227*4df55fdeSJanie Lu 	uint32_t rule_locs[256];
228*4df55fdeSJanie Lu 	flow_resource_t fs;
229*4df55fdeSJanie Lu } __attribute__((packed));
230*4df55fdeSJanie Lu 
231*4df55fdeSJanie Lu typedef struct rx_class_cfg_s rx_class_cfg_t;
232*4df55fdeSJanie Lu 
233*4df55fdeSJanie Lu /*
234*4df55fdeSJanie Lu  * ioctl data structure and cmd types for configuring rx hash
235*4df55fdeSJanie Lu  * for IP tunneled traffic and symmetric mode.
236*4df55fdeSJanie Lu  */
237*4df55fdeSJanie Lu 
238*4df55fdeSJanie Lu #define	NXGE_IPTUN_CFG_ADD_CLS	0x07
239*4df55fdeSJanie Lu #define	NXGE_IPTUN_CFG_SET_HASH	0x08
240*4df55fdeSJanie Lu #define	NXGE_IPTUN_CFG_DEL_CLS	0x09
241*4df55fdeSJanie Lu #define	NXGE_IPTUN_CFG_GET_CLS	0x0a
242*4df55fdeSJanie Lu #define	NXGE_CLS_CFG_SET_SYM	0x0b
243*4df55fdeSJanie Lu #define	NXGE_CLS_CFG_GET_SYM	0x0c
244*4df55fdeSJanie Lu 
245*4df55fdeSJanie Lu #define	IPTUN_PKT_IPV4		1
246*4df55fdeSJanie Lu #define	IPTUN_PKT_IPV6		2
247*4df55fdeSJanie Lu #define	IPTUN_PKT_GRE		3
248*4df55fdeSJanie Lu #define	IPTUN_PKT_GTP		4
249*4df55fdeSJanie Lu #define	OTHER_USR_PKT		5
250*4df55fdeSJanie Lu 
251*4df55fdeSJanie Lu #define	SEL_L4B_0_3		0x0001
252*4df55fdeSJanie Lu #define	SEL_L4B_4_7		0x0002
253*4df55fdeSJanie Lu #define	SEL_L4B_8_11		0x0004
254*4df55fdeSJanie Lu #define	SEL_L4B_12_15		0x0008
255*4df55fdeSJanie Lu #define	SEL_L4B_16_19		0x0010
256*4df55fdeSJanie Lu #define	SEL_L4B_20_23		0x0020
257*4df55fdeSJanie Lu #define	SEL_L4B_24_27		0x0040
258*4df55fdeSJanie Lu #define	SEL_L4B_28_31		0x0080
259*4df55fdeSJanie Lu #define	SEL_L4B_32_35		0x0100
260*4df55fdeSJanie Lu #define	SEL_L4B_36_39		0x0200
261*4df55fdeSJanie Lu 
262*4df55fdeSJanie Lu #define	HASH_IFPORT		0x0001
263*4df55fdeSJanie Lu #define	HASH_L2DA		0x0002
264*4df55fdeSJanie Lu #define	HASH_VLAN		0x0004
265*4df55fdeSJanie Lu #define	HASH_IPSA		0x0008
266*4df55fdeSJanie Lu #define	HASH_IPDA		0x0010
267*4df55fdeSJanie Lu #define	HASH_L3PROTO		0x0020
268*4df55fdeSJanie Lu 
269*4df55fdeSJanie Lu #define	CLS_TCPV4		0x08
270*4df55fdeSJanie Lu #define	CLS_UDPV4		0x09
271*4df55fdeSJanie Lu #define	CLS_AHESPV4		0x0A
272*4df55fdeSJanie Lu #define	CLS_SCTPV4		0x0B
273*4df55fdeSJanie Lu #define	CLS_TCPV6		0x0C
274*4df55fdeSJanie Lu #define	CLS_UDPV6		0x0D
275*4df55fdeSJanie Lu #define	CLS_AHESPV6		0x0E
276*4df55fdeSJanie Lu #define	CLS_SCTPV6		0x0F
277*4df55fdeSJanie Lu #define	CLS_IPV6FRAG		0x1F
278*4df55fdeSJanie Lu 
279*4df55fdeSJanie Lu struct _iptun_cfg {
280*4df55fdeSJanie Lu 	uint8_t		in_pkt_type;
281*4df55fdeSJanie Lu 	uint8_t		l4b0_val;
282*4df55fdeSJanie Lu 	uint8_t		l4b0_mask;
283*4df55fdeSJanie Lu 	uint8_t		l4b23_sel;
284*4df55fdeSJanie Lu 	uint16_t	l4b23_val;
285*4df55fdeSJanie Lu 	uint16_t	l4xor_sel;
286*4df55fdeSJanie Lu 	uint8_t		hash_flags;
287*4df55fdeSJanie Lu } __attribute__((packed));
288*4df55fdeSJanie Lu 
289*4df55fdeSJanie Lu typedef struct _iptun_cfg iptun_cfg_t;
290*4df55fdeSJanie Lu 
291*4df55fdeSJanie Lu struct _cfg_cmd {
292*4df55fdeSJanie Lu 	uint16_t cmd;
293*4df55fdeSJanie Lu 	uint8_t sym;
294*4df55fdeSJanie Lu 	uint8_t	class_id;
295*4df55fdeSJanie Lu 	iptun_cfg_t	iptun_cfg;
296*4df55fdeSJanie Lu } __attribute__((packed));
297*4df55fdeSJanie Lu 
298*4df55fdeSJanie Lu typedef struct _cfg_cmd cfg_cmd_t;
2996f45ec7bSml29623 
3006f45ec7bSml29623 #ifdef	__cplusplus
3016f45ec7bSml29623 }
3026f45ec7bSml29623 #endif
3036f45ec7bSml29623 
3046f45ec7bSml29623 #endif	/* _SYS_NXGE_NXGE_FLOW_H */
305