net: Use NULL to signal lack of promisc/multicast
[akaros.git] / kern / drivers / net / bnx2x / bnx2x_dcb.h
1 /* bnx2x_dcb.h: Broadcom Everest network driver.
2  *
3  * Copyright 2009-2013 Broadcom Corporation
4  *
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").
9  *
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.
14  *
15  * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
16  * Written by: Dmitry Kravkov
17  *
18  */
19 #pragma once
20
21 #include "bnx2x_hsi.h"
22
23 #define LLFC_DRIVER_TRAFFIC_TYPE_MAX 3 /* NW, iSCSI, FCoE */
24 struct bnx2x_dcbx_app_params {
25         uint32_t enabled;
26         uint32_t traffic_type_priority[LLFC_DRIVER_TRAFFIC_TYPE_MAX];
27 };
28
29 #define DCBX_COS_MAX_NUM_E2     DCBX_E2E3_MAX_NUM_COS
30 /* bnx2x currently limits numbers of supported COSes to 3 to be extended to 6 */
31 #define BNX2X_MAX_COS_SUPPORT   3
32 #define DCBX_COS_MAX_NUM_E3B0   BNX2X_MAX_COS_SUPPORT
33 #define DCBX_COS_MAX_NUM        BNX2X_MAX_COS_SUPPORT
34
35 struct bnx2x_dcbx_cos_params {
36         uint32_t        bw_tbl;
37         uint32_t        pri_bitmask;
38         /*
39          * strict priority: valid values are 0..5; 0 is highest priority.
40          * There can't be two COSes with the same priority.
41          */
42         uint8_t strict;
43 #define BNX2X_DCBX_STRICT_INVALID                       DCBX_COS_MAX_NUM
44 #define BNX2X_DCBX_STRICT_COS_HIGHEST                   0
45 #define BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(sp)        ((sp) + 1)
46         uint8_t pauseable;
47 };
48
49 struct bnx2x_dcbx_pg_params {
50         uint32_t enabled;
51         uint8_t num_of_cos; /* valid COS entries */
52         struct bnx2x_dcbx_cos_params    cos_params[DCBX_COS_MAX_NUM];
53 };
54
55 struct bnx2x_dcbx_pfc_params {
56         uint32_t enabled;
57         uint32_t priority_non_pauseable_mask;
58 };
59
60 struct bnx2x_dcbx_port_params {
61         struct bnx2x_dcbx_pfc_params pfc;
62         struct bnx2x_dcbx_pg_params  ets;
63         struct bnx2x_dcbx_app_params app;
64 };
65
66 #define BNX2X_DCBX_CONFIG_INV_VALUE                     (0xFFFFFFFF)
67 #define BNX2X_DCBX_OVERWRITE_SETTINGS_DISABLE           0
68 #define BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE            1
69 #define BNX2X_DCBX_OVERWRITE_SETTINGS_INVALID   (BNX2X_DCBX_CONFIG_INV_VALUE)
70 #define BNX2X_IS_ETS_ENABLED(bp) ((bp)->dcb_state == BNX2X_DCB_STATE_ON &&\
71                                   (bp)->dcbx_port_params.ets.enabled)
72
73 struct bnx2x_config_lldp_params {
74         uint32_t overwrite_settings;
75         uint32_t msg_tx_hold;
76         uint32_t msg_fast_tx;
77         uint32_t tx_credit_max;
78         uint32_t msg_tx_interval;
79         uint32_t tx_fast;
80 };
81
82 struct bnx2x_admin_priority_app_table {
83                 uint32_t valid;
84                 uint32_t priority;
85 #define INVALID_TRAFFIC_TYPE_PRIORITY   (0xFFFFFFFF)
86                 uint32_t traffic_type;
87 #define TRAFFIC_TYPE_ETH                0
88 #define TRAFFIC_TYPE_PORT               1
89                 uint32_t app_id;
90 };
91
92 #define DCBX_CONFIG_MAX_APP_PROTOCOL 4
93 struct bnx2x_config_dcbx_params {
94         uint32_t overwrite_settings;
95         uint32_t admin_dcbx_version;
96         uint32_t admin_ets_enable;
97         uint32_t admin_pfc_enable;
98         uint32_t admin_tc_supported_tx_enable;
99         uint32_t admin_ets_configuration_tx_enable;
100         uint32_t admin_ets_recommendation_tx_enable;
101         uint32_t admin_pfc_tx_enable;
102         uint32_t admin_application_priority_tx_enable;
103         uint32_t admin_ets_willing;
104         uint32_t admin_ets_reco_valid;
105         uint32_t admin_pfc_willing;
106         uint32_t admin_app_priority_willing;
107         uint32_t admin_configuration_bw_precentage[8];
108         uint32_t admin_configuration_ets_pg[8];
109         uint32_t admin_recommendation_bw_precentage[8];
110         uint32_t admin_recommendation_ets_pg[8];
111         uint32_t admin_pfc_bitmap;
112         struct bnx2x_admin_priority_app_table
113                 admin_priority_app_table[DCBX_CONFIG_MAX_APP_PROTOCOL];
114         uint32_t admin_default_priority;
115 };
116
117 #define GET_FLAGS(flags, bits)          ((flags) & (bits))
118 #define SET_FLAGS(flags, bits)          ((flags) |= (bits))
119 #define RESET_FLAGS(flags, bits)        ((flags) &= ~(bits))
120
121 enum {
122         DCBX_READ_LOCAL_MIB,
123         DCBX_READ_REMOTE_MIB
124 };
125
126 #define ETH_TYPE_FCOE           (0x8906)
127 #define TCP_PORT_ISCSI          (0xCBC)
128
129 #define PFC_VALUE_FRAME_SIZE                            (512)
130 #define PFC_QUANTA_IN_NANOSEC_FROM_SPEED_MEGA(mega_speed)  \
131                                 ((1000 * PFC_VALUE_FRAME_SIZE)/(mega_speed))
132
133 #define PFC_BRB1_REG_HIGH_LLFC_LOW_THRESHOLD                    130
134 #define PFC_BRB1_REG_HIGH_LLFC_HIGH_THRESHOLD                   170
135
136 struct cos_entry_help_data {
137         uint32_t                        pri_join_mask;
138         uint32_t                        cos_bw;
139         uint8_t                 strict;
140         bool                    pausable;
141 };
142
143 struct cos_help_data {
144         struct cos_entry_help_data      data[DCBX_COS_MAX_NUM];
145         uint8_t                         num_of_cos;
146 };
147
148 #define DCBX_ILLEGAL_PG                         (0xFF)
149 #define DCBX_PFC_PRI_MASK                       (0xFF)
150 #define DCBX_STRICT_PRIORITY                    (15)
151 #define DCBX_INVALID_COS_BW                     (0xFFFFFFFF)
152 #define DCBX_PFC_PRI_NON_PAUSE_MASK(bp)         \
153                         ((bp)->dcbx_port_params.pfc.priority_non_pauseable_mask)
154 #define DCBX_PFC_PRI_PAUSE_MASK(bp)             \
155                                         ((uint8_t)~DCBX_PFC_PRI_NON_PAUSE_MASK(bp))
156 #define DCBX_PFC_PRI_GET_PAUSE(bp, pg_pri)      \
157                                 ((pg_pri) & (DCBX_PFC_PRI_PAUSE_MASK(bp)))
158 #define DCBX_PFC_PRI_GET_NON_PAUSE(bp, pg_pri)  \
159                         (DCBX_PFC_PRI_NON_PAUSE_MASK(bp) & (pg_pri))
160 #define DCBX_IS_PFC_PRI_SOME_PAUSE(bp, pg_pri)  \
161                         (0 != DCBX_PFC_PRI_GET_PAUSE(bp, pg_pri))
162 #define IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pg_pri)  \
163                         (pg_pri == DCBX_PFC_PRI_GET_PAUSE((bp), (pg_pri)))
164 #define IS_DCBX_PFC_PRI_ONLY_NON_PAUSE(bp, pg_pri)\
165                         ((pg_pri) == DCBX_PFC_PRI_GET_NON_PAUSE((bp), (pg_pri)))
166 #define IS_DCBX_PFC_PRI_MIX_PAUSE(bp, pg_pri)   \
167                         (!(IS_DCBX_PFC_PRI_ONLY_NON_PAUSE((bp), (pg_pri)) || \
168                          IS_DCBX_PFC_PRI_ONLY_PAUSE((bp), (pg_pri))))
169
170 struct pg_entry_help_data {
171         uint8_t num_of_dif_pri;
172         uint8_t pg;
173         uint32_t        pg_priority;
174 };
175
176 struct pg_help_data {
177         struct pg_entry_help_data       data[LLFC_DRIVER_TRAFFIC_TYPE_MAX];
178         uint8_t                         num_of_pg;
179 };
180
181 /* forward DCB/PFC related declarations */
182 struct bnx2x;
183 void bnx2x_dcbx_update(struct work_struct *work);
184 void bnx2x_dcbx_init_params(struct bnx2x *bp);
185 void bnx2x_dcbx_set_state(struct bnx2x *bp, bool dcb_on,
186                           uint32_t dcbx_enabled);
187
188 enum {
189         BNX2X_DCBX_STATE_NEG_RECEIVED = 0x1,
190         BNX2X_DCBX_STATE_TX_PAUSED,
191         BNX2X_DCBX_STATE_TX_RELEASED
192 };
193
194 void bnx2x_dcbx_set_params(struct bnx2x *bp, uint32_t state);
195 void bnx2x_dcbx_pmf_update(struct bnx2x *bp);
196 /* DCB netlink */
197 #ifdef BCM_DCBNL
198 extern const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops;
199 int bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall);
200 #endif /* BCM_DCBNL */
201
202 int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp);
203 int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp);