13dec9fcdSqs /*
23dec9fcdSqs  * CDDL HEADER START
33dec9fcdSqs  *
43dec9fcdSqs  * The contents of this file are subject to the terms of the
53dec9fcdSqs  * Common Development and Distribution License (the "License").
63dec9fcdSqs  * You may not use this file except in compliance with the License.
73dec9fcdSqs  *
83dec9fcdSqs  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93dec9fcdSqs  * or http://www.opensolaris.org/os/licensing.
103dec9fcdSqs  * See the License for the specific language governing permissions
113dec9fcdSqs  * and limitations under the License.
123dec9fcdSqs  *
133dec9fcdSqs  * When distributing Covered Code, include this CDDL HEADER in each
143dec9fcdSqs  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153dec9fcdSqs  * If applicable, add the following below this CDDL HEADER, with the
163dec9fcdSqs  * fields enclosed by brackets "[]" replaced with your own identifying
173dec9fcdSqs  * information: Portions Copyright [yyyy] [name of copyright owner]
183dec9fcdSqs  *
193dec9fcdSqs  * CDDL HEADER END
203dec9fcdSqs  */
213dec9fcdSqs /*
223dec9fcdSqs  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
233dec9fcdSqs  * Use is subject to license terms.
243dec9fcdSqs  */
253dec9fcdSqs 
263dec9fcdSqs #ifndef	_SYS_HXGE_HXGE_COMMON_H
273dec9fcdSqs #define	_SYS_HXGE_HXGE_COMMON_H
283dec9fcdSqs 
293dec9fcdSqs #include <sys/types.h>
303dec9fcdSqs #include <hxge_defs.h>
313dec9fcdSqs #include <hxge_pfc.h>
323dec9fcdSqs #include <hxge_common_impl.h>
333dec9fcdSqs 
343dec9fcdSqs #ifdef	__cplusplus
353dec9fcdSqs extern "C" {
363dec9fcdSqs #endif
373dec9fcdSqs 
383dec9fcdSqs #define	HXGE_DMA_START	B_TRUE
393dec9fcdSqs #define	HXGE_DMA_STOP	B_FALSE
403dec9fcdSqs #define	HXGE_TIMER_RESO	2
413dec9fcdSqs #define	HXGE_TIMER_LDG	2
423dec9fcdSqs 
433dec9fcdSqs /*
443dec9fcdSqs  * Receive and Transmit DMA definitions
453dec9fcdSqs  */
463dec9fcdSqs #ifdef	_DMA_USES_VIRTADDR
473dec9fcdSqs #define	HXGE_DMA_BLOCK		1
483dec9fcdSqs #else
493dec9fcdSqs #define	HXGE_DMA_BLOCK		(64 * 64)
503dec9fcdSqs #endif
513dec9fcdSqs 
52*a512c5d1SQiyan Sun - Sun Microsystems - San Diego United States #define	HXGE_RBR_RBB_MIN	128
533dec9fcdSqs #define	HXGE_RBR_RBB_MAX	(64 * 128 -1)
54*a512c5d1SQiyan Sun - Sun Microsystems - San Diego United States #define	HXGE_RBR_RBB_DEFAULT	2048		/* Number of RBR Blocks */
553dec9fcdSqs #define	HXGE_RCR_MIN		(HXGE_RBR_RBB_MIN * 2)
56*a512c5d1SQiyan Sun - Sun Microsystems - San Diego United States #define	HXGE_RCR_MAX		65504			/* 2^16 - 32 */
573dec9fcdSqs 
583dec9fcdSqs #if defined(_BIG_ENDIAN)
593dec9fcdSqs #define	HXGE_RCR_DEFAULT	(HXGE_RBR_RBB_DEFAULT * 8)
603dec9fcdSqs #else /* _BIG_ENDIAN */
613dec9fcdSqs #ifdef USE_RX_BIG_BUF
623dec9fcdSqs #define	HXGE_RCR_DEFAULT	(HXGE_RBR_RBB_DEFAULT * 8)
633dec9fcdSqs #else
643dec9fcdSqs #define	HXGE_RCR_DEFAULT	(HXGE_RBR_RBB_DEFAULT * 4)
653dec9fcdSqs #endif
663dec9fcdSqs #endif /* _BIG_ENDIAN */
673dec9fcdSqs 
68*a512c5d1SQiyan Sun - Sun Microsystems - San Diego United States #define	HXGE_TX_RING_DEFAULT	2048
693dec9fcdSqs #define	HXGE_TX_RING_MAX	(64 * 128 - 1)
703dec9fcdSqs 
713dec9fcdSqs #define	RBR_BKSIZE_4K			0
723dec9fcdSqs #define	RBR_BKSIZE_8K			1
733dec9fcdSqs #define	RBR_BKSIZE_4K_BYTES		(4 * 1024)
743dec9fcdSqs 
753dec9fcdSqs #define	RBR_BUFSZ2_2K			0
763dec9fcdSqs #define	RBR_BUFSZ2_4K			1
773dec9fcdSqs #define	RBR_BUFSZ2_2K_BYTES		(2 * 1024)
783dec9fcdSqs #define	RBR_BUFSZ2_4K_BYTES		(4 * 1024)
793dec9fcdSqs 
803dec9fcdSqs #define	RBR_BUFSZ1_1K			0
813dec9fcdSqs #define	RBR_BUFSZ1_2K			1
823dec9fcdSqs #define	RBR_BUFSZ1_1K_BYTES		1024
833dec9fcdSqs #define	RBR_BUFSZ1_2K_BYTES		(2 * 1024)
843dec9fcdSqs 
853dec9fcdSqs #define	RBR_BUFSZ0_256B			0
863dec9fcdSqs #define	RBR_BUFSZ0_512B			1
873dec9fcdSqs #define	RBR_BUFSZ0_1K			2
883dec9fcdSqs #define	RBR_BUFSZ0_256_BYTES		256
893dec9fcdSqs #define	RBR_BUFSZ0_512B_BYTES		512
90*a512c5d1SQiyan Sun - Sun Microsystems - San Diego United States #define	RBR_BUFSZ0_1K_BYTES		1024
913dec9fcdSqs 
923dec9fcdSqs /*
933dec9fcdSqs  * VLAN table configuration
943dec9fcdSqs  */
953dec9fcdSqs typedef struct hxge_mv_cfg {
963dec9fcdSqs 	uint8_t		flag;			/* 0:unconfigure 1:configured */
973dec9fcdSqs } hxge_mv_cfg_t, *p_hxge_mv_cfg_t;
983dec9fcdSqs 
993dec9fcdSqs typedef struct hxge_param_map {
1003dec9fcdSqs #if defined(_BIG_ENDIAN)
1013dec9fcdSqs 	uint32_t		rsrvd2:2;	/* [30:31] rsrvd */
1023dec9fcdSqs 	uint32_t		remove:1;	/* [29] Remove */
1033dec9fcdSqs 	uint32_t		pref:1;		/* [28] preference */
1043dec9fcdSqs 	uint32_t		rsrv:4;		/* [27:24] preference */
1053dec9fcdSqs 	uint32_t		map_to:8;	/* [23:16] map to resource */
1063dec9fcdSqs 	uint32_t		param_id:16;	/* [15:0] Param ID */
1073dec9fcdSqs #else
1083dec9fcdSqs 	uint32_t		param_id:16;	/* [15:0] Param ID */
1093dec9fcdSqs 	uint32_t		map_to:8;	/* [23:16] map to resource */
1103dec9fcdSqs 	uint32_t		rsrv:4;		/* [27:24] preference */
1113dec9fcdSqs 	uint32_t		pref:1;		/* [28] preference */
1123dec9fcdSqs 	uint32_t		remove:1;	/* [29] Remove */
1133dec9fcdSqs 	uint32_t		rsrvd2:2;	/* [30:31] rsrvd */
1143dec9fcdSqs #endif
1153dec9fcdSqs } hxge_param_map_t, *p_hxge_param_map_t;
1163dec9fcdSqs 
1173dec9fcdSqs typedef struct hxge_hw_pt_cfg {
1183dec9fcdSqs 	uint32_t	start_tdc;	 /* start TDC (0 - 3)		*/
1193dec9fcdSqs 	uint32_t	max_tdcs;	 /* max TDC in sequence		*/
1203dec9fcdSqs 	uint32_t	start_rdc;	 /* start RDC (0 - 3)		*/
1213dec9fcdSqs 	uint32_t	max_rdcs;	 /* max rdc in sequence		*/
1223dec9fcdSqs 	uint32_t	rx_full_header;	 /* select the header flag	*/
1233dec9fcdSqs 	uint32_t	start_ldg;	 /* starting logical group # 	*/
1243dec9fcdSqs 	uint32_t	max_ldgs;	 /* max logical device group	*/
1253dec9fcdSqs 	uint32_t	max_ldvs;	 /* max logical devices		*/
1263dec9fcdSqs } hxge_hw_pt_cfg_t, *p_hxge_hw_pt_cfg_t;
1273dec9fcdSqs 
1283dec9fcdSqs /* per port configuration */
1293dec9fcdSqs typedef struct hxge_dma_pt_cfg {
1303dec9fcdSqs 	hxge_hw_pt_cfg_t hw_config;	/* hardware configuration 	*/
1313dec9fcdSqs 
1323dec9fcdSqs 	uint32_t	alloc_buf_size;
1333dec9fcdSqs 	uint32_t	rbr_size;
1343dec9fcdSqs 	uint32_t	rcr_size;
1353dec9fcdSqs } hxge_dma_pt_cfg_t, *p_hxge_dma_pt_cfg_t;
1363dec9fcdSqs 
1373dec9fcdSqs /* classification configuration */
1383dec9fcdSqs typedef struct hxge_class_pt_cfg {
1393dec9fcdSqs 	/* VLAN table */
1403dec9fcdSqs 	hxge_mv_cfg_t	vlan_tbl[VLAN_ID_MAX + 1];
1413dec9fcdSqs 	/* class config value */
1423dec9fcdSqs 	uint32_t	init_hash;
1433dec9fcdSqs 	uint32_t	class_cfg[TCAM_CLASS_MAX];
1443dec9fcdSqs } hxge_class_pt_cfg_t, *p_hxge_class_pt_cfg_t;
1453dec9fcdSqs 
1463dec9fcdSqs typedef struct hxge_hw_list {
1473dec9fcdSqs 	struct hxge_hw_list 	*next;
1483dec9fcdSqs 	hxge_os_mutex_t 	hxge_cfg_lock;
1493dec9fcdSqs 	hxge_os_mutex_t 	hxge_tcam_lock;
1503dec9fcdSqs 	hxge_os_mutex_t 	hxge_vlan_lock;
1513dec9fcdSqs 
1523dec9fcdSqs 	hxge_dev_info_t		*parent_devp;
1533dec9fcdSqs 	struct _hxge_t		*hxge_p;
1543dec9fcdSqs 	uint32_t		ndevs;
1553dec9fcdSqs 	uint32_t 		flags;
1563dec9fcdSqs 	uint32_t 		magic;
1573dec9fcdSqs } hxge_hw_list_t, *p_hxge_hw_list_t;
1583dec9fcdSqs 
1593dec9fcdSqs #ifdef	__cplusplus
1603dec9fcdSqs }
1613dec9fcdSqs #endif
1623dec9fcdSqs 
1633dec9fcdSqs #endif	/* _SYS_HXGE_HXGE_COMMON_H */
164