13859Sml29623 /* 23859Sml29623 * CDDL HEADER START 33859Sml29623 * 43859Sml29623 * The contents of this file are subject to the terms of the 53859Sml29623 * Common Development and Distribution License (the "License"). 63859Sml29623 * You may not use this file except in compliance with the License. 73859Sml29623 * 83859Sml29623 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93859Sml29623 * or http://www.opensolaris.org/os/licensing. 103859Sml29623 * See the License for the specific language governing permissions 113859Sml29623 * and limitations under the License. 123859Sml29623 * 133859Sml29623 * When distributing Covered Code, include this CDDL HEADER in each 143859Sml29623 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153859Sml29623 * If applicable, add the following below this CDDL HEADER, with the 163859Sml29623 * fields enclosed by brackets "[]" replaced with your own identifying 173859Sml29623 * information: Portions Copyright [yyyy] [name of copyright owner] 183859Sml29623 * 193859Sml29623 * CDDL HEADER END 203859Sml29623 */ 213859Sml29623 /* 22*11304SJanie.Lu@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 233859Sml29623 * Use is subject to license terms. 243859Sml29623 */ 253859Sml29623 263859Sml29623 #ifndef _SYS_NXGE_NXGE_FLOW_H 273859Sml29623 #define _SYS_NXGE_NXGE_FLOW_H 283859Sml29623 293859Sml29623 #ifdef __cplusplus 303859Sml29623 extern "C" { 313859Sml29623 #endif 323859Sml29623 333859Sml29623 #include <netinet/in.h> 343859Sml29623 #define S6_addr32 _S6_un._S6_u32 353859Sml29623 363859Sml29623 typedef struct tcpip4_spec_s { 373859Sml29623 in_addr_t ip4src; 383859Sml29623 in_addr_t ip4dst; 393859Sml29623 in_port_t psrc; 403859Sml29623 in_port_t pdst; 41*11304SJanie.Lu@Sun.COM uint8_t tos; 423859Sml29623 } tcpip4_spec_t; 433859Sml29623 443859Sml29623 typedef struct tcpip6_spec_s { 453859Sml29623 struct in6_addr ip6src; 463859Sml29623 struct in6_addr ip6dst; 473859Sml29623 in_port_t psrc; 483859Sml29623 in_port_t pdst; 49*11304SJanie.Lu@Sun.COM uint8_t tos; 503859Sml29623 } tcpip6_spec_t; 513859Sml29623 523859Sml29623 typedef struct udpip4_spec_s { 533859Sml29623 in_addr_t ip4src; 543859Sml29623 in_addr_t ip4dst; 553859Sml29623 in_port_t psrc; 563859Sml29623 in_port_t pdst; 57*11304SJanie.Lu@Sun.COM uint8_t tos; 583859Sml29623 } udpip4_spec_t; 593859Sml29623 603859Sml29623 typedef struct udpip6_spec_s { 613859Sml29623 struct in6_addr ip6src; 623859Sml29623 struct in6_addr ip6dst; 633859Sml29623 in_port_t psrc; 643859Sml29623 in_port_t pdst; 65*11304SJanie.Lu@Sun.COM uint8_t tos; 663859Sml29623 } udpip6_spec_t; 673859Sml29623 683859Sml29623 typedef struct ahip4_spec_s { 693859Sml29623 in_addr_t ip4src; 703859Sml29623 in_addr_t ip4dst; 713859Sml29623 uint32_t spi; 72*11304SJanie.Lu@Sun.COM uint8_t tos; 733859Sml29623 } ahip4_spec_t; 743859Sml29623 753859Sml29623 typedef struct ahip6_spec_s { 763859Sml29623 struct in6_addr ip6src; 773859Sml29623 struct in6_addr ip6dst; 783859Sml29623 uint32_t spi; 79*11304SJanie.Lu@Sun.COM uint8_t tos; 803859Sml29623 } ahip6_spec_t; 813859Sml29623 823859Sml29623 typedef ahip4_spec_t espip4_spec_t; 833859Sml29623 typedef ahip6_spec_t espip6_spec_t; 843859Sml29623 853859Sml29623 typedef struct rawip4_spec_s { 863859Sml29623 struct in6_addr ip4src; 873859Sml29623 struct in6_addr ip4dst; 883859Sml29623 uint8_t hdata[64]; 893859Sml29623 } rawip4_spec_t; 903859Sml29623 913859Sml29623 typedef struct rawip6_spec_s { 923859Sml29623 struct in6_addr ip6src; 933859Sml29623 struct in6_addr ip6dst; 943859Sml29623 uint8_t hdata[64]; 953859Sml29623 } rawip6_spec_t; 963859Sml29623 973859Sml29623 983859Sml29623 typedef struct ether_spec_s { 993859Sml29623 uint16_t ether_type; 1003859Sml29623 uint8_t frame_size; 1013859Sml29623 uint8_t eframe[16]; 1023859Sml29623 } ether_spec_t; 1033859Sml29623 1043859Sml29623 105*11304SJanie.Lu@Sun.COM #define FSPEC_IP4 1 106*11304SJanie.Lu@Sun.COM #define FSPEC_IP6 2 107*11304SJanie.Lu@Sun.COM 1083859Sml29623 typedef struct ip_user_spec_s { 109*11304SJanie.Lu@Sun.COM uint32_t ip4src; 110*11304SJanie.Lu@Sun.COM uint32_t ip4dst; 111*11304SJanie.Lu@Sun.COM uint32_t l4_4_bytes; 112*11304SJanie.Lu@Sun.COM uint8_t tos; 113*11304SJanie.Lu@Sun.COM uint8_t ip_ver; 114*11304SJanie.Lu@Sun.COM uint8_t proto; 1153859Sml29623 } ip_user_spec_t; 1163859Sml29623 117*11304SJanie.Lu@Sun.COM typedef struct ip6_frag_spec_s { 118*11304SJanie.Lu@Sun.COM struct in6_addr ip6src; 119*11304SJanie.Lu@Sun.COM struct in6_addr ip6dst; 120*11304SJanie.Lu@Sun.COM uint32_t l4_4_bytes; 121*11304SJanie.Lu@Sun.COM uint8_t tos; 122*11304SJanie.Lu@Sun.COM uint8_t proto; /* should be 44 */ 123*11304SJanie.Lu@Sun.COM } ip6_frag_spec_t; 124*11304SJanie.Lu@Sun.COM 125*11304SJanie.Lu@Sun.COM 1263859Sml29623 typedef ether_spec_t arpip_spec_t; 1273859Sml29623 typedef ether_spec_t ether_user_spec_t; 1283859Sml29623 129*11304SJanie.Lu@Sun.COM struct flow_spec_s { 1303859Sml29623 uint32_t flow_type; 1313859Sml29623 union { 1323859Sml29623 tcpip4_spec_t tcpip4spec; 1333859Sml29623 tcpip6_spec_t tcpip6spec; 1343859Sml29623 udpip4_spec_t udpip4spec; 1353859Sml29623 udpip6_spec_t udpip6spec; 1363859Sml29623 arpip_spec_t arpipspec; 1373859Sml29623 ahip4_spec_t ahip4spec; 1383859Sml29623 ahip6_spec_t ahip6spec; 1393859Sml29623 espip4_spec_t espip4spec; 1403859Sml29623 espip6_spec_t espip6spec; 1413859Sml29623 rawip4_spec_t rawip4spec; 1423859Sml29623 rawip6_spec_t rawip6spec; 1433859Sml29623 ether_spec_t etherspec; 1443859Sml29623 ip_user_spec_t ip_usr_spec; 145*11304SJanie.Lu@Sun.COM ip6_frag_spec_t ip6_frag_spec; 1463859Sml29623 uint8_t hdata[64]; 1473859Sml29623 } uh, um; /* entry, mask */ 148*11304SJanie.Lu@Sun.COM } __attribute__((packed)); 149*11304SJanie.Lu@Sun.COM 150*11304SJanie.Lu@Sun.COM typedef struct flow_spec_s flow_spec_t; 1513859Sml29623 1523859Sml29623 #define FSPEC_TCPIP4 0x1 /* TCP/IPv4 Flow */ 1533859Sml29623 #define FSPEC_TCPIP6 0x2 /* TCP/IPv6 */ 1543859Sml29623 #define FSPEC_UDPIP4 0x3 /* UDP/IPv4 */ 1553859Sml29623 #define FSPEC_UDPIP6 0x4 /* UDP/IPv6 */ 1563859Sml29623 #define FSPEC_ARPIP 0x5 /* ARP/IPv4 */ 1573859Sml29623 #define FSPEC_AHIP4 0x6 /* AH/IP4 */ 1583859Sml29623 #define FSPEC_AHIP6 0x7 /* AH/IP6 */ 1593859Sml29623 #define FSPEC_ESPIP4 0x8 /* ESP/IP4 */ 1603859Sml29623 #define FSPEC_ESPIP6 0x9 /* ESP/IP6 */ 161*11304SJanie.Lu@Sun.COM #define FSPEC_SCTPIP4 0xA /* SCTP/IP4 */ 162*11304SJanie.Lu@Sun.COM #define FSPEC_SCTPIP6 0xB /* SCTP/IP6 */ 163*11304SJanie.Lu@Sun.COM #define FSPEC_IP6FRAG 0xC /* IPv6 Fragments */ 164*11304SJanie.Lu@Sun.COM #define FSPEC_RAW4 0xD /* RAW/IP4 */ 165*11304SJanie.Lu@Sun.COM #define FSPEC_RAW6 0xE /* RAW/IP6 */ 166*11304SJanie.Lu@Sun.COM #define FSPEC_ETHER 0xF /* ETHER Programmable */ 167*11304SJanie.Lu@Sun.COM #define FSPEC_IP_USR 0x10 /* IP Programmable */ 168*11304SJanie.Lu@Sun.COM #define FSPEC_HDATA 0x11 /* Pkt Headers eth-da,sa,etype,ip,tcp(Bitmap) */ 1693859Sml29623 1703859Sml29623 #define TCAM_IPV6_ADDR(m32, ip6addr) { \ 1713859Sml29623 m32[0] = ip6addr.S6_addr32[0]; \ 1723859Sml29623 m32[1] = ip6addr.S6_addr32[1]; \ 1733859Sml29623 m32[2] = ip6addr.S6_addr32[2]; \ 1743859Sml29623 m32[3] = ip6addr.S6_addr32[3]; \ 1753859Sml29623 } 1763859Sml29623 177*11304SJanie.Lu@Sun.COM #define FSPEC_IPV6_ADDR(ip6addr, m32) { \ 178*11304SJanie.Lu@Sun.COM ip6addr.S6_addr32[0] = m32[0]; \ 179*11304SJanie.Lu@Sun.COM ip6addr.S6_addr32[1] = m32[1]; \ 180*11304SJanie.Lu@Sun.COM ip6addr.S6_addr32[2] = m32[2]; \ 181*11304SJanie.Lu@Sun.COM ip6addr.S6_addr32[3] = m32[3]; \ 182*11304SJanie.Lu@Sun.COM } 183*11304SJanie.Lu@Sun.COM 1843859Sml29623 #define TCAM_IPV4_ADDR(m32, ip4addr) (m32 = ip4addr) 185*11304SJanie.Lu@Sun.COM #define FSPEC_IPV4_ADDR(ip4addr, m32) (ip4addr = m32) 186*11304SJanie.Lu@Sun.COM 1873859Sml29623 #define TCAM_IP_PORTS(port32, dp, sp) (port32 = dp | (sp << 16)) 188*11304SJanie.Lu@Sun.COM #define FSPEC_IP_PORTS(dp, sp, port32) { \ 189*11304SJanie.Lu@Sun.COM dp = port32 & 0xff; \ 190*11304SJanie.Lu@Sun.COM sp = port32 >> 16; \ 191*11304SJanie.Lu@Sun.COM } 192*11304SJanie.Lu@Sun.COM 1933859Sml29623 #define TCAM_IP_CLASS(key, mask, class) { \ 1943859Sml29623 key = class; \ 1953859Sml29623 mask = 0x1f; \ 1963859Sml29623 } 1973859Sml29623 1983859Sml29623 #define TCAM_IP_PROTO(key, mask, proto) { \ 1993859Sml29623 key = proto; \ 2003859Sml29623 mask = 0xff; \ 2013859Sml29623 } 2023859Sml29623 203*11304SJanie.Lu@Sun.COM struct flow_resource_s { 2043859Sml29623 uint64_t channel_cookie; 2053859Sml29623 uint64_t flow_cookie; 206*11304SJanie.Lu@Sun.COM uint64_t location; 2073859Sml29623 flow_spec_t flow_spec; 208*11304SJanie.Lu@Sun.COM } __attribute__((packed)); 209*11304SJanie.Lu@Sun.COM 210*11304SJanie.Lu@Sun.COM typedef struct flow_resource_s flow_resource_t; 211*11304SJanie.Lu@Sun.COM 212*11304SJanie.Lu@Sun.COM /* ioctl data structure and cmd types for configuring rx classification */ 213*11304SJanie.Lu@Sun.COM 214*11304SJanie.Lu@Sun.COM #define NXGE_RX_CLASS_GCHAN 0x01 215*11304SJanie.Lu@Sun.COM #define NXGE_RX_CLASS_GRULE_CNT 0x02 216*11304SJanie.Lu@Sun.COM #define NXGE_RX_CLASS_GRULE 0x03 217*11304SJanie.Lu@Sun.COM #define NXGE_RX_CLASS_GRULE_ALL 0x04 218*11304SJanie.Lu@Sun.COM #define NXGE_RX_CLASS_RULE_DEL 0x05 219*11304SJanie.Lu@Sun.COM #define NXGE_RX_CLASS_RULE_INS 0x06 220*11304SJanie.Lu@Sun.COM 221*11304SJanie.Lu@Sun.COM #define NXGE_PKT_DISCARD 0xffffffffffffffffULL 222*11304SJanie.Lu@Sun.COM 223*11304SJanie.Lu@Sun.COM struct rx_class_cfg_s { 224*11304SJanie.Lu@Sun.COM uint32_t cmd; 225*11304SJanie.Lu@Sun.COM uint32_t data; /* the rule DB size or the # rx rings */ 226*11304SJanie.Lu@Sun.COM uint64_t rule_cnt; 227*11304SJanie.Lu@Sun.COM uint32_t rule_locs[256]; 228*11304SJanie.Lu@Sun.COM flow_resource_t fs; 229*11304SJanie.Lu@Sun.COM } __attribute__((packed)); 230*11304SJanie.Lu@Sun.COM 231*11304SJanie.Lu@Sun.COM typedef struct rx_class_cfg_s rx_class_cfg_t; 232*11304SJanie.Lu@Sun.COM 233*11304SJanie.Lu@Sun.COM /* 234*11304SJanie.Lu@Sun.COM * ioctl data structure and cmd types for configuring rx hash 235*11304SJanie.Lu@Sun.COM * for IP tunneled traffic and symmetric mode. 236*11304SJanie.Lu@Sun.COM */ 237*11304SJanie.Lu@Sun.COM 238*11304SJanie.Lu@Sun.COM #define NXGE_IPTUN_CFG_ADD_CLS 0x07 239*11304SJanie.Lu@Sun.COM #define NXGE_IPTUN_CFG_SET_HASH 0x08 240*11304SJanie.Lu@Sun.COM #define NXGE_IPTUN_CFG_DEL_CLS 0x09 241*11304SJanie.Lu@Sun.COM #define NXGE_IPTUN_CFG_GET_CLS 0x0a 242*11304SJanie.Lu@Sun.COM #define NXGE_CLS_CFG_SET_SYM 0x0b 243*11304SJanie.Lu@Sun.COM #define NXGE_CLS_CFG_GET_SYM 0x0c 244*11304SJanie.Lu@Sun.COM 245*11304SJanie.Lu@Sun.COM #define IPTUN_PKT_IPV4 1 246*11304SJanie.Lu@Sun.COM #define IPTUN_PKT_IPV6 2 247*11304SJanie.Lu@Sun.COM #define IPTUN_PKT_GRE 3 248*11304SJanie.Lu@Sun.COM #define IPTUN_PKT_GTP 4 249*11304SJanie.Lu@Sun.COM #define OTHER_USR_PKT 5 250*11304SJanie.Lu@Sun.COM 251*11304SJanie.Lu@Sun.COM #define SEL_L4B_0_3 0x0001 252*11304SJanie.Lu@Sun.COM #define SEL_L4B_4_7 0x0002 253*11304SJanie.Lu@Sun.COM #define SEL_L4B_8_11 0x0004 254*11304SJanie.Lu@Sun.COM #define SEL_L4B_12_15 0x0008 255*11304SJanie.Lu@Sun.COM #define SEL_L4B_16_19 0x0010 256*11304SJanie.Lu@Sun.COM #define SEL_L4B_20_23 0x0020 257*11304SJanie.Lu@Sun.COM #define SEL_L4B_24_27 0x0040 258*11304SJanie.Lu@Sun.COM #define SEL_L4B_28_31 0x0080 259*11304SJanie.Lu@Sun.COM #define SEL_L4B_32_35 0x0100 260*11304SJanie.Lu@Sun.COM #define SEL_L4B_36_39 0x0200 261*11304SJanie.Lu@Sun.COM 262*11304SJanie.Lu@Sun.COM #define HASH_IFPORT 0x0001 263*11304SJanie.Lu@Sun.COM #define HASH_L2DA 0x0002 264*11304SJanie.Lu@Sun.COM #define HASH_VLAN 0x0004 265*11304SJanie.Lu@Sun.COM #define HASH_IPSA 0x0008 266*11304SJanie.Lu@Sun.COM #define HASH_IPDA 0x0010 267*11304SJanie.Lu@Sun.COM #define HASH_L3PROTO 0x0020 268*11304SJanie.Lu@Sun.COM 269*11304SJanie.Lu@Sun.COM #define CLS_TCPV4 0x08 270*11304SJanie.Lu@Sun.COM #define CLS_UDPV4 0x09 271*11304SJanie.Lu@Sun.COM #define CLS_AHESPV4 0x0A 272*11304SJanie.Lu@Sun.COM #define CLS_SCTPV4 0x0B 273*11304SJanie.Lu@Sun.COM #define CLS_TCPV6 0x0C 274*11304SJanie.Lu@Sun.COM #define CLS_UDPV6 0x0D 275*11304SJanie.Lu@Sun.COM #define CLS_AHESPV6 0x0E 276*11304SJanie.Lu@Sun.COM #define CLS_SCTPV6 0x0F 277*11304SJanie.Lu@Sun.COM #define CLS_IPV6FRAG 0x1F 278*11304SJanie.Lu@Sun.COM 279*11304SJanie.Lu@Sun.COM struct _iptun_cfg { 280*11304SJanie.Lu@Sun.COM uint8_t in_pkt_type; 281*11304SJanie.Lu@Sun.COM uint8_t l4b0_val; 282*11304SJanie.Lu@Sun.COM uint8_t l4b0_mask; 283*11304SJanie.Lu@Sun.COM uint8_t l4b23_sel; 284*11304SJanie.Lu@Sun.COM uint16_t l4b23_val; 285*11304SJanie.Lu@Sun.COM uint16_t l4xor_sel; 286*11304SJanie.Lu@Sun.COM uint8_t hash_flags; 287*11304SJanie.Lu@Sun.COM } __attribute__((packed)); 288*11304SJanie.Lu@Sun.COM 289*11304SJanie.Lu@Sun.COM typedef struct _iptun_cfg iptun_cfg_t; 290*11304SJanie.Lu@Sun.COM 291*11304SJanie.Lu@Sun.COM struct _cfg_cmd { 292*11304SJanie.Lu@Sun.COM uint16_t cmd; 293*11304SJanie.Lu@Sun.COM uint8_t sym; 294*11304SJanie.Lu@Sun.COM uint8_t class_id; 295*11304SJanie.Lu@Sun.COM iptun_cfg_t iptun_cfg; 296*11304SJanie.Lu@Sun.COM } __attribute__((packed)); 297*11304SJanie.Lu@Sun.COM 298*11304SJanie.Lu@Sun.COM typedef struct _cfg_cmd cfg_cmd_t; 2993859Sml29623 3003859Sml29623 #ifdef __cplusplus 3013859Sml29623 } 3023859Sml29623 #endif 3033859Sml29623 3043859Sml29623 #endif /* _SYS_NXGE_NXGE_FLOW_H */ 305