sfc: Don't use enums as a bitmask.
[zen-stable.git] / drivers / net / bnx2x / bnx2x_dcb.h
blobbed369d67e02b010afe43363f373aa1543408bad
1 /* bnx2x_dcb.h: Broadcom Everest network driver.
3 * Copyright 2009-2011 Broadcom Corporation
5 * Unless you and Broadcom execute a separate written software license
6 * agreement governing use of this software, this software is licensed to you
7 * under the terms of the GNU General Public License version 2, available
8 * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
10 * Notwithstanding the above, under no circumstances may you combine this
11 * software in any way with any other Broadcom software provided under a
12 * license other than the GPL, without Broadcom's express prior written
13 * consent.
15 * Maintained by: Eilon Greenstein <eilong@broadcom.com>
16 * Written by: Dmitry Kravkov
19 #ifndef BNX2X_DCB_H
20 #define BNX2X_DCB_H
22 #include "bnx2x_hsi.h"
24 #define LLFC_DRIVER_TRAFFIC_TYPE_MAX 3 /* NW, iSCSI, FCoE */
25 struct bnx2x_dcbx_app_params {
26 u32 enabled;
27 u32 traffic_type_priority[LLFC_DRIVER_TRAFFIC_TYPE_MAX];
30 #define E2_NUM_OF_COS 2
31 #define BNX2X_DCBX_COS_NOT_STRICT 0
32 #define BNX2X_DCBX_COS_LOW_STRICT 1
33 #define BNX2X_DCBX_COS_HIGH_STRICT 2
35 struct bnx2x_dcbx_cos_params {
36 u32 bw_tbl;
37 u32 pri_bitmask;
38 u8 strict;
39 u8 pauseable;
42 struct bnx2x_dcbx_pg_params {
43 u32 enabled;
44 u8 num_of_cos; /* valid COS entries */
45 struct bnx2x_dcbx_cos_params cos_params[E2_NUM_OF_COS];
48 struct bnx2x_dcbx_pfc_params {
49 u32 enabled;
50 u32 priority_non_pauseable_mask;
53 struct bnx2x_dcbx_port_params {
54 struct bnx2x_dcbx_pfc_params pfc;
55 struct bnx2x_dcbx_pg_params ets;
56 struct bnx2x_dcbx_app_params app;
59 #define BNX2X_DCBX_CONFIG_INV_VALUE (0xFFFFFFFF)
60 #define BNX2X_DCBX_OVERWRITE_SETTINGS_DISABLE 0
61 #define BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE 1
62 #define BNX2X_DCBX_OVERWRITE_SETTINGS_INVALID (BNX2X_DCBX_CONFIG_INV_VALUE)
64 struct bnx2x_config_lldp_params {
65 u32 overwrite_settings;
66 u32 msg_tx_hold;
67 u32 msg_fast_tx;
68 u32 tx_credit_max;
69 u32 msg_tx_interval;
70 u32 tx_fast;
73 struct bnx2x_admin_priority_app_table {
74 u32 valid;
75 u32 priority;
76 #define INVALID_TRAFFIC_TYPE_PRIORITY (0xFFFFFFFF)
77 u32 traffic_type;
78 #define TRAFFIC_TYPE_ETH 0
79 #define TRAFFIC_TYPE_PORT 1
80 u32 app_id;
83 struct bnx2x_config_dcbx_params {
84 u32 overwrite_settings;
85 u32 admin_dcbx_version;
86 u32 admin_ets_enable;
87 u32 admin_pfc_enable;
88 u32 admin_tc_supported_tx_enable;
89 u32 admin_ets_configuration_tx_enable;
90 u32 admin_ets_recommendation_tx_enable;
91 u32 admin_pfc_tx_enable;
92 u32 admin_application_priority_tx_enable;
93 u32 admin_ets_willing;
94 u32 admin_ets_reco_valid;
95 u32 admin_pfc_willing;
96 u32 admin_app_priority_willing;
97 u32 admin_configuration_bw_precentage[8];
98 u32 admin_configuration_ets_pg[8];
99 u32 admin_recommendation_bw_precentage[8];
100 u32 admin_recommendation_ets_pg[8];
101 u32 admin_pfc_bitmap;
102 struct bnx2x_admin_priority_app_table admin_priority_app_table[4];
103 u32 admin_default_priority;
106 #define GET_FLAGS(flags, bits) ((flags) & (bits))
107 #define SET_FLAGS(flags, bits) ((flags) |= (bits))
108 #define RESET_FLAGS(flags, bits) ((flags) &= ~(bits))
110 enum {
111 DCBX_READ_LOCAL_MIB,
112 DCBX_READ_REMOTE_MIB
115 #define ETH_TYPE_FCOE (0x8906)
116 #define TCP_PORT_ISCSI (0xCBC)
118 #define PFC_VALUE_FRAME_SIZE (512)
119 #define PFC_QUANTA_IN_NANOSEC_FROM_SPEED_MEGA(mega_speed) \
120 ((1000 * PFC_VALUE_FRAME_SIZE)/(mega_speed))
122 #define PFC_BRB1_REG_HIGH_LLFC_LOW_THRESHOLD 130
123 #define PFC_BRB1_REG_HIGH_LLFC_HIGH_THRESHOLD 170
127 struct cos_entry_help_data {
128 u32 pri_join_mask;
129 u32 cos_bw;
130 u8 strict;
131 bool pausable;
134 struct cos_help_data {
135 struct cos_entry_help_data data[E2_NUM_OF_COS];
136 u8 num_of_cos;
139 #define DCBX_ILLEGAL_PG (0xFF)
140 #define DCBX_PFC_PRI_MASK (0xFF)
141 #define DCBX_STRICT_PRIORITY (15)
142 #define DCBX_INVALID_COS_BW (0xFFFFFFFF)
143 #define DCBX_PFC_PRI_NON_PAUSE_MASK(bp) \
144 ((bp)->dcbx_port_params.pfc.priority_non_pauseable_mask)
145 #define DCBX_PFC_PRI_PAUSE_MASK(bp) \
146 ((u8)~DCBX_PFC_PRI_NON_PAUSE_MASK(bp))
147 #define DCBX_PFC_PRI_GET_PAUSE(bp, pg_pri) \
148 ((pg_pri) & (DCBX_PFC_PRI_PAUSE_MASK(bp)))
149 #define DCBX_PFC_PRI_GET_NON_PAUSE(bp, pg_pri) \
150 (DCBX_PFC_PRI_NON_PAUSE_MASK(bp) & (pg_pri))
151 #define IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pg_pri) \
152 (pg_pri == DCBX_PFC_PRI_GET_PAUSE((bp), (pg_pri)))
153 #define IS_DCBX_PFC_PRI_ONLY_NON_PAUSE(bp, pg_pri)\
154 ((pg_pri) == DCBX_PFC_PRI_GET_NON_PAUSE((bp), (pg_pri)))
155 #define IS_DCBX_PFC_PRI_MIX_PAUSE(bp, pg_pri) \
156 (!(IS_DCBX_PFC_PRI_ONLY_NON_PAUSE((bp), (pg_pri)) || \
157 IS_DCBX_PFC_PRI_ONLY_PAUSE((bp), (pg_pri))))
160 struct pg_entry_help_data {
161 u8 num_of_dif_pri;
162 u8 pg;
163 u32 pg_priority;
166 struct pg_help_data {
167 struct pg_entry_help_data data[LLFC_DRIVER_TRAFFIC_TYPE_MAX];
168 u8 num_of_pg;
171 /* forward DCB/PFC related declarations */
172 struct bnx2x;
173 void bnx2x_dcb_init_intmem_pfc(struct bnx2x *bp);
174 void bnx2x_dcbx_update(struct work_struct *work);
175 void bnx2x_dcbx_init_params(struct bnx2x *bp);
176 void bnx2x_dcbx_set_state(struct bnx2x *bp, bool dcb_on, u32 dcbx_enabled);
178 enum {
179 BNX2X_DCBX_STATE_NEG_RECEIVED = 0x1,
180 #ifdef BCM_CNIC
181 BNX2X_DCBX_STATE_ISCSI_STOPPED,
182 #endif
183 BNX2X_DCBX_STATE_TX_PAUSED,
184 BNX2X_DCBX_STATE_TX_RELEASED
187 void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state);
189 /* DCB netlink */
190 #ifdef BCM_DCBNL
191 extern const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops;
192 int bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall);
193 #endif /* BCM_DCBNL */
195 #endif /* BNX2X_DCB_H */