xref: /freebsd/sys/dev/qlnx/qlnxe/ecore_dcbx_api.h (revision 0e6acb26)
1 /*
2  * Copyright (c) 2017-2018 Cavium, Inc.
3  * All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions
7  *  are met:
8  *
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.
14  *
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.
26  *
27  * $FreeBSD$
28  *
29  */
30 
31 #ifndef __ECORE_DCBX_API_H__
32 #define __ECORE_DCBX_API_H__
33 
34 #include "ecore_status.h"
35 
36 #define DCBX_CONFIG_MAX_APP_PROTOCOL	4
37 
38 enum ecore_mib_read_type {
39 	ECORE_DCBX_OPERATIONAL_MIB,
40 	ECORE_DCBX_REMOTE_MIB,
41 	ECORE_DCBX_LOCAL_MIB,
42 	ECORE_DCBX_REMOTE_LLDP_MIB,
43 	ECORE_DCBX_LOCAL_LLDP_MIB
44 };
45 
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 */
53 };
54 
55 enum dcbx_protocol_type {
56 	DCBX_PROTOCOL_ISCSI,
57 	DCBX_PROTOCOL_FCOE,
58 	DCBX_PROTOCOL_ROCE,
59 	DCBX_PROTOCOL_ROCE_V2,
60 	DCBX_PROTOCOL_ETH,
61 	DCBX_PROTOCOL_IWARP,
62 	DCBX_MAX_PROTOCOL_TYPE
63 };
64 
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
70 
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];
74 	bool	enable_rx;
75 	bool	enable_tx;
76 	u32     tx_interval;
77 	u32     max_credit;
78 };
79 
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];
83 };
84 
85 struct ecore_dcbx_app_prio {
86 	u8	roce;
87 	u8	roce_v2;
88 	u8	fcoe;
89 	u8	iscsi;
90 	u8	eth;
91 };
92 
93 struct ecore_dbcx_pfc_params {
94 	bool	willing;
95 	bool	enabled;
96 	u8	prio[ECORE_MAX_PFC_PRIORITIES];
97 	u8	max_tc;
98 };
99 
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
105 };
106 
107 struct ecore_app_entry {
108 	bool ethtype;
109 	enum ecore_dcbx_sf_ieee_type sf_ieee;
110 	bool enabled;
111 	u8 prio;
112 	u16 proto_id;
113 	enum dcbx_protocol_type proto_type;
114 };
115 
116 struct ecore_dcbx_params {
117 	struct ecore_app_entry app_entry[ECORE_DCBX_MAX_APP_PROTOCOL];
118 	u16	num_app_entries;
119 	bool	app_willing;
120 	bool	app_valid;
121 	bool	app_error;
122 	bool	ets_willing;
123 	bool	ets_enabled;
124 	bool	ets_cbs;
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;
130 	u8	max_ets_tc;
131 };
132 
133 struct ecore_dcbx_admin_params {
134 	struct ecore_dcbx_params params;
135 	bool valid;		/* Indicate validity of params */
136 };
137 
138 struct ecore_dcbx_remote_params {
139 	struct ecore_dcbx_params params;
140 	bool valid;		/* Indicate validity of params */
141 };
142 
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 */
147 	bool enabled;
148 	bool ieee;
149 	bool cee;
150 	bool local;
151 	u32 err;
152 };
153 
154 struct ecore_dcbx_dscp_params {
155 	bool enabled;
156 	u8 dscp_pri_map[ECORE_DCBX_DSCP_SIZE];
157 };
158 
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;
166 };
167 
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
172 
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)
179 	u32 override_flags;
180 	bool enabled;
181 	struct ecore_dcbx_admin_params config;
182 	u32 ver_num;
183 	struct ecore_dcbx_dscp_params dscp;
184 };
185 
186 struct ecore_dcbx_results {
187 	bool dcbx_enabled;
188 	u8 pf_id;
189 	struct ecore_dcbx_app_data arr[DCBX_MAX_PROTOCOL_TYPE];
190 };
191 
192 struct ecore_dcbx_app_metadata {
193 	enum dcbx_protocol_type id;
194 	char *name;
195 	enum ecore_pci_personality personality;
196 };
197 
198 enum _ecore_status_t ecore_dcbx_query_params(struct ecore_hwfn *,
199 					     struct ecore_dcbx_get *,
200 					     enum ecore_mib_read_type);
201 
202 enum _ecore_status_t ecore_dcbx_get_config_params(struct ecore_hwfn *,
203 						  struct ecore_dcbx_set *);
204 
205 enum _ecore_status_t ecore_dcbx_config_params(struct ecore_hwfn *,
206 					      struct ecore_ptt *,
207 					      struct ecore_dcbx_set *,
208 					      bool);
209 
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}
217 };
218 
219 #endif /* __ECORE_DCBX_API_H__ */
220