Imported Upstream version 16.07-rc1
[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.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         bool update;            /* Update indication */
27         u8 priority;            /* Priority */
28         u8 tc;                  /* Traffic Class */
29 };
30
31 #ifndef __EXTRACT__LINUX__
32 enum dcbx_protocol_type {
33         DCBX_PROTOCOL_ETH,
34         DCBX_MAX_PROTOCOL_TYPE
35 };
36
37 #ifdef LINUX_REMOVE
38 /* We can't assume THE HSI values are available to clients, so we need
39  * to redefine those here.
40  */
41 #ifndef LLDP_CHASSIS_ID_STAT_LEN
42 #define LLDP_CHASSIS_ID_STAT_LEN 4
43 #endif
44 #ifndef LLDP_PORT_ID_STAT_LEN
45 #define LLDP_PORT_ID_STAT_LEN 4
46 #endif
47 #ifndef DCBX_MAX_APP_PROTOCOL
48 #define DCBX_MAX_APP_PROTOCOL 32
49 #endif
50
51 #endif
52
53 struct ecore_dcbx_lldp_remote {
54         u32 peer_chassis_id[LLDP_CHASSIS_ID_STAT_LEN];
55         u32 peer_port_id[LLDP_PORT_ID_STAT_LEN];
56         bool enable_rx;
57         bool enable_tx;
58         u32 tx_interval;
59         u32 max_credit;
60 };
61
62 struct ecore_dcbx_lldp_local {
63         u32 local_chassis_id[LLDP_CHASSIS_ID_STAT_LEN];
64         u32 local_port_id[LLDP_PORT_ID_STAT_LEN];
65 };
66
67 struct ecore_dcbx_app_prio {
68         u8 eth;
69 };
70
71 struct ecore_dcbx_params {
72         u32 app_bitmap[DCBX_MAX_APP_PROTOCOL];
73         u16 num_app_entries;
74         bool app_willing;
75         bool app_valid;
76         bool ets_willing;
77         bool ets_enabled;
78         bool valid;             /* Indicate validity of params */
79         u32 ets_pri_tc_tbl[1];
80         u32 ets_tc_bw_tbl[2];
81         u32 ets_tc_tsa_tbl[2];
82         bool pfc_willing;
83         bool pfc_enabled;
84         u32 pfc_bitmap;
85         u8 max_pfc_tc;
86         u8 max_ets_tc;
87 };
88
89 struct ecore_dcbx_admin_params {
90         struct ecore_dcbx_params params;
91         bool valid;             /* Indicate validity of params */
92 };
93
94 struct ecore_dcbx_remote_params {
95         struct ecore_dcbx_params params;
96         bool valid;             /* Indicate validity of params */
97 };
98
99 struct ecore_dcbx_operational_params {
100         struct ecore_dcbx_app_prio app_prio;
101         struct ecore_dcbx_params params;
102         bool valid;             /* Indicate validity of params */
103         bool enabled;
104         bool ieee;
105         bool cee;
106         u32 err;
107 };
108
109 struct ecore_dcbx_get {
110         struct ecore_dcbx_operational_params operational;
111         struct ecore_dcbx_lldp_remote lldp_remote;
112         struct ecore_dcbx_lldp_local lldp_local;
113         struct ecore_dcbx_remote_params remote;
114         struct ecore_dcbx_admin_params local;
115 };
116 #endif
117
118 struct ecore_dcbx_set {
119         struct ecore_dcbx_admin_params config;
120         bool enabled;
121         u32 ver_num;
122 };
123
124 struct ecore_dcbx_results {
125         bool dcbx_enabled;
126         u8 pf_id;
127         struct ecore_dcbx_app_data arr[DCBX_MAX_PROTOCOL_TYPE];
128 };
129
130 struct ecore_dcbx_app_metadata {
131         enum dcbx_protocol_type id;
132         const char *name;       /* @DPDK */
133         enum ecore_pci_personality personality;
134 };
135
136 struct ecore_dcbx_mib_meta_data {
137         struct lldp_config_params_s *lldp_local;
138         struct lldp_status_params_s *lldp_remote;
139         struct dcbx_local_params *local_admin;
140         struct dcbx_mib *mib;
141         osal_size_t size;
142         u32 addr;
143 };
144
145 void
146 ecore_dcbx_set_params(struct ecore_dcbx_results *p_data,
147                       struct ecore_hw_info *p_info,
148                       bool enable, bool update, u8 prio, u8 tc,
149                       enum dcbx_protocol_type type,
150                       enum ecore_pci_personality personality);
151
152 enum _ecore_status_t ecore_dcbx_query_params(struct ecore_hwfn *,
153                                              struct ecore_dcbx_get *,
154                                              enum ecore_mib_read_type);
155
156 static const struct ecore_dcbx_app_metadata ecore_dcbx_app_update[] = {
157         {DCBX_PROTOCOL_ETH, "ETH", ECORE_PCI_ETH}
158 };
159
160 #endif /* __ECORE_DCBX_API_H__ */