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
46 struct ecore_dcbx_app_data {
47 bool enable; /* DCB enabled */
48 u8 update; /* Update indication */
49 u8 priority; /* Priority */
50 u8 tc; /* Traffic Class */
51 bool dscp_enable; /* DSCP enabled */
52 u8 dscp_val; /* DSCP value */
55 enum dcbx_protocol_type {
59 DCBX_PROTOCOL_ROCE_V2,
62 DCBX_MAX_PROTOCOL_TYPE
65 #define ECORE_LLDP_CHASSIS_ID_STAT_LEN 4
66 #define ECORE_LLDP_PORT_ID_STAT_LEN 4
67 #define ECORE_DCBX_MAX_APP_PROTOCOL 32
68 #define ECORE_MAX_PFC_PRIORITIES 8
69 #define ECORE_DCBX_DSCP_SIZE 64
71 struct ecore_dcbx_lldp_remote {
72 u32 peer_chassis_id[ECORE_LLDP_CHASSIS_ID_STAT_LEN];
73 u32 peer_port_id[ECORE_LLDP_PORT_ID_STAT_LEN];
80 struct ecore_dcbx_lldp_local {
81 u32 local_chassis_id[ECORE_LLDP_CHASSIS_ID_STAT_LEN];
82 u32 local_port_id[ECORE_LLDP_PORT_ID_STAT_LEN];
85 struct ecore_dcbx_app_prio {
93 struct ecore_dbcx_pfc_params {
96 u8 prio[ECORE_MAX_PFC_PRIORITIES];
100 enum ecore_dcbx_sf_ieee_type {
101 ECORE_DCBX_SF_IEEE_ETHTYPE,
102 ECORE_DCBX_SF_IEEE_TCP_PORT,
103 ECORE_DCBX_SF_IEEE_UDP_PORT,
104 ECORE_DCBX_SF_IEEE_TCP_UDP_PORT
107 struct ecore_app_entry {
109 enum ecore_dcbx_sf_ieee_type sf_ieee;
113 enum dcbx_protocol_type proto_type;
116 struct ecore_dcbx_params {
117 struct ecore_app_entry app_entry[ECORE_DCBX_MAX_APP_PROTOCOL];
125 bool valid; /* Indicate validity of params */
126 u8 ets_pri_tc_tbl[ECORE_MAX_PFC_PRIORITIES];
127 u8 ets_tc_bw_tbl[ECORE_MAX_PFC_PRIORITIES];
128 u8 ets_tc_tsa_tbl[ECORE_MAX_PFC_PRIORITIES];
129 struct ecore_dbcx_pfc_params pfc;
133 struct ecore_dcbx_admin_params {
134 struct ecore_dcbx_params params;
135 bool valid; /* Indicate validity of params */
138 struct ecore_dcbx_remote_params {
139 struct ecore_dcbx_params params;
140 bool valid; /* Indicate validity of params */
143 struct ecore_dcbx_operational_params {
144 struct ecore_dcbx_app_prio app_prio;
145 struct ecore_dcbx_params params;
146 bool valid; /* Indicate validity of params */
154 struct ecore_dcbx_dscp_params {
156 u8 dscp_pri_map[ECORE_DCBX_DSCP_SIZE];
159 struct ecore_dcbx_get {
160 struct ecore_dcbx_operational_params operational;
161 struct ecore_dcbx_lldp_remote lldp_remote;
162 struct ecore_dcbx_lldp_local lldp_local;
163 struct ecore_dcbx_remote_params remote;
164 struct ecore_dcbx_admin_params local;
165 struct ecore_dcbx_dscp_params dscp;
168 #define ECORE_DCBX_VERSION_DISABLED 0
169 #define ECORE_DCBX_VERSION_IEEE 1
170 #define ECORE_DCBX_VERSION_CEE 2
171 #define ECORE_DCBX_VERSION_DYNAMIC 3
173 struct ecore_dcbx_set {
174 #define ECORE_DCBX_OVERRIDE_STATE (1 << 0)
175 #define ECORE_DCBX_OVERRIDE_PFC_CFG (1 << 1)
176 #define ECORE_DCBX_OVERRIDE_ETS_CFG (1 << 2)
177 #define ECORE_DCBX_OVERRIDE_APP_CFG (1 << 3)
178 #define ECORE_DCBX_OVERRIDE_DSCP_CFG (1 << 4)
181 struct ecore_dcbx_admin_params config;
183 struct ecore_dcbx_dscp_params dscp;
186 struct ecore_dcbx_results {
189 struct ecore_dcbx_app_data arr[DCBX_MAX_PROTOCOL_TYPE];
192 struct ecore_dcbx_app_metadata {
193 enum dcbx_protocol_type id;
195 enum ecore_pci_personality personality;
198 enum _ecore_status_t ecore_dcbx_query_params(struct ecore_hwfn *,
199 struct ecore_dcbx_get *,
200 enum ecore_mib_read_type);
202 enum _ecore_status_t ecore_dcbx_get_config_params(struct ecore_hwfn *,
203 struct ecore_dcbx_set *);
205 enum _ecore_status_t ecore_dcbx_config_params(struct ecore_hwfn *,
207 struct ecore_dcbx_set *,
210 static const struct ecore_dcbx_app_metadata ecore_dcbx_app_update[] = {
211 {DCBX_PROTOCOL_ISCSI, "ISCSI", ECORE_PCI_ISCSI},
212 {DCBX_PROTOCOL_FCOE, "FCOE", ECORE_PCI_FCOE},
213 {DCBX_PROTOCOL_ROCE, "ROCE", ECORE_PCI_ETH_ROCE},
214 {DCBX_PROTOCOL_ROCE_V2, "ROCE_V2", ECORE_PCI_ETH_ROCE},
215 {DCBX_PROTOCOL_ETH, "ETH", ECORE_PCI_ETH},
216 {DCBX_PROTOCOL_IWARP, "IWARP", ECORE_PCI_ETH_IWARP}
219 #endif /* __ECORE_DCBX_API_H__ */