xref: /onnv-gate/usr/src/uts/common/sys/nxge/nxge.h (revision 12452:80e5df69a097)
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 /*
2212103SSantwona.Behera@Sun.COM  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
233859Sml29623  */
243859Sml29623 
253859Sml29623 #ifndef	_SYS_NXGE_NXGE_H
263859Sml29623 #define	_SYS_NXGE_NXGE_H
273859Sml29623 
283859Sml29623 #ifdef	__cplusplus
293859Sml29623 extern "C" {
303859Sml29623 #endif
313859Sml29623 
323859Sml29623 #include <nxge_mac.h>
333859Sml29623 #include <nxge_ipp.h>
343859Sml29623 #include <nxge_fflp.h>
353859Sml29623 
363859Sml29623 /*
373859Sml29623  * NXGE diagnostics IOCTLS.
383859Sml29623  */
393859Sml29623 #define	NXGE_IOC		((((('N' << 8) + 'X') << 8) + 'G') << 8)
403859Sml29623 
413859Sml29623 #define	NXGE_GET64		(NXGE_IOC|1)
423859Sml29623 #define	NXGE_PUT64		(NXGE_IOC|2)
433859Sml29623 #define	NXGE_GET_TX_RING_SZ	(NXGE_IOC|3)
443859Sml29623 #define	NXGE_GET_TX_DESC	(NXGE_IOC|4)
453859Sml29623 #define	NXGE_GLOBAL_RESET	(NXGE_IOC|5)
463859Sml29623 #define	NXGE_TX_SIDE_RESET	(NXGE_IOC|6)
473859Sml29623 #define	NXGE_RX_SIDE_RESET	(NXGE_IOC|7)
483859Sml29623 #define	NXGE_RESET_MAC		(NXGE_IOC|8)
493859Sml29623 
503859Sml29623 #define	NXGE_GET_MII		(NXGE_IOC|11)
513859Sml29623 #define	NXGE_PUT_MII		(NXGE_IOC|12)
523859Sml29623 #define	NXGE_RTRACE		(NXGE_IOC|13)
533859Sml29623 #define	NXGE_RTRACE_TEST	(NXGE_IOC|20)
543859Sml29623 #define	NXGE_TX_REGS_DUMP	(NXGE_IOC|21)
553859Sml29623 #define	NXGE_RX_REGS_DUMP	(NXGE_IOC|22)
563859Sml29623 #define	NXGE_INT_REGS_DUMP	(NXGE_IOC|23)
573859Sml29623 #define	NXGE_VIR_REGS_DUMP	(NXGE_IOC|24)
583859Sml29623 #define	NXGE_VIR_INT_REGS_DUMP	(NXGE_IOC|25)
593859Sml29623 #define	NXGE_RDUMP		(NXGE_IOC|26)
603859Sml29623 #define	NXGE_RDC_GRPS_DUMP	(NXGE_IOC|27)
613859Sml29623 #define	NXGE_PIO_TEST		(NXGE_IOC|28)
623859Sml29623 
633859Sml29623 #define	NXGE_GET_TCAM		(NXGE_IOC|29)
643859Sml29623 #define	NXGE_PUT_TCAM		(NXGE_IOC|30)
653859Sml29623 #define	NXGE_INJECT_ERR		(NXGE_IOC|40)
663859Sml29623 
6711304SJanie.Lu@Sun.COM #define	NXGE_RX_CLASS		(NXGE_IOC|41)
6811304SJanie.Lu@Sun.COM #define	NXGE_RX_HASH		(NXGE_IOC|42)
6911304SJanie.Lu@Sun.COM 
703859Sml29623 #define	NXGE_OK			0
713859Sml29623 #define	NXGE_ERROR		0x40000000
723859Sml29623 #define	NXGE_DDI_FAILED		0x20000000
733859Sml29623 #define	NXGE_GET_PORT_NUM(n)	n
743859Sml29623 
753859Sml29623 /*
763859Sml29623  * Definitions for module_info.
773859Sml29623  */
783859Sml29623 #define	NXGE_IDNUM		(0)			/* module ID number */
793859Sml29623 #define	NXGE_DRIVER_NAME	"nxge"			/* module name */
803859Sml29623 
813859Sml29623 #define	NXGE_MINPSZ		(0)			/* min packet size */
823859Sml29623 #define	NXGE_MAXPSZ		(ETHERMTU)		/* max packet size */
833859Sml29623 #define	NXGE_HIWAT		(2048 * NXGE_MAXPSZ)	/* hi-water mark */
843859Sml29623 #define	NXGE_LOWAT		(1)			/* lo-water mark */
853859Sml29623 #define	NXGE_HIWAT_MAX		(192000 * NXGE_MAXPSZ)
863859Sml29623 #define	NXGE_HIWAT_MIN		(2 * NXGE_MAXPSZ)
873859Sml29623 #define	NXGE_LOWAT_MAX		(192000 * NXGE_MAXPSZ)
883859Sml29623 #define	NXGE_LOWAT_MIN		(1)
893859Sml29623 
903859Sml29623 #ifndef	D_HOTPLUG
913859Sml29623 #define	D_HOTPLUG		0x00
923859Sml29623 #endif
933859Sml29623 
943859Sml29623 #define	INIT_BUCKET_SIZE	16	/* Initial Hash Bucket Size */
953859Sml29623 
963859Sml29623 #define	NXGE_CHECK_TIMER	(5000)
973859Sml29623 
9811304SJanie.Lu@Sun.COM /* KT/NIU OBP creates a compatible property for KT */
9911304SJanie.Lu@Sun.COM #define	KT_NIU_COMPATIBLE	"SUNW,niusl-kt"
10011304SJanie.Lu@Sun.COM 
1013859Sml29623 typedef enum {
1023859Sml29623 	param_instance,
1033859Sml29623 	param_main_instance,
1043859Sml29623 	param_function_number,
1053859Sml29623 	param_partition_id,
1063859Sml29623 	param_read_write_mode,
1074185Sspeer 	param_fw_version,
1084977Sraghus 	param_port_mode,
1093859Sml29623 	param_niu_cfg_type,
1103859Sml29623 	param_tx_quick_cfg,
1113859Sml29623 	param_rx_quick_cfg,
1123859Sml29623 	param_master_cfg_enable,
1133859Sml29623 	param_master_cfg_value,
1143859Sml29623 
1153859Sml29623 	param_autoneg,
1163859Sml29623 	param_anar_10gfdx,
1173859Sml29623 	param_anar_10ghdx,
1183859Sml29623 	param_anar_1000fdx,
1193859Sml29623 	param_anar_1000hdx,
1203859Sml29623 	param_anar_100T4,
1213859Sml29623 	param_anar_100fdx,
1223859Sml29623 	param_anar_100hdx,
1233859Sml29623 	param_anar_10fdx,
1243859Sml29623 	param_anar_10hdx,
1253859Sml29623 
1263859Sml29623 	param_anar_asmpause,
1273859Sml29623 	param_anar_pause,
1283859Sml29623 	param_use_int_xcvr,
1293859Sml29623 	param_enable_ipg0,
1303859Sml29623 	param_ipg0,
1313859Sml29623 	param_ipg1,
1323859Sml29623 	param_ipg2,
1333859Sml29623 	param_txdma_weight,
1343859Sml29623 	param_txdma_channels_begin,
1353859Sml29623 
1363859Sml29623 	param_txdma_channels,
1373859Sml29623 	param_txdma_info,
1383859Sml29623 	param_rxdma_channels_begin,
1393859Sml29623 	param_rxdma_channels,
1403859Sml29623 	param_rxdma_drr_weight,
1413859Sml29623 	param_rxdma_full_header,
1423859Sml29623 	param_rxdma_info,
1433859Sml29623 	param_rxdma_rbr_size,
1443859Sml29623 	param_rxdma_rcr_size,
1453859Sml29623 	param_default_port_rdc,
1463859Sml29623 	param_rxdma_intr_time,
1473859Sml29623 	param_rxdma_intr_pkts,
1483859Sml29623 
1493859Sml29623 	param_rdc_grps_start,
1503859Sml29623 	param_rx_rdc_grps,
1513859Sml29623 	param_default_grp0_rdc,
1523859Sml29623 	param_default_grp1_rdc,
1533859Sml29623 	param_default_grp2_rdc,
1543859Sml29623 	param_default_grp3_rdc,
1553859Sml29623 	param_default_grp4_rdc,
1563859Sml29623 	param_default_grp5_rdc,
1573859Sml29623 	param_default_grp6_rdc,
1583859Sml29623 	param_default_grp7_rdc,
1593859Sml29623 
1603859Sml29623 	param_info_rdc_groups,
1613859Sml29623 	param_start_ldg,
1623859Sml29623 	param_max_ldg,
1633859Sml29623 	param_mac_2rdc_grp,
1643859Sml29623 	param_vlan_2rdc_grp,
1653859Sml29623 	param_fcram_part_cfg,
1663859Sml29623 	param_fcram_access_ratio,
1673859Sml29623 	param_tcam_access_ratio,
1683859Sml29623 	param_tcam_enable,
1693859Sml29623 	param_hash_lookup_enable,
1703859Sml29623 	param_llc_snap_enable,
1713859Sml29623 
1723859Sml29623 	param_h1_init_value,
1733859Sml29623 	param_h2_init_value,
1743859Sml29623 	param_class_cfg_ether_usr1,
1753859Sml29623 	param_class_cfg_ether_usr2,
1763859Sml29623 	param_class_cfg_ip_usr4,
1773859Sml29623 	param_class_cfg_ip_usr5,
1783859Sml29623 	param_class_cfg_ip_usr6,
1793859Sml29623 	param_class_cfg_ip_usr7,
1803859Sml29623 	param_class_opt_ip_usr4,
1813859Sml29623 	param_class_opt_ip_usr5,
1823859Sml29623 	param_class_opt_ip_usr6,
1833859Sml29623 	param_class_opt_ip_usr7,
1843859Sml29623 	param_class_opt_ipv4_tcp,
1853859Sml29623 	param_class_opt_ipv4_udp,
1863859Sml29623 	param_class_opt_ipv4_ah,
1873859Sml29623 	param_class_opt_ipv4_sctp,
1883859Sml29623 	param_class_opt_ipv6_tcp,
1893859Sml29623 	param_class_opt_ipv6_udp,
1903859Sml29623 	param_class_opt_ipv6_ah,
1913859Sml29623 	param_class_opt_ipv6_sctp,
1923859Sml29623 	param_nxge_debug_flag,
1933859Sml29623 	param_npi_debug_flag,
1943859Sml29623 	param_dump_rdc,
1953859Sml29623 	param_dump_tdc,
1963859Sml29623 	param_dump_mac_regs,
1973859Sml29623 	param_dump_ipp_regs,
1983859Sml29623 	param_dump_fflp_regs,
1993859Sml29623 	param_dump_vlan_table,
2003859Sml29623 	param_dump_rdc_table,
2013859Sml29623 	param_dump_ptrs,
2023859Sml29623 	param_end
2033859Sml29623 } nxge_param_index_t;
2043859Sml29623 
2056495Sspeer typedef enum {
2066495Sspeer 	SOLARIS_DOMAIN,
2076495Sspeer 	SOLARIS_SERVICE_DOMAIN,
2086495Sspeer 	SOLARIS_GUEST_DOMAIN,
2096495Sspeer 	LINUX_SERVICE_DOMAIN,
2106495Sspeer 	LINUX_GUEST_DOMAIN
2116495Sspeer } nxge_environs_t;
2123859Sml29623 
2133859Sml29623 /*
2143859Sml29623  * Named Dispatch Parameter Management Structure
2153859Sml29623  */
2163859Sml29623 typedef	int (*nxge_ndgetf_t)(p_nxge_t, queue_t *, MBLKP, caddr_t, cred_t *);
2173859Sml29623 typedef	int (*nxge_ndsetf_t)(p_nxge_t, queue_t *,
2183859Sml29623 	    MBLKP, char *, caddr_t, cred_t *);
2193859Sml29623 
2203859Sml29623 #define	NXGE_PARAM_READ			0x00000001ULL
2213859Sml29623 #define	NXGE_PARAM_WRITE		0x00000002ULL
2223859Sml29623 #define	NXGE_PARAM_SHARED		0x00000004ULL
2233859Sml29623 #define	NXGE_PARAM_PRIV			0x00000008ULL
2243859Sml29623 #define	NXGE_PARAM_RW			NXGE_PARAM_READ | NXGE_PARAM_WRITE
2253859Sml29623 #define	NXGE_PARAM_RWS			NXGE_PARAM_RW | NXGE_PARAM_SHARED
2263859Sml29623 #define	NXGE_PARAM_RWP			NXGE_PARAM_RW | NXGE_PARAM_PRIV
2273859Sml29623 
2283859Sml29623 #define	NXGE_PARAM_RXDMA		0x00000010ULL
2293859Sml29623 #define	NXGE_PARAM_TXDMA		0x00000020ULL
2303859Sml29623 #define	NXGE_PARAM_CLASS_GEN	0x00000040ULL
2313859Sml29623 #define	NXGE_PARAM_MAC			0x00000080ULL
2323859Sml29623 #define	NXGE_PARAM_CLASS_BIN	NXGE_PARAM_CLASS_GEN | NXGE_PARAM_BASE_BIN
2333859Sml29623 #define	NXGE_PARAM_CLASS_HEX	NXGE_PARAM_CLASS_GEN | NXGE_PARAM_BASE_HEX
2343859Sml29623 #define	NXGE_PARAM_CLASS		NXGE_PARAM_CLASS_HEX
2353859Sml29623 
2363859Sml29623 #define	NXGE_PARAM_CMPLX		0x00010000ULL
2373859Sml29623 #define	NXGE_PARAM_NDD_WR_OK		0x00020000ULL
2383859Sml29623 #define	NXGE_PARAM_INIT_ONLY		0x00040000ULL
2393859Sml29623 #define	NXGE_PARAM_INIT_CONFIG		0x00080000ULL
2403859Sml29623 
2413859Sml29623 #define	NXGE_PARAM_READ_PROP		0x00100000ULL
2423859Sml29623 #define	NXGE_PARAM_PROP_ARR32		0x00200000ULL
2433859Sml29623 #define	NXGE_PARAM_PROP_ARR64		0x00400000ULL
2443859Sml29623 #define	NXGE_PARAM_PROP_STR		0x00800000ULL
2453859Sml29623 
2463859Sml29623 #define	NXGE_PARAM_BASE_DEC		0x00000000ULL
2473859Sml29623 #define	NXGE_PARAM_BASE_BIN		0x10000000ULL
2483859Sml29623 #define	NXGE_PARAM_BASE_HEX		0x20000000ULL
2493859Sml29623 #define	NXGE_PARAM_BASE_STR		0x40000000ULL
2503859Sml29623 #define	NXGE_PARAM_DONT_SHOW		0x80000000ULL
2513859Sml29623 
2523859Sml29623 #define	NXGE_PARAM_ARRAY_CNT_MASK	0x0000ffff00000000ULL
2533859Sml29623 #define	NXGE_PARAM_ARRAY_CNT_SHIFT	32ULL
2543859Sml29623 #define	NXGE_PARAM_ARRAY_ALLOC_MASK	0xffff000000000000ULL
2553859Sml29623 #define	NXGE_PARAM_ARRAY_ALLOC_SHIFT	48ULL
2563859Sml29623 
2573859Sml29623 typedef struct _nxge_param_t {
2583859Sml29623 	int (*getf)();
2593859Sml29623 	int (*setf)();   /* null for read only */
2603859Sml29623 	uint64_t type;  /* R/W/ Common/Port/ .... */
2613859Sml29623 	uint64_t minimum;
2623859Sml29623 	uint64_t maximum;
2633859Sml29623 	uint64_t value;	/* for array params, pointer to value array */
2643859Sml29623 	uint64_t old_value; /* for array params, pointer to old_value array */
2653859Sml29623 	char   *fcode_name;
2663859Sml29623 	char   *name;
2673859Sml29623 } nxge_param_t, *p_nxge_param_t;
2683859Sml29623 
2693859Sml29623 
2706075Ssbehera /*
2716075Ssbehera  * Do not change the order of the elements of this enum as that will
2726075Ssbehera  * break the driver code.
2736075Ssbehera  */
2743859Sml29623 typedef enum {
2753859Sml29623 	nxge_lb_normal,
2763859Sml29623 	nxge_lb_ext10g,
2773859Sml29623 	nxge_lb_ext1000,
2783859Sml29623 	nxge_lb_ext100,
2793859Sml29623 	nxge_lb_ext10,
2803859Sml29623 	nxge_lb_phy10g,
2813859Sml29623 	nxge_lb_phy1000,
2823859Sml29623 	nxge_lb_phy,
2833859Sml29623 	nxge_lb_serdes10g,
2843859Sml29623 	nxge_lb_serdes1000,
2853859Sml29623 	nxge_lb_serdes,
2863859Sml29623 	nxge_lb_mac10g,
2873859Sml29623 	nxge_lb_mac1000,
2883859Sml29623 	nxge_lb_mac
2893859Sml29623 } nxge_lb_t;
2903859Sml29623 
2913859Sml29623 enum nxge_mac_state {
2923859Sml29623 	NXGE_MAC_STOPPED = 0,
2936495Sspeer 	NXGE_MAC_STARTED,
2946495Sspeer 	NXGE_MAC_STOPPING
2953859Sml29623 };
2963859Sml29623 
2973859Sml29623 /*
2983859Sml29623  * Private DLPI full dlsap address format.
2993859Sml29623  */
3003859Sml29623 typedef struct _nxge_dladdr_t {
3013859Sml29623 	ether_addr_st dl_phys;
3023859Sml29623 	uint16_t dl_sap;
3033859Sml29623 } nxge_dladdr_t, *p_nxge_dladdr_t;
3043859Sml29623 
3053859Sml29623 typedef struct _mc_addr_t {
3063859Sml29623 	ether_addr_st multcast_addr;
3073859Sml29623 	uint_t mc_addr_cnt;
3083859Sml29623 } mc_addr_t, *p_mc_addr_t;
3093859Sml29623 
3103859Sml29623 typedef struct _mc_bucket_t {
3113859Sml29623 	p_mc_addr_t addr_list;
3123859Sml29623 	uint_t list_size;
3133859Sml29623 } mc_bucket_t, *p_mc_bucket_t;
3143859Sml29623 
3153859Sml29623 typedef struct _mc_table_t {
3163859Sml29623 	p_mc_bucket_t bucket_list;
3173859Sml29623 	uint_t buckets_used;
3183859Sml29623 } mc_table_t, *p_mc_table_t;
3193859Sml29623 
3203859Sml29623 typedef struct _filter_t {
3213859Sml29623 	uint32_t all_phys_cnt;
3223859Sml29623 	uint32_t all_multicast_cnt;
3233859Sml29623 	uint32_t all_sap_cnt;
3243859Sml29623 } filter_t, *p_filter_t;
3253859Sml29623 
3268275SEric Cheng 
3273859Sml29623 typedef struct _nxge_port_stats_t {
3283859Sml29623 	/*
3293859Sml29623 	 *  Overall structure size
3303859Sml29623 	 */
3313859Sml29623 	size_t			stats_size;
3323859Sml29623 
3333859Sml29623 	/*
3343859Sml29623 	 * Link Input/Output stats
3353859Sml29623 	 */
3363859Sml29623 	uint64_t		ipackets;
3373859Sml29623 	uint64_t		ierrors;
3383859Sml29623 	uint64_t		opackets;
3393859Sml29623 	uint64_t		oerrors;
3403859Sml29623 	uint64_t		collisions;
3413859Sml29623 
3423859Sml29623 	/*
3433859Sml29623 	 * MIB II variables
3443859Sml29623 	 */
3453859Sml29623 	uint64_t		rbytes;    /* # bytes received */
3463859Sml29623 	uint64_t		obytes;    /* # bytes transmitted */
3473859Sml29623 	uint32_t		multircv;  /* # multicast packets received */
3483859Sml29623 	uint32_t		multixmt;  /* # multicast packets for xmit */
3493859Sml29623 	uint32_t		brdcstrcv; /* # broadcast packets received */
3503859Sml29623 	uint32_t		brdcstxmt; /* # broadcast packets for xmit */
3513859Sml29623 	uint32_t		norcvbuf;  /* # rcv packets discarded */
3523859Sml29623 	uint32_t		noxmtbuf;  /* # xmit packets discarded */
3533859Sml29623 
3543859Sml29623 	/*
3553859Sml29623 	 * Lets the user know the MTU currently in use by
3563859Sml29623 	 * the physical MAC port.
3573859Sml29623 	 */
3583859Sml29623 	nxge_lb_t		lb_mode;
3593859Sml29623 	uint32_t		qos_mode;
3603859Sml29623 	uint32_t		trunk_mode;
3613859Sml29623 	uint32_t		poll_mode;
3623859Sml29623 
3633859Sml29623 	/*
3643859Sml29623 	 * Tx Statistics.
3653859Sml29623 	 */
3663859Sml29623 	uint32_t		tx_inits;
3673859Sml29623 	uint32_t		tx_starts;
3683859Sml29623 	uint32_t		tx_nocanput;
3693859Sml29623 	uint32_t		tx_msgdup_fail;
3703859Sml29623 	uint32_t		tx_allocb_fail;
3713859Sml29623 	uint32_t		tx_no_desc;
3723859Sml29623 	uint32_t		tx_dma_bind_fail;
3733859Sml29623 	uint32_t		tx_uflo;
3743859Sml29623 	uint32_t		tx_hdr_pkts;
3753859Sml29623 	uint32_t		tx_ddi_pkts;
3763859Sml29623 	uint32_t		tx_dvma_pkts;
3773859Sml29623 
3783859Sml29623 	uint32_t		tx_max_pend;
3793859Sml29623 
3803859Sml29623 	/*
3813859Sml29623 	 * Rx Statistics.
3823859Sml29623 	 */
3833859Sml29623 	uint32_t		rx_inits;
3843859Sml29623 	uint32_t		rx_hdr_pkts;
3853859Sml29623 	uint32_t		rx_mtu_pkts;
3863859Sml29623 	uint32_t		rx_split_pkts;
3873859Sml29623 	uint32_t		rx_no_buf;
3883859Sml29623 	uint32_t		rx_no_comp_wb;
3893859Sml29623 	uint32_t		rx_ov_flow;
3903859Sml29623 	uint32_t		rx_len_mm;
3913859Sml29623 	uint32_t		rx_tag_err;
3923859Sml29623 	uint32_t		rx_nocanput;
3933859Sml29623 	uint32_t		rx_msgdup_fail;
3943859Sml29623 	uint32_t		rx_allocb_fail;
3953859Sml29623 
3963859Sml29623 	/*
3973859Sml29623 	 * Receive buffer management statistics.
3983859Sml29623 	 */
3993859Sml29623 	uint32_t		rx_new_pages;
4003859Sml29623 	uint32_t		rx_new_hdr_pgs;
4013859Sml29623 	uint32_t		rx_new_mtu_pgs;
4023859Sml29623 	uint32_t		rx_new_nxt_pgs;
4033859Sml29623 	uint32_t		rx_reused_pgs;
4043859Sml29623 	uint32_t		rx_hdr_drops;
4053859Sml29623 	uint32_t		rx_mtu_drops;
4063859Sml29623 	uint32_t		rx_nxt_drops;
4073859Sml29623 
4083859Sml29623 	/*
4093859Sml29623 	 * Receive flow statistics
4103859Sml29623 	 */
4113859Sml29623 	uint32_t		rx_rel_flow;
4123859Sml29623 	uint32_t		rx_rel_bit;
4133859Sml29623 
4143859Sml29623 	uint32_t		rx_pkts_dropped;
4153859Sml29623 
4163859Sml29623 	/*
4173859Sml29623 	 * PCI-E Bus Statistics.
4183859Sml29623 	 */
4193859Sml29623 	uint32_t		pci_bus_speed;
4203859Sml29623 	uint32_t		pci_err;
4213859Sml29623 	uint32_t		pci_rta_err;
4223859Sml29623 	uint32_t		pci_rma_err;
4233859Sml29623 	uint32_t		pci_parity_err;
4243859Sml29623 	uint32_t		pci_bad_ack_err;
4253859Sml29623 	uint32_t		pci_drto_err;
4263859Sml29623 	uint32_t		pci_dmawz_err;
4273859Sml29623 	uint32_t		pci_dmarz_err;
4283859Sml29623 
4293859Sml29623 	uint32_t		rx_taskq_waits;
4303859Sml29623 
4313859Sml29623 	uint32_t		tx_jumbo_pkts;
4323859Sml29623 
4333859Sml29623 	/*
4343859Sml29623 	 * Some statistics added to support bringup, these
4353859Sml29623 	 * should be removed.
4363859Sml29623 	 */
4373859Sml29623 	uint32_t		user_defined;
4383859Sml29623 } nxge_port_stats_t, *p_nxge_port_stats_t;
4393859Sml29623 
4403859Sml29623 
4413859Sml29623 typedef struct _nxge_stats_t {
4423859Sml29623 	/*
4433859Sml29623 	 *  Overall structure size
4443859Sml29623 	 */
4453859Sml29623 	size_t			stats_size;
4463859Sml29623 
4473859Sml29623 	kstat_t			*ksp;
4483859Sml29623 	kstat_t			*rdc_ksp[NXGE_MAX_RDCS];
4493859Sml29623 	kstat_t			*tdc_ksp[NXGE_MAX_TDCS];
4503859Sml29623 	kstat_t			*rdc_sys_ksp;
4513859Sml29623 	kstat_t			*fflp_ksp[1];
4523859Sml29623 	kstat_t			*ipp_ksp;
4533859Sml29623 	kstat_t			*txc_ksp;
4543859Sml29623 	kstat_t			*mac_ksp;
4553859Sml29623 	kstat_t			*zcp_ksp;
4563859Sml29623 	kstat_t			*port_ksp;
4573859Sml29623 	kstat_t			*mmac_ksp;
4583859Sml29623 
4593859Sml29623 	nxge_mac_stats_t	mac_stats;	/* Common MAC Statistics */
4603859Sml29623 	nxge_xmac_stats_t	xmac_stats;	/* XMAC Statistics */
4613859Sml29623 	nxge_bmac_stats_t	bmac_stats;	/* BMAC Statistics */
4623859Sml29623 
4633859Sml29623 	nxge_rx_ring_stats_t	rx_stats;	/* per port RX stats */
4643859Sml29623 	nxge_ipp_stats_t	ipp_stats;	/* per port IPP stats */
4653859Sml29623 	nxge_zcp_stats_t	zcp_stats;	/* per port IPP stats */
4663859Sml29623 	nxge_rx_ring_stats_t	rdc_stats[NXGE_MAX_RDCS]; /* per rdc stats */
4673859Sml29623 	nxge_rdc_sys_stats_t	rdc_sys_stats;	/* per port RDC stats */
4683859Sml29623 
4693859Sml29623 	nxge_tx_ring_stats_t	tx_stats;	/* per port TX stats */
4703859Sml29623 	nxge_txc_stats_t	txc_stats;	/* per port TX stats */
4713859Sml29623 	nxge_tx_ring_stats_t	tdc_stats[NXGE_MAX_TDCS]; /* per tdc stats */
4723859Sml29623 	nxge_fflp_stats_t	fflp_stats;	/* fflp stats */
4733859Sml29623 	nxge_port_stats_t	port_stats;	/* fflp stats */
4743859Sml29623 	nxge_mmac_stats_t	mmac_stats;	/* Multi mac. stats */
4753859Sml29623 
4763859Sml29623 } nxge_stats_t, *p_nxge_stats_t;
4773859Sml29623 
4788275SEric Cheng 
4798275SEric Cheng 
4803859Sml29623 typedef struct _nxge_intr_t {
4813859Sml29623 	boolean_t		intr_registered; /* interrupts are registered */
4823859Sml29623 	boolean_t		intr_enabled; 	/* interrupts are enabled */
4833859Sml29623 	boolean_t		niu_msi_enable;	/* debug or configurable? */
4843859Sml29623 	int			intr_types;	/* interrupt types supported */
4853859Sml29623 	int			intr_type;	/* interrupt type to add */
4863859Sml29623 	int			max_int_cnt;	/* max MSIX/INT HW supports */
4873859Sml29623 	int			start_inum;	/* start inum (in sequence?) */
4883859Sml29623 	int			msi_intx_cnt;	/* # msi/intx ints returned */
4893859Sml29623 	int			intr_added;	/* # ints actually needed */
4903859Sml29623 	int			intr_cap;	/* interrupt capabilities */
4913859Sml29623 	size_t			intr_size;	/* size of array to allocate */
4923859Sml29623 	ddi_intr_handle_t 	*htable;	/* For array of interrupts */
4933859Sml29623 	/* Add interrupt number for each interrupt vector */
4943859Sml29623 	int			pri;
4953859Sml29623 } nxge_intr_t, *p_nxge_intr_t;
4963859Sml29623 
4973859Sml29623 typedef struct _nxge_ldgv_t {
4983859Sml29623 	uint8_t			ndma_ldvs;
4993859Sml29623 	uint8_t			nldvs;
5003859Sml29623 	uint8_t			maxldgs;
5013859Sml29623 	uint8_t			maxldvs;
5023859Sml29623 	uint8_t			ldg_intrs;
5033859Sml29623 	uint32_t		tmres;
5043859Sml29623 	p_nxge_ldg_t		ldgp;
5053859Sml29623 	p_nxge_ldv_t		ldvp;
5063859Sml29623 	p_nxge_ldv_t		ldvp_syserr;
5078275SEric Cheng 	boolean_t		ldvp_syserr_alloced;
5083859Sml29623 } nxge_ldgv_t, *p_nxge_ldgv_t;
5093859Sml29623 
5106495Sspeer typedef enum {
5116495Sspeer 	NXGE_TRANSMIT_GROUP,	/* Legacy transmit group */
5126495Sspeer 	NXGE_RECEIVE_GROUP,	/* Legacy receive group */
5136495Sspeer 	NXGE_VR_GROUP,		/* Virtualization Region group */
5146495Sspeer 	EXT_TRANSMIT_GROUP,	/* External (Crossbow) transmit group */
5156495Sspeer 	EXT_RECEIVE_GROUP	/* External (Crossbow) receive group */
5166495Sspeer } nxge_grp_type_t;
5176495Sspeer 
5186495Sspeer #define	NXGE_ILLEGAL_CHANNEL	(NXGE_MAX_TDCS + 1)
5196495Sspeer 
5206495Sspeer typedef uint8_t nxge_channel_t;
5216495Sspeer 
5226495Sspeer typedef struct nxge_grp {
5236495Sspeer 	nxge_t			*nxge;
5246495Sspeer 	nxge_grp_type_t		type; /* Tx or Rx */
5256495Sspeer 
5266495Sspeer 	int			sequence; /* When it was created. */
5276495Sspeer 	int			index; /* nxge_grp_set_t.group[index] */
5286495Sspeer 
5296495Sspeer 	struct nx_dc		*dc; /* Linked list of DMA channels. */
5306495Sspeer 	size_t			count; /* A count of <dc> above. */
5316495Sspeer 
5326495Sspeer 	boolean_t		active;	/* Is it being used? */
5336495Sspeer 
5346495Sspeer 	dc_map_t		map; /* A bitmap of the channels in <dc>. */
5356495Sspeer 	nxge_channel_t		legend[NXGE_MAX_TDCS];
5366495Sspeer 
5376495Sspeer } nxge_grp_t;
5386495Sspeer 
5396495Sspeer typedef struct {
5406495Sspeer 	lg_map_t		map;
5416495Sspeer 	size_t			count;
5426495Sspeer } lg_data_t;
5436495Sspeer 
5446495Sspeer typedef struct {
5456495Sspeer 	dc_map_t		map;
5466495Sspeer 	size_t			count;
5476495Sspeer } dc_data_t;
5486495Sspeer 
5496495Sspeer #define	NXGE_DC_SET(map, channel)	map |= (1 << channel)
5506495Sspeer #define	NXGE_DC_RESET(map, channel)	map &= (~(1 << channel))
5516495Sspeer 
5528275SEric Cheng /* For now, we only support up to 8 RDC/TDC groups */
5538275SEric Cheng #define	NXGE_LOGICAL_GROUP_MAX	NXGE_MAX_RDC_GROUPS
5546495Sspeer 
5556495Sspeer typedef struct {
5566495Sspeer 	int			sequence; /* To order groups in time. */
5576495Sspeer 
5586495Sspeer 	/* These are this instance's logical groups. */
5596495Sspeer 	nxge_grp_t		*group[NXGE_LOGICAL_GROUP_MAX];
5606495Sspeer 	lg_data_t		lg;
5616495Sspeer 
5626495Sspeer 	dc_data_t		shared;	/* These DCs are being shared. */
5636495Sspeer 	dc_data_t		owned; /* These DCs belong to me. */
5646495Sspeer 	dc_data_t		dead; /* These DCs are in an error state. */
5656495Sspeer 
5666495Sspeer } nxge_grp_set_t;
5676495Sspeer 
5686495Sspeer /*
5698275SEric Cheng  * Transmit Ring Group
5708275SEric Cheng  * TX groups will be used exclusively for the purpose of Hybrid I/O.  From
5718275SEric Cheng  * the point of view of the nxge driver, the groups will be software
5728275SEric Cheng  * constructs which will be used to establish the relationship between TX
5738275SEric Cheng  * rings and shares.
5748275SEric Cheng  *
5756495Sspeer  * Receive Ring Group
5766495Sspeer  * One of the advanced virtualization features is the ability to bundle
5776495Sspeer  * multiple Receive Rings in a single group.  One or more MAC addresses may
5786495Sspeer  * be assigned to a group.  Incoming packets destined to the group's MAC
5796495Sspeer  * address(es) are delivered to any ring member, according to a programmable
5806495Sspeer  * or predefined RTS policy.  Member rings can be polled individually.
5816495Sspeer  * RX ring groups can come with a predefined set of member rings, or they
5826495Sspeer  * are programmable by adding and removing rings to/from them.
5836495Sspeer  */
5848275SEric Cheng typedef struct _nxge_ring_group_t {
5856495Sspeer 	mac_group_handle_t	ghandle;
5866495Sspeer 	p_nxge_t		nxgep;
5878275SEric Cheng 	boolean_t		started;
5888597SMichael.Speer@Sun.COM 	boolean_t		port_default_grp;
5898275SEric Cheng 	mac_ring_type_t		type;
5906495Sspeer 	int			gindex;
5916495Sspeer 	int			sindex;
5928275SEric Cheng 	int			rdctbl;
5938275SEric Cheng 	int			n_mac_addrs;
5948275SEric Cheng } nxge_ring_group_t;
5956495Sspeer 
5966495Sspeer /*
5976495Sspeer  * Ring Handle
5986495Sspeer  */
5996495Sspeer typedef struct _nxge_ring_handle_t {
6006495Sspeer 	p_nxge_t		nxgep;
6016495Sspeer 	int			index;		/* port-wise */
6026495Sspeer 	mac_ring_handle_t	ring_handle;
60311878SVenu.Iyer@Sun.COM 	uint64_t		ring_gen_num;	/* For RX Ring Start */
60411878SVenu.Iyer@Sun.COM 	uint32_t		channel;
6058275SEric Cheng } nxge_ring_handle_t, *p_nxge_ring_handle_t;
6066495Sspeer 
6076495Sspeer /*
6086495Sspeer  * Share Handle
6096495Sspeer  */
6106495Sspeer typedef struct _nxge_share_handle_t {
6116495Sspeer 	p_nxge_t		nxgep;		/* Driver Handle */
6126495Sspeer 	int			index;
6136495Sspeer 	void			*vrp;
6146495Sspeer 	uint64_t		tmap;
6156495Sspeer 	uint64_t		rmap;
6166495Sspeer 	int			rxgroup;
6176495Sspeer 	boolean_t		active;
6186495Sspeer } nxge_share_handle_t;
6196495Sspeer 
6203859Sml29623 /*
6213859Sml29623  * Neptune Device instance state information.
6223859Sml29623  *
6233859Sml29623  * Each instance is dynamically allocated on first attach.
6243859Sml29623  */
6253859Sml29623 struct _nxge_t {
6263859Sml29623 	dev_info_t		*dip;		/* device instance */
6273859Sml29623 	dev_info_t		*p_dip;		/* Parent's device instance */
6283859Sml29623 	int			instance;	/* instance number */
6293859Sml29623 	int			function_num;	/* device function number */
6303859Sml29623 	int			nports;		/* # of ports on this device */
6313859Sml29623 	int			board_ver;	/* Board Version */
6323859Sml29623 	int			use_partition;	/* partition is enabled */
6333859Sml29623 	uint32_t		drv_state;	/* driver state bit flags */
6343859Sml29623 	uint64_t		nxge_debug_level; /* driver state bit flags */
6353859Sml29623 	kmutex_t		genlock[1];
6363859Sml29623 	enum nxge_mac_state	nxge_mac_state;
6373859Sml29623 
6383859Sml29623 	p_dev_regs_t		dev_regs;
6393859Sml29623 	npi_handle_t		npi_handle;
6403859Sml29623 	npi_handle_t		npi_pci_handle;
6413859Sml29623 	npi_handle_t		npi_reg_handle;
6423859Sml29623 	npi_handle_t		npi_msi_handle;
6433859Sml29623 	npi_handle_t		npi_vreg_handle;
6443859Sml29623 	npi_handle_t		npi_v2reg_handle;
6453859Sml29623 
6464732Sdavemq 	nxge_xcvr_table_t	xcvr;
6475572Ssbehera 	boolean_t		hot_swappable_phy;
6485572Ssbehera 	boolean_t		phy_absent;
6495572Ssbehera 	uint32_t		xcvr_addr;
6505572Ssbehera 	uint16_t		chip_id;
65112103SSantwona.Behera@Sun.COM 	nxge_nlp_conn_t		nlp_conn;
652*12452SSantwona.Behera@oracle.COM 	nxge_phy_prop_t		phy_prop;
653*12452SSantwona.Behera@oracle.COM 	nxge_serdes_prop_t	srds_prop;
65412103SSantwona.Behera@Sun.COM 
6553859Sml29623 	nxge_mac_t		mac;
6563859Sml29623 	nxge_ipp_t		ipp;
6573859Sml29623 	nxge_txc_t		txc;
6583859Sml29623 	nxge_classify_t		classifier;
6593859Sml29623 
6603859Sml29623 	mac_handle_t		mach;	/* mac module handle */
6613859Sml29623 	p_nxge_stats_t		statsp;
6623859Sml29623 	uint32_t		param_count;
6633859Sml29623 	p_nxge_param_t		param_arr;
6646439Sml29623 
6656439Sml29623 	uint32_t		param_en_pause:1,
6666439Sml29623 				param_en_asym_pause:1,
6676439Sml29623 				param_en_1000fdx:1,
6686439Sml29623 				param_en_100fdx:1,
6696439Sml29623 				param_en_10fdx:1,
6706439Sml29623 				param_pad_to_32:27;
6716439Sml29623 
6723859Sml29623 	nxge_hw_list_t		*nxge_hw_p; 	/* pointer to per Neptune */
6733859Sml29623 	niu_type_t		niu_type;
6744977Sraghus 	platform_type_t		platform_type;
6753859Sml29623 	boolean_t		os_addr_mode32;	/* set to 1 for 32 bit mode */
6766495Sspeer 
6773859Sml29623 	uint8_t			def_rdc;
6783859Sml29623 
6793859Sml29623 	nxge_intr_t		nxge_intr_type;
6803859Sml29623 	nxge_dma_pt_cfg_t 	pt_config;
6813859Sml29623 	nxge_class_pt_cfg_t 	class_config;
6823859Sml29623 
6833859Sml29623 	/* Logical device and group data structures. */
6843859Sml29623 	p_nxge_ldgv_t		ldgvp;
6853859Sml29623 
6864185Sspeer 	npi_vpd_info_t		vpd_info;
6873859Sml29623 
6883859Sml29623 	ether_addr_st		factaddr;	/* factory mac address	    */
6893859Sml29623 	ether_addr_st		ouraddr;	/* individual address	    */
6908597SMichael.Speer@Sun.COM 	boolean_t		primary;	/* primary addr set?.	    */
6913859Sml29623 	kmutex_t		ouraddr_lock;	/* lock to protect to uradd */
6923859Sml29623 
6933859Sml29623 	ddi_iblock_cookie_t	interrupt_cookie;
6943859Sml29623 
6953859Sml29623 	/*
6963859Sml29623 	 * Blocks of memory may be pre-allocated by the
6973859Sml29623 	 * partition manager or the driver. They may include
6983859Sml29623 	 * blocks for configuration and buffers. The idea is
6993859Sml29623 	 * to preallocate big blocks of contiguous areas in
7003859Sml29623 	 * system memory (i.e. with IOMMU). These blocks then
7013859Sml29623 	 * will be broken up to a fixed number of blocks with
7023859Sml29623 	 * each block having the same block size (4K, 8K, 16K or
7033859Sml29623 	 * 32K) in the case of buffer blocks. For systems that
7043859Sml29623 	 * do not support DVMA, more than one big block will be
7053859Sml29623 	 * allocated.
7063859Sml29623 	 */
7073859Sml29623 	uint32_t		rx_default_block_size;
7083859Sml29623 	nxge_rx_block_size_t	rx_bksize_code;
7093859Sml29623 
7103859Sml29623 	p_nxge_dma_pool_t	rx_buf_pool_p;
7113859Sml29623 	p_nxge_dma_pool_t	rx_cntl_pool_p;
7123859Sml29623 
7133859Sml29623 	p_nxge_dma_pool_t	tx_buf_pool_p;
7143859Sml29623 	p_nxge_dma_pool_t	tx_cntl_pool_p;
7153859Sml29623 
7163859Sml29623 	/* Receive buffer block ring and completion ring. */
7173859Sml29623 	p_rx_rbr_rings_t 	rx_rbr_rings;
7183859Sml29623 	p_rx_rcr_rings_t 	rx_rcr_rings;
7193859Sml29623 	p_rx_mbox_areas_t 	rx_mbox_areas_p;
7203859Sml29623 
7213859Sml29623 	uint32_t		rdc_mask;
7223859Sml29623 
7233859Sml29623 	/* Transmit descriptors rings */
7243859Sml29623 	p_tx_rings_t 		tx_rings;
7253859Sml29623 	p_tx_mbox_areas_t	tx_mbox_areas_p;
7263859Sml29623 
7273859Sml29623 	ddi_dma_handle_t 	dmasparehandle;
7283859Sml29623 
7293859Sml29623 	ulong_t 		sys_page_sz;
7303859Sml29623 	ulong_t 		sys_page_mask;
7313859Sml29623 	int 			suspended;
7323859Sml29623 
7333859Sml29623 	mii_bmsr_t 		bmsr;		/* xcvr status at last poll. */
7343859Sml29623 	mii_bmsr_t 		soft_bmsr;	/* xcvr status kept by SW. */
7353859Sml29623 
7363859Sml29623 	kmutex_t 		mif_lock;	/* Lock to protect the list. */
7373859Sml29623 
7383859Sml29623 	void 			(*mii_read)();
7393859Sml29623 	void 			(*mii_write)();
7403859Sml29623 	void 			(*mii_poll)();
7413859Sml29623 	filter_t 		filter;		/* Current instance filter */
7423859Sml29623 	p_hash_filter_t 	hash_filter;	/* Multicast hash filter. */
7433859Sml29623 	krwlock_t		filter_lock;	/* Lock to protect filters. */
7443859Sml29623 
7453859Sml29623 	ulong_t 		sys_burst_sz;
7463859Sml29623 
7473859Sml29623 	uint8_t 		cache_line;
7483859Sml29623 
7493859Sml29623 	timeout_id_t 		nxge_link_poll_timerid;
7503859Sml29623 	timeout_id_t 		nxge_timerid;
7513859Sml29623 
7523859Sml29623 	uint_t 			need_periodic_reclaim;
7533859Sml29623 	timeout_id_t 		reclaim_timer;
7543859Sml29623 
7553859Sml29623 	uint8_t 		msg_min;
7563859Sml29623 	uint8_t 		crc_size;
7573859Sml29623 
7583859Sml29623 	boolean_t 		hard_props_read;
7593859Sml29623 
7603859Sml29623 	uint32_t 		nxge_ncpus;
7613859Sml29623 	uint16_t 		intr_timeout;
7623859Sml29623 	uint16_t 		intr_threshold;
7633859Sml29623 
7643859Sml29623 	int			fm_capabilities; /* FMA capabilities */
7653859Sml29623 
7663859Sml29623 	uint32_t 		nxge_port_rbr_size;
7676495Sspeer 	uint32_t 		nxge_port_rbr_spare_size;
7683859Sml29623 	uint32_t 		nxge_port_rcr_size;
7696495Sspeer 	uint32_t		nxge_port_rx_cntl_alloc_size;
7703859Sml29623 	uint32_t 		nxge_port_tx_ring_size;
7713859Sml29623 	nxge_mmac_t		nxge_mmac_info;
7723859Sml29623 #if	defined(sun4v)
7733859Sml29623 	boolean_t		niu_hsvc_available;
7743859Sml29623 	hsvc_info_t		niu_hsvc;
7753859Sml29623 	uint64_t		niu_min_ver;
7763859Sml29623 #endif
7773859Sml29623 	boolean_t		link_notify;
77811409Stc99174@train 	int			link_check_count;
7794693Stm144005 
7804693Stm144005 	kmutex_t		poll_lock;
7814693Stm144005 	kcondvar_t		poll_cv;
7824693Stm144005 	link_mon_enable_t	poll_state;
7834693Stm144005 #define	NXGE_MAGIC		0x3ab434e3
7844693Stm144005 	uint32_t		nxge_magic;
7856003Sml29623 
7866003Sml29623 	int			soft_lso_enable;
7876495Sspeer 	/* The following fields are LDOMs-specific additions. */
7886495Sspeer 	nxge_environs_t		environs;
7896495Sspeer 	ether_addr_t		hio_mac_addr;
7906495Sspeer 	uint32_t		niu_cfg_hdl;
7916495Sspeer 	kmutex_t		group_lock;
7926495Sspeer 
7936495Sspeer 	struct nxge_hio_vr	*hio_vr;
7946495Sspeer 
7956495Sspeer 	nxge_grp_set_t		rx_set;
7966495Sspeer 	nxge_grp_set_t		tx_set;
7977812SMichael.Speer@Sun.COM 	boolean_t		tdc_is_shared[NXGE_MAX_TDCS];
7986495Sspeer 
7998275SEric Cheng 	/* Ring Handles */
8008275SEric Cheng 	nxge_ring_handle_t	tx_ring_handles[NXGE_MAX_TDCS];
8018275SEric Cheng 	nxge_ring_handle_t	rx_ring_handles[NXGE_MAX_RDCS];
8028275SEric Cheng 
8038275SEric Cheng 	nxge_ring_group_t	tx_hio_groups[NXGE_MAX_TDC_GROUPS];
8048275SEric Cheng 	nxge_ring_group_t	rx_hio_groups[NXGE_MAX_RDC_GROUPS];
8058275SEric Cheng 
8066495Sspeer 	nxge_share_handle_t	shares[NXGE_MAX_VRS];
80711304SJanie.Lu@Sun.COM 
80811304SJanie.Lu@Sun.COM 	/*
80911304SJanie.Lu@Sun.COM 	 * KT-NIU:
81011304SJanie.Lu@Sun.COM 	 *	KT family will have up to 4 NIUs per system.
81111304SJanie.Lu@Sun.COM 	 *	Differences between N2/NIU and KT/NIU:
81211304SJanie.Lu@Sun.COM 	 *		SerDes, Hypervisor interfaces,
81311304SJanie.Lu@Sun.COM 	 *		additional NIU classification features.
81411304SJanie.Lu@Sun.COM 	 */
81511304SJanie.Lu@Sun.COM 	niu_hw_type_t		niu_hw_type;
8163859Sml29623 };
8173859Sml29623 
8183859Sml29623 /*
8193859Sml29623  * Driver state flags.
8203859Sml29623  */
8213859Sml29623 #define	STATE_REGS_MAPPED	0x000000001	/* device registers mapped */
8223859Sml29623 #define	STATE_KSTATS_SETUP	0x000000002	/* kstats allocated	*/
8233859Sml29623 #define	STATE_NODE_CREATED	0x000000004	/* device node created	*/
8243859Sml29623 #define	STATE_HW_CONFIG_CREATED	0x000000008	/* hardware properties	*/
8253859Sml29623 #define	STATE_HW_INITIALIZED	0x000000010	/* hardware initialized	*/
8263859Sml29623 #define	STATE_MDIO_LOCK_INIT	0x000000020	/* mdio lock initialized */
8273859Sml29623 #define	STATE_MII_LOCK_INIT	0x000000040	/* mii lock initialized */
8283859Sml29623 
8293859Sml29623 #define	STOP_POLL_THRESH 	9
8303859Sml29623 #define	START_POLL_THRESH	2
8313859Sml29623 
8323859Sml29623 typedef struct _nxge_port_kstat_t {
8333859Sml29623 	/*
8343859Sml29623 	 * Transciever state informations.
8353859Sml29623 	 */
8363859Sml29623 	kstat_named_t	xcvr_inits;
8373859Sml29623 	kstat_named_t	xcvr_inuse;
8383859Sml29623 	kstat_named_t	xcvr_addr;
8393859Sml29623 	kstat_named_t	xcvr_id;
8403859Sml29623 	kstat_named_t	cap_autoneg;
8413859Sml29623 	kstat_named_t	cap_10gfdx;
8423859Sml29623 	kstat_named_t	cap_10ghdx;
8433859Sml29623 	kstat_named_t	cap_1000fdx;
8443859Sml29623 	kstat_named_t	cap_1000hdx;
8453859Sml29623 	kstat_named_t	cap_100T4;
8463859Sml29623 	kstat_named_t	cap_100fdx;
8473859Sml29623 	kstat_named_t	cap_100hdx;
8483859Sml29623 	kstat_named_t	cap_10fdx;
8493859Sml29623 	kstat_named_t	cap_10hdx;
8503859Sml29623 	kstat_named_t	cap_asmpause;
8513859Sml29623 	kstat_named_t	cap_pause;
8523859Sml29623 
8533859Sml29623 	/*
8543859Sml29623 	 * Link partner capabilities.
8553859Sml29623 	 */
8563859Sml29623 	kstat_named_t	lp_cap_autoneg;
8573859Sml29623 	kstat_named_t	lp_cap_10gfdx;
8583859Sml29623 	kstat_named_t	lp_cap_10ghdx;
8593859Sml29623 	kstat_named_t	lp_cap_1000fdx;
8603859Sml29623 	kstat_named_t	lp_cap_1000hdx;
8613859Sml29623 	kstat_named_t	lp_cap_100T4;
8623859Sml29623 	kstat_named_t	lp_cap_100fdx;
8633859Sml29623 	kstat_named_t	lp_cap_100hdx;
8643859Sml29623 	kstat_named_t	lp_cap_10fdx;
8653859Sml29623 	kstat_named_t	lp_cap_10hdx;
8663859Sml29623 	kstat_named_t	lp_cap_asmpause;
8673859Sml29623 	kstat_named_t	lp_cap_pause;
8683859Sml29623 
8693859Sml29623 	/*
8703859Sml29623 	 * Shared link setup.
8713859Sml29623 	 */
8723859Sml29623 	kstat_named_t	link_T4;
8733859Sml29623 	kstat_named_t	link_speed;
8743859Sml29623 	kstat_named_t	link_duplex;
8753859Sml29623 	kstat_named_t	link_asmpause;
8763859Sml29623 	kstat_named_t	link_pause;
8773859Sml29623 	kstat_named_t	link_up;
8783859Sml29623 
8793859Sml29623 	/*
8803859Sml29623 	 * Lets the user know the MTU currently in use by
8813859Sml29623 	 * the physical MAC port.
8823859Sml29623 	 */
8833859Sml29623 	kstat_named_t	mac_mtu;
8843859Sml29623 	kstat_named_t	lb_mode;
8853859Sml29623 	kstat_named_t	qos_mode;
8863859Sml29623 	kstat_named_t	trunk_mode;
8873859Sml29623 
8883859Sml29623 	/*
8893859Sml29623 	 * Misc MAC statistics.
8903859Sml29623 	 */
8913859Sml29623 	kstat_named_t	ifspeed;
8923859Sml29623 	kstat_named_t	promisc;
8933859Sml29623 	kstat_named_t	rev_id;
8943859Sml29623 
8953859Sml29623 	/*
8963859Sml29623 	 * Some statistics added to support bringup, these
8973859Sml29623 	 * should be removed.
8983859Sml29623 	 */
8993859Sml29623 	kstat_named_t	user_defined;
9003859Sml29623 } nxge_port_kstat_t, *p_nxge_port_kstat_t;
9013859Sml29623 
9023859Sml29623 typedef struct _nxge_rdc_kstat {
9033859Sml29623 	/*
9043859Sml29623 	 * Receive DMA channel statistics.
9053859Sml29623 	 */
9063859Sml29623 	kstat_named_t	ipackets;
9073859Sml29623 	kstat_named_t	rbytes;
9083859Sml29623 	kstat_named_t	errors;
9093859Sml29623 	kstat_named_t	dcf_err;
9103859Sml29623 	kstat_named_t	rcr_ack_err;
9113859Sml29623 
9123859Sml29623 	kstat_named_t	dc_fifoflow_err;
9133859Sml29623 	kstat_named_t	rcr_sha_par_err;
9143859Sml29623 	kstat_named_t	rbr_pre_par_err;
9153859Sml29623 	kstat_named_t	wred_drop;
9163859Sml29623 	kstat_named_t	rbr_pre_emty;
9173859Sml29623 
9183859Sml29623 	kstat_named_t	rcr_shadow_full;
9193859Sml29623 	kstat_named_t	rbr_tmout;
9203859Sml29623 	kstat_named_t	rsp_cnt_err;
9213859Sml29623 	kstat_named_t	byte_en_bus;
9223859Sml29623 	kstat_named_t	rsp_dat_err;
9233859Sml29623 
9246028Ssbehera 	kstat_named_t	pkt_too_long_err;
9253859Sml29623 	kstat_named_t	compl_l2_err;
9263859Sml29623 	kstat_named_t	compl_l4_cksum_err;
9273859Sml29623 	kstat_named_t	compl_zcp_soft_err;
9283859Sml29623 	kstat_named_t	compl_fflp_soft_err;
9293859Sml29623 	kstat_named_t	config_err;
9303859Sml29623 
9313859Sml29623 	kstat_named_t	rcrincon;
9323859Sml29623 	kstat_named_t	rcrfull;
9333859Sml29623 	kstat_named_t	rbr_empty;
9343859Sml29623 	kstat_named_t	rbrfull;
9353859Sml29623 	kstat_named_t	rbrlogpage;
9363859Sml29623 
9373859Sml29623 	kstat_named_t	cfiglogpage;
9383859Sml29623 	kstat_named_t	port_drop_pkt;
9393859Sml29623 	kstat_named_t	rcr_to;
9403859Sml29623 	kstat_named_t	rcr_thresh;
9413859Sml29623 	kstat_named_t	rcr_mex;
9423859Sml29623 	kstat_named_t	id_mismatch;
9433859Sml29623 	kstat_named_t	zcp_eop_err;
9443859Sml29623 	kstat_named_t	ipp_eop_err;
9453859Sml29623 } nxge_rdc_kstat_t, *p_nxge_rdc_kstat_t;
9463859Sml29623 
9473859Sml29623 typedef struct _nxge_rdc_sys_kstat {
9483859Sml29623 	/*
9493859Sml29623 	 * Receive DMA system statistics.
9503859Sml29623 	 */
9513859Sml29623 	kstat_named_t	pre_par;
9523859Sml29623 	kstat_named_t	sha_par;
9533859Sml29623 	kstat_named_t	id_mismatch;
9543859Sml29623 	kstat_named_t	ipp_eop_err;
9553859Sml29623 	kstat_named_t	zcp_eop_err;
9563859Sml29623 } nxge_rdc_sys_kstat_t, *p_nxge_rdc_sys_kstat_t;
9573859Sml29623 
9583859Sml29623 typedef	struct _nxge_tdc_kstat {
9593859Sml29623 	/*
9603859Sml29623 	 * Transmit DMA channel statistics.
9613859Sml29623 	 */
9623859Sml29623 	kstat_named_t	opackets;
9633859Sml29623 	kstat_named_t	obytes;
9643859Sml29623 	kstat_named_t	oerrors;
9653859Sml29623 	kstat_named_t	tx_inits;
9663859Sml29623 	kstat_named_t	tx_no_buf;
9673859Sml29623 
9683859Sml29623 	kstat_named_t	mbox_err;
9693859Sml29623 	kstat_named_t	pkt_size_err;
9703859Sml29623 	kstat_named_t	tx_ring_oflow;
9713859Sml29623 	kstat_named_t	pref_buf_ecc_err;
9723859Sml29623 	kstat_named_t	nack_pref;
9733859Sml29623 	kstat_named_t	nack_pkt_rd;
9743859Sml29623 	kstat_named_t	conf_part_err;
9753859Sml29623 	kstat_named_t	pkt_prt_err;
9763859Sml29623 	kstat_named_t	reset_fail;
9773859Sml29623 /* used to in the common (per port) counter */
9783859Sml29623 
9793859Sml29623 	kstat_named_t	tx_starts;
9803859Sml29623 	kstat_named_t	tx_nocanput;
9813859Sml29623 	kstat_named_t	tx_msgdup_fail;
9823859Sml29623 	kstat_named_t	tx_allocb_fail;
9833859Sml29623 	kstat_named_t	tx_no_desc;
9843859Sml29623 	kstat_named_t	tx_dma_bind_fail;
9853859Sml29623 	kstat_named_t	tx_uflo;
9863859Sml29623 	kstat_named_t	tx_hdr_pkts;
9873859Sml29623 	kstat_named_t	tx_ddi_pkts;
9883859Sml29623 	kstat_named_t	tx_dvma_pkts;
9893859Sml29623 	kstat_named_t	tx_max_pend;
9903859Sml29623 } nxge_tdc_kstat_t, *p_nxge_tdc_kstat_t;
9913859Sml29623 
9923859Sml29623 typedef	struct _nxge_txc_kstat {
9933859Sml29623 	/*
9943859Sml29623 	 * Transmit port TXC block statistics.
9953859Sml29623 	 */
9963859Sml29623 	kstat_named_t	pkt_stuffed;
9973859Sml29623 	kstat_named_t	pkt_xmit;
9983859Sml29623 	kstat_named_t	ro_correct_err;
9993859Sml29623 	kstat_named_t	ro_uncorrect_err;
10003859Sml29623 	kstat_named_t	sf_correct_err;
10013859Sml29623 	kstat_named_t	sf_uncorrect_err;
10023859Sml29623 	kstat_named_t	address_failed;
10033859Sml29623 	kstat_named_t	dma_failed;
10043859Sml29623 	kstat_named_t	length_failed;
10053859Sml29623 	kstat_named_t	pkt_assy_dead;
10063859Sml29623 	kstat_named_t	reorder_err;
10073859Sml29623 } nxge_txc_kstat_t, *p_nxge_txc_kstat_t;
10083859Sml29623 
10093859Sml29623 typedef struct _nxge_ipp_kstat {
10103859Sml29623 	/*
10113859Sml29623 	 * Receive port IPP block statistics.
10123859Sml29623 	 */
10133859Sml29623 	kstat_named_t	eop_miss;
10143859Sml29623 	kstat_named_t	sop_miss;
10153859Sml29623 	kstat_named_t	dfifo_ue;
10163859Sml29623 	kstat_named_t	ecc_err_cnt;
10174439Sml29623 	kstat_named_t	pfifo_perr;
10183859Sml29623 	kstat_named_t	pfifo_over;
10193859Sml29623 	kstat_named_t	pfifo_und;
10203859Sml29623 	kstat_named_t	bad_cs_cnt;
10213859Sml29623 	kstat_named_t	pkt_dis_cnt;
10223859Sml29623 } nxge_ipp_kstat_t, *p_nxge_ipp_kstat_t;
10233859Sml29623 
10243859Sml29623 typedef	struct _nxge_zcp_kstat {
10253859Sml29623 	/*
10263859Sml29623 	 * ZCP statistics.
10273859Sml29623 	 */
10283859Sml29623 	kstat_named_t	errors;
10293859Sml29623 	kstat_named_t	inits;
10303859Sml29623 	kstat_named_t	rrfifo_underrun;
10313859Sml29623 	kstat_named_t	rrfifo_overrun;
10323859Sml29623 	kstat_named_t	rspfifo_uncorr_err;
10333859Sml29623 	kstat_named_t	buffer_overflow;
10343859Sml29623 	kstat_named_t	stat_tbl_perr;
10353859Sml29623 	kstat_named_t	dyn_tbl_perr;
10363859Sml29623 	kstat_named_t	buf_tbl_perr;
10373859Sml29623 	kstat_named_t	tt_program_err;
10383859Sml29623 	kstat_named_t	rsp_tt_index_err;
10393859Sml29623 	kstat_named_t	slv_tt_index_err;
10403859Sml29623 	kstat_named_t	zcp_tt_index_err;
10413859Sml29623 	kstat_named_t	access_fail;
10423859Sml29623 	kstat_named_t	cfifo_ecc;
10433859Sml29623 } nxge_zcp_kstat_t, *p_nxge_zcp_kstat_t;
10443859Sml29623 
10453859Sml29623 typedef	struct _nxge_mac_kstat {
10463859Sml29623 	/*
10473859Sml29623 	 * Transmit MAC statistics.
10483859Sml29623 	 */
10493859Sml29623 	kstat_named_t	tx_frame_cnt;
10503859Sml29623 	kstat_named_t	tx_underflow_err;
10513859Sml29623 	kstat_named_t	tx_overflow_err;
10523859Sml29623 	kstat_named_t	tx_maxpktsize_err;
10533859Sml29623 	kstat_named_t	tx_fifo_xfr_err;
10543859Sml29623 	kstat_named_t	tx_byte_cnt;
10553859Sml29623 
10563859Sml29623 	/*
10573859Sml29623 	 * Receive MAC statistics.
10583859Sml29623 	 */
10593859Sml29623 	kstat_named_t	rx_frame_cnt;
10603859Sml29623 	kstat_named_t	rx_underflow_err;
10613859Sml29623 	kstat_named_t	rx_overflow_err;
10623859Sml29623 	kstat_named_t	rx_len_err_cnt;
10633859Sml29623 	kstat_named_t	rx_crc_err_cnt;
10643859Sml29623 	kstat_named_t	rx_viol_err_cnt;
10653859Sml29623 	kstat_named_t	rx_byte_cnt;
10663859Sml29623 	kstat_named_t	rx_hist1_cnt;
10673859Sml29623 	kstat_named_t	rx_hist2_cnt;
10683859Sml29623 	kstat_named_t	rx_hist3_cnt;
10693859Sml29623 	kstat_named_t	rx_hist4_cnt;
10703859Sml29623 	kstat_named_t	rx_hist5_cnt;
10713859Sml29623 	kstat_named_t	rx_hist6_cnt;
10726075Ssbehera 	kstat_named_t	rx_hist7_cnt;
10733859Sml29623 	kstat_named_t	rx_broadcast_cnt;
10743859Sml29623 	kstat_named_t	rx_mult_cnt;
10753859Sml29623 	kstat_named_t	rx_frag_cnt;
10763859Sml29623 	kstat_named_t	rx_frame_align_err_cnt;
10773859Sml29623 	kstat_named_t	rx_linkfault_err_cnt;
10783859Sml29623 	kstat_named_t	rx_local_fault_err_cnt;
10793859Sml29623 	kstat_named_t	rx_remote_fault_err_cnt;
10803859Sml29623 } nxge_mac_kstat_t, *p_nxge_mac_kstat_t;
10813859Sml29623 
10823859Sml29623 typedef	struct _nxge_xmac_kstat {
10833859Sml29623 	/*
10843859Sml29623 	 * XMAC statistics.
10853859Sml29623 	 */
10863859Sml29623 	kstat_named_t	tx_frame_cnt;
10873859Sml29623 	kstat_named_t	tx_underflow_err;
10883859Sml29623 	kstat_named_t	tx_maxpktsize_err;
10893859Sml29623 	kstat_named_t	tx_overflow_err;
10903859Sml29623 	kstat_named_t	tx_fifo_xfr_err;
10913859Sml29623 	kstat_named_t	tx_byte_cnt;
10923859Sml29623 	kstat_named_t	rx_frame_cnt;
10933859Sml29623 	kstat_named_t	rx_underflow_err;
10943859Sml29623 	kstat_named_t	rx_overflow_err;
10953859Sml29623 	kstat_named_t	rx_crc_err_cnt;
10963859Sml29623 	kstat_named_t	rx_len_err_cnt;
10973859Sml29623 	kstat_named_t	rx_viol_err_cnt;
10983859Sml29623 	kstat_named_t	rx_byte_cnt;
10993859Sml29623 	kstat_named_t	rx_hist1_cnt;
11003859Sml29623 	kstat_named_t	rx_hist2_cnt;
11013859Sml29623 	kstat_named_t	rx_hist3_cnt;
11023859Sml29623 	kstat_named_t	rx_hist4_cnt;
11033859Sml29623 	kstat_named_t	rx_hist5_cnt;
11043859Sml29623 	kstat_named_t	rx_hist6_cnt;
11053859Sml29623 	kstat_named_t	rx_hist7_cnt;
11063859Sml29623 	kstat_named_t	rx_broadcast_cnt;
11073859Sml29623 	kstat_named_t	rx_mult_cnt;
11083859Sml29623 	kstat_named_t	rx_frag_cnt;
11093859Sml29623 	kstat_named_t	rx_frame_align_err_cnt;
11103859Sml29623 	kstat_named_t	rx_linkfault_err_cnt;
11113859Sml29623 	kstat_named_t	rx_remote_fault_err_cnt;
11123859Sml29623 	kstat_named_t	rx_local_fault_err_cnt;
11133859Sml29623 	kstat_named_t	rx_pause_cnt;
11143859Sml29623 	kstat_named_t	xpcs_deskew_err_cnt;
11153859Sml29623 	kstat_named_t	xpcs_ln0_symbol_err_cnt;
11163859Sml29623 	kstat_named_t	xpcs_ln1_symbol_err_cnt;
11173859Sml29623 	kstat_named_t	xpcs_ln2_symbol_err_cnt;
11183859Sml29623 	kstat_named_t	xpcs_ln3_symbol_err_cnt;
11193859Sml29623 } nxge_xmac_kstat_t, *p_nxge_xmac_kstat_t;
11203859Sml29623 
11213859Sml29623 typedef	struct _nxge_bmac_kstat {
11223859Sml29623 	/*
11233859Sml29623 	 * BMAC statistics.
11243859Sml29623 	 */
11253859Sml29623 	kstat_named_t tx_frame_cnt;
11263859Sml29623 	kstat_named_t tx_underrun_err;
11273859Sml29623 	kstat_named_t tx_max_pkt_err;
11283859Sml29623 	kstat_named_t tx_byte_cnt;
11293859Sml29623 	kstat_named_t rx_frame_cnt;
11303859Sml29623 	kstat_named_t rx_byte_cnt;
11313859Sml29623 	kstat_named_t rx_overflow_err;
11323859Sml29623 	kstat_named_t rx_align_err_cnt;
11333859Sml29623 	kstat_named_t rx_crc_err_cnt;
11343859Sml29623 	kstat_named_t rx_len_err_cnt;
11353859Sml29623 	kstat_named_t rx_viol_err_cnt;
11363859Sml29623 	kstat_named_t rx_pause_cnt;
11373859Sml29623 	kstat_named_t tx_pause_state;
11383859Sml29623 	kstat_named_t tx_nopause_state;
11393859Sml29623 } nxge_bmac_kstat_t, *p_nxge_bmac_kstat_t;
11403859Sml29623 
11413859Sml29623 
11423859Sml29623 typedef struct _nxge_fflp_kstat {
11433859Sml29623 	/*
11443859Sml29623 	 * FFLP statistics.
11453859Sml29623 	 */
11463859Sml29623 
11475938Smisaki 	kstat_named_t	fflp_tcam_perr;
11483859Sml29623 	kstat_named_t	fflp_tcam_ecc_err;
11493859Sml29623 	kstat_named_t	fflp_vlan_perr;
11503859Sml29623 	kstat_named_t	fflp_hasht_lookup_err;
11513859Sml29623 	kstat_named_t	fflp_hasht_data_err[MAX_PARTITION];
11523859Sml29623 } nxge_fflp_kstat_t, *p_nxge_fflp_kstat_t;
11533859Sml29623 
11543859Sml29623 typedef struct _nxge_mmac_kstat {
11553859Sml29623 	kstat_named_t	mmac_max_addr_cnt;
11563859Sml29623 	kstat_named_t	mmac_avail_addr_cnt;
11573859Sml29623 	kstat_named_t	mmac_addr1;
11583859Sml29623 	kstat_named_t	mmac_addr2;
11593859Sml29623 	kstat_named_t	mmac_addr3;
11603859Sml29623 	kstat_named_t	mmac_addr4;
11613859Sml29623 	kstat_named_t	mmac_addr5;
11623859Sml29623 	kstat_named_t	mmac_addr6;
11633859Sml29623 	kstat_named_t	mmac_addr7;
11643859Sml29623 	kstat_named_t	mmac_addr8;
11653859Sml29623 	kstat_named_t	mmac_addr9;
11663859Sml29623 	kstat_named_t	mmac_addr10;
11673859Sml29623 	kstat_named_t	mmac_addr11;
11683859Sml29623 	kstat_named_t	mmac_addr12;
11693859Sml29623 	kstat_named_t	mmac_addr13;
11703859Sml29623 	kstat_named_t	mmac_addr14;
11713859Sml29623 	kstat_named_t	mmac_addr15;
11723859Sml29623 	kstat_named_t	mmac_addr16;
11733859Sml29623 } nxge_mmac_kstat_t, *p_nxge_mmac_kstat_t;
11743859Sml29623 
11753859Sml29623 /*
11763859Sml29623  * Prototype definitions.
11773859Sml29623  */
11783859Sml29623 nxge_status_t nxge_init(p_nxge_t);
11793859Sml29623 void nxge_uninit(p_nxge_t);
11803859Sml29623 void nxge_get64(p_nxge_t, p_mblk_t);
11813859Sml29623 void nxge_put64(p_nxge_t, p_mblk_t);
11823859Sml29623 void nxge_pio_loop(p_nxge_t, p_mblk_t);
11833859Sml29623 
11843859Sml29623 typedef	void	(*fptrv_t)();
11857812SMichael.Speer@Sun.COM timeout_id_t	nxge_start_timer(p_nxge_t, fptrv_t, int);
11867812SMichael.Speer@Sun.COM void		nxge_stop_timer(p_nxge_t, timeout_id_t);
11873859Sml29623 
11883859Sml29623 #ifdef	__cplusplus
11893859Sml29623 }
11903859Sml29623 #endif
11913859Sml29623 
11923859Sml29623 #endif	/* _SYS_NXGE_NXGE_H */
1193