]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/qlnx/qlnxe/ecore_dcbx_api.h
MFV r348583: 9847 leaking dd_clones (DMU_OT_DSL_CLONES) objects
[FreeBSD/FreeBSD.git] / sys / dev / qlnx / qlnxe / ecore_dcbx_api.h
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         ECORE_DCBX_LLDP_TLVS
45 };
46
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 */
55 };
56
57 #ifndef __EXTRACT__LINUX__IF__
58 enum dcbx_protocol_type {
59         DCBX_PROTOCOL_ISCSI,
60         DCBX_PROTOCOL_FCOE,
61         DCBX_PROTOCOL_ROCE,
62         DCBX_PROTOCOL_ROCE_V2,
63         DCBX_PROTOCOL_ETH,
64         DCBX_PROTOCOL_IWARP,
65         DCBX_MAX_PROTOCOL_TYPE
66 };
67
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
73
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];
77         bool    enable_rx;
78         bool    enable_tx;
79         u32     tx_interval;
80         u32     max_credit;
81 };
82
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];
86 };
87
88 struct ecore_dcbx_app_prio {
89         u8      roce;
90         u8      roce_v2;
91         u8      fcoe;
92         u8      iscsi;
93         u8      eth;
94 };
95
96 struct ecore_dbcx_pfc_params {
97         bool    willing;
98         bool    enabled;
99         u8      prio[ECORE_MAX_PFC_PRIORITIES];
100         u8      max_tc;
101 };
102
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
108 };
109
110 struct ecore_app_entry {
111         bool ethtype;
112         enum ecore_dcbx_sf_ieee_type sf_ieee;
113         bool enabled;
114         u8 prio;
115         u16 proto_id;
116         enum dcbx_protocol_type proto_type;
117 };
118
119 struct ecore_dcbx_params {
120         struct ecore_app_entry app_entry[ECORE_DCBX_MAX_APP_PROTOCOL];
121         u16     num_app_entries;
122         bool    app_willing;
123         bool    app_valid;
124         bool    app_error;
125         bool    ets_willing;
126         bool    ets_enabled;
127         bool    ets_cbs;
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;
132         u8      max_ets_tc;
133 };
134
135 struct ecore_dcbx_admin_params {
136         struct ecore_dcbx_params params;
137         bool valid;             /* Indicate validity of params */
138 };
139
140 struct ecore_dcbx_remote_params {
141         struct ecore_dcbx_params params;
142         bool valid;             /* Indicate validity of params */
143 };
144
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 */
149         bool enabled;
150         bool ieee;
151         bool cee;
152         bool local;
153         u32 err;
154 };
155
156 struct ecore_dcbx_dscp_params {
157         bool enabled;
158         u8 dscp_pri_map[ECORE_DCBX_DSCP_SIZE];
159 };
160
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;
168 };
169 #endif
170
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
175
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)
182         u32 override_flags;
183         bool enabled;
184         struct ecore_dcbx_admin_params config;
185         u32 ver_num;
186         struct ecore_dcbx_dscp_params dscp;
187 };
188
189 struct ecore_dcbx_results {
190         bool dcbx_enabled;
191         u8 pf_id;
192         struct ecore_dcbx_app_data arr[DCBX_MAX_PROTOCOL_TYPE];
193 };
194
195 struct ecore_dcbx_app_metadata {
196         enum dcbx_protocol_type id;
197         char *name;
198         enum ecore_pci_personality personality;
199 };
200
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
206 };
207
208 struct ecore_lldp_config_params {
209         enum ecore_lldp_agent agent;
210         u8 tx_interval;
211         u8 tx_hold;
212         u8 tx_credit;
213         bool rx_enable;
214         bool tx_enable;
215         u32 chassis_id_tlv[ECORE_LLDP_CHASSIS_ID_STAT_LEN];
216         u32 port_id_tlv[ECORE_LLDP_PORT_ID_STAT_LEN];
217 };
218
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];
223         u16 buf_size;
224 };
225
226 struct ecore_lldp_stats {
227         enum ecore_lldp_agent agent;
228         u32 tx_frames;
229         u32 rx_frames;
230         u32 rx_discards;
231         u32 rx_age_outs;
232 };
233
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);
237
238 enum _ecore_status_t ecore_dcbx_get_config_params(struct ecore_hwfn *p_hwfn,
239                                                   struct ecore_dcbx_set
240                                                   *params);
241
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,
245                                               bool hw_commit);
246
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,
250                                              u8 tlv_type);
251
252 enum _ecore_status_t
253 ecore_lldp_get_params(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
254                       struct ecore_lldp_config_params *p_params);
255
256 enum _ecore_status_t
257 ecore_lldp_set_params(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
258                       struct ecore_lldp_config_params *p_params);
259
260 enum _ecore_status_t
261 ecore_lldp_set_system_tlvs(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
262                            struct ecore_lldp_sys_tlvs *p_params);
263
264 /* Returns priority value for a given dscp index */
265 enum _ecore_status_t
266 ecore_dcbx_get_dscp_priority(struct ecore_hwfn *p_hwfn,
267                              u8 dscp_index, u8 *p_dscp_pri);
268
269 /* Sets priority value for a given dscp index */
270 enum _ecore_status_t
271 ecore_dcbx_set_dscp_priority(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
272                              u8 dscp_index, u8 pri_val);
273
274 enum _ecore_status_t
275 ecore_lldp_get_stats(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
276                      struct ecore_lldp_stats *p_params);
277
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}
286 };
287 #endif
288
289 #endif /* __ECORE_DCBX_API_H__ */