aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Fastabend <john.r.fastabend@intel.com>2011-01-04 23:47:43 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2011-02-11 11:44:04 -0500
commit55320cb58baebd1795ec92f4550a1e8b38bf9ddf (patch)
treeb2cf72c8c649e71677ba14ecd02bb7e27976d570
parent39a7e587ec76db9f157fce653235b20f5283b003 (diff)
ixgbe: DCB, abstract out dcb_config from DCB hardware configuration
Currently the routines that configure the HW for DCB require a ixgbe_dcb_config structure. This structure was designed to support the CEE standard and does not match the IEEE standard well. This patch changes the HW routines in ixgbe_dcb_8259x.{ch} to use raw pfc and bandwidth values. This requires some parsing of the DCB configuration but makes the HW routines independent of the data structure that contains the DCB configuration. The primary advantage to doing this is we can do HW setup directly from the 802.1Qaz ops without having to arbitrarily encapsulate this data into the CEE structure. Signed-off-by: John Fastabend <john.r.fastabend@intel.com> Tested-by: Ross Brattain <ross.b.brattain@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ixgbe/ixgbe_dcb.c74
-rw-r--r--drivers/net/ixgbe/ixgbe_dcb.h1
-rw-r--r--drivers/net/ixgbe/ixgbe_dcb_82598.c86
-rw-r--r--drivers/net/ixgbe/ixgbe_dcb_82598.h23
-rw-r--r--drivers/net/ixgbe/ixgbe_dcb_82599.c115
-rw-r--r--drivers/net/ixgbe/ixgbe_dcb_82599.h24
-rw-r--r--drivers/net/ixgbe/ixgbe_dcb_nl.c9
7 files changed, 230 insertions, 102 deletions
diff --git a/drivers/net/ixgbe/ixgbe_dcb.c b/drivers/net/ixgbe/ixgbe_dcb.c
index d16c260c1f50..d9bb670ae258 100644
--- a/drivers/net/ixgbe/ixgbe_dcb.c
+++ b/drivers/net/ixgbe/ixgbe_dcb.c
@@ -141,6 +141,59 @@ out:
141 return ret_val; 141 return ret_val;
142} 142}
143 143
144void ixgbe_dcb_unpack_pfc(struct ixgbe_dcb_config *cfg, u8 *pfc_en)
145{
146 int i;
147
148 *pfc_en = 0;
149 for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
150 *pfc_en |= (cfg->tc_config[i].dcb_pfc & 0xF) << i;
151}
152
153void ixgbe_dcb_unpack_refill(struct ixgbe_dcb_config *cfg, int direction,
154 u16 *refill)
155{
156 struct tc_bw_alloc *p;
157 int i;
158
159 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
160 p = &cfg->tc_config[i].path[direction];
161 refill[i] = p->data_credits_refill;
162 }
163}
164
165void ixgbe_dcb_unpack_max(struct ixgbe_dcb_config *cfg, u16 *max)
166{
167 int i;
168
169 for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
170 max[i] = cfg->tc_config[i].desc_credits_max;
171}
172
173void ixgbe_dcb_unpack_bwgid(struct ixgbe_dcb_config *cfg, int direction,
174 u8 *bwgid)
175{
176 struct tc_bw_alloc *p;
177 int i;
178
179 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
180 p = &cfg->tc_config[i].path[direction];
181 bwgid[i] = p->bwg_id;
182 }
183}
184
185void ixgbe_dcb_unpack_prio(struct ixgbe_dcb_config *cfg, int direction,
186 u8 *ptype)
187{
188 struct tc_bw_alloc *p;
189 int i;
190
191 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
192 p = &cfg->tc_config[i].path[direction];
193 ptype[i] = p->prio_type;
194 }
195}
196
144/** 197/**
145 * ixgbe_dcb_hw_config - Config and enable DCB 198 * ixgbe_dcb_hw_config - Config and enable DCB
146 * @hw: pointer to hardware structure 199 * @hw: pointer to hardware structure
@@ -152,13 +205,30 @@ s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw,
152 struct ixgbe_dcb_config *dcb_config) 205 struct ixgbe_dcb_config *dcb_config)
153{ 206{
154 s32 ret = 0; 207 s32 ret = 0;
208 u8 pfc_en;
209 u8 ptype[MAX_TRAFFIC_CLASS];
210 u8 bwgid[MAX_TRAFFIC_CLASS];
211 u16 refill[MAX_TRAFFIC_CLASS];
212 u16 max[MAX_TRAFFIC_CLASS];
213
214 /* Unpack CEE standard containers */
215 ixgbe_dcb_unpack_pfc(dcb_config, &pfc_en);
216 ixgbe_dcb_unpack_refill(dcb_config, DCB_TX_CONFIG, refill);
217 ixgbe_dcb_unpack_max(dcb_config, max);
218 ixgbe_dcb_unpack_bwgid(dcb_config, DCB_TX_CONFIG, bwgid);
219 ixgbe_dcb_unpack_prio(dcb_config, DCB_TX_CONFIG, ptype);
220
155 switch (hw->mac.type) { 221 switch (hw->mac.type) {
156 case ixgbe_mac_82598EB: 222 case ixgbe_mac_82598EB:
157 ret = ixgbe_dcb_hw_config_82598(hw, dcb_config); 223 ret = ixgbe_dcb_hw_config_82598(hw, dcb_config->rx_pba_cfg,
224 pfc_en, refill, max, bwgid,
225 ptype);
158 break; 226 break;
159 case ixgbe_mac_82599EB: 227 case ixgbe_mac_82599EB:
160 case ixgbe_mac_X540: 228 case ixgbe_mac_X540:
161 ret = ixgbe_dcb_hw_config_82599(hw, dcb_config); 229 ret = ixgbe_dcb_hw_config_82599(hw, dcb_config->rx_pba_cfg,
230 pfc_en, refill, max, bwgid,
231 ptype);
162 break; 232 break;
163 default: 233 default:
164 break; 234 break;
diff --git a/drivers/net/ixgbe/ixgbe_dcb.h b/drivers/net/ixgbe/ixgbe_dcb.h
index d0b2450781a2..aa6cb5f9ebf4 100644
--- a/drivers/net/ixgbe/ixgbe_dcb.h
+++ b/drivers/net/ixgbe/ixgbe_dcb.h
@@ -147,6 +147,7 @@ struct ixgbe_dcb_config {
147}; 147};
148 148
149/* DCB driver APIs */ 149/* DCB driver APIs */
150void ixgbe_dcb_unpack_pfc(struct ixgbe_dcb_config *cfg, u8 *pfc_en);
150 151
151/* DCB credits calculation */ 152/* DCB credits calculation */
152s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *, 153s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *,
diff --git a/drivers/net/ixgbe/ixgbe_dcb_82598.c b/drivers/net/ixgbe/ixgbe_dcb_82598.c
index 19aa80640f68..d1288060cbd0 100644
--- a/drivers/net/ixgbe/ixgbe_dcb_82598.c
+++ b/drivers/net/ixgbe/ixgbe_dcb_82598.c
@@ -38,15 +38,14 @@
38 * 38 *
39 * Configure packet buffers for DCB mode. 39 * Configure packet buffers for DCB mode.
40 */ 40 */
41static s32 ixgbe_dcb_config_packet_buffers_82598(struct ixgbe_hw *hw, 41static s32 ixgbe_dcb_config_packet_buffers_82598(struct ixgbe_hw *hw, u8 rx_pba)
42 struct ixgbe_dcb_config *dcb_config)
43{ 42{
44 s32 ret_val = 0; 43 s32 ret_val = 0;
45 u32 value = IXGBE_RXPBSIZE_64KB; 44 u32 value = IXGBE_RXPBSIZE_64KB;
46 u8 i = 0; 45 u8 i = 0;
47 46
48 /* Setup Rx packet buffer sizes */ 47 /* Setup Rx packet buffer sizes */
49 switch (dcb_config->rx_pba_cfg) { 48 switch (rx_pba) {
50 case pba_80_48: 49 case pba_80_48:
51 /* Setup the first four at 80KB */ 50 /* Setup the first four at 80KB */
52 value = IXGBE_RXPBSIZE_80KB; 51 value = IXGBE_RXPBSIZE_80KB;
@@ -78,10 +77,11 @@ static s32 ixgbe_dcb_config_packet_buffers_82598(struct ixgbe_hw *hw,
78 * 77 *
79 * Configure Rx Data Arbiter and credits for each traffic class. 78 * Configure Rx Data Arbiter and credits for each traffic class.
80 */ 79 */
81static s32 ixgbe_dcb_config_rx_arbiter_82598(struct ixgbe_hw *hw, 80s32 ixgbe_dcb_config_rx_arbiter_82598(struct ixgbe_hw *hw,
82 struct ixgbe_dcb_config *dcb_config) 81 u16 *refill,
82 u16 *max,
83 u8 *prio_type)
83{ 84{
84 struct tc_bw_alloc *p;
85 u32 reg = 0; 85 u32 reg = 0;
86 u32 credit_refill = 0; 86 u32 credit_refill = 0;
87 u32 credit_max = 0; 87 u32 credit_max = 0;
@@ -102,13 +102,12 @@ static s32 ixgbe_dcb_config_rx_arbiter_82598(struct ixgbe_hw *hw,
102 102
103 /* Configure traffic class credits and priority */ 103 /* Configure traffic class credits and priority */
104 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 104 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
105 p = &dcb_config->tc_config[i].path[DCB_RX_CONFIG]; 105 credit_refill = refill[i];
106 credit_refill = p->data_credits_refill; 106 credit_max = max[i];
107 credit_max = p->data_credits_max;
108 107
109 reg = credit_refill | (credit_max << IXGBE_RT2CR_MCL_SHIFT); 108 reg = credit_refill | (credit_max << IXGBE_RT2CR_MCL_SHIFT);
110 109
111 if (p->prio_type == prio_link) 110 if (prio_type[i] == prio_link)
112 reg |= IXGBE_RT2CR_LSP; 111 reg |= IXGBE_RT2CR_LSP;
113 112
114 IXGBE_WRITE_REG(hw, IXGBE_RT2CR(i), reg); 113 IXGBE_WRITE_REG(hw, IXGBE_RT2CR(i), reg);
@@ -135,10 +134,12 @@ static s32 ixgbe_dcb_config_rx_arbiter_82598(struct ixgbe_hw *hw,
135 * 134 *
136 * Configure Tx Descriptor Arbiter and credits for each traffic class. 135 * Configure Tx Descriptor Arbiter and credits for each traffic class.
137 */ 136 */
138static s32 ixgbe_dcb_config_tx_desc_arbiter_82598(struct ixgbe_hw *hw, 137s32 ixgbe_dcb_config_tx_desc_arbiter_82598(struct ixgbe_hw *hw,
139 struct ixgbe_dcb_config *dcb_config) 138 u16 *refill,
139 u16 *max,
140 u8 *bwg_id,
141 u8 *prio_type)
140{ 142{
141 struct tc_bw_alloc *p;
142 u32 reg, max_credits; 143 u32 reg, max_credits;
143 u8 i; 144 u8 i;
144 145
@@ -156,16 +157,15 @@ static s32 ixgbe_dcb_config_tx_desc_arbiter_82598(struct ixgbe_hw *hw,
156 157
157 /* Configure traffic class credits and priority */ 158 /* Configure traffic class credits and priority */
158 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 159 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
159 p = &dcb_config->tc_config[i].path[DCB_TX_CONFIG]; 160 max_credits = max[i];
160 max_credits = dcb_config->tc_config[i].desc_credits_max;
161 reg = max_credits << IXGBE_TDTQ2TCCR_MCL_SHIFT; 161 reg = max_credits << IXGBE_TDTQ2TCCR_MCL_SHIFT;
162 reg |= p->data_credits_refill; 162 reg |= refill[i];
163 reg |= (u32)(p->bwg_id) << IXGBE_TDTQ2TCCR_BWG_SHIFT; 163 reg |= (u32)(bwg_id[i]) << IXGBE_TDTQ2TCCR_BWG_SHIFT;
164 164
165 if (p->prio_type == prio_group) 165 if (prio_type[i] == prio_group)
166 reg |= IXGBE_TDTQ2TCCR_GSP; 166 reg |= IXGBE_TDTQ2TCCR_GSP;
167 167
168 if (p->prio_type == prio_link) 168 if (prio_type[i] == prio_link)
169 reg |= IXGBE_TDTQ2TCCR_LSP; 169 reg |= IXGBE_TDTQ2TCCR_LSP;
170 170
171 IXGBE_WRITE_REG(hw, IXGBE_TDTQ2TCCR(i), reg); 171 IXGBE_WRITE_REG(hw, IXGBE_TDTQ2TCCR(i), reg);
@@ -181,10 +181,12 @@ static s32 ixgbe_dcb_config_tx_desc_arbiter_82598(struct ixgbe_hw *hw,
181 * 181 *
182 * Configure Tx Data Arbiter and credits for each traffic class. 182 * Configure Tx Data Arbiter and credits for each traffic class.
183 */ 183 */
184static s32 ixgbe_dcb_config_tx_data_arbiter_82598(struct ixgbe_hw *hw, 184s32 ixgbe_dcb_config_tx_data_arbiter_82598(struct ixgbe_hw *hw,
185 struct ixgbe_dcb_config *dcb_config) 185 u16 *refill,
186 u16 *max,
187 u8 *bwg_id,
188 u8 *prio_type)
186{ 189{
187 struct tc_bw_alloc *p;
188 u32 reg; 190 u32 reg;
189 u8 i; 191 u8 i;
190 192
@@ -198,15 +200,14 @@ static s32 ixgbe_dcb_config_tx_data_arbiter_82598(struct ixgbe_hw *hw,
198 200
199 /* Configure traffic class credits and priority */ 201 /* Configure traffic class credits and priority */
200 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 202 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
201 p = &dcb_config->tc_config[i].path[DCB_TX_CONFIG]; 203 reg = refill[i];
202 reg = p->data_credits_refill; 204 reg |= (u32)(max[i]) << IXGBE_TDPT2TCCR_MCL_SHIFT;
203 reg |= (u32)(p->data_credits_max) << IXGBE_TDPT2TCCR_MCL_SHIFT; 205 reg |= (u32)(bwg_id[i]) << IXGBE_TDPT2TCCR_BWG_SHIFT;
204 reg |= (u32)(p->bwg_id) << IXGBE_TDPT2TCCR_BWG_SHIFT;
205 206
206 if (p->prio_type == prio_group) 207 if (prio_type[i] == prio_group)
207 reg |= IXGBE_TDPT2TCCR_GSP; 208 reg |= IXGBE_TDPT2TCCR_GSP;
208 209
209 if (p->prio_type == prio_link) 210 if (prio_type[i] == prio_link)
210 reg |= IXGBE_TDPT2TCCR_LSP; 211 reg |= IXGBE_TDPT2TCCR_LSP;
211 212
212 IXGBE_WRITE_REG(hw, IXGBE_TDPT2TCCR(i), reg); 213 IXGBE_WRITE_REG(hw, IXGBE_TDPT2TCCR(i), reg);
@@ -227,13 +228,12 @@ static s32 ixgbe_dcb_config_tx_data_arbiter_82598(struct ixgbe_hw *hw,
227 * 228 *
228 * Configure Priority Flow Control for each traffic class. 229 * Configure Priority Flow Control for each traffic class.
229 */ 230 */
230s32 ixgbe_dcb_config_pfc_82598(struct ixgbe_hw *hw, 231s32 ixgbe_dcb_config_pfc_82598(struct ixgbe_hw *hw, u8 pfc_en)
231 struct ixgbe_dcb_config *dcb_config)
232{ 232{
233 u32 reg, rx_pba_size; 233 u32 reg, rx_pba_size;
234 u8 i; 234 u8 i;
235 235
236 if (!dcb_config->pfc_mode_enable) 236 if (!pfc_en)
237 goto out; 237 goto out;
238 238
239 /* Enable Transmit Priority Flow Control */ 239 /* Enable Transmit Priority Flow Control */
@@ -254,19 +254,20 @@ s32 ixgbe_dcb_config_pfc_82598(struct ixgbe_hw *hw,
254 * for each traffic class. 254 * for each traffic class.
255 */ 255 */
256 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 256 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
257 int enabled = pfc_en & (1 << i);
257 rx_pba_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i)); 258 rx_pba_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i));
258 rx_pba_size >>= IXGBE_RXPBSIZE_SHIFT; 259 rx_pba_size >>= IXGBE_RXPBSIZE_SHIFT;
259 reg = (rx_pba_size - hw->fc.low_water) << 10; 260 reg = (rx_pba_size - hw->fc.low_water) << 10;
260 261
261 if (dcb_config->tc_config[i].dcb_pfc == pfc_enabled_tx || 262 if (enabled == pfc_enabled_tx ||
262 dcb_config->tc_config[i].dcb_pfc == pfc_enabled_full) 263 enabled == pfc_enabled_full)
263 reg |= IXGBE_FCRTL_XONE; 264 reg |= IXGBE_FCRTL_XONE;
264 265
265 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), reg); 266 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), reg);
266 267
267 reg = (rx_pba_size - hw->fc.high_water) << 10; 268 reg = (rx_pba_size - hw->fc.high_water) << 10;
268 if (dcb_config->tc_config[i].dcb_pfc == pfc_enabled_tx || 269 if (enabled == pfc_enabled_tx ||
269 dcb_config->tc_config[i].dcb_pfc == pfc_enabled_full) 270 enabled == pfc_enabled_full)
270 reg |= IXGBE_FCRTH_FCEN; 271 reg |= IXGBE_FCRTH_FCEN;
271 272
272 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), reg); 273 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), reg);
@@ -323,13 +324,16 @@ static s32 ixgbe_dcb_config_tc_stats_82598(struct ixgbe_hw *hw)
323 * Configure dcb settings and enable dcb mode. 324 * Configure dcb settings and enable dcb mode.
324 */ 325 */
325s32 ixgbe_dcb_hw_config_82598(struct ixgbe_hw *hw, 326s32 ixgbe_dcb_hw_config_82598(struct ixgbe_hw *hw,
326 struct ixgbe_dcb_config *dcb_config) 327 u8 rx_pba, u8 pfc_en, u16 *refill,
328 u16 *max, u8 *bwg_id, u8 *prio_type)
327{ 329{
328 ixgbe_dcb_config_packet_buffers_82598(hw, dcb_config); 330 ixgbe_dcb_config_packet_buffers_82598(hw, rx_pba);
329 ixgbe_dcb_config_rx_arbiter_82598(hw, dcb_config); 331 ixgbe_dcb_config_rx_arbiter_82598(hw, refill, max, prio_type);
330 ixgbe_dcb_config_tx_desc_arbiter_82598(hw, dcb_config); 332 ixgbe_dcb_config_tx_desc_arbiter_82598(hw, refill, max,
331 ixgbe_dcb_config_tx_data_arbiter_82598(hw, dcb_config); 333 bwg_id, prio_type);
332 ixgbe_dcb_config_pfc_82598(hw, dcb_config); 334 ixgbe_dcb_config_tx_data_arbiter_82598(hw, refill, max,
335 bwg_id, prio_type);
336 ixgbe_dcb_config_pfc_82598(hw, pfc_en);
333 ixgbe_dcb_config_tc_stats_82598(hw); 337 ixgbe_dcb_config_tc_stats_82598(hw);
334 338
335 return 0; 339 return 0;
diff --git a/drivers/net/ixgbe/ixgbe_dcb_82598.h b/drivers/net/ixgbe/ixgbe_dcb_82598.h
index abc03ccfa088..0d2a758effce 100644
--- a/drivers/net/ixgbe/ixgbe_dcb_82598.h
+++ b/drivers/net/ixgbe/ixgbe_dcb_82598.h
@@ -71,9 +71,28 @@
71/* DCB hardware-specific driver APIs */ 71/* DCB hardware-specific driver APIs */
72 72
73/* DCB PFC functions */ 73/* DCB PFC functions */
74s32 ixgbe_dcb_config_pfc_82598(struct ixgbe_hw *, struct ixgbe_dcb_config *); 74s32 ixgbe_dcb_config_pfc_82598(struct ixgbe_hw *, u8 pfc_en);
75 75
76/* DCB hw initialization */ 76/* DCB hw initialization */
77s32 ixgbe_dcb_hw_config_82598(struct ixgbe_hw *, struct ixgbe_dcb_config *); 77s32 ixgbe_dcb_config_rx_arbiter_82598(struct ixgbe_hw *hw,
78 u16 *refill,
79 u16 *max,
80 u8 *prio_type);
81
82s32 ixgbe_dcb_config_tx_desc_arbiter_82598(struct ixgbe_hw *hw,
83 u16 *refill,
84 u16 *max,
85 u8 *bwg_id,
86 u8 *prio_type);
87
88s32 ixgbe_dcb_config_tx_data_arbiter_82598(struct ixgbe_hw *hw,
89 u16 *refill,
90 u16 *max,
91 u8 *bwg_id,
92 u8 *prio_type);
93
94s32 ixgbe_dcb_hw_config_82598(struct ixgbe_hw *hw,
95 u8 rx_pba, u8 pfc_en, u16 *refill,
96 u16 *max, u8 *bwg_id, u8 *prio_type);
78 97
79#endif /* _DCB_82598_CONFIG_H */ 98#endif /* _DCB_82598_CONFIG_H */
diff --git a/drivers/net/ixgbe/ixgbe_dcb_82599.c b/drivers/net/ixgbe/ixgbe_dcb_82599.c
index 374e1f74d0f5..b0d97a98c84d 100644
--- a/drivers/net/ixgbe/ixgbe_dcb_82599.c
+++ b/drivers/net/ixgbe/ixgbe_dcb_82599.c
@@ -33,19 +33,18 @@
33/** 33/**
34 * ixgbe_dcb_config_packet_buffers_82599 - Configure DCB packet buffers 34 * ixgbe_dcb_config_packet_buffers_82599 - Configure DCB packet buffers
35 * @hw: pointer to hardware structure 35 * @hw: pointer to hardware structure
36 * @dcb_config: pointer to ixgbe_dcb_config structure 36 * @rx_pba: method to distribute packet buffer
37 * 37 *
38 * Configure packet buffers for DCB mode. 38 * Configure packet buffers for DCB mode.
39 */ 39 */
40static s32 ixgbe_dcb_config_packet_buffers_82599(struct ixgbe_hw *hw, 40static s32 ixgbe_dcb_config_packet_buffers_82599(struct ixgbe_hw *hw, u8 rx_pba)
41 struct ixgbe_dcb_config *dcb_config)
42{ 41{
43 s32 ret_val = 0; 42 s32 ret_val = 0;
44 u32 value = IXGBE_RXPBSIZE_64KB; 43 u32 value = IXGBE_RXPBSIZE_64KB;
45 u8 i = 0; 44 u8 i = 0;
46 45
47 /* Setup Rx packet buffer sizes */ 46 /* Setup Rx packet buffer sizes */
48 switch (dcb_config->rx_pba_cfg) { 47 switch (rx_pba) {
49 case pba_80_48: 48 case pba_80_48:
50 /* Setup the first four at 80KB */ 49 /* Setup the first four at 80KB */
51 value = IXGBE_RXPBSIZE_80KB; 50 value = IXGBE_RXPBSIZE_80KB;
@@ -75,14 +74,19 @@ static s32 ixgbe_dcb_config_packet_buffers_82599(struct ixgbe_hw *hw,
75/** 74/**
76 * ixgbe_dcb_config_rx_arbiter_82599 - Config Rx Data arbiter 75 * ixgbe_dcb_config_rx_arbiter_82599 - Config Rx Data arbiter
77 * @hw: pointer to hardware structure 76 * @hw: pointer to hardware structure
78 * @dcb_config: pointer to ixgbe_dcb_config structure 77 * @refill: refill credits index by traffic class
78 * @max: max credits index by traffic class
79 * @bwg_id: bandwidth grouping indexed by traffic class
80 * @prio_type: priority type indexed by traffic class
79 * 81 *
80 * Configure Rx Packet Arbiter and credits for each traffic class. 82 * Configure Rx Packet Arbiter and credits for each traffic class.
81 */ 83 */
82static s32 ixgbe_dcb_config_rx_arbiter_82599(struct ixgbe_hw *hw, 84s32 ixgbe_dcb_config_rx_arbiter_82599(struct ixgbe_hw *hw,
83 struct ixgbe_dcb_config *dcb_config) 85 u16 *refill,
86 u16 *max,
87 u8 *bwg_id,
88 u8 *prio_type)
84{ 89{
85 struct tc_bw_alloc *p;
86 u32 reg = 0; 90 u32 reg = 0;
87 u32 credit_refill = 0; 91 u32 credit_refill = 0;
88 u32 credit_max = 0; 92 u32 credit_max = 0;
@@ -103,15 +107,13 @@ static s32 ixgbe_dcb_config_rx_arbiter_82599(struct ixgbe_hw *hw,
103 107
104 /* Configure traffic class credits and priority */ 108 /* Configure traffic class credits and priority */
105 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 109 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
106 p = &dcb_config->tc_config[i].path[DCB_RX_CONFIG]; 110 credit_refill = refill[i];
107 111 credit_max = max[i];
108 credit_refill = p->data_credits_refill;
109 credit_max = p->data_credits_max;
110 reg = credit_refill | (credit_max << IXGBE_RTRPT4C_MCL_SHIFT); 112 reg = credit_refill | (credit_max << IXGBE_RTRPT4C_MCL_SHIFT);
111 113
112 reg |= (u32)(p->bwg_id) << IXGBE_RTRPT4C_BWG_SHIFT; 114 reg |= (u32)(bwg_id[i]) << IXGBE_RTRPT4C_BWG_SHIFT;
113 115
114 if (p->prio_type == prio_link) 116 if (prio_type[i] == prio_link)
115 reg |= IXGBE_RTRPT4C_LSP; 117 reg |= IXGBE_RTRPT4C_LSP;
116 118
117 IXGBE_WRITE_REG(hw, IXGBE_RTRPT4C(i), reg); 119 IXGBE_WRITE_REG(hw, IXGBE_RTRPT4C(i), reg);
@@ -130,14 +132,19 @@ static s32 ixgbe_dcb_config_rx_arbiter_82599(struct ixgbe_hw *hw,
130/** 132/**
131 * ixgbe_dcb_config_tx_desc_arbiter_82599 - Config Tx Desc. arbiter 133 * ixgbe_dcb_config_tx_desc_arbiter_82599 - Config Tx Desc. arbiter
132 * @hw: pointer to hardware structure 134 * @hw: pointer to hardware structure
133 * @dcb_config: pointer to ixgbe_dcb_config structure 135 * @refill: refill credits index by traffic class
136 * @max: max credits index by traffic class
137 * @bwg_id: bandwidth grouping indexed by traffic class
138 * @prio_type: priority type indexed by traffic class
134 * 139 *
135 * Configure Tx Descriptor Arbiter and credits for each traffic class. 140 * Configure Tx Descriptor Arbiter and credits for each traffic class.
136 */ 141 */
137static s32 ixgbe_dcb_config_tx_desc_arbiter_82599(struct ixgbe_hw *hw, 142s32 ixgbe_dcb_config_tx_desc_arbiter_82599(struct ixgbe_hw *hw,
138 struct ixgbe_dcb_config *dcb_config) 143 u16 *refill,
144 u16 *max,
145 u8 *bwg_id,
146 u8 *prio_type)
139{ 147{
140 struct tc_bw_alloc *p;
141 u32 reg, max_credits; 148 u32 reg, max_credits;
142 u8 i; 149 u8 i;
143 150
@@ -149,16 +156,15 @@ static s32 ixgbe_dcb_config_tx_desc_arbiter_82599(struct ixgbe_hw *hw,
149 156
150 /* Configure traffic class credits and priority */ 157 /* Configure traffic class credits and priority */
151 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 158 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
152 p = &dcb_config->tc_config[i].path[DCB_TX_CONFIG]; 159 max_credits = max[i];
153 max_credits = dcb_config->tc_config[i].desc_credits_max;
154 reg = max_credits << IXGBE_RTTDT2C_MCL_SHIFT; 160 reg = max_credits << IXGBE_RTTDT2C_MCL_SHIFT;
155 reg |= p->data_credits_refill; 161 reg |= refill[i];
156 reg |= (u32)(p->bwg_id) << IXGBE_RTTDT2C_BWG_SHIFT; 162 reg |= (u32)(bwg_id[i]) << IXGBE_RTTDT2C_BWG_SHIFT;
157 163
158 if (p->prio_type == prio_group) 164 if (prio_type[i] == prio_group)
159 reg |= IXGBE_RTTDT2C_GSP; 165 reg |= IXGBE_RTTDT2C_GSP;
160 166
161 if (p->prio_type == prio_link) 167 if (prio_type[i] == prio_link)
162 reg |= IXGBE_RTTDT2C_LSP; 168 reg |= IXGBE_RTTDT2C_LSP;
163 169
164 IXGBE_WRITE_REG(hw, IXGBE_RTTDT2C(i), reg); 170 IXGBE_WRITE_REG(hw, IXGBE_RTTDT2C(i), reg);
@@ -177,14 +183,19 @@ static s32 ixgbe_dcb_config_tx_desc_arbiter_82599(struct ixgbe_hw *hw,
177/** 183/**
178 * ixgbe_dcb_config_tx_data_arbiter_82599 - Config Tx Data arbiter 184 * ixgbe_dcb_config_tx_data_arbiter_82599 - Config Tx Data arbiter
179 * @hw: pointer to hardware structure 185 * @hw: pointer to hardware structure
180 * @dcb_config: pointer to ixgbe_dcb_config structure 186 * @refill: refill credits index by traffic class
187 * @max: max credits index by traffic class
188 * @bwg_id: bandwidth grouping indexed by traffic class
189 * @prio_type: priority type indexed by traffic class
181 * 190 *
182 * Configure Tx Packet Arbiter and credits for each traffic class. 191 * Configure Tx Packet Arbiter and credits for each traffic class.
183 */ 192 */
184static s32 ixgbe_dcb_config_tx_data_arbiter_82599(struct ixgbe_hw *hw, 193s32 ixgbe_dcb_config_tx_data_arbiter_82599(struct ixgbe_hw *hw,
185 struct ixgbe_dcb_config *dcb_config) 194 u16 *refill,
195 u16 *max,
196 u8 *bwg_id,
197 u8 *prio_type)
186{ 198{
187 struct tc_bw_alloc *p;
188 u32 reg; 199 u32 reg;
189 u8 i; 200 u8 i;
190 201
@@ -205,15 +216,14 @@ static s32 ixgbe_dcb_config_tx_data_arbiter_82599(struct ixgbe_hw *hw,
205 216
206 /* Configure traffic class credits and priority */ 217 /* Configure traffic class credits and priority */
207 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 218 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
208 p = &dcb_config->tc_config[i].path[DCB_TX_CONFIG]; 219 reg = refill[i];
209 reg = p->data_credits_refill; 220 reg |= (u32)(max[i]) << IXGBE_RTTPT2C_MCL_SHIFT;
210 reg |= (u32)(p->data_credits_max) << IXGBE_RTTPT2C_MCL_SHIFT; 221 reg |= (u32)(bwg_id[i]) << IXGBE_RTTPT2C_BWG_SHIFT;
211 reg |= (u32)(p->bwg_id) << IXGBE_RTTPT2C_BWG_SHIFT;
212 222
213 if (p->prio_type == prio_group) 223 if (prio_type[i] == prio_group)
214 reg |= IXGBE_RTTPT2C_GSP; 224 reg |= IXGBE_RTTPT2C_GSP;
215 225
216 if (p->prio_type == prio_link) 226 if (prio_type[i] == prio_link)
217 reg |= IXGBE_RTTPT2C_LSP; 227 reg |= IXGBE_RTTPT2C_LSP;
218 228
219 IXGBE_WRITE_REG(hw, IXGBE_RTTPT2C(i), reg); 229 IXGBE_WRITE_REG(hw, IXGBE_RTTPT2C(i), reg);
@@ -233,17 +243,16 @@ static s32 ixgbe_dcb_config_tx_data_arbiter_82599(struct ixgbe_hw *hw,
233/** 243/**
234 * ixgbe_dcb_config_pfc_82599 - Configure priority flow control 244 * ixgbe_dcb_config_pfc_82599 - Configure priority flow control
235 * @hw: pointer to hardware structure 245 * @hw: pointer to hardware structure
236 * @dcb_config: pointer to ixgbe_dcb_config structure 246 * @pfc_en: enabled pfc bitmask
237 * 247 *
238 * Configure Priority Flow Control (PFC) for each traffic class. 248 * Configure Priority Flow Control (PFC) for each traffic class.
239 */ 249 */
240s32 ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw, 250s32 ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw, u8 pfc_en)
241 struct ixgbe_dcb_config *dcb_config)
242{ 251{
243 u32 i, reg, rx_pba_size; 252 u32 i, reg, rx_pba_size;
244 253
245 /* If PFC is disabled globally then fall back to LFC. */ 254 /* If PFC is disabled globally then fall back to LFC. */
246 if (!dcb_config->pfc_mode_enable) { 255 if (!pfc_en) {
247 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) 256 for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
248 hw->mac.ops.fc_enable(hw, i); 257 hw->mac.ops.fc_enable(hw, i);
249 goto out; 258 goto out;
@@ -251,19 +260,18 @@ s32 ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw,
251 260
252 /* Configure PFC Tx thresholds per TC */ 261 /* Configure PFC Tx thresholds per TC */
253 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 262 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
263 int enabled = pfc_en & (1 << i);
254 rx_pba_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i)); 264 rx_pba_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i));
255 rx_pba_size >>= IXGBE_RXPBSIZE_SHIFT; 265 rx_pba_size >>= IXGBE_RXPBSIZE_SHIFT;
256 266
257 reg = (rx_pba_size - hw->fc.low_water) << 10; 267 reg = (rx_pba_size - hw->fc.low_water) << 10;
258 268
259 if (dcb_config->tc_config[i].dcb_pfc == pfc_enabled_full || 269 if (enabled)
260 dcb_config->tc_config[i].dcb_pfc == pfc_enabled_tx)
261 reg |= IXGBE_FCRTL_XONE; 270 reg |= IXGBE_FCRTL_XONE;
262 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), reg); 271 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), reg);
263 272
264 reg = (rx_pba_size - hw->fc.high_water) << 10; 273 reg = (rx_pba_size - hw->fc.high_water) << 10;
265 if (dcb_config->tc_config[i].dcb_pfc == pfc_enabled_full || 274 if (enabled)
266 dcb_config->tc_config[i].dcb_pfc == pfc_enabled_tx)
267 reg |= IXGBE_FCRTH_FCEN; 275 reg |= IXGBE_FCRTH_FCEN;
268 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(i), reg); 276 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(i), reg);
269 } 277 }
@@ -349,7 +357,6 @@ static s32 ixgbe_dcb_config_tc_stats_82599(struct ixgbe_hw *hw)
349/** 357/**
350 * ixgbe_dcb_config_82599 - Configure general DCB parameters 358 * ixgbe_dcb_config_82599 - Configure general DCB parameters
351 * @hw: pointer to hardware structure 359 * @hw: pointer to hardware structure
352 * @dcb_config: pointer to ixgbe_dcb_config structure
353 * 360 *
354 * Configure general DCB parameters. 361 * Configure general DCB parameters.
355 */ 362 */
@@ -406,19 +413,27 @@ static s32 ixgbe_dcb_config_82599(struct ixgbe_hw *hw)
406/** 413/**
407 * ixgbe_dcb_hw_config_82599 - Configure and enable DCB 414 * ixgbe_dcb_hw_config_82599 - Configure and enable DCB
408 * @hw: pointer to hardware structure 415 * @hw: pointer to hardware structure
409 * @dcb_config: pointer to ixgbe_dcb_config structure 416 * @rx_pba: method to distribute packet buffer
417 * @refill: refill credits index by traffic class
418 * @max: max credits index by traffic class
419 * @bwg_id: bandwidth grouping indexed by traffic class
420 * @prio_type: priority type indexed by traffic class
421 * @pfc_en: enabled pfc bitmask
410 * 422 *
411 * Configure dcb settings and enable dcb mode. 423 * Configure dcb settings and enable dcb mode.
412 */ 424 */
413s32 ixgbe_dcb_hw_config_82599(struct ixgbe_hw *hw, 425s32 ixgbe_dcb_hw_config_82599(struct ixgbe_hw *hw,
414 struct ixgbe_dcb_config *dcb_config) 426 u8 rx_pba, u8 pfc_en, u16 *refill,
427 u16 *max, u8 *bwg_id, u8 *prio_type)
415{ 428{
416 ixgbe_dcb_config_packet_buffers_82599(hw, dcb_config); 429 ixgbe_dcb_config_packet_buffers_82599(hw, rx_pba);
417 ixgbe_dcb_config_82599(hw); 430 ixgbe_dcb_config_82599(hw);
418 ixgbe_dcb_config_rx_arbiter_82599(hw, dcb_config); 431 ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, bwg_id, prio_type);
419 ixgbe_dcb_config_tx_desc_arbiter_82599(hw, dcb_config); 432 ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max,
420 ixgbe_dcb_config_tx_data_arbiter_82599(hw, dcb_config); 433 bwg_id, prio_type);
421 ixgbe_dcb_config_pfc_82599(hw, dcb_config); 434 ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max,
435 bwg_id, prio_type);
436 ixgbe_dcb_config_pfc_82599(hw, pfc_en);
422 ixgbe_dcb_config_tc_stats_82599(hw); 437 ixgbe_dcb_config_tc_stats_82599(hw);
423 438
424 return 0; 439 return 0;
diff --git a/drivers/net/ixgbe/ixgbe_dcb_82599.h b/drivers/net/ixgbe/ixgbe_dcb_82599.h
index 3841649fb954..5b0ca85614d1 100644
--- a/drivers/net/ixgbe/ixgbe_dcb_82599.h
+++ b/drivers/net/ixgbe/ixgbe_dcb_82599.h
@@ -102,11 +102,29 @@
102/* DCB hardware-specific driver APIs */ 102/* DCB hardware-specific driver APIs */
103 103
104/* DCB PFC functions */ 104/* DCB PFC functions */
105s32 ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw, 105s32 ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw, u8 pfc_en);
106 struct ixgbe_dcb_config *dcb_config);
107 106
108/* DCB hw initialization */ 107/* DCB hw initialization */
108s32 ixgbe_dcb_config_rx_arbiter_82599(struct ixgbe_hw *hw,
109 u16 *refill,
110 u16 *max,
111 u8 *bwg_id,
112 u8 *prio_type);
113
114s32 ixgbe_dcb_config_tx_desc_arbiter_82599(struct ixgbe_hw *hw,
115 u16 *refill,
116 u16 *max,
117 u8 *bwg_id,
118 u8 *prio_type);
119
120s32 ixgbe_dcb_config_tx_data_arbiter_82599(struct ixgbe_hw *hw,
121 u16 *refill,
122 u16 *max,
123 u8 *bwg_id,
124 u8 *prio_type);
125
109s32 ixgbe_dcb_hw_config_82599(struct ixgbe_hw *hw, 126s32 ixgbe_dcb_hw_config_82599(struct ixgbe_hw *hw,
110 struct ixgbe_dcb_config *config); 127 u8 rx_pba, u8 pfc_en, u16 *refill,
128 u16 *max, u8 *bwg_id, u8 *prio_type);
111 129
112#endif /* _DCB_82599_CONFIG_H */ 130#endif /* _DCB_82599_CONFIG_H */
diff --git a/drivers/net/ixgbe/ixgbe_dcb_nl.c b/drivers/net/ixgbe/ixgbe_dcb_nl.c
index 48058359ba69..6ab1f1abaa01 100644
--- a/drivers/net/ixgbe/ixgbe_dcb_nl.c
+++ b/drivers/net/ixgbe/ixgbe_dcb_nl.c
@@ -422,12 +422,13 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
422 } 422 }
423 ret = DCB_HW_CHG_RST; 423 ret = DCB_HW_CHG_RST;
424 } else if (adapter->dcb_set_bitmap & BIT_PFC) { 424 } else if (adapter->dcb_set_bitmap & BIT_PFC) {
425 u8 pfc_en;
426 ixgbe_dcb_unpack_pfc(&adapter->dcb_cfg, &pfc_en);
427
425 if (adapter->hw.mac.type == ixgbe_mac_82598EB) 428 if (adapter->hw.mac.type == ixgbe_mac_82598EB)
426 ixgbe_dcb_config_pfc_82598(&adapter->hw, 429 ixgbe_dcb_config_pfc_82598(&adapter->hw, pfc_en);
427 &adapter->dcb_cfg);
428 else if (adapter->hw.mac.type == ixgbe_mac_82599EB) 430 else if (adapter->hw.mac.type == ixgbe_mac_82599EB)
429 ixgbe_dcb_config_pfc_82599(&adapter->hw, 431 ixgbe_dcb_config_pfc_82599(&adapter->hw, pfc_en);
430 &adapter->dcb_cfg);
431 ret = DCB_HW_CHG; 432 ret = DCB_HW_CHG;
432 } 433 }
433 if (adapter->dcb_cfg.pfc_mode_enable) 434 if (adapter->dcb_cfg.pfc_mode_enable)