xref: /titanic_41/usr/src/uts/common/sys/nxge/nxge_fflp.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_FFLP_H
276f45ec7bSml29623 #define	_SYS_NXGE_NXGE_FFLP_H
286f45ec7bSml29623 
296f45ec7bSml29623 #ifdef	__cplusplus
306f45ec7bSml29623 extern "C" {
316f45ec7bSml29623 #endif
326f45ec7bSml29623 
336f45ec7bSml29623 #include <npi_fflp.h>
346f45ec7bSml29623 
356f45ec7bSml29623 #define	MAX_PARTITION 8
366f45ec7bSml29623 
376f45ec7bSml29623 typedef	struct _fflp_errlog {
386f45ec7bSml29623 	uint32_t		vlan;
396f45ec7bSml29623 	uint32_t		tcam;
406f45ec7bSml29623 	uint32_t		hash_pio[MAX_PARTITION];
416f45ec7bSml29623 	uint32_t		hash_lookup1;
426f45ec7bSml29623 	uint32_t		hash_lookup2;
436f45ec7bSml29623 } fflp_errlog_t, *p_fflp_errlog_t;
446f45ec7bSml29623 
456f45ec7bSml29623 typedef struct _fflp_stats {
466f45ec7bSml29623 	uint32_t 		tcam_entries;
476f45ec7bSml29623 	uint32_t 		fcram_entries;
486f45ec7bSml29623 	uint32_t 		tcam_parity_err;
496f45ec7bSml29623 	uint32_t 		tcam_ecc_err;
506f45ec7bSml29623 	uint32_t 		vlan_parity_err;
516f45ec7bSml29623 	uint32_t 		hash_lookup_err;
526f45ec7bSml29623 	uint32_t 		hash_pio_err[MAX_PARTITION];
536f45ec7bSml29623 	fflp_errlog_t		errlog;
546f45ec7bSml29623 } nxge_fflp_stats_t, *p_nxge_fflp_stats_t;
556f45ec7bSml29623 
566f45ec7bSml29623 /*
576f45ec7bSml29623  * The FCRAM (hash table) cosnists of 1 meg cells
586f45ec7bSml29623  * each 64 byte wide. Each cell can hold either of:
596f45ec7bSml29623  * 2 IPV4 Exact match entry (each 32 bytes)
606f45ec7bSml29623  * 1 IPV6 Exact match entry (each 56 bytes) and
616f45ec7bSml29623  *    1 Optimistic match entry (each 8 bytes)
626f45ec7bSml29623  * 8 Optimistic match entries (each 8 bytes)
636f45ec7bSml29623  * In the case IPV4 Exact match, half of the cell
646f45ec7bSml29623  * (the first or the second 32 bytes) could be used
656f45ec7bSml29623  * to hold 4 Optimistic matches
666f45ec7bSml29623  */
676f45ec7bSml29623 
686f45ec7bSml29623 #define	FCRAM_CELL_EMPTY	0x00
696f45ec7bSml29623 #define	FCRAM_CELL_IPV4_IPV4	0x01
706f45ec7bSml29623 #define	FCRAM_CELL_IPV4_OPT	0x02
716f45ec7bSml29623 #define	FCRAM_CELL_OPT_IPV4	0x04
726f45ec7bSml29623 #define	FCRAM_CELL_IPV6_OPT	0x08
736f45ec7bSml29623 #define	FCRAM_CELL_OPT_OPT	0x10
746f45ec7bSml29623 
756f45ec7bSml29623 
766f45ec7bSml29623 #define	FCRAM_SUBAREA0_OCCUPIED	0x01
776f45ec7bSml29623 #define	FCRAM_SUBAREA1_OCCUPIED	0x02
786f45ec7bSml29623 #define	FCRAM_SUBAREA2_OCCUPIED	0x04
796f45ec7bSml29623 #define	FCRAM_SUBAREA3_OCCUPIED	0x08
806f45ec7bSml29623 
816f45ec7bSml29623 #define	FCRAM_SUBAREA4_OCCUPIED	0x10
826f45ec7bSml29623 #define	FCRAM_SUBAREA5_OCCUPIED	0x20
836f45ec7bSml29623 #define	FCRAM_SUBAREA6_OCCUPIED	0x40
846f45ec7bSml29623 #define	FCRAM_SUBAREA7_OCCUPIED	0x20
856f45ec7bSml29623 
866f45ec7bSml29623 #define	FCRAM_IPV4_SUBAREA0_OCCUPIED \
876f45ec7bSml29623 	(FCRAM_SUBAREA0_OCCUPIED | FCRAM_SUBAREA1_OCCUPIED | \
886f45ec7bSml29623 	FCRAM_SUBAREA2_OCCUPIED | FCRAM_SUBAREA3_OCCUPIED)
896f45ec7bSml29623 
906f45ec7bSml29623 #define	FCRAM_IPV4_SUBAREA4_OCCUPIED \
916f45ec7bSml29623 	(FCRAM_SUBAREA4_OCCUPIED | FCRAM_SUBAREA5_OCCUPIED | \
926f45ec7bSml29623 	FCRAM_SUBAREA6_OCCUPIED | FCRAM_SUBAREA7_OCCUPIED)
936f45ec7bSml29623 
946f45ec7bSml29623 
956f45ec7bSml29623 #define	FCRAM_IPV6_SUBAREA0_OCCUPIED \
966f45ec7bSml29623 	(FCRAM_SUBAREA0_OCCUPIED | FCRAM_SUBAREA1_OCCUPIED | \
976f45ec7bSml29623 	FCRAM_SUBAREA2_OCCUPIED | FCRAM_SUBAREA3_OCCUPIED | \
986f45ec7bSml29623 	FCRAM_SUBAREA4_OCCUPIED | FCRAM_SUBAREA5_OCCUPIED | \
996f45ec7bSml29623 	FCRAM_SUBAREA6_OCCUPIED)
1006f45ec7bSml29623 
1016f45ec7bSml29623 	/*
1026f45ec7bSml29623 	 * The current occupancy state of each FCRAM cell isy
1036f45ec7bSml29623 	 * described by the fcram_cell_t data structure.
1046f45ec7bSml29623 	 * The "type" field denotes the type of entry (or combination)
1056f45ec7bSml29623 	 * the cell holds (FCRAM_CELL_EMPTY ...... FCRAM_CELL_OPT_OPT)
1066f45ec7bSml29623 	 * The "occupied" field indicates if individual 8 bytes (subareas)
1076f45ec7bSml29623 	 * with in the cell are occupied
1086f45ec7bSml29623 	 */
1096f45ec7bSml29623 
1106f45ec7bSml29623 typedef struct _fcram_cell {
1116f45ec7bSml29623 	uint32_t 		type:8;
1126f45ec7bSml29623 	uint32_t 		occupied:8;
1136f45ec7bSml29623 	uint32_t 		shadow_loc:16;
1146f45ec7bSml29623 } fcram_cell_t, *p_fcram_cell_t;
1156f45ec7bSml29623 
1166f45ec7bSml29623 typedef struct _fcram_parition {
1176f45ec7bSml29623 	uint8_t 		id;
1186f45ec7bSml29623 	uint8_t 		base;
1196f45ec7bSml29623 	uint8_t 		mask;
1206f45ec7bSml29623 	uint8_t 		reloc;
1216f45ec7bSml29623 	uint32_t 		flags;
1226f45ec7bSml29623 #define	HASH_PARTITION_ENABLED 1
1236f45ec7bSml29623 	uint32_t 		offset;
1246f45ec7bSml29623 	uint32_t 		size;
1256f45ec7bSml29623 } fcram_parition_t, *p_fcram_partition_t;
1266f45ec7bSml29623 
1276f45ec7bSml29623 
1286f45ec7bSml29623 typedef struct _tcam_flow_spec {
1296f45ec7bSml29623 	tcam_entry_t tce;
1306f45ec7bSml29623 	uint64_t flags;
1316f45ec7bSml29623 	uint64_t user_info;
132*4df55fdeSJanie Lu 	uint8_t valid;
1336f45ec7bSml29623 } tcam_flow_spec_t, *p_tcam_flow_spec_t;
1346f45ec7bSml29623 
1356f45ec7bSml29623 
1366f45ec7bSml29623 /*
1376f45ec7bSml29623  * Used for configuration.
1386f45ec7bSml29623  * ndd as well nxge.conf use the following definitions
1396f45ec7bSml29623  */
1406f45ec7bSml29623 
1416f45ec7bSml29623 #define	NXGE_CLASS_CONFIG_PARAMS	20
1426f45ec7bSml29623 /* Used for ip class flow key and tcam key config */
1436f45ec7bSml29623 
1446f45ec7bSml29623 #define	NXGE_CLASS_TCAM_LOOKUP		0x0001
1456f45ec7bSml29623 #define	NXGE_CLASS_TCAM_USE_SRC_ADDR	0x0002
1466f45ec7bSml29623 #define	NXGE_CLASS_FLOW_USE_PORTNUM	0x0010
1476f45ec7bSml29623 #define	NXGE_CLASS_FLOW_USE_L2DA	0x0020
1486f45ec7bSml29623 #define	NXGE_CLASS_FLOW_USE_VLAN	0x0040
1496f45ec7bSml29623 #define	NXGE_CLASS_FLOW_USE_PROTO	0x0080
1506f45ec7bSml29623 #define	NXGE_CLASS_FLOW_USE_IPSRC	0x0100
1516f45ec7bSml29623 #define	NXGE_CLASS_FLOW_USE_IPDST	0x0200
1526f45ec7bSml29623 #define	NXGE_CLASS_FLOW_USE_SRC_PORT	0x0400
1536f45ec7bSml29623 #define	NXGE_CLASS_FLOW_USE_DST_PORT	0x0800
1546f45ec7bSml29623 #define	NXGE_CLASS_DISCARD		0x80000000
1556f45ec7bSml29623 
1566f45ec7bSml29623 /* these are used for quick configs */
1576f45ec7bSml29623 #define	NXGE_CLASS_FLOW_WEB_SERVER	NXGE_CLASS_FLOW_USE_IPSRC | \
1586f45ec7bSml29623 					NXGE_CLASS_FLOW_USE_SRC_PORT
1596f45ec7bSml29623 
1606f45ec7bSml29623 #define	NXGE_CLASS_FLOW_GEN_SERVER	NXGE_CLASS_FLOW_USE_IPSRC | \
1616f45ec7bSml29623 					NXGE_CLASS_FLOW_USE_IPDST | \
1626f45ec7bSml29623 					NXGE_CLASS_FLOW_USE_SRC_PORT |	\
1636f45ec7bSml29623 					NXGE_CLASS_FLOW_USE_DST_PORT | \
1646f45ec7bSml29623 					NXGE_CLASS_FLOW_USE_PROTO | \
1656f45ec7bSml29623 					NXGE_CLASS_FLOW_USE_L2DA | \
1666f45ec7bSml29623 					NXGE_CLASS_FLOW_USE_VLAN
1676f45ec7bSml29623 
1686f45ec7bSml29623 /*
1696f45ec7bSml29623  * used for use classes
1706f45ec7bSml29623  */
1716f45ec7bSml29623 
1726f45ec7bSml29623 
1736f45ec7bSml29623 /* Ethernet Classes */
1746f45ec7bSml29623 #define	NXGE_CLASS_CFG_ETHER_TYPE_MASK		0x0000FFFF
1756f45ec7bSml29623 #define	NXGE_CLASS_CFG_ETHER_ENABLE_MASK	0x40000000
1766f45ec7bSml29623 
1776f45ec7bSml29623 /* IP Classes */
1786f45ec7bSml29623 #define	NXGE_CLASS_CFG_IP_TOS_MASK		0x000000FF
1796f45ec7bSml29623 #define	NXGE_CLASS_CFG_IP_TOS_SHIFT		0
1806f45ec7bSml29623 #define	NXGE_CLASS_CFG_IP_TOS_MASK_MASK		0x0000FF00
1816f45ec7bSml29623 #define	NXGE_CLASS_CFG_IP_TOS_MASK_SHIFT	8
1826f45ec7bSml29623 #define	NXGE_CLASS_CFG_IP_PROTO_MASK		0x00FFFF00
1836f45ec7bSml29623 #define	NXGE_CLASS_CFG_IP_PROTO_SHIFT		16
1846f45ec7bSml29623 
1856f45ec7bSml29623 #define	NXGE_CLASS_CFG_IP_IPV6_MASK		0x01000000
1866f45ec7bSml29623 #define	NXGE_CLASS_CFG_IP_PARAM_MASK	NXGE_CLASS_CFG_IP_TOS_MASK | \
1876f45ec7bSml29623 					NXGE_CLASS_CFG_IP_TOS_MASK_MASK | \
1886f45ec7bSml29623 					NXGE_CLASS_CFG_IP_PROTO_MASK | \
1896f45ec7bSml29623 					NXGE_CLASS_CFG_IP_IPV6_MASK
1906f45ec7bSml29623 
1916f45ec7bSml29623 #define	NXGE_CLASS_CFG_IP_ENABLE_MASK		0x40000000
1926f45ec7bSml29623 
1936f45ec7bSml29623 typedef struct _vlan_rdcgrp_map {
1946f45ec7bSml29623 	uint32_t		rsrvd:8;
1956f45ec7bSml29623 	uint32_t		vid:16;
1966f45ec7bSml29623 	uint32_t		rdc_grp:8;
1976f45ec7bSml29623 }	vlan_rdcgrp_map_t, *p_vlan_rdcgrp_map_t;
1986f45ec7bSml29623 
1996f45ec7bSml29623 #define	NXGE_INIT_VLAN_RDCG_TBL	32
2006f45ec7bSml29623 
2016f45ec7bSml29623 typedef struct _nxge_classify {
2026f45ec7bSml29623 	nxge_os_mutex_t 	tcam_lock;
2036f45ec7bSml29623 	nxge_os_mutex_t		fcram_lock;
2046f45ec7bSml29623 	nxge_os_mutex_t		hash_lock[MAX_PARTITION];
2056f45ec7bSml29623 	uint32_t 		tcam_size;
206*4df55fdeSJanie Lu 	uint32_t		tcam_entry_cnt;
2076f45ec7bSml29623 	uint32_t 		state;
2086f45ec7bSml29623 #define	NXGE_FFLP_HW_RESET	0x1
2096f45ec7bSml29623 #define	NXGE_FFLP_HW_INIT	0x2
2106f45ec7bSml29623 #define	NXGE_FFLP_SW_INIT	0x4
2116f45ec7bSml29623 #define	NXGE_FFLP_FCRAM_PART	0x80000000
2126f45ec7bSml29623 	p_nxge_fflp_stats_t	fflp_stats;
2136f45ec7bSml29623 
2146f45ec7bSml29623 	tcam_flow_spec_t    	*tcam_entries;
215*4df55fdeSJanie Lu 	uint8_t			tcam_top;
2166f45ec7bSml29623 	uint8_t			tcam_location;
217*4df55fdeSJanie Lu 	uint64_t		tcam_l2_prog_cls[NXGE_L2_PROG_CLS];
218*4df55fdeSJanie Lu 	uint64_t		tcam_l3_prog_cls[NXGE_L3_PROG_CLS];
219*4df55fdeSJanie Lu 	uint64_t		tcam_key[12];
220*4df55fdeSJanie Lu 	uint64_t		flow_key[12];
221*4df55fdeSJanie Lu 	uint16_t		tcam_l3_prog_cls_refcnt[NXGE_L3_PROG_CLS];
222*4df55fdeSJanie Lu 	uint8_t			tcam_l3_prog_cls_pid[NXGE_L3_PROG_CLS];
2236f45ec7bSml29623 #define	NXGE_FLOW_NO_SUPPORT  0x0
2246f45ec7bSml29623 #define	NXGE_FLOW_USE_TCAM    0x1
2256f45ec7bSml29623 #define	NXGE_FLOW_USE_FCRAM   0x2
2266f45ec7bSml29623 #define	NXGE_FLOW_USE_TCAM_FCRAM   0x3
2276f45ec7bSml29623 
2286f45ec7bSml29623 #define	NXGE_FLOW_COMPUTE_H1   0x10
2296f45ec7bSml29623 #define	NXGE_FLOW_COMPUTE_H2   0x20
2306f45ec7bSml29623 	uint8_t	fragment_bug;
2316f45ec7bSml29623 	uint8_t	fragment_bug_location;
2326f45ec7bSml29623 	fcram_cell_t		*hash_table; /* allocated for Neptune only */
2336f45ec7bSml29623 	fcram_parition_t    partition[MAX_PARTITION];
2346f45ec7bSml29623 } nxge_classify_t, *p_nxge_classify_t;
2356f45ec7bSml29623 
2366f45ec7bSml29623 #ifdef	__cplusplus
2376f45ec7bSml29623 }
2386f45ec7bSml29623 #endif
2396f45ec7bSml29623 
2406f45ec7bSml29623 #endif	/* _SYS_NXGE_NXGE_FFLP_H */
241