2 * Copyright (c) 2017-2018 Cavium, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
31 #ifndef __ECORE_DCBX_API_H__
32 #define __ECORE_DCBX_API_H__
34 #include "ecore_status.h"
36 #define DCBX_CONFIG_MAX_APP_PROTOCOL 4
38 enum ecore_mib_read_type {
39 ECORE_DCBX_OPERATIONAL_MIB,
40 ECORE_DCBX_REMOTE_MIB,
42 ECORE_DCBX_REMOTE_LLDP_MIB,
43 ECORE_DCBX_LOCAL_LLDP_MIB,
47 struct ecore_dcbx_app_data {
48 bool enable; /* DCB enabled */
49 u8 update; /* Update indication */
50 u8 priority; /* Priority */
51 u8 tc; /* Traffic Class */
52 bool dscp_enable; /* DSCP enabled */
53 u8 dscp_val; /* DSCP value */
54 bool dont_add_vlan0; /* Do not insert a vlan tag with id 0 */
57 #ifndef __EXTRACT__LINUX__IF__
58 enum dcbx_protocol_type {
62 DCBX_PROTOCOL_ROCE_V2,
65 DCBX_MAX_PROTOCOL_TYPE
68 #define ECORE_LLDP_CHASSIS_ID_STAT_LEN 4
69 #define ECORE_LLDP_PORT_ID_STAT_LEN 4
70 #define ECORE_DCBX_MAX_APP_PROTOCOL 32
71 #define ECORE_MAX_PFC_PRIORITIES 8
72 #define ECORE_DCBX_DSCP_SIZE 64
74 struct ecore_dcbx_lldp_remote {
75 u32 peer_chassis_id[ECORE_LLDP_CHASSIS_ID_STAT_LEN];
76 u32 peer_port_id[ECORE_LLDP_PORT_ID_STAT_LEN];
83 struct ecore_dcbx_lldp_local {
84 u32 local_chassis_id[ECORE_LLDP_CHASSIS_ID_STAT_LEN];
85 u32 local_port_id[ECORE_LLDP_PORT_ID_STAT_LEN];
88 struct ecore_dcbx_app_prio {
96 struct ecore_dbcx_pfc_params {
99 u8 prio[ECORE_MAX_PFC_PRIORITIES];
103 enum ecore_dcbx_sf_ieee_type {
104 ECORE_DCBX_SF_IEEE_ETHTYPE,
105 ECORE_DCBX_SF_IEEE_TCP_PORT,
106 ECORE_DCBX_SF_IEEE_UDP_PORT,
107 ECORE_DCBX_SF_IEEE_TCP_UDP_PORT
110 struct ecore_app_entry {
112 enum ecore_dcbx_sf_ieee_type sf_ieee;
116 enum dcbx_protocol_type proto_type;
119 struct ecore_dcbx_params {
120 struct ecore_app_entry app_entry[ECORE_DCBX_MAX_APP_PROTOCOL];
128 u8 ets_pri_tc_tbl[ECORE_MAX_PFC_PRIORITIES];
129 u8 ets_tc_bw_tbl[ECORE_MAX_PFC_PRIORITIES];
130 u8 ets_tc_tsa_tbl[ECORE_MAX_PFC_PRIORITIES];
131 struct ecore_dbcx_pfc_params pfc;
135 struct ecore_dcbx_admin_params {
136 struct ecore_dcbx_params params;
137 bool valid; /* Indicate validity of params */
140 struct ecore_dcbx_remote_params {
141 struct ecore_dcbx_params params;
142 bool valid; /* Indicate validity of params */
145 struct ecore_dcbx_operational_params {
146 struct ecore_dcbx_app_prio app_prio;
147 struct ecore_dcbx_params params;
148 bool valid; /* Indicate validity of params */
156 struct ecore_dcbx_dscp_params {
158 u8 dscp_pri_map[ECORE_DCBX_DSCP_SIZE];
161 struct ecore_dcbx_get {
162 struct ecore_dcbx_operational_params operational;
163 struct ecore_dcbx_lldp_remote lldp_remote;
164 struct ecore_dcbx_lldp_local lldp_local;
165 struct ecore_dcbx_remote_params remote;
166 struct ecore_dcbx_admin_params local;
167 struct ecore_dcbx_dscp_params dscp;
171 #define ECORE_DCBX_VERSION_DISABLED 0
172 #define ECORE_DCBX_VERSION_IEEE 1
173 #define ECORE_DCBX_VERSION_CEE 2
174 #define ECORE_DCBX_VERSION_DYNAMIC 3
176 struct ecore_dcbx_set {
177 #define ECORE_DCBX_OVERRIDE_STATE (1 << 0)
178 #define ECORE_DCBX_OVERRIDE_PFC_CFG (1 << 1)
179 #define ECORE_DCBX_OVERRIDE_ETS_CFG (1 << 2)
180 #define ECORE_DCBX_OVERRIDE_APP_CFG (1 << 3)
181 #define ECORE_DCBX_OVERRIDE_DSCP_CFG (1 << 4)
184 struct ecore_dcbx_admin_params config;
186 struct ecore_dcbx_dscp_params dscp;
189 struct ecore_dcbx_results {
192 struct ecore_dcbx_app_data arr[DCBX_MAX_PROTOCOL_TYPE];
195 struct ecore_dcbx_app_metadata {
196 enum dcbx_protocol_type id;
198 enum ecore_pci_personality personality;
201 enum ecore_lldp_agent {
202 ECORE_LLDP_NEAREST_BRIDGE = 0,
203 ECORE_LLDP_NEAREST_NON_TPMR_BRIDGE,
204 ECORE_LLDP_NEAREST_CUSTOMER_BRIDGE,
205 ECORE_LLDP_MAX_AGENTS
208 struct ecore_lldp_config_params {
209 enum ecore_lldp_agent agent;
215 u32 chassis_id_tlv[ECORE_LLDP_CHASSIS_ID_STAT_LEN];
216 u32 port_id_tlv[ECORE_LLDP_PORT_ID_STAT_LEN];
219 #define ECORE_LLDP_SYS_TLV_SIZE 256
220 struct ecore_lldp_sys_tlvs {
221 bool discard_mandatory_tlv;
222 u8 buf[ECORE_LLDP_SYS_TLV_SIZE];
226 struct ecore_lldp_stats {
227 enum ecore_lldp_agent agent;
234 enum _ecore_status_t ecore_dcbx_query_params(struct ecore_hwfn *p_hwfn,
235 struct ecore_dcbx_get *p_get,
236 enum ecore_mib_read_type type);
238 enum _ecore_status_t ecore_dcbx_get_config_params(struct ecore_hwfn *p_hwfn,
239 struct ecore_dcbx_set
242 enum _ecore_status_t ecore_dcbx_config_params(struct ecore_hwfn *p_hwfn,
243 struct ecore_ptt *p_ptt,
244 struct ecore_dcbx_set *params,
247 enum _ecore_status_t ecore_lldp_register_tlv(struct ecore_hwfn *p_hwfn,
248 struct ecore_ptt *p_ptt,
249 enum ecore_lldp_agent agent,
253 ecore_lldp_get_params(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
254 struct ecore_lldp_config_params *p_params);
257 ecore_lldp_set_params(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
258 struct ecore_lldp_config_params *p_params);
261 ecore_lldp_set_system_tlvs(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
262 struct ecore_lldp_sys_tlvs *p_params);
264 /* Returns priority value for a given dscp index */
266 ecore_dcbx_get_dscp_priority(struct ecore_hwfn *p_hwfn,
267 u8 dscp_index, u8 *p_dscp_pri);
269 /* Sets priority value for a given dscp index */
271 ecore_dcbx_set_dscp_priority(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
272 u8 dscp_index, u8 pri_val);
275 ecore_lldp_get_stats(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
276 struct ecore_lldp_stats *p_params);
278 #ifndef __EXTRACT__LINUX__C__
279 static const struct ecore_dcbx_app_metadata ecore_dcbx_app_update[] = {
280 {DCBX_PROTOCOL_ISCSI, "ISCSI", ECORE_PCI_ISCSI},
281 {DCBX_PROTOCOL_FCOE, "FCOE", ECORE_PCI_FCOE},
282 {DCBX_PROTOCOL_ROCE, "ROCE", ECORE_PCI_ETH_ROCE},
283 {DCBX_PROTOCOL_ROCE_V2, "ROCE_V2", ECORE_PCI_ETH_ROCE},
284 {DCBX_PROTOCOL_ETH, "ETH", ECORE_PCI_ETH},
285 {DCBX_PROTOCOL_IWARP, "IWARP", ECORE_PCI_ETH_IWARP}
289 #endif /* __ECORE_DCBX_API_H__ */