xref: /titanic_41/usr/src/uts/common/io/hxge/hpi_txdma.h (revision fe930412c257f961ae67039de3b164b83717976a)
13dec9fcdSqs148142 /*
23dec9fcdSqs148142  * CDDL HEADER START
33dec9fcdSqs148142  *
43dec9fcdSqs148142  * The contents of this file are subject to the terms of the
53dec9fcdSqs148142  * Common Development and Distribution License (the "License").
63dec9fcdSqs148142  * You may not use this file except in compliance with the License.
73dec9fcdSqs148142  *
83dec9fcdSqs148142  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93dec9fcdSqs148142  * or http://www.opensolaris.org/os/licensing.
103dec9fcdSqs148142  * See the License for the specific language governing permissions
113dec9fcdSqs148142  * and limitations under the License.
123dec9fcdSqs148142  *
133dec9fcdSqs148142  * When distributing Covered Code, include this CDDL HEADER in each
143dec9fcdSqs148142  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153dec9fcdSqs148142  * If applicable, add the following below this CDDL HEADER, with the
163dec9fcdSqs148142  * fields enclosed by brackets "[]" replaced with your own identifying
173dec9fcdSqs148142  * information: Portions Copyright [yyyy] [name of copyright owner]
183dec9fcdSqs148142  *
193dec9fcdSqs148142  * CDDL HEADER END
203dec9fcdSqs148142  */
213dec9fcdSqs148142 /*
223dec9fcdSqs148142  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
233dec9fcdSqs148142  * Use is subject to license terms.
243dec9fcdSqs148142  */
253dec9fcdSqs148142 
263dec9fcdSqs148142 #ifndef _HPI_TXDMA_H
273dec9fcdSqs148142 #define	_HPI_TXDMA_H
283dec9fcdSqs148142 
293dec9fcdSqs148142 #pragma ident	"%Z%%M%	%I%	%E% SMI"
303dec9fcdSqs148142 
313dec9fcdSqs148142 #ifdef	__cplusplus
323dec9fcdSqs148142 extern "C" {
333dec9fcdSqs148142 #endif
343dec9fcdSqs148142 
353dec9fcdSqs148142 #include <hpi.h>
363dec9fcdSqs148142 #include <hxge_txdma_hw.h>
373dec9fcdSqs148142 #include <hxge_tdc_hw.h>
383dec9fcdSqs148142 
393dec9fcdSqs148142 typedef	enum _txdma_cs_cntl_e {
403dec9fcdSqs148142 	TXDMA_INIT_RESET	= 0x1,
413dec9fcdSqs148142 	TXDMA_INIT_START	= 0x2,
423dec9fcdSqs148142 	TXDMA_START		= 0x3,
433dec9fcdSqs148142 	TXDMA_RESET		= 0x4,
443dec9fcdSqs148142 	TXDMA_STOP		= 0x5,
453dec9fcdSqs148142 	TXDMA_MBOX_ENABLE	= 0x6
463dec9fcdSqs148142 } txdma_cs_cntl_t;
473dec9fcdSqs148142 
483dec9fcdSqs148142 #define	HXGE_TXDMA_OFFSET(x, v, channel) (x + \
493dec9fcdSqs148142 		(!v ? DMC_OFFSET(channel) : TDMC_PIOVADDR_OFFSET(channel)))
503dec9fcdSqs148142 /*
513dec9fcdSqs148142  * PIO macros to read and write the transmit registers.
523dec9fcdSqs148142  */
533dec9fcdSqs148142 #define	TXDMA_REG_READ64(handle, reg, channel, val_p)	\
543dec9fcdSqs148142 		HXGE_REG_RD64(handle, \
553dec9fcdSqs148142 		(HXGE_TXDMA_OFFSET(reg, handle.is_vraddr, channel)), val_p)
563dec9fcdSqs148142 
573dec9fcdSqs148142 #define	TXDMA_REG_WRITE64(handle, reg, channel, data)	\
583dec9fcdSqs148142 		HXGE_REG_WR64(handle, \
593dec9fcdSqs148142 		HXGE_TXDMA_OFFSET(reg, handle.is_vraddr, channel), data)
603dec9fcdSqs148142 
613dec9fcdSqs148142 #define	HPI_TXDMA_GATHER_INDEX(index)	\
623dec9fcdSqs148142 		((index <= TX_MAX_GATHER_POINTERS)) ? HPI_SUCCESS : \
633dec9fcdSqs148142 		(HPI_TXDMA_GATHER_INVALID)
643dec9fcdSqs148142 
653dec9fcdSqs148142 /*
663dec9fcdSqs148142  * Transmit HPI error codes
673dec9fcdSqs148142  */
683dec9fcdSqs148142 #define	TXDMA_ER_ST			(TXDMA_BLK_ID << HPI_BLOCK_ID_SHIFT)
693dec9fcdSqs148142 #define	TXDMA_ID_SHIFT(n)		(n << HPI_PORT_CHAN_SHIFT)
703dec9fcdSqs148142 
713dec9fcdSqs148142 #define	TXDMA_HW_STOP_FAILED		(HPI_BK_HW_ER_START | 0x1)
723dec9fcdSqs148142 #define	TXDMA_HW_RESUME_FAILED		(HPI_BK_HW_ER_START | 0x2)
733dec9fcdSqs148142 
743dec9fcdSqs148142 #define	TXDMA_GATHER_INVALID		(HPI_BK_ERROR_START | 0x1)
753dec9fcdSqs148142 #define	TXDMA_XFER_LEN_INVALID		(HPI_BK_ERROR_START | 0x2)
763dec9fcdSqs148142 
773dec9fcdSqs148142 #define	HPI_TXDMA_OPCODE_INVALID(n)	(TXDMA_ID_SHIFT(n) |	\
783dec9fcdSqs148142 					TXDMA_ER_ST | OPCODE_INVALID)
793dec9fcdSqs148142 
803dec9fcdSqs148142 #define	HPI_TXDMA_FUNC_INVALID(n)	(TXDMA_ID_SHIFT(n) |	\
813dec9fcdSqs148142 					TXDMA_ER_ST | PORT_INVALID)
823dec9fcdSqs148142 #define	HPI_TXDMA_CHANNEL_INVALID(n)	(TXDMA_ID_SHIFT(n) |	\
833dec9fcdSqs148142 					TXDMA_ER_ST | CHANNEL_INVALID)
843dec9fcdSqs148142 
853dec9fcdSqs148142 #define	HPI_TXDMA_PAGE_INVALID(n)	(TXDMA_ID_SHIFT(n) |	\
863dec9fcdSqs148142 					TXDMA_ER_ST | LOGICAL_PAGE_INVALID)
873dec9fcdSqs148142 
883dec9fcdSqs148142 #define	HPI_TXDMA_REGISTER_INVALID	(TXDMA_ER_ST | REGISTER_INVALID)
893dec9fcdSqs148142 #define	HPI_TXDMA_COUNTER_INVALID	(TXDMA_ER_ST | COUNTER_INVALID)
903dec9fcdSqs148142 #define	HPI_TXDMA_CONFIG_INVALID	(TXDMA_ER_ST | CONFIG_INVALID)
913dec9fcdSqs148142 
923dec9fcdSqs148142 
933dec9fcdSqs148142 #define	HPI_TXDMA_GATHER_INVALID	(TXDMA_ER_ST | TXDMA_GATHER_INVALID)
943dec9fcdSqs148142 #define	HPI_TXDMA_XFER_LEN_INVALID	(TXDMA_ER_ST | TXDMA_XFER_LEN_INVALID)
953dec9fcdSqs148142 
963dec9fcdSqs148142 #define	HPI_TXDMA_RESET_FAILED		(TXDMA_ER_ST | RESET_FAILED)
973dec9fcdSqs148142 #define	HPI_TXDMA_STOP_FAILED		(TXDMA_ER_ST | TXDMA_HW_STOP_FAILED)
983dec9fcdSqs148142 #define	HPI_TXDMA_RESUME_FAILED		(TXDMA_ER_ST | TXDMA_HW_RESUME_FAILED)
993dec9fcdSqs148142 
1003dec9fcdSqs148142 /*
1013dec9fcdSqs148142  * Transmit DMA Channel HPI Prototypes.
1023dec9fcdSqs148142  */
1033dec9fcdSqs148142 hpi_status_t hpi_txdma_log_page_handle_set(hpi_handle_t handle,
1043dec9fcdSqs148142     uint8_t channel, tdc_page_handle_t *hdl_p);
1053dec9fcdSqs148142 hpi_status_t hpi_txdma_channel_reset(hpi_handle_t handle, uint8_t channel);
1063dec9fcdSqs148142 hpi_status_t hpi_txdma_channel_init_enable(hpi_handle_t handle,
1073dec9fcdSqs148142     uint8_t channel);
1083dec9fcdSqs148142 hpi_status_t hpi_txdma_channel_enable(hpi_handle_t handle, uint8_t channel);
1093dec9fcdSqs148142 hpi_status_t hpi_txdma_channel_disable(hpi_handle_t handle, uint8_t channel);
1103dec9fcdSqs148142 hpi_status_t hpi_txdma_channel_mbox_enable(hpi_handle_t handle,
1113dec9fcdSqs148142     uint8_t channel);
1123dec9fcdSqs148142 hpi_status_t hpi_txdma_channel_control(hpi_handle_t handle,
1133dec9fcdSqs148142     txdma_cs_cntl_t control, uint8_t channel);
1143dec9fcdSqs148142 hpi_status_t hpi_txdma_control_status(hpi_handle_t handle, io_op_t op_mode,
1153dec9fcdSqs148142     uint8_t channel, tdc_stat_t *cs_p);
1163dec9fcdSqs148142 
1173dec9fcdSqs148142 hpi_status_t hpi_txdma_event_mask(hpi_handle_t handle, io_op_t op_mode,
1183dec9fcdSqs148142     uint8_t channel, tdc_int_mask_t *mask_p);
1193dec9fcdSqs148142 
1203dec9fcdSqs148142 hpi_status_t hpi_txdma_ring_config(hpi_handle_t handle, io_op_t op_mode,
1213dec9fcdSqs148142     uint8_t channel, uint64_t *reg_data);
1223dec9fcdSqs148142 hpi_status_t hpi_txdma_mbox_config(hpi_handle_t handle, io_op_t op_mode,
1233dec9fcdSqs148142     uint8_t channel, uint64_t *mbox_addr);
1243dec9fcdSqs148142 hpi_status_t hpi_txdma_desc_gather_set(hpi_handle_t handle,
1253dec9fcdSqs148142     p_tx_desc_t desc_p, uint8_t gather_index,
1263dec9fcdSqs148142     boolean_t mark, uint8_t ngathers,
1273dec9fcdSqs148142     uint64_t dma_ioaddr, uint32_t transfer_len);
128*fe930412Sqs148142 hpi_status_t hpi_txdma_control_stop_wait(hpi_handle_t handle,
129*fe930412Sqs148142     uint8_t channel);
1303dec9fcdSqs148142 
1313dec9fcdSqs148142 hpi_status_t hpi_txdma_desc_set_xfer_len(hpi_handle_t handle,
1323dec9fcdSqs148142     p_tx_desc_t desc_p, uint32_t transfer_len);
1333dec9fcdSqs148142 
1343dec9fcdSqs148142 hpi_status_t hpi_txdma_desc_set_zero(hpi_handle_t handle, uint16_t entries);
1353dec9fcdSqs148142 hpi_status_t hpi_txdma_ring_head_get(hpi_handle_t handle, uint8_t channel,
1363dec9fcdSqs148142     tdc_tdr_head_t *hdl_p);
1373dec9fcdSqs148142 void hpi_txdma_dump_desc_one(hpi_handle_t handle, p_tx_desc_t desc_p,
1383dec9fcdSqs148142     int desc_index);
1393dec9fcdSqs148142 
1403dec9fcdSqs148142 #ifdef	__cplusplus
1413dec9fcdSqs148142 }
1423dec9fcdSqs148142 #endif
1433dec9fcdSqs148142 
1443dec9fcdSqs148142 #endif	/* _HPI_TXDMA_H */
145