aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ixgbe/ixgbe_dcb_82598.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_82598.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_82598.c')
-rw-r--r--drivers/net/ixgbe/ixgbe_dcb_82598.c86
1 files changed, 45 insertions, 41 deletions
diff --git a/drivers/net/ixgbe/ixgbe_dcb_82598.c b/drivers/net/ixgbe/ixgbe_dcb_82598.c
index 19aa80640f68..d1288060cbd0 100644
--- a/drivers/net/ixgbe/ixgbe_dcb_82598.c
+++ b/drivers/net/ixgbe/ixgbe_dcb_82598.c
@@ -38,15 +38,14 @@
38 * 38 *
39 * Configure packet buffers for DCB mode. 39 * Configure packet buffers for DCB mode.
40 */ 40 */
41static s32 ixgbe_dcb_config_packet_buffers_82598(struct ixgbe_hw *hw, 41static s32 ixgbe_dcb_config_packet_buffers_82598(struct ixgbe_hw *hw, u8 rx_pba)
42 struct ixgbe_dcb_config *dcb_config)
43{ 42{
44 s32 ret_val = 0; 43 s32 ret_val = 0;
45 u32 value = IXGBE_RXPBSIZE_64KB; 44 u32 value = IXGBE_RXPBSIZE_64KB;
46 u8 i = 0; 45 u8 i = 0;
47 46
48 /* Setup Rx packet buffer sizes */ 47 /* Setup Rx packet buffer sizes */
49 switch (dcb_config->rx_pba_cfg) { 48 switch (rx_pba) {
50 case pba_80_48: 49 case pba_80_48:
51 /* Setup the first four at 80KB */ 50 /* Setup the first four at 80KB */
52 value = IXGBE_RXPBSIZE_80KB; 51 value = IXGBE_RXPBSIZE_80KB;
@@ -78,10 +77,11 @@ static s32 ixgbe_dcb_config_packet_buffers_82598(struct ixgbe_hw *hw,
78 * 77 *
79 * Configure Rx Data Arbiter and credits for each traffic class. 78 * Configure Rx Data Arbiter and credits for each traffic class.
80 */ 79 */
81static s32 ixgbe_dcb_config_rx_arbiter_82598(struct ixgbe_hw *hw, 80s32 ixgbe_dcb_config_rx_arbiter_82598(struct ixgbe_hw *hw,
82 struct ixgbe_dcb_config *dcb_config) 81 u16 *refill,
82 u16 *max,
83 u8 *prio_type)
83{ 84{
84 struct tc_bw_alloc *p;
85 u32 reg = 0; 85 u32 reg = 0;
86 u32 credit_refill = 0; 86 u32 credit_refill = 0;
87 u32 credit_max = 0; 87 u32 credit_max = 0;
@@ -102,13 +102,12 @@ static s32 ixgbe_dcb_config_rx_arbiter_82598(struct ixgbe_hw *hw,
102 102
103 /* Configure traffic class credits and priority */ 103 /* Configure traffic class credits and priority */
104 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 104 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
105 p = &dcb_config->tc_config[i].path[DCB_RX_CONFIG]; 105 credit_refill = refill[i];
106 credit_refill = p->data_credits_refill; 106 credit_max = max[i];
107 credit_max = p->data_credits_max;
108 107
109 reg = credit_refill | (credit_max << IXGBE_RT2CR_MCL_SHIFT); 108 reg = credit_refill | (credit_max << IXGBE_RT2CR_MCL_SHIFT);
110 109
111 if (p->prio_type == prio_link) 110 if (prio_type[i] == prio_link)
112 reg |= IXGBE_RT2CR_LSP; 111 reg |= IXGBE_RT2CR_LSP;
113 112
114 IXGBE_WRITE_REG(hw, IXGBE_RT2CR(i), reg); 113 IXGBE_WRITE_REG(hw, IXGBE_RT2CR(i), reg);
@@ -135,10 +134,12 @@ static s32 ixgbe_dcb_config_rx_arbiter_82598(struct ixgbe_hw *hw,
135 * 134 *
136 * Configure Tx Descriptor Arbiter and credits for each traffic class. 135 * Configure Tx Descriptor Arbiter and credits for each traffic class.
137 */ 136 */
138static s32 ixgbe_dcb_config_tx_desc_arbiter_82598(struct ixgbe_hw *hw, 137s32 ixgbe_dcb_config_tx_desc_arbiter_82598(struct ixgbe_hw *hw,
139 struct ixgbe_dcb_config *dcb_config) 138 u16 *refill,
139 u16 *max,
140 u8 *bwg_id,
141 u8 *prio_type)
140{ 142{
141 struct tc_bw_alloc *p;
142 u32 reg, max_credits; 143 u32 reg, max_credits;
143 u8 i; 144 u8 i;
144 145
@@ -156,16 +157,15 @@ static s32 ixgbe_dcb_config_tx_desc_arbiter_82598(struct ixgbe_hw *hw,
156 157
157 /* Configure traffic class credits and priority */ 158 /* Configure traffic class credits and priority */
158 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 159 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
159 p = &dcb_config->tc_config[i].path[DCB_TX_CONFIG]; 160 max_credits = max[i];
160 max_credits = dcb_config->tc_config[i].desc_credits_max;
161 reg = max_credits << IXGBE_TDTQ2TCCR_MCL_SHIFT; 161 reg = max_credits << IXGBE_TDTQ2TCCR_MCL_SHIFT;
162 reg |= p->data_credits_refill; 162 reg |= refill[i];
163 reg |= (u32)(p->bwg_id) << IXGBE_TDTQ2TCCR_BWG_SHIFT; 163 reg |= (u32)(bwg_id[i]) << IXGBE_TDTQ2TCCR_BWG_SHIFT;
164 164
165 if (p->prio_type == prio_group) 165 if (prio_type[i] == prio_group)
166 reg |= IXGBE_TDTQ2TCCR_GSP; 166 reg |= IXGBE_TDTQ2TCCR_GSP;
167 167
168 if (p->prio_type == prio_link) 168 if (prio_type[i] == prio_link)
169 reg |= IXGBE_TDTQ2TCCR_LSP; 169 reg |= IXGBE_TDTQ2TCCR_LSP;
170 170
171 IXGBE_WRITE_REG(hw, IXGBE_TDTQ2TCCR(i), reg); 171 IXGBE_WRITE_REG(hw, IXGBE_TDTQ2TCCR(i), reg);
@@ -181,10 +181,12 @@ static s32 ixgbe_dcb_config_tx_desc_arbiter_82598(struct ixgbe_hw *hw,
181 * 181 *
182 * Configure Tx Data Arbiter and credits for each traffic class. 182 * Configure Tx Data Arbiter and credits for each traffic class.
183 */ 183 */
184static s32 ixgbe_dcb_config_tx_data_arbiter_82598(struct ixgbe_hw *hw, 184s32 ixgbe_dcb_config_tx_data_arbiter_82598(struct ixgbe_hw *hw,
185 struct ixgbe_dcb_config *dcb_config) 185 u16 *refill,
186 u16 *max,
187 u8 *bwg_id,
188 u8 *prio_type)
186{ 189{
187 struct tc_bw_alloc *p;
188 u32 reg; 190 u32 reg;
189 u8 i; 191 u8 i;
190 192
@@ -198,15 +200,14 @@ static s32 ixgbe_dcb_config_tx_data_arbiter_82598(struct ixgbe_hw *hw,
198 200
199 /* Configure traffic class credits and priority */ 201 /* Configure traffic class credits and priority */
200 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 202 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
201 p = &dcb_config->tc_config[i].path[DCB_TX_CONFIG]; 203 reg = refill[i];
202 reg = p->data_credits_refill; 204 reg |= (u32)(max[i]) << IXGBE_TDPT2TCCR_MCL_SHIFT;
203 reg |= (u32)(p->data_credits_max) << IXGBE_TDPT2TCCR_MCL_SHIFT; 205 reg |= (u32)(bwg_id[i]) << IXGBE_TDPT2TCCR_BWG_SHIFT;
204 reg |= (u32)(p->bwg_id) << IXGBE_TDPT2TCCR_BWG_SHIFT;
205 206
206 if (p->prio_type == prio_group) 207 if (prio_type[i] == prio_group)
207 reg |= IXGBE_TDPT2TCCR_GSP; 208 reg |= IXGBE_TDPT2TCCR_GSP;
208 209
209 if (p->prio_type == prio_link) 210 if (prio_type[i] == prio_link)
210 reg |= IXGBE_TDPT2TCCR_LSP; 211 reg |= IXGBE_TDPT2TCCR_LSP;
211 212
212 IXGBE_WRITE_REG(hw, IXGBE_TDPT2TCCR(i), reg); 213 IXGBE_WRITE_REG(hw, IXGBE_TDPT2TCCR(i), reg);
@@ -227,13 +228,12 @@ static s32 ixgbe_dcb_config_tx_data_arbiter_82598(struct ixgbe_hw *hw,
227 * 228 *
228 * Configure Priority Flow Control for each traffic class. 229 * Configure Priority Flow Control for each traffic class.
229 */ 230 */
230s32 ixgbe_dcb_config_pfc_82598(struct ixgbe_hw *hw, 231s32 ixgbe_dcb_config_pfc_82598(struct ixgbe_hw *hw, u8 pfc_en)
231 struct ixgbe_dcb_config *dcb_config)
232{ 232{
233 u32 reg, rx_pba_size; 233 u32 reg, rx_pba_size;
234 u8 i; 234 u8 i;
235 235
236 if (!dcb_config->pfc_mode_enable) 236 if (!pfc_en)
237 goto out; 237 goto out;
238 238
239 /* Enable Transmit Priority Flow Control */ 239 /* Enable Transmit Priority Flow Control */
@@ -254,19 +254,20 @@ s32 ixgbe_dcb_config_pfc_82598(struct ixgbe_hw *hw,
254 * for each traffic class. 254 * for each traffic class.
255 */ 255 */
256 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 256 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
257 int enabled = pfc_en & (1 << i);
257 rx_pba_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i)); 258 rx_pba_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i));
258 rx_pba_size >>= IXGBE_RXPBSIZE_SHIFT; 259 rx_pba_size >>= IXGBE_RXPBSIZE_SHIFT;
259 reg = (rx_pba_size - hw->fc.low_water) << 10; 260 reg = (rx_pba_size - hw->fc.low_water) << 10;
260 261
261 if (dcb_config->tc_config[i].dcb_pfc == pfc_enabled_tx || 262 if (enabled == pfc_enabled_tx ||
262 dcb_config->tc_config[i].dcb_pfc == pfc_enabled_full) 263 enabled == pfc_enabled_full)
263 reg |= IXGBE_FCRTL_XONE; 264 reg |= IXGBE_FCRTL_XONE;
264 265
265 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), reg); 266 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), reg);
266 267
267 reg = (rx_pba_size - hw->fc.high_water) << 10; 268 reg = (rx_pba_size - hw->fc.high_water) << 10;
268 if (dcb_config->tc_config[i].dcb_pfc == pfc_enabled_tx || 269 if (enabled == pfc_enabled_tx ||
269 dcb_config->tc_config[i].dcb_pfc == pfc_enabled_full) 270 enabled == pfc_enabled_full)
270 reg |= IXGBE_FCRTH_FCEN; 271 reg |= IXGBE_FCRTH_FCEN;
271 272
272 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), reg); 273 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), reg);
@@ -323,13 +324,16 @@ static s32 ixgbe_dcb_config_tc_stats_82598(struct ixgbe_hw *hw)
323 * Configure dcb settings and enable dcb mode. 324 * Configure dcb settings and enable dcb mode.
324 */ 325 */
325s32 ixgbe_dcb_hw_config_82598(struct ixgbe_hw *hw, 326s32 ixgbe_dcb_hw_config_82598(struct ixgbe_hw *hw,
326 struct ixgbe_dcb_config *dcb_config) 327 u8 rx_pba, u8 pfc_en, u16 *refill,
328 u16 *max, u8 *bwg_id, u8 *prio_type)
327{ 329{
328 ixgbe_dcb_config_packet_buffers_82598(hw, dcb_config); 330 ixgbe_dcb_config_packet_buffers_82598(hw, rx_pba);
329 ixgbe_dcb_config_rx_arbiter_82598(hw, dcb_config); 331 ixgbe_dcb_config_rx_arbiter_82598(hw, refill, max, prio_type);
330 ixgbe_dcb_config_tx_desc_arbiter_82598(hw, dcb_config); 332 ixgbe_dcb_config_tx_desc_arbiter_82598(hw, refill, max,
331 ixgbe_dcb_config_tx_data_arbiter_82598(hw, dcb_config); 333 bwg_id, prio_type);
332 ixgbe_dcb_config_pfc_82598(hw, dcb_config); 334 ixgbe_dcb_config_tx_data_arbiter_82598(hw, refill, max,
335 bwg_id, prio_type);
336 ixgbe_dcb_config_pfc_82598(hw, pfc_en);
333 ixgbe_dcb_config_tc_stats_82598(hw); 337 ixgbe_dcb_config_tc_stats_82598(hw);
334 338
335 return 0; 339 return 0;