xref: /onnv-gate/usr/src/uts/common/io/nxge/npi/npi_rxdma.h (revision 11304:3092d1e303d6)
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 _NPI_RXDMA_H
273859Sml29623 #define	_NPI_RXDMA_H
283859Sml29623 
293859Sml29623 #ifdef	__cplusplus
303859Sml29623 extern "C" {
313859Sml29623 #endif
323859Sml29623 
333859Sml29623 #include <npi.h>
343859Sml29623 
353859Sml29623 #include "nxge_defs.h"
363859Sml29623 #include "nxge_hw.h"
373859Sml29623 #include <nxge_rxdma_hw.h>
383859Sml29623 
393859Sml29623 /*
403859Sml29623  * Register offset (0x200 bytes for each channel) for receive ring registers.
413859Sml29623  */
423859Sml29623 #define	NXGE_RXDMA_OFFSET(x, v, channel) (x + \
433859Sml29623 		(!v ? DMC_OFFSET(channel) : \
443859Sml29623 		    RDMC_PIOVADDR_OFFSET(channel)))
453859Sml29623 
463859Sml29623 
473859Sml29623 #define	 REG_FZC_RDC_OFFSET(reg, rdc) (reg + RX_LOG_DMA_OFFSET(rdc))
483859Sml29623 
493859Sml29623 #define	 REG_RDC_TABLE_OFFSET(table) \
503859Sml29623 	    (RDC_TBL_REG + table * (NXGE_MAX_RDCS * 8))
513859Sml29623 
523859Sml29623 /*
533859Sml29623  * RX NPI error codes
543859Sml29623  */
553859Sml29623 #define	RXDMA_ER_ST			(RXDMA_BLK_ID << NPI_BLOCK_ID_SHIFT)
563859Sml29623 #define	RXDMA_ID_SHIFT(n)		(n << NPI_PORT_CHAN_SHIFT)
573859Sml29623 
583859Sml29623 
593859Sml29623 #define	NPI_RXDMA_ERROR			RXDMA_ER_ST
603859Sml29623 
613859Sml29623 #define	NPI_RXDMA_SW_PARAM_ERROR	(NPI_RXDMA_ERROR | 0x40)
623859Sml29623 #define	NPI_RXDMA_HW_ERROR	(NPI_RXDMA_ERROR | 0x80)
633859Sml29623 
643859Sml29623 #define	NPI_RXDMA_RDC_INVALID		(NPI_RXDMA_ERROR | CHANNEL_INVALID)
653859Sml29623 #define	NPI_RXDMA_PAGE_INVALID		(NPI_RXDMA_ERROR | LOGICAL_PAGE_INVALID)
663859Sml29623 #define	NPI_RXDMA_RESET_ERR		(NPI_RXDMA_HW_ERROR | RESET_FAILED)
673859Sml29623 #define	NPI_RXDMA_DISABLE_ERR		(NPI_RXDMA_HW_ERROR | 0x0000a)
683859Sml29623 #define	NPI_RXDMA_ENABLE_ERR		(NPI_RXDMA_HW_ERROR | 0x0000b)
693859Sml29623 #define	NPI_RXDMA_FUNC_INVALID		(NPI_RXDMA_SW_PARAM_ERROR | 0x0000a)
706495Sspeer #define	NPI_RXDMA_BUFSIZE_INVALID	(NPI_RXDMA_SW_PARAM_ERROR | 0x0000b)
716495Sspeer #define	NPI_RXDMA_RBRSIZE_INVALID	(NPI_RXDMA_SW_PARAM_ERROR | 0x0000c)
726495Sspeer #define	NPI_RXDMA_RCRSIZE_INVALID	(NPI_RXDMA_SW_PARAM_ERROR | 0x0000d)
733859Sml29623 #define	NPI_RXDMA_PORT_INVALID		(NPI_RXDMA_ERROR | PORT_INVALID)
743859Sml29623 #define	NPI_RXDMA_TABLE_INVALID		(NPI_RXDMA_ERROR | RDC_TAB_INVALID)
753859Sml29623 
763859Sml29623 #define	NPI_RXDMA_CHANNEL_INVALID(n)	(RXDMA_ID_SHIFT(n) |	\
773859Sml29623 					NPI_RXDMA_ERROR | CHANNEL_INVALID)
783859Sml29623 #define	NPI_RXDMA_OPCODE_INVALID(n)	(RXDMA_ID_SHIFT(n) |	\
793859Sml29623 					NPI_RXDMA_ERROR | OPCODE_INVALID)
803859Sml29623 
813859Sml29623 
823859Sml29623 #define	NPI_RXDMA_ERROR_ENCODE(err, rdc)	\
833859Sml29623 	(RXDMA_ID_SHIFT(rdc) | RXDMA_ER_ST | err)
843859Sml29623 
853859Sml29623 
863859Sml29623 #define	RXDMA_CHANNEL_VALID(rdc) \
873859Sml29623 	((rdc < NXGE_MAX_RDCS))
883859Sml29623 
893859Sml29623 #define	RXDMA_PORT_VALID(port) \
903859Sml29623 	((port < MAX_PORTS_PER_NXGE))
913859Sml29623 
923859Sml29623 #define	RXDMA_TABLE_VALID(table) \
933859Sml29623 	((table < NXGE_MAX_RDC_GROUPS))
943859Sml29623 
953859Sml29623 
963859Sml29623 #define	RXDMA_PAGE_VALID(page) \
973859Sml29623 	((page == 0) || (page == 1))
983859Sml29623 
993859Sml29623 #define	RXDMA_BUFF_OFFSET_VALID(offset) \
1003859Sml29623 	((offset == SW_OFFSET_NO_OFFSET) || \
1013859Sml29623 	    (offset == SW_OFFSET_64) || \
1023859Sml29623 	    (offset == SW_OFFSET_128))
1033859Sml29623 
104*11304SJanie.Lu@Sun.COM #define	RXDMA_RF_BUFF_OFFSET_VALID(offset) \
105*11304SJanie.Lu@Sun.COM 	((offset == SW_OFFSET_NO_OFFSET) || \
106*11304SJanie.Lu@Sun.COM 	    (offset == SW_OFFSET_64) || \
107*11304SJanie.Lu@Sun.COM 	    (offset == SW_OFFSET_128) || \
108*11304SJanie.Lu@Sun.COM 	    (offset == SW_OFFSET_192) || \
109*11304SJanie.Lu@Sun.COM 	    (offset == SW_OFFSET_256) || \
110*11304SJanie.Lu@Sun.COM 	    (offset == SW_OFFSET_320) || \
111*11304SJanie.Lu@Sun.COM 	    (offset == SW_OFFSET_384) || \
112*11304SJanie.Lu@Sun.COM 	    (offset == SW_OFFSET_448))
113*11304SJanie.Lu@Sun.COM 
1143859Sml29623 
1153859Sml29623 #define	RXDMA_RCR_TO_VALID(tov) ((tov) && (tov < 64))
1163859Sml29623 #define	RXDMA_RCR_THRESH_VALID(thresh) ((thresh) && (thresh < 512))
1173859Sml29623 
1183859Sml29623 /*
1193859Sml29623  * RXDMA NPI defined control types.
1203859Sml29623  */
1213859Sml29623 typedef	enum _rxdma_cs_cntl_e {
1223859Sml29623 	RXDMA_CS_CLEAR_ALL		= 0x1,
1233859Sml29623 	RXDMA_MEX_SET			= 0x2,
1243859Sml29623 	RXDMA_RCRTO_CLEAR		= 0x8,
1253859Sml29623 	RXDMA_PT_DROP_PKT_CLEAR		= 0x10,
1263859Sml29623 	RXDMA_WRED_DROP_CLEAR		= 0x20,
1273859Sml29623 	RXDMA_RCR_SFULL_CLEAR		= 0x40,
1283859Sml29623 	RXDMA_RCR_FULL_CLEAR		= 0x80,
1293859Sml29623 	RXDMA_RBR_PRE_EMPTY_CLEAR	= 0x100,
1303859Sml29623 	RXDMA_RBR_EMPTY_CLEAR		= 0x200
1313859Sml29623 } rxdma_cs_cntl_t;
1323859Sml29623 
1333859Sml29623 /*
1343859Sml29623  * RXDMA NPI defined event masks (mapped to the hardware defined masks).
1353859Sml29623  */
1363859Sml29623 typedef	enum _rxdma_ent_msk_cfg_e {
1373859Sml29623 	CFG_RXDMA_ENT_MSK_CFIGLOGPGE_MASK = RX_DMA_ENT_MSK_CFIGLOGPGE_MASK,
1383859Sml29623 	CFG_RXDMA_ENT_MSK_RBRLOGPGE_MASK  = RX_DMA_ENT_MSK_RBRLOGPGE_MASK,
1393859Sml29623 	CFG_RXDMA_ENT_MSK_RBRFULL_MASK	  = RX_DMA_ENT_MSK_RBRFULL_MASK,
1403859Sml29623 	CFG_RXDMA_ENT_MSK_RBREMPTY_MASK	  = RX_DMA_ENT_MSK_RBREMPTY_MASK,
1413859Sml29623 	CFG_RXDMA_ENT_MSK_RCRFULL_MASK	  = RX_DMA_ENT_MSK_RCRFULL_MASK,
1423859Sml29623 	CFG_RXDMA_ENT_MSK_RCRINCON_MASK	  = RX_DMA_ENT_MSK_RCRINCON_MASK,
1433859Sml29623 	CFG_RXDMA_ENT_MSK_CONFIG_ERR	  = RX_DMA_ENT_MSK_CONFIG_ERR_MASK,
1443859Sml29623 	CFG_RXDMA_ENT_MSK_RCR_SH_FULL_MASK = RX_DMA_ENT_MSK_RCRSH_FULL_MASK,
1453859Sml29623 	CFG_RXDMA_ENT_MSK_RBR_PRE_EMTY_MASK = RX_DMA_ENT_MSK_RBR_PRE_EMPTY_MASK,
1463859Sml29623 	CFG_RXDMA_ENT_MSK_WRED_DROP_MASK   = RX_DMA_ENT_MSK_WRED_DROP_MASK,
1473859Sml29623 	CFG_RXDMA_ENT_MSK_PT_DROP_PKT_MASK = RX_DMA_ENT_MSK_PTDROP_PKT_MASK,
1483859Sml29623 	CFG_RXDMA_ENT_MSK_RBR_PRE_PAR_MASK = RX_DMA_ENT_MSK_RBR_PRE_PAR_MASK,
1493859Sml29623 	CFG_RXDMA_ENT_MSK_RCR_SHA_PAR_MASK = RX_DMA_ENT_MSK_RCR_SHA_PAR_MASK,
1503859Sml29623 	CFG_RXDMA_ENT_MSK_RCRTO_MASK	  = RX_DMA_ENT_MSK_RCRTO_MASK,
1513859Sml29623 	CFG_RXDMA_ENT_MSK_THRES_MASK	  = RX_DMA_ENT_MSK_THRES_MASK,
1523859Sml29623 	CFG_RXDMA_ENT_MSK_DC_FIFO_ERR_MASK  = RX_DMA_ENT_MSK_DC_FIFO_ERR_MASK,
1533859Sml29623 	CFG_RXDMA_ENT_MSK_RCR_ACK_ERR_MASK  = RX_DMA_ENT_MSK_RCR_ACK_ERR_MASK,
1543859Sml29623 	CFG_RXDMA_ENT_MSK_RSP_DAT_ERR_MASK  = RX_DMA_ENT_MSK_RSP_DAT_ERR_MASK,
1553859Sml29623 	CFG_RXDMA_ENT_MSK_BYTE_EN_BUS_MASK  = RX_DMA_ENT_MSK_BYTE_EN_BUS_MASK,
1563859Sml29623 	CFG_RXDMA_ENT_MSK_RSP_CNT_ERR_MASK  = RX_DMA_ENT_MSK_RSP_CNT_ERR_MASK,
1573859Sml29623 	CFG_RXDMA_ENT_MSK_RBR_TMOUT_MASK  = RX_DMA_ENT_MSK_RBR_TMOUT_MASK,
1583859Sml29623 
1593859Sml29623 	CFG_RXDMA_MASK_ALL	  = (RX_DMA_ENT_MSK_CFIGLOGPGE_MASK |
1603859Sml29623 					RX_DMA_ENT_MSK_RBRLOGPGE_MASK |
1613859Sml29623 					RX_DMA_ENT_MSK_RBRFULL_MASK |
1623859Sml29623 					RX_DMA_ENT_MSK_RBREMPTY_MASK |
1633859Sml29623 					RX_DMA_ENT_MSK_RCRFULL_MASK |
1643859Sml29623 					RX_DMA_ENT_MSK_RCRINCON_MASK |
1653859Sml29623 					RX_DMA_ENT_MSK_CONFIG_ERR_MASK |
1663859Sml29623 					RX_DMA_ENT_MSK_RCRSH_FULL_MASK |
1673859Sml29623 					RX_DMA_ENT_MSK_RBR_PRE_EMPTY_MASK |
1683859Sml29623 					RX_DMA_ENT_MSK_WRED_DROP_MASK |
1693859Sml29623 					RX_DMA_ENT_MSK_PTDROP_PKT_MASK |
1703859Sml29623 					RX_DMA_ENT_MSK_RBR_PRE_PAR_MASK |
1713859Sml29623 					RX_DMA_ENT_MSK_RCR_SHA_PAR_MASK |
1723859Sml29623 					RX_DMA_ENT_MSK_RCRTO_MASK |
1733859Sml29623 					RX_DMA_ENT_MSK_THRES_MASK |
1743859Sml29623 					RX_DMA_ENT_MSK_DC_FIFO_ERR_MASK |
1753859Sml29623 					RX_DMA_ENT_MSK_RCR_ACK_ERR_MASK |
1763859Sml29623 					RX_DMA_ENT_MSK_RSP_DAT_ERR_MASK |
1773859Sml29623 					RX_DMA_ENT_MSK_BYTE_EN_BUS_MASK |
1783859Sml29623 					RX_DMA_ENT_MSK_RSP_CNT_ERR_MASK |
1793859Sml29623 					RX_DMA_ENT_MSK_RBR_TMOUT_MASK)
1803859Sml29623 } rxdma_ent_msk_cfg_t;
1813859Sml29623 
1823859Sml29623 
1833859Sml29623 
1843859Sml29623 typedef union _addr44 {
1853859Sml29623 	uint64_t	addr;
1863859Sml29623 	struct {
1873859Sml29623 #if defined(_BIG_ENDIAN)
1883859Sml29623 		uint32_t rsrvd:20;
1893859Sml29623 		uint32_t hdw:12;
1903859Sml29623 		uint32_t ldw;
1913859Sml29623 #else
1923859Sml29623 		uint32_t ldw;
1933859Sml29623 		uint32_t hdw:12;
1943859Sml29623 		uint32_t rsrvd:20;
1953859Sml29623 #endif
1963859Sml29623 	} bits;
1973859Sml29623 } addr44_t;
1983859Sml29623 
1993859Sml29623 
2003859Sml29623 /*
2013859Sml29623  * npi_rxdma_cfg_default_port_rdc()
2023859Sml29623  * Set the default rdc for the port
2033859Sml29623  *
2043859Sml29623  * Inputs:
2053859Sml29623  *	handle:		register handle interpreted by the underlying OS
2063859Sml29623  *	portnm:		Physical Port Number
2073859Sml29623  *	rdc:	RX DMA Channel number
2083859Sml29623  *
2093859Sml29623  * Return:
2103859Sml29623  * NPI_SUCCESS
2113859Sml29623  * NPI_RXDMA_RDC_INVALID
2123859Sml29623  * NPI_RXDMA_PORT_INVALID
2133859Sml29623  *
2143859Sml29623  */
2153859Sml29623 
2163859Sml29623 npi_status_t npi_rxdma_cfg_default_port_rdc(npi_handle_t,
2173859Sml29623 				    uint8_t, uint8_t);
2183859Sml29623 
2193859Sml29623 /*
2206495Sspeer  * npi_rxdma_rdc_table_config
2213859Sml29623  * Configure/populate the RDC table
2223859Sml29623  *
2233859Sml29623  * Inputs:
2246495Sspeer  *	handle:	register handle interpreted by the underlying OS
2256495Sspeer  *	table:	RDC Group Number
2266495Sspeer  *	map:	Bitmap of RDCs to be written to <table>.
2276495Sspeer  *	count:	A count of the number of bits in <map>.
2283859Sml29623  *
2293859Sml29623  * Return:
2303859Sml29623  * NPI_SUCCESS
2313859Sml29623  * NPI_RXDMA_TABLE_INVALID
2323859Sml29623  *
2333859Sml29623  */
2343859Sml29623 
2356495Sspeer npi_status_t npi_rxdma_rdc_table_config(npi_handle_t, uint8_t, dc_map_t,
2366495Sspeer     int);
2373859Sml29623 
2383859Sml29623 npi_status_t npi_rxdma_cfg_rdc_table_default_rdc(npi_handle_t,
2393859Sml29623 					    uint8_t, uint8_t);
2403859Sml29623 npi_status_t npi_rxdma_cfg_rdc_rcr_timeout_disable(npi_handle_t,
2413859Sml29623 					    uint8_t);
2423859Sml29623 
2433859Sml29623 
2443859Sml29623 /*
2453859Sml29623  * npi_rxdma_32bitmode_enable()
2463859Sml29623  * Enable 32 bit mode
2473859Sml29623  *
2483859Sml29623  * Inputs:
2493859Sml29623  *	handle:		register handle interpreted by the underlying OS
2503859Sml29623  *
2513859Sml29623  * Return:
2523859Sml29623  * NPI_SUCCESS
2533859Sml29623  * NPI_FAILURE
2543859Sml29623  * NPI_HW_ERR
2553859Sml29623  *
2563859Sml29623  */
2573859Sml29623 
2583859Sml29623 npi_status_t npi_rxdma_cfg_32bitmode_enable(npi_handle_t);
2593859Sml29623 
2603859Sml29623 
2613859Sml29623 /*
2623859Sml29623  * npi_rxdma_32bitmode_disable()
2633859Sml29623  * disable 32 bit mode
2643859Sml29623  *
2653859Sml29623  * Inputs:
2663859Sml29623  *	handle:		register handle interpreted by the underlying OS
2673859Sml29623  *
2683859Sml29623  * Return:
2693859Sml29623  * NPI_SUCCESS
2703859Sml29623  * NPI_FAILURE
2713859Sml29623  * NPI_HW_ERR
2723859Sml29623  *
2733859Sml29623  */
2743859Sml29623 
2753859Sml29623 
2763859Sml29623 npi_status_t npi_rxdma_cfg_32bitmode_disable(npi_handle_t);
2773859Sml29623 
2783859Sml29623 /*
2793859Sml29623  * npi_rxdma_cfg_ram_access_enable()
2803859Sml29623  * Enable PIO access to shadow and prefetch memory.
2813859Sml29623  * In the case of DMA errors, software may need to
2823859Sml29623  * initialize the shadow and prefetch memories to
2833859Sml29623  * sane value (may be clear it) before re-enabling
2843859Sml29623  * the DMA channel.
2853859Sml29623  *
2863859Sml29623  * Inputs:
2873859Sml29623  *	handle:		register handle interpreted by the underlying OS
2883859Sml29623  *
2893859Sml29623  * Return:
2903859Sml29623  * NPI_SUCCESS
2913859Sml29623  * NPI_FAILURE
2923859Sml29623  * NPI_HW_ERR
2933859Sml29623  *
2943859Sml29623  */
2953859Sml29623 
2963859Sml29623 npi_status_t npi_rxdma_cfg_ram_access_enable(npi_handle_t);
2973859Sml29623 
2983859Sml29623 
2993859Sml29623 /*
3003859Sml29623  * npi_rxdma_cfg_ram_access_disable()
3013859Sml29623  * Disable PIO access to shadow and prefetch memory.
3023859Sml29623  * This is the normal operation mode.
3033859Sml29623  *
3043859Sml29623  * Inputs:
3053859Sml29623  *	handle:		register handle interpreted by the underlying OS
3063859Sml29623  *
3073859Sml29623  * Return:
3083859Sml29623  * NPI_SUCCESS
3093859Sml29623  * NPI_FAILURE
3103859Sml29623  * NPI_HW_ERR
3113859Sml29623  *
3123859Sml29623  */
3133859Sml29623 
3143859Sml29623 npi_status_t npi_rxdma_cfg_ram_access_disable(npi_handle_t);
3153859Sml29623 
3163859Sml29623 
3173859Sml29623 /*
3183859Sml29623  * npi_rxdma_cfg_clock_div_set()
3193859Sml29623  * init the clock division, used for RX timers
3203859Sml29623  * This determines the granularity of RX DMA countdown timers
3213859Sml29623  * It depends on the system clock. For example if the system
3223859Sml29623  * clock is 300 MHz, a value of 30000 will yield a granularity
3233859Sml29623  * of 100usec.
3243859Sml29623  *
3253859Sml29623  * Inputs:
3263859Sml29623  *	handle:		register handle interpreted by the underlying OS
3273859Sml29623  *	count:		System clock divider
3283859Sml29623  *
3293859Sml29623  * Return:
3303859Sml29623  * NPI_SUCCESS
3313859Sml29623  * NPI_FAILURE
3323859Sml29623  * NPI_SW_ERR
3333859Sml29623  * NPI_HW_ERR
3343859Sml29623  *
3353859Sml29623  */
3363859Sml29623 
3373859Sml29623 npi_status_t npi_rxdma_cfg_clock_div_set(npi_handle_t, uint16_t);
3383859Sml29623 
3393859Sml29623 /*
3403859Sml29623  * npi_rxdma_cfg_red_rand_init()
3413859Sml29623  * init the WRED Discard
3423859Sml29623  * By default, it is enabled
3433859Sml29623  *
3443859Sml29623  * Inputs:
3453859Sml29623  *	handle:		register handle interpreted by the underlying OS
3463859Sml29623  *	init_value:	WRED init value
3473859Sml29623  *
3483859Sml29623  * Return:
3493859Sml29623  * NPI_SUCCESS
3503859Sml29623  * NPI_FAILURE
3513859Sml29623  * NPI_SW_ERR
3523859Sml29623  * NPI_HW_ERR
3533859Sml29623  *
3543859Sml29623  */
3553859Sml29623 
3563859Sml29623 npi_status_t npi_rxdma_cfg_red_rand_init(npi_handle_t, uint16_t);
3573859Sml29623 
3583859Sml29623 /*
3593859Sml29623  * npi_rxdma_cfg_wred_disable()
3603859Sml29623  * init the WRED Discard
3613859Sml29623  * By default, it is enabled
3623859Sml29623  *
3633859Sml29623  * Inputs:
3643859Sml29623  *	handle:		register handle interpreted by the underlying OS
3653859Sml29623  *
3663859Sml29623  * Return:
3673859Sml29623  * NPI_SUCCESS
3683859Sml29623  * NPI_FAILURE
3693859Sml29623  * NPI_SW_ERR
3703859Sml29623  * NPI_HW_ERR
3713859Sml29623  *
3723859Sml29623  */
3733859Sml29623 
3743859Sml29623 
3753859Sml29623 npi_status_t npi_rxdma_cfg_wred_disable(npi_handle_t);
3763859Sml29623 
3773859Sml29623 /*
3783859Sml29623  * npi_rxdma_cfg_wred_param()
3793859Sml29623  * COnfigure per rxdma channel WRED parameters
3803859Sml29623  * By default, it is enabled
3813859Sml29623  *
3823859Sml29623  * Inputs:
3833859Sml29623  *	handle:		register handle interpreted by the underlying OS
3843859Sml29623  *	rdc:	RX DMA Channel number
3853859Sml29623  *	wred_params:	WRED configuration parameters
3863859Sml29623  *
3873859Sml29623  * Return:
3883859Sml29623  * NPI_SUCCESS
3893859Sml29623  * NPI_FAILURE
3903859Sml29623  * NPI_SW_ERR
3913859Sml29623  * NPI_HW_ERR
3923859Sml29623  *
3933859Sml29623  */
3943859Sml29623 
3953859Sml29623 
3963859Sml29623 
3973859Sml29623 npi_status_t npi_rxdma_cfg_wred_param(npi_handle_t, uint8_t,
3983859Sml29623 				    rdc_red_para_t *);
3993859Sml29623 
4003859Sml29623 
4013859Sml29623 /*
4023859Sml29623  * npi_rxdma_port_ddr_weight
4033859Sml29623  * Set the DDR weight for a port.
4043859Sml29623  *
4053859Sml29623  * Inputs:
4063859Sml29623  *	handle:		register handle interpreted by the underlying OS
4073859Sml29623  *	portnm:		Physical Port Number
4083859Sml29623  *	weight:		Port relative weight (in approx. bytes)
4093859Sml29623  *			Default values are:
4103859Sml29623  *			0x400 (port 0 and 1) corresponding to 10 standard
4113859Sml29623  *			      size (1500 bytes) Frames
4123859Sml29623  *			0x66 (port 2 and 3) corresponding to 10% 10Gig ports
4133859Sml29623  *
4143859Sml29623  * Return:
4153859Sml29623  * NPI_SUCCESS
4163859Sml29623  * NPI_FAILURE
4173859Sml29623  * NPI_HW_ERR
4183859Sml29623  * NPI_SW_ERR
4193859Sml29623  *
4203859Sml29623  */
4213859Sml29623 
4223859Sml29623 npi_status_t npi_rxdma_cfg_port_ddr_weight(npi_handle_t,
4233859Sml29623 				    uint8_t, uint32_t);
4243859Sml29623 
4253859Sml29623 
4263859Sml29623 /*
4273859Sml29623  * npi_rxdma_port_usage_get()
4283859Sml29623  * Gets the port usage, in terms of 16 byte blocks
4293859Sml29623  *
4303859Sml29623  * NOTE: The register count is cleared upon reading.
4313859Sml29623  *
4323859Sml29623  * Inputs:
4333859Sml29623  *	handle:		register handle interpreted by the underlying OS
4343859Sml29623  *	portnm:		Physical Port Number
4353859Sml29623  *	blocks:		ptr to save current count.
4363859Sml29623  *
4373859Sml29623  * Return:
4383859Sml29623  * NPI_SUCCESS
4393859Sml29623  * NPI_FAILURE
4403859Sml29623  * NPI_HW_ERR
4413859Sml29623  * NPI_SW_ERR
4423859Sml29623  *
4433859Sml29623  */
4443859Sml29623 
4453859Sml29623 npi_status_t npi_rxdma_port_usage_get(npi_handle_t,
4463859Sml29623 				    uint8_t, uint32_t *);
4473859Sml29623 
4483859Sml29623 
4493859Sml29623 /*
4503859Sml29623  * npi_rxdma_cfg_logical_page()
4513859Sml29623  * Configure per rxdma channel Logical page
4523859Sml29623  *
4533859Sml29623  * To disable the logical page, set valid = 0;
4543859Sml29623  *
4553859Sml29623  * Inputs:
4563859Sml29623  *	handle:		register handle interpreted by the underlying OS
4573859Sml29623  *	rdc:		RX DMA Channel number
4583859Sml29623  *	page_params:	Logical Page configuration parameters
4593859Sml29623  *
4603859Sml29623  * Return:
4613859Sml29623  * NPI_SUCCESS
4623859Sml29623  * NPI_FAILURE
4633859Sml29623  * NPI_SW_ERR
4643859Sml29623  * NPI_HW_ERR
4653859Sml29623  *
4663859Sml29623  */
4673859Sml29623 
4683859Sml29623 
4693859Sml29623 
4703859Sml29623 npi_status_t npi_rxdma_cfg_logical_page(npi_handle_t, uint8_t,
4713859Sml29623 				    dma_log_page_t *);
4723859Sml29623 
4733859Sml29623 
4743859Sml29623 /*
4753859Sml29623  * npi_rxdma_cfg_logical_page_handle()
4763859Sml29623  * Configure per rxdma channel Logical page handle
4773859Sml29623  *
4783859Sml29623  *
4793859Sml29623  * Inputs:
4803859Sml29623  *	handle:		register handle interpreted by the underlying OS
4813859Sml29623  *	rdc:		RX DMA Channel number
4823859Sml29623  *	pg_handle:	Logical Page handle
4833859Sml29623  *
4843859Sml29623  * Return:
4853859Sml29623  * NPI_SUCCESS
4863859Sml29623  * NPI_FAILURE
4873859Sml29623  * NPI_SW_ERR
4883859Sml29623  * NPI_HW_ERR
4893859Sml29623  *
4903859Sml29623  */
4913859Sml29623 
4923859Sml29623 
4933859Sml29623 npi_status_t npi_rxdma_cfg_logical_page_handle(npi_handle_t, uint8_t,
4943859Sml29623 				    uint64_t);
4953859Sml29623 
4963859Sml29623 
4973859Sml29623 
4983859Sml29623 
4993859Sml29623 npi_status_t npi_rxdma_cfg_logical_page_disable(npi_handle_t,
5003859Sml29623 				    uint8_t, uint8_t);
5013859Sml29623 
5023859Sml29623 typedef enum _bsize {
5033859Sml29623 	SIZE_0B = 0x0,
5043859Sml29623 	SIZE_64B,
5053859Sml29623 	SIZE_128B,
5063859Sml29623 	SIZE_192B,
5073859Sml29623 	SIZE_256B,
5083859Sml29623 	SIZE_512B,
5093859Sml29623 	SIZE_1KB,
5103859Sml29623 	SIZE_2KB,
5113859Sml29623 	SIZE_4KB,
5123859Sml29623 	SIZE_8KB,
5133859Sml29623 	SIZE_16KB,
5143859Sml29623 	SIZE_32KB
5153859Sml29623 } bsize_t;
5163859Sml29623 
5173859Sml29623 
5183859Sml29623 
5193859Sml29623 /*
5203859Sml29623  * npi_rxdma_cfg_rdc_ring()
5213859Sml29623  * Configure The RDC channel Rcv Buffer Ring
5223859Sml29623  *
5233859Sml29623  * Inputs:
5243859Sml29623  *	rdc:		RX DMA Channel number
5253859Sml29623  *	rdc_params:	RDC configuration parameters
5263859Sml29623  *
5273859Sml29623  * Return:
5283859Sml29623  * NPI_SUCCESS
5293859Sml29623  * NPI_FAILURE
5303859Sml29623  * NPI_SW_ERR
5313859Sml29623  * NPI_HW_ERR
5323859Sml29623  *
5333859Sml29623  */
5343859Sml29623 
5353859Sml29623 typedef struct _rdc_desc_cfg_t {
5363859Sml29623 	uint8_t mbox_enable;	/* Enable full (18b) header */
5373859Sml29623 	uint8_t full_hdr;	/* Enable full (18b) header */
5383859Sml29623 	uint8_t offset;	/* 64 byte offsets */
5393859Sml29623 	uint8_t valid2;	/* size 2 is valid */
5403859Sml29623 	bsize_t size2;	/* Size 2 length */
5413859Sml29623 	uint8_t valid1;	/* size 1 is valid */
5423859Sml29623 	bsize_t size1;	/* Size 1 length */
5433859Sml29623 	uint8_t valid0;	/* size 0 is valid */
5443859Sml29623 	bsize_t size0;	/* Size 1 length */
5453859Sml29623 	bsize_t page_size;   /* Page or buffer Size */
5463859Sml29623     uint8_t	rcr_timeout_enable;
5473859Sml29623     uint8_t	rcr_timeout;
5483859Sml29623     uint16_t	rcr_threshold;
5493859Sml29623 	uint16_t rcr_len;	   /* RBR Descriptor size (entries) */
5503859Sml29623 	uint16_t rbr_len;	   /* RBR Descriptor size (entries) */
5513859Sml29623 	uint64_t mbox_addr;	   /* Mailbox Address */
5523859Sml29623 	uint64_t rcr_addr;	   /* RCR Address */
5533859Sml29623 	uint64_t rbr_addr;	   /* RBB Address */
5543859Sml29623 } rdc_desc_cfg_t;
5553859Sml29623 
5563859Sml29623 
5573859Sml29623 
5583859Sml29623 npi_status_t npi_rxdma_cfg_rdc_ring(npi_handle_t, uint8_t,
559*11304SJanie.Lu@Sun.COM 				    rdc_desc_cfg_t *, boolean_t);
5603859Sml29623 
5613859Sml29623 
5623859Sml29623 
5633859Sml29623 
5643859Sml29623 /*
5653859Sml29623  * npi_rxdma_rdc_rcr_flush
5663859Sml29623  * Forces RX completion ring update
5673859Sml29623  *
5683859Sml29623  * Inputs:
5693859Sml29623  *	rdc:		RX DMA Channel number
5703859Sml29623  *
5713859Sml29623  * Return:
5723859Sml29623  *
5733859Sml29623  */
5743859Sml29623 
5753859Sml29623 #define	npi_rxdma_rdc_rcr_flush(handle, rdc) \
5763859Sml29623 	RXDMA_REG_WRITE64(handle, RCR_FLSH_REG, rdc, \
5773859Sml29623 		    (RCR_FLSH_SET << RCR_FLSH_SHIFT))
5783859Sml29623 
5793859Sml29623 
5803859Sml29623 
5813859Sml29623 /*
5823859Sml29623  * npi_rxdma_rdc_rcr_read_update
5833859Sml29623  * Update the number of rcr packets and buffers processed
5843859Sml29623  *
5853859Sml29623  * Inputs:
5863859Sml29623  *	channel:	RX DMA Channel number
5873859Sml29623  *	num_pkts:	Number of pkts processed by SW.
5883859Sml29623  *			    A packet could constitute multiple
5893859Sml29623  *			    buffers, in case jumbo packets.
5903859Sml29623  *	num_bufs:	Number of buffer processed by SW.
5913859Sml29623  *
5923859Sml29623  * Return:
5933859Sml29623  *	NPI_FAILURE		-
5943859Sml29623  *		NPI_RXDMA_OPCODE_INVALID	-
5953859Sml29623  *		NPI_RXDMA_CHANNEL_INVALID	-
5963859Sml29623  *
5973859Sml29623  */
5983859Sml29623 
5993859Sml29623 npi_status_t npi_rxdma_rdc_rcr_read_update(npi_handle_t, uint8_t,
6003859Sml29623 				    uint16_t, uint16_t);
6013859Sml29623 /*
6023859Sml29623  * npi_rxdma_rdc_rcr_pktread_update
6033859Sml29623  * Update the number of packets processed
6043859Sml29623  *
6053859Sml29623  * Inputs:
6063859Sml29623  *	channel:	RX DMA Channel number
6073859Sml29623  *	num_pkts:	Number ofpkts processed by SW.
6083859Sml29623  *			A packet could constitute multiple
6093859Sml29623  *			buffers, in case jumbo packets.
6103859Sml29623  *
6113859Sml29623  * Return:
6123859Sml29623  *	NPI_FAILURE		-
6133859Sml29623  *		NPI_RXDMA_OPCODE_INVALID	-
6143859Sml29623  *		NPI_RXDMA_CHANNEL_INVALID	-
6153859Sml29623  *
6163859Sml29623  */
6173859Sml29623 
6183859Sml29623 npi_status_t npi_rxdma_rdc_rcr_pktread_update(npi_handle_t,
6193859Sml29623 					uint8_t, uint16_t);
6203859Sml29623 
6213859Sml29623 
6223859Sml29623 
6233859Sml29623 /*
6243859Sml29623  * npi_rxdma_rdc_rcr_bufread_update
6253859Sml29623  * Update the number of buffers processed
6263859Sml29623  *
6273859Sml29623  * Inputs:
6283859Sml29623  *	channel:		RX DMA Channel number
6293859Sml29623  *	num_bufs:	Number of buffer processed by SW. Multiple buffers
6303859Sml29623  *   could be part of a single packet.
6313859Sml29623  *
6323859Sml29623  * Return:
6333859Sml29623  *	NPI_FAILURE		-
6343859Sml29623  *		NPI_RXDMA_OPCODE_INVALID	-
6353859Sml29623  *		NPI_RXDMA_CHANNEL_INVALID	-
6363859Sml29623  *
6373859Sml29623  */
6383859Sml29623 
6393859Sml29623 npi_status_t npi_rxdma_rdc_rcr_bufread_update(npi_handle_t,
6403859Sml29623 					uint8_t, uint16_t);
6413859Sml29623 
6423859Sml29623 
6433859Sml29623 
6443859Sml29623 /*
6453859Sml29623  * npi_rxdma_rdc_rbr_kick
6463859Sml29623  * Kick RDC RBR
6473859Sml29623  *
6483859Sml29623  * Inputs:
6493859Sml29623  *	rdc:		RX DMA Channel number
6503859Sml29623  *	num_buffers:	Number of Buffers posted to the RBR
6513859Sml29623  *
6523859Sml29623  * Return:
6533859Sml29623  *
6543859Sml29623  */
6553859Sml29623 
6563859Sml29623 #define	npi_rxdma_rdc_rbr_kick(handle, rdc, num_buffers) \
6573859Sml29623 	RXDMA_REG_WRITE64(handle, RBR_KICK_REG, rdc, num_buffers)
6583859Sml29623 
6593859Sml29623 
6603859Sml29623 /*
6613859Sml29623  * npi_rxdma_rdc_rbr_head_get
6623859Sml29623  * Gets the current rbr head pointer.
6633859Sml29623  *
6643859Sml29623  * Inputs:
6653859Sml29623  *	rdc:		RX DMA Channel number
6663859Sml29623  *	hdptr		ptr to write the rbr head value
6673859Sml29623  *
6683859Sml29623  * Return:
6693859Sml29623  *
6703859Sml29623  */
6713859Sml29623 
6723859Sml29623 npi_status_t npi_rxdma_rdc_rbr_head_get(npi_handle_t,
6733859Sml29623 				    uint8_t, addr44_t  *);
6743859Sml29623 
6753859Sml29623 
6763859Sml29623 
6773859Sml29623 /*
6783859Sml29623  * npi_rxdma_rdc_rbr_stat_get
6793859Sml29623  * Returns the RBR stat. The stat consists of the
6803859Sml29623  * RX buffers in the ring. It also indicates if there
6813859Sml29623  * has been an overflow.
6823859Sml29623  *
6833859Sml29623  * Inputs:
6843859Sml29623  *	rdc:		RX DMA Channel number
6853859Sml29623  *	rbr_stat_t:	Structure to update stat
6863859Sml29623  *
6873859Sml29623  * Return:
6883859Sml29623  *
6893859Sml29623  */
6903859Sml29623 
6913859Sml29623 npi_status_t npi_rxdma_rdc_rbr_stat_get(npi_handle_t, uint8_t,
6923859Sml29623 				    rbr_stat_t *);
6933859Sml29623 
6943859Sml29623 
6953859Sml29623 
6963859Sml29623 /*
6973859Sml29623  * npi_rxdma_cfg_rdc_reset
6983859Sml29623  * Resets the RDC channel
6993859Sml29623  *
7003859Sml29623  * Inputs:
7013859Sml29623  *	rdc:		RX DMA Channel number
7023859Sml29623  *
7033859Sml29623  * Return:
7043859Sml29623  *
7053859Sml29623  */
7063859Sml29623 
7073859Sml29623 npi_status_t npi_rxdma_cfg_rdc_reset(npi_handle_t, uint8_t);
7083859Sml29623 
7093859Sml29623 
7103859Sml29623 /*
7113859Sml29623  * npi_rxdma_rdc_enable
7123859Sml29623  * Enables the RDC channel
7133859Sml29623  *
7143859Sml29623  * Inputs:
7153859Sml29623  *	rdc:		RX DMA Channel number
7163859Sml29623  *
7173859Sml29623  * Return:
7183859Sml29623  *
7193859Sml29623  */
7203859Sml29623 
7213859Sml29623 npi_status_t npi_rxdma_cfg_rdc_enable(npi_handle_t, uint8_t);
7223859Sml29623 
7233859Sml29623 /*
7243859Sml29623  * npi_rxdma_rdc_disable
7253859Sml29623  * Disables the RDC channel
7263859Sml29623  *
7273859Sml29623  * Inputs:
7283859Sml29623  *	rdc:		RX DMA Channel number
7293859Sml29623  *
7303859Sml29623  * Return:
7313859Sml29623  *
7323859Sml29623  */
7333859Sml29623 
7343859Sml29623 npi_status_t npi_rxdma_cfg_rdc_disable(npi_handle_t, uint8_t);
7353859Sml29623 
7363859Sml29623 
7373859Sml29623 /*
7383859Sml29623  * npi_rxdma_cfg_rdc_rcr_timeout()
7393859Sml29623  * Configure The RDC channel completion ring timeout.
7403859Sml29623  * If a frame has been received, an event would be
7413859Sml29623  * generated atleast at the expiration of the timeout.
7423859Sml29623  *
7433859Sml29623  * Enables timeout by default.
7443859Sml29623  *
7453859Sml29623  * Inputs:
7463859Sml29623  *	rdc:		RX DMA Channel number
7473859Sml29623  *	rcr_timeout:	Completion Ring timeout value
7483859Sml29623  *
7493859Sml29623  * Return:
7503859Sml29623  * NPI_SUCCESS
7513859Sml29623  * NPI_FAILURE
7523859Sml29623  * NPI_SW_ERR
7533859Sml29623  * NPI_HW_ERR
7543859Sml29623  *
7553859Sml29623  */
7563859Sml29623 
7573859Sml29623 npi_status_t npi_rxdma_cfg_rdc_rcr_timeout(npi_handle_t, uint8_t,
7583859Sml29623 				    uint8_t);
7593859Sml29623 
7603859Sml29623 
7613859Sml29623 /*
7623859Sml29623  * npi_rxdma_cfg_rdc_rcr_threshold()
7633859Sml29623  * Configure The RDC channel completion ring threshold.
7643859Sml29623  * An event would be If the number of frame received,
7653859Sml29623  * surpasses the threshold value
7663859Sml29623  *
7673859Sml29623  * Inputs:
7683859Sml29623  *	rdc:		RX DMA Channel number
7693859Sml29623  *	rcr_threshold:	Completion Ring Threshold count
7703859Sml29623  *
7713859Sml29623  * Return:
7723859Sml29623  * NPI_SUCCESS
7733859Sml29623  * NPI_FAILURE
7743859Sml29623  * NPI_SW_ERR
7753859Sml29623  * NPI_HW_ERR
7763859Sml29623  *
7773859Sml29623  */
7783859Sml29623 
7793859Sml29623 npi_status_t npi_rxdma_cfg_rdc_rcr_threshold(npi_handle_t, uint8_t,
7803859Sml29623 				    uint16_t);
7813859Sml29623 
7823859Sml29623 
7833859Sml29623 npi_status_t npi_rxdma_cfg_rdc_rcr_timeout_disable(npi_handle_t, uint8_t);
7843859Sml29623 
7853859Sml29623 typedef struct _rdc_error_stat_t {
7863859Sml29623 	uint8_t fault:1;
7873859Sml29623     uint8_t	multi_fault:1;
7883859Sml29623     uint8_t	rbr_fault:1;
7893859Sml29623     uint8_t	buff_fault:1;
7903859Sml29623     uint8_t	rcr_fault:1;
7913859Sml29623 	addr44_t fault_addr;
7923859Sml29623 } rdc_error_stat_t;
7933859Sml29623 
7943859Sml29623 #if OLD
7953859Sml29623 /*
7963859Sml29623  * npi_rxdma_rdc_error_stat_get
7973859Sml29623  * Gets the current Error stat for the RDC.
7983859Sml29623  *
7993859Sml29623  * Inputs:
8003859Sml29623  *	rdc:		RX DMA Channel number
8013859Sml29623  *	error_stat	Structure to write current RDC Error stat
8023859Sml29623  *
8033859Sml29623  * Return:
8043859Sml29623  *
8053859Sml29623  */
8063859Sml29623 
8073859Sml29623 npi_status_t npi_rxdma_rdc_error_stat_get(npi_handle_t,
8083859Sml29623 				    uint8_t, rdc_error_stat_t *);
8093859Sml29623 
8103859Sml29623 #endif
8113859Sml29623 
8123859Sml29623 /*
8133859Sml29623  * npi_rxdma_rdc_rcr_tail_get
8143859Sml29623  * Gets the current RCR tail address for the RDC.
8153859Sml29623  *
8163859Sml29623  * Inputs:
8173859Sml29623  *	rdc:		RX DMA Channel number
8183859Sml29623  *	tail_addr	Structure to write current RDC RCR tail address
8193859Sml29623  *
8203859Sml29623  * Return:
8213859Sml29623  *
8223859Sml29623  */
8233859Sml29623 
8243859Sml29623 npi_status_t npi_rxdma_rdc_rcr_tail_get(npi_handle_t,
8253859Sml29623 				    uint8_t, addr44_t *);
8263859Sml29623 
8273859Sml29623 
8283859Sml29623 npi_status_t npi_rxdma_rdc_rcr_qlen_get(npi_handle_t,
8293859Sml29623 				    uint8_t, uint16_t *);
8303859Sml29623 
8313859Sml29623 
8323859Sml29623 
8333859Sml29623 typedef struct _rdc_discard_stat_t {
8343859Sml29623     uint8_t	nobuf_ovflow;
8353859Sml29623     uint8_t	red_ovflow;
8363859Sml29623     uint32_t	nobuf_discard;
8373859Sml29623     uint32_t	red_discard;
8383859Sml29623 } rdc_discard_stat_t;
8393859Sml29623 
8403859Sml29623 
8413859Sml29623 /*
8423859Sml29623  * npi_rxdma_rdc_discard_stat_get
8433859Sml29623  * Gets the current discrad stats for the RDC.
8443859Sml29623  *
8453859Sml29623  * Inputs:
8463859Sml29623  *	rdc:		RX DMA Channel number
8473859Sml29623  *	rcr_stat	Structure to write current RDC discard stat
8483859Sml29623  *
8493859Sml29623  * Return:
8503859Sml29623  *
8513859Sml29623  */
8523859Sml29623 
8533859Sml29623 npi_status_t npi_rxdma_rdc_discard_stat_get(npi_handle_t,
8543859Sml29623 				    uint8_t, rdc_discard_stat_t);
8553859Sml29623 
8563859Sml29623 
8573859Sml29623 /*
8583859Sml29623  * npi_rx_port_discard_stat_get
8593859Sml29623  * Gets the current input (IPP) discrad stats for the rx port.
8603859Sml29623  *
8613859Sml29623  * Inputs:
8623859Sml29623  *	rdc:		RX DMA Channel number
8633859Sml29623  *	rx_disc_cnt_t	Structure to write current RDC discard stat
8643859Sml29623  *
8653859Sml29623  * Return:
8663859Sml29623  *
8673859Sml29623  */
8683859Sml29623 
8693859Sml29623 npi_status_t npi_rx_port_discard_stat_get(npi_handle_t,
8703859Sml29623 				    uint8_t,
8713859Sml29623 				    rx_disc_cnt_t *);
8723859Sml29623 
8733859Sml29623 
8743859Sml29623 /*
8753859Sml29623  * npi_rxdma_red_discard_stat_get
8763859Sml29623  * Gets the current discrad count due RED
8773859Sml29623  * The counter overflow bit is cleared, if it has been set.
8783859Sml29623  *
8793859Sml29623  * Inputs:
8803859Sml29623  *	rdc:		RX DMA Channel number
8813859Sml29623  *	rx_disc_cnt_t	Structure to write current RDC discard stat
8823859Sml29623  *
8833859Sml29623  * Return:
8843859Sml29623  * NPI_SUCCESS
8853859Sml29623  * NPI_RXDMA_RDC_INVALID
8863859Sml29623  *
8873859Sml29623  */
8883859Sml29623 
8893859Sml29623 npi_status_t npi_rxdma_red_discard_stat_get(npi_handle_t, uint8_t,
8903859Sml29623 				    rx_disc_cnt_t *);
8913859Sml29623 
8923859Sml29623 
8933859Sml29623 
8943859Sml29623 /*
8953859Sml29623  * npi_rxdma_red_discard_oflow_clear
8963859Sml29623  * Clear RED discard counter overflow bit
8973859Sml29623  *
8983859Sml29623  * Inputs:
8993859Sml29623  *	rdc:		RX DMA Channel number
9003859Sml29623  *
9013859Sml29623  * Return:
9023859Sml29623  * NPI_SUCCESS
9033859Sml29623  * NPI_RXDMA_RDC_INVALID
9043859Sml29623  *
9053859Sml29623  */
9063859Sml29623 
9073859Sml29623 npi_status_t npi_rxdma_red_discard_oflow_clear(npi_handle_t,
9083859Sml29623 					uint8_t);
9093859Sml29623 
9103859Sml29623 
9113859Sml29623 
9123859Sml29623 
9133859Sml29623 /*
9143859Sml29623  * npi_rxdma_misc_discard_stat_get
9153859Sml29623  * Gets the current discrad count for the rdc due to
9163859Sml29623  * buffer pool empty
9173859Sml29623  * The counter overflow bit is cleared, if it has been set.
9183859Sml29623  *
9193859Sml29623  * Inputs:
9203859Sml29623  *	rdc:		RX DMA Channel number
9213859Sml29623  *	rx_disc_cnt_t	Structure to write current RDC discard stat
9223859Sml29623  *
9233859Sml29623  * Return:
9243859Sml29623  * NPI_SUCCESS
9253859Sml29623  * NPI_RXDMA_RDC_INVALID
9263859Sml29623  *
9273859Sml29623  */
9283859Sml29623 
9293859Sml29623 npi_status_t npi_rxdma_misc_discard_stat_get(npi_handle_t, uint8_t,
9303859Sml29623 				    rx_disc_cnt_t *);
9313859Sml29623 
9323859Sml29623 
9333859Sml29623 
9343859Sml29623 /*
9353859Sml29623  * npi_rxdma_red_discard_oflow_clear
9363859Sml29623  * Clear RED discard counter overflow bit
9373859Sml29623  * clear the overflow bit for  buffer pool empty discrad counter
9383859Sml29623  * for the rdc
9393859Sml29623  *
9403859Sml29623  *
9413859Sml29623  * Inputs:
9423859Sml29623  *	rdc:		RX DMA Channel number
9433859Sml29623  *
9443859Sml29623  * Return:
9453859Sml29623  * NPI_SUCCESS
9463859Sml29623  * NPI_RXDMA_RDC_INVALID
9473859Sml29623  *
9483859Sml29623  */
9493859Sml29623 
9503859Sml29623 npi_status_t npi_rxdma_misc_discard_oflow_clear(npi_handle_t,
9513859Sml29623 					uint8_t);
9523859Sml29623 
9533859Sml29623 
9543859Sml29623 
9553859Sml29623 /*
9563859Sml29623  * npi_rxdma_ring_perr_stat_get
9573859Sml29623  * Gets the current RDC Memory parity error
9583859Sml29623  * The counter overflow bit is cleared, if it has been set.
9593859Sml29623  *
9603859Sml29623  * Inputs:
9613859Sml29623  * pre_cnt:	Structure to write current RDC Prefetch memory
9623859Sml29623  *		Parity Error stat
9633859Sml29623  * sha_cnt:	Structure to write current RDC Shadow memory
9643859Sml29623  *		Parity Error stat
9653859Sml29623  *
9663859Sml29623  * Return:
9673859Sml29623  * NPI_SUCCESS
9683859Sml29623  * NPI_RXDMA_RDC_INVALID
9693859Sml29623  *
9703859Sml29623  */
9713859Sml29623 
9723859Sml29623 npi_status_t npi_rxdma_ring_perr_stat_get(npi_handle_t,
9733859Sml29623 				    rdmc_par_err_log_t *,
9743859Sml29623 				    rdmc_par_err_log_t *);
9753859Sml29623 
9763859Sml29623 
9773859Sml29623 /*
9783859Sml29623  * npi_rxdma_ring_perr_stat_get
9793859Sml29623  * Clear RDC Memory Parity Error counter overflow bits
9803859Sml29623  *
9813859Sml29623  * Inputs:
9823859Sml29623  * Return:
9833859Sml29623  * NPI_SUCCESS
9843859Sml29623  *
9853859Sml29623  */
9863859Sml29623 
9873859Sml29623 npi_status_t npi_rxdma_ring_perr_stat_clear(npi_handle_t);
9883859Sml29623 
9893859Sml29623 
9903859Sml29623 /* Access the RDMC Memory: used for debugging */
9913859Sml29623 
9923859Sml29623 npi_status_t npi_rxdma_rdmc_memory_io(npi_handle_t,
9933859Sml29623 			    rdmc_mem_access_t *, uint8_t);
9943859Sml29623 
9953859Sml29623 
9963859Sml29623 
9973859Sml29623 /*
9983859Sml29623  * npi_rxdma_rxctl_fifo_error_intr_set
9993859Sml29623  * Configure The RX ctrl fifo error interrupt generation
10003859Sml29623  *
10013859Sml29623  * Inputs:
10023859Sml29623  *	mask:	rx_ctl_dat_fifo_mask_t specifying the errors
10033859Sml29623  *
10043859Sml29623  * Return:
10053859Sml29623  * NPI_SUCCESS
10063859Sml29623  * NPI_FAILURE
10073859Sml29623  *
10083859Sml29623  */
10093859Sml29623 
10103859Sml29623 npi_status_t npi_rxdma_rxctl_fifo_error_intr_set(npi_handle_t,
10113859Sml29623 				    rx_ctl_dat_fifo_mask_t *);
10123859Sml29623 
10133859Sml29623 /*
10143859Sml29623  * npi_rxdma_rxctl_fifo_error_status_get
10153859Sml29623  * Read The RX ctrl fifo error Status
10163859Sml29623  *
10173859Sml29623  * Inputs:
10183859Sml29623  *	stat:	rx_ctl_dat_fifo_stat_t to read the errors to
10193859Sml29623  * valid fields in  rx_ctl_dat_fifo_stat_t structure are:
10203859Sml29623  * zcp_eop_err, ipp_eop_err, id_mismatch.
10213859Sml29623  * Return:
10223859Sml29623  * NPI_SUCCESS
10233859Sml29623  * NPI_FAILURE
10243859Sml29623  *
10253859Sml29623  */
10263859Sml29623 
10273859Sml29623 npi_status_t npi_rxdma_rxctl_fifo_error_status_get(npi_handle_t,
10283859Sml29623 				    rx_ctl_dat_fifo_stat_t *);
10293859Sml29623 
10303859Sml29623 
10313859Sml29623 /*
10323859Sml29623  * npi_rxdma_channel_mex_set():
10333859Sml29623  *	This function is called to arm the DMA channel with
10343859Sml29623  *	mailbox updating capability. Software needs to rearm
10353859Sml29623  *	for each update by writing to the control and status register.
10363859Sml29623  *
10373859Sml29623  * Parameters:
10383859Sml29623  *	handle		- NPI handle (virtualization flag must be defined).
10393859Sml29623  *	channel		- logical RXDMA channel from 0 to 23.
10403859Sml29623  *			  (If virtualization flag is not set, then
10413859Sml29623  *			   logical channel is the same as the hardware
10423859Sml29623  *			   channel number).
10433859Sml29623  *
10443859Sml29623  * Return:
10453859Sml29623  *	NPI_SUCCESS		- If enable channel with mailbox update
10463859Sml29623  *				  is complete successfully.
10473859Sml29623  *
10483859Sml29623  *	Error:
10493859Sml29623  *	NPI_FAILURE	-
10503859Sml29623  *		NPI_RXDMA_CHANNEL_INVALID -
10513859Sml29623  */
10523859Sml29623 npi_status_t npi_rxdma_channel_mex_set(npi_handle_t, uint8_t);
10533859Sml29623 
10543859Sml29623 /*
10553859Sml29623  * npi_rxdma_channel_rcrto_clear():
10563859Sml29623  *	This function is called to reset RCRTO bit to 0.
10573859Sml29623  *
10583859Sml29623  * Parameters:
10593859Sml29623  *	handle		- NPI handle (virtualization flag must be defined).
10603859Sml29623  *	channel		- logical RXDMA channel from 0 to 23.
10613859Sml29623  *			  (If virtualization flag is not set, then
10623859Sml29623  *			   logical channel is the same as the hardware
10633859Sml29623  *			   channel number).
10643859Sml29623  * Return:
10653859Sml29623  *	NPI_SUCCESS
10663859Sml29623  *
10673859Sml29623  *	Error:
10683859Sml29623  *	NPI_FAILURE	-
10693859Sml29623  *		NPI_RXDMA_CHANNEL_INVALID -
10703859Sml29623  */
10713859Sml29623 npi_status_t npi_rxdma_channel_rcrto_clear(npi_handle_t, uint8_t);
10723859Sml29623 
10733859Sml29623 /*
10743859Sml29623  * npi_rxdma_channel_pt_drop_pkt_clear():
10753859Sml29623  *	This function is called to clear the port drop packet bit (debug).
10763859Sml29623  *
10773859Sml29623  * Parameters:
10783859Sml29623  *	handle		- NPI handle (virtualization flag must be defined).
10793859Sml29623  *	channel		- logical RXDMA channel from 0 to 23.
10803859Sml29623  *			  (If virtualization flag is not set, then
10813859Sml29623  *			   logical channel is the same as the hardware
10823859Sml29623  *			   channel number).
10833859Sml29623  * Return:
10843859Sml29623  *	NPI_SUCCESS
10853859Sml29623  *
10863859Sml29623  *	Error:
10873859Sml29623  *	NPI_FAILURE	-
10883859Sml29623  *		NPI_RXDMA_CHANNEL_INVALID -
10893859Sml29623  */
10903859Sml29623 npi_status_t npi_rxdma_channel_pt_drop_pkt_clear(npi_handle_t, uint8_t);
10913859Sml29623 
10923859Sml29623 /*
10933859Sml29623  * npi_rxdma_channel_wred_drop_clear():
10943859Sml29623  *	This function is called to wred drop bit (debug only).
10953859Sml29623  *
10963859Sml29623  * Parameters:
10973859Sml29623  *	handle		- NPI handle (virtualization flag must be defined).
10983859Sml29623  *	channel		- logical RXDMA channel from 0 to 23.
10993859Sml29623  *			  (If virtualization flag is not set, then
11003859Sml29623  *			   logical channel is the same as the hardware
11013859Sml29623  *			   channel number).
11023859Sml29623  * Return:
11033859Sml29623  *	NPI_SUCCESS
11043859Sml29623  *
11053859Sml29623  *	Error:
11063859Sml29623  *	NPI_FAILURE	-
11073859Sml29623  *		NPI_RXDMA_CHANNEL_INVALID -
11083859Sml29623  */
11093859Sml29623 npi_status_t npi_rxdma_channel_wred_drop_clear(npi_handle_t, uint8_t);
11103859Sml29623 
11113859Sml29623 /*
11123859Sml29623  * npi_rxdma_channel_rcr_shfull_clear():
11133859Sml29623  *	This function is called to clear RCR shadow full bit.
11143859Sml29623  *
11153859Sml29623  * Parameters:
11163859Sml29623  *	handle		- NPI handle (virtualization flag must be defined).
11173859Sml29623  *	channel		- logical RXDMA channel from 0 to 23.
11183859Sml29623  *			  (If virtualization flag is not set, then
11193859Sml29623  *			   logical channel is the same as the hardware
11203859Sml29623  *			   channel number).
11213859Sml29623  * Return:
11223859Sml29623  *	NPI_SUCCESS
11233859Sml29623  *
11243859Sml29623  *	Error:
11253859Sml29623  *	NPI_FAILURE	-
11263859Sml29623  *		NPI_RXDMA_CHANNEL_INVALID -
11273859Sml29623  */
11283859Sml29623 npi_status_t npi_rxdma_channel_rcr_shfull_clear(npi_handle_t, uint8_t);
11293859Sml29623 
11303859Sml29623 /*
11313859Sml29623  * npi_rxdma_channel_rcrfull_clear():
11323859Sml29623  *	This function is called to clear RCR full bit.
11333859Sml29623  *
11343859Sml29623  * Parameters:
11353859Sml29623  *	handle		- NPI handle (virtualization flag must be defined).
11363859Sml29623  *	channel		- logical RXDMA channel from 0 to 23.
11373859Sml29623  *			  (If virtualization flag is not set, then
11383859Sml29623  *			   logical channel is the same as the hardware
11393859Sml29623  *			   channel number).
11403859Sml29623  * Return:
11413859Sml29623  *	NPI_SUCCESS
11423859Sml29623  *
11433859Sml29623  *	Error:
11443859Sml29623  *	NPI_FAILURE	-
11453859Sml29623  *		NPI_RXDMA_CHANNEL_INVALID -
11463859Sml29623  */
11473859Sml29623 npi_status_t npi_rxdma_channel_rcrfull_clear(npi_handle_t, uint8_t);
11483859Sml29623 
11493859Sml29623 /*
11503859Sml29623  * npi_rxdma_rbr_pre_empty_clear():
11513859Sml29623  *	This function is called to control a receive DMA channel
11523859Sml29623  *	for arming the channel with mailbox updates, resetting
11533859Sml29623  *	various event status bits (control and status register).
11543859Sml29623  *
11553859Sml29623  * Parameters:
11563859Sml29623  *	handle		- NPI handle (virtualization flag must be defined).
11573859Sml29623  *	control		- NPI defined control type supported:
11583859Sml29623  *				- RXDMA_MEX_SET
11593859Sml29623  * 				- RXDMA_RCRTO_CLEAR
11603859Sml29623  *				- RXDMA_PT_DROP_PKT_CLEAR
11613859Sml29623  *				- RXDMA_WRED_DROP_CLEAR
11623859Sml29623  *				- RXDMA_RCR_SFULL_CLEAR
11633859Sml29623  *				- RXDMA_RCR_FULL_CLEAR
11643859Sml29623  *				- RXDMA_RBR_PRE_EMPTY_CLEAR
11653859Sml29623  *	channel		- logical RXDMA channel from 0 to 23.
11663859Sml29623  *			  (If virtualization flag is not set, then
11673859Sml29623  *			   logical channel is the same as the hardware.
11683859Sml29623  * Return:
11693859Sml29623  *	NPI_SUCCESS
11703859Sml29623  *
11713859Sml29623  *	Error:
11723859Sml29623  *	NPI_FAILURE		-
11733859Sml29623  *		NPI_RXDMA_CHANNEL_INVALID -
11743859Sml29623  */
11753859Sml29623 npi_status_t npi_rxdma_channel_rbr_pre_empty_clear(npi_handle_t, uint8_t);
11763859Sml29623 
11773859Sml29623 /*
11783859Sml29623  * npi_rxdma_channel_control():
11793859Sml29623  *	This function is called to control a receive DMA channel
11803859Sml29623  *	for arming the channel with mailbox updates, resetting
11813859Sml29623  *	various event status bits (control and status register).
11823859Sml29623  *
11833859Sml29623  * Parameters:
11843859Sml29623  *	handle		- NPI handle (virtualization flag must be defined).
11853859Sml29623  *	control		- NPI defined control type supported:
11863859Sml29623  *				- RXDMA_MEX_SET
11873859Sml29623  * 				- RXDMA_RCRTO_CLEAR
11883859Sml29623  *				- RXDMA_PT_DROP_PKT_CLEAR
11893859Sml29623  *				- RXDMA_WRED_DROP_CLEAR
11903859Sml29623  *				- RXDMA_RCR_SFULL_CLEAR
11913859Sml29623  *				- RXDMA_RCR_FULL_CLEAR
11923859Sml29623  *				- RXDMA_RBR_PRE_EMPTY_CLEAR
11933859Sml29623  *	channel		- logical RXDMA channel from 0 to 23.
11943859Sml29623  *			  (If virtualization flag is not set, then
11953859Sml29623  *			   logical channel is the same as the hardware.
11963859Sml29623  * Return:
11973859Sml29623  *	NPI_SUCCESS
11983859Sml29623  *
11993859Sml29623  *	Error:
12003859Sml29623  *	NPI_FAILURE		-
12013859Sml29623  *		NPI_TXDMA_OPCODE_INVALID	-
12023859Sml29623  *		NPI_TXDMA_CHANNEL_INVALID	-
12033859Sml29623  */
12043859Sml29623 npi_status_t npi_rxdma_channel_control(npi_handle_t,
12053859Sml29623 				rxdma_cs_cntl_t, uint8_t);
12063859Sml29623 
12073859Sml29623 /*
12083859Sml29623  * npi_rxdma_control_status():
12093859Sml29623  *	This function is called to operate on the control
12103859Sml29623  *	and status register.
12113859Sml29623  *
12123859Sml29623  * Parameters:
12133859Sml29623  *	handle		- NPI handle
12143859Sml29623  *	op_mode		- OP_GET: get hardware control and status
12153859Sml29623  *			  OP_SET: set hardware control and status
12163859Sml29623  *			  OP_UPDATE: update hardware control and status.
12173859Sml29623  *			  OP_CLEAR: clear control and status register to 0s.
12183859Sml29623  *	channel		- hardware RXDMA channel from 0 to 23.
12193859Sml29623  *	cs_p		- pointer to hardware defined control and status
12203859Sml29623  *			  structure.
12213859Sml29623  * Return:
12223859Sml29623  *	NPI_SUCCESS
12233859Sml29623  *
12243859Sml29623  *	Error:
12253859Sml29623  *	NPI_FAILURE		-
12263859Sml29623  *		NPI_RXDMA_OPCODE_INVALID	-
12273859Sml29623  *		NPI_RXDMA_CHANNEL_INVALID	-
12283859Sml29623  */
12293859Sml29623 npi_status_t npi_rxdma_control_status(npi_handle_t, io_op_t,
12303859Sml29623 			uint8_t, p_rx_dma_ctl_stat_t);
12313859Sml29623 
12323859Sml29623 /*
12333859Sml29623  * npi_rxdma_event_mask():
12343859Sml29623  *	This function is called to operate on the event mask
12353859Sml29623  *	register which is used for generating interrupts.
12363859Sml29623  *
12373859Sml29623  * Parameters:
12383859Sml29623  *	handle		- NPI handle
12393859Sml29623  *	op_mode		- OP_GET: get hardware event mask
12403859Sml29623  *			  OP_SET: set hardware interrupt event masks
12413859Sml29623  *			  OP_CLEAR: clear control and status register to 0s.
12423859Sml29623  *	channel		- hardware RXDMA channel from 0 to 23.
12433859Sml29623  *	mask_p		- pointer to hardware defined event mask
12443859Sml29623  *			  structure.
12453859Sml29623  * Return:
12463859Sml29623  *	NPI_SUCCESS		- If set is complete successfully.
12473859Sml29623  *
12483859Sml29623  *	Error:
12493859Sml29623  *	NPI_FAILURE		-
12503859Sml29623  *		NPI_RXDMA_OPCODE_INVALID	-
12513859Sml29623  *		NPI_RXDMA_CHANNEL_INVALID	-
12523859Sml29623  */
12533859Sml29623 npi_status_t npi_rxdma_event_mask(npi_handle_t, io_op_t,
12543859Sml29623 		uint8_t, p_rx_dma_ent_msk_t);
12553859Sml29623 
12563859Sml29623 /*
12573859Sml29623  * npi_rxdma_event_mask_config():
12583859Sml29623  *	This function is called to operate on the event mask
12593859Sml29623  *	register which is used for generating interrupts
12603859Sml29623  *	and status register.
12613859Sml29623  *
12623859Sml29623  * Parameters:
12633859Sml29623  *	handle		- NPI handle
12643859Sml29623  *	op_mode		- OP_GET: get hardware event mask
12653859Sml29623  *			  OP_SET: set hardware interrupt event masks
12663859Sml29623  *			  OP_CLEAR: clear control and status register to 0s.
12673859Sml29623  *	channel		- hardware RXDMA channel from 0 to 23.
12683859Sml29623  *	cfgp		- pointer to NPI defined event mask
12693859Sml29623  *			  enum data type.
12703859Sml29623  * Return:
12713859Sml29623  *	NPI_SUCCESS		- If set is complete successfully.
12723859Sml29623  *
12733859Sml29623  *	Error:
12743859Sml29623  *	NPI_FAILURE		-
12753859Sml29623  *		NPI_RXDMA_OPCODE_INVALID	-
12763859Sml29623  *		NPI_RXDMA_CHANNEL_INVALID	-
12773859Sml29623  */
12783859Sml29623 npi_status_t npi_rxdma_event_mask_config(npi_handle_t, io_op_t,
12793859Sml29623 		uint8_t, rxdma_ent_msk_cfg_t *);
12803859Sml29623 
12813859Sml29623 
12823859Sml29623 /*
12833859Sml29623  * npi_rxdma_dump_rdc_regs
12843859Sml29623  * Dumps the contents of rdc csrs and fzc registers
12853859Sml29623  *
12863859Sml29623  * Input:
12873859Sml29623  *         rdc:      RX DMA number
12883859Sml29623  *
12893859Sml29623  * return:
12903859Sml29623  *     NPI_SUCCESS
12913859Sml29623  *     NPI_FAILURE
12923859Sml29623  *     NPI_RXDMA_RDC_INVALID
12933859Sml29623  *
12943859Sml29623  */
12953859Sml29623 
12963859Sml29623 npi_status_t npi_rxdma_dump_rdc_regs(npi_handle_t, uint8_t);
12973859Sml29623 
12983859Sml29623 
12993859Sml29623 /*
13003859Sml29623  * npi_rxdma_dump_fzc_regs
13013859Sml29623  * Dumps the contents of rdc csrs and fzc registers
13023859Sml29623  *
13033859Sml29623  * Input:
13043859Sml29623  *         rdc:      RX DMA number
13053859Sml29623  *
13063859Sml29623  * return:
13073859Sml29623  *     NPI_SUCCESS
13083859Sml29623  *     NPI_FAILURE
13093859Sml29623  *     NPI_RXDMA_RDC_INVALID
13103859Sml29623  *
13113859Sml29623  */
13123859Sml29623 
13133859Sml29623 npi_status_t npi_rxdma_dump_fzc_regs(npi_handle_t);
13143859Sml29623 
13153859Sml29623 npi_status_t npi_rxdma_channel_rbr_empty_clear(npi_handle_t,
13163859Sml29623 							uint8_t);
13173859Sml29623 npi_status_t npi_rxdma_rxctl_fifo_error_intr_get(npi_handle_t,
13183859Sml29623 				rx_ctl_dat_fifo_stat_t *);
13193859Sml29623 
13203859Sml29623 npi_status_t npi_rxdma_rxctl_fifo_error_intr_set(npi_handle_t,
13213859Sml29623 				rx_ctl_dat_fifo_mask_t *);
13223859Sml29623 
13233859Sml29623 npi_status_t npi_rxdma_dump_rdc_table(npi_handle_t, uint8_t);
13243859Sml29623 #ifdef	__cplusplus
13253859Sml29623 }
13263859Sml29623 #endif
13273859Sml29623 
13283859Sml29623 #endif	/* _NPI_RXDMA_H */
1329