aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ixgbe/ixgbe_dcb_82599.c
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 /drivers/net/ixgbe/ixgbe_dcb_82599.c
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>
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_dcb_82599.c')
-rw-r--r--drivers/net/ixgbe/ixgbe_dcb_82599.c115
1 files changed, 65 insertions, 50 deletions
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;