xref: /dpdk/drivers/net/qede/base/ecore_dcbx_api.h (revision 9aea0e7daffd26888252cbf77287def3a907e7af)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2016 - 2018 Cavium Inc.
3  * All rights reserved.
4  * www.cavium.com
5  */
6 
7 #ifndef __ECORE_DCBX_API_H__
8 #define __ECORE_DCBX_API_H__
9 
10 #include "ecore_status.h"
11 
12 #define DCBX_CONFIG_MAX_APP_PROTOCOL	4
13 
14 enum ecore_mib_read_type {
15 	ECORE_DCBX_OPERATIONAL_MIB,
16 	ECORE_DCBX_REMOTE_MIB,
17 	ECORE_DCBX_LOCAL_MIB,
18 	ECORE_DCBX_REMOTE_LLDP_MIB,
19 	ECORE_DCBX_LOCAL_LLDP_MIB,
20 	ECORE_DCBX_LLDP_TLVS
21 };
22 
23 struct ecore_dcbx_app_data {
24 	bool enable;		/* DCB enabled */
25 	u8 update;		/* Update indication */
26 	u8 priority;		/* Priority */
27 	u8 tc;			/* Traffic Class */
28 	bool dscp_enable;	/* DSCP enabled */
29 	u8 dscp_val;		/* DSCP value */
30 	bool dont_add_vlan0;	/* Do not insert a vlan tag with id 0 */
31 };
32 
33 #ifndef __EXTRACT__LINUX__
34 enum dcbx_protocol_type {
35 	DCBX_PROTOCOL_ISCSI,
36 	DCBX_PROTOCOL_FCOE,
37 	DCBX_PROTOCOL_ROCE,
38 	DCBX_PROTOCOL_ROCE_V2,
39 	DCBX_PROTOCOL_ETH,
40 	DCBX_PROTOCOL_IWARP,
41 	DCBX_MAX_PROTOCOL_TYPE
42 };
43 
44 #define ECORE_LLDP_CHASSIS_ID_STAT_LEN 4
45 #define ECORE_LLDP_PORT_ID_STAT_LEN 4
46 #define ECORE_DCBX_MAX_APP_PROTOCOL 32
47 #define ECORE_MAX_PFC_PRIORITIES 8
48 #define ECORE_DCBX_DSCP_SIZE 64
49 
50 struct ecore_dcbx_lldp_remote {
51 	u32     peer_chassis_id[ECORE_LLDP_CHASSIS_ID_STAT_LEN];
52 	u32     peer_port_id[ECORE_LLDP_PORT_ID_STAT_LEN];
53 	bool	enable_rx;
54 	bool	enable_tx;
55 	u32     tx_interval;
56 	u32     max_credit;
57 };
58 
59 struct ecore_dcbx_lldp_local {
60 	u32     local_chassis_id[ECORE_LLDP_CHASSIS_ID_STAT_LEN];
61 	u32     local_port_id[ECORE_LLDP_PORT_ID_STAT_LEN];
62 };
63 
64 struct ecore_dcbx_app_prio {
65 	u8	roce;
66 	u8	roce_v2;
67 	u8	fcoe;
68 	u8	iscsi;
69 	u8	eth;
70 };
71 
72 struct ecore_dbcx_pfc_params {
73 	bool	willing;
74 	bool	enabled;
75 	u8	prio[ECORE_MAX_PFC_PRIORITIES];
76 	u8	max_tc;
77 };
78 
79 enum ecore_dcbx_sf_ieee_type {
80 	ECORE_DCBX_SF_IEEE_ETHTYPE,
81 	ECORE_DCBX_SF_IEEE_TCP_PORT,
82 	ECORE_DCBX_SF_IEEE_UDP_PORT,
83 	ECORE_DCBX_SF_IEEE_TCP_UDP_PORT
84 };
85 
86 struct ecore_app_entry {
87 	bool ethtype;
88 	enum ecore_dcbx_sf_ieee_type sf_ieee;
89 	bool enabled;
90 	u8 prio;
91 	u16 proto_id;
92 	enum dcbx_protocol_type proto_type;
93 };
94 
95 struct ecore_dcbx_params {
96 	struct ecore_app_entry app_entry[ECORE_DCBX_MAX_APP_PROTOCOL];
97 	u16	num_app_entries;
98 	bool	app_willing;
99 	bool	app_valid;
100 	bool	app_error;
101 	bool	ets_willing;
102 	bool	ets_enabled;
103 	bool	ets_cbs;
104 	u8	ets_pri_tc_tbl[ECORE_MAX_PFC_PRIORITIES];
105 	u8	ets_tc_bw_tbl[ECORE_MAX_PFC_PRIORITIES];
106 	u8	ets_tc_tsa_tbl[ECORE_MAX_PFC_PRIORITIES];
107 	struct ecore_dbcx_pfc_params pfc;
108 	u8	max_ets_tc;
109 };
110 
111 struct ecore_dcbx_admin_params {
112 	struct ecore_dcbx_params params;
113 	bool valid;		/* Indicate validity of params */
114 };
115 
116 struct ecore_dcbx_remote_params {
117 	struct ecore_dcbx_params params;
118 	bool valid;		/* Indicate validity of params */
119 };
120 
121 struct ecore_dcbx_operational_params {
122 	struct ecore_dcbx_app_prio app_prio;
123 	struct ecore_dcbx_params params;
124 	bool valid;		/* Indicate validity of params */
125 	bool enabled;
126 	bool ieee;
127 	bool cee;
128 	bool local;
129 	u32 err;
130 };
131 
132 struct ecore_dcbx_dscp_params {
133 	bool enabled;
134 	u8 dscp_pri_map[ECORE_DCBX_DSCP_SIZE];
135 };
136 
137 struct ecore_dcbx_get {
138 	struct ecore_dcbx_operational_params operational;
139 	struct ecore_dcbx_lldp_remote lldp_remote;
140 	struct ecore_dcbx_lldp_local lldp_local;
141 	struct ecore_dcbx_remote_params remote;
142 	struct ecore_dcbx_admin_params local;
143 	struct ecore_dcbx_dscp_params dscp;
144 };
145 #endif
146 
147 #define ECORE_DCBX_VERSION_DISABLED	0
148 #define ECORE_DCBX_VERSION_IEEE		1
149 #define ECORE_DCBX_VERSION_CEE		2
150 #define ECORE_DCBX_VERSION_DYNAMIC	3
151 
152 struct ecore_dcbx_set {
153 #define ECORE_DCBX_OVERRIDE_STATE	(1 << 0)
154 #define ECORE_DCBX_OVERRIDE_PFC_CFG	(1 << 1)
155 #define ECORE_DCBX_OVERRIDE_ETS_CFG	(1 << 2)
156 #define ECORE_DCBX_OVERRIDE_APP_CFG	(1 << 3)
157 #define ECORE_DCBX_OVERRIDE_DSCP_CFG	(1 << 4)
158 	u32 override_flags;
159 	bool enabled;
160 	struct ecore_dcbx_admin_params config;
161 	u32 ver_num;
162 	struct ecore_dcbx_dscp_params dscp;
163 };
164 
165 struct ecore_dcbx_results {
166 	bool dcbx_enabled;
167 	u8 pf_id;
168 	struct ecore_dcbx_app_data arr[DCBX_MAX_PROTOCOL_TYPE];
169 };
170 
171 struct ecore_dcbx_app_metadata {
172 	enum dcbx_protocol_type id;
173 	const char *name; /* @DPDK */
174 	enum ecore_pci_personality personality;
175 };
176 
177 enum ecore_lldp_agent {
178 	ECORE_LLDP_NEAREST_BRIDGE = 0,
179 	ECORE_LLDP_NEAREST_NON_TPMR_BRIDGE,
180 	ECORE_LLDP_NEAREST_CUSTOMER_BRIDGE,
181 	ECORE_LLDP_MAX_AGENTS
182 };
183 
184 struct ecore_lldp_config_params {
185 	enum ecore_lldp_agent agent;
186 	u8 tx_interval;
187 	u8 tx_hold;
188 	u8 tx_credit;
189 	bool rx_enable;
190 	bool tx_enable;
191 	u32 chassis_id_tlv[ECORE_LLDP_CHASSIS_ID_STAT_LEN];
192 	u32 port_id_tlv[ECORE_LLDP_PORT_ID_STAT_LEN];
193 };
194 
195 #define ECORE_LLDP_SYS_TLV_SIZE 256
196 struct ecore_lldp_sys_tlvs {
197 	bool discard_mandatory_tlv;
198 	u8 buf[ECORE_LLDP_SYS_TLV_SIZE];
199 	u16 buf_size;
200 };
201 
202 enum _ecore_status_t ecore_dcbx_query_params(struct ecore_hwfn *,
203 					     struct ecore_dcbx_get *,
204 					     enum ecore_mib_read_type);
205 
206 enum _ecore_status_t ecore_dcbx_get_config_params(struct ecore_hwfn *,
207 						  struct ecore_dcbx_set *);
208 
209 enum _ecore_status_t ecore_dcbx_config_params(struct ecore_hwfn *,
210 					      struct ecore_ptt *,
211 					      struct ecore_dcbx_set *,
212 					      bool);
213 
214 enum _ecore_status_t ecore_lldp_register_tlv(struct ecore_hwfn *p_hwfn,
215 					     struct ecore_ptt *p_ptt,
216 					     enum ecore_lldp_agent agent,
217 					     u8 tlv_type);
218 
219 enum _ecore_status_t
220 ecore_lldp_get_params(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
221 		      struct ecore_lldp_config_params *p_params);
222 
223 enum _ecore_status_t
224 ecore_lldp_set_params(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
225 		      struct ecore_lldp_config_params *p_params);
226 
227 enum _ecore_status_t
228 ecore_lldp_set_system_tlvs(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
229 			   struct ecore_lldp_sys_tlvs *p_params);
230 
231 /* Returns priority value for a given dscp index */
232 enum _ecore_status_t
233 ecore_dcbx_get_dscp_priority(struct ecore_hwfn *p_hwfn,
234 			     u8 dscp_index, u8 *p_dscp_pri);
235 
236 /* Sets priority value for a given dscp index */
237 enum _ecore_status_t
238 ecore_dcbx_set_dscp_priority(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
239 			     u8 dscp_index, u8 pri_val);
240 
241 static const struct ecore_dcbx_app_metadata ecore_dcbx_app_update[] = {
242 	{DCBX_PROTOCOL_ISCSI, "ISCSI", ECORE_PCI_ISCSI},
243 	{DCBX_PROTOCOL_FCOE, "FCOE", ECORE_PCI_FCOE},
244 	{DCBX_PROTOCOL_ROCE, "ROCE", ECORE_PCI_ETH_ROCE},
245 	{DCBX_PROTOCOL_ROCE_V2, "ROCE_V2", ECORE_PCI_ETH_ROCE},
246 	{DCBX_PROTOCOL_ETH, "ETH", ECORE_PCI_ETH},
247 	{DCBX_PROTOCOL_IWARP, "IWARP", ECORE_PCI_ETH_IWARP}
248 };
249 
250 #endif /* __ECORE_DCBX_API_H__ */
251