2 * Copyright (c) 2007-2013 Broadcom Corporation. All rights reserved.
4 * Eric Davis <edavis@broadcom.com>
5 * David Christensen <davidch@broadcom.com>
6 * Gary Zambrano <zambrano@broadcom.com>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of Broadcom Corporation nor the name of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written consent.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/cdefs.h>
35 __FBSDID("$FreeBSD$");
40 #define LLFC_DRIVER_TRAFFIC_TYPE_MAX 3 /* NW, iSCSI, FCoE */
41 struct bxe_dcbx_app_params {
43 uint32_t traffic_type_priority[LLFC_DRIVER_TRAFFIC_TYPE_MAX];
46 #define DCBX_COS_MAX_NUM_E2 DCBX_E2E3_MAX_NUM_COS
47 /* bxe currently limits numbers of supported COSes to 3 to be extended to 6 */
48 #define BXE_MAX_COS_SUPPORT 3
49 #define DCBX_COS_MAX_NUM_E3B0 BXE_MAX_COS_SUPPORT
50 #define DCBX_COS_MAX_NUM BXE_MAX_COS_SUPPORT
52 struct bxe_dcbx_cos_params {
56 * strict priority: valid values are 0..5; 0 is highest priority.
57 * There can't be two COSes with the same priority.
60 #define BXE_DCBX_STRICT_INVALID DCBX_COS_MAX_NUM
61 #define BXE_DCBX_STRICT_COS_HIGHEST 0
62 #define BXE_DCBX_STRICT_COS_NEXT_LOWER_PRI(sp) ((sp) + 1)
66 struct bxe_dcbx_pg_params {
68 uint8_t num_of_cos; /* valid COS entries */
69 struct bxe_dcbx_cos_params cos_params[DCBX_COS_MAX_NUM];
72 struct bxe_dcbx_pfc_params {
74 uint32_t priority_non_pauseable_mask;
77 struct bxe_dcbx_port_params {
78 struct bxe_dcbx_pfc_params pfc;
79 struct bxe_dcbx_pg_params ets;
80 struct bxe_dcbx_app_params app;
83 #define BXE_DCBX_CONFIG_INV_VALUE (0xFFFFFFFF)
84 #define BXE_DCBX_OVERWRITE_SETTINGS_DISABLE 0
85 #define BXE_DCBX_OVERWRITE_SETTINGS_ENABLE 1
86 #define BXE_DCBX_OVERWRITE_SETTINGS_INVALID (BXE_DCBX_CONFIG_INV_VALUE)
87 #define BXE_IS_ETS_ENABLED(sc) \
88 ((sc)->dcb_state == BXE_DCB_STATE_ON && \
89 (sc)->dcbx_port_params.ets.enabled)
91 struct bxe_config_lldp_params {
92 uint32_t overwrite_settings;
95 uint32_t tx_credit_max;
96 uint32_t msg_tx_interval;
100 struct bxe_lldp_params_get {
102 #define LLDP_PARAMS_VER_NUM 2
103 struct bxe_config_lldp_params config_lldp_params;
104 /* The reserved field should follow in case the struct above will increase*/
105 uint32_t _reserved[20];
106 uint32_t admin_status;
107 #define LLDP_TX_ONLY 0x01
108 #define LLDP_RX_ONLY 0x02
109 #define LLDP_TX_RX 0x03
110 #define LLDP_DISABLED 0x04
111 uint32_t remote_chassis_id[REM_CHASSIS_ID_STAT_LEN];
112 uint32_t remote_port_id[REM_PORT_ID_STAT_LEN];
113 uint32_t local_chassis_id[LOCAL_CHASSIS_ID_STAT_LEN];
114 uint32_t local_port_id[LOCAL_PORT_ID_STAT_LEN];
117 struct bxe_admin_priority_app_table {
120 #define INVALID_TRAFFIC_TYPE_PRIORITY (0xFFFFFFFF)
121 uint32_t traffic_type;
122 #define TRAFFIC_TYPE_ETH 0
123 #define TRAFFIC_TYPE_PORT 1
127 #define DCBX_CONFIG_MAX_APP_PROTOCOL 4
128 struct bxe_config_dcbx_params {
129 uint32_t overwrite_settings;
130 uint32_t admin_dcbx_version;
131 uint32_t admin_ets_enable;
132 uint32_t admin_pfc_enable;
133 uint32_t admin_tc_supported_tx_enable;
134 uint32_t admin_ets_configuration_tx_enable;
135 uint32_t admin_ets_recommendation_tx_enable;
136 uint32_t admin_pfc_tx_enable;
137 uint32_t admin_application_priority_tx_enable;
138 uint32_t admin_ets_willing;
139 uint32_t admin_ets_reco_valid;
140 uint32_t admin_pfc_willing;
141 uint32_t admin_app_priority_willing;
142 uint32_t admin_configuration_bw_precentage[8];
143 uint32_t admin_configuration_ets_pg[8];
144 uint32_t admin_recommendation_bw_precentage[8];
145 uint32_t admin_recommendation_ets_pg[8];
146 uint32_t admin_pfc_bitmap;
147 struct bxe_admin_priority_app_table
148 admin_priority_app_table[DCBX_CONFIG_MAX_APP_PROTOCOL];
149 uint32_t admin_default_priority;
152 //#define DCBX_PARAMS_VER_NUM 3 /* XXX conflict with common_uif.h */
153 struct bxe_dcbx_params_get {
156 uint32_t dcbx_enabled;
157 struct bxe_config_dcbx_params config_dcbx_params;
158 /* The reserved field should follow in case the struct above will increase*/
159 uint32_t _reserved[19];
161 uint32_t dcb_current_state;
162 #define BXE_DCBX_CURRENT_STATE_IS_SYNC (1 << 0)
163 #define BXE_PFC_IS_CURRENTLY_OPERATIONAL (1 << 1)
164 #define BXE_ETS_IS_CURRENTLY_OPERATIONAL (1 << 2)
165 #define BXE_PRIORITY_TAGGING_IS_CURRENTLY_OPERATIONAL (1 << 3)
167 uint32_t local_tc_supported;
168 uint32_t local_pfc_caps;
169 uint32_t remote_tc_supported;
170 uint32_t remote_pfc_cap;
171 uint32_t remote_ets_willing;
172 uint32_t remote_ets_reco_valid;
173 uint32_t remote_pfc_willing;
174 uint32_t remote_app_priority_willing;
175 uint32_t remote_configuration_bw_precentage[8];
176 uint32_t remote_configuration_ets_pg[8];
177 uint32_t remote_recommendation_bw_precentage[8];
178 uint32_t remote_recommendation_ets_pg[8];
179 uint32_t remote_pfc_bitmap;
180 struct bxe_admin_priority_app_table
181 remote_priority_app_table[DCBX_MAX_APP_PROTOCOL];
182 uint32_t local_ets_enable;
183 uint32_t local_pfc_enable;
184 uint32_t local_configuration_bw_precentage[8];
185 uint32_t local_configuration_ets_pg[8];
186 uint32_t local_pfc_bitmap;
187 struct bxe_admin_priority_app_table
188 local_priority_app_table[DCBX_MAX_APP_PROTOCOL];
189 uint32_t pfc_mismatch;
190 uint32_t priority_app_mismatch;
191 uint32_t dcbx_frames_sent;
192 uint32_t dcbx_frames_received;
193 uint32_t pfc_frames_sent[2];
194 uint32_t pfc_frames_received[2];
197 struct bxe_dcbx_params_set {
200 uint32_t dcbx_enabled;
201 struct bxe_config_dcbx_params config_dcbx_params;
204 #define GET_FLAGS(flags, bits) ((flags) & (bits))
205 #define SET_FLAGS(flags, bits) ((flags) |= (bits))
206 #define RESET_FLAGS(flags, bits) ((flags) &= ~(bits))
213 #define ETH_TYPE_FCOE (0x8906)
214 #define TCP_PORT_ISCSI (0xCBC)
216 #define PFC_VALUE_FRAME_SIZE (512)
217 #define PFC_QUANTA_IN_NANOSEC_FROM_SPEED_MEGA(mega_speed) \
218 ((1000 * PFC_VALUE_FRAME_SIZE)/(mega_speed))
220 #define PFC_BRB1_REG_HIGH_LLFC_LOW_THRESHOLD 130
221 #define PFC_BRB1_REG_HIGH_LLFC_HIGH_THRESHOLD 170
223 struct cos_entry_help_data {
224 uint32_t pri_join_mask;
230 struct cos_help_data {
231 struct cos_entry_help_data data[DCBX_COS_MAX_NUM];
235 #define DCBX_ILLEGAL_PG (0xFF)
236 #define DCBX_PFC_PRI_MASK (0xFF)
237 #define DCBX_STRICT_PRIORITY (15)
238 #define DCBX_INVALID_COS_BW (0xFFFFFFFF)
239 #define DCBX_PFC_PRI_NON_PAUSE_MASK(sc) \
240 ((sc)->dcbx_port_params.pfc.priority_non_pauseable_mask)
241 #define DCBX_PFC_PRI_PAUSE_MASK(sc) \
242 ((uint8_t)~DCBX_PFC_PRI_NON_PAUSE_MASK(sc))
243 #define DCBX_PFC_PRI_GET_PAUSE(sc, pg_pri) \
244 ((pg_pri) & (DCBX_PFC_PRI_PAUSE_MASK(sc)))
245 #define DCBX_PFC_PRI_GET_NON_PAUSE(sc, pg_pri) \
246 (DCBX_PFC_PRI_NON_PAUSE_MASK(sc) & (pg_pri))
247 #define DCBX_IS_PFC_PRI_SOME_PAUSE(sc, pg_pri) \
248 (0 != DCBX_PFC_PRI_GET_PAUSE(sc, pg_pri))
249 #define IS_DCBX_PFC_PRI_ONLY_PAUSE(sc, pg_pri) \
250 (pg_pri == DCBX_PFC_PRI_GET_PAUSE((sc), (pg_pri)))
251 #define IS_DCBX_PFC_PRI_ONLY_NON_PAUSE(sc, pg_pri) \
252 ((pg_pri) == DCBX_PFC_PRI_GET_NON_PAUSE((sc), (pg_pri)))
253 #define IS_DCBX_PFC_PRI_MIX_PAUSE(sc, pg_pri) \
254 (!(IS_DCBX_PFC_PRI_ONLY_NON_PAUSE((sc), (pg_pri)) || \
255 IS_DCBX_PFC_PRI_ONLY_PAUSE((sc), (pg_pri))))
257 struct pg_entry_help_data {
258 uint8_t num_of_dif_pri;
260 uint32_t pg_priority;
263 struct pg_help_data {
264 struct pg_entry_help_data data[LLFC_DRIVER_TRAFFIC_TYPE_MAX];
268 /* forward DCB/PFC related declarations */
270 /* void bxe_dcbx_update(struct work_struct *work); */
271 void bxe_dcbx_init_params(struct bxe_softc *sc);
272 void bxe_dcbx_set_state(struct bxe_softc *sc, uint8_t dcb_on, uint32_t dcbx_enabled);
273 int bxe_dcb_get_lldp_params_ioctl(struct bxe_softc *sc, void *uaddr);
274 int bxe_dcb_get_dcbx_params_ioctl(struct bxe_softc *sc, void *uaddr);
275 int bxe_dcb_set_dcbx_params_ioctl(struct bxe_softc *sc, void *uaddr);
278 BXE_DCBX_STATE_NEG_RECEIVED = 0x1,
279 BXE_DCBX_STATE_TX_PAUSED,
280 BXE_DCBX_STATE_TX_RELEASED
283 void bxe_dcbx_set_params(struct bxe_softc *sc, uint32_t state);
284 void bxe_dcbx_pmf_update(struct bxe_softc *sc);
286 #endif /* BXE_DCB_H */