1 /*******************************************************************************
3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2011 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *******************************************************************************/
29 #include "ixgbe_type.h"
30 #include "ixgbe_dcb.h"
31 #include "ixgbe_dcb_82599.h"
34 * ixgbe_dcb_config_packet_buffers_82599 - Configure DCB packet buffers
35 * @hw: pointer to hardware structure
36 * @rx_pba: method to distribute packet buffer
38 * Configure packet buffers for DCB mode.
40 static s32
ixgbe_dcb_config_packet_buffers_82599(struct ixgbe_hw
*hw
, u8 rx_pba
)
43 u32 value
= IXGBE_RXPBSIZE_64KB
;
46 /* Setup Rx packet buffer sizes */
49 /* Setup the first four at 80KB */
50 value
= IXGBE_RXPBSIZE_80KB
;
52 IXGBE_WRITE_REG(hw
, IXGBE_RXPBSIZE(i
), value
);
53 /* Setup the last four at 48KB...don't re-init i */
54 value
= IXGBE_RXPBSIZE_48KB
;
58 for (; i
< IXGBE_MAX_PACKET_BUFFERS
; i
++)
59 IXGBE_WRITE_REG(hw
, IXGBE_RXPBSIZE(i
), value
);
61 /* Setup Tx packet buffer sizes */
62 for (i
= 0; i
< IXGBE_MAX_PACKET_BUFFERS
; i
++) {
63 IXGBE_WRITE_REG(hw
, IXGBE_TXPBSIZE(i
),
65 IXGBE_WRITE_REG(hw
, IXGBE_TXPBTHRESH(i
),
66 IXGBE_TXPBTHRESH_DCB
);
75 * ixgbe_dcb_config_rx_arbiter_82599 - Config Rx Data arbiter
76 * @hw: pointer to hardware 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
82 * Configure Rx Packet Arbiter and credits for each traffic class.
84 s32
ixgbe_dcb_config_rx_arbiter_82599(struct ixgbe_hw
*hw
,
92 u32 credit_refill
= 0;
97 * Disable the arbiter before changing parameters
98 * (always enable recycle mode; WSP)
100 reg
= IXGBE_RTRPCS_RRM
| IXGBE_RTRPCS_RAC
| IXGBE_RTRPCS_ARBDIS
;
101 IXGBE_WRITE_REG(hw
, IXGBE_RTRPCS
, reg
);
103 /* Map all traffic classes to their UP, 1 to 1 */
105 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++)
106 reg
|= (prio_tc
[i
] << (i
* IXGBE_RTRUP2TC_UP_SHIFT
));
107 IXGBE_WRITE_REG(hw
, IXGBE_RTRUP2TC
, reg
);
109 /* Configure traffic class credits and priority */
110 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++) {
111 credit_refill
= refill
[i
];
113 reg
= credit_refill
| (credit_max
<< IXGBE_RTRPT4C_MCL_SHIFT
);
115 reg
|= (u32
)(bwg_id
[i
]) << IXGBE_RTRPT4C_BWG_SHIFT
;
117 if (prio_type
[i
] == prio_link
)
118 reg
|= IXGBE_RTRPT4C_LSP
;
120 IXGBE_WRITE_REG(hw
, IXGBE_RTRPT4C(i
), reg
);
124 * Configure Rx packet plane (recycle mode; WSP) and
127 reg
= IXGBE_RTRPCS_RRM
| IXGBE_RTRPCS_RAC
;
128 IXGBE_WRITE_REG(hw
, IXGBE_RTRPCS
, reg
);
134 * ixgbe_dcb_config_tx_desc_arbiter_82599 - Config Tx Desc. arbiter
135 * @hw: pointer to hardware structure
136 * @refill: refill credits index by traffic class
137 * @max: max credits index by traffic class
138 * @bwg_id: bandwidth grouping indexed by traffic class
139 * @prio_type: priority type indexed by traffic class
141 * Configure Tx Descriptor Arbiter and credits for each traffic class.
143 s32
ixgbe_dcb_config_tx_desc_arbiter_82599(struct ixgbe_hw
*hw
,
149 u32 reg
, max_credits
;
152 /* Clear the per-Tx queue credits; we use per-TC instead */
153 for (i
= 0; i
< 128; i
++) {
154 IXGBE_WRITE_REG(hw
, IXGBE_RTTDQSEL
, i
);
155 IXGBE_WRITE_REG(hw
, IXGBE_RTTDT1C
, 0);
158 /* Configure traffic class credits and priority */
159 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++) {
160 max_credits
= max
[i
];
161 reg
= max_credits
<< IXGBE_RTTDT2C_MCL_SHIFT
;
163 reg
|= (u32
)(bwg_id
[i
]) << IXGBE_RTTDT2C_BWG_SHIFT
;
165 if (prio_type
[i
] == prio_group
)
166 reg
|= IXGBE_RTTDT2C_GSP
;
168 if (prio_type
[i
] == prio_link
)
169 reg
|= IXGBE_RTTDT2C_LSP
;
171 IXGBE_WRITE_REG(hw
, IXGBE_RTTDT2C(i
), reg
);
175 * Configure Tx descriptor plane (recycle mode; WSP) and
178 reg
= IXGBE_RTTDCS_TDPAC
| IXGBE_RTTDCS_TDRM
;
179 IXGBE_WRITE_REG(hw
, IXGBE_RTTDCS
, reg
);
185 * ixgbe_dcb_config_tx_data_arbiter_82599 - Config Tx Data arbiter
186 * @hw: pointer to hardware structure
187 * @refill: refill credits index by traffic class
188 * @max: max credits index by traffic class
189 * @bwg_id: bandwidth grouping indexed by traffic class
190 * @prio_type: priority type indexed by traffic class
192 * Configure Tx Packet Arbiter and credits for each traffic class.
194 s32
ixgbe_dcb_config_tx_data_arbiter_82599(struct ixgbe_hw
*hw
,
205 * Disable the arbiter before changing parameters
206 * (always enable recycle mode; SP; arb delay)
208 reg
= IXGBE_RTTPCS_TPPAC
| IXGBE_RTTPCS_TPRM
|
209 (IXGBE_RTTPCS_ARBD_DCB
<< IXGBE_RTTPCS_ARBD_SHIFT
) |
211 IXGBE_WRITE_REG(hw
, IXGBE_RTTPCS
, reg
);
213 /* Map all traffic classes to their UP, 1 to 1 */
215 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++)
216 reg
|= (prio_tc
[i
] << (i
* IXGBE_RTTUP2TC_UP_SHIFT
));
217 IXGBE_WRITE_REG(hw
, IXGBE_RTTUP2TC
, reg
);
219 /* Configure traffic class credits and priority */
220 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++) {
222 reg
|= (u32
)(max
[i
]) << IXGBE_RTTPT2C_MCL_SHIFT
;
223 reg
|= (u32
)(bwg_id
[i
]) << IXGBE_RTTPT2C_BWG_SHIFT
;
225 if (prio_type
[i
] == prio_group
)
226 reg
|= IXGBE_RTTPT2C_GSP
;
228 if (prio_type
[i
] == prio_link
)
229 reg
|= IXGBE_RTTPT2C_LSP
;
231 IXGBE_WRITE_REG(hw
, IXGBE_RTTPT2C(i
), reg
);
235 * Configure Tx packet plane (recycle mode; SP; arb delay) and
238 reg
= IXGBE_RTTPCS_TPPAC
| IXGBE_RTTPCS_TPRM
|
239 (IXGBE_RTTPCS_ARBD_DCB
<< IXGBE_RTTPCS_ARBD_SHIFT
);
240 IXGBE_WRITE_REG(hw
, IXGBE_RTTPCS
, reg
);
246 * ixgbe_dcb_config_pfc_82599 - Configure priority flow control
247 * @hw: pointer to hardware structure
248 * @pfc_en: enabled pfc bitmask
250 * Configure Priority Flow Control (PFC) for each traffic class.
252 s32
ixgbe_dcb_config_pfc_82599(struct ixgbe_hw
*hw
, u8 pfc_en
)
254 u32 i
, reg
, rx_pba_size
;
256 /* Configure PFC Tx thresholds per TC */
257 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++) {
258 int enabled
= pfc_en
& (1 << i
);
259 rx_pba_size
= IXGBE_READ_REG(hw
, IXGBE_RXPBSIZE(i
));
260 rx_pba_size
>>= IXGBE_RXPBSIZE_SHIFT
;
262 reg
= (rx_pba_size
- hw
->fc
.low_water
) << 10;
265 reg
|= IXGBE_FCRTL_XONE
;
266 IXGBE_WRITE_REG(hw
, IXGBE_FCRTL_82599(i
), reg
);
268 reg
= (rx_pba_size
- hw
->fc
.high_water
) << 10;
270 reg
|= IXGBE_FCRTH_FCEN
;
271 IXGBE_WRITE_REG(hw
, IXGBE_FCRTH_82599(i
), reg
);
275 /* Configure pause time (2 TCs per register) */
276 reg
= hw
->fc
.pause_time
| (hw
->fc
.pause_time
<< 16);
277 for (i
= 0; i
< (MAX_TRAFFIC_CLASS
/ 2); i
++)
278 IXGBE_WRITE_REG(hw
, IXGBE_FCTTV(i
), reg
);
280 /* Configure flow control refresh threshold value */
281 IXGBE_WRITE_REG(hw
, IXGBE_FCRTV
, hw
->fc
.pause_time
/ 2);
284 reg
= IXGBE_FCCFG_TFCE_PRIORITY
;
285 IXGBE_WRITE_REG(hw
, IXGBE_FCCFG
, reg
);
288 * We will always honor XOFF frames we receive when
289 * we are in PFC mode.
291 reg
= IXGBE_READ_REG(hw
, IXGBE_MFLCN
);
292 reg
&= ~IXGBE_MFLCN_RFCE
;
293 reg
|= IXGBE_MFLCN_RPFCE
| IXGBE_MFLCN_DPF
;
294 IXGBE_WRITE_REG(hw
, IXGBE_MFLCN
, reg
);
297 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++)
298 hw
->mac
.ops
.fc_enable(hw
, i
);
305 * ixgbe_dcb_config_tc_stats_82599 - Config traffic class statistics
306 * @hw: pointer to hardware structure
308 * Configure queue statistics registers, all queues belonging to same traffic
309 * class uses a single set of queue statistics counters.
311 static s32
ixgbe_dcb_config_tc_stats_82599(struct ixgbe_hw
*hw
)
317 * Receive Queues stats setting
318 * 32 RQSMR registers, each configuring 4 queues.
319 * Set all 16 queues of each TC to the same stat
320 * with TC 'n' going to stat 'n'.
322 for (i
= 0; i
< 32; i
++) {
323 reg
= 0x01010101 * (i
/ 4);
324 IXGBE_WRITE_REG(hw
, IXGBE_RQSMR(i
), reg
);
327 * Transmit Queues stats setting
328 * 32 TQSM registers, each controlling 4 queues.
329 * Set all queues of each TC to the same stat
330 * with TC 'n' going to stat 'n'.
331 * Tx queues are allocated non-uniformly to TCs:
332 * 32, 32, 16, 16, 8, 8, 8, 8.
334 for (i
= 0; i
< 32; i
++) {
351 IXGBE_WRITE_REG(hw
, IXGBE_TQSM(i
), reg
);
358 * ixgbe_dcb_config_82599 - Configure general DCB parameters
359 * @hw: pointer to hardware structure
361 * Configure general DCB parameters.
363 static s32
ixgbe_dcb_config_82599(struct ixgbe_hw
*hw
)
368 /* Disable the Tx desc arbiter so that MTQC can be changed */
369 reg
= IXGBE_READ_REG(hw
, IXGBE_RTTDCS
);
370 reg
|= IXGBE_RTTDCS_ARBDIS
;
371 IXGBE_WRITE_REG(hw
, IXGBE_RTTDCS
, reg
);
373 /* Enable DCB for Rx with 8 TCs */
374 reg
= IXGBE_READ_REG(hw
, IXGBE_MRQC
);
375 switch (reg
& IXGBE_MRQC_MRQE_MASK
) {
377 case IXGBE_MRQC_RT4TCEN
:
378 /* RSS disabled cases */
379 reg
= (reg
& ~IXGBE_MRQC_MRQE_MASK
) | IXGBE_MRQC_RT8TCEN
;
381 case IXGBE_MRQC_RSSEN
:
382 case IXGBE_MRQC_RTRSS4TCEN
:
383 /* RSS enabled cases */
384 reg
= (reg
& ~IXGBE_MRQC_MRQE_MASK
) | IXGBE_MRQC_RTRSS8TCEN
;
387 /* Unsupported value, assume stale data, overwrite no RSS */
388 reg
= (reg
& ~IXGBE_MRQC_MRQE_MASK
) | IXGBE_MRQC_RT8TCEN
;
390 IXGBE_WRITE_REG(hw
, IXGBE_MRQC
, reg
);
392 /* Enable DCB for Tx with 8 TCs */
393 reg
= IXGBE_MTQC_RT_ENA
| IXGBE_MTQC_8TC_8TQ
;
394 IXGBE_WRITE_REG(hw
, IXGBE_MTQC
, reg
);
396 /* Disable drop for all queues */
397 for (q
= 0; q
< 128; q
++)
398 IXGBE_WRITE_REG(hw
, IXGBE_QDE
, q
<< IXGBE_QDE_IDX_SHIFT
);
400 /* Enable the Tx desc arbiter */
401 reg
= IXGBE_READ_REG(hw
, IXGBE_RTTDCS
);
402 reg
&= ~IXGBE_RTTDCS_ARBDIS
;
403 IXGBE_WRITE_REG(hw
, IXGBE_RTTDCS
, reg
);
405 /* Enable Security TX Buffer IFG for DCB */
406 reg
= IXGBE_READ_REG(hw
, IXGBE_SECTXMINIFG
);
407 reg
|= IXGBE_SECTX_DCB
;
408 IXGBE_WRITE_REG(hw
, IXGBE_SECTXMINIFG
, reg
);
414 * ixgbe_dcb_hw_config_82599 - Configure and enable DCB
415 * @hw: pointer to hardware 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
423 * Configure dcb settings and enable dcb mode.
425 s32
ixgbe_dcb_hw_config_82599(struct ixgbe_hw
*hw
,
426 u8 rx_pba
, u8 pfc_en
, u16
*refill
,
427 u16
*max
, u8
*bwg_id
, u8
*prio_type
, u8
*prio_tc
)
429 ixgbe_dcb_config_packet_buffers_82599(hw
, rx_pba
);
430 ixgbe_dcb_config_82599(hw
);
431 ixgbe_dcb_config_rx_arbiter_82599(hw
, refill
, max
, bwg_id
,
433 ixgbe_dcb_config_tx_desc_arbiter_82599(hw
, refill
, max
,
435 ixgbe_dcb_config_tx_data_arbiter_82599(hw
, refill
, max
,
436 bwg_id
, prio_type
, prio_tc
);
437 ixgbe_dcb_config_pfc_82599(hw
, pfc_en
);
438 ixgbe_dcb_config_tc_stats_82599(hw
);