1 /*******************************************************************************
3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2010 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 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
30 #include "ixgbe_type.h"
31 #include "ixgbe_dcb.h"
32 #include "ixgbe_dcb_82598.h"
35 * ixgbe_dcb_config_packet_buffers_82598 - Configure packet buffers
36 * @hw: pointer to hardware structure
37 * @dcb_config: pointer to ixgbe_dcb_config structure
39 * Configure packet buffers for DCB mode.
41 static s32
ixgbe_dcb_config_packet_buffers_82598(struct ixgbe_hw
*hw
,
42 struct ixgbe_dcb_config
*dcb_config
)
45 u32 value
= IXGBE_RXPBSIZE_64KB
;
48 /* Setup Rx packet buffer sizes */
49 switch (dcb_config
->rx_pba_cfg
) {
51 /* Setup the first four at 80KB */
52 value
= IXGBE_RXPBSIZE_80KB
;
54 IXGBE_WRITE_REG(hw
, IXGBE_RXPBSIZE(i
), value
);
55 /* Setup the last four at 48KB...don't re-init i */
56 value
= IXGBE_RXPBSIZE_48KB
;
60 for (; i
< IXGBE_MAX_PACKET_BUFFERS
; i
++)
61 IXGBE_WRITE_REG(hw
, IXGBE_RXPBSIZE(i
), value
);
63 /* Setup Tx packet buffer sizes */
64 for (i
= 0; i
< IXGBE_MAX_PACKET_BUFFERS
; i
++) {
65 IXGBE_WRITE_REG(hw
, IXGBE_TXPBSIZE(i
),
75 * ixgbe_dcb_config_rx_arbiter_82598 - Config Rx data arbiter
76 * @hw: pointer to hardware structure
77 * @dcb_config: pointer to ixgbe_dcb_config structure
79 * Configure Rx Data Arbiter and credits for each traffic class.
81 static s32
ixgbe_dcb_config_rx_arbiter_82598(struct ixgbe_hw
*hw
,
82 struct ixgbe_dcb_config
*dcb_config
)
84 struct tc_bw_alloc
*p
;
86 u32 credit_refill
= 0;
90 reg
= IXGBE_READ_REG(hw
, IXGBE_RUPPBMR
) | IXGBE_RUPPBMR_MQA
;
91 IXGBE_WRITE_REG(hw
, IXGBE_RUPPBMR
, reg
);
93 reg
= IXGBE_READ_REG(hw
, IXGBE_RMCS
);
95 reg
&= ~IXGBE_RMCS_ARBDIS
;
96 /* Enable Receive Recycle within the BWG */
97 reg
|= IXGBE_RMCS_RRM
;
98 /* Enable Deficit Fixed Priority arbitration*/
99 reg
|= IXGBE_RMCS_DFP
;
101 IXGBE_WRITE_REG(hw
, IXGBE_RMCS
, reg
);
103 /* Configure traffic class credits and priority */
104 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++) {
105 p
= &dcb_config
->tc_config
[i
].path
[DCB_RX_CONFIG
];
106 credit_refill
= p
->data_credits_refill
;
107 credit_max
= p
->data_credits_max
;
109 reg
= credit_refill
| (credit_max
<< IXGBE_RT2CR_MCL_SHIFT
);
111 if (p
->prio_type
== prio_link
)
112 reg
|= IXGBE_RT2CR_LSP
;
114 IXGBE_WRITE_REG(hw
, IXGBE_RT2CR(i
), reg
);
117 reg
= IXGBE_READ_REG(hw
, IXGBE_RDRXCTL
);
118 reg
|= IXGBE_RDRXCTL_RDMTS_1_2
;
119 reg
|= IXGBE_RDRXCTL_MPBEN
;
120 reg
|= IXGBE_RDRXCTL_MCEN
;
121 IXGBE_WRITE_REG(hw
, IXGBE_RDRXCTL
, reg
);
123 reg
= IXGBE_READ_REG(hw
, IXGBE_RXCTRL
);
124 /* Make sure there is enough descriptors before arbitration */
125 reg
&= ~IXGBE_RXCTRL_DMBYPS
;
126 IXGBE_WRITE_REG(hw
, IXGBE_RXCTRL
, reg
);
132 * ixgbe_dcb_config_tx_desc_arbiter_82598 - Config Tx Desc. arbiter
133 * @hw: pointer to hardware structure
134 * @dcb_config: pointer to ixgbe_dcb_config structure
136 * Configure Tx Descriptor Arbiter and credits for each traffic class.
138 static s32
ixgbe_dcb_config_tx_desc_arbiter_82598(struct ixgbe_hw
*hw
,
139 struct ixgbe_dcb_config
*dcb_config
)
141 struct tc_bw_alloc
*p
;
142 u32 reg
, max_credits
;
145 reg
= IXGBE_READ_REG(hw
, IXGBE_DPMCS
);
148 reg
&= ~IXGBE_DPMCS_ARBDIS
;
149 if (!(dcb_config
->round_robin_enable
)) {
150 /* Enable DFP and Recycle mode */
151 reg
|= (IXGBE_DPMCS_TDPAC
| IXGBE_DPMCS_TRM
);
153 reg
|= IXGBE_DPMCS_TSOEF
;
154 /* Configure Max TSO packet size 34KB including payload and headers */
155 reg
|= (0x4 << IXGBE_DPMCS_MTSOS_SHIFT
);
157 IXGBE_WRITE_REG(hw
, IXGBE_DPMCS
, reg
);
159 /* Configure traffic class credits and priority */
160 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++) {
161 p
= &dcb_config
->tc_config
[i
].path
[DCB_TX_CONFIG
];
162 max_credits
= dcb_config
->tc_config
[i
].desc_credits_max
;
163 reg
= max_credits
<< IXGBE_TDTQ2TCCR_MCL_SHIFT
;
164 reg
|= p
->data_credits_refill
;
165 reg
|= (u32
)(p
->bwg_id
) << IXGBE_TDTQ2TCCR_BWG_SHIFT
;
167 if (p
->prio_type
== prio_group
)
168 reg
|= IXGBE_TDTQ2TCCR_GSP
;
170 if (p
->prio_type
== prio_link
)
171 reg
|= IXGBE_TDTQ2TCCR_LSP
;
173 IXGBE_WRITE_REG(hw
, IXGBE_TDTQ2TCCR(i
), reg
);
180 * ixgbe_dcb_config_tx_data_arbiter_82598 - Config Tx data arbiter
181 * @hw: pointer to hardware structure
182 * @dcb_config: pointer to ixgbe_dcb_config structure
184 * Configure Tx Data Arbiter and credits for each traffic class.
186 static s32
ixgbe_dcb_config_tx_data_arbiter_82598(struct ixgbe_hw
*hw
,
187 struct ixgbe_dcb_config
*dcb_config
)
189 struct tc_bw_alloc
*p
;
193 reg
= IXGBE_READ_REG(hw
, IXGBE_PDPMCS
);
194 /* Enable Data Plane Arbiter */
195 reg
&= ~IXGBE_PDPMCS_ARBDIS
;
196 /* Enable DFP and Transmit Recycle Mode */
197 reg
|= (IXGBE_PDPMCS_TPPAC
| IXGBE_PDPMCS_TRM
);
199 IXGBE_WRITE_REG(hw
, IXGBE_PDPMCS
, reg
);
201 /* Configure traffic class credits and priority */
202 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++) {
203 p
= &dcb_config
->tc_config
[i
].path
[DCB_TX_CONFIG
];
204 reg
= p
->data_credits_refill
;
205 reg
|= (u32
)(p
->data_credits_max
) << IXGBE_TDPT2TCCR_MCL_SHIFT
;
206 reg
|= (u32
)(p
->bwg_id
) << IXGBE_TDPT2TCCR_BWG_SHIFT
;
208 if (p
->prio_type
== prio_group
)
209 reg
|= IXGBE_TDPT2TCCR_GSP
;
211 if (p
->prio_type
== prio_link
)
212 reg
|= IXGBE_TDPT2TCCR_LSP
;
214 IXGBE_WRITE_REG(hw
, IXGBE_TDPT2TCCR(i
), reg
);
217 /* Enable Tx packet buffer division */
218 reg
= IXGBE_READ_REG(hw
, IXGBE_DTXCTL
);
219 reg
|= IXGBE_DTXCTL_ENDBUBD
;
220 IXGBE_WRITE_REG(hw
, IXGBE_DTXCTL
, reg
);
226 * ixgbe_dcb_config_pfc_82598 - Config priority flow control
227 * @hw: pointer to hardware structure
228 * @dcb_config: pointer to ixgbe_dcb_config structure
230 * Configure Priority Flow Control for each traffic class.
232 s32
ixgbe_dcb_config_pfc_82598(struct ixgbe_hw
*hw
,
233 struct ixgbe_dcb_config
*dcb_config
)
235 u32 reg
, rx_pba_size
;
238 if (!dcb_config
->pfc_mode_enable
)
241 /* Enable Transmit Priority Flow Control */
242 reg
= IXGBE_READ_REG(hw
, IXGBE_RMCS
);
243 reg
&= ~IXGBE_RMCS_TFCE_802_3X
;
244 /* correct the reporting of our flow control status */
245 reg
|= IXGBE_RMCS_TFCE_PRIORITY
;
246 IXGBE_WRITE_REG(hw
, IXGBE_RMCS
, reg
);
248 /* Enable Receive Priority Flow Control */
249 reg
= IXGBE_READ_REG(hw
, IXGBE_FCTRL
);
250 reg
&= ~IXGBE_FCTRL_RFCE
;
251 reg
|= IXGBE_FCTRL_RPFCE
;
252 IXGBE_WRITE_REG(hw
, IXGBE_FCTRL
, reg
);
255 * Configure flow control thresholds and enable priority flow control
256 * for each traffic class.
258 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++) {
259 rx_pba_size
= IXGBE_READ_REG(hw
, IXGBE_RXPBSIZE(i
));
260 rx_pba_size
>>= IXGBE_RXPBSIZE_SHIFT
;
261 reg
= (rx_pba_size
- hw
->fc
.low_water
) << 10;
263 if (dcb_config
->tc_config
[i
].dcb_pfc
== pfc_enabled_tx
||
264 dcb_config
->tc_config
[i
].dcb_pfc
== pfc_enabled_full
)
265 reg
|= IXGBE_FCRTL_XONE
;
267 IXGBE_WRITE_REG(hw
, IXGBE_FCRTL(i
), reg
);
269 reg
= (rx_pba_size
- hw
->fc
.high_water
) << 10;
270 if (dcb_config
->tc_config
[i
].dcb_pfc
== pfc_enabled_tx
||
271 dcb_config
->tc_config
[i
].dcb_pfc
== pfc_enabled_full
)
272 reg
|= IXGBE_FCRTH_FCEN
;
274 IXGBE_WRITE_REG(hw
, IXGBE_FCRTH(i
), reg
);
277 /* Configure pause time */
278 for (i
= 0; i
< (MAX_TRAFFIC_CLASS
>> 1); i
++)
279 IXGBE_WRITE_REG(hw
, IXGBE_FCTTV(i
), 0x68006800);
281 /* Configure flow control refresh threshold value */
282 IXGBE_WRITE_REG(hw
, IXGBE_FCRTV
, 0x3400);
289 * ixgbe_dcb_config_tc_stats_82598 - Configure traffic class statistics
290 * @hw: pointer to hardware structure
292 * Configure queue statistics registers, all queues belonging to same traffic
293 * class uses a single set of queue statistics counters.
295 static s32
ixgbe_dcb_config_tc_stats_82598(struct ixgbe_hw
*hw
)
301 /* Receive Queues stats setting - 8 queues per statistics reg */
302 for (i
= 0, j
= 0; i
< 15 && j
< 8; i
= i
+ 2, j
++) {
303 reg
= IXGBE_READ_REG(hw
, IXGBE_RQSMR(i
));
304 reg
|= ((0x1010101) * j
);
305 IXGBE_WRITE_REG(hw
, IXGBE_RQSMR(i
), reg
);
306 reg
= IXGBE_READ_REG(hw
, IXGBE_RQSMR(i
+ 1));
307 reg
|= ((0x1010101) * j
);
308 IXGBE_WRITE_REG(hw
, IXGBE_RQSMR(i
+ 1), reg
);
310 /* Transmit Queues stats setting - 4 queues per statistics reg */
311 for (i
= 0; i
< 8; i
++) {
312 reg
= IXGBE_READ_REG(hw
, IXGBE_TQSMR(i
));
313 reg
|= ((0x1010101) * i
);
314 IXGBE_WRITE_REG(hw
, IXGBE_TQSMR(i
), reg
);
321 * ixgbe_dcb_hw_config_82598 - Config and enable DCB
322 * @hw: pointer to hardware structure
323 * @dcb_config: pointer to ixgbe_dcb_config structure
325 * Configure dcb settings and enable dcb mode.
327 s32
ixgbe_dcb_hw_config_82598(struct ixgbe_hw
*hw
,
328 struct ixgbe_dcb_config
*dcb_config
)
330 ixgbe_dcb_config_packet_buffers_82598(hw
, dcb_config
);
331 ixgbe_dcb_config_rx_arbiter_82598(hw
, dcb_config
);
332 ixgbe_dcb_config_tx_desc_arbiter_82598(hw
, dcb_config
);
333 ixgbe_dcb_config_tx_data_arbiter_82598(hw
, dcb_config
);
334 ixgbe_dcb_config_pfc_82598(hw
, dcb_config
);
335 ixgbe_dcb_config_tc_stats_82598(hw
);