xref: /illumos-gate/usr/src/uts/common/io/hxge/hpi_txdma.h (revision d227ea68051b5404410ee1880d0bba1ebb33a4cc)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _HPI_TXDMA_H
27 #define	_HPI_TXDMA_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <hpi.h>
34 #include <hxge_txdma_hw.h>
35 #include <hxge_tdc_hw.h>
36 
37 typedef	enum _txdma_cs_cntl_e {
38 	TXDMA_INIT_RESET	= 0x1,
39 	TXDMA_INIT_START	= 0x2,
40 	TXDMA_START		= 0x3,
41 	TXDMA_RESET		= 0x4,
42 	TXDMA_STOP		= 0x5,
43 	TXDMA_MBOX_ENABLE	= 0x6
44 } txdma_cs_cntl_t;
45 
46 #define	HXGE_TXDMA_OFFSET(x, v, channel) (x + \
47 		(!v ? DMC_OFFSET(channel) : TDMC_PIOVADDR_OFFSET(channel)))
48 /*
49  * PIO macros to read and write the transmit registers.
50  */
51 #define	TXDMA_REG_READ64(handle, reg, channel, val_p)	\
52 		HXGE_REG_RD64(handle, \
53 		(HXGE_TXDMA_OFFSET(reg, handle.is_vraddr, channel)), val_p)
54 
55 #define	TXDMA_REG_WRITE64(handle, reg, channel, data)	\
56 		HXGE_REG_WR64(handle, \
57 		HXGE_TXDMA_OFFSET(reg, handle.is_vraddr, channel), data)
58 
59 #define	HPI_TXDMA_GATHER_INDEX(index)	\
60 		((index <= TX_MAX_GATHER_POINTERS)) ? HPI_SUCCESS : \
61 		(HPI_TXDMA_GATHER_INVALID)
62 
63 /*
64  * Transmit HPI error codes
65  */
66 #define	TXDMA_ER_ST			(TXDMA_BLK_ID << HPI_BLOCK_ID_SHIFT)
67 #define	TXDMA_ID_SHIFT(n)		(n << HPI_PORT_CHAN_SHIFT)
68 
69 #define	TXDMA_HW_STOP_FAILED		(HPI_BK_HW_ER_START | 0x1)
70 #define	TXDMA_HW_RESUME_FAILED		(HPI_BK_HW_ER_START | 0x2)
71 
72 #define	TXDMA_GATHER_INVALID		(HPI_BK_ERROR_START | 0x1)
73 #define	TXDMA_XFER_LEN_INVALID		(HPI_BK_ERROR_START | 0x2)
74 
75 #define	HPI_TXDMA_OPCODE_INVALID(n)	(TXDMA_ID_SHIFT(n) |	\
76 					TXDMA_ER_ST | OPCODE_INVALID)
77 
78 #define	HPI_TXDMA_FUNC_INVALID(n)	(TXDMA_ID_SHIFT(n) |	\
79 					TXDMA_ER_ST | PORT_INVALID)
80 #define	HPI_TXDMA_CHANNEL_INVALID(n)	(TXDMA_ID_SHIFT(n) |	\
81 					TXDMA_ER_ST | CHANNEL_INVALID)
82 
83 #define	HPI_TXDMA_PAGE_INVALID(n)	(TXDMA_ID_SHIFT(n) |	\
84 					TXDMA_ER_ST | LOGICAL_PAGE_INVALID)
85 
86 #define	HPI_TXDMA_REGISTER_INVALID	(TXDMA_ER_ST | REGISTER_INVALID)
87 #define	HPI_TXDMA_COUNTER_INVALID	(TXDMA_ER_ST | COUNTER_INVALID)
88 #define	HPI_TXDMA_CONFIG_INVALID	(TXDMA_ER_ST | CONFIG_INVALID)
89 
90 
91 #define	HPI_TXDMA_GATHER_INVALID	(TXDMA_ER_ST | TXDMA_GATHER_INVALID)
92 #define	HPI_TXDMA_XFER_LEN_INVALID	(TXDMA_ER_ST | TXDMA_XFER_LEN_INVALID)
93 
94 #define	HPI_TXDMA_RESET_FAILED		(TXDMA_ER_ST | RESET_FAILED)
95 #define	HPI_TXDMA_STOP_FAILED		(TXDMA_ER_ST | TXDMA_HW_STOP_FAILED)
96 #define	HPI_TXDMA_RESUME_FAILED		(TXDMA_ER_ST | TXDMA_HW_RESUME_FAILED)
97 
98 /*
99  * Transmit DMA Channel HPI Prototypes.
100  */
101 hpi_status_t hpi_txdma_log_page_handle_set(hpi_handle_t handle,
102     uint8_t channel, tdc_page_handle_t *hdl_p);
103 hpi_status_t hpi_txdma_channel_reset(hpi_handle_t handle, uint8_t channel);
104 hpi_status_t hpi_txdma_channel_init_enable(hpi_handle_t handle,
105     uint8_t channel);
106 hpi_status_t hpi_txdma_channel_enable(hpi_handle_t handle, uint8_t channel);
107 hpi_status_t hpi_txdma_channel_disable(hpi_handle_t handle, uint8_t channel);
108 hpi_status_t hpi_txdma_channel_mbox_enable(hpi_handle_t handle,
109     uint8_t channel);
110 hpi_status_t hpi_txdma_channel_control(hpi_handle_t handle,
111     txdma_cs_cntl_t control, uint8_t channel);
112 hpi_status_t hpi_txdma_control_status(hpi_handle_t handle, io_op_t op_mode,
113     uint8_t channel, tdc_stat_t *cs_p);
114 
115 hpi_status_t hpi_txdma_event_mask(hpi_handle_t handle, io_op_t op_mode,
116     uint8_t channel, tdc_int_mask_t *mask_p);
117 
118 hpi_status_t hpi_txdma_ring_config(hpi_handle_t handle, io_op_t op_mode,
119     uint8_t channel, uint64_t *reg_data);
120 hpi_status_t hpi_txdma_mbox_config(hpi_handle_t handle, io_op_t op_mode,
121     uint8_t channel, uint64_t *mbox_addr);
122 hpi_status_t hpi_txdma_desc_gather_set(hpi_handle_t handle,
123     p_tx_desc_t desc_p, uint8_t gather_index,
124     boolean_t mark, uint8_t ngathers,
125     uint64_t dma_ioaddr, uint32_t transfer_len);
126 hpi_status_t hpi_txdma_control_stop_wait(hpi_handle_t handle,
127     uint8_t channel);
128 
129 hpi_status_t hpi_txdma_desc_set_xfer_len(hpi_handle_t handle,
130     p_tx_desc_t desc_p, uint32_t transfer_len);
131 
132 hpi_status_t hpi_txdma_desc_set_zero(hpi_handle_t handle, uint16_t entries);
133 hpi_status_t hpi_txdma_ring_head_get(hpi_handle_t handle, uint8_t channel,
134     tdc_tdr_head_t *hdl_p);
135 void hpi_txdma_dump_desc_one(hpi_handle_t handle, p_tx_desc_t desc_p,
136     int desc_index);
137 
138 #ifdef	__cplusplus
139 }
140 #endif
141 
142 #endif	/* _HPI_TXDMA_H */
143