xref: /illumos-gate/usr/src/uts/common/io/hxge/hpi_pfc.h (revision 7a6d80f1660abd4755c68cbd094d4a914681d26e)
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 _HPI_PFC_H
28 #define	_HPI_PFC_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include <hpi.h>
35 #include <hxge_common.h>
36 #include <hxge_pfc_hw.h>
37 #include <hxge_pfc.h>
38 
39 typedef enum _tcam_op {
40 	TCAM_RWC_STAT	= 0x1,
41 	TCAM_RWC_MATCH	= 0x2
42 } tcam_op_t;
43 
44 /*
45  * HPI PFC ERROR Codes
46  */
47 #define	HPI_PFC_BLK_CODE	PFC_BLK_ID << 8
48 #define	HPI_PFC_ERROR		(HPI_FAILURE | HPI_PFC_BLK_CODE)
49 #define	HPI_TCAM_ERROR		0x10
50 #define	HPI_FCRAM_ERROR		0x20
51 #define	HPI_GEN_PFC		0x30
52 #define	HPI_PFC_SW_PARAM_ERROR	0x40
53 #define	HPI_PFC_HW_ERROR	0x80
54 
55 #define	HPI_PFC_RESET_ERROR	(HPI_PFC_ERROR | HPI_GEN_PFC | RESET_FAILED)
56 #define	HPI_PFC_TCAM_WR_ERROR		\
57 	(HPI_PFC_ERROR | HPI_TCAM_ERROR | WRITE_FAILED)
58 #define	HPI_PFC_ASC_RAM_RD_ERROR	\
59 	(HPI_PFC_ERROR | HPI_TCAM_ERROR | READ_FAILED)
60 #define	HPI_PFC_ASC_RAM_WR_ERROR	\
61 	(HPI_PFC_ERROR | HPI_TCAM_ERROR | WRITE_FAILED)
62 
63 #define	TCAM_CLASS_INVALID		\
64 	(HPI_PFC_SW_PARAM_ERROR | 0xb)
65 /* have only 0xc, 0xd, 0xe and 0xf left for sw error codes */
66 #define	HPI_PFC_TCAM_HW_ERROR		\
67 	(HPI_PFC_ERROR | HPI_PFC_HW_ERROR | HPI_TCAM_ERROR)
68 
69 #define	PFC_N_VLAN_MEMBERS		0x20
70 
71 #define	PFC_N_MAC_ADDRESSES		16
72 #define	PFC_MAX_DMA_CHANNELS		4
73 #define	PFC_MAC_ADDR_STEP		8
74 
75 #define	PFC_HASH_STEP			0x08
76 
77 #define	PFC_L2_CLASS_CONFIG_STEP	0x08
78 
79 #define	PFC_L3_CLASS_CONFIG_STEP	0x08
80 
81 #define	PFC_N_TCAM_ENTRIES		42
82 
83 #define	PFC_VLAN_REG_OFFSET(vlan_id) \
84 	((((vlan_id_t)(vlan_id / PFC_N_VLAN_MEMBERS)) * 8) + PFC_VLAN_TABLE)
85 #define	PFC_VLAN_BIT_OFFSET(vlan_id) \
86 	(vlan_id % PFC_N_VLAN_MEMBERS)
87 #define	PFC_MAC_ADDRESS(slot) \
88 	((slot * PFC_MAC_ADDR_STEP) + PFC_MAC_ADDR)
89 #define	PFC_MAC_ADDRESS_MASK(slot) \
90 	((slot * PFC_MAC_ADDR_STEP) + PFC_MAC_ADDR_MASK)
91 #define	PFC_HASH_ADDR(slot) \
92 	((slot * PFC_HASH_STEP) + PFC_HASH_TABLE)
93 
94 #define	PFC_L2_CONFIG(slot) \
95 	((slot * PFC_L2_CLASS_CONFIG_STEP) + PFC_L2_CLASS_CONFIG)
96 #define	PFC_L3_CONFIG(slot) \
97 	(((slot - TCAM_CLASS_TCP_IPV4) * PFC_L3_CLASS_CONFIG_STEP) + \
98 	PFC_L3_CLASS_CONFIG)
99 
100 typedef uint16_t vlan_id_t;
101 
102 /*
103  * PFC Control Register Functions
104  */
105 hpi_status_t hpi_pfc_set_tcam_enable(hpi_handle_t, boolean_t);
106 hpi_status_t hpi_pfc_set_l2_hash(hpi_handle_t, boolean_t);
107 hpi_status_t hpi_pfc_set_tcp_cksum(hpi_handle_t, boolean_t);
108 hpi_status_t hpi_pfc_set_default_dma(hpi_handle_t, uint32_t);
109 hpi_status_t hpi_pfc_mac_addr_enable(hpi_handle_t, uint32_t);
110 hpi_status_t hpi_pfc_mac_addr_disable(hpi_handle_t, uint32_t);
111 hpi_status_t hpi_pfc_set_force_csum(hpi_handle_t, boolean_t);
112 
113 /*
114  * PFC vlan Functions
115  */
116 hpi_status_t hpi_pfc_cfg_vlan_table_clear(hpi_handle_t);
117 hpi_status_t hpi_pfc_cfg_vlan_table_entry_clear(hpi_handle_t, vlan_id_t);
118 hpi_status_t hpi_pfc_cfg_vlan_table_entry_set(hpi_handle_t, vlan_id_t);
119 hpi_status_t hpi_pfc_cfg_vlan_control_set(hpi_handle_t, boolean_t,
120     boolean_t, vlan_id_t);
121 hpi_status_t hpi_pfc_get_vlan_parity_log(hpi_handle_t,
122     pfc_vlan_par_err_log_t *);
123 
124 /*
125  * PFC Mac Address Functions
126  */
127 hpi_status_t hpi_pfc_set_mac_address(hpi_handle_t, uint32_t, uint64_t);
128 hpi_status_t hpi_pfc_clear_mac_address(hpi_handle_t, uint32_t);
129 hpi_status_t hpi_pfc_clear_multicast_hash_table(hpi_handle_t, uint32_t);
130 hpi_status_t hpi_pfc_set_multicast_hash_table(hpi_handle_t, uint32_t,
131     uint64_t);
132 
133 /*
134  * PFC L2 and L3 Config Functions.
135  */
136 hpi_status_t hpi_pfc_set_l2_class_slot(hpi_handle_t, uint16_t, boolean_t, int);
137 hpi_status_t hpi_pfc_get_l3_class_config(hpi_handle_t handle, tcam_class_t slot,
138     tcam_key_cfg_t *cfg);
139 hpi_status_t hpi_pfc_set_l3_class_config(hpi_handle_t handle, tcam_class_t slot,
140     tcam_key_cfg_t cfg);
141 
142 /*
143  * PFC TCAM Functions
144  */
145 hpi_status_t hpi_pfc_tcam_invalidate_all(hpi_handle_t);
146 hpi_status_t hpi_pfc_tcam_entry_invalidate(hpi_handle_t, uint32_t);
147 hpi_status_t hpi_pfc_tcam_entry_write(hpi_handle_t, uint32_t,
148     hxge_tcam_entry_t *);
149 hpi_status_t hpi_pfc_tcam_entry_read(hpi_handle_t, uint32_t,
150     hxge_tcam_entry_t *);
151 hpi_status_t hpi_pfc_tcam_asc_ram_entry_read(hpi_handle_t handle,
152     uint32_t location, uint64_t *ram_data);
153 hpi_status_t hpi_pfc_tcam_asc_ram_entry_write(hpi_handle_t handle,
154     uint32_t location, uint64_t ram_data);
155 hpi_status_t hpi_pfc_get_tcam_parity_log(hpi_handle_t,
156     pfc_tcam_par_err_log_t *);
157 hpi_status_t hpi_pfc_get_tcam_auto_init(hpi_handle_t,
158     pfc_auto_init_t *);
159 
160 /*
161  * PFC TCP Control
162  */
163 hpi_status_t hpi_pfc_set_tcp_control_discard(hpi_handle_t, boolean_t);
164 hpi_status_t hpi_pfc_set_tcp_control_fin(hpi_handle_t, boolean_t);
165 hpi_status_t hpi_pfc_set_tcp_control_syn(hpi_handle_t, boolean_t);
166 hpi_status_t hpi_pfc_set_tcp_control_rst(hpi_handle_t, boolean_t);
167 hpi_status_t hpi_pfc_set_tcp_control_psh(hpi_handle_t, boolean_t);
168 hpi_status_t hpi_pfc_set_tcp_control_ack(hpi_handle_t, boolean_t);
169 hpi_status_t hpi_pfc_set_tcp_control_urg(hpi_handle_t, boolean_t);
170 
171 /*
172  * PFC Hash Seed Value
173  */
174 hpi_status_t hpi_pfc_set_hash_seed_value(hpi_handle_t, uint32_t);
175 
176 /*
177  * PFC Interrupt Management Functions
178  */
179 hpi_status_t hpi_pfc_get_interrupt_status(hpi_handle_t, pfc_int_status_t *);
180 hpi_status_t hpi_pfc_clear_interrupt_status(hpi_handle_t);
181 hpi_status_t hpi_pfc_set_interrupt_mask(hpi_handle_t, boolean_t,
182     boolean_t, boolean_t);
183 
184 /*
185  * PFC Packet Logs
186  */
187 hpi_status_t hpi_pfc_get_drop_log(hpi_handle_t, pfc_drop_log_t *);
188 hpi_status_t hpi_pfc_set_drop_log_mask(hpi_handle_t, boolean_t,
189     boolean_t, boolean_t, boolean_t, boolean_t);
190 hpi_status_t hpi_pfc_get_bad_csum_counter(hpi_handle_t, uint64_t *);
191 hpi_status_t hpi_pfc_get_drop_counter(hpi_handle_t, uint64_t *);
192 
193 hpi_status_t hpi_pfc_get_number_mac_addrs(hpi_handle_t handle,
194     uint32_t *n_of_addrs);
195 hpi_status_t hpi_pfc_mac_addr_get_i(hpi_handle_t handle, uint8_t *data,
196     int slot);
197 hpi_status_t hpi_pfc_num_macs_get(hpi_handle_t handle, uint8_t *data);
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 
203 #endif /* !_HPI_PFC_H */
204