aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2012-04-19 13:48:48 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2012-05-04 06:25:24 -0400
commit041441d0f0d885619d48f8f7682825ace523cf59 (patch)
treec1ddc6cb296a46862093138aa1ada4c2cf8f0d0d /drivers
parent67a79df27163a89fb1ce2191718855288071cbd2 (diff)
ixgbe: Update link flow control to correctly handle multiple packet buffer DCB
This change updates the link flow control configuration so that we correctly set the link flow control settings for DCB. Previously we would have to call the fc_enable call 8 times, once for each packet buffer. If we move that logic into the fc_enable call itself we can avoid multiple unnecessary register writes. This change also corrects an issue in which we were only shifting the water marks for 82599 parts by 6 instead of 10. This was resulting in us only using 1/16 of the packet buffer when flow control was enabled. Signed-off-by: Alexander Duyck <alexander.h.duyck@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')
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c61
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.c164
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.h2
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c13
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c16
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_type.h4
6 files changed, 102 insertions, 158 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
index badcf821d89a..42537336110c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
@@ -324,24 +324,33 @@ out:
324/** 324/**
325 * ixgbe_fc_enable_82598 - Enable flow control 325 * ixgbe_fc_enable_82598 - Enable flow control
326 * @hw: pointer to hardware structure 326 * @hw: pointer to hardware structure
327 * @packetbuf_num: packet buffer number (0-7)
328 * 327 *
329 * Enable flow control according to the current settings. 328 * Enable flow control according to the current settings.
330 **/ 329 **/
331static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num) 330static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
332{ 331{
333 s32 ret_val = 0; 332 s32 ret_val = 0;
334 u32 fctrl_reg; 333 u32 fctrl_reg;
335 u32 rmcs_reg; 334 u32 rmcs_reg;
336 u32 reg; 335 u32 reg;
336 u32 fcrtl, fcrth;
337 u32 link_speed = 0; 337 u32 link_speed = 0;
338 int i;
338 bool link_up; 339 bool link_up;
339 340
340#ifdef CONFIG_DCB 341 /*
341 if (hw->fc.requested_mode == ixgbe_fc_pfc) 342 * Validate the water mark configuration for packet buffer 0. Zero
343 * water marks indicate that the packet buffer was not configured
344 * and the watermarks for packet buffer 0 should always be configured.
345 */
346 if (!hw->fc.low_water ||
347 !hw->fc.high_water[0] ||
348 !hw->fc.pause_time) {
349 hw_dbg(hw, "Invalid water mark configuration\n");
350 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
342 goto out; 351 goto out;
352 }
343 353
344#endif /* CONFIG_DCB */
345 /* 354 /*
346 * On 82598 having Rx FC on causes resets while doing 1G 355 * On 82598 having Rx FC on causes resets while doing 1G
347 * so if it's on turn it off once we know link_speed. For 356 * so if it's on turn it off once we know link_speed. For
@@ -380,9 +389,6 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
380 * 2: Tx flow control is enabled (we can send pause frames but 389 * 2: Tx flow control is enabled (we can send pause frames but
381 * we do not support receiving pause frames). 390 * we do not support receiving pause frames).
382 * 3: Both Rx and Tx flow control (symmetric) are enabled. 391 * 3: Both Rx and Tx flow control (symmetric) are enabled.
383#ifdef CONFIG_DCB
384 * 4: Priority Flow Control is enabled.
385#endif
386 * other: Invalid. 392 * other: Invalid.
387 */ 393 */
388 switch (hw->fc.current_mode) { 394 switch (hw->fc.current_mode) {
@@ -415,11 +421,6 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
415 fctrl_reg |= IXGBE_FCTRL_RFCE; 421 fctrl_reg |= IXGBE_FCTRL_RFCE;
416 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X; 422 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
417 break; 423 break;
418#ifdef CONFIG_DCB
419 case ixgbe_fc_pfc:
420 goto out;
421 break;
422#endif /* CONFIG_DCB */
423 default: 424 default:
424 hw_dbg(hw, "Flow control param set incorrectly\n"); 425 hw_dbg(hw, "Flow control param set incorrectly\n");
425 ret_val = IXGBE_ERR_CONFIG; 426 ret_val = IXGBE_ERR_CONFIG;
@@ -432,29 +433,29 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
432 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl_reg); 433 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl_reg);
433 IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg); 434 IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg);
434 435
435 /* Set up and enable Rx high/low water mark thresholds, enable XON. */ 436 fcrtl = (hw->fc.low_water << 10) | IXGBE_FCRTL_XONE;
436 if (hw->fc.current_mode & ixgbe_fc_tx_pause) {
437 reg = hw->fc.low_water << 6;
438 if (hw->fc.send_xon)
439 reg |= IXGBE_FCRTL_XONE;
440 437
441 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num), reg); 438 /* Set up and enable Rx high/low water mark thresholds, enable XON. */
442 439 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
443 reg = hw->fc.high_water[packetbuf_num] << 6; 440 if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
444 reg |= IXGBE_FCRTH_FCEN; 441 hw->fc.high_water[i]) {
442 fcrth = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN;
443 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), fcrtl);
444 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), fcrth);
445 } else {
446 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), 0);
447 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), 0);
448 }
445 449
446 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(packetbuf_num), reg);
447 } 450 }
448 451
449 /* Configure pause time (2 TCs per register) */ 452 /* Configure pause time (2 TCs per register) */
450 reg = IXGBE_READ_REG(hw, IXGBE_FCTTV(packetbuf_num / 2)); 453 reg = hw->fc.pause_time * 0x00010001;
451 if ((packetbuf_num & 1) == 0) 454 for (i = 0; i < (MAX_TRAFFIC_CLASS / 2); i++)
452 reg = (reg & 0xFFFF0000) | hw->fc.pause_time; 455 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
453 else
454 reg = (reg & 0x0000FFFF) | (hw->fc.pause_time << 16);
455 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(packetbuf_num / 2), reg);
456 456
457 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, (hw->fc.pause_time >> 1)); 457 /* Configure flow control refresh threshold value */
458 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
458 459
459out: 460out:
460 return ret_val; 461 return ret_val;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
index 3035f1938f5b..c7e51b85b8b6 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
@@ -84,39 +84,12 @@ static s32 ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw)
84 * 84 *
85 * Called at init time to set up flow control. 85 * Called at init time to set up flow control.
86 **/ 86 **/
87static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num) 87static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
88{ 88{
89 s32 ret_val = 0; 89 s32 ret_val = 0;
90 u32 reg = 0, reg_bp = 0; 90 u32 reg = 0, reg_bp = 0;
91 u16 reg_cu = 0; 91 u16 reg_cu = 0;
92 92
93#ifdef CONFIG_DCB
94 if (hw->fc.requested_mode == ixgbe_fc_pfc) {
95 hw->fc.current_mode = hw->fc.requested_mode;
96 goto out;
97 }
98
99#endif /* CONFIG_DCB */
100 /* Validate the packetbuf configuration */
101 if (packetbuf_num < 0 || packetbuf_num > 7) {
102 hw_dbg(hw, "Invalid packet buffer number [%d], expected range is 0-7\n",
103 packetbuf_num);
104 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
105 goto out;
106 }
107
108 /*
109 * Validate the water mark configuration. Zero water marks are invalid
110 * because it causes the controller to just blast out fc packets.
111 */
112 if (!hw->fc.low_water ||
113 !hw->fc.high_water[packetbuf_num] ||
114 !hw->fc.pause_time) {
115 hw_dbg(hw, "Invalid water mark configuration\n");
116 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
117 goto out;
118 }
119
120 /* 93 /*
121 * Validate the requested mode. Strict IEEE mode does not allow 94 * Validate the requested mode. Strict IEEE mode does not allow
122 * ixgbe_fc_rx_pause because it will cause us to fail at UNH. 95 * ixgbe_fc_rx_pause because it will cause us to fail at UNH.
@@ -139,21 +112,18 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)
139 * HW will be able to do fc autoneg once the cable is plugged in. If 112 * HW will be able to do fc autoneg once the cable is plugged in. If
140 * we link at 10G, the 1G advertisement is harmless and vice versa. 113 * we link at 10G, the 1G advertisement is harmless and vice versa.
141 */ 114 */
142
143 switch (hw->phy.media_type) { 115 switch (hw->phy.media_type) {
144 case ixgbe_media_type_fiber: 116 case ixgbe_media_type_fiber:
145 case ixgbe_media_type_backplane: 117 case ixgbe_media_type_backplane:
146 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA); 118 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA);
147 reg_bp = IXGBE_READ_REG(hw, IXGBE_AUTOC); 119 reg_bp = IXGBE_READ_REG(hw, IXGBE_AUTOC);
148 break; 120 break;
149
150 case ixgbe_media_type_copper: 121 case ixgbe_media_type_copper:
151 hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE, 122 hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE,
152 MDIO_MMD_AN, &reg_cu); 123 MDIO_MMD_AN, &reg_cu);
153 break; 124 break;
154
155 default: 125 default:
156 ; 126 break;
157 } 127 }
158 128
159 /* 129 /*
@@ -164,9 +134,6 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)
164 * 2: Tx flow control is enabled (we can send pause frames but 134 * 2: Tx flow control is enabled (we can send pause frames but
165 * we do not support receiving pause frames). 135 * we do not support receiving pause frames).
166 * 3: Both Rx and Tx flow control (symmetric) are enabled. 136 * 3: Both Rx and Tx flow control (symmetric) are enabled.
167#ifdef CONFIG_DCB
168 * 4: Priority Flow Control is enabled.
169#endif
170 * other: Invalid. 137 * other: Invalid.
171 */ 138 */
172 switch (hw->fc.requested_mode) { 139 switch (hw->fc.requested_mode) {
@@ -179,51 +146,40 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)
179 else if (hw->phy.media_type == ixgbe_media_type_copper) 146 else if (hw->phy.media_type == ixgbe_media_type_copper)
180 reg_cu &= ~(IXGBE_TAF_SYM_PAUSE | IXGBE_TAF_ASM_PAUSE); 147 reg_cu &= ~(IXGBE_TAF_SYM_PAUSE | IXGBE_TAF_ASM_PAUSE);
181 break; 148 break;
182 case ixgbe_fc_rx_pause:
183 /*
184 * Rx Flow control is enabled and Tx Flow control is
185 * disabled by software override. Since there really
186 * isn't a way to advertise that we are capable of RX
187 * Pause ONLY, we will advertise that we support both
188 * symmetric and asymmetric Rx PAUSE. Later, we will
189 * disable the adapter's ability to send PAUSE frames.
190 */
191 reg |= (IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE);
192 if (hw->phy.media_type == ixgbe_media_type_backplane)
193 reg_bp |= (IXGBE_AUTOC_SYM_PAUSE |
194 IXGBE_AUTOC_ASM_PAUSE);
195 else if (hw->phy.media_type == ixgbe_media_type_copper)
196 reg_cu |= (IXGBE_TAF_SYM_PAUSE | IXGBE_TAF_ASM_PAUSE);
197 break;
198 case ixgbe_fc_tx_pause: 149 case ixgbe_fc_tx_pause:
199 /* 150 /*
200 * Tx Flow control is enabled, and Rx Flow control is 151 * Tx Flow control is enabled, and Rx Flow control is
201 * disabled by software override. 152 * disabled by software override.
202 */ 153 */
203 reg |= (IXGBE_PCS1GANA_ASM_PAUSE); 154 reg |= IXGBE_PCS1GANA_ASM_PAUSE;
204 reg &= ~(IXGBE_PCS1GANA_SYM_PAUSE); 155 reg &= ~IXGBE_PCS1GANA_SYM_PAUSE;
205 if (hw->phy.media_type == ixgbe_media_type_backplane) { 156 if (hw->phy.media_type == ixgbe_media_type_backplane) {
206 reg_bp |= (IXGBE_AUTOC_ASM_PAUSE); 157 reg_bp |= IXGBE_AUTOC_ASM_PAUSE;
207 reg_bp &= ~(IXGBE_AUTOC_SYM_PAUSE); 158 reg_bp &= ~IXGBE_AUTOC_SYM_PAUSE;
208 } else if (hw->phy.media_type == ixgbe_media_type_copper) { 159 } else if (hw->phy.media_type == ixgbe_media_type_copper) {
209 reg_cu |= (IXGBE_TAF_ASM_PAUSE); 160 reg_cu |= IXGBE_TAF_ASM_PAUSE;
210 reg_cu &= ~(IXGBE_TAF_SYM_PAUSE); 161 reg_cu &= ~IXGBE_TAF_SYM_PAUSE;
211 } 162 }
212 break; 163 break;
164 case ixgbe_fc_rx_pause:
165 /*
166 * Rx Flow control is enabled and Tx Flow control is
167 * disabled by software override. Since there really
168 * isn't a way to advertise that we are capable of RX
169 * Pause ONLY, we will advertise that we support both
170 * symmetric and asymmetric Rx PAUSE, as such we fall
171 * through to the fc_full statement. Later, we will
172 * disable the adapter's ability to send PAUSE frames.
173 */
213 case ixgbe_fc_full: 174 case ixgbe_fc_full:
214 /* Flow control (both Rx and Tx) is enabled by SW override. */ 175 /* Flow control (both Rx and Tx) is enabled by SW override. */
215 reg |= (IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE); 176 reg |= IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE;
216 if (hw->phy.media_type == ixgbe_media_type_backplane) 177 if (hw->phy.media_type == ixgbe_media_type_backplane)
217 reg_bp |= (IXGBE_AUTOC_SYM_PAUSE | 178 reg_bp |= IXGBE_AUTOC_SYM_PAUSE |
218 IXGBE_AUTOC_ASM_PAUSE); 179 IXGBE_AUTOC_ASM_PAUSE;
219 else if (hw->phy.media_type == ixgbe_media_type_copper) 180 else if (hw->phy.media_type == ixgbe_media_type_copper)
220 reg_cu |= (IXGBE_TAF_SYM_PAUSE | IXGBE_TAF_ASM_PAUSE); 181 reg_cu |= IXGBE_TAF_SYM_PAUSE | IXGBE_TAF_ASM_PAUSE;
221 break;
222#ifdef CONFIG_DCB
223 case ixgbe_fc_pfc:
224 goto out;
225 break; 182 break;
226#endif /* CONFIG_DCB */
227 default: 183 default:
228 hw_dbg(hw, "Flow control param set incorrectly\n"); 184 hw_dbg(hw, "Flow control param set incorrectly\n");
229 ret_val = IXGBE_ERR_CONFIG; 185 ret_val = IXGBE_ERR_CONFIG;
@@ -298,7 +254,7 @@ s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)
298 IXGBE_WRITE_FLUSH(hw); 254 IXGBE_WRITE_FLUSH(hw);
299 255
300 /* Setup flow control */ 256 /* Setup flow control */
301 ixgbe_setup_fc(hw, 0); 257 ixgbe_setup_fc(hw);
302 258
303 /* Clear adapter stopped flag */ 259 /* Clear adapter stopped flag */
304 hw->adapter_stopped = false; 260 hw->adapter_stopped = false;
@@ -2126,28 +2082,36 @@ s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw)
2126/** 2082/**
2127 * ixgbe_fc_enable_generic - Enable flow control 2083 * ixgbe_fc_enable_generic - Enable flow control
2128 * @hw: pointer to hardware structure 2084 * @hw: pointer to hardware structure
2129 * @packetbuf_num: packet buffer number (0-7)
2130 * 2085 *
2131 * Enable flow control according to the current settings. 2086 * Enable flow control according to the current settings.
2132 **/ 2087 **/
2133s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw, s32 packetbuf_num) 2088s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)
2134{ 2089{
2135 s32 ret_val = 0; 2090 s32 ret_val = 0;
2136 u32 mflcn_reg, fccfg_reg; 2091 u32 mflcn_reg, fccfg_reg;
2137 u32 reg; 2092 u32 reg;
2138 u32 fcrtl, fcrth; 2093 u32 fcrtl, fcrth;
2094 int i;
2139 2095
2140#ifdef CONFIG_DCB 2096 /*
2141 if (hw->fc.requested_mode == ixgbe_fc_pfc) 2097 * Validate the water mark configuration for packet buffer 0. Zero
2098 * water marks indicate that the packet buffer was not configured
2099 * and the watermarks for packet buffer 0 should always be configured.
2100 */
2101 if (!hw->fc.low_water ||
2102 !hw->fc.high_water[0] ||
2103 !hw->fc.pause_time) {
2104 hw_dbg(hw, "Invalid water mark configuration\n");
2105 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
2142 goto out; 2106 goto out;
2107 }
2143 2108
2144#endif /* CONFIG_DCB */
2145 /* Negotiate the fc mode to use */ 2109 /* Negotiate the fc mode to use */
2146 ixgbe_fc_autoneg(hw); 2110 ixgbe_fc_autoneg(hw);
2147 2111
2148 /* Disable any previous flow control settings */ 2112 /* Disable any previous flow control settings */
2149 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN); 2113 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
2150 mflcn_reg &= ~(IXGBE_MFLCN_RFCE | IXGBE_MFLCN_RPFCE); 2114 mflcn_reg &= ~(IXGBE_MFLCN_RPFCE_MASK | IXGBE_MFLCN_RFCE);
2151 2115
2152 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG); 2116 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
2153 fccfg_reg &= ~(IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY); 2117 fccfg_reg &= ~(IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY);
@@ -2160,9 +2124,6 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw, s32 packetbuf_num)
2160 * 2: Tx flow control is enabled (we can send pause frames but 2124 * 2: Tx flow control is enabled (we can send pause frames but
2161 * we do not support receiving pause frames). 2125 * we do not support receiving pause frames).
2162 * 3: Both Rx and Tx flow control (symmetric) are enabled. 2126 * 3: Both Rx and Tx flow control (symmetric) are enabled.
2163#ifdef CONFIG_DCB
2164 * 4: Priority Flow Control is enabled.
2165#endif
2166 * other: Invalid. 2127 * other: Invalid.
2167 */ 2128 */
2168 switch (hw->fc.current_mode) { 2129 switch (hw->fc.current_mode) {
@@ -2195,11 +2156,6 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw, s32 packetbuf_num)
2195 mflcn_reg |= IXGBE_MFLCN_RFCE; 2156 mflcn_reg |= IXGBE_MFLCN_RFCE;
2196 fccfg_reg |= IXGBE_FCCFG_TFCE_802_3X; 2157 fccfg_reg |= IXGBE_FCCFG_TFCE_802_3X;
2197 break; 2158 break;
2198#ifdef CONFIG_DCB
2199 case ixgbe_fc_pfc:
2200 goto out;
2201 break;
2202#endif /* CONFIG_DCB */
2203 default: 2159 default:
2204 hw_dbg(hw, "Flow control param set incorrectly\n"); 2160 hw_dbg(hw, "Flow control param set incorrectly\n");
2205 ret_val = IXGBE_ERR_CONFIG; 2161 ret_val = IXGBE_ERR_CONFIG;
@@ -2212,34 +2168,34 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw, s32 packetbuf_num)
2212 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg); 2168 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg);
2213 IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg); 2169 IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg);
2214 2170
2215 fcrtl = hw->fc.low_water << 10; 2171 fcrtl = (hw->fc.low_water << 10) | IXGBE_FCRTL_XONE;
2216 2172
2217 if (hw->fc.current_mode & ixgbe_fc_tx_pause) { 2173 /* Set up and enable Rx high/low water mark thresholds, enable XON. */
2218 fcrth = hw->fc.high_water[packetbuf_num] << 10; 2174 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
2219 fcrth |= IXGBE_FCRTH_FCEN; 2175 if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
2220 if (hw->fc.send_xon) 2176 hw->fc.high_water[i]) {
2221 fcrtl |= IXGBE_FCRTL_XONE; 2177 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), fcrtl);
2222 } else { 2178 fcrth = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN;
2223 /* 2179 } else {
2224 * If Tx flow control is disabled, set our high water mark 2180 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), 0);
2225 * to Rx FIFO size minus 32 in order prevent Tx switch 2181 /*
2226 * loopback from stalling on DMA. 2182 * In order to prevent Tx hangs when the internal Tx
2227 */ 2183 * switch is enabled we must set the high water mark
2228 fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(packetbuf_num)) - 32; 2184 * to the maximum FCRTH value. This allows the Tx
2229 } 2185 * switch to function even under heavy Rx workloads.
2186 */
2187 fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i)) - 32;
2188 }
2230 2189
2231 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(packetbuf_num), fcrth); 2190 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(i), fcrth);
2232 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(packetbuf_num), fcrtl); 2191 }
2233 2192
2234 /* Configure pause time (2 TCs per register) */ 2193 /* Configure pause time (2 TCs per register) */
2235 reg = IXGBE_READ_REG(hw, IXGBE_FCTTV(packetbuf_num / 2)); 2194 reg = hw->fc.pause_time * 0x00010001;
2236 if ((packetbuf_num & 1) == 0) 2195 for (i = 0; i < (MAX_TRAFFIC_CLASS / 2); i++)
2237 reg = (reg & 0xFFFF0000) | hw->fc.pause_time; 2196 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
2238 else
2239 reg = (reg & 0x0000FFFF) | (hw->fc.pause_time << 16);
2240 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(packetbuf_num / 2), reg);
2241 2197
2242 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, (hw->fc.pause_time >> 1)); 2198 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
2243 2199
2244out: 2200out:
2245 return ret_val; 2201 return ret_val;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
index 9e8a1c05df6e..6222fdb3d3f1 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
@@ -77,7 +77,7 @@ s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw);
77s32 ixgbe_disable_rx_buff_generic(struct ixgbe_hw *hw); 77s32 ixgbe_disable_rx_buff_generic(struct ixgbe_hw *hw);
78s32 ixgbe_enable_rx_buff_generic(struct ixgbe_hw *hw); 78s32 ixgbe_enable_rx_buff_generic(struct ixgbe_hw *hw);
79s32 ixgbe_enable_rx_dma_generic(struct ixgbe_hw *hw, u32 regval); 79s32 ixgbe_enable_rx_dma_generic(struct ixgbe_hw *hw, u32 regval);
80s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw, s32 packetbuf_num); 80s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw);
81void ixgbe_fc_autoneg(struct ixgbe_hw *hw); 81void ixgbe_fc_autoneg(struct ixgbe_hw *hw);
82 82
83s32 ixgbe_validate_mac_addr(u8 *mac_addr); 83s32 ixgbe_validate_mac_addr(u8 *mac_addr);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c
index 888a419dc3d9..65913c5a616e 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c
@@ -278,18 +278,7 @@ s32 ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw, u8 pfc_en, u8 *prio_tc)
278 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, reg); 278 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, reg);
279 279
280 } else { 280 } else {
281 /* X540 devices have a RX bit that should be cleared 281 hw->mac.ops.fc_enable(hw);
282 * if PFC is disabled on all TCs but PFC features is
283 * enabled.
284 */
285 if (hw->mac.type == ixgbe_mac_X540) {
286 reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
287 reg &= ~IXGBE_MFLCN_RPFCE_MASK;
288 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, reg);
289 }
290
291 for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
292 hw->mac.ops.fc_enable(hw, i);
293 } 282 }
294 283
295 return 0; 284 return 0;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index c2ceda9133ba..b2daff3b3328 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -5250,7 +5250,7 @@ static void ixgbe_watchdog_update_link(struct ixgbe_adapter *adapter)
5250 struct ixgbe_hw *hw = &adapter->hw; 5250 struct ixgbe_hw *hw = &adapter->hw;
5251 u32 link_speed = adapter->link_speed; 5251 u32 link_speed = adapter->link_speed;
5252 bool link_up = adapter->link_up; 5252 bool link_up = adapter->link_up;
5253 int i; 5253 bool pfc_en = adapter->dcb_cfg.pfc_mode_enable;
5254 5254
5255 if (!(adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE)) 5255 if (!(adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE))
5256 return; 5256 return;
@@ -5262,14 +5262,12 @@ static void ixgbe_watchdog_update_link(struct ixgbe_adapter *adapter)
5262 link_speed = IXGBE_LINK_SPEED_10GB_FULL; 5262 link_speed = IXGBE_LINK_SPEED_10GB_FULL;
5263 link_up = true; 5263 link_up = true;
5264 } 5264 }
5265 if (link_up) { 5265
5266 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { 5266 if (adapter->ixgbe_ieee_pfc)
5267 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) 5267 pfc_en |= !!(adapter->ixgbe_ieee_pfc->pfc_en);
5268 hw->mac.ops.fc_enable(hw, i); 5268
5269 } else { 5269 if (link_up && !((adapter->flags & IXGBE_FLAG_DCB_ENABLED) && pfc_en))
5270 hw->mac.ops.fc_enable(hw, 0); 5270 hw->mac.ops.fc_enable(hw);
5271 }
5272 }
5273 5271
5274 if (link_up || 5272 if (link_up ||
5275 time_after(jiffies, (adapter->link_check_timeout + 5273 time_after(jiffies, (adapter->link_check_timeout +
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 5337260bed5b..5e64c77255e9 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -1892,7 +1892,7 @@ enum {
1892#define IXGBE_MFLCN_DPF 0x00000002 /* Discard Pause Frame */ 1892#define IXGBE_MFLCN_DPF 0x00000002 /* Discard Pause Frame */
1893#define IXGBE_MFLCN_RPFCE 0x00000004 /* Receive Priority FC Enable */ 1893#define IXGBE_MFLCN_RPFCE 0x00000004 /* Receive Priority FC Enable */
1894#define IXGBE_MFLCN_RFCE 0x00000008 /* Receive FC Enable */ 1894#define IXGBE_MFLCN_RFCE 0x00000008 /* Receive FC Enable */
1895#define IXGBE_MFLCN_RPFCE_MASK 0x00000FF0 /* Receive FC Mask */ 1895#define IXGBE_MFLCN_RPFCE_MASK 0x00000FF4 /* Receive FC Mask */
1896 1896
1897#define IXGBE_MFLCN_RPFCE_SHIFT 4 1897#define IXGBE_MFLCN_RPFCE_SHIFT 4
1898 1898
@@ -2808,7 +2808,7 @@ struct ixgbe_mac_operations {
2808 void (*set_vlan_anti_spoofing)(struct ixgbe_hw *, bool, int); 2808 void (*set_vlan_anti_spoofing)(struct ixgbe_hw *, bool, int);
2809 2809
2810 /* Flow Control */ 2810 /* Flow Control */
2811 s32 (*fc_enable)(struct ixgbe_hw *, s32); 2811 s32 (*fc_enable)(struct ixgbe_hw *);
2812 2812
2813 /* Manageability interface */ 2813 /* Manageability interface */
2814 s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8); 2814 s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8);