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_FFLP_H 273859Sml29623 #define _SYS_NXGE_NXGE_FFLP_H 283859Sml29623 293859Sml29623 #ifdef __cplusplus 303859Sml29623 extern "C" { 313859Sml29623 #endif 323859Sml29623 333859Sml29623 #include <npi_fflp.h> 343859Sml29623 353859Sml29623 #define MAX_PARTITION 8 363859Sml29623 373859Sml29623 typedef struct _fflp_errlog { 383859Sml29623 uint32_t vlan; 393859Sml29623 uint32_t tcam; 403859Sml29623 uint32_t hash_pio[MAX_PARTITION]; 413859Sml29623 uint32_t hash_lookup1; 423859Sml29623 uint32_t hash_lookup2; 433859Sml29623 } fflp_errlog_t, *p_fflp_errlog_t; 443859Sml29623 453859Sml29623 typedef struct _fflp_stats { 463859Sml29623 uint32_t tcam_entries; 473859Sml29623 uint32_t fcram_entries; 483859Sml29623 uint32_t tcam_parity_err; 493859Sml29623 uint32_t tcam_ecc_err; 503859Sml29623 uint32_t vlan_parity_err; 513859Sml29623 uint32_t hash_lookup_err; 523859Sml29623 uint32_t hash_pio_err[MAX_PARTITION]; 533859Sml29623 fflp_errlog_t errlog; 543859Sml29623 } nxge_fflp_stats_t, *p_nxge_fflp_stats_t; 553859Sml29623 563859Sml29623 /* 573859Sml29623 * The FCRAM (hash table) cosnists of 1 meg cells 583859Sml29623 * each 64 byte wide. Each cell can hold either of: 593859Sml29623 * 2 IPV4 Exact match entry (each 32 bytes) 603859Sml29623 * 1 IPV6 Exact match entry (each 56 bytes) and 613859Sml29623 * 1 Optimistic match entry (each 8 bytes) 623859Sml29623 * 8 Optimistic match entries (each 8 bytes) 633859Sml29623 * In the case IPV4 Exact match, half of the cell 643859Sml29623 * (the first or the second 32 bytes) could be used 653859Sml29623 * to hold 4 Optimistic matches 663859Sml29623 */ 673859Sml29623 683859Sml29623 #define FCRAM_CELL_EMPTY 0x00 693859Sml29623 #define FCRAM_CELL_IPV4_IPV4 0x01 703859Sml29623 #define FCRAM_CELL_IPV4_OPT 0x02 713859Sml29623 #define FCRAM_CELL_OPT_IPV4 0x04 723859Sml29623 #define FCRAM_CELL_IPV6_OPT 0x08 733859Sml29623 #define FCRAM_CELL_OPT_OPT 0x10 743859Sml29623 753859Sml29623 763859Sml29623 #define FCRAM_SUBAREA0_OCCUPIED 0x01 773859Sml29623 #define FCRAM_SUBAREA1_OCCUPIED 0x02 783859Sml29623 #define FCRAM_SUBAREA2_OCCUPIED 0x04 793859Sml29623 #define FCRAM_SUBAREA3_OCCUPIED 0x08 803859Sml29623 813859Sml29623 #define FCRAM_SUBAREA4_OCCUPIED 0x10 823859Sml29623 #define FCRAM_SUBAREA5_OCCUPIED 0x20 833859Sml29623 #define FCRAM_SUBAREA6_OCCUPIED 0x40 843859Sml29623 #define FCRAM_SUBAREA7_OCCUPIED 0x20 853859Sml29623 863859Sml29623 #define FCRAM_IPV4_SUBAREA0_OCCUPIED \ 873859Sml29623 (FCRAM_SUBAREA0_OCCUPIED | FCRAM_SUBAREA1_OCCUPIED | \ 883859Sml29623 FCRAM_SUBAREA2_OCCUPIED | FCRAM_SUBAREA3_OCCUPIED) 893859Sml29623 903859Sml29623 #define FCRAM_IPV4_SUBAREA4_OCCUPIED \ 913859Sml29623 (FCRAM_SUBAREA4_OCCUPIED | FCRAM_SUBAREA5_OCCUPIED | \ 923859Sml29623 FCRAM_SUBAREA6_OCCUPIED | FCRAM_SUBAREA7_OCCUPIED) 933859Sml29623 943859Sml29623 953859Sml29623 #define FCRAM_IPV6_SUBAREA0_OCCUPIED \ 963859Sml29623 (FCRAM_SUBAREA0_OCCUPIED | FCRAM_SUBAREA1_OCCUPIED | \ 973859Sml29623 FCRAM_SUBAREA2_OCCUPIED | FCRAM_SUBAREA3_OCCUPIED | \ 983859Sml29623 FCRAM_SUBAREA4_OCCUPIED | FCRAM_SUBAREA5_OCCUPIED | \ 993859Sml29623 FCRAM_SUBAREA6_OCCUPIED) 1003859Sml29623 1013859Sml29623 /* 1023859Sml29623 * The current occupancy state of each FCRAM cell isy 1033859Sml29623 * described by the fcram_cell_t data structure. 1043859Sml29623 * The "type" field denotes the type of entry (or combination) 1053859Sml29623 * the cell holds (FCRAM_CELL_EMPTY ...... FCRAM_CELL_OPT_OPT) 1063859Sml29623 * The "occupied" field indicates if individual 8 bytes (subareas) 1073859Sml29623 * with in the cell are occupied 1083859Sml29623 */ 1093859Sml29623 1103859Sml29623 typedef struct _fcram_cell { 1113859Sml29623 uint32_t type:8; 1123859Sml29623 uint32_t occupied:8; 1133859Sml29623 uint32_t shadow_loc:16; 1143859Sml29623 } fcram_cell_t, *p_fcram_cell_t; 1153859Sml29623 1163859Sml29623 typedef struct _fcram_parition { 1173859Sml29623 uint8_t id; 1183859Sml29623 uint8_t base; 1193859Sml29623 uint8_t mask; 1203859Sml29623 uint8_t reloc; 1213859Sml29623 uint32_t flags; 1223859Sml29623 #define HASH_PARTITION_ENABLED 1 1233859Sml29623 uint32_t offset; 1243859Sml29623 uint32_t size; 1253859Sml29623 } fcram_parition_t, *p_fcram_partition_t; 1263859Sml29623 1273859Sml29623 1283859Sml29623 typedef struct _tcam_flow_spec { 1293859Sml29623 tcam_entry_t tce; 1303859Sml29623 uint64_t flags; 1313859Sml29623 uint64_t user_info; 132*11304SJanie.Lu@Sun.COM uint8_t valid; 1333859Sml29623 } tcam_flow_spec_t, *p_tcam_flow_spec_t; 1343859Sml29623 1353859Sml29623 1363859Sml29623 /* 1373859Sml29623 * Used for configuration. 1383859Sml29623 * ndd as well nxge.conf use the following definitions 1393859Sml29623 */ 1403859Sml29623 1413859Sml29623 #define NXGE_CLASS_CONFIG_PARAMS 20 1423859Sml29623 /* Used for ip class flow key and tcam key config */ 1433859Sml29623 1443859Sml29623 #define NXGE_CLASS_TCAM_LOOKUP 0x0001 1453859Sml29623 #define NXGE_CLASS_TCAM_USE_SRC_ADDR 0x0002 1463859Sml29623 #define NXGE_CLASS_FLOW_USE_PORTNUM 0x0010 1473859Sml29623 #define NXGE_CLASS_FLOW_USE_L2DA 0x0020 1483859Sml29623 #define NXGE_CLASS_FLOW_USE_VLAN 0x0040 1493859Sml29623 #define NXGE_CLASS_FLOW_USE_PROTO 0x0080 1503859Sml29623 #define NXGE_CLASS_FLOW_USE_IPSRC 0x0100 1513859Sml29623 #define NXGE_CLASS_FLOW_USE_IPDST 0x0200 1523859Sml29623 #define NXGE_CLASS_FLOW_USE_SRC_PORT 0x0400 1533859Sml29623 #define NXGE_CLASS_FLOW_USE_DST_PORT 0x0800 1543859Sml29623 #define NXGE_CLASS_DISCARD 0x80000000 1553859Sml29623 1563859Sml29623 /* these are used for quick configs */ 1573859Sml29623 #define NXGE_CLASS_FLOW_WEB_SERVER NXGE_CLASS_FLOW_USE_IPSRC | \ 1583859Sml29623 NXGE_CLASS_FLOW_USE_SRC_PORT 1593859Sml29623 1603859Sml29623 #define NXGE_CLASS_FLOW_GEN_SERVER NXGE_CLASS_FLOW_USE_IPSRC | \ 1613859Sml29623 NXGE_CLASS_FLOW_USE_IPDST | \ 1623859Sml29623 NXGE_CLASS_FLOW_USE_SRC_PORT | \ 1633859Sml29623 NXGE_CLASS_FLOW_USE_DST_PORT | \ 1643859Sml29623 NXGE_CLASS_FLOW_USE_PROTO | \ 1653859Sml29623 NXGE_CLASS_FLOW_USE_L2DA | \ 1663859Sml29623 NXGE_CLASS_FLOW_USE_VLAN 1673859Sml29623 1683859Sml29623 /* 1693859Sml29623 * used for use classes 1703859Sml29623 */ 1713859Sml29623 1723859Sml29623 1733859Sml29623 /* Ethernet Classes */ 1743859Sml29623 #define NXGE_CLASS_CFG_ETHER_TYPE_MASK 0x0000FFFF 1753859Sml29623 #define NXGE_CLASS_CFG_ETHER_ENABLE_MASK 0x40000000 1763859Sml29623 1773859Sml29623 /* IP Classes */ 1783859Sml29623 #define NXGE_CLASS_CFG_IP_TOS_MASK 0x000000FF 1793859Sml29623 #define NXGE_CLASS_CFG_IP_TOS_SHIFT 0 1803859Sml29623 #define NXGE_CLASS_CFG_IP_TOS_MASK_MASK 0x0000FF00 1813859Sml29623 #define NXGE_CLASS_CFG_IP_TOS_MASK_SHIFT 8 1823859Sml29623 #define NXGE_CLASS_CFG_IP_PROTO_MASK 0x00FFFF00 1833859Sml29623 #define NXGE_CLASS_CFG_IP_PROTO_SHIFT 16 1843859Sml29623 1853859Sml29623 #define NXGE_CLASS_CFG_IP_IPV6_MASK 0x01000000 1863859Sml29623 #define NXGE_CLASS_CFG_IP_PARAM_MASK NXGE_CLASS_CFG_IP_TOS_MASK | \ 1873859Sml29623 NXGE_CLASS_CFG_IP_TOS_MASK_MASK | \ 1883859Sml29623 NXGE_CLASS_CFG_IP_PROTO_MASK | \ 1893859Sml29623 NXGE_CLASS_CFG_IP_IPV6_MASK 1903859Sml29623 1913859Sml29623 #define NXGE_CLASS_CFG_IP_ENABLE_MASK 0x40000000 1923859Sml29623 1933859Sml29623 typedef struct _vlan_rdcgrp_map { 1943859Sml29623 uint32_t rsrvd:8; 1953859Sml29623 uint32_t vid:16; 1963859Sml29623 uint32_t rdc_grp:8; 1973859Sml29623 } vlan_rdcgrp_map_t, *p_vlan_rdcgrp_map_t; 1983859Sml29623 1993859Sml29623 #define NXGE_INIT_VLAN_RDCG_TBL 32 2003859Sml29623 2013859Sml29623 typedef struct _nxge_classify { 2023859Sml29623 nxge_os_mutex_t tcam_lock; 2033859Sml29623 nxge_os_mutex_t fcram_lock; 2043859Sml29623 nxge_os_mutex_t hash_lock[MAX_PARTITION]; 2053859Sml29623 uint32_t tcam_size; 206*11304SJanie.Lu@Sun.COM uint32_t tcam_entry_cnt; 2073859Sml29623 uint32_t state; 2083859Sml29623 #define NXGE_FFLP_HW_RESET 0x1 2093859Sml29623 #define NXGE_FFLP_HW_INIT 0x2 2103859Sml29623 #define NXGE_FFLP_SW_INIT 0x4 2113859Sml29623 #define NXGE_FFLP_FCRAM_PART 0x80000000 2123859Sml29623 p_nxge_fflp_stats_t fflp_stats; 2133859Sml29623 214*11304SJanie.Lu@Sun.COM tcam_flow_spec_t *tcam_entries; 215*11304SJanie.Lu@Sun.COM uint8_t tcam_top; 216*11304SJanie.Lu@Sun.COM uint8_t tcam_location; 217*11304SJanie.Lu@Sun.COM uint64_t tcam_l2_prog_cls[NXGE_L2_PROG_CLS]; 218*11304SJanie.Lu@Sun.COM uint64_t tcam_l3_prog_cls[NXGE_L3_PROG_CLS]; 219*11304SJanie.Lu@Sun.COM uint64_t tcam_key[12]; 220*11304SJanie.Lu@Sun.COM uint64_t flow_key[12]; 221*11304SJanie.Lu@Sun.COM uint16_t tcam_l3_prog_cls_refcnt[NXGE_L3_PROG_CLS]; 222*11304SJanie.Lu@Sun.COM uint8_t tcam_l3_prog_cls_pid[NXGE_L3_PROG_CLS]; 2233859Sml29623 #define NXGE_FLOW_NO_SUPPORT 0x0 2243859Sml29623 #define NXGE_FLOW_USE_TCAM 0x1 2253859Sml29623 #define NXGE_FLOW_USE_FCRAM 0x2 2263859Sml29623 #define NXGE_FLOW_USE_TCAM_FCRAM 0x3 2273859Sml29623 2283859Sml29623 #define NXGE_FLOW_COMPUTE_H1 0x10 2293859Sml29623 #define NXGE_FLOW_COMPUTE_H2 0x20 2303859Sml29623 uint8_t fragment_bug; 2313859Sml29623 uint8_t fragment_bug_location; 2323859Sml29623 fcram_cell_t *hash_table; /* allocated for Neptune only */ 2333859Sml29623 fcram_parition_t partition[MAX_PARTITION]; 2343859Sml29623 } nxge_classify_t, *p_nxge_classify_t; 2353859Sml29623 2363859Sml29623 #ifdef __cplusplus 2373859Sml29623 } 2383859Sml29623 #endif 2393859Sml29623 2403859Sml29623 #endif /* _SYS_NXGE_NXGE_FFLP_H */ 241