34
34
* ixgbe_dcb_config_packet_buffers_82599 - Configure DCB packet buffers
35
35
* @hw: pointer to hardware structure
36
* @dcb_config: pointer to ixgbe_dcb_config structure
36
* @rx_pba: method to distribute packet buffer
38
38
* Configure packet buffers for DCB mode.
40
static s32 ixgbe_dcb_config_packet_buffers_82599(struct ixgbe_hw *hw,
41
struct ixgbe_dcb_config *dcb_config)
40
static s32 ixgbe_dcb_config_packet_buffers_82599(struct ixgbe_hw *hw, u8 rx_pba)
44
u32 value = IXGBE_RXPBSIZE_64KB;
42
int num_tcs = IXGBE_MAX_PACKET_BUFFERS;
43
u32 rx_pb_size = hw->mac.rx_pb_size << IXGBE_RXPBSIZE_SHIFT;
47
/* Setup Rx packet buffer sizes */
48
switch (dcb_config->rx_pba_cfg) {
50
/* Setup the first four at 80KB */
51
value = IXGBE_RXPBSIZE_80KB;
53
IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), value);
54
/* Setup the last four at 48KB...don't re-init i */
55
value = IXGBE_RXPBSIZE_48KB;
59
for (; i < IXGBE_MAX_PACKET_BUFFERS; i++)
60
IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), value);
62
/* Setup Tx packet buffer sizes */
63
for (i = 0; i < IXGBE_MAX_PACKET_BUFFERS; i++) {
64
IXGBE_WRITE_REG(hw, IXGBE_TXPBSIZE(i),
66
IXGBE_WRITE_REG(hw, IXGBE_TXPBTHRESH(i),
67
IXGBE_TXPBTHRESH_DCB);
50
* This really means configure the first half of the TCs
51
* (Traffic Classes) to use 5/8 of the Rx packet buffer
52
* space. To determine the size of the buffer for each TC,
53
* we are multiplying the average size by 5/4 and applying
54
* it to half of the traffic classes.
56
if (rx_pba == pba_80_48) {
57
rxpktsize = (rx_pb_size * 5) / (num_tcs * 4);
58
rx_pb_size -= rxpktsize * (num_tcs / 2);
59
for (; i < (num_tcs / 2); i++)
60
IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpktsize);
63
/* Divide the remaining Rx packet buffer evenly among the TCs */
64
rxpktsize = rx_pb_size / (num_tcs - i);
65
for (; i < num_tcs; i++)
66
IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpktsize);
69
* Setup Tx packet buffer and threshold equally for all TCs
70
* TXPBTHRESH register is set in K so divide by 1024 and subtract
71
* 10 since the largest packet we support is just over 9K.
73
txpktsize = IXGBE_TXPBSIZE_MAX / num_tcs;
74
txpbthresh = (txpktsize / 1024) - IXGBE_TXPKT_SIZE_MAX;
75
for (i = 0; i < num_tcs; i++) {
76
IXGBE_WRITE_REG(hw, IXGBE_TXPBSIZE(i), txpktsize);
77
IXGBE_WRITE_REG(hw, IXGBE_TXPBTHRESH(i), txpbthresh);
80
/* Clear unused TCs, if any, to zero buffer size*/
81
for (; i < MAX_TRAFFIC_CLASS; i++) {
82
IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), 0);
83
IXGBE_WRITE_REG(hw, IXGBE_TXPBSIZE(i), 0);
84
IXGBE_WRITE_REG(hw, IXGBE_TXPBTHRESH(i), 0);
76
91
* ixgbe_dcb_config_rx_arbiter_82599 - Config Rx Data arbiter
77
92
* @hw: pointer to hardware structure
78
* @dcb_config: pointer to ixgbe_dcb_config structure
93
* @refill: refill credits index by traffic class
94
* @max: max credits index by traffic class
95
* @bwg_id: bandwidth grouping indexed by traffic class
96
* @prio_type: priority type indexed by traffic class
80
98
* Configure Rx Packet Arbiter and credits for each traffic class.
82
static s32 ixgbe_dcb_config_rx_arbiter_82599(struct ixgbe_hw *hw,
83
struct ixgbe_dcb_config *dcb_config)
100
s32 ixgbe_dcb_config_rx_arbiter_82599(struct ixgbe_hw *hw,
85
struct tc_bw_alloc *p;
87
108
u32 credit_refill = 0;
88
109
u32 credit_max = 0;
98
119
/* Map all traffic classes to their UP, 1 to 1 */
100
121
for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
101
reg |= (i << (i * IXGBE_RTRUP2TC_UP_SHIFT));
122
reg |= (prio_tc[i] << (i * IXGBE_RTRUP2TC_UP_SHIFT));
102
123
IXGBE_WRITE_REG(hw, IXGBE_RTRUP2TC, reg);
104
125
/* Configure traffic class credits and priority */
105
126
for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
106
p = &dcb_config->tc_config[i].path[DCB_RX_CONFIG];
108
credit_refill = p->data_credits_refill;
109
credit_max = p->data_credits_max;
127
credit_refill = refill[i];
110
129
reg = credit_refill | (credit_max << IXGBE_RTRPT4C_MCL_SHIFT);
112
reg |= (u32)(p->bwg_id) << IXGBE_RTRPT4C_BWG_SHIFT;
131
reg |= (u32)(bwg_id[i]) << IXGBE_RTRPT4C_BWG_SHIFT;
114
if (p->prio_type == prio_link)
133
if (prio_type[i] == prio_link)
115
134
reg |= IXGBE_RTRPT4C_LSP;
117
136
IXGBE_WRITE_REG(hw, IXGBE_RTRPT4C(i), reg);
131
150
* ixgbe_dcb_config_tx_desc_arbiter_82599 - Config Tx Desc. arbiter
132
151
* @hw: pointer to hardware structure
133
* @dcb_config: pointer to ixgbe_dcb_config structure
152
* @refill: refill credits index by traffic class
153
* @max: max credits index by traffic class
154
* @bwg_id: bandwidth grouping indexed by traffic class
155
* @prio_type: priority type indexed by traffic class
135
157
* Configure Tx Descriptor Arbiter and credits for each traffic class.
137
static s32 ixgbe_dcb_config_tx_desc_arbiter_82599(struct ixgbe_hw *hw,
138
struct ixgbe_dcb_config *dcb_config)
159
s32 ixgbe_dcb_config_tx_desc_arbiter_82599(struct ixgbe_hw *hw,
140
struct tc_bw_alloc *p;
141
165
u32 reg, max_credits;
150
174
/* Configure traffic class credits and priority */
151
175
for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
152
p = &dcb_config->tc_config[i].path[DCB_TX_CONFIG];
153
max_credits = dcb_config->tc_config[i].desc_credits_max;
176
max_credits = max[i];
154
177
reg = max_credits << IXGBE_RTTDT2C_MCL_SHIFT;
155
reg |= p->data_credits_refill;
156
reg |= (u32)(p->bwg_id) << IXGBE_RTTDT2C_BWG_SHIFT;
179
reg |= (u32)(bwg_id[i]) << IXGBE_RTTDT2C_BWG_SHIFT;
158
if (p->prio_type == prio_group)
181
if (prio_type[i] == prio_group)
159
182
reg |= IXGBE_RTTDT2C_GSP;
161
if (p->prio_type == prio_link)
184
if (prio_type[i] == prio_link)
162
185
reg |= IXGBE_RTTDT2C_LSP;
164
187
IXGBE_WRITE_REG(hw, IXGBE_RTTDT2C(i), reg);
178
201
* ixgbe_dcb_config_tx_data_arbiter_82599 - Config Tx Data arbiter
179
202
* @hw: pointer to hardware structure
180
* @dcb_config: pointer to ixgbe_dcb_config structure
203
* @refill: refill credits index by traffic class
204
* @max: max credits index by traffic class
205
* @bwg_id: bandwidth grouping indexed by traffic class
206
* @prio_type: priority type indexed by traffic class
182
208
* Configure Tx Packet Arbiter and credits for each traffic class.
184
static s32 ixgbe_dcb_config_tx_data_arbiter_82599(struct ixgbe_hw *hw,
185
struct ixgbe_dcb_config *dcb_config)
210
s32 ixgbe_dcb_config_tx_data_arbiter_82599(struct ixgbe_hw *hw,
187
struct tc_bw_alloc *p;
200
229
/* Map all traffic classes to their UP, 1 to 1 */
202
231
for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
203
reg |= (i << (i * IXGBE_RTTUP2TC_UP_SHIFT));
232
reg |= (prio_tc[i] << (i * IXGBE_RTTUP2TC_UP_SHIFT));
204
233
IXGBE_WRITE_REG(hw, IXGBE_RTTUP2TC, reg);
206
235
/* Configure traffic class credits and priority */
207
236
for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
208
p = &dcb_config->tc_config[i].path[DCB_TX_CONFIG];
209
reg = p->data_credits_refill;
210
reg |= (u32)(p->data_credits_max) << IXGBE_RTTPT2C_MCL_SHIFT;
211
reg |= (u32)(p->bwg_id) << IXGBE_RTTPT2C_BWG_SHIFT;
238
reg |= (u32)(max[i]) << IXGBE_RTTPT2C_MCL_SHIFT;
239
reg |= (u32)(bwg_id[i]) << IXGBE_RTTPT2C_BWG_SHIFT;
213
if (p->prio_type == prio_group)
241
if (prio_type[i] == prio_group)
214
242
reg |= IXGBE_RTTPT2C_GSP;
216
if (p->prio_type == prio_link)
244
if (prio_type[i] == prio_link)
217
245
reg |= IXGBE_RTTPT2C_LSP;
219
247
IXGBE_WRITE_REG(hw, IXGBE_RTTPT2C(i), reg);
234
262
* ixgbe_dcb_config_pfc_82599 - Configure priority flow control
235
263
* @hw: pointer to hardware structure
236
* @dcb_config: pointer to ixgbe_dcb_config structure
264
* @pfc_en: enabled pfc bitmask
238
266
* Configure Priority Flow Control (PFC) for each traffic class.
240
s32 ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw,
241
struct ixgbe_dcb_config *dcb_config)
268
s32 ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw, u8 pfc_en)
243
270
u32 i, reg, rx_pba_size;
245
/* If PFC is disabled globally then fall back to LFC. */
246
if (!dcb_config->pfc_mode_enable) {
247
for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
248
hw->mac.ops.fc_enable(hw, i);
252
272
/* Configure PFC Tx thresholds per TC */
253
273
for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
274
int enabled = pfc_en & (1 << i);
254
275
rx_pba_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i));
255
276
rx_pba_size >>= IXGBE_RXPBSIZE_SHIFT;
257
278
reg = (rx_pba_size - hw->fc.low_water) << 10;
259
if (dcb_config->tc_config[i].dcb_pfc == pfc_enabled_full ||
260
dcb_config->tc_config[i].dcb_pfc == pfc_enabled_tx)
261
281
reg |= IXGBE_FCRTL_XONE;
262
282
IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), reg);
264
284
reg = (rx_pba_size - hw->fc.high_water) << 10;
265
if (dcb_config->tc_config[i].dcb_pfc == pfc_enabled_full ||
266
dcb_config->tc_config[i].dcb_pfc == pfc_enabled_tx)
267
286
reg |= IXGBE_FCRTH_FCEN;
268
287
IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(i), reg);
271
/* Configure pause time (2 TCs per register) */
272
reg = hw->fc.pause_time | (hw->fc.pause_time << 16);
273
for (i = 0; i < (MAX_TRAFFIC_CLASS / 2); i++)
274
IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
276
/* Configure flow control refresh threshold value */
277
IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
279
/* Enable Transmit PFC */
280
reg = IXGBE_FCCFG_TFCE_PRIORITY;
281
IXGBE_WRITE_REG(hw, IXGBE_FCCFG, reg);
285
* We will always honor XOFF frames we receive when
286
* we are in PFC mode.
288
reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
289
reg &= ~IXGBE_MFLCN_RFCE;
290
reg |= IXGBE_MFLCN_RPFCE | IXGBE_MFLCN_DPF;
291
IXGBE_WRITE_REG(hw, IXGBE_MFLCN, reg);
291
/* Configure pause time (2 TCs per register) */
292
reg = hw->fc.pause_time | (hw->fc.pause_time << 16);
293
for (i = 0; i < (MAX_TRAFFIC_CLASS / 2); i++)
294
IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
296
/* Configure flow control refresh threshold value */
297
IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
300
reg = IXGBE_FCCFG_TFCE_PRIORITY;
301
IXGBE_WRITE_REG(hw, IXGBE_FCCFG, reg);
304
* 82599 will always honor XOFF frames we receive when
305
* we are in PFC mode however X540 only honors enabled
308
reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
309
reg &= ~IXGBE_MFLCN_RFCE;
310
reg |= IXGBE_MFLCN_RPFCE | IXGBE_MFLCN_DPF;
312
if (hw->mac.type == ixgbe_mac_X540)
313
reg |= pfc_en << IXGBE_MFLCN_RPFCE_SHIFT;
315
IXGBE_WRITE_REG(hw, IXGBE_MFLCN, reg);
318
for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
319
hw->mac.ops.fc_enable(hw, i);
407
435
* ixgbe_dcb_hw_config_82599 - Configure and enable DCB
408
436
* @hw: pointer to hardware structure
409
* @dcb_config: pointer to ixgbe_dcb_config structure
437
* @rx_pba: method to distribute packet buffer
438
* @refill: refill credits index by traffic class
439
* @max: max credits index by traffic class
440
* @bwg_id: bandwidth grouping indexed by traffic class
441
* @prio_type: priority type indexed by traffic class
442
* @pfc_en: enabled pfc bitmask
411
444
* Configure dcb settings and enable dcb mode.
413
446
s32 ixgbe_dcb_hw_config_82599(struct ixgbe_hw *hw,
414
struct ixgbe_dcb_config *dcb_config)
447
u8 rx_pba, u8 pfc_en, u16 *refill,
448
u16 *max, u8 *bwg_id, u8 *prio_type, u8 *prio_tc)
416
ixgbe_dcb_config_packet_buffers_82599(hw, dcb_config);
450
ixgbe_dcb_config_packet_buffers_82599(hw, rx_pba);
417
451
ixgbe_dcb_config_82599(hw);
418
ixgbe_dcb_config_rx_arbiter_82599(hw, dcb_config);
419
ixgbe_dcb_config_tx_desc_arbiter_82599(hw, dcb_config);
420
ixgbe_dcb_config_tx_data_arbiter_82599(hw, dcb_config);
421
ixgbe_dcb_config_pfc_82599(hw, dcb_config);
452
ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, bwg_id,
454
ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max,
456
ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max,
457
bwg_id, prio_type, prio_tc);
458
ixgbe_dcb_config_pfc_82599(hw, pfc_en);
422
459
ixgbe_dcb_config_tc_stats_82599(hw);