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