2dc767961c8bb2b5bd2ecc63060ec9cb551a3fa4
[deb_dpdk.git] / drivers / net / qede / base / ecore_dcbx_api.h
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 };
23
24 struct ecore_dcbx_app_data {
25         bool enable;            /* DCB enabled */
26         u8 update;              /* Update indication */
27         u8 priority;            /* Priority */
28         u8 tc;                  /* Traffic Class */
29         bool dscp_enable;       /* DSCP enabled */
30         u8 dscp_val;            /* DSCP value */
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         bool    valid;          /* Indicate validity of params */
105         u8      ets_pri_tc_tbl[ECORE_MAX_PFC_PRIORITIES];
106         u8      ets_tc_bw_tbl[ECORE_MAX_PFC_PRIORITIES];
107         u8      ets_tc_tsa_tbl[ECORE_MAX_PFC_PRIORITIES];
108         struct ecore_dbcx_pfc_params pfc;
109         u8      max_ets_tc;
110 };
111
112 struct ecore_dcbx_admin_params {
113         struct ecore_dcbx_params params;
114         bool valid;             /* Indicate validity of params */
115 };
116
117 struct ecore_dcbx_remote_params {
118         struct ecore_dcbx_params params;
119         bool valid;             /* Indicate validity of params */
120 };
121
122 struct ecore_dcbx_operational_params {
123         struct ecore_dcbx_app_prio app_prio;
124         struct ecore_dcbx_params params;
125         bool valid;             /* Indicate validity of params */
126         bool enabled;
127         bool ieee;
128         bool cee;
129         bool local;
130         u32 err;
131 };
132
133 struct ecore_dcbx_dscp_params {
134         bool enabled;
135         u8 dscp_pri_map[ECORE_DCBX_DSCP_SIZE];
136 };
137
138 struct ecore_dcbx_get {
139         struct ecore_dcbx_operational_params operational;
140         struct ecore_dcbx_lldp_remote lldp_remote;
141         struct ecore_dcbx_lldp_local lldp_local;
142         struct ecore_dcbx_remote_params remote;
143         struct ecore_dcbx_admin_params local;
144         struct ecore_dcbx_dscp_params dscp;
145 };
146 #endif
147
148 #define ECORE_DCBX_VERSION_DISABLED     0
149 #define ECORE_DCBX_VERSION_IEEE         1
150 #define ECORE_DCBX_VERSION_CEE          2
151 #define ECORE_DCBX_VERSION_DYNAMIC      3
152
153 struct ecore_dcbx_set {
154 #define ECORE_DCBX_OVERRIDE_STATE       (1 << 0)
155 #define ECORE_DCBX_OVERRIDE_PFC_CFG     (1 << 1)
156 #define ECORE_DCBX_OVERRIDE_ETS_CFG     (1 << 2)
157 #define ECORE_DCBX_OVERRIDE_APP_CFG     (1 << 3)
158 #define ECORE_DCBX_OVERRIDE_DSCP_CFG    (1 << 4)
159         u32 override_flags;
160         bool enabled;
161         struct ecore_dcbx_admin_params config;
162         u32 ver_num;
163         struct ecore_dcbx_dscp_params dscp;
164 };
165
166 struct ecore_dcbx_results {
167         bool dcbx_enabled;
168         u8 pf_id;
169         struct ecore_dcbx_app_data arr[DCBX_MAX_PROTOCOL_TYPE];
170 };
171
172 struct ecore_dcbx_app_metadata {
173         enum dcbx_protocol_type id;
174         const char *name; /* @DPDK */
175         enum ecore_pci_personality personality;
176 };
177
178 enum _ecore_status_t ecore_dcbx_query_params(struct ecore_hwfn *,
179                                              struct ecore_dcbx_get *,
180                                              enum ecore_mib_read_type);
181
182 enum _ecore_status_t ecore_dcbx_get_config_params(struct ecore_hwfn *,
183                                                   struct ecore_dcbx_set *);
184
185 enum _ecore_status_t ecore_dcbx_config_params(struct ecore_hwfn *,
186                                               struct ecore_ptt *,
187                                               struct ecore_dcbx_set *,
188                                               bool);
189
190 static const struct ecore_dcbx_app_metadata ecore_dcbx_app_update[] = {
191         {DCBX_PROTOCOL_ISCSI, "ISCSI", ECORE_PCI_ISCSI},
192         {DCBX_PROTOCOL_FCOE, "FCOE", ECORE_PCI_FCOE},
193         {DCBX_PROTOCOL_ROCE, "ROCE", ECORE_PCI_ETH_ROCE},
194         {DCBX_PROTOCOL_ROCE_V2, "ROCE_V2", ECORE_PCI_ETH_ROCE},
195         {DCBX_PROTOCOL_ETH, "ETH", ECORE_PCI_ETH},
196         {DCBX_PROTOCOL_IWARP, "IWARP", ECORE_PCI_ETH_IWARP}
197 };
198
199 #endif /* __ECORE_DCBX_API_H__ */