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 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_HXGE_HXGE_TXDMA_HW_H
28 #define	_SYS_HXGE_HXGE_TXDMA_HW_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include <hxge_defs.h>
35 #include <hxge_tdc_hw.h>
36 
37 /*
38  * Transmit Packet Descriptor Structure
39  * 	See Hydra PRM (Chapter 8, Section 8.1.1)
40  */
41 typedef union _tx_desc_t {
42 	uint64_t value;
43 	struct {
44 #if defined(_BIG_ENDIAN)
45 		uint32_t	sop:1;
46 		uint32_t	mark:1;
47 		uint32_t	num_ptr:4;
48 		uint32_t	rsvd:1;
49 		uint32_t	tr_len:13;
50 		uint32_t	sad:12;
51 		uint32_t	sad_l:32;
52 #else
53 		uint32_t	sad_l:32;
54 		uint32_t	sad:12;
55 		uint32_t	tr_len:13;
56 		uint32_t	rsvd:1;
57 		uint32_t	num_ptr:4;
58 		uint32_t	mark:1;
59 		uint32_t	sop:1;
60 #endif
61 	} bits;
62 } tx_desc_t, *p_tx_desc_t;
63 
64 /*
65  * TDC Ring Configuration
66  */
67 #define	TDC_TDR_CFG_STADDR_SHIFT	6	/* bits 18:6 */
68 #define	TDC_TDR_CFG_STADDR_MASK		0x000000000007FFC0ULL
69 #define	TDC_TDR_CFG_ADDR_MASK		0x00000FFFFFFFFFC0ULL
70 #define	TDC_TDR_CFG_STADDR_BASE_SHIFT	19	/* bits 43:19 */
71 #define	TDC_TDR_CFG_STADDR_BASE_MASK	0x00000FFFFFF80000ULL
72 #define	TDC_TDR_CFG_LEN_SHIFT		53	/* bits 63:53 */
73 #define	TDC_TDR_CFG_LEN_MASK		0xFFE0000000000000ULL
74 #define	TDC_TDR_RST_SHIFT		46
75 #define	TDC_TDR_RST_MASK		0x0000400000000000ULL
76 
77 /*
78  * Transmit Event Mask
79  */
80 #define	TDC_INT_MASK_MK_MASK		0x0000000000008000ULL
81 
82 /*
83  * Trasnmit Mailbox High
84  */
85 #define	TDC_MBH_SHIFT			0	/* bit 11:0 */
86 #define	TDC_MBH_ADDR_SHIFT		32	/* bit 43:32 */
87 #define	TDC_MBH_MASK			0x0000000000000FFFULL
88 
89 /*
90  * Trasnmit Mailbox Low
91  */
92 #define	TDC_MBL_SHIFT			6	/* bit 31:6 */
93 #define	TDC_MBL_MASK			0x00000000FFFFFFC0ULL
94 
95 #define	TXDMA_MAILBOX_BYTE_LENGTH	64
96 #define	TXDMA_MAILBOX_UNUSED		24
97 
98 typedef struct _txdma_mailbox_t {
99 	tdc_stat_t		tx_cs;			/* 8 bytes */
100 	tdc_tdr_pre_head_t	tx_dma_pre_st;		/* 8 bytes */
101 	tdc_tdr_head_t		tx_ring_hdl;		/* 8 bytes */
102 	tdc_tdr_kick_t		tx_ring_kick;		/* 8 bytes */
103 	uint32_t		tx_rng_err_logh;	/* 4 bytes */
104 	uint32_t		tx_rng_err_logl;	/* 4 bytes */
105 	uint8_t			resv[TXDMA_MAILBOX_UNUSED];
106 } txdma_mailbox_t, *p_txdma_mailbox_t;
107 
108 /*
109  * Internal Transmit Packet Format (16 bytes)
110  */
111 #define	TX_PKT_HEADER_SIZE			16
112 #define	TX_MAX_GATHER_POINTERS			15
113 #define	TX_GATHER_POINTERS_THRESHOLD		8
114 /*
115  * There is bugs in the hardware
116  * and max sfter len is changed from 4096 to 4076.
117  *
118  * Jumbo from 9500 to 9216
119  */
120 #define	TX_MAX_TRANSFER_LENGTH			4076
121 #define	TX_JUMBO_MTU				9216
122 
123 #define	TX_PKT_HEADER_PAD_SHIFT			0	/* bit 2:0 */
124 #define	TX_PKT_HEADER_PAD_MASK			0x0000000000000007ULL
125 #define	TX_PKT_HEADER_TOT_XFER_LEN_SHIFT	16	/* bit 16:29 */
126 #define	TX_PKT_HEADER_TOT_XFER_LEN_MASK		0x000000000000FFF8ULL
127 #define	TX_PKT_HEADER_L4STUFF_SHIFT		32	/* bit 37:32 */
128 #define	TX_PKT_HEADER_L4STUFF_MASK		0x0000003F00000000ULL
129 #define	TX_PKT_HEADER_L4START_SHIFT		40	/* bit 45:40 */
130 #define	TX_PKT_HEADER_L4START_MASK		0x00003F0000000000ULL
131 #define	TX_PKT_HEADER_L3START_SHIFT		48	/* bit 45:40 */
132 #define	TX_PKT_HEADER_IHL_SHIFT			52	/* bit 52 */
133 #define	TX_PKT_HEADER_VLAN__SHIFT		56	/* bit 56 */
134 #define	TX_PKT_HEADER_TCP_UDP_CRC32C_SHIFT	57	/* bit 57 */
135 #define	TX_PKT_HEADER_LLC_SHIFT			57	/* bit 57 */
136 #define	TX_PKT_HEADER_TCP_UDP_CRC32C_SET	0x0200000000000000ULL
137 #define	TX_PKT_HEADER_TCP_UDP_CRC32C_MASK	0x0200000000000000ULL
138 #define	TX_PKT_HEADER_L4_PROTO_OP_SHIFT		2	/* bit 59:58 */
139 #define	TX_PKT_HEADER_L4_PROTO_OP_MASK		0x0C00000000000000ULL
140 #define	TX_PKT_HEADER_V4_HDR_CS_SHIFT		60	/* bit 60 */
141 #define	TX_PKT_HEADER_V4_HDR_CS_SET		0x1000000000000000ULL
142 #define	TX_PKT_HEADER_V4_HDR_CS_MASK		0x1000000000000000ULL
143 #define	TX_PKT_HEADER_IP_VER_SHIFT		61	/* bit 61 */
144 #define	TX_PKT_HEADER_IP_VER_MASK		0x2000000000000000ULL
145 #define	TX_PKT_HEADER_PKT_TYPE_SHIFT		62	/* bit 62 */
146 #define	TX_PKT_HEADER_PKT_TYPE_MASK		0x4000000000000000ULL
147 
148 /* L4 Prototol Operations */
149 #define	TX_PKT_L4_PROTO_OP_NOP			0x00
150 #define	TX_PKT_L4_PROTO_OP_FULL_L4_CSUM		0x01
151 #define	TX_PKT_L4_PROTO_OP_L4_PAYLOAD_CSUM	0x02
152 #define	TX_PKT_L4_PROTO_OP_SCTP_CRC32		0x04
153 
154 /* Transmit Packet Types */
155 #define	TX_PKT_PKT_TYPE_NOP			0x00
156 #define	TX_PKT_PKT_TYPE_TCP			0x01
157 #define	TX_PKT_PKT_TYPE_UDP			0x02
158 #define	TX_PKT_PKT_TYPE_SCTP			0x03
159 
160 typedef union _tx_pkt_header_t {
161 	uint64_t value;
162 	struct {
163 #if defined(_BIG_ENDIAN)
164 		uint32_t	cksum_en_pkt_type:2;
165 		uint32_t	ip_ver:1;
166 		uint32_t	rsrvd:4;
167 		uint32_t	vlan:1;
168 		uint32_t	ihl:4;
169 		uint32_t	l3start:4;
170 		uint32_t	rsvrvd1:2;
171 		uint32_t	l4start:6;
172 		uint32_t	rsvrvd2:2;
173 		uint32_t	l4stuff:6;
174 		uint32_t	rsvrvd3:2;
175 		uint32_t	tot_xfer_len:14;
176 		uint32_t	rsrrvd4:13;
177 		uint32_t	pad:3;
178 #else
179 		uint32_t	pad:3;
180 		uint32_t	rsrrvd4:13;
181 		uint32_t	tot_xfer_len:14;
182 		uint32_t	rsvrvd3:2;
183 		uint32_t	l4stuff:6;
184 		uint32_t	rsvrvd2:2;
185 		uint32_t	l4start:6;
186 		uint32_t	rsvrvd1:2;
187 		uint32_t	l3start:4;
188 		uint32_t	ihl:4;
189 		uint32_t	vlan:1;
190 		uint32_t	rsrvd:4;
191 		uint32_t	ip_ver:1;
192 		uint32_t	cksum_en_pkt_type:2;
193 #endif
194 	} bits;
195 } tx_pkt_header_t, *p_tx_pkt_header_t;
196 
197 typedef struct _tx_pkt_hdr_all_t {
198 	tx_pkt_header_t		pkthdr;
199 	uint64_t		reserved;
200 } tx_pkt_hdr_all_t, *p_tx_pkt_hdr_all_t;
201 
202 
203 #ifdef	__cplusplus
204 }
205 #endif
206 
207 #endif /* _SYS_HXGE_HXGE_TXDMA_HW_H */
208