Imported Upstream version 16.04
[deb_dpdk.git] / drivers / net / ixgbe / base / ixgbe_dcb_82599.c
1 /*******************************************************************************
2
3 Copyright (c) 2001-2015, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8
9  1. Redistributions of source code must retain the above copyright notice,
10     this list of conditions and the following disclaimer.
11
12  2. Redistributions in binary form must reproduce the above copyright
13     notice, this list of conditions and the following disclaimer in the
14     documentation and/or other materials provided with the distribution.
15
16  3. Neither the name of the Intel Corporation nor the names of its
17     contributors may be used to endorse or promote products derived from
18     this software without specific prior written permission.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32 ***************************************************************************/
33
34
35 #include "ixgbe_type.h"
36 #include "ixgbe_dcb.h"
37 #include "ixgbe_dcb_82599.h"
38
39 /**
40  * ixgbe_dcb_get_tc_stats_82599 - Returns status for each traffic class
41  * @hw: pointer to hardware structure
42  * @stats: pointer to statistics structure
43  * @tc_count:  Number of elements in bwg_array.
44  *
45  * This function returns the status data for each of the Traffic Classes in use.
46  */
47 s32 ixgbe_dcb_get_tc_stats_82599(struct ixgbe_hw *hw,
48                                  struct ixgbe_hw_stats *stats,
49                                  u8 tc_count)
50 {
51         int tc;
52
53         DEBUGFUNC("dcb_get_tc_stats");
54
55         if (tc_count > IXGBE_DCB_MAX_TRAFFIC_CLASS)
56                 return IXGBE_ERR_PARAM;
57
58         /* Statistics pertaining to each traffic class */
59         for (tc = 0; tc < tc_count; tc++) {
60                 /* Transmitted Packets */
61                 stats->qptc[tc] += IXGBE_READ_REG(hw, IXGBE_QPTC(tc));
62                 /* Transmitted Bytes (read low first to prevent missed carry) */
63                 stats->qbtc[tc] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(tc));
64                 stats->qbtc[tc] +=
65                         (((u64)(IXGBE_READ_REG(hw, IXGBE_QBTC_H(tc)))) << 32);
66                 /* Received Packets */
67                 stats->qprc[tc] += IXGBE_READ_REG(hw, IXGBE_QPRC(tc));
68                 /* Received Bytes (read low first to prevent missed carry) */
69                 stats->qbrc[tc] += IXGBE_READ_REG(hw, IXGBE_QBRC_L(tc));
70                 stats->qbrc[tc] +=
71                         (((u64)(IXGBE_READ_REG(hw, IXGBE_QBRC_H(tc)))) << 32);
72
73                 /* Received Dropped Packet */
74                 stats->qprdc[tc] += IXGBE_READ_REG(hw, IXGBE_QPRDC(tc));
75         }
76
77         return IXGBE_SUCCESS;
78 }
79
80 /**
81  * ixgbe_dcb_get_pfc_stats_82599 - Return CBFC status data
82  * @hw: pointer to hardware structure
83  * @stats: pointer to statistics structure
84  * @tc_count:  Number of elements in bwg_array.
85  *
86  * This function returns the CBFC status data for each of the Traffic Classes.
87  */
88 s32 ixgbe_dcb_get_pfc_stats_82599(struct ixgbe_hw *hw,
89                                   struct ixgbe_hw_stats *stats,
90                                   u8 tc_count)
91 {
92         int tc;
93
94         DEBUGFUNC("dcb_get_pfc_stats");
95
96         if (tc_count > IXGBE_DCB_MAX_TRAFFIC_CLASS)
97                 return IXGBE_ERR_PARAM;
98
99         for (tc = 0; tc < tc_count; tc++) {
100                 /* Priority XOFF Transmitted */
101                 stats->pxofftxc[tc] += IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(tc));
102                 /* Priority XOFF Received */
103                 stats->pxoffrxc[tc] += IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(tc));
104         }
105
106         return IXGBE_SUCCESS;
107 }
108
109 /**
110  * ixgbe_dcb_config_rx_arbiter_82599 - Config Rx Data arbiter
111  * @hw: pointer to hardware structure
112  * @dcb_config: pointer to ixgbe_dcb_config structure
113  *
114  * Configure Rx Packet Arbiter and credits for each traffic class.
115  */
116 s32 ixgbe_dcb_config_rx_arbiter_82599(struct ixgbe_hw *hw, u16 *refill,
117                                       u16 *max, u8 *bwg_id, u8 *tsa,
118                                       u8 *map)
119 {
120         u32 reg = 0;
121         u32 credit_refill = 0;
122         u32 credit_max = 0;
123         u8  i = 0;
124
125         /*
126          * Disable the arbiter before changing parameters
127          * (always enable recycle mode; WSP)
128          */
129         reg = IXGBE_RTRPCS_RRM | IXGBE_RTRPCS_RAC | IXGBE_RTRPCS_ARBDIS;
130         IXGBE_WRITE_REG(hw, IXGBE_RTRPCS, reg);
131
132         /*
133          * map all UPs to TCs. up_to_tc_bitmap for each TC has corresponding
134          * bits sets for the UPs that needs to be mappped to that TC.
135          * e.g if priorities 6 and 7 are to be mapped to a TC then the
136          * up_to_tc_bitmap value for that TC will be 11000000 in binary.
137          */
138         reg = 0;
139         for (i = 0; i < IXGBE_DCB_MAX_USER_PRIORITY; i++)
140                 reg |= (map[i] << (i * IXGBE_RTRUP2TC_UP_SHIFT));
141
142         IXGBE_WRITE_REG(hw, IXGBE_RTRUP2TC, reg);
143
144         /* Configure traffic class credits and priority */
145         for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
146                 credit_refill = refill[i];
147                 credit_max = max[i];
148                 reg = credit_refill | (credit_max << IXGBE_RTRPT4C_MCL_SHIFT);
149
150                 reg |= (u32)(bwg_id[i]) << IXGBE_RTRPT4C_BWG_SHIFT;
151
152                 if (tsa[i] == ixgbe_dcb_tsa_strict)
153                         reg |= IXGBE_RTRPT4C_LSP;
154
155                 IXGBE_WRITE_REG(hw, IXGBE_RTRPT4C(i), reg);
156         }
157
158         /*
159          * Configure Rx packet plane (recycle mode; WSP) and
160          * enable arbiter
161          */
162         reg = IXGBE_RTRPCS_RRM | IXGBE_RTRPCS_RAC;
163         IXGBE_WRITE_REG(hw, IXGBE_RTRPCS, reg);
164
165         return IXGBE_SUCCESS;
166 }
167
168 /**
169  * ixgbe_dcb_config_tx_desc_arbiter_82599 - Config Tx Desc. arbiter
170  * @hw: pointer to hardware structure
171  * @dcb_config: pointer to ixgbe_dcb_config structure
172  *
173  * Configure Tx Descriptor Arbiter and credits for each traffic class.
174  */
175 s32 ixgbe_dcb_config_tx_desc_arbiter_82599(struct ixgbe_hw *hw, u16 *refill,
176                                            u16 *max, u8 *bwg_id, u8 *tsa)
177 {
178         u32 reg, max_credits;
179         u8  i;
180
181         /* Clear the per-Tx queue credits; we use per-TC instead */
182         for (i = 0; i < 128; i++) {
183                 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, i);
184                 IXGBE_WRITE_REG(hw, IXGBE_RTTDT1C, 0);
185         }
186
187         /* Configure traffic class credits and priority */
188         for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
189                 max_credits = max[i];
190                 reg = max_credits << IXGBE_RTTDT2C_MCL_SHIFT;
191                 reg |= refill[i];
192                 reg |= (u32)(bwg_id[i]) << IXGBE_RTTDT2C_BWG_SHIFT;
193
194                 if (tsa[i] == ixgbe_dcb_tsa_group_strict_cee)
195                         reg |= IXGBE_RTTDT2C_GSP;
196
197                 if (tsa[i] == ixgbe_dcb_tsa_strict)
198                         reg |= IXGBE_RTTDT2C_LSP;
199
200                 IXGBE_WRITE_REG(hw, IXGBE_RTTDT2C(i), reg);
201         }
202
203         /*
204          * Configure Tx descriptor plane (recycle mode; WSP) and
205          * enable arbiter
206          */
207         reg = IXGBE_RTTDCS_TDPAC | IXGBE_RTTDCS_TDRM;
208         IXGBE_WRITE_REG(hw, IXGBE_RTTDCS, reg);
209
210         return IXGBE_SUCCESS;
211 }
212
213 /**
214  * ixgbe_dcb_config_tx_data_arbiter_82599 - Config Tx Data arbiter
215  * @hw: pointer to hardware structure
216  * @dcb_config: pointer to ixgbe_dcb_config structure
217  *
218  * Configure Tx Packet Arbiter and credits for each traffic class.
219  */
220 s32 ixgbe_dcb_config_tx_data_arbiter_82599(struct ixgbe_hw *hw, u16 *refill,
221                                            u16 *max, u8 *bwg_id, u8 *tsa,
222                                            u8 *map)
223 {
224         u32 reg;
225         u8 i;
226
227         /*
228          * Disable the arbiter before changing parameters
229          * (always enable recycle mode; SP; arb delay)
230          */
231         reg = IXGBE_RTTPCS_TPPAC | IXGBE_RTTPCS_TPRM |
232               (IXGBE_RTTPCS_ARBD_DCB << IXGBE_RTTPCS_ARBD_SHIFT) |
233               IXGBE_RTTPCS_ARBDIS;
234         IXGBE_WRITE_REG(hw, IXGBE_RTTPCS, reg);
235
236         /*
237          * map all UPs to TCs. up_to_tc_bitmap for each TC has corresponding
238          * bits sets for the UPs that needs to be mappped to that TC.
239          * e.g if priorities 6 and 7 are to be mapped to a TC then the
240          * up_to_tc_bitmap value for that TC will be 11000000 in binary.
241          */
242         reg = 0;
243         for (i = 0; i < IXGBE_DCB_MAX_USER_PRIORITY; i++)
244                 reg |= (map[i] << (i * IXGBE_RTTUP2TC_UP_SHIFT));
245
246         IXGBE_WRITE_REG(hw, IXGBE_RTTUP2TC, reg);
247
248         /* Configure traffic class credits and priority */
249         for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
250                 reg = refill[i];
251                 reg |= (u32)(max[i]) << IXGBE_RTTPT2C_MCL_SHIFT;
252                 reg |= (u32)(bwg_id[i]) << IXGBE_RTTPT2C_BWG_SHIFT;
253
254                 if (tsa[i] == ixgbe_dcb_tsa_group_strict_cee)
255                         reg |= IXGBE_RTTPT2C_GSP;
256
257                 if (tsa[i] == ixgbe_dcb_tsa_strict)
258                         reg |= IXGBE_RTTPT2C_LSP;
259
260                 IXGBE_WRITE_REG(hw, IXGBE_RTTPT2C(i), reg);
261         }
262
263         /*
264          * Configure Tx packet plane (recycle mode; SP; arb delay) and
265          * enable arbiter
266          */
267         reg = IXGBE_RTTPCS_TPPAC | IXGBE_RTTPCS_TPRM |
268               (IXGBE_RTTPCS_ARBD_DCB << IXGBE_RTTPCS_ARBD_SHIFT);
269         IXGBE_WRITE_REG(hw, IXGBE_RTTPCS, reg);
270
271         return IXGBE_SUCCESS;
272 }
273
274 /**
275  * ixgbe_dcb_config_pfc_82599 - Configure priority flow control
276  * @hw: pointer to hardware structure
277  * @pfc_en: enabled pfc bitmask
278  * @map: priority to tc assignments indexed by priority
279  *
280  * Configure Priority Flow Control (PFC) for each traffic class.
281  */
282 s32 ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw, u8 pfc_en, u8 *map)
283 {
284         u32 i, j, fcrtl, reg;
285         u8 max_tc = 0;
286
287         /* Enable Transmit Priority Flow Control */
288         IXGBE_WRITE_REG(hw, IXGBE_FCCFG, IXGBE_FCCFG_TFCE_PRIORITY);
289
290         /* Enable Receive Priority Flow Control */
291         reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
292         reg |= IXGBE_MFLCN_DPF;
293
294         /*
295          * X540 supports per TC Rx priority flow control.  So
296          * clear all TCs and only enable those that should be
297          * enabled.
298          */
299         reg &= ~(IXGBE_MFLCN_RPFCE_MASK | IXGBE_MFLCN_RFCE);
300
301         if (hw->mac.type >= ixgbe_mac_X540)
302                 reg |= pfc_en << IXGBE_MFLCN_RPFCE_SHIFT;
303
304         if (pfc_en)
305                 reg |= IXGBE_MFLCN_RPFCE;
306
307         IXGBE_WRITE_REG(hw, IXGBE_MFLCN, reg);
308
309         for (i = 0; i < IXGBE_DCB_MAX_USER_PRIORITY; i++) {
310                 if (map[i] > max_tc)
311                         max_tc = map[i];
312         }
313
314
315         /* Configure PFC Tx thresholds per TC */
316         for (i = 0; i <= max_tc; i++) {
317                 int enabled = 0;
318
319                 for (j = 0; j < IXGBE_DCB_MAX_USER_PRIORITY; j++) {
320                         if ((map[j] == i) && (pfc_en & (1 << j))) {
321                                 enabled = 1;
322                                 break;
323                         }
324                 }
325
326                 if (enabled) {
327                         reg = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN;
328                         fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE;
329                         IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), fcrtl);
330                 } else {
331                         /*
332                          * In order to prevent Tx hangs when the internal Tx
333                          * switch is enabled we must set the high water mark
334                          * to the Rx packet buffer size - 24KB.  This allows
335                          * the Tx switch to function even under heavy Rx
336                          * workloads.
337                          */
338                         reg = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i)) - 24576;
339                         IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), 0);
340                 }
341
342                 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(i), reg);
343         }
344
345         for (; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
346                 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), 0);
347                 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(i), 0);
348         }
349
350         /* Configure pause time (2 TCs per register) */
351         reg = hw->fc.pause_time | (hw->fc.pause_time << 16);
352         for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
353                 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
354
355         /* Configure flow control refresh threshold value */
356         IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
357
358         return IXGBE_SUCCESS;
359 }
360
361 /**
362  * ixgbe_dcb_config_tc_stats_82599 - Config traffic class statistics
363  * @hw: pointer to hardware structure
364  *
365  * Configure queue statistics registers, all queues belonging to same traffic
366  * class uses a single set of queue statistics counters.
367  */
368 s32 ixgbe_dcb_config_tc_stats_82599(struct ixgbe_hw *hw,
369                                     struct ixgbe_dcb_config *dcb_config)
370 {
371         u32 reg = 0;
372         u8  i   = 0;
373         u8 tc_count = 8;
374         bool vt_mode = false;
375
376         if (dcb_config != NULL) {
377                 tc_count = dcb_config->num_tcs.pg_tcs;
378                 vt_mode = dcb_config->vt_mode;
379         }
380
381         if (!((tc_count == 8 && vt_mode == false) || tc_count == 4))
382                 return IXGBE_ERR_PARAM;
383
384         if (tc_count == 8 && vt_mode == false) {
385                 /*
386                  * Receive Queues stats setting
387                  * 32 RQSMR registers, each configuring 4 queues.
388                  *
389                  * Set all 16 queues of each TC to the same stat
390                  * with TC 'n' going to stat 'n'.
391                  */
392                 for (i = 0; i < 32; i++) {
393                         reg = 0x01010101 * (i / 4);
394                         IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), reg);
395                 }
396                 /*
397                  * Transmit Queues stats setting
398                  * 32 TQSM registers, each controlling 4 queues.
399                  *
400                  * Set all queues of each TC to the same stat
401                  * with TC 'n' going to stat 'n'.
402                  * Tx queues are allocated non-uniformly to TCs:
403                  * 32, 32, 16, 16, 8, 8, 8, 8.
404                  */
405                 for (i = 0; i < 32; i++) {
406                         if (i < 8)
407                                 reg = 0x00000000;
408                         else if (i < 16)
409                                 reg = 0x01010101;
410                         else if (i < 20)
411                                 reg = 0x02020202;
412                         else if (i < 24)
413                                 reg = 0x03030303;
414                         else if (i < 26)
415                                 reg = 0x04040404;
416                         else if (i < 28)
417                                 reg = 0x05050505;
418                         else if (i < 30)
419                                 reg = 0x06060606;
420                         else
421                                 reg = 0x07070707;
422                         IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), reg);
423                 }
424         } else if (tc_count == 4 && vt_mode == false) {
425                 /*
426                  * Receive Queues stats setting
427                  * 32 RQSMR registers, each configuring 4 queues.
428                  *
429                  * Set all 16 queues of each TC to the same stat
430                  * with TC 'n' going to stat 'n'.
431                  */
432                 for (i = 0; i < 32; i++) {
433                         if (i % 8 > 3)
434                                 /* In 4 TC mode, odd 16-queue ranges are
435                                  *  not used.
436                                 */
437                                 continue;
438                         reg = 0x01010101 * (i / 8);
439                         IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), reg);
440                 }
441                 /*
442                  * Transmit Queues stats setting
443                  * 32 TQSM registers, each controlling 4 queues.
444                  *
445                  * Set all queues of each TC to the same stat
446                  * with TC 'n' going to stat 'n'.
447                  * Tx queues are allocated non-uniformly to TCs:
448                  * 64, 32, 16, 16.
449                  */
450                 for (i = 0; i < 32; i++) {
451                         if (i < 16)
452                                 reg = 0x00000000;
453                         else if (i < 24)
454                                 reg = 0x01010101;
455                         else if (i < 28)
456                                 reg = 0x02020202;
457                         else
458                                 reg = 0x03030303;
459                         IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), reg);
460                 }
461         } else if (tc_count == 4 && vt_mode == true) {
462                 /*
463                  * Receive Queues stats setting
464                  * 32 RQSMR registers, each configuring 4 queues.
465                  *
466                  * Queue Indexing in 32 VF with DCB mode maps 4 TC's to each
467                  * pool. Set all 32 queues of each TC across pools to the same
468                  * stat with TC 'n' going to stat 'n'.
469                  */
470                 for (i = 0; i < 32; i++)
471                         IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), 0x03020100);
472                 /*
473                  * Transmit Queues stats setting
474                  * 32 TQSM registers, each controlling 4 queues.
475                  *
476                  * Queue Indexing in 32 VF with DCB mode maps 4 TC's to each
477                  * pool. Set all 32 queues of each TC across pools to the same
478                  * stat with TC 'n' going to stat 'n'.
479                  */
480                 for (i = 0; i < 32; i++)
481                         IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), 0x03020100);
482         }
483
484         return IXGBE_SUCCESS;
485 }
486
487 /**
488  * ixgbe_dcb_config_82599 - Configure general DCB parameters
489  * @hw: pointer to hardware structure
490  * @dcb_config: pointer to ixgbe_dcb_config structure
491  *
492  * Configure general DCB parameters.
493  */
494 s32 ixgbe_dcb_config_82599(struct ixgbe_hw *hw,
495                            struct ixgbe_dcb_config *dcb_config)
496 {
497         u32 reg;
498         u32 q;
499
500         /* Disable the Tx desc arbiter so that MTQC can be changed */
501         reg = IXGBE_READ_REG(hw, IXGBE_RTTDCS);
502         reg |= IXGBE_RTTDCS_ARBDIS;
503         IXGBE_WRITE_REG(hw, IXGBE_RTTDCS, reg);
504
505         reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
506         if (dcb_config->num_tcs.pg_tcs == 8) {
507                 /* Enable DCB for Rx with 8 TCs */
508                 switch (reg & IXGBE_MRQC_MRQE_MASK) {
509                 case 0:
510                 case IXGBE_MRQC_RT4TCEN:
511                         /* RSS disabled cases */
512                         reg = (reg & ~IXGBE_MRQC_MRQE_MASK) |
513                               IXGBE_MRQC_RT8TCEN;
514                         break;
515                 case IXGBE_MRQC_RSSEN:
516                 case IXGBE_MRQC_RTRSS4TCEN:
517                         /* RSS enabled cases */
518                         reg = (reg & ~IXGBE_MRQC_MRQE_MASK) |
519                               IXGBE_MRQC_RTRSS8TCEN;
520                         break;
521                 default:
522                         /*
523                          * Unsupported value, assume stale data,
524                          * overwrite no RSS
525                          */
526                         ASSERT(0);
527                         reg = (reg & ~IXGBE_MRQC_MRQE_MASK) |
528                               IXGBE_MRQC_RT8TCEN;
529                 }
530         }
531         if (dcb_config->num_tcs.pg_tcs == 4) {
532                 /* We support both VT-on and VT-off with 4 TCs. */
533                 if (dcb_config->vt_mode)
534                         reg = (reg & ~IXGBE_MRQC_MRQE_MASK) |
535                               IXGBE_MRQC_VMDQRT4TCEN;
536                 else
537                         reg = (reg & ~IXGBE_MRQC_MRQE_MASK) |
538                               IXGBE_MRQC_RTRSS4TCEN;
539         }
540         IXGBE_WRITE_REG(hw, IXGBE_MRQC, reg);
541
542         /* Enable DCB for Tx with 8 TCs */
543         if (dcb_config->num_tcs.pg_tcs == 8)
544                 reg = IXGBE_MTQC_RT_ENA | IXGBE_MTQC_8TC_8TQ;
545         else {
546                 /* We support both VT-on and VT-off with 4 TCs. */
547                 reg = IXGBE_MTQC_RT_ENA | IXGBE_MTQC_4TC_4TQ;
548                 if (dcb_config->vt_mode)
549                         reg |= IXGBE_MTQC_VT_ENA;
550         }
551         IXGBE_WRITE_REG(hw, IXGBE_MTQC, reg);
552
553         /* Disable drop for all queues */
554         for (q = 0; q < 128; q++)
555                 IXGBE_WRITE_REG(hw, IXGBE_QDE,
556                                 (IXGBE_QDE_WRITE | (q << IXGBE_QDE_IDX_SHIFT)));
557
558         /* Enable the Tx desc arbiter */
559         reg = IXGBE_READ_REG(hw, IXGBE_RTTDCS);
560         reg &= ~IXGBE_RTTDCS_ARBDIS;
561         IXGBE_WRITE_REG(hw, IXGBE_RTTDCS, reg);
562
563         /* Enable Security TX Buffer IFG for DCB */
564         reg = IXGBE_READ_REG(hw, IXGBE_SECTXMINIFG);
565         reg |= IXGBE_SECTX_DCB;
566         IXGBE_WRITE_REG(hw, IXGBE_SECTXMINIFG, reg);
567
568         return IXGBE_SUCCESS;
569 }
570
571 /**
572  * ixgbe_dcb_hw_config_82599 - Configure and enable DCB
573  * @hw: pointer to hardware structure
574  * @dcb_config: pointer to ixgbe_dcb_config structure
575  *
576  * Configure dcb settings and enable dcb mode.
577  */
578 s32 ixgbe_dcb_hw_config_82599(struct ixgbe_hw *hw, int link_speed,
579                               u16 *refill, u16 *max, u8 *bwg_id, u8 *tsa,
580                               u8 *map)
581 {
582         UNREFERENCED_1PARAMETER(link_speed);
583
584         ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, bwg_id, tsa,
585                                           map);
586         ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max, bwg_id,
587                                                tsa);
588         ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max, bwg_id,
589                                                tsa, map);
590
591         return IXGBE_SUCCESS;
592 }
593